Public Slots | Public Member Functions | Protected Member Functions

KDChart::DatasetProxyModel Class Reference

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

#include <KDChartDatasetProxyModel.h>

Inheritance diagram for KDChart::DatasetProxyModel:
Inheritance graph
[legend]
Collaboration diagram for KDChart::DatasetProxyModel:
Collaboration graph
[legend]

List of all members.

Public Slots

void resetDatasetDescriptions ()
 Reset all dataset description.
void setDatasetColumnDescriptionVector (const DatasetDescriptionVector &columnConfig)
 Configure the dataset selection for the columns.
void setDatasetDescriptionVectors (const DatasetDescriptionVector &rowConfig, const DatasetDescriptionVector &columnConfig)
 Convenience method to configure rows and columns in one step.
void setDatasetRowDescriptionVector (const DatasetDescriptionVector &rowConfig)
 Configure the dataset selection for the rows.

Public Member Functions

QModelIndex buddy (const QModelIndex &index) const
QVariant data (const QModelIndex &index, int role) const
 Overloaded from base class.
 DatasetProxyModel (QObject *parent=0)
 Create a DatasetProxyModel.
Qt::ItemFlags flags (const QModelIndex &index) const
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
 Overloaded from base class.
QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const
QModelIndex mapFromSource (const QModelIndex &sourceIndex) const
 Implements the mapping from the source to the proxy indexes.
QModelIndex mapToSource (const QModelIndex &proxyIndex) const
 Implements the mapping from the proxy to the source indexes.
QModelIndex parent (const QModelIndex &child) const
bool setData (const QModelIndex &index, const QVariant &value, int role)
 Overloaded from base class.
void setSourceModel (QAbstractItemModel *sourceModel)
 Overloaded from base class.
void setSourceRootIndex (const QModelIndex &rootIdx)
 Set the root index of the table in the source model.

Protected Member Functions

bool filterAcceptsColumn (int sourceColumn, const QModelIndex &) const
 Decide whether the column is accepted.
bool filterAcceptsRow (int source_row, const QModelIndex &source_parent) const
 Decide whether the row is accepted.

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 55 of file KDChartDatasetProxyModel.h.


Constructor & Destructor Documentation

DatasetProxyModel::DatasetProxyModel ( QObject parent = 0  )  [explicit]

Create a DatasetProxyModel.

Without further configuration, this model is invalid.

See also:
setDatasetDescriptionVector

Definition at line 32 of file KDChartDatasetProxyModel.cpp.


Member Function Documentation

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

Definition at line 37 of file KDChartDatasetProxyModel.cpp.

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

Overloaded from base class.

Definition at line 216 of file KDChartDatasetProxyModel.cpp.

References mapToSource().

bool DatasetProxyModel::filterAcceptsColumn ( int  sourceColumn,
const QModelIndex &   
) const [protected]

Decide whether the column is accepted.

Definition at line 143 of file KDChartDatasetProxyModel.cpp.

bool DatasetProxyModel::filterAcceptsRow ( int  source_row,
const QModelIndex &  source_parent 
) const [protected]

Decide whether the row is accepted.

Definition at line 123 of file KDChartDatasetProxyModel.cpp.

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

Definition at line 42 of file KDChartDatasetProxyModel.cpp.

References mapToSource().

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

Overloaded from base class.

Definition at line 226 of file KDChartDatasetProxyModel.cpp.

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

Definition at line 75 of file KDChartDatasetProxyModel.cpp.

References mapFromSource().

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

Implements the mapping from the source to the proxy indexes.

Definition at line 89 of file KDChartDatasetProxyModel.cpp.

Referenced by index(), and parent().

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

Implements the mapping from the proxy to the source indexes.

Definition at line 107 of file KDChartDatasetProxyModel.cpp.

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

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

Definition at line 83 of file KDChartDatasetProxyModel.cpp.

References mapFromSource(), and mapToSource().

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 207 of file KDChartDatasetProxyModel.cpp.

Referenced by setSourceModel(), and setSourceRootIndex().

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

Overloaded from base class.

Definition at line 221 of file KDChartDatasetProxyModel.cpp.

References mapToSource().

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 57 of file KDChartDatasetProxyModel.cpp.

Referenced by setDatasetDescriptionVectors().

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

Convenience method to configure rows and columns in one step.

Definition at line 67 of file KDChartDatasetProxyModel.cpp.

References setDatasetColumnDescriptionVector(), and 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 47 of file KDChartDatasetProxyModel.cpp.

Referenced by setDatasetDescriptionVectors().

void DatasetProxyModel::setSourceModel ( QAbstractItemModel *  sourceModel  ) 

Overloaded from base class.

Definition at line 280 of file KDChartDatasetProxyModel.cpp.

References resetDatasetDescriptions().

void DatasetProxyModel::setSourceRootIndex ( const QModelIndex &  rootIdx  ) 

Set the root index of the table in the source model.

Definition at line 295 of file KDChartDatasetProxyModel.cpp.

References resetDatasetDescriptions().


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