Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

KDChartAttributesModel.h

Go to the documentation of this file.
00001 /* -*- Mode: C++ -*-
00002    KDChart - a multi-platform charting engine
00003    */
00004 
00005 /****************************************************************************
00006  ** Copyright (C) 2001-2006 Klarälvdalens Datakonsult AB.  All rights reserved.
00007  **
00008  ** This file is part of the KD Chart library.
00009  **
00010  ** This file may be distributed and/or modified under the terms of the
00011  ** GNU General Public License version 2 as published by the Free Software
00012  ** Foundation and appearing in the file LICENSE.GPL included in the
00013  ** packaging of this file.
00014  **
00015  ** Licensees holding valid commercial KD Chart licenses may use this file in
00016  ** accordance with the KD Chart Commercial License Agreement provided with
00017  ** the Software.
00018  **
00019  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00020  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00021  **
00022  ** See http://www.kdab.net/kdchart for
00023  **   information about KD Chart Commercial License Agreements.
00024  **
00025  ** Contact info@kdab.net if any conditions of this
00026  ** licensing are not clear to you.
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 
00040 class KDCHART_EXPORT AttributesModel : public AbstractProxyModel
00041 {
00042     Q_OBJECT
00043 
00044     friend class AttributesModelSerializer;
00045 
00046 public:
00047     enum PaletteType {
00048         PaletteTypeDefault = 0,
00049         PaletteTypeRainbow = 1,
00050         PaletteTypeSubdued = 2
00051     };
00052 
00053     explicit AttributesModel( QAbstractItemModel* model, QObject * parent = 0 );
00054     ~AttributesModel();
00055 
00056     /* Copies the internal data (maps and palette) of another
00057        AttributesModel* into this one.
00058     */
00059     void initFrom( const AttributesModel* other );
00060 
00061     /* Returns true if both, all of the attributes set, and
00062      * the palette set is equal in both of the AttributeModels.
00063     */
00064     bool compare( const AttributesModel* other )const;
00065 
00066     bool compareAttributes( int role, const QVariant& a, const QVariant& b )const;
00067 
00068     /* Attributes Model specific API */
00069     bool setModelData( const QVariant value, int role );
00070     QVariant modelData( int role ) const;
00071 
00074     bool isKnownAttributesRole( int role ) const;
00075 
00077     void setPaletteType( PaletteType type );
00078     PaletteType paletteType() const;
00079 
00083     QVariant data(int role) const;
00084 
00088     QVariant data(int column, int role) const;
00089 
00091     QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
00093     int rowCount(const QModelIndex& ) const;
00095     int columnCount(const QModelIndex& ) const;
00097     QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const;
00099     bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::DisplayRole);
00101     bool resetData ( const QModelIndex & index, int role = Qt::DisplayRole);
00103     bool setHeaderData ( int section, Qt::Orientation orientation, const QVariant & value,
00104                          int role = Qt::DisplayRole);
00106     bool resetHeaderData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole);
00108     void setSourceModel ( QAbstractItemModel* sourceModel );
00109 
00110 Q_SIGNALS:
00111     void attributesChanged( const QModelIndex&, const QModelIndex& );
00112 
00113 protected:
00115     const QMap<int, QMap<int, QMap<int, QVariant> > > dataMap()const;
00117     const QMap<int, QMap<int, QVariant> > horizontalHeaderDataMap()const;
00119     const QMap<int, QMap<int, QVariant> > verticalHeaderDataMap()const;
00121     const QMap<int, QVariant> modelDataMap()const;
00123     void setDataMap( const QMap<int, QMap<int, QMap<int, QVariant> > > map );
00125     void setHorizontalHeaderDataMap( const QMap<int, QMap<int, QVariant> > map );
00127     void setVerticalHeaderDataMap( const QMap<int, QMap<int, QVariant> > map );
00129     void setModelDataMap( const QMap<int, QVariant> map );
00130 
00131 private:
00132     // helper
00133     QVariant defaultsForRole( int role ) const;
00134 
00135     QMap<int, QMap<int, QMap<int, QVariant> > > mDataMap;
00136     QMap<int, QMap<int, QVariant> > mHorizontalHeaderDataMap;
00137     QMap<int, QMap<int, QVariant> > mVerticalHeaderDataMap;
00138     QMap<int, QVariant> mModelDataMap;
00139     PaletteType mPaletteType;
00140 };
00141 
00142 }
00143 
00144 #endif

Generated on Thu May 10 11:06:24 2007 for KD Chart 2 by doxygen 1.3.6