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)
129 if (!source_parent.isValid() || q->filterAcceptsRow(source_parent.row(), source_parent.parent()))
149 void KRecursiveFilterProxyModelPrivate::refreshAscendantMapping(const QModelIndex &index, bool refreshAll)
157 // We need to tell the QSortFilterProxyModel that the first child between an existing row in the model
159 while(sourceAscendant.isValid() && !q->acceptRow(sourceAscendant.row(), sourceAscendant.parent()))
168 // Inform the model that its data changed so that it creates new mappings and finds the rows which now match the filter.
172 void KRecursiveFilterProxyModelPrivate::sourceRowsAboutToBeInserted(const QModelIndex &source_parent, int start, int end)
176 if (!source_parent.isValid() || q->filterAcceptsRow(source_parent.row(), source_parent.parent()))
183 void KRecursiveFilterProxyModelPrivate::sourceRowsInserted(const QModelIndex &source_parent, int start, int end)
214 void KRecursiveFilterProxyModelPrivate::sourceRowsAboutToBeRemoved(const QModelIndex &source_parent, int start, int end)
218 if (source_parent.isValid() && q->filterAcceptsRow(source_parent.row(), source_parent.parent()))
244 void KRecursiveFilterProxyModelPrivate::sourceRowsRemoved(const QModelIndex &source_parent, int start, int end)
251 // fall through. After removing rows, we need to refresh things so that intermediates will be removed too if necessary.
278 bool KRecursiveFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const
280 // TODO: Implement some caching so that if one match is found on the first pass, we can return early results
291 accepted = true; // Need to do this in a loop so that all siblings in a parent get processed, not just the first.
296 QModelIndexList KRecursiveFilterProxyModel::match( const QModelIndex& start, int role, const QVariant& value, int hits, Qt::MatchFlags flags ) const
303 foreach ( const QModelIndex &idx, sourceModel()->match( mapToSource( start ), role, value, hits, flags ) ) {
312 bool KRecursiveFilterProxyModel::acceptRow(int sourceRow, const QModelIndex& sourceParent) const
392 // Instead we connect the sourceModel signal to our own slot in *this (sourceRowsAboutToBeInserted)
393 // Inside that method, the entire new subtree is queried (J, K *and* L) to see if there is a match,
396 // it matches the filter. It did not before, because L did not exist before. Now it does. That is
397 // 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:312
Implements recursive filtering of models.
Definition: krecursivefilterproxymodel.h:87
KRecursiveFilterProxyModel(QObject *parent=0)
Constructor.
Definition: krecursivefilterproxymodel.cpp:267
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:296
KRecursiveFilterProxyModelPrivate *const d_ptr
Definition: krecursivefilterproxymodel.h:121
void setSourceModel(QAbstractItemModel *model)
Definition: krecursivefilterproxymodel.cpp:317
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:49:15 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:49:15 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.