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 int rowCount(const QModelIndex &parent) const =0
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const =0
virtual bool acceptRow(int sourceRow, const QModelIndex &sourceParent) const
Reimplement this method for custom filtering strategies.
Definition: krecursivefilterproxymodel.cpp:282
virtual void setSourceModel(QAbstractItemModel *sourceModel)
virtual QModelIndexList match(const QModelIndex &start, int role, const QVariant &value, int hits, QFlags< Qt::MatchFlag > flags) const
typedef MatchFlags
void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
bool isValid() const
void rowsAboutToBeInserted(const QModelIndex &parent, int start, int end)
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
int row() const
void setDynamicSortFilter(bool enable)
QModelIndex parent() const
void rowsRemoved(const QModelIndex &parent, int start, int end)
Implements recursive filtering of models.
Definition: krecursivefilterproxymodel.h:87
bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType type, QGenericReturnArgument ret, QGenericArgument val0, QGenericArgument val1, QGenericArgument val2, QGenericArgument val3, QGenericArgument val4, QGenericArgument val5, QGenericArgument val6, QGenericArgument val7, QGenericArgument val8, QGenericArgument val9)
virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
QAbstractItemModel * sourceModel() const
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const
KRecursiveFilterProxyModel(QObject *parent=0)
Constructor.
Definition: krecursivefilterproxymodel.cpp:234
virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const
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:266
KRecursiveFilterProxyModelPrivate *const d_ptr
Definition: krecursivefilterproxymodel.h:121
void setSourceModel(QAbstractItemModel *model)
Definition: krecursivefilterproxymodel.cpp:287
void rowsInserted(const QModelIndex &parent, int start, int end)
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:24:00 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:24:00 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.