KD Chart API Documentation  3.1
Public Slots | Public Member Functions | Protected Member Functions | List of all members
KDChart::DatasetProxyModel Class Reference

#include <KDChartDatasetProxyModel.h>

Inheritance diagram for KDChart::DatasetProxyModel:

Public Slots

void resetDatasetDescriptions ()
 
void setDatasetColumnDescriptionVector (const DatasetDescriptionVector &columnConfig)
 
void setDatasetDescriptionVectors (const DatasetDescriptionVector &rowConfig, const DatasetDescriptionVector &columnConfig)
 
void setDatasetRowDescriptionVector (const DatasetDescriptionVector &rowConfig)
 

Public Member Functions

 DatasetProxyModel (QObject *parent=nullptr)
 
QModelIndex buddy (const QModelIndex &index) const override
 
QVariant data (const QModelIndex &index, int role) const override
 
Qt::ItemFlags flags (const QModelIndex &index) const override
 
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
 
QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const override
 
QModelIndex mapFromSource (const QModelIndex &sourceIndex) const override
 
QModelIndex mapToSource (const QModelIndex &proxyIndex) const override
 
QModelIndex parent (const QModelIndex &child) const override
 
bool setData (const QModelIndex &index, const QVariant &value, int role) override
 
void setSourceModel (QAbstractItemModel *sourceModel) override
 
void setSourceRootIndex (const QModelIndex &rootIdx)
 

Protected Member Functions

bool filterAcceptsColumn (int sourceColumn, const QModelIndex &) const override
 
bool filterAcceptsRow (int source_row, const QModelIndex &source_parent) const override
 

Detailed Description

DatasetProxyModel takes a KDChart dataset configuration and translates it into a filtering proxy model.

The resulting model will only contain the part of the model that is selected by the dataset, and the according row and column header data.

Currently, this model is implemented for table models only. The way it would work with models representing a tree is to be decided.

The column selection is configured by passing a dataset description vector to the model. This vector (of integers) is supposed to have one value for each column of the original model. If the value at position x is -1, column x of the original model is not included in the dataset. If it is between 0 and (columnCount() -1), it is the column the source column is mapped to in the resulting model. Any other value is an error.

Definition at line 43 of file KDChartDatasetProxyModel.h.

Constructor & Destructor Documentation

◆ DatasetProxyModel()

DatasetProxyModel::DatasetProxyModel ( QObject *  parent = nullptr)
explicit

Create a DatasetProxyModel. Without further configuration, this model is invalid.

See also
setDatasetDescriptionVector

Definition at line 19 of file KDChartDatasetProxyModel.cpp.

Member Function Documentation

◆ buddy()

QModelIndex DatasetProxyModel::buddy ( const QModelIndex &  index) const
override

Definition at line 24 of file KDChartDatasetProxyModel.cpp.

References index().

◆ data()

QVariant DatasetProxyModel::data ( const QModelIndex &  index,
int  role 
) const
override

Overloaded from base class.

Definition at line 195 of file KDChartDatasetProxyModel.cpp.

References index(), and mapToSource().

◆ filterAcceptsColumn()

bool DatasetProxyModel::filterAcceptsColumn ( int  sourceColumn,
const QModelIndex &   
) const
overrideprotected

Decide whether the column is accepted.

Definition at line 128 of file KDChartDatasetProxyModel.cpp.

◆ filterAcceptsRow()

bool DatasetProxyModel::filterAcceptsRow ( int  source_row,
const QModelIndex &  source_parent 
) const
overrideprotected

Decide whether the row is accepted.

Definition at line 110 of file KDChartDatasetProxyModel.cpp.

◆ flags()

Qt::ItemFlags DatasetProxyModel::flags ( const QModelIndex &  index) const
override

Definition at line 29 of file KDChartDatasetProxyModel.cpp.

References index(), and mapToSource().

◆ headerData()

QVariant DatasetProxyModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const
override

Overloaded from base class.

Definition at line 205 of file KDChartDatasetProxyModel.cpp.

◆ index()

QModelIndex DatasetProxyModel::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const
override

Definition at line 62 of file KDChartDatasetProxyModel.cpp.

References mapFromSource(), and parent().

Referenced by buddy(), data(), flags(), and setData().

◆ mapFromSource()

QModelIndex DatasetProxyModel::mapFromSource ( const QModelIndex &  sourceIndex) const
override

Implements the mapping from the source to the proxy indexes.

Definition at line 76 of file KDChartDatasetProxyModel.cpp.

Referenced by index(), and parent().

◆ mapToSource()

QModelIndex DatasetProxyModel::mapToSource ( const QModelIndex &  proxyIndex) const
override

Implements the mapping from the proxy to the source indexes.

Definition at line 94 of file KDChartDatasetProxyModel.cpp.

Referenced by data(), flags(), parent(), and setData().

◆ parent()

QModelIndex DatasetProxyModel::parent ( const QModelIndex &  child) const
override

Definition at line 70 of file KDChartDatasetProxyModel.cpp.

References mapFromSource(), and mapToSource().

Referenced by index().

◆ resetDatasetDescriptions

void DatasetProxyModel::resetDatasetDescriptions ( )
slot

Reset all dataset description. After that, the result of the proxying is an empty model (a new dataset description needs to be set to achieve a non-empty result).

Definition at line 186 of file KDChartDatasetProxyModel.cpp.

Referenced by setSourceModel(), and setSourceRootIndex().

◆ setData()

bool DatasetProxyModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role 
)
override

Overloaded from base class.

Definition at line 200 of file KDChartDatasetProxyModel.cpp.

References index(), and mapToSource().

◆ setDatasetColumnDescriptionVector

void DatasetProxyModel::setDatasetColumnDescriptionVector ( const DatasetDescriptionVector columnConfig)
slot

Configure the dataset selection for the columns. Every call to this method resets the previous dataset description.

Definition at line 44 of file KDChartDatasetProxyModel.cpp.

Referenced by setDatasetDescriptionVectors().

◆ setDatasetDescriptionVectors

void DatasetProxyModel::setDatasetDescriptionVectors ( const DatasetDescriptionVector rowConfig,
const DatasetDescriptionVector columnConfig 
)
slot

Convenience method to configure rows and columns in one step.

Definition at line 54 of file KDChartDatasetProxyModel.cpp.

References setDatasetColumnDescriptionVector(), and setDatasetRowDescriptionVector().

◆ setDatasetRowDescriptionVector

void DatasetProxyModel::setDatasetRowDescriptionVector ( const DatasetDescriptionVector rowConfig)
slot

Configure the dataset selection for the rows. Every call to this method resets the previous dataset description.

Definition at line 34 of file KDChartDatasetProxyModel.cpp.

Referenced by setDatasetDescriptionVectors().

◆ setSourceModel()

void DatasetProxyModel::setSourceModel ( QAbstractItemModel *  sourceModel)
override

Overloaded from base class.

Definition at line 252 of file KDChartDatasetProxyModel.cpp.

References resetDatasetDescriptions().

◆ setSourceRootIndex()

void DatasetProxyModel::setSourceRootIndex ( const QModelIndex &  rootIdx)

Set the root index of the table in the source model

Definition at line 268 of file KDChartDatasetProxyModel.cpp.

References resetDatasetDescriptions().


The documentation for this class was generated from the following files:

© 2001 Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
https://www.kdab.com/development-resources/qt-tools/kd-chart/
Generated by doxygen 1.9.1