Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

KDChart::AbstractProxyModel Class Reference

#include <KDChartAbstractProxyModel.h>

Inheritance diagram for KDChart::AbstractProxyModel:

[legend]
Collaboration diagram for KDChart::AbstractProxyModel:
[legend]
List of all members.

Public Member Functions

 AbstractProxyModel (QObject *parent=0)
 This is basically KDAbstractProxyModel, but only the bits that we really need from it.

QModelIndex index (int row, int col, const QModelIndex &index) const
QModelIndex mapFromSource (const QModelIndex &sourceIndex) const
QModelIndex mapToSource (const QModelIndex &proxyIndex) const
QModelIndex parent (const QModelIndex &index) const

Constructor & Destructor Documentation

KDChart::AbstractProxyModel::AbstractProxyModel QObject parent = 0  )  [explicit]
 

This is basically KDAbstractProxyModel, but only the bits that we really need from it.

Definition at line 12 of file KDChartAbstractProxyModel.cpp.

00013   : QAbstractProxyModel(parent) {}


Member Function Documentation

QModelIndex KDChart::AbstractProxyModel::index int  row,
int  col,
const QModelIndex &  index
const
 

Definition at line 53 of file KDChartAbstractProxyModel.cpp.

References mapFromSource(), and mapToSource().

Referenced by KDChart::AttributesModel::setHeaderData(), and KDChart::AttributesModel::setModelData().

00054 {
00055     Q_ASSERT(sourceModel());
00056     return mapFromSource(sourceModel()->index( row, col, mapToSource(index) ));
00057 }

QModelIndex KDChart::AbstractProxyModel::mapFromSource const QModelIndex &  sourceIndex  )  const
 

Definition at line 23 of file KDChartAbstractProxyModel.cpp.

Referenced by index(), and parent().

00024 {
00025   if ( !sourceIndex.isValid() )
00026     return QModelIndex();
00027   //qDebug() << "sourceIndex.model()="<<sourceIndex.model();
00028   //qDebug() << "model()="<<sourceModel();
00029   Q_ASSERT( sourceIndex.model() == sourceModel() );
00030 
00031   // Create an index that preserves the internal pointer from the source;
00032   // this way AbstractProxyModel preserves the structure of the source model
00033   return createIndex( sourceIndex.row(), sourceIndex.column(), sourceIndex.internalPointer() );
00034 }

QModelIndex KDChart::AbstractProxyModel::mapToSource const QModelIndex &  proxyIndex  )  const
 

Definition at line 36 of file KDChartAbstractProxyModel.cpp.

Referenced by KDChart::AttributesModel::columnCount(), KDChart::AttributesModel::data(), index(), parent(), KDChart::AttributesModel::rowCount(), and KDChart::AttributesModel::setData().

00037 {
00038   if ( !proxyIndex.isValid() )
00039     return QModelIndex();
00040   Q_ASSERT( proxyIndex.model() == this );
00041   // So here we need to create a source index which holds that internal pointer.
00042   // No way to pass it to sourceModel()->index... so we have to do the ugly way:
00043   QModelIndex sourceIndex;
00044   KDPrivateModelIndex* hack = reinterpret_cast<KDPrivateModelIndex*>(&sourceIndex);
00045   hack->r = proxyIndex.row();
00046   hack->c = proxyIndex.column();
00047   hack->p = proxyIndex.internalPointer();
00048   hack->m = sourceModel();
00049   Q_ASSERT( sourceIndex.isValid() );
00050   return sourceIndex;
00051 }

QModelIndex KDChart::AbstractProxyModel::parent const QModelIndex &  index  )  const
 

Definition at line 59 of file KDChartAbstractProxyModel.cpp.

References mapFromSource(), and mapToSource().

00060 {
00061     Q_ASSERT(sourceModel());
00062     return mapFromSource(sourceModel()->parent( mapToSource(index) ));
00063 }


The documentation for this class was generated from the following files:
Generated on Thu May 10 11:06:31 2007 for KD Chart 2 by doxygen 1.3.6