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
47 // Convenience methods for invoking the QSFPM slots. Those slots must be invoked with invokeMethod
73 bool success = QMetaObject::invokeMethod(q, "_q_sourceRowsAboutToBeInserted", Qt::DirectConnection,
95 bool success = QMetaObject::invokeMethod(q, "_q_sourceRowsAboutToBeRemoved", Qt::DirectConnection,
103 void sourceDataChanged(const QModelIndex &source_top_left, const QModelIndex &source_bottom_right);
122 void KRecursiveFilterProxyModelPrivate::sourceDataChanged(const QModelIndex &source_top_left, const QModelIndex &source_bottom_right)
125 Q_ASSERT(source_bottom_right.parent() == source_parent); // don't know how to handle different parents in this code...
130 // We can't find out if the change really matters to us or not, for a lack of a dataAboutToBeChanged signal (or a cache).
158 void KRecursiveFilterProxyModelPrivate::sourceRowsAboutToBeInserted(const QModelIndex &source_parent, int start, int end)
162 if (!source_parent.isValid() || q->filterAcceptsRow(source_parent.row(), source_parent.parent()))
164 // If the parent is already in the model (directly or indirectly), we can just pass on the signal.
174 void KRecursiveFilterProxyModelPrivate::sourceRowsInserted(const QModelIndex &source_parent, int start, int end)
206 void KRecursiveFilterProxyModelPrivate::sourceRowsAboutToBeRemoved(const QModelIndex &source_parent, int start, int end)
229 void KRecursiveFilterProxyModelPrivate::sourceRowsRemoved(const QModelIndex &source_parent, int start, int end)
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
292 QModelIndexList KRecursiveFilterProxyModel::match( const QModelIndex& start, int role, const QVariant& value, int hits, Qt::MatchFlags flags ) const
299 foreach ( const QModelIndex &idx, sourceModel()->match( mapToSource( start ), role, value, hits, flags ) ) {
308 bool KRecursiveFilterProxyModel::acceptRow(int sourceRow, const QModelIndex& sourceParent) const
388 // Instead we connect the sourceModel signal to our own slot in *this (sourceRowsAboutToBeInserted)
389 // Inside that method, the entire new subtree is queried (J, K *and* L) to see if there is a match,
392 // it matches the filter. It did not before, because L did not exist before. Now it does. That is
393 // achieved by telling the QSFPM that the data changed for H, which causes it to requery this class
virtual bool acceptRow(int sourceRow, const QModelIndex &sourceParent) const
Reimplement this method for custom filtering strategies.
Definition: krecursivefilterproxymodel.cpp:308
Implements recursive filtering of models.
Definition: krecursivefilterproxymodel.h:87
KRecursiveFilterProxyModel(QObject *parent=0)
Constructor.
Definition: krecursivefilterproxymodel.cpp:260
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:292
KRecursiveFilterProxyModelPrivate *const d_ptr
Definition: krecursivefilterproxymodel.h:121
void setSourceModel(QAbstractItemModel *model)
Definition: krecursivefilterproxymodel.cpp:313
This file is part of the KDE documentation.
Documentation copyright © 1996-2015 The KDE developers.
Generated on Wed Apr 22 2015 15:32:55 by doxygen 1.8.6 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2015 The KDE developers.
Generated on Wed Apr 22 2015 15:32:55 by doxygen 1.8.6 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.