TreeModel: Take responsibility for some of the casting

This adds a templated layer on top of TreeModel that can specify
item types for the top three layers in the model, relieving user
code from some of the previously necessary type casting.

Two common setups get an extra layer with convenience functions
on top: TwoLevelTreeModel for two-level model with a first level
of static headers and a uniform second level, and UniformTreeModel
where all non-root nodes are the same.

"Untyped" plain TreeModels are still possible.

The walkTree() feature and untyped iteration in the base
TreeItem and TreeModel is retained for now to ease transition
in downstream modules, but is planned to be removed soon.

Change-Id: I67d75a1a4e18e8f254dbfb458db03510d8990d8b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
hjk
2016-05-27 11:12:03 +02:00
parent ded0b1c4f5
commit 7a80f2f01e
13 changed files with 267 additions and 130 deletions

View File

@@ -657,18 +657,6 @@ QString WatchItem::expression() const
return name;
}
WatchItem *WatchItem::findItem(const QByteArray &iname)
{
if (internalName() == iname)
return this;
foreach (TreeItem *child, children()) {
auto witem = static_cast<WatchItem *>(child);
if (WatchItem *result = witem->findItem(iname))
return result;
}
return 0;
}
} // namespace Internal
} // namespace Debugger