KD Chart 2  [rev.2.5]
KDChartAttributesModel.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB.  All rights reserved.
00003 **
00004 ** This file is part of the KD Chart library.
00005 **
00006 ** Licensees holding valid commercial KD Chart licenses may use this file in
00007 ** accordance with the KD Chart Commercial License Agreement provided with
00008 ** the Software.
00009 **
00010 **
00011 ** This file may be distributed and/or modified under the terms of the
00012 ** GNU General Public License version 2 and version 3 as published by the
00013 ** Free Software Foundation and appearing in the file LICENSE.GPL.txt included.
00014 **
00015 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00016 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00017 **
00018 ** Contact info@kdab.com if any conditions of this licensing are not
00019 ** clear to you.
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 
00046 class KDCHART_EXPORT AttributesModel : public AbstractProxyModel
00047 {
00048     Q_OBJECT
00049     KDCHART_DECLARE_PRIVATE_BASE_POLYMORPHIC( AttributesModel )
00050 public:
00051     enum PaletteType {
00052         PaletteTypeDefault = 0,
00053         PaletteTypeRainbow = 1,
00054         PaletteTypeSubdued = 2
00055     };
00056 
00057     explicit AttributesModel( QAbstractItemModel* model, QObject * parent = 0 );
00058     ~AttributesModel();
00059 
00063     void initFrom( const AttributesModel* other );
00064 
00068     bool compare( const AttributesModel* other ) const;
00069 
00070     bool compareAttributes( int role, const QVariant& a, const QVariant& b ) const;
00071 
00072     /* Attributes Model specific API */
00073     bool setModelData( const QVariant value, int role );
00074     QVariant modelData( int role ) const;
00075 
00078     bool isKnownAttributesRole( int role ) const;
00079 
00081     void setPaletteType( PaletteType type );
00082     PaletteType paletteType() const;
00083 
00087     QVariant data(int role) const;
00088 
00092     QVariant data(int column, int role) const;
00093 
00095     QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
00097     int rowCount(const QModelIndex& ) const;
00099     int columnCount(const QModelIndex& ) const;
00101     QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const;
00103     bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::DisplayRole);
00105     bool resetData ( const QModelIndex & index, int role = Qt::DisplayRole);
00107     bool setHeaderData ( int section, Qt::Orientation orientation, const QVariant & value,
00108                          int role = Qt::DisplayRole);
00110     virtual QVariant defaultHeaderData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
00112     bool resetHeaderData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole);
00114     void setSourceModel ( QAbstractItemModel* sourceModel );
00115 
00118     void setDefaultForRole( int role, const QVariant& value );
00119 
00121     void setDatasetDimension( int dimension );
00122     int datasetDimension() const;
00123 
00124 Q_SIGNALS:
00125     void attributesChanged( const QModelIndex&, const QModelIndex& );
00126 
00127 private Q_SLOTS:
00128     void slotRowsAboutToBeInserted( const QModelIndex& parent, int start, int end );
00129     void slotColumnsAboutToBeInserted( const QModelIndex& parent, int start, int end );
00130     void slotRowsInserted( const QModelIndex& parent, int start, int end );
00131     void slotColumnsInserted( const QModelIndex& parent, int start, int end );
00132 
00133     void slotRowsAboutToBeRemoved( const QModelIndex& parent, int start, int end );
00134     void slotColumnsAboutToBeRemoved( const QModelIndex& parent, int start, int end );
00135     void slotRowsRemoved( const QModelIndex& parent, int start, int end );
00136     void slotColumnsRemoved( const QModelIndex& parent, int start, int end );
00137 
00138     void slotDataChanged( const QModelIndex& topLeft, const QModelIndex& bottomRight );
00139 
00140 private:
00141     // helper
00142     QVariant defaultsForRole( int role ) const;
00143     bool compareHeaderDataMaps( const QMap< int, QMap< int, QVariant > >& mapA,
00144                                 const QMap< int, QMap< int, QVariant > >& mapB ) const;
00145 
00146     void removeEntriesFromDataMap( int start, int end );
00147     void removeEntriesFromDirectionDataMaps( Qt::Orientation dir, int start, int end );
00148 };
00149 
00150 }
00151 
00152 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Defines

Klarälvdalens Datakonsult AB (KDAB)
Qt-related services and products
http://www.kdab.com/
http://www.kdab.com/products/kd-chart/