KDE 4.9 PyKDE API Reference

- KDE's Python API

# KCheckableProxyModel Class Reference

`from PyKDE4.kdeui import *`

Inherits: KIdentityProxyModel → QAbstractProxyModel → QAbstractItemModel → QObject

## Detailed Description

Adds a checkable capability to a source model

Items is standard Qt views such as QTreeView and QListView can have a checkable capability and draw checkboxes. Adding such a capability requires specific implementations of the data() and flags() virtual methods. This class implements those methods generically so that it is not necessary to implement them in your model.

This can be combined with a KSelectionProxyModel showing the items currently selected

       QItemSelectionModel *checkModel = new QItemSelectionModel(rootModel, this);
       KCheckableProxyModel *checkable = new KCheckableProxyModel(this);
       checkable->setSourceModel(rootModel);
       checkable->setSelectionModel(checkModel);

       QTreeView *tree1 = new QTreeView(vSplitter);
       tree1->setModel(checkable);
       tree1->expandAll();

       KSelectionProxyModel *selectionProxy = new KSelectionProxyModel(checkModel, this);
       selectionProxy->setFilterBehavior(KSelectionProxyModel.ExactSelection);
       selectionProxy->setSourceModel(rootModel);

       QTreeView *tree2 = new QTreeView(vSplitter);
       tree2->setModel(selectionProxy);

"A KCheckableProxyModel and KSelectionProxyModel showing checked items"

Since:
  4.6

Author:
  Stephen Kelly <steveire@gmail.com>

## Methods

| __init__ (self, QObject parent=0)
QVariant | data (self, QModelIndex index, int role=Qt.DisplayRole)
Qt::ItemFlags | flags (self, QModelIndex index)
bool | select (self, QItemSelection selection, QItemSelectionModel::SelectionFlags command)
QItemSelectionModel | selectionModel (self)
bool | setData (self, QModelIndex index, QVariant value, int role=Qt.EditRole)
| setSelectionModel (self, QItemSelectionModel itemSelectionModel)
| setSourceModel (self, QAbstractItemModel sourceModel)

## Method Documentation

__init__ | ( | self, |
|  | QObject | parent=0
| ) |  |  |

QVariant data | ( | self, |
|  | QModelIndex | index,
|  | int | role=Qt.DisplayRole
| ) |  |  |

Qt::ItemFlags flags | ( | self, |
|  | QModelIndex | index
| ) |  |  |

bool select | ( | self, |
|  | QItemSelection | selection,
|  | QItemSelectionModel::SelectionFlags | command
| ) |  |  |

QItemSelectionModel selectionModel | ( |  | self ) |

bool setData | ( | self, |
|  | QModelIndex | index,
|  | QVariant | value,
|  | int | role=Qt.EditRole
| ) |  |  |

setSelectionModel | ( | self, |
|  | QItemSelectionModel | itemSelectionModel
| ) |  |  |

setSourceModel | ( | self, |
|  | QAbstractItemModel | sourceModel
| ) |  |  |