• Skip to content
  • Skip to link menu
KDE 4.5 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
Note: This is a reduced mirror of the KDE API documentation hosted by Michael Pyne.
 

KDEUI

KProxyItemSelectionModel Class Reference

Makes it possible to share a selection in multiple views which do not have the same source model. More...

#include <kproxyitemselectionmodel.h>

Inheritance diagram for KProxyItemSelectionModel:

Inheritance graph
[legend]

List of all members.


Public Member Functions

 KProxyItemSelectionModel (QAbstractItemModel *targetModel, QItemSelectionModel *proxySelector, QObject *parent=0)
void select (const QItemSelection &selection, QItemSelectionModel::SelectionFlags command)
void select (const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
 ~KProxyItemSelectionModel ()

Protected Attributes

KProxyItemSelectionModelPrivate
*const 
d_ptr

Detailed Description

Makes it possible to share a selection in multiple views which do not have the same source model.

Although multiple views can share the same QItemSelectionModel, the views then need to have the same source model.

If there is a proxy model between the model and one of the views, or different proxy models in each, this class makes it possible to share the selection between the views.

kproxyitemselectionmodel-simple.png

Sharing a QItemSelectionModel between views on the same model is trivial

kproxyitemselectionmodel-error.png

If a proxy model is used, it is no longer possible to share the QItemSelectionModel directly

kproxyitemselectionmodel-solution.png

A KProxyItemSelectionModel can be used to map the selection through the proxy model

    QAbstractItemModel *model = getModel();

    QSortFilterProxyModel *proxy = new QSortFilterProxyModel();
    proxy->setSourceModel(model);

    QTreeView *view1 = new QTreeView(splitter);
    view1->setModel(model);

    KProxyItemSelectionModel *view2SelectionModel = new KProxyItemSelectionModel( proxy, view1->selectionModel());

    QTreeView *view2 = new QTreeView(splitter);
    // Note that the QAbstractItemModel passed to KProxyItemSelectionModel must be the same as what is used in the view
    view2->setModel(proxy);
    view2->setSelectionModel( view2SelectionModel );

kproxyitemselectionmodel-complex.png

Arbitrarily complex proxy configurations on the same root model can be used

    QAbstractItemModel *model = getModel();

    QSortFilterProxyModel *proxy1 = new QSortFilterProxyModel();
    proxy1->setSourceModel(model);
    QSortFilterProxyModel *proxy2 = new QSortFilterProxyModel();
    proxy2->setSourceModel(proxy1);
    QSortFilterProxyModel *proxy3 = new QSortFilterProxyModel();
    proxy3->setSourceModel(proxy2);

    QTreeView *view1 = new QTreeView(splitter);
    view1->setModel(proxy3);

    QSortFilterProxyModel *proxy4 = new QSortFilterProxyModel();
    proxy4->setSourceModel(model);
    QSortFilterProxyModel *proxy5 = new QSortFilterProxyModel();
    proxy5->setSourceModel(proxy4);

    KProxyItemSelectionModel *view2SelectionModel = new KProxyItemSelectionModel( proxy5, view1->selectionModel());

    QTreeView *view2 = new QTreeView(splitter);
    // Note that the QAbstractItemModel passed to KProxyItemSelectionModel must be the same as what is used in the view
    view2->setModel(proxy5);
    view2->setSelectionModel( view2SelectionModel );

See also kdelibs/kdeui/tests/proxymodeltestapp/proxyitemselectionwidget.cpp.

Since:
4.5

Definition at line 96 of file kproxyitemselectionmodel.h.


Constructor & Destructor Documentation

KProxyItemSelectionModel::KProxyItemSelectionModel ( QAbstractItemModel *  targetModel,
QItemSelectionModel *  proxySelector,
QObject *  parent = 0 
)

Constructor.

Definition at line 52 of file kproxyitemselectionmodel.cpp.

KProxyItemSelectionModel::~KProxyItemSelectionModel (  ) 

Definition at line 59 of file kproxyitemselectionmodel.cpp.


Member Function Documentation

void KProxyItemSelectionModel::select ( const QItemSelection &  selection,
QItemSelectionModel::SelectionFlags  command 
)

Definition at line 80 of file kproxyitemselectionmodel.cpp.

void KProxyItemSelectionModel::select ( const QModelIndex &  index,
QItemSelectionModel::SelectionFlags  command 
)

Definition at line 64 of file kproxyitemselectionmodel.cpp.


Member Data Documentation

KProxyItemSelectionModelPrivate* const KProxyItemSelectionModel::d_ptr [protected]

Definition at line 112 of file kproxyitemselectionmodel.h.


The documentation for this class was generated from the following files:
  • kproxyitemselectionmodel.h
  • kproxyitemselectionmodel.cpp

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

Class Picker

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  •     Sodep
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.9
This website is maintained by Michael Pyne, and is a reduced mirror of the KDE API docs. KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal