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