KItemModels
kselectionproxymodel.h
24 The KSelectionProxyModel is most useful as a convenience for displaying the selection in one view in
25 another view. The selectionModel of the initial view is used to create a proxied model which is filtered
28 For example, when a user clicks a mail folder in one view in an email application, the contained emails
31 This takes away the need for the developer to handle the selection between the views, including all the
39 KSelectionProxyModel *selectionProxy = new KSelectionProxyModel(leftView->selectionModel(), this);
46 \image html selectionproxymodelsimpleselection.png "A Selection in one view creating a model for use with another view."
50 \image html selectionproxymodelmultipleselection.png "Non-contiguous selection creating a new simple model in a second view."
52 The contents of the secondary view depends on the selection in the primary view, and the configuration of the proxy model.
55 For example, if the filterBehavior is SubTrees, selecting another item in an already selected subtree has no effect.
57 \image html selectionproxymodelmultipleselection-withdescendant.png "Selecting an item and its descendant."
63 Obviously, the KSelectionProxyModel may be used in a view, or further processed with other proxy models.
64 See KAddressBook and AkonadiConsole in kdepim for examples which use a further KDescendantsProxyModel
67 Additionally, this class can be used to programmatically choose some items from the source model to display in the view. For example,
79 Q_PROPERTY(FilterBehavior filterBehavior READ filterBehavior WRITE setFilterBehavior NOTIFY filterBehaviorChanged)
80 Q_PROPERTY(QItemSelectionModel *selectionModel READ selectionModel WRITE setSelectionModel NOTIFY selectionModelChanged)
122 The filter behaviors of the model govern the content of the model based on the selection of the contained QItemSelectionModel.
128 The default behavior is SubTrees. This means that this proxy model will contain the roots of the items in the source model.
161 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:
175 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,
183 Note that although 'D' is selected, it is not part of the proxy model, because its parent 'B' is already selected.
185 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'
202 ChildrenOfExactSelection causes the proxy model to contain the children of the selected indexes,but further descendants are omitted.
203 Additionally, if descendants of an already selected index are selected, their children are part of the proxy model.
217 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
220 The ExactSelection behavior causes the selected items to be part of the proxy model, even if their ancestors are already selected, but children of
248 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
253 bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
312 Q_PRIVATE_SLOT(d_func(), void sourceRowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int))
313 Q_PRIVATE_SLOT(d_func(), void sourceRowsMoved(const QModelIndex &, int, int, const QModelIndex &, int))
319 Q_PRIVATE_SLOT(d_func(), void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected))
A Proxy Model which presents a subset of its source model to observers.
Definition kselectionproxymodel.h:77
void rootIndexAdded(const QModelIndex &newIndex, QPrivateSignal)
void rootSelectionAdded(const QItemSelection &selection, QPrivateSignal)
void rootSelectionAboutToBeRemoved(const QItemSelection &selection, QPrivateSignal)
void rootIndexAboutToBeRemoved(const QModelIndex &removeRootIndex, QPrivateSignal)
Q_SCRIPTABLE Q_NOREPLY void start()
virtual int columnCount(const QModelIndex &parent) const const=0
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const=0
virtual QModelIndexList match(const QModelIndex &start, int role, const QVariant &value, int hits, Qt::MatchFlags flags) const const
virtual int rowCount(const QModelIndex &parent) const const=0
virtual QVariant data(const QModelIndex &proxyIndex, int role) const const override
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
virtual Qt::ItemFlags flags(const QModelIndex &index) const const override
virtual bool hasChildren(const QModelIndex &parent) const const override
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const const override
virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const const=0
virtual QItemSelection mapSelectionFromSource(const QItemSelection &sourceSelection) const const
virtual QItemSelection mapSelectionToSource(const QItemSelection &proxySelection) const const
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const const=0
virtual QMimeData * mimeData(const QModelIndexList &indexes) const const override
virtual QStringList mimeTypes() const const override
virtual void setSourceModel(QAbstractItemModel *sourceModel)
virtual Qt::DropActions supportedDropActions() const const override
Q_ENUM(...)
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
typedef DropActions
DisplayRole
typedef ItemFlags
typedef MatchFlags
Orientation
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:18:35 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:18:35 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.