Add missing hasChildren() implementation.

Summary:
QAbstractProxyModel forwards hasChildren() to the source model, which
will return a wrong value for our tree-restructuring model. Current
views/proxies don't call hasChildren(), which is how this oversight
happened, but implementing it improves model hygiene - could blow up
in the future otherwise.

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1799
wilder-5.14
Eike Hein 10 years ago
parent 84671a0813
commit 2d7b6692d3
  1. 9
      libtaskmanager/taskgroupingproxymodel.cpp
  2. 1
      libtaskmanager/taskgroupingproxymodel.h

@ -599,6 +599,15 @@ int TaskGroupingProxyModel::rowCount(const QModelIndex &parent) const
return d->rowMap.count();
}
bool TaskGroupingProxyModel::hasChildren(const QModelIndex &parent) const
{
if ((parent.model() && parent.model() != this) || !sourceModel()) {
return false;
}
return rowCount(parent);
}
int TaskGroupingProxyModel::columnCount(const QModelIndex &parent) const
{
Q_UNUSED(parent)

@ -62,6 +62,7 @@ public:
QModelIndex mapToSource(const QModelIndex &proxyIndex) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
bool hasChildren(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &proxyIndex, int role) const override;

Loading…
Cancel
Save