# KDChart::AttributesModel Class Reference

`#include <KDChartAttributesModel.h>`

Inheritance diagram for KDChart::AttributesModel:

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

## Public Types

enum | PaletteType { PaletteTypeDefault = 0, PaletteTypeRainbow = 1, PaletteTypeSubdued = 2 }

## Public Member Functions

| AttributesModel (QAbstractItemModel *model, QObject *parent=0)
int | columnCount (const QModelIndex &) const
| [reimplemented]
bool | compare (const AttributesModel *other) const
bool | compareAttributes (int role, const QVariant &a, const QVariant &b) const
QVariant | data (const QModelIndex &, int role=Qt::DisplayRole) const
| [reimplemented]
QVariant | data (int column, int role) const
| Returns the data that were specified at per column level, or the globally set data, or the default data, or QVariant().
QVariant | data (int role) const
| Returns the data that were specified at global level, or the default data, or QVariant().
QVariant | headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
| [reimplemented]
QModelIndex | index (int row, int col, const QModelIndex &index) const
void | initFrom (const AttributesModel *other)
bool | isKnownAttributesRole (int role) const
| Returns whether the given role corresponds to one of the known internally used ones.
QModelIndex | mapFromSource (const QModelIndex &sourceIndex) const
QModelIndex | mapToSource (const QModelIndex &proxyIndex) const
QVariant | modelData (int role) const
PaletteType | paletteType () const
QModelIndex | parent (const QModelIndex &index) const
bool | resetData (const QModelIndex &index, int role=Qt::DisplayRole)
| Remove any explicit attributes settings that might have been specified before.
bool | resetHeaderData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole)
| Remove any explicit attributes settings that might have been specified before.
int | rowCount (const QModelIndex &) const
| [reimplemented]
bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::DisplayRole)
| [reimplemented]
bool | setHeaderData (int section, Qt::Orientation orientation, const QVariant &value, int role=Qt::DisplayRole)
| [reimplemented]
bool | setModelData (const QVariant value, int role)
void | setPaletteType (PaletteType type)
| Sets the palettetype used by this attributesmodel.
void | setSourceModel (QAbstractItemModel *sourceModel)
| [reimplemented]
| ~AttributesModel ()

## Public Attributes

Q_SIGNALS | __pad0__: void attributesChanged( const QModelIndex&

## Protected Member Functions

const QMap< int, QMap< int, QMap< int, QVariant > > > | dataMap () const
| needed for serialization
const QMap< int, QMap< int, QVariant > > | horizontalHeaderDataMap () const
| needed for serialization
const QMap< int, QVariant > | modelDataMap () const
| needed for serialization
void | setDataMap (const QMap< int, QMap< int, QMap< int, QVariant > > > map)
| needed for serialization
void | setHorizontalHeaderDataMap (const QMap< int, QMap< int, QVariant > > map)
| needed for serialization
void | setModelDataMap (const QMap< int, QVariant > map)
| needed for serialization
void | setVerticalHeaderDataMap (const QMap< int, QMap< int, QVariant > > map)
| needed for serialization
const QMap< int, QMap< int, QVariant > > | verticalHeaderDataMap () const
| needed for serialization

## Member Enumeration Documentation

enum KDChart::AttributesModel::PaletteType

Enumeration values:

  PaletteTypeDefault |
  PaletteTypeRainbow |
  PaletteTypeSubdued |

Definition at line 47 of file KDChartAttributesModel.h.

    00047                      {
    00048         PaletteTypeDefault = 0,
    00049         PaletteTypeRainbow = 1,
    00050         PaletteTypeSubdued = 2
    00051     };

## Constructor & Destructor Documentation

AttributesModel::AttributesModel | ( | QAbstractItemModel * | model,
|  | QObject * | parent = 0
| ) | `[explicit]`

Definition at line 56 of file KDChartAttributesModel.cpp.

References setSourceModel().

    00057   : AbstractProxyModel( parent ),
    00058     mPaletteType( PaletteTypeDefault )
    00059 {
    00060   setSourceModel(model);
    00061 }

AttributesModel::~AttributesModel | ( |  | ) |

Definition at line 63 of file KDChartAttributesModel.cpp.

    00064 {
    00065 }

## Member Function Documentation

int AttributesModel::columnCount | ( | const QModelIndex & |  | ) | const

[reimplemented]

Definition at line 503 of file KDChartAttributesModel.cpp.

References KDChart::AbstractProxyModel::mapToSource().

Referenced by setModelData().

    00504 {
    00505     Q_ASSERT(sourceModel());
    00506     return sourceModel()->columnCount( mapToSource(index) );
    00507 }

bool AttributesModel::compare | ( | const AttributesModel * | other | ) | const

Definition at line 79 of file KDChartAttributesModel.cpp.

    00080 {
    00081     if( other == this ) return true;
    00082     if( ! other ){
    00083         //qDebug() << "AttributesModel::compare() cannot compare to Null pointer";
    00084         return false;
    00085     }
    00086
    00087     {
    00088         if (mDataMap.count() != other->mDataMap.count()){
    00089             //qDebug() << "AttributesModel::compare() dataMap have different sizes";
    00090             return false;
    00091         }
    00092         QMap<int, QMap<int, QMap<int, QVariant> > >::const_iterator itA = mDataMap.constBegin();
    00093         QMap<int, QMap<int, QMap<int, QVariant> > >::const_iterator itB = other->mDataMap.constBegin();
    00094         while (itA != mDataMap.constEnd()) {
    00095             if ((*itA).count() != (*itB).count()){
    00096                 //qDebug() << "AttributesModel::compare() dataMap/map have different sizes";
    00097                 return false;
    00098             }
    00099             QMap<int, QMap<int, QVariant> >::const_iterator it2A = (*itA).constBegin();
    00100             QMap<int, QMap<int, QVariant> >::const_iterator it2B = (*itB).constBegin();
    00101             while (it2A != itA->constEnd()) {
    00102                 if ((*it2A).count() != (*it2B).count()){
    00103                     //qDebug() << "AttributesModel::compare() dataMap/map/map have different sizes:"
    00104                     //        << (*it2A).count() << (*it2B).count();
    00105                     return false;
    00106                 }
    00107                 QMap<int, QVariant>::const_iterator it3A = (*it2A).constBegin();
    00108                 QMap<int, QVariant>::const_iterator it3B = (*it2B).constBegin();
    00109                 while (it3A != it2A->constEnd()) {
    00110                     if ( it3A.key() != it3B.key() ){
    00111                         //qDebug( "AttributesModel::compare()\n"
    00112                         //        "   dataMap[%i, %i] values have different types.  A: %x  B: %x",
    00113                         //        itA.key(), it2A.key(), it3A.key(), it3B.key());
    00114                         return false;
    00115                     }
    00116                     if ( ! compareAttributes( it3A.key(), it3A.value(), it3B.value() ) ){
    00117                         //qDebug( "AttributesModel::compare()\n"
    00118                         //        "   dataMap[%i, %i] values are different. Role: %x", itA.key(), it2A.key(), it3A.key());
    00119                         return false;
    00120                     }
    00121                     ++it3A;
    00122                     ++it3B;
    00123                 }
    00124                 ++it2A;
    00125                 ++it2B;
    00126             }
    00127             ++itA;
    00128             ++itB;
    00129         }
    00130     }
    00131     {
    00132         if (mHorizontalHeaderDataMap.count() != other->mHorizontalHeaderDataMap.count()){
    00133             //qDebug() << "AttributesModel::compare() horizontalHeaderDataMap have different sizes";
    00134             return false;
    00135         }
    00136         QMap<int, QMap<int, QVariant> >::const_iterator itA = mHorizontalHeaderDataMap.constBegin();
    00137         QMap<int, QMap<int, QVariant> >::const_iterator itB = other->mHorizontalHeaderDataMap.constBegin();
    00138         while (itA != mHorizontalHeaderDataMap.constEnd()) {
    00139             if ((*itA).count() != (*itB).count()){
    00140                 //qDebug() << "AttributesModel::compare() horizontalHeaderDataMap/map have different sizes";
    00141                 return false;
    00142             }
    00143             QMap<int, QVariant>::const_iterator it2A = (*itA).constBegin();
    00144             QMap<int, QVariant>::const_iterator it2B = (*itB).constBegin();
    00145             while (it2A != itA->constEnd()) {
    00146                 if ( it2A.key() != it2B.key() ){
    00147                     //qDebug( "AttributesModel::compare()\n"
    00148                     //        "   horizontalHeaderDataMap[ %i ] values have different types.  A: %x  B: %x",
    00149                     //        itA.key(), it2A.key(), it2B.key());
    00150                     return false;
    00151                 }
    00152                 if ( ! compareAttributes( it2A.key(), it2A.value(), it2B.value() ) ){
    00153                     //qDebug( "AttributesModel::compare()\n"
    00154                     //        "   horizontalHeaderDataMap[ %i ] values are different. Role: %x", itA.key(), it2A.key() );
    00155                     return false;
    00156                 }
    00157                 ++it2A;
    00158                 ++it2B;
    00159             }
    00160             ++itA;
    00161             ++itB;
    00162         }
    00163     }
    00164     {
    00165         if (mVerticalHeaderDataMap.count() != other->mVerticalHeaderDataMap.count()){
    00166             //qDebug() << "AttributesModel::compare() verticalHeaderDataMap have different sizes";
    00167             return false;
    00168         }
    00169         QMap<int, QMap<int, QVariant> >::const_iterator itA = mVerticalHeaderDataMap.constBegin();
    00170         QMap<int, QMap<int, QVariant> >::const_iterator itB = other->mVerticalHeaderDataMap.constBegin();
    00171         while (itA != mVerticalHeaderDataMap.constEnd()) {
    00172             if ((*itA).count() != (*itB).count()){
    00173                 //qDebug() << "AttributesModel::compare() verticalHeaderDataMap/map have different sizes";
    00174                 return false;
    00175             }
    00176             QMap<int, QVariant>::const_iterator it2A = (*itA).constBegin();
    00177             QMap<int, QVariant>::const_iterator it2B = (*itB).constBegin();
    00178             while (it2A != itA->constEnd()) {
    00179                 if ( it2A.key() != it2B.key() ){
    00180                     //qDebug( "AttributesModel::compare()\n"
    00181                     //        "   verticalHeaderDataMap[ %i ] values have different types.  A: %x  B: %x",
    00182                     //        itA.key(), it2A.key(), it2B.key());
    00183                     return false;
    00184                 }
    00185                 if ( ! compareAttributes( it2A.key(), it2A.value(), it2B.value() ) ){
    00186                     //qDebug( "AttributesModel::compare()\n"
    00187                     //        "   verticalHeaderDataMap[ %i ] values are different. Role: %x", itA.key(), it2A.key() );
    00188                     return false;
    00189                 }
    00190                 ++it2A;
    00191                 ++it2B;
    00192             }
    00193             ++itA;
    00194             ++itB;
    00195         }
    00196     }
    00197     {
    00198         if (mModelDataMap.count() != other->mModelDataMap.count()){
    00199             //qDebug() << "AttributesModel::compare() modelDataMap have different sizes:" << mModelDataMap.count() << other->mModelDataMap.count();
    00200             return false;
    00201         }
    00202         QMap<int, QVariant>::const_iterator itA = mModelDataMap.constBegin();
    00203         QMap<int, QVariant>::const_iterator itB = other->mModelDataMap.constBegin();
    00204         while (itA != mModelDataMap.constEnd()) {
    00205             if ( itA.key() != itB.key() ){
    00206                 //qDebug( "AttributesModel::compare()\n"
    00207                 //        "   modelDataMap values have different types.  A: %x  B: %x",
    00208                 //        itA.key(), itB.key());
    00209                 return false;
    00210             }
    00211             if ( ! compareAttributes( itA.key(), itA.value(), itB.value() ) ){
    00212                 //qDebug( "AttributesModel::compare()\n"
    00213                 //        "   modelDataMap values are different. Role: %x", itA.key() );
    00214                 return false;
    00215             }
    00216             ++itA;
    00217             ++itB;
    00218         }
    00219     }
    00220     if (paletteType() != other->paletteType()){
    00221         //qDebug() << "AttributesModel::compare() palette types are different";
    00222         return false;
    00223     }
    00224     return true;
    00225 }

bool AttributesModel::compareAttributes | ( | int | role,
|  | const QVariant & | a,
|  | const QVariant & | b
| ) | const

Definition at line 227 of file KDChartAttributesModel.cpp.

References KDChart::BarAttributesRole, KDChart::DataHiddenRole, KDChart::DatasetBrushRole, KDChart::DatasetPenRole, KDChart::DataValueLabelAttributesRole, KDChart::LineAttributesRole, KDChart::PieAttributesRole, KDChart::ThreeDAttributesRole, KDChart::ThreeDBarAttributesRole, KDChart::ThreeDLineAttributesRole, and KDChart::ThreeDPieAttributesRole.

    00229 {
    00230     if( isKnownAttributesRole( role ) ){
    00231         switch( role ) {
    00232             case DataValueLabelAttributesRole:
    00233                 return (qVariantValue<DataValueAttributes>( a ) ==
    00234                         qVariantValue<DataValueAttributes>( b ));
    00235             case DatasetBrushRole:
    00236                 return (qVariantValue<QBrush>( a ) ==
    00237                         qVariantValue<QBrush>( b ));
    00238             case DatasetPenRole:
    00239                 return (qVariantValue<QPen>( a ) ==
    00240                         qVariantValue<QPen>( b ));
    00241             case ThreeDAttributesRole:
    00242                 // As of yet there is no ThreeDAttributes class,
    00243                 // and the AbstractThreeDAttributes class is pure virtual,
    00244                 // so we ignore this role for now.
    00245                 // (khz, 04.04.2007)
    00246                 /*
    00247                 return (qVariantValue<ThreeDAttributes>( a ) ==
    00248                         qVariantValue<ThreeDAttributes>( b ));
    00249                 */
    00250                 break;
    00251             case LineAttributesRole:
    00252                 return (qVariantValue<LineAttributes>( a ) ==
    00253                         qVariantValue<LineAttributes>( b ));
    00254             case ThreeDLineAttributesRole:
    00255                 return (qVariantValue<ThreeDLineAttributes>( a ) ==
    00256                         qVariantValue<ThreeDLineAttributes>( b ));
    00257             case BarAttributesRole:
    00258                 return (qVariantValue<BarAttributes>( a ) ==
    00259                         qVariantValue<BarAttributes>( b ));
    00260             case ThreeDBarAttributesRole:
    00261                 return (qVariantValue<ThreeDBarAttributes>( a ) ==
    00262                         qVariantValue<ThreeDBarAttributes>( b ));
    00263             case PieAttributesRole:
    00264                 return (qVariantValue<PieAttributes>( a ) ==
    00265                         qVariantValue<PieAttributes>( b ));
    00266             case ThreeDPieAttributesRole:
    00267                 return (qVariantValue<ThreeDPieAttributes>( a ) ==
    00268                         qVariantValue<ThreeDPieAttributes>( b ));
    00269             case DataHiddenRole:
    00270                 return (qVariantValue<bool>( a ) ==
    00271                         qVariantValue<bool>( b ));
    00272             default:
    00273                 Q_ASSERT( false ); // all of our own roles need to be handled
    00274                 break;
    00275         }
    00276     }else{
    00277         return (a == b);
    00278     }
    00279     return true;
    00280 }

QVariant AttributesModel::data | ( | const QModelIndex & | ,
|  | int | role = Qt::DisplayRole
| ) | const

[reimplemented]

Definition at line 366 of file KDChartAttributesModel.cpp.

References data(), dataMap(), and KDChart::AbstractProxyModel::mapToSource().

    00367 {
    00368   //qDebug() << "AttributesModel::data(" << index << role << ")";
    00369   if( index.isValid() ) {
    00370     Q_ASSERT( index.model() == this );
    00371   }
    00372   QVariant sourceData = sourceModel()->data( mapToSource(index), role );
    00373   if ( sourceData.isValid() )
    00374       return sourceData;
    00375
    00376   // check if we are storing a value for this role at this cell index
    00377   if ( mDataMap.contains( index.column() ) ) {
    00378       const QMap< int,  QMap< int, QVariant> > &colDataMap = mDataMap[ index.column() ];
    00379       if ( colDataMap.contains( index.row() ) ) {
    00380           const QMap<int, QVariant> &dataMap = colDataMap[ index.row() ];
    00381           if ( dataMap.contains( role ) ) {
    00382               QVariant v = dataMap[ role ];
    00383               if( v.isValid() )
    00384                   return dataMap[ role ];
    00385           }
    00386       }
    00387   }
    00388   // check if there is something set for the column (dataset), or at global level
    00389   if( index.isValid() )
    00390       return data( index.column(), role ); // includes automatic fallback to default
    00391
    00392   return QVariant();
    00393 }

QVariant AttributesModel::data | ( | int | column,
|  | int | role
| ) | const

Returns the data that were specified at per column level, or the globally set data, or the default data, or QVariant().

Definition at line 350 of file KDChartAttributesModel.cpp.

References data(), headerData(), and isKnownAttributesRole().

    00351 {
    00352   if ( isKnownAttributesRole( role ) ) {
    00353       // check if there is something set for the column (dataset)
    00354       QVariant v;
    00355       v = headerData( column, Qt::Vertical, role );
    00356
    00357       // check if there is something set at global level
    00358       if ( !v.isValid() )
    00359           v = data( role ); // includes automatic fallback to default
    00360       return v;
    00361   }
    00362   return QVariant();
    00363 }

QVariant AttributesModel::data | ( | int | role | ) | const

Returns the data that were specified at global level, or the default data, or QVariant().

Definition at line 332 of file KDChartAttributesModel.cpp.

References isKnownAttributesRole(), and modelData().

Referenced by data().

    00333 {
    00334   if ( isKnownAttributesRole( role ) ) {
    00335       // check if there is something set at global level
    00336       QVariant v = modelData( role );
    00337
    00338       // else return the default setting, if any
    00339       if ( !v.isValid() )
    00340           v = defaultsForRole( role );
    00341       return v;
    00342   }
    00343   return QVariant();
    00344 }

const QMap< int, QMap< int, QMap< int, QVariant > > > AttributesModel::dataMap | ( |  | ) | const`[protected]`

needed for serialization

Definition at line 521 of file KDChartAttributesModel.cpp.

Referenced by data(), headerData(), setData(), and setHeaderData().

    00522 {
    00523     return mDataMap;
    00524 }

QVariant AttributesModel::headerData | ( | int | section,
|  | Qt::Orientation | orientation,
|  | int | role = Qt::DisplayRole
| ) | const

[reimplemented]

Definition at line 283 of file KDChartAttributesModel.cpp.

References dataMap(), KDChart::DatasetBrushRole, KDChart::Palette::defaultPalette(), KDChart::Palette::getBrush(), modelData(), paletteType(), PaletteTypeDefault, PaletteTypeRainbow, PaletteTypeSubdued, KDChart::Palette::rainbowPalette(), and KDChart::Palette::subduedPalette().

Referenced by data(), KDChart::RingDiagram::paint(), and KDChart::PolarDiagram::paint().

    00286 {
    00287   QVariant sourceData = sourceModel()->headerData( section, orientation, role );
    00288   if ( sourceData.isValid() ) return sourceData;
    00289   // the source model didn't have data set, let's use our stored values
    00290   const QMap<int, QMap<int, QVariant> >& map = orientation == Qt::Horizontal ? mHorizontalHeaderDataMap : mVerticalHeaderDataMap;
    00291   if ( map.contains( section ) ) {
    00292       const QMap<int, QVariant> &dataMap = map[ section ];
    00293       if ( dataMap.contains( role ) ) {
    00294           return dataMap[ role ];
    00295       }
    00296   }
    00297
    00298   // Default values if nothing else matches
    00299   switch ( role ) {
    00300   case Qt::DisplayRole:
    00301       return QLatin1String( orientation == Qt::Vertical ?  "Series " : "Item " ) + QString::number( section ) ;
    00302
    00303   case KDChart::DatasetBrushRole: {
    00304       if ( paletteType() == PaletteTypeSubdued )
    00305           return Palette::subduedPalette().getBrush( section );
    00306       else if ( paletteType() == PaletteTypeRainbow )
    00307           return Palette::rainbowPalette().getBrush( section );
    00308       else if ( paletteType() == PaletteTypeDefault )
    00309           return Palette::defaultPalette().getBrush( section );
    00310       else
    00311           qWarning("Unknown type of fallback palette!");
    00312   }
    00313   case KDChart::DatasetPenRole: {
    00314       // default to the color set for the brush (or it's defaults)
    00315       // but only if no per model override was set
    00316       if ( !modelData( role ).isValid() ) {
    00317           QBrush brush = qVariantValue<QBrush>( headerData( section, orientation, DatasetBrushRole ) );
    00318           return QPen( brush.color() );
    00319       }
    00320   }
    00321   default:
    00322       break;
    00323   }
    00324
    00325   return QVariant();
    00326 }

const QMap< int, QMap< int, QVariant > > AttributesModel::horizontalHeaderDataMap | ( |  | ) | const`[protected]`

needed for serialization

Definition at line 526 of file KDChartAttributesModel.cpp.

    00527 {
    00528     return mHorizontalHeaderDataMap;
    00529 }

QModelIndex KDChart::AbstractProxyModel::index | ( | int | row,
|  | int | col,
|  | const QModelIndex & | index
| ) | const`[inherited]`

Definition at line 53 of file KDChartAbstractProxyModel.cpp.

References KDChart::AbstractProxyModel::mapFromSource(), and KDChart::AbstractProxyModel::mapToSource().

Referenced by setHeaderData(), and setModelData().

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

void AttributesModel::initFrom | ( | const AttributesModel * | other | ) |

Definition at line 67 of file KDChartAttributesModel.cpp.

References mDataMap, mHorizontalHeaderDataMap, mModelDataMap, mVerticalHeaderDataMap, paletteType(), and setPaletteType().

Referenced by KDChart::AbstractDiagram::setModel().

    00068 {
    00069     if( other == this || ! other ) return;
    00070
    00071     mDataMap = other->mDataMap;
    00072     mHorizontalHeaderDataMap = other->mHorizontalHeaderDataMap;
    00073     mVerticalHeaderDataMap = other->mVerticalHeaderDataMap;
    00074     mModelDataMap = other->mModelDataMap;
    00075
    00076     setPaletteType( other->paletteType() );
    00077 }

bool AttributesModel::isKnownAttributesRole | ( | int | role | ) | const

Returns whether the given role corresponds to one of the known internally used ones.

Definition at line 396 of file KDChartAttributesModel.cpp.

References KDChart::BarAttributesRole, KDChart::DataHiddenRole, KDChart::DatasetBrushRole, KDChart::DatasetPenRole, KDChart::DataValueLabelAttributesRole, KDChart::LineAttributesRole, KDChart::PieAttributesRole, KDChart::ThreeDAttributesRole, KDChart::ThreeDBarAttributesRole, KDChart::ThreeDLineAttributesRole, and KDChart::ThreeDPieAttributesRole.

Referenced by data(), setData(), and setHeaderData().

    00397 {
    00398     bool oneOfOurs = false;
    00399     switch( role ) {
    00400       // fallthrough intended
    00401       case DataValueLabelAttributesRole:
    00402       case DatasetBrushRole:
    00403       case DatasetPenRole:
    00404       case ThreeDAttributesRole:
    00405       case LineAttributesRole:
    00406       case ThreeDLineAttributesRole:
    00407       case BarAttributesRole:
    00408       case ThreeDBarAttributesRole:
    00409       case PieAttributesRole:
    00410       case ThreeDPieAttributesRole:
    00411       case DataHiddenRole:
    00412             oneOfOurs = true;
    00413         default:
    00414         break;
    00415     }
    00416     return oneOfOurs;
    00417 }

QModelIndex KDChart::AbstractProxyModel::mapFromSource | ( | const QModelIndex & | sourceIndex | ) | const`[inherited]`

Definition at line 23 of file KDChartAbstractProxyModel.cpp.

Referenced by KDChart::AbstractProxyModel::index(), and KDChart::AbstractProxyModel::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`[inherited]`

Definition at line 36 of file KDChartAbstractProxyModel.cpp.

Referenced by columnCount(), data(), KDChart::AbstractProxyModel::index(), KDChart::AbstractProxyModel::parent(), rowCount(), and 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 }

