aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/utils
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2018-05-02 09:15:49 +0200
committerChristian Stenger <christian.stenger@qt.io>2018-05-02 12:58:28 +0000
commitc46b6dbb5661e9f3d16310da381909376e8e9a6b (patch)
treedff915f1994df03b0315cbc92719122c5efc99a3 /src/libs/utils
parent147e6078ad8c6a59a87789ad5bbfad196345286c (diff)
Utils: Fix treemodel's hasChildren
Basically this reverts 08e73d1a9336, but adds an additional check for the column as the BaseTreeModel implementation just allows children at the first column. Main reason for this revert is that the variable choosers used across Qt Creator did no more populate their respective macro lists automatically. Change-Id: I172506a9dbe18f20b152ec797f35feff717dc3cf Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'src/libs/utils')
-rw-r--r--src/libs/utils/treemodel.cpp8
-rw-r--r--src/libs/utils/treemodel.h1
2 files changed, 9 insertions, 0 deletions
diff --git a/src/libs/utils/treemodel.cpp b/src/libs/utils/treemodel.cpp
index 0493a67a4a..d17174a024 100644
--- a/src/libs/utils/treemodel.cpp
+++ b/src/libs/utils/treemodel.cpp
@@ -1028,6 +1028,14 @@ QVariant BaseTreeModel::headerData(int section, Qt::Orientation orientation,
return QVariant();
}
+bool BaseTreeModel::hasChildren(const QModelIndex &idx) const
+{
+ if (idx.column() > 0)
+ return false;
+ TreeItem *item = itemForIndex(idx);
+ return !item || item->hasChildren();
+}
+
Qt::ItemFlags BaseTreeModel::flags(const QModelIndex &idx) const
{
if (!idx.isValid())
diff --git a/src/libs/utils/treemodel.h b/src/libs/utils/treemodel.h
index fd299bd945..930f6f5e2e 100644
--- a/src/libs/utils/treemodel.h
+++ b/src/libs/utils/treemodel.h
@@ -193,6 +193,7 @@ protected:
QModelIndex sibling(int row, int column, const QModelIndex &idx) const override;
Qt::ItemFlags flags(const QModelIndex &idx) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
+ bool hasChildren(const QModelIndex &idx) const override;
bool canFetchMore(const QModelIndex &idx) const override;
void fetchMore(const QModelIndex &idx) override;