![]() |
KD Chart API Documentation
3.1
|
A proxy model used for decorating data with attributes. More...
#include <KDChartAttributesModel.h>
Public Types | |
enum | PaletteType { PaletteTypeDefault = 0 , PaletteTypeRainbow = 1 , PaletteTypeSubdued = 2 } |
Signals | |
void | attributesChanged (const QModelIndex &, const QModelIndex &) |
Public Member Functions | |
AttributesModel (QAbstractItemModel *model, QObject *parent=nullptr) | |
~AttributesModel () override | |
int | columnCount (const QModelIndex &) const override |
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 override |
QVariant | data (int column, int role) const |
QVariant | data (int role) const |
int | datasetDimension () const |
virtual QVariant | defaultHeaderData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const |
QVariant | headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override |
void | initFrom (const AttributesModel *other) |
bool | isKnownAttributesRole (int role) const |
QVariant | modelData (int role) const |
PaletteType | paletteType () const |
bool | resetData (const QModelIndex &index, int role=Qt::DisplayRole) |
bool | resetHeaderData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) |
int | rowCount (const QModelIndex &) const override |
bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::DisplayRole) override |
void | setDatasetDimension (int dimension) |
void | setDefaultForRole (int role, const QVariant &value) |
bool | setHeaderData (int section, Qt::Orientation orientation, const QVariant &value, int role=Qt::DisplayRole) override |
bool | setModelData (const QVariant value, int role) |
void | setPaletteType (PaletteType type) |
void | setSourceModel (QAbstractItemModel *sourceModel) override |
![]() | |
AbstractProxyModel (QObject *parent=nullptr) | |
QModelIndex | index (int row, int col, const QModelIndex &index) const override |
Reimplemented for internal purposes. More... | |
QModelIndex | mapFromSource (const QModelIndex &sourceIndex) const override |
Reimplemented for internal purposes. More... | |
QModelIndex | mapToSource (const QModelIndex &proxyIndex) const override |
Reimplemented for internal purposes. More... | |
QModelIndex | parent (const QModelIndex &index) const override |
Reimplemented for internal purposes. More... | |
A proxy model used for decorating data with attributes.
An AttributesModel forwards data from and to the source model and adds attributes, data that influences the graphical rendering of the source model data. The attributes are distinguished from the source model's data by their @p role values. Therefore this class does not need to, and does not, change the data layout from the source model's; indexes that refer to the same data have the same row and column values in both models. Attribute changes, that is changes to data with the attribute role, via the interface of this class (including setData()) are stored internally and not forwarded to the source model.
Definition at line 34 of file KDChartAttributesModel.h.
Enumerator | |
---|---|
PaletteTypeDefault | |
PaletteTypeRainbow | |
PaletteTypeSubdued |
Definition at line 39 of file KDChartAttributesModel.h.
|
explicit |
Definition at line 61 of file KDChartAttributesModel.cpp.
References KDChart::DataValueLabelAttributesRole, KDChart::DataValueAttributes::defaultAttributesAsVariant(), setDefaultForRole(), and setSourceModel().
|
override |
Definition at line 70 of file KDChartAttributesModel.cpp.
|
signal |
Referenced by setData(), and setHeaderData().
|
override |
Reimplemented for internal purposes.
Definition at line 473 of file KDChartAttributesModel.cpp.
References KDChart::AbstractProxyModel::index(), and KDChart::AbstractProxyModel::mapToSource().
Referenced by KDChart::StockDiagram::calculateDataBoundaries(), KDChart::StockDiagram::paint(), and setHeaderData().
bool AttributesModel::compare | ( | const AttributesModel * | other | ) | const |
Returns true if both, all of the attributes set, and the palette set is equal in both of the AttributeModels.
Definition at line 107 of file KDChartAttributesModel.cpp.
References compareAttributes(), d, and paletteType().
Referenced by KDChart::AbstractDiagram::compare().
bool AttributesModel::compareAttributes | ( | int | role, |
const QVariant & | a, | ||
const QVariant & | b | ||
) | const |
Definition at line 168 of file KDChartAttributesModel.cpp.
References KDChart::BarAttributesRole, KDChart::DataHiddenRole, KDChart::DatasetBrushRole, KDChart::DatasetPenRole, KDChart::DataValueLabelAttributesRole, isKnownAttributesRole(), KDChart::LineAttributesRole, KDChart::PieAttributesRole, KDChart::StockBarAttributesRole, KDChart::ThreeDAttributesRole, KDChart::ThreeDBarAttributesRole, KDChart::ThreeDLineAttributesRole, KDChart::ThreeDPieAttributesRole, and KDChart::ValueTrackerAttributesRole.
Referenced by compare().
|
override |
Reimplemented for internal purposes.
Definition at line 295 of file KDChartAttributesModel.cpp.
References d, data(), KDChart::AbstractProxyModel::index(), and KDChart::AbstractProxyModel::mapToSource().
QVariant AttributesModel::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().
Definition at line 280 of file KDChartAttributesModel.cpp.
References data(), headerData(), and isKnownAttributesRole().
QVariant AttributesModel::data | ( | int | role | ) | const |
Returns the data that were specified at global level, or the default data, or QVariant().
Definition at line 266 of file KDChartAttributesModel.cpp.
References isKnownAttributesRole(), and modelData().
Referenced by KDChart::AbstractDiagram::brush(), data(), KDChart::AbstractDiagram::dataValueAttributes(), and KDChart::AbstractDiagram::pen().
int AttributesModel::datasetDimension | ( | ) | const |
Definition at line 672 of file KDChartAttributesModel.cpp.
References d.
|
virtual |
Returns default values for the header data.
Definition at line 241 of file KDChartAttributesModel.cpp.
References d, KDChart::DatasetBrushRole, KDChart::DatasetPenRole, headerData(), and modelData().
Referenced by headerData().
|
override |
Reimplemented for internal purposes.
Definition at line 217 of file KDChartAttributesModel.cpp.
References d, and defaultHeaderData().
Referenced by data(), defaultHeaderData(), KDChart::AbstractDiagram::itemRowLabels(), and setHeaderData().
void AttributesModel::initFrom | ( | const AttributesModel * | other | ) |
Copies the internal data (maps and palette) of another AttributesModel* into this one.
Definition at line 76 of file KDChartAttributesModel.cpp.
References d.
Referenced by KDChart::AbstractDiagram::setModel().
bool AttributesModel::isKnownAttributesRole | ( | int | role | ) | const |
Returns whether the given role corresponds to one of the known internally used ones.
Definition at line 332 of file KDChartAttributesModel.cpp.
References KDChart::BarAttributesRole, KDChart::DataHiddenRole, KDChart::DatasetBrushRole, KDChart::DatasetPenRole, KDChart::DataValueLabelAttributesRole, KDChart::LineAttributesRole, KDChart::PieAttributesRole, KDChart::StockBarAttributesRole, KDChart::ThreeDAttributesRole, KDChart::ThreeDBarAttributesRole, KDChart::ThreeDLineAttributesRole, KDChart::ThreeDPieAttributesRole, and KDChart::ValueTrackerAttributesRole.
Referenced by compareAttributes(), data(), setData(), and setHeaderData().
QVariant KDChart::AttributesModel::modelData | ( | int | role | ) | const |
Definition at line 459 of file KDChartAttributesModel.cpp.
References d.
Referenced by data(), KDChart::AbstractDiagram::dataValueAttributes(), defaultHeaderData(), KDChart::AbstractDiagram::isHidden(), KDChart::StockDiagram::stockBarAttributes(), and KDChart::StockDiagram::threeDBarAttributes().
AttributesModel::PaletteType AttributesModel::paletteType | ( | ) | const |
bool AttributesModel::resetData | ( | const QModelIndex & | index, |
int | role = Qt::DisplayRole |
||
) |
Remove any explicit attributes settings that might have been specified before.
Definition at line 374 of file KDChartAttributesModel.cpp.
References KDChart::AbstractProxyModel::index(), and setData().
bool AttributesModel::resetHeaderData | ( | int | section, |
Qt::Orientation | orientation, | ||
int | role = Qt::DisplayRole |
||
) |
Remove any explicit attributes settings that might have been specified before.
Definition at line 414 of file KDChartAttributesModel.cpp.
References setHeaderData().
|
override |
Reimplemented for internal purposes.
Definition at line 464 of file KDChartAttributesModel.cpp.
References KDChart::AbstractProxyModel::index(), and KDChart::AbstractProxyModel::mapToSource().
Referenced by KDChart::StockDiagram::calculateDataBoundaries(), KDChart::AbstractDiagram::itemRowLabels(), KDChart::StockDiagram::paint(), and setHeaderData().
|
override |
Reimplemented for internal purposes.
Definition at line 361 of file KDChartAttributesModel.cpp.
References attributesChanged(), d, KDChart::AbstractProxyModel::index(), isKnownAttributesRole(), and KDChart::AbstractProxyModel::mapToSource().
Referenced by resetData(), KDChart::BarDiagram::setBarAttributes(), KDChart::AbstractDiagram::setBrush(), and KDChart::AbstractDiagram::setPen().
void AttributesModel::setDatasetDimension | ( | int | dimension | ) |
Set the dimension of the dataset in the source model.
Definition at line 666 of file KDChartAttributesModel.cpp.
References d.
void AttributesModel::setDefaultForRole | ( | int | role, |
const QVariant & | value | ||
) |
Define the default value for a certain role. Passing a default-constructed QVariant is equivalent to removing the default.
Definition at line 651 of file KDChartAttributesModel.cpp.
References d.
Referenced by AttributesModel(), and KDChart::TernaryLineDiagram::TernaryLineDiagram().
|
override |
Reimplemented for internal purposes.
Definition at line 379 of file KDChartAttributesModel.cpp.
References attributesChanged(), columnCount(), d, headerData(), KDChart::AbstractProxyModel::index(), isKnownAttributesRole(), and rowCount().
Referenced by resetHeaderData().
bool KDChart::AttributesModel::setModelData | ( | const QVariant | value, |
int | role | ||
) |
Definition at line 445 of file KDChartAttributesModel.cpp.
References d.
Referenced by KDChart::AbstractDiagram::setBrush(), KDChart::AbstractDiagram::setPen(), KDChart::StockDiagram::setStockBarAttributes(), and KDChart::StockDiagram::setThreeDBarAttributes().
void AttributesModel::setPaletteType | ( | AttributesModel::PaletteType | type | ) |
Sets the palettetype used by this attributesmodel
Definition at line 419 of file KDChartAttributesModel.cpp.
References d, KDChart::Palette::defaultPalette(), PaletteTypeDefault, PaletteTypeRainbow, PaletteTypeSubdued, KDChart::Palette::rainbowPalette(), and KDChart::Palette::subduedPalette().
|
override |
Reimplemented for internal purposes.
Definition at line 482 of file KDChartAttributesModel.cpp.
Referenced by AttributesModel().