# KDChart::AbstractProxyModel Class Reference

`#include <KDChartAbstractProxyModel.h>`

Inheritance diagram for KDChart::AbstractProxyModel:

[legend]
Collaboration diagram for KDChart::AbstractProxyModel:

[legend]
List of all members.

## Detailed Description

Base class for all proxy models used inside KD Chart.

Definition at line 43 of file KDChartAbstractProxyModel.h.

## 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 41 of file KDChartAbstractProxyModel.cpp.

    00042   : QAbstractProxyModel(parent) {}

## Member Function Documentation

QModelIndex KDChart::AbstractProxyModel::index | ( | int | row,
|  | int | col,
|  | const QModelIndex & | index |
| ) |  |  | const

[reimplemented]

Definition at line 84 of file KDChartAbstractProxyModel.cpp.

References mapFromSource(), and mapToSource().

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

    00085 {
    00086     Q_ASSERT(sourceModel());
    00087     return mapFromSource(sourceModel()->index( row, col, mapToSource(index) ));
    00088 }

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

[reimplemented]

Definition at line 52 of file KDChartAbstractProxyModel.cpp.

Referenced by index(), and parent().

    00053 {
    00054   if ( !sourceIndex.isValid() )
    00055     return QModelIndex();
    00056   //qDebug() << "sourceIndex.model()="<<sourceIndex.model();
    00057   //qDebug() << "model()="<<sourceModel();
    00058   Q_ASSERT( sourceIndex.model() == sourceModel() );
    00059
    00060   // Create an index that preserves the internal pointer from the source;
    00061   // this way AbstractProxyModel preserves the structure of the source model
    00062   return createIndex( sourceIndex.row(), sourceIndex.column(), sourceIndex.internalPointer() );
    00063 }

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

[reimplemented]

Definition at line 65 of file KDChartAbstractProxyModel.cpp.

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

    00066 {
    00067   if ( !proxyIndex.isValid() )
    00068     return QModelIndex();
    00069   if( proxyIndex.model() != this )
    00070     qDebug() << proxyIndex.model() << this;
    00071   Q_ASSERT( proxyIndex.model() == this );
    00072   // So here we need to create a source index which holds that internal pointer.
    00073   // No way to pass it to sourceModel()->index... so we have to do the ugly way:
    00074   QModelIndex sourceIndex;
    00075   KDPrivateModelIndex* hack = reinterpret_cast<KDPrivateModelIndex*>(&sourceIndex);
    00076   hack->r = proxyIndex.row();
    00077   hack->c = proxyIndex.column();
    00078   hack->p = proxyIndex.internalPointer();
    00079   hack->m = sourceModel();
    00080   Q_ASSERT( sourceIndex.isValid() );
    00081   return sourceIndex;
    00082 }

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

[reimplemented]

Definition at line 90 of file KDChartAbstractProxyModel.cpp.

References mapFromSource(), and mapToSource().

    00091 {
    00092     Q_ASSERT(sourceModel());
    00093     return mapFromSource(sourceModel()->parent( mapToSource(index) ));
    00094 }

The documentation for this class was generated from the following files:

- KDChartAbstractProxyModel.h
- KDChartAbstractProxyModel.cpp