KD Chart API Documentation  3.1
KDChartAttributesModel.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** This file is part of the KD Chart library.
4 **
5 ** SPDX-FileCopyrightText: 2001 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6 **
7 ** SPDX-License-Identifier: MIT
8 **
9 ****************************************************************************/
10 
11 #ifndef __KDCHART_ATTRIBUTES_MODEL_H__
12 #define __KDCHART_ATTRIBUTES_MODEL_H__
13 
15 #include <QMap>
16 #include <QVariant>
17 
18 #include "KDChartGlobal.h"
19 
20 namespace KDChart {
21 
34 class KDCHART_EXPORT AttributesModel : public AbstractProxyModel
35 {
36  Q_OBJECT
38 public:
40  {
41  PaletteTypeDefault = 0,
42  PaletteTypeRainbow = 1,
43  PaletteTypeSubdued = 2
44  };
45 
46  explicit AttributesModel(QAbstractItemModel *model, QObject *parent = nullptr);
47  ~AttributesModel() override;
48 
52  void initFrom(const AttributesModel *other);
53 
57  bool compare(const AttributesModel *other) const;
58 
59  bool compareAttributes(int role, const QVariant &a, const QVariant &b) const;
60 
61  /* Attributes Model specific API */
62  bool setModelData(const QVariant value, int role);
63  QVariant modelData(int role) const;
64 
67  bool isKnownAttributesRole(int role) const;
68 
70  void setPaletteType(PaletteType type);
71  PaletteType paletteType() const;
72 
76  QVariant data(int role) const;
77 
81  QVariant data(int column, int role) const;
82 
84  QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
86  int rowCount(const QModelIndex &) const override;
88  int columnCount(const QModelIndex &) const override;
90  QVariant data(const QModelIndex &, int role = Qt::DisplayRole) const override;
92  bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::DisplayRole) override;
94  bool resetData(const QModelIndex &index, int role = Qt::DisplayRole);
96  bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value,
97  int role = Qt::DisplayRole) override;
99  virtual QVariant defaultHeaderData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
101  bool resetHeaderData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole);
103  void setSourceModel(QAbstractItemModel *sourceModel) override;
104 
107  void setDefaultForRole(int role, const QVariant &value);
108 
110  void setDatasetDimension(int dimension);
111  int datasetDimension() const;
112 
113 Q_SIGNALS:
114  void attributesChanged(const QModelIndex &, const QModelIndex &);
115 
116 private Q_SLOTS:
117  void slotRowsAboutToBeInserted(const QModelIndex &parent, int start, int end);
118  void slotColumnsAboutToBeInserted(const QModelIndex &parent, int start, int end);
119  void slotRowsInserted(const QModelIndex &parent, int start, int end);
120  void slotColumnsInserted(const QModelIndex &parent, int start, int end);
121 
122  void slotRowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
123  void slotColumnsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
124  void slotRowsRemoved(const QModelIndex &parent, int start, int end);
125  void slotColumnsRemoved(const QModelIndex &parent, int start, int end);
126 
127  void slotDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
128 
129 private:
130  // helper
131  QVariant defaultsForRole(int role) const;
132  bool compareHeaderDataMaps(const QMap<int, QMap<int, QVariant>> &mapA,
133  const QMap<int, QMap<int, QVariant>> &mapB) const;
134 
135  void removeEntriesFromDataMap(int start, int end);
136  void removeEntriesFromDirectionDataMaps(Qt::Orientation dir, int start, int end);
137 };
138 }
139 
140 #endif
Contains KDChart macros.
#define KDCHART_DECLARE_PRIVATE_BASE_POLYMORPHIC(X)
Definition: KDChartGlobal.h:87
Base class for all proxy models used inside KD Chart.
A proxy model used for decorating data with attributes.
void attributesChanged(const QModelIndex &, const QModelIndex &)

© 2001 Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
https://www.kdab.com/development-resources/qt-tools/kd-chart/
Generated by doxygen 1.9.1