KChart

KChartAttributesModel.cpp
1/*
2 * SPDX-FileCopyrightText: 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
3 *
4 * This file is part of the KD Chart library.
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
9#include "KChartAttributesModel.h"
10
11#include "KChartPalette.h"
12#include "KChartMath_p.h"
13
14#include <QDebug>
15#include <QPen>
16#include <QPointer>
17
18#include <KChartTextAttributes.h>
19#include <KChartFrameAttributes.h>
20#include <KChartBackgroundAttributes.h>
22#include <KChartMarkerAttributes.h>
23#include <KChartBarAttributes.h>
24#include <KChartStockBarAttributes.h>
25#include <KChartLineAttributes.h>
26#include <KChartPieAttributes.h>
27#include <KChartAbstractThreeDAttributes.h>
28#include <KChartThreeDBarAttributes.h>
29#include <KChartThreeDLineAttributes.h>
30#include <KChartThreeDPieAttributes.h>
31#include <KChartGridAttributes.h>
32#include <KChartValueTrackerAttributes.h>
33
34
35using namespace KChart;
36
37
38class Q_DECL_HIDDEN AttributesModel::Private
39{
40public:
41 Private();
42
44 QMap< int, QMap< int, QVariant > > horizontalHeaderDataMap;
45 QMap< int, QMap< int, QVariant > > verticalHeaderDataMap;
46 QMap< int, QVariant > modelDataMap;
47 QMap< int, QVariant > defaultsMap;
48 int dataDimension;
49 AttributesModel::PaletteType paletteType;
50 Palette palette;
51};
52
53AttributesModel::Private::Private()
54 : dataDimension( 1 ),
55 paletteType( AttributesModel::PaletteTypeDefault ),
56 palette( Palette::defaultPalette() )
57{
58}
59
60#define d d_func()
61
62AttributesModel::AttributesModel( QAbstractItemModel* model, QObject * parent/* = 0 */ )
63 : AbstractProxyModel( parent ),
64 _d( new Private )
65{
66 setSourceModel( model );
67 setDefaultForRole( KChart::DataValueLabelAttributesRole,
68 DataValueAttributes::defaultAttributesAsVariant() );
69}
70
71AttributesModel::~AttributesModel()
72{
73 delete _d;
74 _d = nullptr;
75}
76
78{
79 *d = *other->d;
80}
81
82bool AttributesModel::compareHeaderDataMaps( const QMap< int, QMap< int, QVariant > >& mapA,
83 const QMap< int, QMap< int, QVariant > >& mapB ) const
84{
85 if ( mapA.count() != mapB.count() ) {
86 return false;
87 }
88 QMap< int, QMap< int, QVariant > >::const_iterator itA = mapA.constBegin();
89 QMap< int, QMap< int, QVariant > >::const_iterator itB = mapB.constBegin();
90 for ( ; itA != mapA.constEnd(); ++itA, ++itB ) {
91 if ( itA->count() != itB->count() ) {
92 return false;
93 }
94 QMap< int, QVariant >::const_iterator it2A = itA->constBegin();
95 QMap< int, QVariant >::const_iterator it2B = itB->constBegin();
96 for ( ; it2A != itA->constEnd(); ++it2A, ++it2B ) {
97 if ( it2A.key() != it2B.key() ) {
98 return false;
99 }
100 if ( !compareAttributes( it2A.key(), it2A.value(), it2B.value() ) ) {
101 return false;
102 }
103 }
104 }
105 return true;
106}
107
109{
110 if ( other == this ) {
111 return true;
112 }
113 if ( !other || d->paletteType != other->d->paletteType ) {
114 return false;
115 }
116
117 {
118 if ( d->dataMap.count() != other->d->dataMap.count() ) {
119 return false;
120 }
121 QMap< int, QMap< int, QMap<int, QVariant > > >::const_iterator itA = d->dataMap.constBegin();
122 QMap< int, QMap< int, QMap<int, QVariant > > >::const_iterator itB = other->d->dataMap.constBegin();
123 for ( ; itA != d->dataMap.constEnd(); ++itA, ++itB ) {
124 if ( itA->count() != itB->count() ) {
125 return false;
126 }
127 QMap< int, QMap< int, QVariant > >::const_iterator it2A = itA->constBegin();
128 QMap< int, QMap< int, QVariant > >::const_iterator it2B = itB->constBegin();
129 for ( ; it2A != itA->constEnd(); ++it2A, ++it2B ) {
130 if ( it2A->count() != it2B->count() ) {
131 return false;
132 }
135 for ( ; it3A != it2A->constEnd(); ++it3A, ++it3B ) {
136 if ( it3A.key() != it3B.key() ) {
137 return false;
138 }
139 if ( !compareAttributes( it3A.key(), it3A.value(), it3B.value() ) ) {
140 return false;
141 }
142 }
143 }
144 }
145 }
146
147 if ( !compareHeaderDataMaps( d->horizontalHeaderDataMap, other->d->horizontalHeaderDataMap ) ||
148 !compareHeaderDataMaps( d->verticalHeaderDataMap, other->d->verticalHeaderDataMap ) ) {
149 return false;
150 }
151
152 {
153 if ( d->modelDataMap.count() != other->d->modelDataMap.count() ) {
154 return false;
155 }
156 QMap< int, QVariant >::const_iterator itA = d->modelDataMap.constBegin();
157 QMap< int, QVariant >::const_iterator itB = other->d->modelDataMap.constBegin();
158 for ( ; itA != d->modelDataMap.constEnd(); ++itA, ++itB ) {
159 if ( itA.key() != itB.key() ) {
160 return false;
161 }
162 if ( !compareAttributes( itA.key(), itA.value(), itB.value() ) ) {
163 return false;
164 }
165 }
166 }
167 return true;
168}
169
170bool AttributesModel::compareAttributes(
171 int role, const QVariant& a, const QVariant& b ) const
172{
173 if ( isKnownAttributesRole( role ) ) {
174 switch ( role ) {
175 case DataValueLabelAttributesRole:
176 return (a.value<DataValueAttributes>() ==
178 case DatasetBrushRole:
179 return (a.value<QBrush>() ==
180 b.value<QBrush>());
181 case DatasetPenRole:
182 return (a.value<QPen>() ==
183 b.value<QPen>());
184 case ThreeDAttributesRole:
185 // As of yet there is no ThreeDAttributes class,
186 // and the AbstractThreeDAttributes class is pure virtual,
187 // so we ignore this role for now.
188 // (khz, 04.04.2007)
189 /*
190 return (qVariantValue<ThreeDAttributes>( a ) ==
191 qVariantValue<ThreeDAttributes>( b ));
192 */
193 break;
194 case LineAttributesRole:
195 return (a.value<LineAttributes>() ==
196 b.value<LineAttributes>());
197 case ThreeDLineAttributesRole:
198 return (a.value<ThreeDLineAttributes>() ==
200 case BarAttributesRole:
201 return (a.value<BarAttributes>() ==
202 b.value<BarAttributes>());
203 case StockBarAttributesRole:
204 return (a.value<StockBarAttributes>() ==
206 case ThreeDBarAttributesRole:
207 return (a.value<ThreeDBarAttributes>() ==
209 case PieAttributesRole:
210 return (a.value<PieAttributes>() ==
211 b.value<PieAttributes>());
212 case ThreeDPieAttributesRole:
213 return (a.value<ThreeDPieAttributes>() ==
215 case ValueTrackerAttributesRole:
216 return (a.value<ValueTrackerAttributes>() ==
218 case DataHiddenRole:
219 return (a.value<bool>() ==
220 b.value<bool>());
221 default:
222 Q_ASSERT( false ); // all of our own roles need to be handled
223 break;
224 }
225 } else {
226 return (a == b);
227 }
228 return true;
229}
230
231
233 int role/* = Qt::DisplayRole */ ) const
234{
235 if ( sourceModel() ) {
236 const QVariant sourceData = sourceModel()->headerData( section, orientation, role );
237 if ( sourceData.isValid() ) {
238 return sourceData;
239 }
240 }
241
242 // the source model didn't have data set, let's use our stored values
243 const QMap< int, QMap< int, QVariant> >& map = orientation == Qt::Horizontal ?
244 d->horizontalHeaderDataMap : d->verticalHeaderDataMap;
245 QMap< int, QMap< int, QVariant > >::const_iterator mapIt = map.find( section );
246 if ( mapIt != map.constEnd() ) {
247 const QMap< int, QVariant >& dataMap = mapIt.value();
248 QMap< int, QVariant >::const_iterator dataMapIt = dataMap.find( role );
249 if ( dataMapIt != dataMap.constEnd() ) {
250 return dataMapIt.value();
251 }
252 }
253
254 return defaultHeaderData( section, orientation, role );
255}
256
257
258QVariant AttributesModel::defaultHeaderData( int section, Qt::Orientation orientation, int role ) const
259{
260 // Default values if nothing else matches
261
262 const int dataset = section / d->dataDimension;
263
264 switch ( role ) {
265 case Qt::DisplayRole:
266 //TODO for KChart 3.0: return QString::number( dataset + 1 );
267 return QVariant( (orientation == Qt::Vertical ? QStringLiteral("Series ") : QStringLiteral("Item ")) + QString::number( dataset )) ;
268 case KChart::DatasetBrushRole:
269 return d->palette.getBrush( dataset );
270 case KChart::DatasetPenRole:
271 // if no per model override was set, use the (possibly default) color set for the brush
272 if ( !modelData( role ).isValid() ) {
273 QBrush brush = headerData( section, orientation, DatasetBrushRole ).value< QBrush >();
274 return QPen( brush.color() );
275 }
276 default:
277 break;
278 }
279
280 return QVariant();
281}
282
283
285{
286 if ( isKnownAttributesRole( role ) ) {
287 // check if there is something set at global level
288 QVariant v = modelData( role );
289
290 // else return the default setting, if any
291 if ( !v.isValid() )
292 v = defaultsForRole( role );
293 return v;
294 }
295 return QVariant();
296}
297
298
299QVariant AttributesModel::data( int column, int role ) const
300{
301 if ( isKnownAttributesRole( role ) ) {
302 // check if there is something set for the column (dataset)
303 QVariant v;
304 v = headerData( column, Qt::Horizontal, role );
305
306 // check if there is something set at global level
307 if ( !v.isValid() )
308 v = data( role ); // includes automatic fallback to default
309 return v;
310 }
311 return QVariant();
312}
313
314
315QVariant AttributesModel::data( const QModelIndex& index, int role ) const
316{
317 if ( index.isValid() ) {
318 Q_ASSERT( index.model() == this );
319 }
320 if ( !sourceModel() ) {
321 return QVariant();
322 }
323
324 if ( index.isValid() ) {
325 const QVariant sourceData = sourceModel()->data( mapToSource( index ), role );
326 if ( sourceData.isValid() ) {
327 return sourceData;
328 }
329 }
330
331 // check if we are storing a value for this role at this cell index
332 if ( d->dataMap.contains( index.column() ) ) {
333 const QMap< int, QMap< int, QVariant > >& colDataMap = d->dataMap[ index.column() ];
334 if ( colDataMap.contains( index.row() ) ) {
335 const QMap< int, QVariant >& dataMap = colDataMap[ index.row() ];
336 if ( dataMap.contains( role ) ) {
337 const QVariant v = dataMap[ role ];
338 if ( v.isValid() ) {
339 return v;
340 }
341 }
342 }
343 }
344 // check if there is something set for the column (dataset), or at global level
345 if ( index.isValid() ) {
346 return data( index.column(), role ); // includes automatic fallback to default
347 }
348
349 return QVariant();
350}
351
352
354{
355 switch ( role ) {
356 // fallthrough intended
357 case DataValueLabelAttributesRole:
358 case DatasetBrushRole:
359 case DatasetPenRole:
360 case ThreeDAttributesRole:
361 case LineAttributesRole:
362 case ThreeDLineAttributesRole:
363 case BarAttributesRole:
364 case StockBarAttributesRole:
365 case ThreeDBarAttributesRole:
366 case PieAttributesRole:
367 case ThreeDPieAttributesRole:
368 case ValueTrackerAttributesRole:
369 case DataHiddenRole:
370 return true;
371 default:
372 return false;
373 }
374}
375
376QVariant AttributesModel::defaultsForRole( int role ) const
377{
378 // returns default-constructed QVariant if not found
379 return d->defaultsMap.value( role );
380}
381
382bool AttributesModel::setData ( const QModelIndex & index, const QVariant & value, int role )
383{
384 if ( !isKnownAttributesRole( role ) ) {
385 return sourceModel()->setData( mapToSource(index), value, role );
386 } else {
387 QMap< int, QMap< int, QVariant> > &colDataMap = d->dataMap[ index.column() ];
388 QMap< int, QVariant > &dataMap = colDataMap[ index.row() ];
389 dataMap.insert( role, value );
390 Q_EMIT attributesChanged( index, index );
391 return true;
392 }
393}
394
395bool AttributesModel::resetData ( const QModelIndex & index, int role )
396{
397 return setData( index, QVariant(), role );
398}
399
400bool AttributesModel::setHeaderData ( int section, Qt::Orientation orientation,
401 const QVariant & value, int role )
402{
403 if ( sourceModel() && headerData( section, orientation, role ) == value ) {
404 return true;
405 }
406
407 if ( !isKnownAttributesRole( role ) ) {
408 return sourceModel()->setHeaderData( section, orientation, value, role );
409 } else {
410 QMap< int, QMap<int, QVariant > > &sectionDataMap
411 = orientation == Qt::Horizontal ? d->horizontalHeaderDataMap : d->verticalHeaderDataMap;
412
413 QMap< int, QVariant > &dataMap = sectionDataMap[ section ];
414 dataMap.insert( role, value );
415 if ( sourceModel() ) {
416 int numRows = rowCount( QModelIndex() );
417 int numCols = columnCount( QModelIndex() );
418 if ( orientation == Qt::Horizontal && numRows > 0 )
419 Q_EMIT attributesChanged( index( 0, section, QModelIndex() ),
420 index( numRows - 1, section, QModelIndex() ) );
421 else if ( orientation == Qt::Vertical && numCols > 0 )
422 Q_EMIT attributesChanged( index( section, 0, QModelIndex() ),
423 index( section, numCols - 1, QModelIndex() ) );
424 Q_EMIT headerDataChanged( orientation, section, section );
425
426 // FIXME: This only makes sense for orientation == Qt::Horizontal,
427 // but what if orientation == Qt::Vertical?
428 if ( section != -1 && numRows > 0 )
429 Q_EMIT dataChanged( index( 0, section, QModelIndex() ),
430 index( numRows - 1, section, QModelIndex() ) );
431 }
432 return true;
433 }
434}
435
436bool AttributesModel::resetHeaderData ( int section, Qt::Orientation orientation, int role )
437{
438 return setHeaderData ( section, orientation, QVariant(), role );
439}
440
441void AttributesModel::setPaletteType( AttributesModel::PaletteType type )
442{
443 if ( d->paletteType == type ) {
444 return;
445 }
446 d->paletteType = type;
447 switch ( type ) {
448 case PaletteTypeDefault:
449 d->palette = Palette::defaultPalette();
450 break;
451 case PaletteTypeSubdued:
452 d->palette = Palette::subduedPalette();
453 break;
454 case PaletteTypeRainbow:
455 d->palette = Palette::rainbowPalette();
456 break;
457 default:
458 qWarning( "Unknown palette type!" );
459 }
460}
461
462AttributesModel::PaletteType AttributesModel::paletteType() const
463{
464 return d->paletteType;
465}
466
467bool KChart::AttributesModel::setModelData( const QVariant value, int role )
468{
469 d->modelDataMap.insert( role, value );
470 int numRows = rowCount( QModelIndex() );
471 int numCols = columnCount( QModelIndex() );
472 if ( sourceModel() && numRows > 0 && numCols > 0 ) {
473 Q_EMIT attributesChanged( index( 0, 0, QModelIndex() ),
474 index( numRows - 1, numCols - 1, QModelIndex() ) );
475 beginResetModel();
476 endResetModel();
477 }
478 return true;
479}
480
481QVariant KChart::AttributesModel::modelData( int role ) const
482{
483 return d->modelDataMap.value( role, QVariant() );
484}
485
486int AttributesModel::rowCount( const QModelIndex& index ) const
487{
488 if ( sourceModel() ) {
489 return sourceModel()->rowCount( mapToSource(index) );
490 } else {
491 return 0;
492 }
493}
494
496{
497 if ( sourceModel() ) {
498 return sourceModel()->columnCount( mapToSource(index) );
499 } else {
500 return 0;
501 }
502}
503
505{
506 if ( this->sourceModel() != nullptr )
507 {
509 this, SLOT(slotDataChanged(QModelIndex,QModelIndex)));
510 disconnect( this->sourceModel(), SIGNAL(rowsInserted(QModelIndex,int,int)),
511 this, SLOT(slotRowsInserted(QModelIndex,int,int)) );
512 disconnect( this->sourceModel(), SIGNAL(rowsRemoved(QModelIndex,int,int)),
513 this, SLOT(slotRowsRemoved(QModelIndex,int,int)) );
514 disconnect( this->sourceModel(), SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
515 this, SLOT(slotRowsAboutToBeInserted(QModelIndex,int,int)) );
516 disconnect( this->sourceModel(), SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
517 this, SLOT(slotRowsAboutToBeRemoved(QModelIndex,int,int)) );
518 disconnect( this->sourceModel(), SIGNAL(columnsInserted(QModelIndex,int,int)),
519 this, SLOT(slotColumnsInserted(QModelIndex,int,int)) );
520 disconnect( this->sourceModel(), SIGNAL(columnsRemoved(QModelIndex,int,int)),
521 this, SLOT(slotColumnsRemoved(QModelIndex,int,int)) );
523 this, SLOT(slotColumnsAboutToBeInserted(QModelIndex,int,int)) );
525 this, SLOT(slotColumnsAboutToBeRemoved(QModelIndex,int,int)) );
526 disconnect( this->sourceModel(), SIGNAL(modelReset()),
527 this, SIGNAL(modelReset()) );
528 disconnect( this->sourceModel(), SIGNAL(layoutChanged()),
529 this, SIGNAL(layoutChanged()) );
530 }
532 if ( this->sourceModel() != nullptr )
533 {
535 this, SLOT(slotDataChanged(QModelIndex,QModelIndex)));
536 connect( this->sourceModel(), SIGNAL(rowsInserted(QModelIndex,int,int)),
537 this, SLOT(slotRowsInserted(QModelIndex,int,int)) );
538 connect( this->sourceModel(), SIGNAL(rowsRemoved(QModelIndex,int,int)),
539 this, SLOT(slotRowsRemoved(QModelIndex,int,int)) );
540 connect( this->sourceModel(), SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
541 this, SLOT(slotRowsAboutToBeInserted(QModelIndex,int,int)) );
542 connect( this->sourceModel(), SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
543 this, SLOT(slotRowsAboutToBeRemoved(QModelIndex,int,int)) );
544 connect( this->sourceModel(), SIGNAL(columnsInserted(QModelIndex,int,int)),
545 this, SLOT(slotColumnsInserted(QModelIndex,int,int)) );
546 connect( this->sourceModel(), SIGNAL(columnsRemoved(QModelIndex,int,int)),
547 this, SLOT(slotColumnsRemoved(QModelIndex,int,int)) );
548 connect( this->sourceModel(), SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)),
549 this, SLOT(slotColumnsAboutToBeInserted(QModelIndex,int,int)) );
550 connect( this->sourceModel(), SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)),
551 this, SLOT(slotColumnsAboutToBeRemoved(QModelIndex,int,int)) );
552 connect( this->sourceModel(), SIGNAL(modelReset()),
553 this, SIGNAL(modelReset()) );
554 connect( this->sourceModel(), SIGNAL(layoutChanged()),
555 this, SIGNAL(layoutChanged()) );
556 }
557}
558
559void AttributesModel::slotRowsAboutToBeInserted( const QModelIndex& parent, int start, int end )
560{
562}
563
564void AttributesModel::slotColumnsAboutToBeInserted( const QModelIndex& parent, int start, int end )
565{
567}
568
569void AttributesModel::slotRowsInserted( const QModelIndex& parent, int start, int end )
570{
571 Q_UNUSED( parent );
572 Q_UNUSED( start );
573 Q_UNUSED( end );
575}
576
577void AttributesModel::slotColumnsInserted( const QModelIndex& parent, int start, int end )
578{
579 Q_UNUSED( parent );
580 Q_UNUSED( start );
581 Q_UNUSED( end );
583}
584
585void AttributesModel::slotRowsAboutToBeRemoved( const QModelIndex& parent, int start, int end )
586{
588}
589
590void AttributesModel::slotColumnsAboutToBeRemoved( const QModelIndex& parent, int start, int end )
591{
593}
594
595void AttributesModel::slotRowsRemoved( const QModelIndex& parent, int start, int end )
596{
597 Q_UNUSED( parent );
598 Q_UNUSED( start );
599 Q_UNUSED( end );
601}
602
603void AttributesModel::removeEntriesFromDataMap( int start, int end )
604{
605 QMap< int, QMap< int, QMap< int, QVariant > > >::iterator it = d->dataMap.find( end );
606 // check that the element was found
607 if ( it != d->dataMap.end() ) {
608 ++it;
609 QVector< int > indexesToDel;
610 for ( int i = start; i < end && it != d->dataMap.end(); ++i ) {
611 d->dataMap[ i ] = it.value();
612 indexesToDel << it.key();
613 ++it;
614 }
615 if ( indexesToDel.isEmpty() ) {
616 for ( int i = start; i < end; ++i ) {
617 indexesToDel << i;
618 }
619 }
620 for ( int i = 0; i < indexesToDel.count(); ++i ) {
621 d->dataMap.remove( indexesToDel[ i ] );
622 }
623 }
624}
625
626void AttributesModel::removeEntriesFromDirectionDataMaps( Qt::Orientation dir, int start, int end )
627{
628 QMap<int, QMap<int, QVariant> > &sectionDataMap
629 = dir == Qt::Horizontal ? d->horizontalHeaderDataMap : d->verticalHeaderDataMap;
630 QMap<int, QMap<int, QVariant> >::iterator it = sectionDataMap.upperBound( end );
631 // check that the element was found
632 if ( it != sectionDataMap.end() )
633 {
634 QVector< int > indexesToDel;
635 for ( int i = start; i < end && it != sectionDataMap.end(); ++i )
636 {
637 sectionDataMap[ i ] = it.value();
638 indexesToDel << it.key();
639 ++it;
640 }
641 if ( indexesToDel.isEmpty() )
642 {
643 for ( int i = start; i < end; ++i )
644 {
645 indexesToDel << i;
646 }
647 }
648 for ( int i = 0; i < indexesToDel.count(); ++i )
649 {
650 sectionDataMap.remove( indexesToDel[ i ] );
651 }
652 }
653}
654
655void AttributesModel::slotColumnsRemoved( const QModelIndex& parent, int start, int end )
656{
657 Q_UNUSED( parent );
658 Q_UNUSED( start );
659 Q_UNUSED( end );
660 Q_ASSERT_X( sourceModel(), "removeColumn", "This should only be triggered if a valid source Model exists!" );
661 for ( int i = start; i <= end; ++i ) {
662 d->verticalHeaderDataMap.remove( start );
663 }
664 removeEntriesFromDataMap( start, end );
665 removeEntriesFromDirectionDataMaps( Qt::Horizontal, start, end );
666 removeEntriesFromDirectionDataMaps( Qt::Vertical, start, end );
667
669}
670
671void AttributesModel::slotDataChanged( const QModelIndex& topLeft, const QModelIndex& bottomRight )
672{
673 Q_EMIT dataChanged( mapFromSource( topLeft ), mapFromSource( bottomRight ) );
674}
675
676void AttributesModel::setDefaultForRole( int role, const QVariant& value )
677{
678 if ( value.isValid() ) {
679 d->defaultsMap.insert( role, value );
680 } else {
681 // erase the possibly existing value to not let the map grow:
682 QMap<int, QVariant>::iterator it = d->defaultsMap.find( role );
683 if ( it != d->defaultsMap.end() ) {
684 d->defaultsMap.erase( it );
685 }
686 }
687
688 Q_ASSERT( defaultsForRole( role ).value<KChart::DataValueAttributes>() == value.value<KChart::DataValueAttributes>() );
689}
690
692{
693 //### need to "reformat" or throw away internal data?
694 d->dataDimension = dimension;
695}
696
697int AttributesModel::datasetDimension() const
698{
699 return d->dataDimension;
700}
Declaring the class KChart::DataValueAttributes.
Base class for all proxy models used inside KChart.
QModelIndex index(int row, int col, const QModelIndex &index) const override
QModelIndex mapToSource(const QModelIndex &proxyIndex) const override
QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override
A proxy model used for decorating data with attributes.
virtual QVariant defaultHeaderData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Returns default values for the header data.
QVariant data(int role) const
Returns the data that were specified at global level, or the default data, or QVariant().
int rowCount(const QModelIndex &) const override
\reimpl
void setDatasetDimension(int dimension)
Set the dimension of the dataset in the source model.
bool resetHeaderData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole)
Remove any explicit attributes settings that might have been specified before.
bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role=Qt::DisplayRole) override
\reimpl
void setPaletteType(PaletteType type)
Sets the palettetype used by this attributesmodel.
void setSourceModel(QAbstractItemModel *sourceModel) override
\reimpl
bool resetData(const QModelIndex &index, int role=Qt::DisplayRole)
Remove any explicit attributes settings that might have been specified before.
void setDefaultForRole(int role, const QVariant &value)
Define the default value for a certain role.
void initFrom(const AttributesModel *other)
Copies the internal data (maps and palette) of another AttributesModel* into this one.
bool compare(const AttributesModel *other) const
Returns true if both, all of the attributes set, and the palette set is equal in both of the Attribut...
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::DisplayRole) override
\reimpl
bool isKnownAttributesRole(int role) const
Returns whether the given role corresponds to one of the known internally used ones.
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
\reimpl
int columnCount(const QModelIndex &) const override
\reimpl
Set of attributes for changing the appearance of bar charts.
Diagram attributes dealing with data value labels.
Set of attributes for changing the appearance of line charts.
static const Palette & defaultPalette()
Provide access to the three builtin palettes, one with standard bright colors, one with more subdued ...
A set of attributes controlling the appearance of pie charts.
Attributes to customize the appearance of a column in a stock chart.
A set of 3D bar attributes.
A set of 3D pie attributes.
Cell-specific attributes regarding value tracking.
Q_SCRIPTABLE Q_NOREPLY void start()
KIOCORE_EXPORT QString dir(const QString &fileClass)
const QList< QKeySequence > & end()
void beginInsertColumns(const QModelIndex &parent, int first, int last)
void beginInsertRows(const QModelIndex &parent, int first, int last)
void beginRemoveColumns(const QModelIndex &parent, int first, int last)
void beginRemoveRows(const QModelIndex &parent, int first, int last)
void columnsAboutToBeInserted(const QModelIndex &parent, int first, int last)
void columnsAboutToBeRemoved(const QModelIndex &parent, int first, int last)
void columnsInserted(const QModelIndex &parent, int first, int last)
void columnsRemoved(const QModelIndex &parent, int first, int last)
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles)
void headerDataChanged(Qt::Orientation orientation, int first, int last)
void layoutChanged(const QList< QPersistentModelIndex > &parents, QAbstractItemModel::LayoutChangeHint hint)
void rowsAboutToBeInserted(const QModelIndex &parent, int start, int end)
void rowsAboutToBeRemoved(const QModelIndex &parent, int first, int last)
void rowsInserted(const QModelIndex &parent, int first, int last)
void rowsRemoved(const QModelIndex &parent, int first, int last)
virtual void setSourceModel(QAbstractItemModel *sourceModel)
const QColor & color() const const
const_iterator constBegin() const const
const_iterator constEnd() const const
bool contains(const Key &key) const const
size_type count() const const
iterator end()
iterator find(const Key &key)
iterator insert(const Key &key, const T &value)
Key key(const T &value, const Key &defaultKey) const const
size_type remove(const Key &key)
iterator upperBound(const Key &key)
T value(const Key &key, const T &defaultValue) const const
int column() const const
bool isValid() const const
const QAbstractItemModel * model() const const
int row() const const
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool disconnect(const QMetaObject::Connection &connection)
QObject * parent() const const
QString number(double n, char format, int precision)
DisplayRole
Orientation
void * data()
bool isValid() const const
T value() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:02:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.