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

akonadi_next

Public Member Functions | List of all members
KReparentingProxyModel Class Reference

#include <kreparentingproxymodel.h>

Inheritance diagram for KReparentingProxyModel:
Inheritance graph
[legend]

Public Member Functions

 KReparentingProxyModel (QObject *parent=0)
 
 ~KReparentingProxyModel ()
 
virtual int columnCount (const QModelIndex &parent=QModelIndex()) const
 
virtual QVariant data (const QModelIndex &proxyIndex, int role=Qt::DisplayRole) const
 
virtual bool hasChildren (const QModelIndex &parent=QModelIndex()) const
 
virtual QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const
 
virtual bool isDescendantOf (const QModelIndex &ancestor, const QModelIndex &descendant) const
 
virtual QModelIndex mapFromSource (const QModelIndex &sourceIndex) const
 
virtual QModelIndex mapToSource (const QModelIndex &proxyIndex) const
 
virtual QModelIndex parent (const QModelIndex &child) const
 
virtual int rowCount (const QModelIndex &parent=QModelIndex()) const
 
virtual void setSourceModel (QAbstractItemModel *sourceModel)
 
virtual Qt::DropActions supportedDropActions () const
 

Detailed Description

Restructures a source model, changing the parents of items.

Subclasses can change the structure of a source model by reimplementing the isDescendantOf method.

For example, if the source model is a list,

0
- A
- B
- C
- D
- E

It could be converted to a tree by an implementation something like:

bool MyReparentingModel::isDescedantOf(const QModelIndex& ancestor, const QModelIndex& descendant ) const
{
return (
(ancestor.data().toString() == "A" && descendant.data().toString() == "B")
|| (ancestor.data().toString() == "A" && descendant.data().toString() == "C")
|| (ancestor.data().toString() == "B" && descendant.data().toString() == "C")
|| (ancestor.data().toString() == "A" && descendant.data().toString() == "D")
)
? true : KReparentingProxyModel::isDescendantOf(ancestor, descendant);
}

to get this result:

0
- A
- - B
- - - C
- - D
- E

Note that the implementation returns true for a query if "C" is a descendant of "A". The implementation must return the correct value for all of its descendants, not only its direct parent. The actual location to insert the descendant in the tree is determined internally by a binary find algorithm.

Definition at line 74 of file kreparentingproxymodel.h.

Constructor & Destructor Documentation

KReparentingProxyModel::KReparentingProxyModel ( QObject *  parent = 0)
explicit

Definition at line 435 of file kreparentingproxymodel.cpp.

KReparentingProxyModel::~KReparentingProxyModel ( )

Definition at line 441 of file kreparentingproxymodel.cpp.

Member Function Documentation

int KReparentingProxyModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const
virtual

Definition at line 566 of file kreparentingproxymodel.cpp.

QVariant KReparentingProxyModel::data ( const QModelIndex &  proxyIndex,
int  role = Qt::DisplayRole 
) const
virtual

Definition at line 583 of file kreparentingproxymodel.cpp.

bool KReparentingProxyModel::hasChildren ( const QModelIndex &  parent = QModelIndex()) const
virtual

Definition at line 692 of file kreparentingproxymodel.cpp.

QModelIndex KReparentingProxyModel::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const
virtual

Definition at line 588 of file kreparentingproxymodel.cpp.

bool KReparentingProxyModel::isDescendantOf ( const QModelIndex &  ancestor,
const QModelIndex &  descendant 
) const
virtual

Reimplement this to return whether descendant is a descendant of ancestor.

Definition at line 463 of file kreparentingproxymodel.cpp.

QModelIndex KReparentingProxyModel::mapFromSource ( const QModelIndex &  sourceIndex) const
virtual

Definition at line 470 of file kreparentingproxymodel.cpp.

QModelIndex KReparentingProxyModel::mapToSource ( const QModelIndex &  proxyIndex) const
virtual

Definition at line 503 of file kreparentingproxymodel.cpp.

QModelIndex KReparentingProxyModel::parent ( const QModelIndex &  child) const
virtual

Definition at line 619 of file kreparentingproxymodel.cpp.

int KReparentingProxyModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
virtual

Definition at line 671 of file kreparentingproxymodel.cpp.

void KReparentingProxyModel::setSourceModel ( QAbstractItemModel *  sourceModel)
virtual

Definition at line 697 of file kreparentingproxymodel.cpp.

Qt::DropActions KReparentingProxyModel::supportedDropActions ( ) const
virtual

Definition at line 1462 of file kreparentingproxymodel.cpp.


The documentation for this class was generated from the following files:
  • kreparentingproxymodel.h
  • kreparentingproxymodel.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:54:56 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi_next

Skip menu "akonadi_next"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal