KSelectionProxyModel

Search for usage in LXR

#include <KSelectionProxyModel>

Inheritance diagram for KSelectionProxyModel:

Public Types

enum  FilterBehavior {
  SubTrees , SubTreeRoots , SubTreesWithoutRoots , ExactSelection ,
  ChildrenOfExactSelection , InvalidBehavior
}
 
- Public Types inherited from QAbstractItemModel
enum  CheckIndexOption
 
typedef  CheckIndexOptions
 
enum  LayoutChangeHint
 
- Public Types inherited from QObject
typedef  QObjectList
 

Properties

FilterBehavior filterBehavior
 
QItemSelectionModelselectionModel
 
- Properties inherited from QAbstractProxyModel
 sourceModel
 
- Properties inherited from QObject
 objectName
 

Signals

void filterBehaviorChanged (QPrivateSignal)
 
void rootIndexAboutToBeRemoved (const QModelIndex &removeRootIndex, QPrivateSignal)
 
void rootIndexAdded (const QModelIndex &newIndex, QPrivateSignal)
 
void rootSelectionAboutToBeRemoved (const QItemSelection &selection, QPrivateSignal)
 
void rootSelectionAdded (const QItemSelection &selection, QPrivateSignal)
 
void selectionModelChanged (QPrivateSignal)
 

Public Member Functions

 KSelectionProxyModel ()
 
 KSelectionProxyModel (QItemSelectionModel *selectionModel, QObject *parent=nullptr)
 
 ~KSelectionProxyModel () override
 
int columnCount (const QModelIndex &=QModelIndex()) const override
 
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
 
bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
 
FilterBehavior filterBehavior () const
 
Qt::ItemFlags flags (const QModelIndex &index) const override
 
bool hasChildren (const QModelIndex &parent=QModelIndex()) const override
 
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
 
QModelIndex index (int, int, const QModelIndex &=QModelIndex()) const override
 
QModelIndex mapFromSource (const QModelIndex &sourceIndex) const override
 
QItemSelection mapSelectionFromSource (const QItemSelection &selection) const override
 
QItemSelection mapSelectionToSource (const QItemSelection &selection) const override
 
QModelIndex mapToSource (const QModelIndex &proxyIndex) const override
 
virtual QModelIndexList match (const QModelIndex &start, int role, const QVariant &value, int hits=1, Qt::MatchFlags flags=Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const override
 
QMimeDatamimeData (const QModelIndexList &indexes) const override
 
QStringList mimeTypes () const override
 
QModelIndex parent (const QModelIndex &) const override
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 
QItemSelectionModelselectionModel () const
 
void setFilterBehavior (FilterBehavior behavior)
 
void setSelectionModel (QItemSelectionModel *selectionModel)
 
void setSourceModel (QAbstractItemModel *sourceModel) override
 
Qt::DropActions supportedDropActions () const override
 
- Public Member Functions inherited from QAbstractProxyModel
 QAbstractProxyModel (QObject *parent)
 
QBindable< QAbstractItemModel * > bindableSourceModel ()
 
virtual QModelIndex buddy (const QModelIndex &index) const const override
 
virtual bool canDropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const const override
 
virtual bool canFetchMore (const QModelIndex &parent) const const override
 
virtual bool clearItemData (const QModelIndex &index) override
 
virtual void fetchMore (const QModelIndex &parent) override
 
virtual QMap< int, QVariantitemData (const QModelIndex &proxyIndex) const const override
 
virtual void revert () override
 
virtual QHash< int, QByteArrayroleNames () const const override
 
virtual bool setData (const QModelIndex &index, const QVariant &value, int role) override
 
virtual bool setHeaderData (int section, Qt::Orientation orientation, const QVariant &value, int role) override
 
virtual bool setItemData (const QModelIndex &index, const QMap< int, QVariant > &roles) override
 
virtual QModelIndex sibling (int row, int column, const QModelIndex &idx) const const override
 
virtual void sort (int column, Qt::SortOrder order) override
 
QAbstractItemModelsourceModel () const const
 
void sourceModelChanged ()
 
virtual QSize span (const QModelIndex &index) const const override
 
virtual bool submit () override
 
virtual Qt::DropActions supportedDragActions () const const override
 
- Public Member Functions inherited from QAbstractItemModel
 QAbstractItemModel (QObject *parent)
 
bool checkIndex (const QModelIndex &index, CheckIndexOptions options) const const
 
void columnsAboutToBeInserted (const QModelIndex &parent, int first, int last)
 
void columnsAboutToBeMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn)
 
void columnsAboutToBeRemoved (const QModelIndex &parent, int first, int last)
 
void columnsInserted (const QModelIndex &parent, int first, int last)
 
void columnsMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn)
 
void columnsRemoved (const QModelIndex &parent, int first, int last)
 
void dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles)
 
bool hasIndex (int row, int column, const QModelIndex &parent) const const
 
void headerDataChanged (Qt::Orientation orientation, int first, int last)
 
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 (const QList< QPersistentModelIndex > &parents, QAbstractItemModel::LayoutChangeHint hint)
 
void layoutChanged (const QList< QPersistentModelIndex > &parents, QAbstractItemModel::LayoutChangeHint hint)
 
void modelAboutToBeReset ()
 
void modelReset ()
 
bool moveColumn (const QModelIndex &sourceParent, int sourceColumn, const QModelIndex &destinationParent, int destinationChild)
 
virtual bool moveColumns (const QModelIndex &sourceParent, int sourceColumn, int count, const QModelIndex &destinationParent, int destinationChild)
 
bool moveRow (const QModelIndex &sourceParent, int sourceRow, const QModelIndex &destinationParent, int destinationChild)
 
virtual bool moveRows (const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild)
 
virtual void multiData (const QModelIndex &index, QModelRoleDataSpan roleDataSpan) const const
 
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)
 
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 first, int last)
 
void rowsInserted (const QModelIndex &parent, int first, int last)
 
void rowsMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow)
 
void rowsRemoved (const QModelIndex &parent, int first, int last)
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
QBindable< QStringbindableObjectName ()
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo () const const
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isQuickItemType () const const
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_GADGET_EXPORT (EXPORT_MACRO)
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setObjectName (QAnyStringView name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool setProperty (const char *name, QVariant &&value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType)
 
QThreadthread () const const
 

Protected Member Functions

QList< QPersistentModelIndexsourceRootIndexes () const
 
- Protected Member Functions inherited from QAbstractProxyModel
QModelIndex createSourceIndex (int row, int col, void *internalPtr) const 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, const void *ptr) const const
 
QModelIndex createIndex (int row, int column, quintptr id) const const
 
void endInsertColumns ()
 
void endInsertRows ()
 
void endMoveColumns ()
 
void endMoveRows ()
 
void endRemoveColumns ()
 
void endRemoveRows ()
 
void endResetModel ()
 
QModelIndexList persistentIndexList () const const
 
virtual void resetInternalData ()
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
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)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
- Public Attributes inherited from QAbstractItemModel
 DoNotUseParent
 
 HorizontalSortHint
 
 IndexIsValid
 
 NoLayoutChangeHint
 
 NoOption
 
 ParentIsInvalid
 
 VerticalSortHint
 

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.

MyModel *sourceModel = new MyModel(this);
QTreeView *leftView = new QTreeView(this);
leftView->setModel(sourceModel);
KSelectionProxyModel *selectionProxy = new KSelectionProxyModel(leftView->selectionModel(), this);
selectionProxy->setSourceModel(sourceModel);
QTreeView *rightView = new QTreeView(this);
rightView->setModel(selectionProxy);
A Proxy Model which presents a subset of its source model to observers.
KSelectionProxyModel()
Default constructor.
void setSourceModel(QAbstractItemModel *sourceModel) override
reimp.
QItemSelectionModel * selectionModel() const const
virtual void setModel(QAbstractItemModel *model) override
A Selection in one view creating a model for use with another view.

The KSelectionProxyModel can handle complex selections.

Non-contiguous selection creating a new simple model in a second view.

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.

Selecting an item and its descendant.

