KDChartAttributesModel.cpp

Go to the documentation of this file.
00001 /* -*- Mode: C++ -*-
00002    KDChart - a multi-platform charting engine
00003    */
00004 
00005 /****************************************************************************
00006  ** Copyright (C) 2001-2007 Klaralvdalens Datakonsult AB.  All rights reserved.
00007  **
00008  ** This file is part of the KD Chart library.
00009  **
00010  ** This file may be distributed and/or modified under the terms of the
00011  ** GNU General Public License version 2 as published by the Free Software
00012  ** Foundation and appearing in the file LICENSE.GPL included in the
00013  ** packaging of this file.
00014  **
00015  ** Licensees holding valid commercial KD Chart licenses may use this file in
00016  ** accordance with the KD Chart Commercial License Agreement provided with
00017  ** the Software.
00018  **
00019  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00020  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00021  **
00022  ** See http://www.kdab.net/kdchart for
00023  **   information about KD Chart Commercial License Agreements.
00024  **
00025  ** Contact info@kdab.net if any conditions of this
00026  ** licensing are not clear to you.
00027  **
00028  **********************************************************************/
00029 #include <QDebug>
00030 #include <QPen>
00031 #include <QPointer>
00032 
00033 #include "KDChartAttributesModel.h"
00034 #include "KDChartPalette.h"
00035 #include "KDChartGlobal.h"
00036 
00037 #include <KDChartTextAttributes>
00038 #include <KDChartFrameAttributes>
00039 #include <KDChartBackgroundAttributes>
00040 #include <KDChartDataValueAttributes>
00041 #include <KDChartMarkerAttributes>
00042 #include <KDChartBarAttributes>
00043 #include <KDChartLineAttributes>
00044 #include <KDChartPieAttributes>
00045 #include <KDChartAbstractThreeDAttributes>
00046 #include <KDChartThreeDBarAttributes>
00047 #include <KDChartThreeDLineAttributes>
00048 #include <KDChartThreeDPieAttributes>
00049 #include <KDChartGridAttributes>
00050 #include <KDChartValueTrackerAttributes>
00051 
00052 #include <KDABLibFakes>
00053 
00054 
00055 using namespace KDChart;
00056 
00057 AttributesModel::AttributesModel( QAbstractItemModel* model, QObject * parent/* = 0 */ )
00058   : AbstractProxyModel( parent ),
00059     mPaletteType( PaletteTypeDefault )
00060 {
00061     setSourceModel(model);
00062     setDefaultForRole( KDChart::DataValueLabelAttributesRole,
00063                        DataValueAttributes::defaultAttributesAsVariant() );
00064 }
00065 
00066 AttributesModel::~AttributesModel()
00067 {
00068 }
00069 
00070 void AttributesModel::initFrom( const AttributesModel* other )
00071 {
00072     if( other == this || ! other ) return;
00073 
00074     mDataMap = other->mDataMap;
00075     mHorizontalHeaderDataMap = other->mHorizontalHeaderDataMap;
00076     mVerticalHeaderDataMap = other->mVerticalHeaderDataMap;
00077     mModelDataMap = other->mModelDataMap;
00078     mDefaultsMap =  other->mDefaultsMap;
00079 
00080     setPaletteType( other->paletteType() );
00081 }
00082 
00083 bool AttributesModel::compare( const AttributesModel* other )const
00084 {
00085     if( other == this ) return true;
00086     if( ! other ){
00087         //qDebug() << "AttributesModel::compare() cannot compare to Null pointer";
00088         return false;
00089     }
00090 
00091     {
00092         if (mDataMap.count() != other->mDataMap.count()){
00093             //qDebug() << "AttributesModel::compare() dataMap have different sizes";
00094             return false;
00095         }
00096         QMap<int, QMap<int, QMap<int, QVariant> > >::const_iterator itA = mDataMap.constBegin();
00097         QMap<int, QMap<int, QMap<int, QVariant> > >::const_iterator itB = other->mDataMap.constBegin();
00098         while (itA != mDataMap.constEnd()) {
00099             if ((*itA).count() != (*itB).count()){
00100                 //qDebug() << "AttributesModel::compare() dataMap/map have different sizes";
00101                 return false;
00102             }
00103             QMap<int, QMap<int, QVariant> >::const_iterator it2A = (*itA).constBegin();
00104             QMap<int, QMap<int, QVariant> >::const_iterator it2B = (*itB).constBegin();
00105             while (it2A != itA->constEnd()) {
00106                 if ((*it2A).count() != (*it2B).count()){
00107                     //qDebug() << "AttributesModel::compare() dataMap/map/map have different sizes:"
00108                     //        << (*it2A).count() << (*it2B).count();
00109                     return false;
00110                 }
00111                 QMap<int, QVariant>::const_iterator it3A = (*it2A).constBegin();
00112                 QMap<int, QVariant>::const_iterator it3B = (*it2B).constBegin();
00113                 while (it3A != it2A->constEnd()) {
00114                     if ( it3A.key() != it3B.key() ){
00115                         //qDebug( "AttributesModel::compare()\n"
00116                         //        "   dataMap[%i, %i] values have different types.  A: %x  B: %x",
00117                         //        itA.key(), it2A.key(), it3A.key(), it3B.key());
00118                         return false;
00119                     }
00120                     if ( ! compareAttributes( it3A.key(), it3A.value(), it3B.value() ) ){
00121                         //qDebug( "AttributesModel::compare()\n"
00122                         //        "   dataMap[%i, %i] values are different. Role: %x", itA.key(), it2A.key(), it3A.key());
00123                         return false;
00124                     }
00125                     ++it3A;
00126                     ++it3B;
00127                 }
00128                 ++it2A;
00129                 ++it2B;
00130             }
00131             ++itA;
00132             ++itB;
00133         }
00134     }
00135     {
00136         if (mHorizontalHeaderDataMap.count() != other->mHorizontalHeaderDataMap.count()){
00137             //qDebug() << "AttributesModel::compare() horizontalHeaderDataMap have different sizes";
00138             return false;
00139         }
00140         QMap<int, QMap<int, QVariant> >::const_iterator itA = mHorizontalHeaderDataMap.constBegin();
00141         QMap<int, QMap<int, QVariant> >::const_iterator itB = other->mHorizontalHeaderDataMap.constBegin();
00142         while (itA != mHorizontalHeaderDataMap.constEnd()) {
00143             if ((*itA).count() != (*itB).count()){
00144                 //qDebug() << "AttributesModel::compare() horizontalHeaderDataMap/map have different sizes";
00145                 return false;
00146             }
00147             QMap<int, QVariant>::const_iterator it2A = (*itA).constBegin();
00148             QMap<int, QVariant>::const_iterator it2B = (*itB).constBegin();
00149             while (it2A != itA->constEnd()) {
00150                 if ( it2A.key() != it2B.key() ){
00151                     //qDebug( "AttributesModel::compare()\n"
00152                     //        "   horizontalHeaderDataMap[ %i ] values have different types.  A: %x  B: %x",
00153                     //        itA.key(), it2A.key(), it2B.key());
00154                     return false;
00155                 }
00156                 if ( ! compareAttributes( it2A.key(), it2A.value(), it2B.value() ) ){
00157                     //qDebug( "AttributesModel::compare()\n"
00158                     //        "   horizontalHeaderDataMap[ %i ] values are different. Role: %x", itA.key(), it2A.key() );
00159                     return false;
00160                 }
00161                 ++it2A;
00162                 ++it2B;
00163             }
00164             ++itA;
00165             ++itB;
00166         }
00167     }
00168     {
00169         if (mVerticalHeaderDataMap.count() != other->mVerticalHeaderDataMap.count()){
00170             //qDebug() << "AttributesModel::compare() verticalHeaderDataMap have different sizes";
00171             return false;
00172         }
00173         QMap<int, QMap<int, QVariant> >::const_iterator itA = mVerticalHeaderDataMap.constBegin();
00174         QMap<int, QMap<int, QVariant> >::const_iterator itB = other->mVerticalHeaderDataMap.constBegin();
00175         while (itA != mVerticalHeaderDataMap.constEnd()) {
00176             if ((*itA).count() != (*itB).count()){
00177                 //qDebug() << "AttributesModel::compare() verticalHeaderDataMap/map have different sizes";
00178                 return false;
00179             }
00180             QMap<int, QVariant>::const_iterator it2A = (*itA).constBegin();
00181             QMap<int, QVariant>::const_iterator it2B = (*itB).constBegin();
00182             while (it2A != itA->constEnd()) {
00183                 if ( it2A.key() != it2B.key() ){
00184                     //qDebug( "AttributesModel::compare()\n"
00185                     //        "   verticalHeaderDataMap[ %i ] values have different types.  A: %x  B: %x",
00186                     //        itA.key(), it2A.key(), it2B.key());
00187                     return false;
00188                 }
00189                 if ( ! compareAttributes( it2A.key(), it2A.value(), it2B.value() ) ){
00190                     //qDebug( "AttributesModel::compare()\n"
00191                     //        "   verticalHeaderDataMap[ %i ] values are different. Role: %x", itA.key(), it2A.key() );
00192                     return false;
00193                 }
00194                 ++it2A;
00195                 ++it2B;
00196             }
00197             ++itA;
00198             ++itB;
00199         }
00200     }
00201     {
00202         if (mModelDataMap.count() != other->mModelDataMap.count()){
00203             //qDebug() << "AttributesModel::compare() modelDataMap have different sizes:" << mModelDataMap.count() << other->mModelDataMap.count();
00204             return false;
00205         }
00206         QMap<int, QVariant>::const_iterator itA = mModelDataMap.constBegin();
00207         QMap<int, QVariant>::const_iterator itB = other->mModelDataMap.constBegin();
00208         while (itA != mModelDataMap.constEnd()) {
00209             if ( itA.key() != itB.key() ){
00210                 //qDebug( "AttributesModel::compare()\n"
00211                 //        "   modelDataMap values have different types.  A: %x  B: %x",
00212                 //        itA.key(), itB.key());
00213                 return false;
00214             }
00215             if ( ! compareAttributes( itA.key(), itA.value(), itB.value() ) ){
00216                 //qDebug( "AttributesModel::compare()\n"
00217                 //        "   modelDataMap values are different. Role: %x", itA.key() );
00218                 return false;
00219             }
00220             ++itA;
00221             ++itB;
00222         }
00223     }
00224     if (paletteType() != other->paletteType()){
00225         //qDebug() << "AttributesModel::compare() palette types are different";
00226         return false;
00227     }
00228     return true;
00229 }
00230 
00231 bool AttributesModel::compareAttributes(
00232         int role, const QVariant& a, const QVariant& b )const
00233 {
00234     if( isKnownAttributesRole( role ) ){
00235         switch( role ) {
00236             case DataValueLabelAttributesRole:
00237                 return (qVariantValue<DataValueAttributes>( a ) ==
00238                         qVariantValue<DataValueAttributes>( b ));
00239             case DatasetBrushRole:
00240                 return (qVariantValue<QBrush>( a ) ==
00241                         qVariantValue<QBrush>( b ));
00242             case DatasetPenRole:
00243                 return (qVariantValue<QPen>( a ) ==
00244                         qVariantValue<QPen>( b ));
00245             case ThreeDAttributesRole:
00246                 // As of yet there is no ThreeDAttributes class,
00247                 // and the AbstractThreeDAttributes class is pure virtual,
00248                 // so we ignore this role for now.
00249                 // (khz, 04.04.2007)
00250                 /*
00251                 return (qVariantValue<ThreeDAttributes>( a ) ==
00252                         qVariantValue<ThreeDAttributes>( b ));
00253                 */
00254                 break;
00255             case LineAttributesRole:
00256                 return (qVariantValue<LineAttributes>( a ) ==
00257                         qVariantValue<LineAttributes>( b ));
00258             case ThreeDLineAttributesRole:
00259                 return (qVariantValue<ThreeDLineAttributes>( a ) ==
00260                         qVariantValue<ThreeDLineAttributes>( b ));
00261             case BarAttributesRole:
00262                 return (qVariantValue<BarAttributes>( a ) ==
00263                         qVariantValue<BarAttributes>( b ));
00264             case ThreeDBarAttributesRole:
00265                 return (qVariantValue<ThreeDBarAttributes>( a ) ==
00266                         qVariantValue<ThreeDBarAttributes>( b ));
00267             case PieAttributesRole:
00268                 return (qVariantValue<PieAttributes>( a ) ==
00269                         qVariantValue<PieAttributes>( b ));
00270             case ThreeDPieAttributesRole:
00271                 return (qVariantValue<ThreeDPieAttributes>( a ) ==
00272                         qVariantValue<ThreeDPieAttributes>( b ));
00273             case ValueTrackerAttributesRole:
00274                 return (qVariantValue<ValueTrackerAttributes>( a ) ==
00275                         qVariantValue<ValueTrackerAttributes>( b ));
00276             case DataHiddenRole:
00277                 return (qVariantValue<bool>( a ) ==
00278                         qVariantValue<bool>( b ));
00279             default:
00280                 Q_ASSERT( false ); // all of our own roles need to be handled
00281                 break;
00282         }
00283     }else{
00284         return (a == b);
00285     }
00286     return true;
00287 }
00288 
00289 
00290 QVariant AttributesModel::headerData ( int section,
00291                                        Qt::Orientation orientation,
00292                                        int role/* = Qt::DisplayRole */ ) const
00293 {
00294   QVariant sourceData = sourceModel()->headerData( section, orientation, role );
00295   if ( sourceData.isValid() ) return sourceData;
00296   // the source model didn't have data set, let's use our stored values
00297   const QMap<int, QMap<int, QVariant> >& map = orientation == Qt::Horizontal ? mHorizontalHeaderDataMap : mVerticalHeaderDataMap;
00298   if ( map.contains( section ) ) {
00299       const QMap<int, QVariant> &dataMap = map[ section ];
00300       if ( dataMap.contains( role ) ) {
00301           return dataMap[ role ];
00302       }
00303   }
00304 
00305   // Default values if nothing else matches
00306   switch ( role ) {
00307   case Qt::DisplayRole:
00308       return QLatin1String( orientation == Qt::Vertical ?  "Series " : "Item " ) + QString::number( section ) ;
00309 
00310   case KDChart::DatasetBrushRole: {
00311       if ( paletteType() == PaletteTypeSubdued )
00312           return Palette::subduedPalette().getBrush( section );
00313       else if ( paletteType() == PaletteTypeRainbow )
00314           return Palette::rainbowPalette().getBrush( section );
00315       else if ( paletteType() == PaletteTypeDefault )
00316           return Palette::defaultPalette().getBrush( section );
00317       else
00318           qWarning("Unknown type of fallback palette!");
00319   }
00320   case KDChart::DatasetPenRole: {
00321       // default to the color set for the brush (or it's defaults)
00322       // but only if no per model override was set
00323       if ( !modelData( role ).isValid() ) {
00324           QBrush brush = qVariantValue<QBrush>( headerData( section, orientation, DatasetBrushRole ) );
00325           return QPen( brush.color() );
00326       }
00327   }
00328   default:
00329       break;
00330   }
00331 
00332   return QVariant();
00333 }
00334 
00335 
00336 // Note: Our users NEED this method - even if
00337 //       we do not need it at drawing time!
00338 //       (khz, 2006-07-28)
00339 QVariant AttributesModel::data( int role ) const
00340 {
00341   if ( isKnownAttributesRole( role ) ) {
00342       // check if there is something set at global level
00343       QVariant v = modelData( role );
00344 
00345       // else return the default setting, if any
00346       if ( !v.isValid() )
00347           v = defaultsForRole( role );
00348       return v;
00349   }
00350   return QVariant();
00351 }
00352 
00353 
00354 // Note: Our users NEED this method - even if
00355 //       we do not need it at drawing time!
00356 //       (khz, 2006-07-28)
00357 QVariant AttributesModel::data( int column, int role ) const
00358 {
00359   if ( isKnownAttributesRole( role ) ) {
00360       // check if there is something set for the column (dataset)
00361       QVariant v;
00362       v = headerData( column, Qt::Vertical, role );
00363 
00364       // check if there is something set at global level
00365       if ( !v.isValid() )
00366           v = data( role ); // includes automatic fallback to default
00367       return v;
00368   }
00369   return QVariant();
00370 }
00371 
00372 
00373 QVariant AttributesModel::data( const QModelIndex& index, int role ) const
00374 {
00375     //qDebug() << "AttributesModel::data(" << index << role << ")";
00376     if( index.isValid() ) {
00377         Q_ASSERT( index.model() == this );
00378     }
00379 
00380     if( sourceModel() == 0 )
00381         return QVariant();
00382 
00383     if( index.isValid() )
00384     {
00385         const QVariant sourceData = sourceModel()->data( mapToSource(index), role );
00386         if( sourceData.isValid() )
00387             return sourceData;
00388     }
00389 
00390     // check if we are storing a value for this role at this cell index
00391     if( mDataMap.contains( index.column() ) )
00392     {
00393         const QMap< int,  QMap< int, QVariant > >& colDataMap = mDataMap[ index.column() ];
00394         if( colDataMap.contains( index.row() ) ) 
00395         {
00396             const QMap< int, QVariant >& dataMap = colDataMap[ index.row() ];
00397             if( dataMap.contains( role ) )
00398             {
00399               const QVariant v = dataMap[ role ];
00400               if( v.isValid() )
00401                   return v;
00402             }
00403         }
00404     }
00405     // check if there is something set for the column (dataset), or at global level
00406     if( index.isValid() )
00407         return data( index.column(), role ); // includes automatic fallback to default
00408 
00409     return QVariant();
00410 }
00411 
00412 
00413 bool AttributesModel::isKnownAttributesRole( int role ) const
00414 {
00415     bool oneOfOurs = false;
00416     switch( role ) {
00417         // fallthrough intended
00418     case DataValueLabelAttributesRole:
00419     case DatasetBrushRole:
00420     case DatasetPenRole:
00421     case ThreeDAttributesRole:
00422     case LineAttributesRole:
00423     case ThreeDLineAttributesRole:
00424     case BarAttributesRole:
00425     case ThreeDBarAttributesRole:
00426     case PieAttributesRole:
00427     case ThreeDPieAttributesRole:
00428     case ValueTrackerAttributesRole:
00429     case DataHiddenRole:
00430         oneOfOurs = true;
00431     default:
00432         break;
00433     }
00434     return oneOfOurs;
00435 }
00436 
00437 QVariant AttributesModel::defaultsForRole( int role ) const
00438 {
00439     // returns default-constructed QVariant if not found
00440     return mDefaultsMap.value( role );
00441 }
00442 
00443 bool AttributesModel::setData ( const QModelIndex & index, const QVariant & value, int role )
00444 {
00445     if ( !isKnownAttributesRole( role ) ) {
00446         return sourceModel()->setData( mapToSource(index), value, role );
00447     } else {
00448         QMap< int,  QMap< int, QVariant> > &colDataMap = mDataMap[ index.column() ];
00449         QMap<int, QVariant> &dataMap = colDataMap[ index.row() ];
00450         //qDebug() <<  "AttributesModel::setData" <<"role" << role << "value" << value;
00451         dataMap.insert( role, value );
00452         emit attributesChanged( index, index );
00453         return true;
00454     }
00455 }
00456 
00457 bool AttributesModel::resetData ( const QModelIndex & index, int role )
00458 {
00459     return setData ( index, QVariant(), role );
00460 }
00461 
00462 bool AttributesModel::setHeaderData ( int section, Qt::Orientation orientation,
00463                                       const QVariant & value, int role )
00464 {
00465     if( sourceModel() != 0 && headerData( section, orientation, role ) == value )
00466         return true;
00467     if ( !isKnownAttributesRole( role ) ) {
00468         return sourceModel()->setHeaderData( section, orientation, value, role );
00469     } else {
00470         QMap<int,  QMap<int, QVariant> > &sectionDataMap
00471             = orientation == Qt::Horizontal ? mHorizontalHeaderDataMap : mVerticalHeaderDataMap;
00472         QMap<int, QVariant> &dataMap = sectionDataMap[ section ];
00473         dataMap.insert( role, value );
00474         if( sourceModel() ){
00475             emit attributesChanged( index( 0, section, QModelIndex() ),
00476                                     index( rowCount( QModelIndex() ), section, QModelIndex() ) );
00477             emit headerDataChanged( orientation, section, section );
00478         }
00479         return true;
00480     }
00481 }
00482 
00483 bool AttributesModel::resetHeaderData ( int section, Qt::Orientation orientation, int role )
00484 {
00485     return setHeaderData ( section, orientation, QVariant(), role );
00486 }
00487 
00488 void AttributesModel::setPaletteType( AttributesModel::PaletteType type )
00489 {
00490     mPaletteType = type;
00491 }
00492 
00493 AttributesModel::PaletteType AttributesModel::paletteType() const
00494 {
00495     return mPaletteType;
00496 }
00497 
00498 bool KDChart::AttributesModel::setModelData( const QVariant value, int role )
00499 {
00500     mModelDataMap.insert( role, value );
00501     if( sourceModel() ){
00502         emit attributesChanged( index( 0, 0, QModelIndex() ),
00503                                 index( rowCount( QModelIndex() ),
00504                                        columnCount( QModelIndex() ), QModelIndex() ) );
00505     }
00506     return true;
00507 }
00508 
00509 QVariant KDChart::AttributesModel::modelData( int role ) const
00510 {
00511     return mModelDataMap.value( role, QVariant() );
00512 }
00513 
00514 int AttributesModel::rowCount( const QModelIndex& index ) const
00515 {
00516     if ( sourceModel() ) {
00517         return sourceModel()->rowCount( mapToSource(index) );
00518     } else {
00519         return 0;
00520     }
00521 }
00522 
00523 int AttributesModel::columnCount( const QModelIndex& index ) const
00524 {
00525     if ( sourceModel() ) {
00526         return sourceModel()->columnCount( mapToSource(index) );
00527     } else {
00528         return 0;
00529     }
00530 }
00531 
00532 void AttributesModel::setSourceModel( QAbstractItemModel* sourceModel )
00533 {
00534     if( this->sourceModel() != 0 )
00535     {
00536         disconnect( this->sourceModel(), SIGNAL( dataChanged( const QModelIndex&, const QModelIndex&)),
00537                                   this, SIGNAL( dataChanged( const QModelIndex&, const QModelIndex&)));
00538         disconnect( this->sourceModel(), SIGNAL( rowsInserted( const QModelIndex&, int, int ) ),
00539                                   this, SIGNAL( rowsInserted( const QModelIndex&, int, int ) ) );
00540         disconnect( this->sourceModel(), SIGNAL( rowsRemoved( const QModelIndex&, int, int ) ),
00541                                   this, SIGNAL( rowsRemoved( const QModelIndex&, int, int ) ) );
00542         disconnect( this->sourceModel(), SIGNAL( columnsInserted( const QModelIndex&, int, int ) ),
00543                                   this, SIGNAL( columnsInserted( const QModelIndex&, int, int ) ) );
00544         disconnect( this->sourceModel(), SIGNAL( columnsRemoved( const QModelIndex&, int, int ) ),
00545                                   this, SIGNAL( columnsRemoved( const QModelIndex&, int, int ) ) );
00546     }
00547     QAbstractProxyModel::setSourceModel( sourceModel );
00548     if( this->sourceModel() != NULL )
00549     {
00550         connect( this->sourceModel(), SIGNAL( dataChanged( const QModelIndex&, const QModelIndex&)),
00551                                 this, SIGNAL( dataChanged( const QModelIndex&, const QModelIndex&)));
00552         connect( this->sourceModel(), SIGNAL( rowsInserted( const QModelIndex&, int, int ) ),
00553                                 this, SIGNAL( rowsInserted( const QModelIndex&, int, int ) ) );
00554         connect( this->sourceModel(), SIGNAL( rowsRemoved( const QModelIndex&, int, int ) ),
00555                                 this, SIGNAL( rowsRemoved( const QModelIndex&, int, int ) ) );
00556         connect( this->sourceModel(), SIGNAL( columnsInserted( const QModelIndex&, int, int ) ),
00557                                 this, SIGNAL( columnsInserted( const QModelIndex&, int, int ) ) );
00558         connect( this->sourceModel(), SIGNAL( columnsRemoved( const QModelIndex&, int, int ) ),
00559                                 this, SIGNAL( columnsRemoved( const QModelIndex&, int, int ) ) );
00560     }
00561 }
00562 
00564 const QMap<int, QMap<int, QMap<int, QVariant> > > AttributesModel::dataMap()const
00565 {
00566     return mDataMap;
00567 }
00569 const QMap<int, QMap<int, QVariant> > AttributesModel::horizontalHeaderDataMap()const
00570 {
00571     return mHorizontalHeaderDataMap;
00572 }
00574 const QMap<int, QMap<int, QVariant> > AttributesModel::verticalHeaderDataMap()const
00575 {
00576     return mVerticalHeaderDataMap;
00577 }
00579 const QMap<int, QVariant> AttributesModel::modelDataMap()const
00580 {
00581     return mModelDataMap;
00582 }
00583 
00585 void AttributesModel::setDataMap( const QMap<int, QMap<int, QMap<int, QVariant> > > map )
00586 {
00587     mDataMap = map;
00588 }
00590 void AttributesModel::setHorizontalHeaderDataMap( const QMap<int, QMap<int, QVariant> > map )
00591 {
00592     mHorizontalHeaderDataMap = map;
00593 }
00595 void AttributesModel::setVerticalHeaderDataMap( const QMap<int, QMap<int, QVariant> > map )
00596 {
00597     mVerticalHeaderDataMap = map;
00598 }
00600 void AttributesModel::setModelDataMap( const QMap<int, QVariant> map )
00601 {
00602     mModelDataMap = map;
00603 }
00604 
00605 void AttributesModel::setDefaultForRole( int role, const QVariant& value )
00606 {
00607     if ( value.isValid() ) {
00608         mDefaultsMap.insert( role, value );
00609     } else {
00610         // erase the possibily existing value to not let the map grow:
00611         QMap<int, QVariant>::iterator it = mDefaultsMap.find( role );
00612         if ( it != mDefaultsMap.end() ) {
00613             mDefaultsMap.erase( it );
00614         }
00615     }
00616 
00617     Q_ASSERT( defaultsForRole( role ) == value );
00618 }

Generated on Mon Sep 17 16:16:49 2007 for KD Chart 2 by  doxygen 1.5.1