KDEUI
#include <kselectionproxymodel.h>
Public Types | |
enum | FilterBehavior { SubTrees, SubTreeRoots, SubTreesWithoutRoots, ExactSelection, ChildrenOfExactSelection } |
Signals | |
void | rootIndexAboutToBeRemoved (const QModelIndex &removeRootIndex) |
void | rootIndexAdded (const QModelIndex &newIndex) |
void | rootSelectionAboutToBeRemoved (const QItemSelection &selection) |
void | rootSelectionAdded (const QItemSelection &selection) |
Public Member Functions | |
KSelectionProxyModel (QItemSelectionModel *selectionModel, QObject *parent=0) | |
virtual | ~KSelectionProxyModel () |
virtual int | columnCount (const QModelIndex &=QModelIndex()) const |
QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const |
virtual bool | dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) |
FilterBehavior | filterBehavior () const |
virtual Qt::ItemFlags | flags (const QModelIndex &index) const |
virtual bool | hasChildren (const QModelIndex &parent=QModelIndex()) const |
virtual QVariant | headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const |
virtual QModelIndex | index (int, int, const QModelIndex &=QModelIndex()) const |
QModelIndex | mapFromSource (const QModelIndex &sourceIndex) const |
QItemSelection | mapSelectionFromSource (const QItemSelection &selection) const |
QItemSelection | mapSelectionToSource (const QItemSelection &selection) const |
QModelIndex | mapToSource (const QModelIndex &proxyIndex) 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 |
virtual QMimeData * | mimeData (const QModelIndexList &indexes) const |
virtual QStringList | mimeTypes () const |
virtual QModelIndex | parent (const QModelIndex &) const |
virtual int | rowCount (const QModelIndex &parent=QModelIndex()) const |
QItemSelectionModel * | selectionModel () const |
void | setFilterBehavior (FilterBehavior behavior) |
virtual void | setSourceModel (QAbstractItemModel *sourceModel) |
virtual Qt::DropActions | supportedDropActions () const |
Public Member Functions inherited from QAbstractProxyModel | |
QAbstractProxyModel (QObject *parent) | |
~QAbstractProxyModel () | |
virtual QModelIndex | buddy (const QModelIndex &index) const |
virtual bool | canFetchMore (const QModelIndex &parent) const |
virtual void | fetchMore (const QModelIndex &parent) |
virtual QMap< int, QVariant > | itemData (const QModelIndex &proxyIndex) const |
virtual QModelIndex | mapFromSource (const QModelIndex &sourceIndex) const =0 |
virtual QModelIndex | mapToSource (const QModelIndex &proxyIndex) const =0 |
virtual void | revert () |
virtual bool | setData (const QModelIndex &index, const QVariant &value, int role) |
virtual bool | setHeaderData (int section, Qt::Orientation orientation, const QVariant &value, int role) |
virtual bool | setItemData (const QModelIndex &index, const QMap< int, QVariant > &roles) |
virtual void | sort (int column, Qt::SortOrder order) |
QAbstractItemModel * | sourceModel () const |
virtual QSize | span (const QModelIndex &index) const |
virtual bool | submit () |
Public Member Functions inherited from QAbstractItemModel | |
QAbstractItemModel (QObject *parent) | |
virtual | ~QAbstractItemModel () |
virtual int | columnCount (const QModelIndex &parent) const =0 |
void | columnsAboutToBeInserted (const QModelIndex &parent, int start, int end) |
void | columnsAboutToBeMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn) |
void | columnsAboutToBeRemoved (const QModelIndex &parent, int start, int end) |
void | columnsInserted (const QModelIndex &parent, int start, int end) |
void | columnsMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn) |
void | columnsRemoved (const QModelIndex &parent, int start, int end) |
virtual QVariant | data (const QModelIndex &index, int role) const =0 |
void | dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight) |
bool | hasIndex (int row, int column, const QModelIndex &parent) const |
void | headerDataChanged (Qt::Orientation orientation, int first, int last) |
virtual QModelIndex | index (int row, int column, const QModelIndex &parent) const =0 |
bool | insertColumn (int column, const QModelIndex &parent) |
virtual bool | insertColumns (int column, int count, const QModelIndex &parent) |
bool | insertRow (int row, const QModelIndex &parent) |
virtual bool | insertRows (int row, int count, const QModelIndex &parent) |
void | layoutAboutToBeChanged () |
void | layoutChanged () |
virtual QModelIndexList | match (const QModelIndex &start, int role, const QVariant &value, int hits, QFlags< Qt::MatchFlag > flags) const |
void | modelAboutToBeReset () |
void | modelReset () |
virtual QModelIndex | parent (const QModelIndex &index) const =0 |
bool | removeColumn (int column, const QModelIndex &parent) |
virtual bool | removeColumns (int column, int count, const QModelIndex &parent) |
bool | removeRow (int row, const QModelIndex &parent) |
virtual bool | removeRows (int row, int count, const QModelIndex &parent) |
const QHash< int, QByteArray > & | roleNames () const |
virtual int | rowCount (const QModelIndex &parent) const =0 |
void | rowsAboutToBeInserted (const QModelIndex &parent, int start, int end) |
void | rowsAboutToBeMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow) |
void | rowsAboutToBeRemoved (const QModelIndex &parent, int start, int end) |
void | rowsInserted (const QModelIndex &parent, int start, int end) |
void | rowsMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow) |
void | rowsRemoved (const QModelIndex &parent, int start, int end) |
void | setSupportedDragActions (QFlags< Qt::DropAction > actions) |
QModelIndex | sibling (int row, int column, const QModelIndex &index) const |
Qt::DropActions | supportedDragActions () const |
Public Member Functions inherited from QObject | |
QObject (QObject *parent) | |
QObject (QObject *parent, const char *name) | |
virtual | ~QObject () |
bool | blockSignals (bool block) |
QObject * | child (const char *objName, const char *inheritsClass, bool recursiveSearch) const |
const QObjectList & | children () const |
const char * | className () const |
bool | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const |
void | deleteLater () |
void | destroyed (QObject *obj) |
bool | disconnect (const QObject *receiver, const char *method) |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) |
void | dumpObjectInfo () |
void | dumpObjectTree () |
QList< QByteArray > | dynamicPropertyNames () const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name) const |
QList< T > | findChildren (const QRegExp ®Exp) const |
QList< T > | findChildren (const QString &name) const |
bool | inherits (const char *className) const |
void | insertChild (QObject *object) |
void | installEventFilter (QObject *filterObj) |
bool | isA (const char *className) const |
bool | isWidgetType () const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const |
void | moveToThread (QThread *targetThread) |
const char * | name () const |
const char * | name (const char *defaultName) const |
QString | objectName () const |
QObject * | parent () const |
QVariant | property (const char *name) const |
void | removeChild (QObject *object) |
void | removeEventFilter (QObject *obj) |
void | setName (const char *name) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | signalsBlocked () const |
int | startTimer (int interval) |
QThread * | thread () const |
Protected Member Functions | |
QList< QPersistentModelIndex > | sourceRootIndexes () const |
Protected Member Functions inherited from QAbstractItemModel | |
void | beginInsertColumns (const QModelIndex &parent, int first, int last) |
void | beginInsertRows (const QModelIndex &parent, int first, int last) |
bool | beginMoveColumns (const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationChild) |
bool | beginMoveRows (const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationChild) |
void | beginRemoveColumns (const QModelIndex &parent, int first, int last) |
void | beginRemoveRows (const QModelIndex &parent, int first, int last) |
void | beginResetModel () |
void | changePersistentIndex (const QModelIndex &from, const QModelIndex &to) |
void | changePersistentIndexList (const QModelIndexList &from, const QModelIndexList &to) |
QModelIndex | createIndex (int row, int column, void *ptr) const |
QModelIndex | createIndex (int row, int column, int id) const |
QModelIndex | createIndex (int row, int column, quint32 id) const |
void | endInsertColumns () |
void | endInsertRows () |
void | endMoveColumns () |
void | endMoveRows () |
void | endRemoveColumns () |
void | endRemoveRows () |
void | endResetModel () |
QModelIndexList | persistentIndexList () const |
void | reset () |
void | resetInternalData () |
void | setRoleNames (const QHash< int, QByteArray > &roleNames) |
Protected Member Functions inherited from QObject | |
bool | checkConnectArgs (const char *signal, const QObject *object, const char *method) |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const char *signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const char *signal) |
int | receivers (const char *signal) const |
QObject * | sender () const |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *event) |
Additional Inherited Members | |
Static Public Member Functions inherited from QObject | |
bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
Static Protected Member Functions inherited from QObject | |
QByteArray | normalizeSignalSlot (const char *signalSlot) |
Properties inherited from QObject | |
objectName | |
Detailed Description
A Proxy Model which presents a subset of its source model to observers.
The KSelectionProxyModel is most useful as a convenience for displaying the selection in one view in another view. The selectionModel of the initial view is used to create a proxied model which is filtered based on the configuration of this class.
For example, when a user clicks a mail folder in one view in an email application, the contained emails should be displayed in another view.
This takes away the need for the developer to handle the selection between the views, including all the mapToSource, mapFromSource and setRootIndex calls.
The KSelectionProxyModel can handle complex selections.
The contents of the secondary view depends on the selection in the primary view, and the configuration of the proxy model. See KSelectionProxyModel::setFilterBehavior for the different possible configurations.
For example, if the filterBehavior is SubTrees, selecting another item in an already selected subtree has no effect.
See the test application in KDE/kdelibs/kdeui/tests/proxymodeltestapp to try out the valid configurations.
Obviously, the KSelectionProxyModel may be used in a view, or further processed with other proxy models. See KAddressBook and AkonadiConsole in kdepim for examples which use a further KDescendantsProxyModel and QSortFilterProxyModel on top of a KSelectionProxyModel.
Additionally, this class can be used to programmatically choose some items from the source model to display in the view. For example, this is how the Favourite Folder View in KMail works, and is also used in unit testing.
See also: http://doc.trolltech.com/4.5/model-view-proxy-models.html
- Since
- 4.4
Definition at line 86 of file kselectionproxymodel.h.
Member Enumeration Documentation
Enumerator | |
---|---|
SubTrees | |
SubTreeRoots | |
SubTreesWithoutRoots | |
ExactSelection | |
ChildrenOfExactSelection |
Definition at line 110 of file kselectionproxymodel.h.
Constructor & Destructor Documentation
|
explicit |
ctor.
selectionModel
The selection model used to filter what is presented by the proxy.
Definition at line 1988 of file kselectionproxymodel.cpp.
|
virtual |
dtor
Definition at line 1993 of file kselectionproxymodel.cpp.
Member Function Documentation
|
virtual |
Definition at line 2312 of file kselectionproxymodel.cpp.
|
virtual |
Reimplemented from QAbstractProxyModel.
Definition at line 2248 of file kselectionproxymodel.cpp.
|
virtual |
Reimplemented from QAbstractItemModel.
Definition at line 2335 of file kselectionproxymodel.cpp.
KSelectionProxyModel::FilterBehavior KSelectionProxyModel::filterBehavior | ( | ) | const |
Definition at line 2047 of file kselectionproxymodel.cpp.
|
virtual |
Reimplemented from QAbstractProxyModel.
Definition at line 2236 of file kselectionproxymodel.cpp.
|
virtual |
Reimplemented from QAbstractProxyModel.
Definition at line 2292 of file kselectionproxymodel.cpp.
|
virtual |
Reimplemented from QAbstractProxyModel.
Definition at line 2261 of file kselectionproxymodel.cpp.
|
virtual |
Definition at line 2207 of file kselectionproxymodel.cpp.
QModelIndex KSelectionProxyModel::mapFromSource | ( | const QModelIndex & | sourceIndex | ) | const |
Definition at line 2160 of file kselectionproxymodel.cpp.
|
virtual |
Reimplemented from QAbstractProxyModel.
Definition at line 2383 of file kselectionproxymodel.cpp.
|
virtual |
Reimplemented from QAbstractProxyModel.
Definition at line 2418 of file kselectionproxymodel.cpp.
QModelIndex KSelectionProxyModel::mapToSource | ( | const QModelIndex & | proxyIndex | ) | const |
Definition at line 2140 of file kselectionproxymodel.cpp.
|
virtual |
Definition at line 2368 of file kselectionproxymodel.cpp.
|
virtual |
Reimplemented from QAbstractProxyModel.
Definition at line 2268 of file kselectionproxymodel.cpp.
|
virtual |
Reimplemented from QAbstractProxyModel.
Definition at line 2278 of file kselectionproxymodel.cpp.
|
virtual |
Definition at line 2224 of file kselectionproxymodel.cpp.
|
signal |
Emitted before removeRootIndex
, an index in the sourceModel is removed from the root selected indexes. This may be unrelated to rows removed from the model, depending on configuration.
|
signal |
Emitted when newIndex
, an index in the sourceModel is added to the root selected indexes. This may be unrelated to rows inserted to the model, depending on configuration.
|
signal |
Emitted before selection
, a selection in the sourceModel, is removed from the root selection.
|
signal |
Emitted after selection
, a selection in the sourceModel, is added to the root selection.
|
virtual |
Definition at line 2178 of file kselectionproxymodel.cpp.
QItemSelectionModel * KSelectionProxyModel::selectionModel | ( | ) | const |
Definition at line 2329 of file kselectionproxymodel.cpp.
void KSelectionProxyModel::setFilterBehavior | ( | FilterBehavior | behavior | ) |
Set the filter behaviors of this model.
The filter behaviors of the model govern the content of the model based on the selection of the contained QItemSelectionModel.
See kdeui/proxymodeltestapp to try out the different proxy model behaviors.
The most useful behaviors are SubTrees, ExactSelection and ChildrenOfExactSelection.
The default behavior is SubTrees. This means that this proxy model will contain the roots of the items in the source model. Any descendants which are also selected have no additional effect. For example if the source model is like:
(root) - A - B - C - D - E - F - G - H - I - J - K - L
And A, B, C and D are selected, the proxy will contain:
(root) - A - B - C - D - E - F - G
That is, selecting 'D' or 'C' if 'B' is also selected has no effect. If 'B' is de-selected, then 'C' amd 'D' become top-level items:
(root) - A - C - D - E - F - G
This is the behavior used by KJots when rendering books.
If the behavior is set to SubTreeRoots, then the children of selected indexes are not part of the model. If 'A', 'B' and 'D' are selected,
(root) - A - B
Note that although 'D' is selected, it is not part of the proxy model, because its parent 'B' is already selected.
SubTreesWithoutRoots has the effect of not making the selected items part of the model, but making their children part of the model instead. If 'A', 'B' and 'I' are selected:
(root) - C - D - E - F - G - J - K - L
Note that 'A' has no children, so selecting it has no outward effect on the model.
ChildrenOfExactSelection causes the proxy model to contain the children of the selected indexes,but further descendants are omitted. Additionally, if descendants of an already selected index are selected, their children are part of the proxy model. For example, if 'A', 'B', 'D' and 'I' are selected:
(root) - C - D - E - G - J - K - L
This would be useful for example if showing containers (for example maildirs) in one view and their items in another. Sub-maildirs would still appear in the proxy, but could be filtered out using a QSortfilterProxyModel.
The ExactSelection behavior causes the selected items to be part of the proxy model, even if their ancestors are already selected, but children of selected items are not included.
Again, if 'A', 'B', 'D' and 'I' are selected:
(root) - A - B - D - I
This is the behavior used by the Favourite Folder View in KMail.
Definition at line 1998 of file kselectionproxymodel.cpp.
|
virtual |
reimp.
Reimplemented from QAbstractProxyModel.
Definition at line 2053 of file kselectionproxymodel.cpp.
|
protected |
Definition at line 2362 of file kselectionproxymodel.cpp.
|
virtual |
Reimplemented from QAbstractProxyModel.
Definition at line 2285 of file kselectionproxymodel.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:24:03 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.