00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __KDCHART_ATTRIBUTES_MODEL_H__
00024 #define __KDCHART_ATTRIBUTES_MODEL_H__
00025
00026 #include "KDChartAbstractProxyModel.h"
00027 #include <QMap>
00028 #include <QVariant>
00029
00030 #include "KDChartGlobal.h"
00031
00032 namespace KDChart {
00033
00037 class KDCHART_EXPORT AttributesModel : public AbstractProxyModel
00038 {
00039 Q_OBJECT
00040
00041 friend class AttributesModelSerializer;
00042
00043 public:
00044 enum PaletteType {
00045 PaletteTypeDefault = 0,
00046 PaletteTypeRainbow = 1,
00047 PaletteTypeSubdued = 2
00048 };
00049
00050 explicit AttributesModel( QAbstractItemModel* model, QObject * parent = 0 );
00051 ~AttributesModel();
00052
00056 void initFrom( const AttributesModel* other );
00057
00061 bool compare( const AttributesModel* other )const;
00062
00063 bool compareAttributes( int role, const QVariant& a, const QVariant& b )const;
00064
00065
00066 bool setModelData( const QVariant value, int role );
00067 QVariant modelData( int role ) const;
00068
00071 bool isKnownAttributesRole( int role ) const;
00072
00074 void setPaletteType( PaletteType type );
00075 PaletteType paletteType() const;
00076
00080 QVariant data(int role) const;
00081
00085 QVariant data(int column, int role) const;
00086
00088 QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
00090 int rowCount(const QModelIndex& ) const;
00092 int columnCount(const QModelIndex& ) const;
00094 QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const;
00096 bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::DisplayRole);
00098 bool resetData ( const QModelIndex & index, int role = Qt::DisplayRole);
00100 bool setHeaderData ( int section, Qt::Orientation orientation, const QVariant & value,
00101 int role = Qt::DisplayRole);
00103 virtual QVariant defaultHeaderData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
00105 bool resetHeaderData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole);
00107 void setSourceModel ( QAbstractItemModel* sourceModel );
00108
00111 void setDefaultForRole( int role, const QVariant& value );
00112
00113 Q_SIGNALS:
00114 void attributesChanged( const QModelIndex&, const QModelIndex& );
00115
00116 protected:
00118 const QMap<int, QMap<int, QMap<int, QVariant> > > dataMap()const;
00120 const QMap<int, QMap<int, QVariant> > horizontalHeaderDataMap()const;
00122 const QMap<int, QMap<int, QVariant> > verticalHeaderDataMap()const;
00124 const QMap<int, QVariant> modelDataMap()const;
00126 void setDataMap( const QMap<int, QMap<int, QMap<int, QVariant> > > map );
00128 void setHorizontalHeaderDataMap( const QMap<int, QMap<int, QVariant> > map );
00130 void setVerticalHeaderDataMap( const QMap<int, QMap<int, QVariant> > map );
00132 void setModelDataMap( const QMap<int, QVariant> map );
00133
00134 private Q_SLOTS:
00135 void slotRowsAboutToBeInserted( const QModelIndex& parent, int start, int end );
00136 void slotColumnsAboutToBeInserted( const QModelIndex& parent, int start, int end );
00137 void slotRowsInserted( const QModelIndex& parent, int start, int end );
00138 void slotColumnsInserted( const QModelIndex& parent, int start, int end );
00139
00140 void slotRowsAboutToBeRemoved( const QModelIndex& parent, int start, int end );
00141 void slotColumnsAboutToBeRemoved( const QModelIndex& parent, int start, int end );
00142 void slotRowsRemoved( const QModelIndex& parent, int start, int end );
00143 void slotColumnsRemoved( const QModelIndex& parent, int start, int end );
00144
00145 void slotDataChanged( const QModelIndex& topLeft, const QModelIndex& bottomRight );
00146
00147 private:
00148
00149 QVariant defaultsForRole( int role ) const;
00150
00151 QMap<int, QMap<int, QMap<int, QVariant> > > mDataMap;
00152 QMap<int, QMap<int, QVariant> > mHorizontalHeaderDataMap;
00153 QMap<int, QMap<int, QVariant> > mVerticalHeaderDataMap;
00154 QMap<int, QVariant> mModelDataMap;
00155 QMap<int, QVariant> mDefaultsMap;
00156 PaletteType mPaletteType;
00157 };
00158
00159 }
00160
00161 #endif