• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

KDEUI

Public Member Functions

KDescendantsProxyModel Class Reference

Proxy Model for restructuring a Tree into a list. More...

#include <kdescendantsproxymodel.h>

Inheritance diagram for KDescendantsProxyModel:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 KDescendantsProxyModel (QObject *parent=0)
virtual ~KDescendantsProxyModel ()
QString ancestorSeparator () const
virtual int columnCount (const QModelIndex &index=QModelIndex()) const
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const
int descendantCount (const QModelIndex &index) const
bool displayAncestorData () const
virtual Qt::ItemFlags flags (const QModelIndex &index) const
virtual bool hasChildren (const QModelIndex &parent=QModelIndex()) const
virtual QVariant headerData (int section, Qt::Orientation orientation, int role) const
virtual QModelIndex index (int, int, const QModelIndex &parent=QModelIndex()) const
QModelIndex mapFromSource (const QModelIndex &sourceIndex) const
QModelIndex mapToSource (const QModelIndex &proxyIndex) const
virtual QModelIndexList match (const QModelIndex &start, int role, const QVariant &value, int hits=1, Qt::MatchFlags flags=Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const
virtual QMimeData * mimeData (const QModelIndexList &indexes) const
virtual QStringList mimeTypes () const
virtual QModelIndex parent (const QModelIndex &) const
virtual int rowCount (const QModelIndex &parent=QModelIndex()) const
void setAncestorSeparator (const QString &separator)
void setDisplayAncestorData (bool display)
void setRootIndex (const QModelIndex &index)
virtual void setSourceModel (QAbstractItemModel *model)
virtual Qt::DropActions supportedDropActions () const

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:

entitytreemodel.png

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);
descendantentitiesproxymodel.png

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 KDescendantesProxyModel(this);
descProxy->setSourceModel(entityTree);

// #### This is new
descProxy->setDisplayAncestorData(true, QString( " / " ));

view->setModel(descProxy);
descendantentitiesproxymodel-withansecnames.png

A KDescendantsProxyModel with ancestor names.

Since:
4.6
Author:
Stephen Kelly <steveire@gmail.com>

Definition at line 69 of file kdescendantsproxymodel.h.


Constructor & Destructor Documentation

KDescendantsProxyModel::KDescendantsProxyModel ( QObject *  parent = 0) [explicit]

Creates a new descendant entities proxy model.

Parameters:
parentThe parent object.

Definition at line 213 of file kdescendantsproxymodel.cpp.

KDescendantsProxyModel::~KDescendantsProxyModel ( ) [virtual]

Destroys the descendant entities proxy model.

Definition at line 218 of file kdescendantsproxymodel.cpp.


Member Function Documentation

QString KDescendantsProxyModel::ancestorSeparator ( ) const

Separator used between data of ancestors.

Definition at line 251 of file kdescendantsproxymodel.cpp.

int KDescendantsProxyModel::columnCount ( const QModelIndex &  index = QModelIndex()) const [virtual]

Definition at line 481 of file kdescendantsproxymodel.cpp.

QVariant KDescendantsProxyModel::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const

Definition at line 489 of file kdescendantsproxymodel.cpp.

int KDescendantsProxyModel::descendantCount ( const QModelIndex &  index) const

Returns the number of descendant entries for the given model index.

bool KDescendantsProxyModel::displayAncestorData ( ) const

Whether ancestor data will be displayed.

Definition at line 239 of file kdescendantsproxymodel.cpp.

Qt::ItemFlags KDescendantsProxyModel::flags ( const QModelIndex &  index) const [virtual]

Definition at line 529 of file kdescendantsproxymodel.cpp.

bool KDescendantsProxyModel::hasChildren ( const QModelIndex &  parent = QModelIndex()) const [virtual]

Definition at line 327 of file kdescendantsproxymodel.cpp.

QVariant KDescendantsProxyModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role 
) const [virtual]

Definition at line 521 of file kdescendantsproxymodel.cpp.

QModelIndex KDescendantsProxyModel::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const [virtual]

Definition at line 347 of file kdescendantsproxymodel.cpp.

QModelIndex KDescendantsProxyModel::mapFromSource ( const QModelIndex &  sourceIndex) const

Definition at line 419 of file kdescendantsproxymodel.cpp.

QModelIndex KDescendantsProxyModel::mapToSource ( const QModelIndex &  proxyIndex) const

Definition at line 358 of file kdescendantsproxymodel.cpp.

QModelIndexList KDescendantsProxyModel::match ( const QModelIndex &  start,
int  role,
const QVariant &  value,
int  hits = 1,
Qt::MatchFlags  flags = Qt::MatchFlags( Qt::MatchStartsWith | Qt::MatchWrap ) 
) const [virtual]

Reimplemented to match all descendants.

Definition at line 228 of file kdescendantsproxymodel.cpp.

QMimeData * KDescendantsProxyModel::mimeData ( const QModelIndexList &  indexes) const [virtual]

Definition at line 981 of file kdescendantsproxymodel.cpp.

QStringList KDescendantsProxyModel::mimeTypes ( ) const [virtual]

Definition at line 992 of file kdescendantsproxymodel.cpp.

QModelIndex KDescendantsProxyModel::parent ( const QModelIndex &  index) const [virtual]

Definition at line 321 of file kdescendantsproxymodel.cpp.

int KDescendantsProxyModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const [virtual]

Definition at line 333 of file kdescendantsproxymodel.cpp.

void KDescendantsProxyModel::setAncestorSeparator ( const QString &  separator)

Sets the ancestor separator used between data of ancestors.

Definition at line 245 of file kdescendantsproxymodel.cpp.

void KDescendantsProxyModel::setDisplayAncestorData ( 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.

Definition at line 233 of file kdescendantsproxymodel.cpp.

void KDescendantsProxyModel::setRootIndex ( const QModelIndex &  index)

Sets the root index to index.

This is the root of the proxy model.

Parameters:
indexThe root index in the *source* model which will be shown in this model. If the index is invalid, the model is empty.
Note:
You must set the model before setting the root index.

Definition at line 223 of file kdescendantsproxymodel.cpp.

void KDescendantsProxyModel::setSourceModel ( QAbstractItemModel *  model) [virtual]

Sets the source model of the proxy.

Definition at line 258 of file kdescendantsproxymodel.cpp.

Qt::DropActions KDescendantsProxyModel::supportedDropActions ( ) const [virtual]

Definition at line 1000 of file kdescendantsproxymodel.cpp.


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

KDEUI

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

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
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal