1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QBARDATAPROXY_H
5#define QBARDATAPROXY_H
6
7#include <QtGraphs/qabstractdataproxy.h>
8#include <QtGraphs/qbardataitem.h>
9#include <QtCore/QList>
10#include <QtCore/QStringList>
11
12Q_MOC_INCLUDE(<QtGraphs/qbar3dseries.h>)
13
14QT_BEGIN_NAMESPACE
15
16class QBarDataProxyPrivate;
17class QBar3DSeries;
18
19using QBarDataRow = QList<QBarDataItem>;
20using QBarDataArray = QList<QBarDataRow *>;
21
22class Q_GRAPHS_EXPORT QBarDataProxy : public QAbstractDataProxy
23{
24 Q_OBJECT
25 Q_DECLARE_PRIVATE(QBarDataProxy)
26 Q_PROPERTY(int rowCount READ rowCount NOTIFY rowCountChanged)
27 Q_PROPERTY(int colCount READ colCount NOTIFY colCountChanged)
28 Q_PROPERTY(QStringList rowLabels READ rowLabels WRITE setRowLabels NOTIFY rowLabelsChanged)
29 Q_PROPERTY(QStringList columnLabels READ columnLabels WRITE setColumnLabels NOTIFY columnLabelsChanged)
30 Q_PROPERTY(QBar3DSeries *series READ series NOTIFY seriesChanged)
31public:
32 explicit QBarDataProxy(QObject *parent = nullptr);
33 virtual ~QBarDataProxy();
34
35 QBar3DSeries *series() const;
36 int rowCount() const;
37 int colCount() const;
38
39 QStringList rowLabels() const;
40 void setRowLabels(const QStringList &labels);
41 QStringList columnLabels() const;
42 void setColumnLabels(const QStringList &labels);
43
44 const QBarDataArray *array() const;
45 const QBarDataRow *rowAt(int rowIndex) const;
46 const QBarDataItem *itemAt(int rowIndex, int columnIndex) const;
47 const QBarDataItem *itemAt(const QPoint &position) const;
48
49 void resetArray();
50 void resetArray(QBarDataArray *newArray);
51 void resetArray(QBarDataArray *newArray, const QStringList &rowLabels,
52 const QStringList &columnLabels);
53
54 void setRow(int rowIndex, QBarDataRow *row);
55 void setRow(int rowIndex, QBarDataRow *row, const QString &label);
56 void setRows(int rowIndex, const QBarDataArray &rows);
57 void setRows(int rowIndex, const QBarDataArray &rows, const QStringList &labels);
58
59 void setItem(int rowIndex, int columnIndex, const QBarDataItem &item);
60 void setItem(const QPoint &position, const QBarDataItem &item);
61
62 int addRow(QBarDataRow *row);
63 int addRow(QBarDataRow *row, const QString &label);
64 int addRows(const QBarDataArray &rows);
65 int addRows(const QBarDataArray &rows, const QStringList &labels);
66
67 void insertRow(int rowIndex, QBarDataRow *row);
68 void insertRow(int rowIndex, QBarDataRow *row, const QString &label);
69 void insertRows(int rowIndex, const QBarDataArray &rows);
70 void insertRows(int rowIndex, const QBarDataArray &rows, const QStringList &labels);
71
72 void removeRows(int rowIndex, int removeCount, bool removeLabels = true);
73
74Q_SIGNALS:
75 void arrayReset();
76 void rowsAdded(int startIndex, int count);
77 void rowsChanged(int startIndex, int count);
78 void rowsRemoved(int startIndex, int count);
79 void rowsInserted(int startIndex, int count);
80 void itemChanged(int rowIndex, int columnIndex);
81
82 void rowCountChanged(int count);
83 void colCountChanged(int count);
84 void rowLabelsChanged();
85 void columnLabelsChanged();
86 void seriesChanged(QBar3DSeries *series);
87
88protected:
89 explicit QBarDataProxy(QBarDataProxyPrivate *d, QObject *parent = nullptr);
90
91private:
92 Q_DISABLE_COPY(QBarDataProxy)
93
94 friend class Bars3DController;
95};
96
97QT_END_NAMESPACE
98
99#endif
100

source code of qtgraphs/src/graphs/data/qbardataproxy.h