Commit 1ce258d7 authored by hjk's avatar hjk

Debugger/Utils: Remove TwoLevelTreeModel

It's well covered by the more generic Utils::LeveledTreeModel now.

Change-Id: I3982ad39a64742b0a0a59433024457db3808bfc7
Reviewed-by: Christian Stenger's avatarChristian Stenger <christian.stenger@qt.io>
parent 6bd7c3ef
......@@ -279,24 +279,6 @@ public:
}
};
// A two-level model with a first level of static headers and a uniform second level.
template <class SecondLevelItemType>
class TwoLevelTreeModel : public LeveledTreeModel<StaticTreeItem, SecondLevelItemType>
{
public:
using FirstLevelItem = StaticTreeItem;
using SecondLevelItem = SecondLevelItemType;
using BaseType = LeveledTreeModel<FirstLevelItem, SecondLevelItem>;
explicit TwoLevelTreeModel(QObject *parent = 0) : BaseType(parent) {}
FirstLevelItem *appendFirstLevelItem(const QStringList &display) {
auto item = new FirstLevelItem(display);
this->rootItem()->appendChild(item);
return item;
}
};
// A model where all non-root nodes are the same.
template <class ItemType>
class UniformTreeModel : public LeveledTreeModel<ItemType, ItemType, ItemType>
......
......@@ -99,7 +99,7 @@ public:
// DebuggerItemModel
// --------------------------------------------------------------------------
class DebuggerItemModel : public TwoLevelTreeModel<DebuggerTreeItem>
class DebuggerItemModel : public LeveledTreeModel<StaticTreeItem, DebuggerTreeItem>
{
Q_DECLARE_TR_FUNCTIONS(Debugger::DebuggerOptionsPage)
......@@ -115,18 +115,17 @@ public:
void apply();
private:
DebuggerTreeItem *m_currentTreeItem;
DebuggerTreeItem *m_currentTreeItem = nullptr;
QStringList removed;
QList<QVariant> m_removedItems;
};
DebuggerItemModel::DebuggerItemModel()
: m_currentTreeItem(0)
{
setHeader({ tr("Name"), tr("Location"), tr("Type") });
appendFirstLevelItem({ tr("Auto-detected") });
appendFirstLevelItem({ tr("Manual") });
rootItem()->appendChild(new StaticTreeItem(tr("Auto-detected")));
rootItem()->appendChild(new StaticTreeItem(tr("Manual")));
foreach (const DebuggerItem &item, DebuggerItemManager::debuggers())
addDebugger(item, false);
}
......@@ -134,7 +133,7 @@ DebuggerItemModel::DebuggerItemModel()
void DebuggerItemModel::addDebugger(const DebuggerItem &item, bool changed)
{
int group = item.isAutoDetected() ? 0 : 1;
rootItem()->child(group)->appendChild(new DebuggerTreeItem(item, changed));
rootItem()->childAt(group)->appendChild(new DebuggerTreeItem(item, changed));
}
void DebuggerItemModel::updateDebugger(const DebuggerItem &item)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment