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

@@ -394,15 +394,12 @@ public:
quint64 addrstep;
};
static bool sortByName(const Utils::TreeItem *a, const Utils::TreeItem *b)
static bool sortByName(const WatchItem *a, const WatchItem *b)
{
auto aa = static_cast<const WatchItem *>(a);
auto bb = static_cast<const WatchItem *>(b);
if (a->sortGroup != b->sortGroup)
return a->sortGroup > b->sortGroup;
if (aa->sortGroup != bb->sortGroup)
return aa->sortGroup > bb->sortGroup;
return aa->name < bb->name;
return a->name < b->name;
}
void WatchItem::parseHelper(const GdbMi &input, bool maySort)