1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Data Visualization module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 or (at your option) any later version
20** approved by the KDE Free Qt Foundation. The licenses are as published by
21** the Free Software Foundation and appearing in the file LICENSE.GPL3
22** included in the packaging of this file. Please review the following
23** information to ensure the GNU General Public License requirements will
24** be met: https://www.gnu.org/licenses/gpl-3.0.html.
25**
26** $QT_END_LICENSE$
27**
28****************************************************************************/
29
30#ifndef QBARDATAPROXY_H
31#define QBARDATAPROXY_H
32
33#include <QtDataVisualization/qabstractdataproxy.h>
34#include <QtDataVisualization/qbardataitem.h>
35#include <QtCore/QVector>
36#include <QtCore/QStringList>
37
38QT_BEGIN_NAMESPACE_DATAVISUALIZATION
39
40class QBarDataProxyPrivate;
41class QBar3DSeries;
42
43typedef QVector<QBarDataItem> QBarDataRow;
44typedef QList<QBarDataRow *> QBarDataArray;
45
46class QT_DATAVISUALIZATION_EXPORT QBarDataProxy : public QAbstractDataProxy
47{
48 Q_OBJECT
49
50 Q_PROPERTY(int rowCount READ rowCount NOTIFY rowCountChanged)
51 Q_PROPERTY(QStringList rowLabels READ rowLabels WRITE setRowLabels NOTIFY rowLabelsChanged)
52 Q_PROPERTY(QStringList columnLabels READ columnLabels WRITE setColumnLabels NOTIFY columnLabelsChanged)
53 Q_PROPERTY(QBar3DSeries *series READ series NOTIFY seriesChanged)
54public:
55 explicit QBarDataProxy(QObject *parent = nullptr);
56 virtual ~QBarDataProxy();
57
58 QBar3DSeries *series() const;
59 int rowCount() const;
60
61 QStringList rowLabels() const;
62 void setRowLabels(const QStringList &labels);
63 QStringList columnLabels() const;
64 void setColumnLabels(const QStringList &labels);
65
66 const QBarDataArray *array() const;
67 const QBarDataRow *rowAt(int rowIndex) const;
68 const QBarDataItem *itemAt(int rowIndex, int columnIndex) const;
69 const QBarDataItem *itemAt(const QPoint &position) const;
70
71 void resetArray();
72 void resetArray(QBarDataArray *newArray);
73 void resetArray(QBarDataArray *newArray, const QStringList &rowLabels,
74 const QStringList &columnLabels);
75
76 void setRow(int rowIndex, QBarDataRow *row);
77 void setRow(int rowIndex, QBarDataRow *row, const QString &label);
78 void setRows(int rowIndex, const QBarDataArray &rows);
79 void setRows(int rowIndex, const QBarDataArray &rows, const QStringList &labels);
80
81 void setItem(int rowIndex, int columnIndex, const QBarDataItem &item);
82 void setItem(const QPoint &position, const QBarDataItem &item);
83
84 int addRow(QBarDataRow *row);
85 int addRow(QBarDataRow *row, const QString &label);
86 int addRows(const QBarDataArray &rows);
87 int addRows(const QBarDataArray &rows, const QStringList &labels);
88
89 void insertRow(int rowIndex, QBarDataRow *row);
90 void insertRow(int rowIndex, QBarDataRow *row, const QString &label);
91 void insertRows(int rowIndex, const QBarDataArray &rows);
92 void insertRows(int rowIndex, const QBarDataArray &rows, const QStringList &labels);
93
94 void removeRows(int rowIndex, int removeCount, bool removeLabels = true);
95
96Q_SIGNALS:
97 void arrayReset();
98 void rowsAdded(int startIndex, int count);
99 void rowsChanged(int startIndex, int count);
100 void rowsRemoved(int startIndex, int count);
101 void rowsInserted(int startIndex, int count);
102 void itemChanged(int rowIndex, int columnIndex);
103
104 void rowCountChanged(int count);
105 void rowLabelsChanged();
106 void columnLabelsChanged();
107 void seriesChanged(QBar3DSeries *series);
108
109protected:
110 explicit QBarDataProxy(QBarDataProxyPrivate *d, QObject *parent = nullptr);
111 QBarDataProxyPrivate *dptr();
112 const QBarDataProxyPrivate *dptrc() const;
113
114private:
115 Q_DISABLE_COPY(QBarDataProxy)
116
117 friend class Bars3DController;
118};
119
120QT_END_NAMESPACE_DATAVISUALIZATION
121
122#endif
123

source code of qtdatavis3d/src/datavisualization/data/qbardataproxy.h