Utils: Introduce a class template TypedTreeItem

For better typesafety on the user side (and optional) for items with uniformly
typed children.  Use it for UniformTreeModels, and consequently WatchModel
to get rid of some of the static_casts there.

Change-Id: Ic20e507036e180c24997b236230f0f71b285202c
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
hjk
2016-06-09 15:26:33 +02:00
parent a823caa396
commit e2ba0aca9b
5 changed files with 36 additions and 23 deletions

View File

@@ -2418,9 +2418,8 @@ void QmlEnginePrivate::insertSubItems(WatchItem *parent, const QVariantList &pro
}
if (boolSetting(SortStructMembers)) {
parent->sortChildren([](const TreeItem *item1, const TreeItem *item2) -> bool {
return static_cast<const WatchItem *>(item1)->name
< static_cast<const WatchItem *>(item2)->name;
parent->sortChildren([](const WatchItem *item1, const WatchItem *item2) {
return item1->name < item2->name;
});
}