KDEUI
krecursivefilterproxymodel.cpp
Go to the documentation of this file.
28 // If they are removed, then layout{AboutToBe}Changed signals should be used when the source model
30 // because layout{AboutToBe}Changed is expensive and causes the entire mapping of the tree in QSFPM
48 // Convenience methods for invoking the QSFPM slots. Those slots must be invoked with invokeMethod
74 bool success = QMetaObject::invokeMethod(q, "_q_sourceRowsAboutToBeInserted", Qt::DirectConnection,
96 bool success = QMetaObject::invokeMethod(q, "_q_sourceRowsAboutToBeRemoved", Qt::DirectConnection,
104 void sourceDataChanged(const QModelIndex &source_top_left, const QModelIndex &source_bottom_right);
123 void KRecursiveFilterProxyModelPrivate::sourceDataChanged(const QModelIndex &source_top_left, const QModelIndex &source_bottom_right)
149 void KRecursiveFilterProxyModelPrivate::refreshAscendantMapping(const QModelIndex &index, bool refreshAll)
156 // We need to tell the QSortFilterProxyModel that the first child between an existing row in the model
165 void KRecursiveFilterProxyModelPrivate::sourceRowsAboutToBeInserted(const QModelIndex &source_parent, int start, int end)
169 if (!source_parent.isValid() || q->filterAcceptsRow(source_parent.row(), source_parent.parent()))
176 void KRecursiveFilterProxyModelPrivate::sourceRowsInserted(const QModelIndex &source_parent, int start, int end)
207 void KRecursiveFilterProxyModelPrivate::sourceRowsAboutToBeRemoved(const QModelIndex &source_parent, int start, int end)
211 if (source_parent.isValid() && q->filterAcceptsRow(source_parent.row(), source_parent.parent()))
237 void KRecursiveFilterProxyModelPrivate::sourceRowsRemoved(const QModelIndex &source_parent, int start, int end)
244 // fall through. After removing rows, we need to refresh things so that intermediates will be removed too if necessary.
271 bool KRecursiveFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const
273 // TODO: Implement some caching so that if one match is found on the first pass, we can return early results
284 accepted = true; // Need to do this in a loop so that all siblings in a parent get processed, not just the first.
289 QModelIndexList KRecursiveFilterProxyModel::match( const QModelIndex& start, int role, const QVariant& value, int hits, Qt::MatchFlags flags ) const
296 foreach ( const QModelIndex &idx, sourceModel()->match( mapToSource( start ), role, value, hits, flags ) ) {
305 bool KRecursiveFilterProxyModel::acceptRow(int sourceRow, const QModelIndex& sourceParent) const
385 // Instead we connect the sourceModel signal to our own slot in *this (sourceRowsAboutToBeInserted)
386 // Inside that method, the entire new subtree is queried (J, K *and* L) to see if there is a match,
389 // it matches the filter. It did not before, because L did not exist before. Now it does. That is
390 // achieved by telling the QSFPM that the data changed for H, which causes it to requery this class
virtual QModelIndexList match(const QModelIndex &start, int role, const QVariant &value, int hits=1, Qt::MatchFlags flags=Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const
Definition: krecursivefilterproxymodel.cpp:289
virtual bool acceptRow(int sourceRow, const QModelIndex &sourceParent) const
Reimplement this method for custom filtering strategies.
Definition: krecursivefilterproxymodel.cpp:305
Implements recursive filtering of models.
Definition: krecursivefilterproxymodel.h:87
KRecursiveFilterProxyModel(QObject *parent=0)
Constructor.
Definition: krecursivefilterproxymodel.cpp:260
KRecursiveFilterProxyModelPrivate *const d_ptr
Definition: krecursivefilterproxymodel.h:121
void setSourceModel(QAbstractItemModel *model)
Definition: krecursivefilterproxymodel.cpp:310
This file is part of the KDE documentation.
Documentation copyright © 1996-2018 The KDE developers.
Generated on Fri Oct 19 2018 17:20:37 by doxygen 1.8.13 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2018 The KDE developers.
Generated on Fri Oct 19 2018 17:20:37 by doxygen 1.8.13 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.