8 SkillTreeWidget::skillSelectionChanged(QTreeWidgetItem* current,
int)
16 auto c =
dynamic_cast<SkillTreeWidgetItem*
>(current);
30 setSortingEnabled(
false);
34 while (i < this->topLevelItemCount())
36 auto* providerItem = this->topLevelItem(i);
37 auto providerName = providerItem->text(0).toStdString();
42 providerItem =
nullptr;
43 auto remove = this->takeTopLevelItem(i);
52 auto& providedSkills =
update.at(providerId);
55 while (j < providerItem->childCount())
57 auto* skillItem = providerItem->child(j);
58 auto skillName = skillItem->text(0).toStdString();
62 .skillName = skillName};
64 if (providedSkills.find(skillId) == providedSkills.end())
67 auto remove = providerItem->takeChild(j);
77 for (
const auto& [providerId, providedSkills] :
update)
79 bool newProvider =
false;
80 QTreeWidgetItem* providerItem =
nullptr;
81 for (
int i = 0; i < this->topLevelItemCount(); ++i)
83 auto el = this->topLevelItem(i);
84 auto providerName = el->text(0).toStdString();
87 if (providerId == elProviderId)
96 providerItem =
new QTreeWidgetItem(
this);
97 providerItem->setText(0, QString::fromStdString(providerId.providerName));
102 for (
const auto& [skillId, skill] : providedSkills)
104 QTreeWidgetItem* skillItem =
nullptr;
105 for (
int i = 0; i < providerItem->childCount(); ++i)
107 auto el = providerItem->child(i);
108 auto skillName = el->text(0).toStdString();
111 if (skillId == elSkillId)
121 skillItem->setText(0, QString::fromStdString(skillId.skillName));
125 if (newProvider && PROVIDER_EXPANDED_DEFAULT)
127 providerItem->setExpanded(
true);
131 setSortingEnabled(
true);
132 sortByColumn(0, Qt::AscendingOrder);
133 sortByColumn(1, Qt::AscendingOrder);
144 SkillTreeWidget::setupUi()
146 this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
148 QTreeWidgetItem* qtreewidgetitem = this->headerItem();
150 qtreewidgetitem->setText(0,
"Skill");
156 SkillTreeWidget::connectSignals()
160 connect(
this, &QTreeWidget::itemClicked,
this, &SkillTreeWidget::skillSelectionChanged);