##// END OF EJS Templates
barseries api change proposal (as TODOs). Support for positioning of bars to x-axis.
sauimone -
r1159:eb9b7c9d2f78
parent child
Show More
@@ -1,79 +1,82
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #ifndef BARSERIES_H
22 22 #define BARSERIES_H
23 23
24 24 #include <qabstractseries.h>
25 25 #include <QStringList>
26 26
27 27 class QModelIndex;
28 28
29 29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 30
31 31 typedef QStringList QBarCategories;
32 32
33 33 class QBarSet;
34 34 class BarCategory;
35 35 class QBarSeriesPrivate;
36 36
37 37 // Container for series
38 38 class QTCOMMERCIALCHART_EXPORT QBarSeries : public QAbstractSeries
39 39 {
40 40 Q_OBJECT
41 41 public:
42 42 explicit QBarSeries(/*QBarCategories categories,*/ QObject *parent = 0);
43 43 virtual ~QBarSeries();
44 44
45 45 QAbstractSeries::SeriesType type() const;
46 46 void setCategories(QBarCategories categories);
47 47
48 48 bool appendBarSet(QBarSet *set); // Takes ownership of set
49 49 bool removeBarSet(QBarSet *set); // Releases ownership, doesn't delete set
50 50 bool appendBarSets(QList<QBarSet* > sets);
51 51 bool removeBarSets(QList<QBarSet* > sets);
52 52 int barsetCount() const;
53 53 int categoryCount() const;
54 54 QList<QBarSet*> barSets() const;
55 55 QBarCategories categories() const;
56 56
57 57 void setLabelsVisible(bool visible = true);
58 // TODO:
59 // void setGroupedDrawing(bool on = true); // By default this is on. Bars are grouped next to each other. If off, bars are drawn at their x-position (propably on top of each other)
60 // void setBarMargin(int margin); // Margin that is left between bars (if drawn as grouped bars)
58 61
59 62 bool setModel(QAbstractItemModel *model);
60 63 void setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical);
61 64 void setModelMappingRange(int first, int count = -1);
62 65
63 66 protected:
64 67 explicit QBarSeries(QBarSeriesPrivate &d,QObject *parent = 0);
65 68
66 69 Q_SIGNALS:
67 70 void clicked(QBarSet *barset, QString category);
68 71 void hovered(QBarSet* barset, bool status);
69 72
70 73 protected:
71 74 Q_DECLARE_PRIVATE(QBarSeries)
72 75 friend class BarChartItem;
73 76 friend class PercentBarChartItem;
74 77 friend class StackedBarChartItem;
75 78 };
76 79
77 80 QTCOMMERCIALCHART_END_NAMESPACE
78 81
79 82 #endif // BARSERIES_H
@@ -1,85 +1,96
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #ifndef QBARSET_H
22 22 #define QBARSET_H
23 23
24 24 #include <qchartglobal.h>
25 25 #include <QPen>
26 26 #include <QBrush>
27 27 #include <QFont>
28 28
29 29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 30 class QBarSetPrivate;
31 31
32 32 class QTCOMMERCIALCHART_EXPORT QBarSet : public QObject
33 33 {
34 34 Q_OBJECT
35 35
36 36 public:
37 37 explicit QBarSet(const QString name, QObject *parent = 0);
38 38 virtual ~QBarSet();
39 39
40 40 void setName(const QString name);
41 41 QString name() const;
42 void append(const qreal value);
43 QBarSet& operator << (const qreal &value);
44 void insert(const int index, const qreal value);
45 void remove(const int index);
42
43 // TODO:
44 // void append(const QPointF value); // Appends bar with x-value
45 // void append(const QList<QPointF> value); // Same with list
46 void append(const qreal value); // TODO: change so, that count becomes x-value
47
48 // TODO:
49 // void append(const QList<qreal> values); // Append list of values. Using index as x-value
50
51 QBarSet& operator << (const qreal &value); // TODO: change implementations so, that count becomes x-value
52 // TODO:
53 // QBarSet& operator << (const QPointF &value); // Appends bar with x-value
54
55 void insert(const int index, const qreal value); // TODO: internal reindexing (what happens, if there are points with real x values?)
56 void remove(const int index); // TODO: internal reindexing (what happens, if there are points with real x values?)
46 57 void replace(const int index, const qreal value);
47 58 qreal at(const int index) const;
48 59 qreal operator [] (int index) const;
49 60 int count() const;
50 61 qreal sum() const;
51 62
52 63 void setPen(const QPen &pen);
53 64 QPen pen() const;
54 65
55 66 void setBrush(const QBrush &brush);
56 67 QBrush brush() const;
57 68
58 69 void setLabelPen(const QPen &pen);
59 70 QPen labelPen() const;
60 71
61 72 void setLabelBrush(const QBrush &brush);
62 73 QBrush labelBrush() const;
63 74
64 75 void setLabelFont(const QFont &font);
65 76 QFont labelFont() const;
66 77
67 78 void setLabelsVisible(bool visible = true);
68 79 bool labelsVisible() const;
69 80
70 81 Q_SIGNALS:
71 82 void clicked(QString category);
72 83 void hovered(bool status);
73 84
74 85 private:
75 86 QScopedPointer<QBarSetPrivate> d_ptr;
76 87 Q_DISABLE_COPY(QBarSet)
77 88 friend class QBarSeries;
78 89 friend class BarLegendMarker;
79 90 friend class BarChartItem;
80 91 friend class QBarSeriesPrivate;
81 92 };
82 93
83 94 QTCOMMERCIALCHART_END_NAMESPACE
84 95
85 96 #endif // QBARSET_H
General Comments 0
You need to be logged in to leave comments. Login now