KDE 4.5 PyKDE API Reference
  • KDE's Python API
  • Overview
  • PyKDE Home
  • Sitemap
  • Contact Us
 

KLinkItemSelectionModel Class Reference

from PyKDE4.kdeui import *

Inherits: QItemSelectionModel → QObject

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.

"Sharing a QItemSelectionModel between views on the same model is trivial"

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

"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 );

"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
Author:
Stephen Kelly <steveire@gmail.com>


Methods

 __init__ (self, QAbstractItemModel targetModel, QItemSelectionModel linkedItemSelectionModel, QObject parent=0)
 select (self, QModelIndex index, QItemSelectionModel.SelectionFlags command)
 select (self, QItemSelection selection, QItemSelectionModel.SelectionFlags command)

Method Documentation

__init__ (  self,
QAbstractItemModel  targetModel,
QItemSelectionModel  linkedItemSelectionModel,
QObject  parent=0
)

Constructor.

select (  self,
QModelIndex  index,
QItemSelectionModel.SelectionFlags  command
)
select (  self,
QItemSelection  selection,
QItemSelectionModel.SelectionFlags  command
)
  • Full Index

Modules

  • akonadi
  • dnssd
  • kdecore
  • kdeui
  • khtml
  • kio
  • knewstuff
  • kparts
  • kutils
  • nepomuk
  • phonon
  • plasma
  • polkitqt
  • solid
  • soprano
This documentation is maintained by Simon Edwards.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal