00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "KDChartAttributesModel.h"
00024 #include "KDChartPalette.h"
00025 #include "KDChartGlobal.h"
00026
00027 #include <QDebug>
00028 #include <QPen>
00029 #include <QPointer>
00030
00031 #include <KDChartTextAttributes>
00032 #include <KDChartFrameAttributes>
00033 #include <KDChartBackgroundAttributes>
00034 #include <KDChartDataValueAttributes>
00035 #include <KDChartMarkerAttributes>
00036 #include <KDChartBarAttributes>
00037 #include <KDChartStockBarAttributes>
00038 #include <KDChartLineAttributes>
00039 #include <KDChartPieAttributes>
00040 #include <KDChartAbstractThreeDAttributes>
00041 #include <KDChartThreeDBarAttributes>
00042 #include <KDChartThreeDLineAttributes>
00043 #include <KDChartThreeDPieAttributes>
00044 #include <KDChartGridAttributes>
00045 #include <KDChartValueTrackerAttributes>
00046
00047 #include <KDABLibFakes>
00048
00049
00050 using namespace KDChart;
00051
00052 AttributesModel::AttributesModel( QAbstractItemModel* model, QObject * parent )
00053 : AbstractProxyModel( parent ),
00054 mPaletteType( PaletteTypeDefault )
00055 {
00056 setSourceModel(model);
00057 setDefaultForRole( KDChart::DataValueLabelAttributesRole,
00058 DataValueAttributes::defaultAttributesAsVariant() );
00059 }
00060
00061 AttributesModel::~AttributesModel()
00062 {
00063 }
00064
00065 void AttributesModel::initFrom( const AttributesModel* other )
00066 {
00067 if( other == this || ! other ) return;
00068
00069 mDataMap = other->mDataMap;
00070 mHorizontalHeaderDataMap = other->mHorizontalHeaderDataMap;
00071 mVerticalHeaderDataMap = other->mVerticalHeaderDataMap;
00072 mModelDataMap = other->mModelDataMap;
00073 mDefaultsMap = other->mDefaultsMap;
00074
00075 setPaletteType( other->paletteType() );
00076 }
00077
00078 bool AttributesModel::compare( const AttributesModel* other )const
00079 {
00080 if( other == this ) return true;
00081 if( ! other ){
00082
00083 return false;
00084 }
00085
00086 {
00087 if (mDataMap.count() != other->mDataMap.count()){
00088
00089 return false;
00090 }
00091 QMap<int, QMap<int, QMap<int, QVariant> > >::const_iterator itA = mDataMap.constBegin();
00092 QMap<int, QMap<int, QMap<int, QVariant> > >::const_iterator itB = other->mDataMap.constBegin();
00093 while (itA != mDataMap.constEnd()) {
00094 if ((*itA).count() != (*itB).count()){
00095
00096 return false;
00097 }
00098 QMap<int, QMap<int, QVariant> >::const_iterator it2A = (*itA).constBegin();
00099 QMap<int, QMap<int, QVariant> >::const_iterator it2B = (*itB).constBegin();
00100 while (it2A != itA->constEnd()) {
00101 if ((*it2A).count() != (*it2B).count()){
00102
00103
00104 return false;
00105 }
00106 QMap<int, QVariant>::const_iterator it3A = (*it2A).constBegin();
00107 QMap<int, QVariant>::const_iterator it3B = (*it2B).constBegin();
00108 while (it3A != it2A->constEnd()) {
00109 if ( it3A.key() != it3B.key() ){
00110
00111
00112
00113 return false;
00114 }
00115 if ( ! compareAttributes( it3A.key(), it3A.value(), it3B.value() ) ){
00116
00117
00118 return false;
00119 }
00120 ++it3A;
00121 ++it3B;
00122 }
00123 ++it2A;
00124 ++it2B;
00125 }
00126 ++itA;
00127 ++itB;
00128 }
00129 }
00130 {
00131 if (mHorizontalHeaderDataMap.count() != other->mHorizontalHeaderDataMap.count()){
00132
00133 return false;
00134 }
00135 QMap<int, QMap<int, QVariant> >::const_iterator itA = mHorizontalHeaderDataMap.constBegin();
00136 QMap<int, QMap<int, QVariant> >::const_iterator itB = other->mHorizontalHeaderDataMap.constBegin();
00137 while (itA != mHorizontalHeaderDataMap.constEnd()) {
00138 if ((*itA).count() != (*itB).count()){
00139
00140 return false;
00141 }
00142 QMap<int, QVariant>::const_iterator it2A = (*itA).constBegin();
00143 QMap<int, QVariant>::const_iterator it2B = (*itB).constBegin();
00144 while (it2A != itA->constEnd()) {
00145 if ( it2A.key() != it2B.key() ){
00146
00147
00148
00149 return false;
00150 }
00151 if ( ! compareAttributes( it2A.key(), it2A.value(), it2B.value() ) ){
00152
00153
00154 return false;
00155 }
00156 ++it2A;
00157 ++it2B;
00158 }
00159 ++itA;
00160 ++itB;
00161 }
00162 }
00163 {
00164 if (mVerticalHeaderDataMap.count() != other->mVerticalHeaderDataMap.count()){
00165
00166 return false;
00167 }
00168 QMap<int, QMap<int, QVariant> >::const_iterator itA = mVerticalHeaderDataMap.constBegin();
00169 QMap<int, QMap<int, QVariant> >::const_iterator itB = other->mVerticalHeaderDataMap.constBegin();
00170 while (itA != mVerticalHeaderDataMap.constEnd()) {
00171 if ((*itA).count() != (*itB).count()){
00172
00173 return false;
00174 }
00175 QMap<int, QVariant>::const_iterator it2A = (*itA).constBegin();
00176 QMap<int, QVariant>::const_iterator it2B = (*itB).constBegin();
00177 while (it2A != itA->constEnd()) {
00178 if ( it2A.key() != it2B.key() ){
00179
00180
00181
00182 return false;
00183 }
00184 if ( ! compareAttributes( it2A.key(), it2A.value(), it2B.value() ) ){
00185
00186
00187 return false;
00188 }
00189 ++it2A;
00190 ++it2B;
00191 }
00192 ++itA;
00193 ++itB;
00194 }
00195 }
00196 {
00197 if (mModelDataMap.count() != other->mModelDataMap.count()){
00198
00199 return false;
00200 }
00201 QMap<int, QVariant>::const_iterator itA = mModelDataMap.constBegin();
00202 QMap<int, QVariant>::const_iterator itB = other->mModelDataMap.constBegin();
00203 while (itA != mModelDataMap.constEnd()) {
00204 if ( itA.key() != itB.key() ){
00205
00206
00207
00208 return false;
00209 }
00210 if ( ! compareAttributes( itA.key(), itA.value(), itB.value() ) ){
00211
00212
00213 return false;
00214 }
00215 ++itA;
00216 ++itB;
00217 }
00218 }
00219 if (paletteType() != other->paletteType()){
00220
00221 return false;
00222 }
00223 return true;
00224 }
00225
00226 bool AttributesModel::compareAttributes(
00227 int role, const QVariant& a, const QVariant& b )const
00228 {
00229 if( isKnownAttributesRole( role ) ){
00230 switch( role ) {
00231 case DataValueLabelAttributesRole:
00232 return (qVariantValue<DataValueAttributes>( a ) ==
00233 qVariantValue<DataValueAttributes>( b ));
00234 case DatasetBrushRole:
00235 return (qVariantValue<QBrush>( a ) ==
00236 qVariantValue<QBrush>( b ));
00237 case DatasetPenRole:
00238 return (qVariantValue<QPen>( a ) ==
00239 qVariantValue<QPen>( b ));
00240 case ThreeDAttributesRole:
00241
00242
00243
00244
00245
00246
00247
00248
00249 break;
00250 case LineAttributesRole:
00251 return (qVariantValue<LineAttributes>( a ) ==
00252 qVariantValue<LineAttributes>( b ));
00253 case ThreeDLineAttributesRole:
00254 return (qVariantValue<ThreeDLineAttributes>( a ) ==
00255 qVariantValue<ThreeDLineAttributes>( b ));
00256 case BarAttributesRole:
00257 return (qVariantValue<BarAttributes>( a ) ==
00258 qVariantValue<BarAttributes>( b ));
00259 case StockBarAttributesRole:
00260 return (qVariantValue<StockBarAttributes>( a ) ==
00261 qVariantValue<StockBarAttributes>( b ));
00262 case ThreeDBarAttributesRole:
00263 return (qVariantValue<ThreeDBarAttributes>( a ) ==
00264 qVariantValue<ThreeDBarAttributes>( b ));
00265 case PieAttributesRole:
00266 return (qVariantValue<PieAttributes>( a ) ==
00267 qVariantValue<PieAttributes>( b ));
00268 case ThreeDPieAttributesRole:
00269 return (qVariantValue<ThreeDPieAttributes>( a ) ==
00270 qVariantValue<ThreeDPieAttributes>( b ));
00271 case ValueTrackerAttributesRole:
00272 return (qVariantValue<ValueTrackerAttributes>( a ) ==
00273 qVariantValue<ValueTrackerAttributes>( b ));
00274 case DataHiddenRole:
00275 return (qVariantValue<bool>( a ) ==
00276 qVariantValue<bool>( b ));
00277 default:
00278 Q_ASSERT( false );
00279 break;
00280 }
00281 }else{
00282 return (a == b);
00283 }
00284 return true;
00285 }
00286
00287
00288 QVariant AttributesModel::headerData ( int section,
00289 Qt::Orientation orientation,
00290 int role ) const
00291 {
00292 if( sourceModel() ) {
00293 const QVariant sourceData = sourceModel()->headerData( section, orientation, role );
00294 if ( sourceData.isValid() ) return sourceData;
00295 }
00296
00297 if( orientation == Qt::Horizontal && role == ColumnDataRole )
00298 {
00299
00300
00301 QVariantList result;
00302 const int rows = sourceModel()->rowCount();
00303 for( int row = 0; row < rows; ++row )
00304 result.push_back( sourceModel()->index( row, section ).data() );
00305
00306 return result;
00307 }
00308
00309
00310
00311 const QMap<int, QMap<int, QVariant> >& map = orientation == Qt::Horizontal ? mHorizontalHeaderDataMap : mVerticalHeaderDataMap;
00312 if ( map.contains( section ) ) {
00313 const QMap<int, QVariant> &dataMap = map[ section ];
00314 if ( dataMap.contains( role ) ) {
00315 return dataMap[ role ];
00316 }
00317 }
00318
00319 return defaultHeaderData( section, orientation, role );
00320 }
00321
00322
00323 QVariant AttributesModel::defaultHeaderData ( int section, Qt::Orientation orientation, int role ) const
00324 {
00325
00326 switch ( role ) {
00327 case Qt::DisplayRole:
00328
00329 return QLatin1String( orientation == Qt::Vertical ? "Series " : "Item " ) + QString::number( section ) ;
00330
00331 case KDChart::DatasetBrushRole: {
00332 if ( paletteType() == PaletteTypeSubdued )
00333 return Palette::subduedPalette().getBrush( section );
00334 else if ( paletteType() == PaletteTypeRainbow )
00335 return Palette::rainbowPalette().getBrush( section );
00336 else if ( paletteType() == PaletteTypeDefault )
00337 return Palette::defaultPalette().getBrush( section );
00338 else
00339 qWarning("Unknown type of fallback palette!");
00340 } break;
00341 case KDChart::DatasetPenRole: {
00342
00343
00344 if ( !modelData( role ).isValid() ) {
00345 QBrush brush = qVariantValue<QBrush>( headerData( section, orientation, DatasetBrushRole ) );
00346 return QPen( brush.color() );
00347 }
00348 } break;
00349 default:
00350 break;
00351 }
00352
00353 return QVariant();
00354 }
00355
00356
00357
00358
00359 QVariant AttributesModel::data( int role ) const
00360 {
00361 if ( isKnownAttributesRole( role ) ) {
00362
00363 QVariant v = modelData( role );
00364
00365
00366 if ( !v.isValid() )
00367 v = defaultsForRole( role );
00368 return v;
00369 }
00370 return QVariant();
00371 }
00372
00373
00374
00375
00376
00377 QVariant AttributesModel::data( int column, int role ) const
00378 {
00379 if ( isKnownAttributesRole( role ) ) {
00380
00381 QVariant v;
00382 v = headerData( column, Qt::Horizontal, role );
00383
00384
00385 if ( !v.isValid() )
00386 v = data( role );
00387 return v;
00388 }
00389 return QVariant();
00390 }
00391
00392
00393 QVariant AttributesModel::data( const QModelIndex& index, int role ) const
00394 {
00395
00396 if( index.isValid() ) {
00397 Q_ASSERT( index.model() == this );
00398 }
00399
00400 if( sourceModel() == 0 )
00401 return QVariant();
00402
00403 if( index.isValid() )
00404 {
00405 const QVariant sourceData = sourceModel()->data( mapToSource(index), role );
00406 if( sourceData.isValid() )
00407 return sourceData;
00408 }
00409
00410
00411 if( mDataMap.contains( index.column() ) )
00412 {
00413 const QMap< int, QMap< int, QVariant > >& colDataMap = mDataMap[ index.column() ];
00414 if( colDataMap.contains( index.row() ) )
00415 {
00416 const QMap< int, QVariant >& dataMap = colDataMap[ index.row() ];
00417 if( dataMap.contains( role ) )
00418 {
00419 const QVariant v = dataMap[ role ];
00420 if( v.isValid() )
00421 return v;
00422 }
00423 }
00424 }
00425
00426 if( index.isValid() )
00427 return data( index.column(), role );
00428
00429 return QVariant();
00430 }
00431
00432
00433 bool AttributesModel::isKnownAttributesRole( int role ) const
00434 {
00435 bool oneOfOurs = false;
00436 switch( role ) {
00437
00438 case DataValueLabelAttributesRole:
00439 case DatasetBrushRole:
00440 case DatasetPenRole:
00441 case ThreeDAttributesRole:
00442 case LineAttributesRole:
00443 case ThreeDLineAttributesRole:
00444 case BarAttributesRole:
00445 case StockBarAttributesRole:
00446 case ThreeDBarAttributesRole:
00447 case PieAttributesRole:
00448 case ThreeDPieAttributesRole:
00449 case ValueTrackerAttributesRole:
00450 case DataHiddenRole:
00451 oneOfOurs = true;
00452 default:
00453 break;
00454 }
00455 return oneOfOurs;
00456 }
00457
00458 QVariant AttributesModel::defaultsForRole( int role ) const
00459 {
00460
00461 return mDefaultsMap.value( role );
00462 }
00463
00464 bool AttributesModel::setData ( const QModelIndex & index, const QVariant & value, int role )
00465 {
00466 if ( !isKnownAttributesRole( role ) ) {
00467 return sourceModel()->setData( mapToSource(index), value, role );
00468 } else {
00469 QMap< int, QMap< int, QVariant> > &colDataMap = mDataMap[ index.column() ];
00470 QMap<int, QVariant> &dataMap = colDataMap[ index.row() ];
00471
00472 dataMap.insert( role, value );
00473 emit attributesChanged( index, index );
00474 return true;
00475 }
00476 }
00477
00478 bool AttributesModel::resetData ( const QModelIndex & index, int role )
00479 {
00480 return setData ( index, QVariant(), role );
00481 }
00482
00483 bool AttributesModel::setHeaderData ( int section, Qt::Orientation orientation,
00484 const QVariant & value, int role )
00485 {
00486 if( sourceModel() != 0 && headerData( section, orientation, role ) == value )
00487 return true;
00488 if ( !isKnownAttributesRole( role ) ) {
00489 return sourceModel()->setHeaderData( section, orientation, value, role );
00490 } else {
00491 QMap<int, QMap<int, QVariant> > §ionDataMap
00492 = orientation == Qt::Horizontal ? mHorizontalHeaderDataMap : mVerticalHeaderDataMap;
00493 QMap<int, QVariant> &dataMap = sectionDataMap[ section ];
00494 dataMap.insert( role, value );
00495 if( sourceModel() ){
00496 emit attributesChanged( index( 0, section, QModelIndex() ),
00497 index( rowCount( QModelIndex() ), section, QModelIndex() ) );
00498 emit headerDataChanged( orientation, section, section );
00499 }
00500 return true;
00501 }
00502 }
00503
00504 bool AttributesModel::resetHeaderData ( int section, Qt::Orientation orientation, int role )
00505 {
00506 return setHeaderData ( section, orientation, QVariant(), role );
00507 }
00508
00509 void AttributesModel::setPaletteType( AttributesModel::PaletteType type )
00510 {
00511 mPaletteType = type;
00512 }
00513
00514 AttributesModel::PaletteType AttributesModel::paletteType() const
00515 {
00516 return mPaletteType;
00517 }
00518
00519 bool KDChart::AttributesModel::setModelData( const QVariant value, int role )
00520 {
00521 mModelDataMap.insert( role, value );
00522 if( sourceModel() ){
00523 emit attributesChanged( index( 0, 0, QModelIndex() ),
00524 index( rowCount( QModelIndex() ),
00525 columnCount( QModelIndex() ), QModelIndex() ) );
00526 }
00527 return true;
00528 }
00529
00530 QVariant KDChart::AttributesModel::modelData( int role ) const
00531 {
00532 return mModelDataMap.value( role, QVariant() );
00533 }
00534
00535 int AttributesModel::rowCount( const QModelIndex& index ) const
00536 {
00537 if ( sourceModel() ) {
00538 return sourceModel()->rowCount( mapToSource(index) );
00539 } else {
00540 return 0;
00541 }
00542 }
00543
00544 int AttributesModel::columnCount( const QModelIndex& index ) const
00545 {
00546 if ( sourceModel() ) {
00547 return sourceModel()->columnCount( mapToSource(index) );
00548 } else {
00549 return 0;
00550 }
00551 }
00552
00553 void AttributesModel::setSourceModel( QAbstractItemModel* sourceModel )
00554 {
00555 if( this->sourceModel() != 0 )
00556 {
00557 disconnect( this->sourceModel(), SIGNAL( dataChanged( const QModelIndex&, const QModelIndex&)),
00558 this, SLOT( slotDataChanged( const QModelIndex&, const QModelIndex&)));
00559 disconnect( this->sourceModel(), SIGNAL( rowsInserted( const QModelIndex&, int, int ) ),
00560 this, SLOT( slotRowsInserted( const QModelIndex&, int, int ) ) );
00561 disconnect( this->sourceModel(), SIGNAL( rowsRemoved( const QModelIndex&, int, int ) ),
00562 this, SLOT( slotRowsRemoved( const QModelIndex&, int, int ) ) );
00563 disconnect( this->sourceModel(), SIGNAL( rowsAboutToBeInserted( const QModelIndex&, int, int ) ),
00564 this, SLOT( slotRowsAboutToBeInserted( const QModelIndex&, int, int ) ) );
00565 disconnect( this->sourceModel(), SIGNAL( rowsAboutToBeRemoved( const QModelIndex&, int, int ) ),
00566 this, SLOT( slotRowsAboutToBeRemoved( const QModelIndex&, int, int ) ) );
00567 disconnect( this->sourceModel(), SIGNAL( columnsInserted( const QModelIndex&, int, int ) ),
00568 this, SLOT( slotColumnsInserted( const QModelIndex&, int, int ) ) );
00569 disconnect( this->sourceModel(), SIGNAL( columnsRemoved( const QModelIndex&, int, int ) ),
00570 this, SLOT( slotColumnsRemoved( const QModelIndex&, int, int ) ) );
00571 disconnect( this->sourceModel(), SIGNAL( columnsAboutToBeInserted( const QModelIndex&, int, int ) ),
00572 this, SLOT( slotColumnsAboutToBeInserted( const QModelIndex&, int, int ) ) );
00573 disconnect( this->sourceModel(), SIGNAL( columnsAboutToBeRemoved( const QModelIndex&, int, int ) ),
00574 this, SLOT( slotColumnsAboutToBeRemoved( const QModelIndex&, int, int ) ) );
00575 disconnect( this->sourceModel(), SIGNAL( modelReset() ),
00576 this, SIGNAL( modelReset() ) );
00577 disconnect( this->sourceModel(), SIGNAL( layoutChanged() ),
00578 this, SIGNAL( layoutChanged() ) );
00579 }
00580 QAbstractProxyModel::setSourceModel( sourceModel );
00581 if( this->sourceModel() != NULL )
00582 {
00583 connect( this->sourceModel(), SIGNAL( dataChanged( const QModelIndex&, const QModelIndex&)),
00584 this, SLOT( slotDataChanged( const QModelIndex&, const QModelIndex&)));
00585 connect( this->sourceModel(), SIGNAL( rowsInserted( const QModelIndex&, int, int ) ),
00586 this, SLOT( slotRowsInserted( const QModelIndex&, int, int ) ) );
00587 connect( this->sourceModel(), SIGNAL( rowsRemoved( const QModelIndex&, int, int ) ),
00588 this, SLOT( slotRowsRemoved( const QModelIndex&, int, int ) ) );
00589 connect( this->sourceModel(), SIGNAL( rowsAboutToBeInserted( const QModelIndex&, int, int ) ),
00590 this, SLOT( slotRowsAboutToBeInserted( const QModelIndex&, int, int ) ) );
00591 connect( this->sourceModel(), SIGNAL( rowsAboutToBeRemoved( const QModelIndex&, int, int ) ),
00592 this, SLOT( slotRowsAboutToBeRemoved( const QModelIndex&, int, int ) ) );
00593 connect( this->sourceModel(), SIGNAL( columnsInserted( const QModelIndex&, int, int ) ),
00594 this, SLOT( slotColumnsInserted( const QModelIndex&, int, int ) ) );
00595 connect( this->sourceModel(), SIGNAL( columnsRemoved( const QModelIndex&, int, int ) ),
00596 this, SLOT( slotColumnsRemoved( const QModelIndex&, int, int ) ) );
00597 connect( this->sourceModel(), SIGNAL( columnsAboutToBeInserted( const QModelIndex&, int, int ) ),
00598 this, SLOT( slotColumnsAboutToBeInserted( const QModelIndex&, int, int ) ) );
00599 connect( this->sourceModel(), SIGNAL( columnsAboutToBeRemoved( const QModelIndex&, int, int ) ),
00600 this, SLOT( slotColumnsAboutToBeRemoved( const QModelIndex&, int, int ) ) );
00601 connect( this->sourceModel(), SIGNAL( modelReset() ),
00602 this, SIGNAL( modelReset() ) );
00603 connect( this->sourceModel(), SIGNAL( layoutChanged() ),
00604 this, SIGNAL( layoutChanged() ) );
00605 }
00606 }
00607
00608 void AttributesModel::slotRowsAboutToBeInserted( const QModelIndex& parent, int start, int end )
00609 {
00610 beginInsertRows( mapFromSource( parent ), start, end );
00611 }
00612
00613 void AttributesModel::slotColumnsAboutToBeInserted( const QModelIndex& parent, int start, int end )
00614 {
00615 beginInsertColumns( mapFromSource( parent ), start, end );
00616 }
00617
00618 void AttributesModel::slotRowsInserted( const QModelIndex& parent, int start, int end )
00619 {
00620 Q_UNUSED( parent );
00621 Q_UNUSED( start );
00622 Q_UNUSED( end );
00623 endInsertRows();
00624 }
00625
00626 void AttributesModel::slotColumnsInserted( const QModelIndex& parent, int start, int end )
00627 {
00628 Q_UNUSED( parent );
00629 Q_UNUSED( start );
00630 Q_UNUSED( end );
00631 endInsertColumns();
00632 }
00633
00634 void AttributesModel::slotRowsAboutToBeRemoved( const QModelIndex& parent, int start, int end )
00635 {
00636 beginRemoveRows( mapFromSource( parent ), start, end );
00637 }
00638
00639 void AttributesModel::slotColumnsAboutToBeRemoved( const QModelIndex& parent, int start, int end )
00640 {
00641 beginRemoveColumns( mapFromSource( parent ), start, end );
00642 }
00643
00644 void AttributesModel::slotRowsRemoved( const QModelIndex& parent, int start, int end )
00645 {
00646 Q_UNUSED( parent );
00647 Q_UNUSED( start );
00648 Q_UNUSED( end );
00649 endRemoveRows();
00650 }
00651
00652 void AttributesModel::slotColumnsRemoved( const QModelIndex& parent, int start, int end )
00653 {
00654 Q_UNUSED( parent );
00655 Q_UNUSED( start );
00656 Q_UNUSED( end );
00657 endRemoveColumns();
00658 }
00659
00660 void AttributesModel::slotDataChanged( const QModelIndex& topLeft, const QModelIndex& bottomRight )
00661 {
00662 emit dataChanged( mapFromSource( topLeft ), mapFromSource( bottomRight ) );
00663 }
00664
00666 const QMap<int, QMap<int, QMap<int, QVariant> > > AttributesModel::dataMap()const
00667 {
00668 return mDataMap;
00669 }
00671 const QMap<int, QMap<int, QVariant> > AttributesModel::horizontalHeaderDataMap()const
00672 {
00673 return mHorizontalHeaderDataMap;
00674 }
00676 const QMap<int, QMap<int, QVariant> > AttributesModel::verticalHeaderDataMap()const
00677 {
00678 return mVerticalHeaderDataMap;
00679 }
00681 const QMap<int, QVariant> AttributesModel::modelDataMap()const
00682 {
00683 return mModelDataMap;
00684 }
00685
00687 void AttributesModel::setDataMap( const QMap<int, QMap<int, QMap<int, QVariant> > > map )
00688 {
00689 mDataMap = map;
00690 }
00692 void AttributesModel::setHorizontalHeaderDataMap( const QMap<int, QMap<int, QVariant> > map )
00693 {
00694 mHorizontalHeaderDataMap = map;
00695 }
00697 void AttributesModel::setVerticalHeaderDataMap( const QMap<int, QMap<int, QVariant> > map )
00698 {
00699 mVerticalHeaderDataMap = map;
00700 }
00702 void AttributesModel::setModelDataMap( const QMap<int, QVariant> map )
00703 {
00704 mModelDataMap = map;
00705 }
00706
00707 void AttributesModel::setDefaultForRole( int role, const QVariant& value )
00708 {
00709 if ( value.isValid() ) {
00710 mDefaultsMap.insert( role, value );
00711 } else {
00712
00713 QMap<int, QVariant>::iterator it = mDefaultsMap.find( role );
00714 if ( it != mDefaultsMap.end() ) {
00715 mDefaultsMap.erase( it );
00716 }
00717 }
00718
00719 Q_ASSERT( defaultsForRole( role ) == value );
00720 }