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
46 // Convenience methods for invoking the QSFPM slots. Those slots must be invoked with invokeMethod
72 bool success = QMetaObject::invokeMethod(q, "_q_sourceRowsAboutToBeInserted", Qt::DirectConnection,
94 bool success = QMetaObject::invokeMethod(q, "_q_sourceRowsAboutToBeRemoved", Qt::DirectConnection,
102 void sourceDataChanged(const QModelIndex &source_top_left, const QModelIndex &source_bottom_right);
120 void KRecursiveFilterProxyModelPrivate::sourceDataChanged(const QModelIndex &source_top_left, const QModelIndex &source_bottom_right)
123 Q_ASSERT(source_bottom_right.parent() == source_parent); // don't know how to handle different parents in this code...
128 // We can't find out if the change really matters to us or not, for a lack of a dataAboutToBeChanged signal (or a cache).
156 void KRecursiveFilterProxyModelPrivate::sourceRowsAboutToBeInserted(const QModelIndex &source_parent, int start, int end)
160 if (!source_parent.isValid() || q->filterAcceptsRow(source_parent.row(), source_parent.parent()))
162 // If the parent is already in the model (directly or indirectly), we can just pass on the signal.
172 void KRecursiveFilterProxyModelPrivate::sourceRowsInserted(const QModelIndex &source_parent, int start, int end)
204 void KRecursiveFilterProxyModelPrivate::sourceRowsAboutToBeRemoved(const QModelIndex &source_parent, int start, int end)
209 void KRecursiveFilterProxyModelPrivate::sourceRowsRemoved(const QModelIndex &source_parent, int start, int end)
245 bool KRecursiveFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const
247 // TODO: Implement some caching so that if one match is found on the first pass, we can return early results
266 QModelIndexList KRecursiveFilterProxyModel::match( const QModelIndex& start, int role, const QVariant& value, int hits, Qt::MatchFlags flags ) const
273 foreach ( const QModelIndex &idx, sourceModel()->match( mapToSource( start ), role, value, hits, flags ) ) {
282 bool KRecursiveFilterProxyModel::acceptRow(int sourceRow, const QModelIndex& sourceParent) const
362 // Instead we connect the sourceModel signal to our own slot in *this (sourceRowsAboutToBeInserted)
363 // Inside that method, the entire new subtree is queried (J, K *and* L) to see if there is a match,
366 // it matches the filter. It did not before, because L did not exist before. Now it does. That is
367 // 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
@reimplemented
Definition: krecursivefilterproxymodel.cpp:266
virtual bool acceptRow(int sourceRow, const QModelIndex &sourceParent) const
Reimplement this method for custom filtering strategies.
Definition: krecursivefilterproxymodel.cpp:282
Implements recursive filtering of models.
Definition: krecursivefilterproxymodel.h:87
KRecursiveFilterProxyModel(QObject *parent=0)
Constructor.
Definition: krecursivefilterproxymodel.cpp:234
KRecursiveFilterProxyModelPrivate *const d_ptr
Definition: krecursivefilterproxymodel.h:121
void setSourceModel(QAbstractItemModel *model)
Definition: krecursivefilterproxymodel.cpp:287
This file is part of the KDE documentation.
Documentation copyright © 1996-2019 The KDE developers.
Generated on Mon Aug 12 2019 21:53:19 by doxygen 1.8.15 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2019 The KDE developers.
Generated on Mon Aug 12 2019 21:53:19 by doxygen 1.8.15 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.