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
00027
00028
00029 #ifndef __KDCHART_ATTRIBUTES_MODEL_H__
00030 #define __KDCHART_ATTRIBUTES_MODEL_H__
00031
00032 #include "KDChartAbstractProxyModel.h"
00033 #include <QMap>
00034 #include <QVariant>
00035
00036 #include "KDChartGlobal.h"
00037
00038 namespace KDChart {
00039
00043 class KDCHART_EXPORT AttributesModel : public AbstractProxyModel
00044 {
00045 Q_OBJECT
00046
00047 friend class AttributesModelSerializer;
00048
00049 public:
00050 enum PaletteType {
00051 PaletteTypeDefault = 0,
00052 PaletteTypeRainbow = 1,
00053 PaletteTypeSubdued = 2
00054 };
00055
00056 explicit AttributesModel( QAbstractItemModel* model, QObject * parent = 0 );
00057 ~AttributesModel();
00058
00059
00060
00061
00062 void initFrom( const AttributesModel* other );
00063
00064
00065
00066
00067 bool compare( const AttributesModel* other )const;
00068
00069 bool compareAttributes( int role, const QVariant& a, const QVariant& b )const;
00070
00071
00072 bool setModelData( const QVariant value, int role );
00073 QVariant modelData( int role ) const;
00074
00077 bool isKnownAttributesRole( int role ) const;
00078
00080 void setPaletteType( PaletteType type );
00081 PaletteType paletteType() const;
00082
00086 QVariant data(int role) const;
00087
00091 QVariant data(int column, int role) const;
00092
00094 QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
00096 int rowCount(const QModelIndex& ) const;
00098 int columnCount(const QModelIndex& ) const;
00100 QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const;
00102 bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::DisplayRole);
00104 bool resetData ( const QModelIndex & index, int role = Qt::DisplayRole);
00106 bool setHeaderData ( int section, Qt::Orientation orientation, const QVariant & value,
00107 int role = Qt::DisplayRole);
00109 bool resetHeaderData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole);
00111 void setSourceModel ( QAbstractItemModel* sourceModel );
00112
00115 void setDefaultForRole( int role, const QVariant& value );
00116
00117 Q_SIGNALS:
00118 void attributesChanged( const QModelIndex&, const QModelIndex& );
00119
00120 protected:
00122 const QMap<int, QMap<int, QMap<int, QVariant> > > dataMap()const;
00124 const QMap<int, QMap<int, QVariant> > horizontalHeaderDataMap()const;
00126 const QMap<int, QMap<int, QVariant> > verticalHeaderDataMap()const;
00128 const QMap<int, QVariant> modelDataMap()const;
00130 void setDataMap( const QMap<int, QMap<int, QMap<int, QVariant> > > map );
00132 void setHorizontalHeaderDataMap( const QMap<int, QMap<int, QVariant> > map );
00134 void setVerticalHeaderDataMap( const QMap<int, QMap<int, QVariant> > map );
00136 void setModelDataMap( const QMap<int, QVariant> map );
00137
00138 private Q_SLOTS:
00139 void slotRowsAboutToBeInserted( const QModelIndex& parent, int start, int end );
00140 void slotColumnsAboutToBeInserted( const QModelIndex& parent, int start, int end );
00141 void slotRowsInserted( const QModelIndex& parent, int start, int end );
00142 void slotColumnsInserted( const QModelIndex& parent, int start, int end );
00143
00144 void slotRowsAboutToBeRemoved( const QModelIndex& parent, int start, int end );
00145 void slotColumnsAboutToBeRemoved( const QModelIndex& parent, int start, int end );
00146 void slotRowsRemoved( const QModelIndex& parent, int start, int end );
00147 void slotColumnsRemoved( const QModelIndex& parent, int start, int end );
00148
00149 void slotDataChanged( const QModelIndex& topLeft, const QModelIndex& bottomRight );
00150
00151 private:
00152
00153 QVariant defaultsForRole( int role ) const;
00154
00155 QMap<int, QMap<int, QMap<int, QVariant> > > mDataMap;
00156 QMap<int, QMap<int, QVariant> > mHorizontalHeaderDataMap;
00157 QMap<int, QMap<int, QVariant> > mVerticalHeaderDataMap;
00158 QMap<int, QVariant> mModelDataMap;
00159 QMap<int, QVariant> mDefaultsMap;
00160 PaletteType mPaletteType;
00161 };
00162
00163 }
00164
00165 #endif