From 3a3545ac93e0b310dfb6c6da5f83df1f26dff8a6 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 15 Jun 2016 07:48:05 +0200 Subject: Automatically fetch children if necessary. Otherwise a treeview doesn't show the expander until you click on the item (which triggers fetchMore). --- common/modelresult.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'common') diff --git a/common/modelresult.cpp b/common/modelresult.cpp index d13f867..9f3e662 100644 --- a/common/modelresult.cpp +++ b/common/modelresult.cpp @@ -155,6 +155,13 @@ bool ModelResult::hasChildren(const QModelIndex &parent) const if (mQuery.parentProperty.isEmpty() && parent.isValid()) { return false; } + //Figure out whether we have children + if (canFetchMore(parent)) { + //Since we don't retrieve that information as part of the entity, + //we have to query for the children to see if we have some + auto p = const_cast*>(this); + p->fetchMore(parent); + } return QAbstractItemModel::hasChildren(parent); } -- cgit v1.2.3