| 460 | } |
| 461 | |
| 462 | TagNode *LabelModel::insertNodeIndex(TagNode *parent, const QString &strPath, int count, TagNode::TagType type, char split) |
| 463 | { |
| 464 | auto titles(QStringView(strPath).split(split, Qt::SkipEmptyParts)); |
| 465 | //auto titles(strPath.splitRef(split, Qt::SkipEmptyParts)); |
| 466 | if(titles.size()==0) return parent; |
| 467 | TagNode *current = parent; |
| 468 | QModelIndex currentIndex; |
| 469 | if(current->parent) currentIndex = createIndex(current->parent->subNodes->indexOf(current), 0, current); |
| 470 | current->animeCount += count; |
| 471 | emit dataChanged(currentIndex, currentIndex); |
| 472 | QString curPath; |
| 473 | bool titleStart = strPath.startsWith(split); |
| 474 | for(auto &title : titles) |
| 475 | { |
| 476 | if(!curPath.isEmpty() || titleStart) curPath.append(split); |
| 477 | curPath.append(title); |
| 478 | if(!current->subNodes) |
| 479 | { |
| 480 | current->subNodes = new QVector<TagNode *>; |
| 481 | emit dataChanged(currentIndex, currentIndex); |
| 482 | } |
| 483 | auto iter = std::find_if(current->subNodes->begin(), current->subNodes->end(), [=](TagNode *node){return node->tagTitle == title;}); |
| 484 | TagNode *next = nullptr; |
| 485 | if(iter == current->subNodes->end()) |
| 486 | { |
| 487 | beginInsertRows(currentIndex, current->subNodes->count(), current->subNodes->count()); |
| 488 | next = new TagNode(title.toString(), current, 0, type); |
| 489 | next->animeCount += count; |
| 490 | next->tagFilter = curPath; |
| 491 | endInsertRows(); |
| 492 | currentIndex = index(current->subNodes->count()-1, 0, currentIndex); |
| 493 | } |
| 494 | else |
| 495 | { |
| 496 | next = *iter; |
| 497 | next->animeCount += count; |
| 498 | currentIndex = index(iter - current->subNodes->begin(), 0, currentIndex); |
| 499 | emit dataChanged(currentIndex, currentIndex); |
| 500 | } |
| 501 | current = next; |
| 502 | } |
| 503 | return current; |
| 504 | } |
| 505 | |
| 506 | void LabelModel::removeNodeIndex(TagNode *parent, const QString &strPath, bool removeAll, char split) |
| 507 | { |