See the test application in tests/proxymodeltestapp to try out the valid configurations.

KSelectionProxyModel test application

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: https://doc.qt.io/qt-5/model-view-programming.html#proxy-models

Since
4.4
Author
Stephen Kelly steve.nosp@m.ire@.nosp@m.gmail.nosp@m..com

Definition at line 76 of file kselectionproxymodel.h.

Member Enumeration Documentation

◆ FilterBehavior

enum KSelectionProxyModel::FilterBehavior

Definition at line 110 of file kselectionproxymodel.h.

Property Documentation

◆ filterBehavior

FilterBehavior KSelectionProxyModel::filterBehavior
readwrite

Definition at line 79 of file kselectionproxymodel.h.

◆ selectionModel

QItemSelectionModel * KSelectionProxyModel::selectionModel
readwrite

Definition at line 80 of file kselectionproxymodel.h.

Constructor & Destructor Documentation

◆ KSelectionProxyModel() [1/2]

KSelectionProxyModel::KSelectionProxyModel ( QItemSelectionModel * selectionModel,
QObject * parent = nullptr )
explicit

ctor.

selectionModel The selection model used to filter what is presented by the proxy.

Definition at line 1992 of file kselectionproxymodel.cpp.

◆ KSelectionProxyModel() [2/2]

KSelectionProxyModel::KSelectionProxyModel ( )
explicit

Default constructor.

Allow the creation of a KSelectionProxyModel in QML code. QML will assign a parent after construction.

Definition at line 1999 of file kselectionproxymodel.cpp.

◆ ~KSelectionProxyModel()

KSelectionProxyModel::~KSelectionProxyModel ( )
overridedefault

dtor

Member Function Documentation

◆ columnCount()

int KSelectionProxyModel::columnCount ( const QModelIndex & index = QModelIndex()) const
overridevirtual

Implements QAbstractItemModel.

Definition at line 2356 of file kselectionproxymodel.cpp.

◆ data()

QVariant KSelectionProxyModel::data ( const QModelIndex & index,
int role = Qt::DisplayRole ) const
overridevirtual

Reimplemented from QAbstractProxyModel.

Definition at line 2283 of file kselectionproxymodel.cpp.

◆ dropMimeData()

bool KSelectionProxyModel::dropMimeData ( const QMimeData * data,
Qt::DropAction action,
int row,
int column,
const QModelIndex & parent )
overridevirtual

Reimplemented from QAbstractProxyModel.

Definition at line 2420 of file kselectionproxymodel.cpp.

◆ filterBehavior()

KSelectionProxyModel::FilterBehavior KSelectionProxyModel::filterBehavior ( ) const

Definition at line 2069 of file kselectionproxymodel.cpp.

◆ flags()

Qt::ItemFlags KSelectionProxyModel::flags ( const QModelIndex & index) const
overridevirtual

Reimplemented from QAbstractProxyModel.

Definition at line 2270 of file kselectionproxymodel.cpp.

◆ hasChildren()

bool KSelectionProxyModel::hasChildren ( const QModelIndex & parent = QModelIndex()) const
overridevirtual

Reimplemented from QAbstractProxyModel.

Definition at line 2333 of file kselectionproxymodel.cpp.

◆ headerData()

QVariant KSelectionProxyModel::headerData ( int section,
Qt::Orientation orientation,
int role = Qt::DisplayRole ) const
overridevirtual

Reimplemented from QAbstractProxyModel.

Definition at line 2297 of file kselectionproxymodel.cpp.

◆ index()

QModelIndex KSelectionProxyModel::index ( int row,
int column,
const QModelIndex & parent = QModelIndex() ) const
overridevirtual

Implements QAbstractItemModel.

Definition at line 2238 of file kselectionproxymodel.cpp.

◆ mapFromSource()

QModelIndex KSelectionProxyModel::mapFromSource ( const QModelIndex & sourceIndex) const
overridevirtual

Implements QAbstractProxyModel.

Definition at line 2184 of file kselectionproxymodel.cpp.

◆ mapSelectionFromSource()

