00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef KDCHARTDATASETPROXYMODEL_H
00027 #define KDCHARTDATASETPROXYMODEL_H
00028
00029 #include <QVector>
00030 #include <QSortFilterProxyModel>
00031
00032 #include "kdchart_export.h"
00033
00034 namespace KDChart {
00035
00036 class IndexOutOfBoundsException;
00037
00038 typedef QVector<int> DatasetDescriptionVector;
00039
00058 class KDCHART_EXPORT DatasetProxyModel : public QSortFilterProxyModel
00059 {
00060 Q_OBJECT
00061 public:
00066 explicit DatasetProxyModel ( QObject* parent = 0 );
00067
00068 QModelIndex index( int row, int column,
00069 const QModelIndex &parent = QModelIndex() ) const;
00070 QModelIndex parent(const QModelIndex &child ) const;
00071
00073 QModelIndex mapFromSource ( const QModelIndex & sourceIndex ) const;
00074
00076 QModelIndex mapToSource ( const QModelIndex& proxyIndex ) const;
00077
00079 QVariant data(const QModelIndex &index, int role) const;
00080
00082 QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
00083
00085 void setSourceModel(QAbstractItemModel *sourceModel);
00086
00089 void setSourceRootIndex(const QModelIndex& rootIdx);
00090
00091
00092 public Q_SLOTS:
00097 void resetDatasetDescriptions();
00098
00103 void setDatasetColumnDescriptionVector ( const DatasetDescriptionVector& columnConfig );
00104
00109 void setDatasetRowDescriptionVector ( const DatasetDescriptionVector& rowConfig );
00110
00112 void setDatasetDescriptionVectors (
00113 const DatasetDescriptionVector& rowConfig,
00114 const DatasetDescriptionVector& columnConfig );
00115
00116
00117
00118
00119 protected:
00121 bool filterAcceptsColumn ( int sourceColumn,
00122 const QModelIndex & ) const;
00123
00124
00126 bool filterAcceptsRow ( int source_row, const QModelIndex & source_parent ) const;
00127
00128 private:
00129
00131 int mapProxyColumnToSource ( const int& proxyColumn ) const;
00132
00134 int mapSourceColumnToProxy ( const int& sourceColumn ) const;
00135
00137 int mapProxyRowToSource ( const int& proxyRow ) const;
00138
00140 int mapSourceRowToProxy ( const int& sourceRow ) const;
00141
00165 void initializeDatasetDecriptors (
00166 const DatasetDescriptionVector& inConfiguration,
00167 int sourceCount,
00168 DatasetDescriptionVector& outSourceToProxyMap,
00169 DatasetDescriptionVector& outProxyToSourceMap );
00170
00171 DatasetDescriptionVector mColSrcToProxyMap;
00172 DatasetDescriptionVector mColProxyToSrcMap;
00173 DatasetDescriptionVector mRowSrcToProxyMap;
00174 DatasetDescriptionVector mRowProxyToSrcMap;
00175
00176 int mProxyRowCount;
00177 int mProxyColumnCount;
00178 QModelIndex mRootIndex;
00179 };
00180
00181 }
00182
00183
00184 #endif