QVariant KDChart::AttributesModel::modelData | ( | int | role | ) | const

Definition at line 492 of file KDChartAttributesModel.cpp.

Referenced by data(), and headerData().

    00493 {
    00494     return mModelDataMap.value( role, QVariant() );
    00495 }

const QMap< int, QVariant > AttributesModel::modelDataMap | ( |  | ) | const`[protected]`

needed for serialization

Definition at line 536 of file KDChartAttributesModel.cpp.

    00537 {
    00538     return mModelDataMap;
    00539 }

AttributesModel::PaletteType AttributesModel::paletteType | ( |  | ) | const

Definition at line 478 of file KDChartAttributesModel.cpp.

Referenced by headerData(), and initFrom().

    00479 {
    00480     return mPaletteType;
    00481 }

QModelIndex KDChart::AbstractProxyModel::parent | ( | const QModelIndex & | index | ) | const`[inherited]`

Definition at line 59 of file KDChartAbstractProxyModel.cpp.

References KDChart::AbstractProxyModel::mapFromSource(), and KDChart::AbstractProxyModel::mapToSource().

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

bool AttributesModel::resetData | ( | const QModelIndex & | index,
|  | int | role = Qt::DisplayRole
| ) |

Remove any explicit attributes settings that might have been specified before.

Definition at line 447 of file KDChartAttributesModel.cpp.

