| 428 | } |
| 429 | |
| 430 | TagNode *LabelModel::insertNode(TagNode *parent, const QString &strPath, int count, TagNode::TagType type, char split) |
| 431 | { |
| 432 | auto titles(QStringView(strPath).split(split, Qt::SkipEmptyParts)); |
| 433 | //auto titles(strPath.splitRef(split, QString::SkipEmptyParts)); |
| 434 | if(titles.size()==0) return parent; |
| 435 | TagNode *current = parent; |
| 436 | QString curPath; |
| 437 | bool titleStart = strPath.startsWith(split); |
| 438 | for(auto &title : titles) |
| 439 | { |
| 440 | if(!curPath.isEmpty() || titleStart) curPath.append(split); |
| 441 | curPath.append(title); |
| 442 | if(!current->subNodes) current->subNodes = new QVector<TagNode *>; |
| 443 | auto iter = std::find_if(current->subNodes->begin(), current->subNodes->end(), [=](TagNode *node){return node->tagTitle == title;}); |
| 444 | TagNode *next = nullptr; |
| 445 | if(iter == current->subNodes->end()) |
| 446 | { |
| 447 | next = new TagNode(title.toString(), current, 0, type); |
| 448 | next->tagFilter = curPath; |
| 449 | } |
| 450 | else |
| 451 | { |
| 452 | next = *iter; |
| 453 | } |
| 454 | current->animeCount += count; |
| 455 | current = next; |
| 456 | } |
| 457 | current->animeCount += count; |
| 458 | return current; |
| 459 | |
| 460 | } |
| 461 | |
| 462 | TagNode *LabelModel::insertNodeIndex(TagNode *parent, const QString &strPath, int count, TagNode::TagType type, char split) |
| 463 | { |