#include <KDChartAbstractDiagram.h>
Inheritance diagram for KDChart::PrivateAttributesModel:
Definition at line 656 of file KDChartAbstractDiagram.h.
Public Types | |
enum | PaletteType { PaletteTypeDefault = 0, PaletteTypeRainbow = 1, PaletteTypeSubdued = 2 } |
Signals | |
void | attributesChanged (const QModelIndex &, const QModelIndex &) |
Public Member Functions | |
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 |
PrivateAttributesModel (QAbstractItemModel *model, QObject *parent=0) | |
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] | |
void | setDefaultForRole (int role, const QVariant &value) |
Define the default value for a certain role. | |
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] | |
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 |
enum KDChart::AttributesModel::PaletteType [inherited] |
Definition at line 50 of file KDChartAttributesModel.h.
00050 { 00051 PaletteTypeDefault = 0, 00052 PaletteTypeRainbow = 1, 00053 PaletteTypeSubdued = 2 00054 };
KDChart::PrivateAttributesModel::PrivateAttributesModel | ( | QAbstractItemModel * | model, | |
QObject * | parent = 0 | |||
) | [explicit] |
void KDChart::AttributesModel::attributesChanged | ( | const QModelIndex & | , | |
const QModelIndex & | ||||
) | [signal, inherited] |
int AttributesModel::columnCount | ( | const QModelIndex & | ) | const [inherited] |
[reimplemented]
Definition at line 523 of file KDChartAttributesModel.cpp.
References KDChart::AbstractProxyModel::mapToSource().
Referenced by KDChart::AbstractDiagram::datasetBrushes(), KDChart::AbstractDiagram::datasetLabels(), KDChart::AbstractDiagram::datasetMarkers(), KDChart::AbstractDiagram::datasetPens(), and KDChart::AttributesModel::setModelData().
00524 { 00525 if ( sourceModel() ) { 00526 return sourceModel()->columnCount( mapToSource(index) ); 00527 } else { 00528 return 0; 00529 } 00530 }
bool AttributesModel::compare | ( | const AttributesModel * | other | ) | const [inherited] |
Definition at line 83 of file KDChartAttributesModel.cpp.
References KDChart::AttributesModel::compareAttributes(), KDChart::AttributesModel::mDataMap, KDChart::AttributesModel::mHorizontalHeaderDataMap, KDChart::AttributesModel::mModelDataMap, KDChart::AttributesModel::mVerticalHeaderDataMap, and KDChart::AttributesModel::paletteType().
Referenced by KDChart::AbstractDiagram::compare().
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 }
bool AttributesModel::compareAttributes | ( | int | role, | |
const QVariant & | a, | |||
const QVariant & | b | |||
) | const [inherited] |
Definition at line 231 of file KDChartAttributesModel.cpp.
References KDChart::BarAttributesRole, KDChart::DataHiddenRole, KDChart::DatasetBrushRole, KDChart::DatasetPenRole, KDChart::DataValueLabelAttributesRole, KDChart::AttributesModel::isKnownAttributesRole(), KDChart::LineAttributesRole, KDChart::PieAttributesRole, KDChart::ThreeDAttributesRole, KDChart::ThreeDBarAttributesRole, KDChart::ThreeDLineAttributesRole, KDChart::ThreeDPieAttributesRole, and KDChart::ValueTrackerAttributesRole.
Referenced by KDChart::AttributesModel::compare().
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 }
QVariant AttributesModel::data | ( | const QModelIndex & | , | |
int | role = Qt::DisplayRole | |||
) | const [inherited] |
[reimplemented]
Definition at line 373 of file KDChartAttributesModel.cpp.
References KDChart::AttributesModel::data(), KDChart::AttributesModel::dataMap(), and KDChart::AbstractProxyModel::mapToSource().
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 }
QVariant AttributesModel::data | ( | int | column, | |
int | role | |||
) | const [inherited] |
Returns the data that were specified at per column level, or the globally set data, or the default data, or QVariant().
Definition at line 357 of file KDChartAttributesModel.cpp.
References KDChart::AttributesModel::data(), KDChart::AttributesModel::headerData(), and KDChart::AttributesModel::isKnownAttributesRole().
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 }
QVariant AttributesModel::data | ( | int | role | ) | const [inherited] |
Returns the data that were specified at global level, or the default data, or QVariant().
Definition at line 339 of file KDChartAttributesModel.cpp.
References KDChart::AttributesModel::isKnownAttributesRole(), and KDChart::AttributesModel::modelData().
Referenced by KDChart::AbstractDiagram::brush(), KDChart::AttributesModel::data(), KDChart::AbstractDiagram::dataValueAttributes(), KDChart::AbstractDiagram::isHidden(), and KDChart::AbstractDiagram::pen().
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 }
const QMap< int, QMap< int, QMap< int, QVariant > > > AttributesModel::dataMap | ( | ) | const [protected, inherited] |
needed for serialization
Definition at line 564 of file KDChartAttributesModel.cpp.
Referenced by KDChart::AttributesModel::data(), KDChart::AttributesModel::headerData(), KDChart::AttributesModel::setData(), and KDChart::AttributesModel::setHeaderData().
QVariant AttributesModel::headerData | ( | int | section, | |
Qt::Orientation | orientation, | |||
int | role = Qt::DisplayRole | |||
) | const [inherited] |
[reimplemented]
Definition at line 290 of file KDChartAttributesModel.cpp.
References KDChart::AttributesModel::dataMap(), KDChart::DatasetBrushRole, KDChart::DatasetPenRole, KDChart::Palette::defaultPalette(), KDChart::Palette::getBrush(), KDChart::AttributesModel::modelData(), KDChart::AttributesModel::paletteType(), KDChart::AttributesModel::PaletteTypeDefault, KDChart::AttributesModel::PaletteTypeRainbow, KDChart::AttributesModel::PaletteTypeSubdued, KDChart::Palette::rainbowPalette(), and KDChart::Palette::subduedPalette().
Referenced by KDChart::AttributesModel::data(), KDChart::AbstractDiagram::datasetLabels(), and KDChart::AttributesModel::setHeaderData().
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 }
const QMap< int, QMap< int, QVariant > > AttributesModel::horizontalHeaderDataMap | ( | ) | const [protected, inherited] |
QModelIndex KDChart::AbstractProxyModel::index | ( | int | row, | |
int | col, | |||
const QModelIndex & | index | |||
) | const [inherited] |
[reimplemented]
Definition at line 84 of file KDChartAbstractProxyModel.cpp.
References KDChart::AbstractProxyModel::mapFromSource(), and KDChart::AbstractProxyModel::mapToSource().
Referenced by KDChart::AttributesModel::setHeaderData(), and KDChart::AttributesModel::setModelData().
00085 { 00086 Q_ASSERT(sourceModel()); 00087 return mapFromSource(sourceModel()->index( row, col, mapToSource(index) )); 00088 }
void AttributesModel::initFrom | ( | const AttributesModel * | other | ) | [inherited] |
Definition at line 70 of file KDChartAttributesModel.cpp.
References KDChart::AttributesModel::mDataMap, KDChart::AttributesModel::mDefaultsMap, KDChart::AttributesModel::mHorizontalHeaderDataMap, KDChart::AttributesModel::mModelDataMap, KDChart::AttributesModel::mVerticalHeaderDataMap, KDChart::AttributesModel::paletteType(), and KDChart::AttributesModel::setPaletteType().
Referenced by KDChart::AbstractDiagram::setModel().
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 }
bool AttributesModel::isKnownAttributesRole | ( | int | role | ) | const [inherited] |
Returns whether the given role corresponds to one of the known internally used ones.
Definition at line 413 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, KDChart::ThreeDPieAttributesRole, and KDChart::ValueTrackerAttributesRole.
Referenced by KDChart::AttributesModel::compareAttributes(), KDChart::AttributesModel::data(), KDChart::AttributesModel::setData(), and KDChart::AttributesModel::setHeaderData().
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 }
QModelIndex KDChart::AbstractProxyModel::mapFromSource | ( | const QModelIndex & | sourceIndex | ) | const [inherited] |
[reimplemented]
Definition at line 52 of file KDChartAbstractProxyModel.cpp.
Referenced by KDChart::AbstractProxyModel::index(), and KDChart::AbstractProxyModel::parent().
00053 { 00054 if ( !sourceIndex.isValid() ) 00055 return QModelIndex(); 00056 //qDebug() << "sourceIndex.model()="<<sourceIndex.model(); 00057 //qDebug() << "model()="<<sourceModel(); 00058 Q_ASSERT( sourceIndex.model() == sourceModel() ); 00059 00060 // Create an index that preserves the internal pointer from the source; 00061 // this way AbstractProxyModel preserves the structure of the source model 00062 return createIndex( sourceIndex.row(), sourceIndex.column(), sourceIndex.internalPointer() ); 00063 }
QModelIndex KDChart::AbstractProxyModel::mapToSource | ( | const QModelIndex & | proxyIndex | ) | const [inherited] |
[reimplemented]
Definition at line 65 of file KDChartAbstractProxyModel.cpp.
Referenced by KDChart::AttributesModel::columnCount(), KDChart::AttributesModel::data(), KDChart::AbstractProxyModel::index(), KDChart::AbstractProxyModel::parent(), KDChart::AttributesModel::rowCount(), and KDChart::AttributesModel::setData().
00066 { 00067 if ( !proxyIndex.isValid() ) 00068 return QModelIndex(); 00069 if( proxyIndex.model() != this ) 00070 qDebug() << proxyIndex.model() << this; 00071 Q_ASSERT( proxyIndex.model() == this ); 00072 // So here we need to create a source index which holds that internal pointer. 00073 // No way to pass it to sourceModel()->index... so we have to do the ugly way: 00074 QModelIndex sourceIndex; 00075 KDPrivateModelIndex* hack = reinterpret_cast<KDPrivateModelIndex*>(&sourceIndex); 00076 hack->r = proxyIndex.row(); 00077 hack->c = proxyIndex.column(); 00078 hack->p = proxyIndex.internalPointer(); 00079 hack->m = sourceModel(); 00080 Q_ASSERT( sourceIndex.isValid() ); 00081 return sourceIndex; 00082 }
QVariant KDChart::AttributesModel::modelData | ( | int | role | ) | const [inherited] |
Definition at line 509 of file KDChartAttributesModel.cpp.
Referenced by KDChart::AttributesModel::data(), KDChart::AbstractDiagram::dataValueAttributes(), KDChart::AttributesModel::headerData(), and KDChart::AbstractDiagram::isHidden().
const QMap< int, QVariant > AttributesModel::modelDataMap | ( | ) | const [protected, inherited] |
AttributesModel::PaletteType AttributesModel::paletteType | ( | ) | const [inherited] |
Definition at line 493 of file KDChartAttributesModel.cpp.
Referenced by KDChart::AttributesModel::compare(), KDChart::AttributesModel::headerData(), and KDChart::AttributesModel::initFrom().
QModelIndex KDChart::AbstractProxyModel::parent | ( | const QModelIndex & | index | ) | const [inherited] |
[reimplemented]
Definition at line 90 of file KDChartAbstractProxyModel.cpp.
References KDChart::AbstractProxyModel::mapFromSource(), and KDChart::AbstractProxyModel::mapToSource().
00091 { 00092 Q_ASSERT(sourceModel()); 00093 return mapFromSource(sourceModel()->parent( mapToSource(index) )); 00094 }
bool AttributesModel::resetData | ( | const QModelIndex & | index, | |
int | role = Qt::DisplayRole | |||
) | [inherited] |
Remove any explicit attributes settings that might have been specified before.
Definition at line 457 of file KDChartAttributesModel.cpp.
References KDChart::AttributesModel::setData().
bool AttributesModel::resetHeaderData | ( | int | section, | |
Qt::Orientation | orientation, | |||
int | role = Qt::DisplayRole | |||
) | [inherited] |
Remove any explicit attributes settings that might have been specified before.
Definition at line 483 of file KDChartAttributesModel.cpp.
References KDChart::AttributesModel::setHeaderData().
00484 { 00485 return setHeaderData ( section, orientation, QVariant(), role ); 00486 }
int AttributesModel::rowCount | ( | const QModelIndex & | ) | const [inherited] |
[reimplemented]
Definition at line 514 of file KDChartAttributesModel.cpp.
References KDChart::AbstractProxyModel::mapToSource().
Referenced by KDChart::AbstractDiagram::itemRowLabels(), KDChart::AttributesModel::setHeaderData(), and KDChart::AttributesModel::setModelData().
00515 { 00516 if ( sourceModel() ) { 00517 return sourceModel()->rowCount( mapToSource(index) ); 00518 } else { 00519 return 0; 00520 } 00521 }
bool AttributesModel::setData | ( | const QModelIndex & | index, | |
const QVariant & | value, | |||
int | role = Qt::DisplayRole | |||
) | [inherited] |
[reimplemented]
Definition at line 443 of file KDChartAttributesModel.cpp.
References KDChart::AttributesModel::attributesChanged(), KDChart::AttributesModel::dataMap(), KDChart::AttributesModel::isKnownAttributesRole(), and KDChart::AbstractProxyModel::mapToSource().
Referenced by KDChart::AttributesModel::resetData(), KDChart::BarDiagram::setBarAttributes(), KDChart::AbstractDiagram::setBrush(), and KDChart::AbstractDiagram::setPen().
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 }
void AttributesModel::setDataMap | ( | const QMap< int, QMap< int, QMap< int, QVariant > > > | map | ) | [protected, inherited] |
void AttributesModel::setDefaultForRole | ( | int | role, | |
const QVariant & | value | |||
) | [inherited] |
Define the default value for a certain role.
Passing a default-constructed QVariant is equivalent to removing the default.
Definition at line 605 of file KDChartAttributesModel.cpp.
Referenced by KDChart::AttributesModel::AttributesModel(), and KDChart::TernaryLineDiagram::TernaryLineDiagram().
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 }
bool AttributesModel::setHeaderData | ( | int | section, | |
Qt::Orientation | orientation, | |||
const QVariant & | value, | |||
int | role = Qt::DisplayRole | |||
) | [inherited] |
[reimplemented]
Definition at line 462 of file KDChartAttributesModel.cpp.
References KDChart::AttributesModel::attributesChanged(), KDChart::AttributesModel::dataMap(), KDChart::AttributesModel::headerData(), KDChart::AbstractProxyModel::index(), KDChart::AttributesModel::isKnownAttributesRole(), and KDChart::AttributesModel::rowCount().
Referenced by KDChart::AttributesModel::resetHeaderData(), KDChart::AbstractDiagram::setBrush(), and KDChart::AbstractDiagram::setPen().
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> > §ionDataMap 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 }
void AttributesModel::setHorizontalHeaderDataMap | ( | const QMap< int, QMap< int, QVariant > > | map | ) | [protected, inherited] |
bool KDChart::AttributesModel::setModelData | ( | const QVariant | value, | |
int | role | |||
) | [inherited] |
Definition at line 498 of file KDChartAttributesModel.cpp.
References KDChart::AttributesModel::attributesChanged(), KDChart::AttributesModel::columnCount(), KDChart::AbstractProxyModel::index(), and KDChart::AttributesModel::rowCount().
Referenced by KDChart::AbstractDiagram::setBrush(), and KDChart::AbstractDiagram::setPen().
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 }
void AttributesModel::setModelDataMap | ( | const QMap< int, QVariant > | map | ) | [protected, inherited] |
void AttributesModel::setPaletteType | ( | PaletteType | type | ) | [inherited] |
Sets the palettetype used by this attributesmodel.
Definition at line 488 of file KDChartAttributesModel.cpp.
Referenced by KDChart::AttributesModel::initFrom().
void AttributesModel::setSourceModel | ( | QAbstractItemModel * | sourceModel | ) | [inherited] |
[reimplemented]
Definition at line 532 of file KDChartAttributesModel.cpp.
Referenced by KDChart::AttributesModel::AttributesModel().
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 }
void AttributesModel::setVerticalHeaderDataMap | ( | const QMap< int, QMap< int, QVariant > > | map | ) | [protected, inherited] |
const QMap< int, QMap< int, QVariant > > AttributesModel::verticalHeaderDataMap | ( | ) | const [protected, inherited] |