References setData().

    00448 {
    00449     return setData ( index, QVariant(), role );
    00450 }

bool AttributesModel::resetHeaderData | ( | int | section,
|  | Qt::Orientation | orientation,
|  | int | role = Qt::DisplayRole
| ) |

Remove any explicit attributes settings that might have been specified before.

Definition at line 468 of file KDChartAttributesModel.cpp.

References setHeaderData().

    00469 {
    00470     return setHeaderData ( section, orientation, QVariant(), role );
    00471 }

int AttributesModel::rowCount | ( | const QModelIndex & |  | ) | const

[reimplemented]

Definition at line 497 of file KDChartAttributesModel.cpp.

References KDChart::AbstractProxyModel::mapToSource().

Referenced by setHeaderData(), and setModelData().

    00498 {
    00499     Q_ASSERT(sourceModel());
    00500     return sourceModel()->rowCount( mapToSource(index) );
    00501 }

bool AttributesModel::setData | ( | const QModelIndex & | index,
|  | const QVariant & | value,
|  | int | role = Qt::DisplayRole
| ) |

[reimplemented]

Definition at line 433 of file KDChartAttributesModel.cpp.

References dataMap(), isKnownAttributesRole(), and KDChart::AbstractProxyModel::mapToSource().

Referenced by resetData(), and KDChart::BarDiagram::setBarAttributes().

    00434 {
    00435     if ( !isKnownAttributesRole( role ) ) {
    00436         return sourceModel()->setData( mapToSource(index), value, role );
    00437     } else {
    00438         QMap< int,  QMap< int, QVariant> > &colDataMap = mDataMap[ index.column() ];
    00439         QMap<int, QVariant> &dataMap = colDataMap[ index.row() ];
    00440         //qDebug() <<  "AttributesModel::setData" <<"role" << role << "value" << value;
    00441         dataMap.insert( role, value );
    00442         emit attributesChanged( index, index );
    00443         return true;
    00444     }
    00445 }

