KDescendantsProxyModel Class Reference
from PyKDE4.kdeui import *
Inherits: QAbstractProxyModel → QAbstractItemModel → QObject
Detailed Description
Proxy Model for restructuring a Tree into a list.
A KDescendantsProxyModel may be used to alter how the items in the tree are presented.
Given a model which is represented as a tree:

"A plain EntityTreeModel in a view"
The KDescendantsProxyModel restructures the sourceModel to represent it as a flat list.
// ... Create an entityTreeModel KDescendantsProxyModel *descProxy = new KDescendantsProxyModel(this); descProxy->setSourceModel(entityTree); view->setModel(descProxy);

"A KDescendantsProxyModel."
KDescendantEntitiesProxyModel can also display the ancestors of the index in the source model as part of its display.
// ... Create an entityTreeModel
KDescendantsProxyModel *descProxy = new KDescendantsProxyModel(this);
descProxy->setSourceModel(entityTree);
// #### This is new
descProxy->setDisplayAncestorData(true);
descProxy->setDisplayAncestorSeparator(QString(" / "));
view->setModel(descProxy);

"A KDescendantsProxyModel with ancestor names."
- Since:
- 4.6
| Methods | |
| __init__ (self, QObject parent=0) | |
| QString | ancestorSeparator (self) | 
| int | columnCount (self, QModelIndex index=QModelIndex()) | 
| QVariant | data (self, QModelIndex index, int role=Qt.DisplayRole) | 
| bool | displayAncestorData (self) | 
| Qt::ItemFlags | flags (self, QModelIndex index) | 
| bool | hasChildren (self, QModelIndex parent=QModelIndex()) | 
| QVariant | headerData (self, int section, Qt::Orientation orientation, int role) | 
| QModelIndex | index (self, int a0, int a1, QModelIndex parent=QModelIndex()) | 
| QModelIndex | mapFromSource (self, QModelIndex sourceIndex) | 
| QModelIndex | mapToSource (self, QModelIndex proxyIndex) | 
| [QModelIndex] | match (self, QModelIndex start, int role, QVariant value, int hits=1, Qt::MatchFlags flags=Qt.MatchFlags(Qt.MatchStartsWith|Qt.MatchWrap)) | 
| QMimeData | mimeData (self, [QModelIndex] indexes) | 
| QStringList | mimeTypes (self) | 
| QModelIndex | parent (self, QModelIndex a0) | 
| int | rowCount (self, QModelIndex parent=QModelIndex()) | 
| setAncestorSeparator (self, QString separator) | |
| setDisplayAncestorData (self, bool display) | |
| setRootIndex (self, QModelIndex index) | |
| setSourceModel (self, QAbstractItemModel model) | |
| Qt::DropActions | supportedDropActions (self) | 
Method Documentation
| __init__ | ( | self, | ||
| QObject | parent=0 | |||
| ) | 
Creates a new descendant entities proxy model.
- Parameters:
- 
parent The parent object. 
| QString ancestorSeparator | ( | self ) | 
Separator used between data of ancestors.
| int columnCount | ( | self, | ||
| QModelIndex | index=QModelIndex() | |||
| ) | 
| QVariant data | ( | self, | ||
| QModelIndex | index, | |||
| int | role=Qt.DisplayRole | |||
| ) | 
| bool displayAncestorData | ( | self ) | 
Whether ancestor data will be displayed.
| Qt::ItemFlags flags | ( | self, | ||
| QModelIndex | index | |||
| ) | 
| bool hasChildren | ( | self, | ||
| QModelIndex | parent=QModelIndex() | |||
| ) | 
| QVariant headerData | ( | self, | ||
| int | section, | |||
| Qt::Orientation | orientation, | |||
| int | role | |||
| ) | 
| QModelIndex index | ( | self, | ||
| int | a0, | |||
| int | a1, | |||
| QModelIndex | parent=QModelIndex() | |||
| ) | 
| QModelIndex mapFromSource | ( | self, | ||
| QModelIndex | sourceIndex | |||
| ) | 
| QModelIndex mapToSource | ( | self, | ||
| QModelIndex | proxyIndex | |||
| ) | 
| [QModelIndex] match | ( | self, | ||
| QModelIndex | start, | |||
| int | role, | |||
| QVariant | value, | |||
| int | hits=1, | |||
| Qt::MatchFlags | flags=Qt.MatchFlags(Qt.MatchStartsWith|Qt.MatchWrap) | |||
| ) | 
Reimplemented to match all descendants.
| QMimeData mimeData | ( | self, | ||
| [QModelIndex] | indexes | |||
| ) | 
| QStringList mimeTypes | ( | self ) | 
| QModelIndex parent | ( | self, | ||
| QModelIndex | a0 | |||
| ) | 
| int rowCount | ( | self, | ||
| QModelIndex | parent=QModelIndex() | |||
| ) | 
| setAncestorSeparator | ( | self, | ||
| QString | separator | |||
| ) | 
Sets the ancestor separator used between data of ancestors.
| setDisplayAncestorData | ( | self, | ||
| bool | display | |||
| ) | 
Set whether to show ancestor data in the model. If display is true, then a source model which is displayed as
-> "Item 0-0" (this is row-depth) -> -> "Item 0-1" -> -> "Item 1-1" -> -> -> "Item 0-2" -> -> -> "Item 1-2" -> "Item 1-0"
will be displayed as
-> *Item 0-0" -> "Item 0-0 / Item 0-1" -> "Item 0-0 / Item 1-1" -> "Item 0-0 / Item 1-1 / Item 0-2" -> "Item 0-0 / Item 1-1 / Item 1-2" -> "Item 1-0"
If display is false, the proxy will show
-> *Item 0-0" -> "Item 0-1" -> "Item 1-1" -> "Item 0-2" -> "Item 1-2" -> "Item 1-0"
Default is false.
| setRootIndex | ( | self, | ||
| QModelIndex | index | |||
| ) | 
- Deprecated:
This method does nothing.
| setSourceModel | ( | self, | ||
| QAbstractItemModel | model | |||
| ) | 
Sets the source model of the proxy.
| Qt::DropActions supportedDropActions | ( | self ) | 
 KDE 4.9 PyKDE API Reference
        KDE 4.9 PyKDE API Reference