forked from qt-creator/qt-creator
ProjectExplorer: Use LeveledTreeModel for ToolChainModel
More typesafety. This also reveals recently introduced mis-counting of levels. Change-Id: I8d90bab57c7122ca08ec2980f4a35fd80db802b3 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -198,7 +198,7 @@ public:
|
|||||||
void apply();
|
void apply();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TreeModel m_model;
|
LeveledTreeModel<TreeItem, ToolChainTreeItem> m_model;
|
||||||
QList<ToolChainFactory *> m_factories;
|
QList<ToolChainFactory *> m_factories;
|
||||||
QTreeView *m_toolChainView;
|
QTreeView *m_toolChainView;
|
||||||
DetailsWidget *m_container;
|
DetailsWidget *m_container;
|
||||||
@@ -252,7 +252,7 @@ void ToolChainOptionsWidget::removeToolChain(ToolChain *tc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto item = m_model.findItemAtLevel<ToolChainTreeItem *>(1, [tc](ToolChainTreeItem *item) {
|
auto item = m_model.findSecondLevelItem([tc](ToolChainTreeItem *item) {
|
||||||
return tc->isAutoDetected() && item->toolChain == tc;
|
return tc->isAutoDetected() && item->toolChain == tc;
|
||||||
});
|
});
|
||||||
delete m_model.takeItem(item);
|
delete m_model.takeItem(item);
|
||||||
@@ -284,7 +284,7 @@ void ToolChainOptionsWidget::apply()
|
|||||||
Q_ASSERT(m_toRemoveList.isEmpty());
|
Q_ASSERT(m_toRemoveList.isEmpty());
|
||||||
|
|
||||||
// Update tool chains:
|
// Update tool chains:
|
||||||
m_model.forEachItemAtLevel<ToolChainTreeItem *>(1, [this](ToolChainTreeItem *item) {
|
m_model.forSecondLevelItems([this](ToolChainTreeItem *item) {
|
||||||
if (item->parent() == m_manualRoot && item->changed) {
|
if (item->parent() == m_manualRoot && item->changed) {
|
||||||
Q_ASSERT(item->toolChain);
|
Q_ASSERT(item->toolChain);
|
||||||
if (item->widget)
|
if (item->widget)
|
||||||
|
Reference in New Issue
Block a user