void AttributesModel::setDataMap | ( | const QMap< int, QMap< int, QMap< int, QVariant > > > | map | ) | `[protected]`

needed for serialization

Definition at line 542 of file KDChartAttributesModel.cpp.

    00543 {
    00544     mDataMap = map;
    00545 }

bool AttributesModel::setHeaderData | ( | int | section,
|  | Qt::Orientation | orientation,
|  | const QVariant & | value,
|  | int | role = Qt::DisplayRole
| ) |

[reimplemented]

Definition at line 452 of file KDChartAttributesModel.cpp.

References dataMap(), KDChart::AbstractProxyModel::index(), isKnownAttributesRole(), and rowCount().

Referenced by resetHeaderData().

    00454 {
    00455     if ( !isKnownAttributesRole( role ) ) {
    00456         return sourceModel()->setHeaderData( section, orientation, value, role );
    00457     } else {
    00458         QMap<int,  QMap<int, QVariant> > &sectionDataMap
    00459             = orientation == Qt::Horizontal ? mHorizontalHeaderDataMap : mVerticalHeaderDataMap;
    00460         QMap<int, QVariant> &dataMap = sectionDataMap[ section ];
    00461         dataMap.insert( role, value );
    00462         emit attributesChanged( index( 0, section, QModelIndex() ),
    00463                                 index( rowCount( QModelIndex() ), section, QModelIndex() ) );
    00464         return true;
    00465     }
    00466 }