QItemSelection KSelectionProxyModel::mapSelectionFromSource ( const QItemSelection & selection) const
overridevirtual

Reimplemented from QAbstractProxyModel.

Definition at line 2472 of file kselectionproxymodel.cpp.

◆ mapSelectionToSource()

QItemSelection KSelectionProxyModel::mapSelectionToSource ( const QItemSelection & selection) const
overridevirtual

Reimplemented from QAbstractProxyModel.

Definition at line 2509 of file kselectionproxymodel.cpp.

◆ mapToSource()

QModelIndex KSelectionProxyModel::mapToSource ( const QModelIndex & proxyIndex) const
overridevirtual

Implements QAbstractProxyModel.

Definition at line 2163 of file kselectionproxymodel.cpp.

◆ match()

QModelIndexList KSelectionProxyModel::match ( const QModelIndex & start,
int role,
const QVariant & value,
int hits = 1,
Qt::MatchFlags flags = Qt::MatchFlags(Qt::MatchStartsWith | Qt::MatchWrap) ) const
overridevirtual

Reimplemented from QAbstractItemModel.

Definition at line 2454 of file kselectionproxymodel.cpp.

◆ mimeData()

QMimeData * KSelectionProxyModel::mimeData ( const QModelIndexList & indexes) const
overridevirtual

Reimplemented from QAbstractProxyModel.

Definition at line 2305 of file kselectionproxymodel.cpp.

◆ mimeTypes()

QStringList KSelectionProxyModel::mimeTypes ( ) const
overridevirtual

Reimplemented from QAbstractProxyModel.

Definition at line 2317 of file kselectionproxymodel.cpp.

◆ parent()

QModelIndex KSelectionProxyModel::parent ( const QModelIndex & index) const
overridevirtual

Implements QAbstractItemModel.

Definition at line 2257 of file kselectionproxymodel.cpp.

◆ rootIndexAboutToBeRemoved

void KSelectionProxyModel::rootIndexAboutToBeRemoved ( const QModelIndex & removeRootIndex,
QPrivateSignal  )
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.

◆ rootIndexAdded

void KSelectionProxyModel::rootIndexAdded ( const QModelIndex & newIndex,
QPrivateSignal  )
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.

◆ rootSelectionAboutToBeRemoved

void KSelectionProxyModel::rootSelectionAboutToBeRemoved ( const QItemSelection & selection,
QPrivateSignal  )
signal

Emitted before selection, a selection in the sourceModel, is removed from the root selection.

◆ rootSelectionAdded

void KSelectionProxyModel::rootSelectionAdded ( const QItemSelection & selection,
QPrivateSignal  )
signal

Emitted after selection, a selection in the sourceModel, is added to the root selection.

◆ rowCount()

int KSelectionProxyModel::rowCount ( const QModelIndex & parent = QModelIndex()) const
overridevirtual

Implements QAbstractItemModel.

Definition at line 2205 of file kselectionproxymodel.cpp.

◆ selectionModel()

QItemSelectionModel * KSelectionProxyModel::selectionModel ( ) const

Definition at line 2365 of file kselectionproxymodel.cpp.

◆ setFilterBehavior()

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 2007 of file kselectionproxymodel.cpp.

◆ setSelectionModel()

void KSelectionProxyModel::setSelectionModel ( QItemSelectionModel * selectionModel)

Definition at line 2371 of file kselectionproxymodel.cpp.

◆ setSourceModel()

void KSelectionProxyModel::setSourceModel ( QAbstractItemModel * sourceModel)
overridevirtual

reimp.

Reimplemented from QAbstractProxyModel.

Definition at line 2075 of file kselectionproxymodel.cpp.

◆ sourceRootIndexes()

QList< QPersistentModelIndex > KSelectionProxyModel::sourceRootIndexes ( ) const
protected

Definition at line 2448 of file kselectionproxymodel.cpp.

◆ supportedDropActions()

Qt::DropActions KSelectionProxyModel::supportedDropActions ( ) const
overridevirtual

Reimplemented from QAbstractProxyModel.

Definition at line 2325 of file kselectionproxymodel.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 13 2024 11:48:57 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.