| 1 | // Copyright (C) 2024 The Qt Company Ltd. | 
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only | 
| 3 | #ifndef QTGRAPHS_QBARMODELMAPPER_H | 
| 4 | #define QTGRAPHS_QBARMODELMAPPER_H | 
| 5 | |
| 6 | #include <QtCore/qobject.h> | 
| 7 | #include <QtGraphs/qgraphsglobal.h> | 
| 8 | #include <QtQmlIntegration/qqmlintegration.h> | 
| 9 | |
| 10 | Q_MOC_INCLUDE(<QtCore / qabstractitemmodel.h>) | 
| 11 | Q_MOC_INCLUDE(<QtGraphs / qbarseries.h>) | 
| 12 | |
| 13 | QT_BEGIN_NAMESPACE | 
| 14 | |
| 15 | class QAbstractItemModel; | 
| 16 | class QBarSeries; | 
| 17 | class QBarModelMapperPrivate; | 
| 18 | |
| 19 | class Q_GRAPHS_EXPORT QBarModelMapper : public QObject | 
| 20 | { | 
| 21 | Q_OBJECT | 
| 22 | Q_PROPERTY(QBarSeries *series READ series WRITE setSeries NOTIFY seriesChanged FINAL) | 
| 23 | Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelChanged FINAL) | 
| 24 | Q_PROPERTY(qsizetype firstBarSetSection READ firstBarSetSection WRITE setFirstBarSetSection | 
| 25 | NOTIFY firstBarSetSectionChanged FINAL) | 
| 26 | Q_PROPERTY(qsizetype lastBarSetSection READ lastBarSetSection WRITE setLastBarSetSection NOTIFY | 
| 27 | lastBarSetSectionChanged FINAL) | 
| 28 | Q_PROPERTY(qsizetype first READ first WRITE setFirst NOTIFY firstChanged FINAL) | 
| 29 | Q_PROPERTY(qsizetype count READ count WRITE setCount NOTIFY countChanged FINAL) | 
| 30 | Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY | 
| 31 | orientationChanged FINAL) | 
| 32 | |
| 33 | QML_NAMED_ELEMENT(BarModelMapper) | 
| 34 | Q_DECLARE_PRIVATE(QBarModelMapper) | 
| 35 | public: | 
| 36 | explicit QBarModelMapper(QObject *parent = nullptr); | 
| 37 | ~QBarModelMapper() override; | 
| 38 | |
| 39 | QAbstractItemModel *model() const; | 
| 40 | void setModel(QAbstractItemModel *model); | 
| 41 | |
| 42 | QBarSeries *series() const; | 
| 43 | void setSeries(QBarSeries *series); | 
| 44 | |
| 45 | qsizetype firstBarSetSection() const; | 
| 46 | void setFirstBarSetSection(qsizetype newFirstBarSetSection); | 
| 47 | |
| 48 | qsizetype lastBarSetSection() const; | 
| 49 | void setLastBarSetSection(qsizetype newLastBarSetSection); | 
| 50 | |
| 51 | qsizetype count() const; | 
| 52 | void setCount(qsizetype newCount); | 
| 53 | |
| 54 | qsizetype first() const; | 
| 55 | void setFirst(qsizetype newFirst); | 
| 56 | |
| 57 | Qt::Orientation orientation() const; | 
| 58 | void setOrientation(Qt::Orientation orientation); | 
| 59 | |
| 60 | Q_SIGNALS: | 
| 61 | void seriesChanged(); | 
| 62 | void modelChanged(); | 
| 63 | void firstBarSetSectionChanged(); | 
| 64 | void lastBarSetSectionChanged(); | 
| 65 | void firstChanged(); | 
| 66 | void countChanged(); | 
| 67 | void orientationChanged(); | 
| 68 | |
| 69 | protected: | 
| 70 | QBarModelMapper(QBarModelMapperPrivate &dd, QObject *parent = nullptr); | 
| 71 | |
| 72 | private Q_SLOTS: | 
| 73 | void onValuesAdded(qsizetype index, qsizetype count); | 
| 74 | void onBarLabelChanged(); | 
| 75 | void onBarValueChanged(qsizetype index); | 
| 76 | |
| 77 | private: | 
| 78 | Q_DISABLE_COPY_MOVE(QBarModelMapper) | 
| 79 | }; | 
| 80 | |
| 81 | QT_END_NAMESPACE | 
| 82 | |
| 83 | #endif // QTGRAPHS_QBARMODELMAPPER_H | 
| 84 | 