void AttributesModel::setHorizontalHeaderDataMap | ( | const QMap< int, QMap< int, QVariant > > | map | ) | `[protected]`

needed for serialization

Definition at line 547 of file KDChartAttributesModel.cpp.

    00548 {
    00549     mHorizontalHeaderDataMap = map;
    00550 }

bool KDChart::AttributesModel::setModelData | ( | const QVariant | value,
|  | int | role
| ) |

Definition at line 483 of file KDChartAttributesModel.cpp.

References columnCount(), KDChart::AbstractProxyModel::index(), and rowCount().

    00484 {
    00485     mModelDataMap.insert( role, value );
    00486     emit attributesChanged( index( 0, 0, QModelIndex() ),
    00487                             index( rowCount( QModelIndex() ),
    00488                                     columnCount( QModelIndex() ), QModelIndex() ) );
    00489     return true;
    00490 }

void AttributesModel::setModelDataMap | ( | const QMap< int, QVariant > | map | ) | `[protected]`

needed for serialization

Definition at line 557 of file KDChartAttributesModel.cpp.

    00558 {
    00559     mModelDataMap = map;
    00560 }

void AttributesModel::setPaletteType | ( | PaletteType | type | ) |

Sets the palettetype used by this attributesmodel.

Definition at line 473 of file KDChartAttributesModel.cpp.

