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