| 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 Charts 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 QABSTRACTBARSERIES_H | 
| 31 | #define QABSTRACTBARSERIES_H | 
| 32 |  | 
| 33 | #include <QtCharts/QAbstractSeries> | 
| 34 | #include <QtCore/QStringList> | 
| 35 |  | 
| 36 | QT_CHARTS_BEGIN_NAMESPACE | 
| 37 |  | 
| 38 | class QBarSet; | 
| 39 | class QAbstractBarSeriesPrivate; | 
| 40 |  | 
| 41 | // Container for series | 
| 42 | class Q_CHARTS_EXPORT QAbstractBarSeries : public QAbstractSeries | 
| 43 | { | 
| 44 |     Q_OBJECT | 
| 45 |     Q_PROPERTY(qreal barWidth READ barWidth WRITE setBarWidth) | 
| 46 |     Q_PROPERTY(int count READ count NOTIFY countChanged) | 
| 47 |     Q_PROPERTY(bool labelsVisible READ isLabelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged) | 
| 48 |     Q_PROPERTY(QString labelsFormat READ labelsFormat WRITE setLabelsFormat NOTIFY labelsFormatChanged) | 
| 49 |     Q_PROPERTY(LabelsPosition labelsPosition READ labelsPosition WRITE setLabelsPosition NOTIFY labelsPositionChanged) | 
| 50 |     Q_PROPERTY(qreal labelsAngle READ labelsAngle WRITE setLabelsAngle NOTIFY labelsAngleChanged) | 
| 51 |     Q_PROPERTY(int labelsPrecision READ labelsPrecision WRITE setLabelsPrecision NOTIFY labelsPrecisionChanged) | 
| 52 |     Q_ENUMS(LabelsPosition) | 
| 53 |  | 
| 54 | public: | 
| 55 |     enum LabelsPosition { | 
| 56 |         LabelsCenter = 0, | 
| 57 |         LabelsInsideEnd, | 
| 58 |         LabelsInsideBase, | 
| 59 |         LabelsOutsideEnd | 
| 60 |     }; | 
| 61 |  | 
| 62 | public: | 
| 63 |     virtual ~QAbstractBarSeries(); | 
| 64 |  | 
| 65 |     void setBarWidth(qreal width); | 
| 66 |     qreal barWidth() const; | 
| 67 |  | 
| 68 |     bool append(QBarSet *set); | 
| 69 |     bool remove(QBarSet *set); | 
| 70 |     bool take(QBarSet *set); | 
| 71 |     bool append(QList<QBarSet *> sets); | 
| 72 |     bool insert(int index, QBarSet *set); | 
| 73 |     int count() const; | 
| 74 |     QList<QBarSet *> barSets() const; | 
| 75 |     void clear(); | 
| 76 |  | 
| 77 |     void setLabelsVisible(bool visible = true); | 
| 78 |     bool isLabelsVisible() const; | 
| 79 |  | 
| 80 |     void setLabelsFormat(const QString &format); | 
| 81 |     QString labelsFormat() const; | 
| 82 |  | 
| 83 |     void setLabelsAngle(qreal angle); | 
| 84 |     qreal labelsAngle() const; | 
| 85 |  | 
| 86 |     void setLabelsPosition(QAbstractBarSeries::LabelsPosition position); | 
| 87 |     QAbstractBarSeries::LabelsPosition labelsPosition() const; | 
| 88 |  | 
| 89 |     void setLabelsPrecision(int precision); | 
| 90 |     int labelsPrecision() const; | 
| 91 |  | 
| 92 | protected: | 
| 93 |     explicit QAbstractBarSeries(QAbstractBarSeriesPrivate &d, QObject *parent = nullptr); | 
| 94 |  | 
| 95 | Q_SIGNALS: | 
| 96 |     void clicked(int index, QBarSet *barset); | 
| 97 |     void hovered(bool status, int index, QBarSet *barset); | 
| 98 |     void pressed(int index, QBarSet *barset); | 
| 99 |     void released(int index, QBarSet *barset); | 
| 100 |     void doubleClicked(int index, QBarSet *barset); | 
| 101 |     void countChanged(); | 
| 102 |     void labelsVisibleChanged(); | 
| 103 |     void labelsFormatChanged(const QString &format); | 
| 104 |     void labelsPositionChanged(QAbstractBarSeries::LabelsPosition position); | 
| 105 |     void labelsAngleChanged(qreal angle); | 
| 106 |     void labelsPrecisionChanged(int precision); | 
| 107 |  | 
| 108 |     void barsetsAdded(QList<QBarSet *> sets); | 
| 109 |     void barsetsRemoved(QList<QBarSet *> sets); | 
| 110 |  | 
| 111 | protected: | 
| 112 |     Q_DECLARE_PRIVATE(QAbstractBarSeries) | 
| 113 |     friend class AbstractBarChartItem; | 
| 114 |     friend class PercentBarChartItem; | 
| 115 |     friend class StackedBarChartItem; | 
| 116 |     friend class BoxPlotChartItem; | 
| 117 |     friend class BarChartItem; | 
| 118 |     friend class HorizontalBarChartItem; | 
| 119 |     friend class HorizontalStackedBarChartItem; | 
| 120 |     friend class HorizontalPercentBarChartItem; | 
| 121 |     friend class BarSet; | 
| 122 | }; | 
| 123 |  | 
| 124 | QT_CHARTS_END_NAMESPACE | 
| 125 |  | 
| 126 | #endif // QABSTRACTBARSERIES_H | 
| 127 |  |