Referenced by initFrom().

    00474 {
    00475     mPaletteType = type;
    00476 }

void AttributesModel::setSourceModel | ( | QAbstractItemModel * | sourceModel | ) |

[reimplemented]

Definition at line 509 of file KDChartAttributesModel.cpp.

Referenced by AttributesModel().

    00510 {
    00511     if( this->sourceModel() != 0 )
    00512         disconnect( this->sourceModel(), SIGNAL( dataChanged( const QModelIndex&, const QModelIndex&)),
    00513                                   this, SIGNAL( dataChanged( const QModelIndex&, const QModelIndex&)));
    00514     QAbstractProxyModel::setSourceModel( sourceModel );
    00515     if( this->sourceModel() != NULL )
    00516         connect( this->sourceModel(), SIGNAL( dataChanged( const QModelIndex&, const QModelIndex&)),
    00517                                 this, SIGNAL( dataChanged( const QModelIndex&, const QModelIndex&)));
    00518 }

void AttributesModel::setVerticalHeaderDataMap | ( | const QMap< int, QMap< int, QVariant > > | map | ) | `[protected]`

needed for serialization

Definition at line 552 of file KDChartAttributesModel.cpp.

    00553 {
    00554     mVerticalHeaderDataMap = map;
    00555 }

const QMap< int, QMap< int, QVariant > > AttributesModel::verticalHeaderDataMap | ( |  | ) | const`[protected]`

needed for serialization

Definition at line 531 of file KDChartAttributesModel.cpp.

    00532 {
    00533     return mVerticalHeaderDataMap;
    00534 }

## Member Data Documentation

Q_SIGNALS KDChart::AttributesModel::__pad0__

| Definition at line 125 of file KDChartAttributesModel.h.

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

- KDChartAttributesModel.h
- KDChartAttributesModel.cpp