@@ -1,128 +1,127 | |||||
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 <qseries.h> |
|
24 | #include <qseries.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 BarChartModel; |
|
34 | class BarChartModel; | |
35 | class BarCategory; |
|
35 | class BarCategory; | |
36 | class QBarSeriesPrivate; |
|
36 | class QBarSeriesPrivate; | |
37 |
|
37 | |||
38 | // Container for series |
|
38 | // Container for series | |
39 | class QTCOMMERCIALCHART_EXPORT QBarSeries : public QSeries |
|
39 | class QTCOMMERCIALCHART_EXPORT QBarSeries : public QSeries | |
40 | { |
|
40 | { | |
41 | Q_OBJECT |
|
41 | Q_OBJECT | |
42 | public: |
|
42 | public: | |
43 | QBarSeries(QBarCategories categories, QObject *parent = 0); |
|
43 | QBarSeries(QBarCategories categories, QObject *parent = 0); | |
44 |
|
44 | |||
45 | QSeries::QSeriesType type() const; |
|
45 | QSeries::QSeriesType type() const; | |
46 |
|
46 | |||
47 | void appendBarSet(QBarSet *set); // Takes ownership of set |
|
47 | void appendBarSet(QBarSet *set); // Takes ownership of set | |
48 | void removeBarSet(QBarSet *set); // Releases ownership, doesn't delete set |
|
48 | void removeBarSet(QBarSet *set); // Releases ownership, doesn't delete set | |
49 | void appendBarSets(QList<QBarSet* > sets); |
|
49 | void appendBarSets(QList<QBarSet* > sets); | |
50 | void removeBarSets(QList<QBarSet* > sets); |
|
50 | void removeBarSets(QList<QBarSet* > sets); | |
51 | void insertBarSet(int i, QBarSet *set); |
|
51 | void insertBarSet(int i, QBarSet *set); | |
52 | void insertCategory(int i, QString category); |
|
52 | void insertCategory(int i, QString category); | |
53 | void removeCategory(int i); |
|
53 | void removeCategory(int i); | |
54 | int barsetCount() const; |
|
54 | int barsetCount() const; | |
55 | int categoryCount() const; |
|
55 | int categoryCount() const; | |
56 | QList<QBarSet*> barSets() const; |
|
56 | QList<QBarSet*> barSets() const; | |
57 | QBarCategories categories() const; |
|
57 | QBarCategories categories() const; | |
58 |
|
58 | |||
59 | void setLabelsVisible(bool visible = true); |
|
59 | void setLabelsVisible(bool visible = true); | |
60 |
|
60 | |||
61 | bool setModel(QAbstractItemModel *model); |
|
61 | bool setModel(QAbstractItemModel *model); | |
62 | void setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical); |
|
62 | void setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical); | |
63 |
|
63 | |||
64 | public: |
|
64 | public: | |
65 | // TODO: Functions below this are not part of api and will be moved |
|
65 | // TODO: Functions below this are not part of api and will be moved | |
66 | // to private implementation, when we start using it |
|
66 | // to private implementation, when we start using it | |
67 | // TODO: TO PIMPL ---> |
|
67 | // TODO: TO PIMPL ---> | |
68 | QBarSet* barsetAt(int index); |
|
68 | QBarSet* barsetAt(int index); | |
69 | QString categoryName(int category); |
|
69 | QString categoryName(int category); | |
70 | qreal min(); |
|
70 | qreal min(); | |
71 | qreal max(); |
|
71 | qreal max(); | |
72 | qreal valueAt(int set, int category); |
|
72 | qreal valueAt(int set, int category); | |
73 | qreal percentageAt(int set, int category); |
|
73 | qreal percentageAt(int set, int category); | |
74 | qreal categorySum(int category); |
|
74 | qreal categorySum(int category); | |
75 | qreal absoluteCategorySum(int category); |
|
75 | qreal absoluteCategorySum(int category); | |
76 | qreal maxCategorySum(); |
|
76 | qreal maxCategorySum(); | |
77 | BarChartModel& modelInternal(); |
|
77 | BarChartModel& modelInternal(); | |
78 | // <--- TO PIMPL |
|
78 | // <--- TO PIMPL | |
79 |
|
79 | |||
80 | protected: |
|
80 | protected: | |
81 | explicit QBarSeries(QBarSeriesPrivate &d,QObject *parent = 0); |
|
81 | explicit QBarSeries(QBarSeriesPrivate &d,QObject *parent = 0); | |
82 |
|
82 | |||
83 | Q_SIGNALS: |
|
83 | Q_SIGNALS: | |
84 | void clicked(QBarSet *barset, QString category, Qt::MouseButtons button); // Up to user of api, what to do with these signals |
|
84 | void clicked(QBarSet *barset, QString category, Qt::MouseButtons button); // Up to user of api, what to do with these signals | |
85 | void selected(); |
|
85 | void selected(); | |
86 | // |
|
86 | // | |
87 | void updatedBars(); |
|
87 | void updatedBars(); | |
88 | void restructuredBars(); |
|
88 | void restructuredBars(); | |
89 |
|
89 | |||
90 | // TODO: internal signals, these to private implementation. |
|
90 | // TODO: internal signals, these to private implementation. | |
91 | // TODO: TO PIMPL ---> |
|
91 | // TODO: TO PIMPL ---> | |
92 | // void showToolTip(QPoint pos, QString tip); |
|
92 | // void showToolTip(QPoint pos, QString tip); | |
93 | // <--- TO PIMPL |
|
93 | // <--- TO PIMPL | |
94 |
|
94 | |||
95 | public Q_SLOTS: |
|
95 | public Q_SLOTS: | |
96 | void setToolTipEnabled(bool enabled = true); // enables tooltips |
|
96 | void setToolTipEnabled(bool enabled = true); // enables tooltips | |
97 |
|
97 | |||
98 | // TODO: TO PIMPL ---> |
|
98 | // TODO: TO PIMPL ---> | |
99 | void barsetClicked(QString category, Qt::MouseButtons button); |
|
99 | void barsetClicked(QString category, Qt::MouseButtons button); | |
100 | // <--- TO PIMPL |
|
100 | // <--- TO PIMPL | |
101 |
|
101 | |||
102 | private Q_SLOTS: |
|
102 | private Q_SLOTS: | |
103 | // slots for updating bars when data in model changes |
|
103 | // slots for updating bars when data in model changes | |
104 | void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight); |
|
104 | void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight); | |
105 | void modelDataAdded(QModelIndex parent, int start, int end); |
|
105 | void modelDataAdded(QModelIndex parent, int start, int end); | |
106 | void modelDataRemoved(QModelIndex parent, int start, int end); |
|
106 | void modelDataRemoved(QModelIndex parent, int start, int end); | |
107 | void barsetChanged(); |
|
107 | void barsetChanged(); | |
108 |
|
108 | |||
109 | protected: |
|
109 | protected: | |
110 | Q_DECLARE_PRIVATE(QBarSeries) |
|
110 | Q_DECLARE_PRIVATE(QBarSeries) | |
111 | Q_DISABLE_COPY(QBarSeries) |
|
|||
112 |
|
111 | |||
113 | /* |
|
112 | /* | |
114 | BarChartModel *m_internalModel; // TODO: this may change... current "2 models" situation doesn't look good. |
|
113 | BarChartModel *m_internalModel; // TODO: this may change... current "2 models" situation doesn't look good. | |
115 |
|
114 | |||
116 | // QAbstractItemModel* m_model; |
|
115 | // QAbstractItemModel* m_model; | |
117 | int m_mapCategories; |
|
116 | int m_mapCategories; | |
118 | int m_mapBarBottom; |
|
117 | int m_mapBarBottom; | |
119 | int m_mapBarTop; |
|
118 | int m_mapBarTop; | |
120 | int m_mapFirst; |
|
119 | int m_mapFirst; | |
121 | int m_mapCount; |
|
120 | int m_mapCount; | |
122 | Qt::Orientation m_mapOrientation; |
|
121 | Qt::Orientation m_mapOrientation; | |
123 | */ |
|
122 | */ | |
124 | }; |
|
123 | }; | |
125 |
|
124 | |||
126 | QTCOMMERCIALCHART_END_NAMESPACE |
|
125 | QTCOMMERCIALCHART_END_NAMESPACE | |
127 |
|
126 | |||
128 | #endif // BARSERIES_H |
|
127 | #endif // BARSERIES_H |
@@ -1,321 +1,326 | |||||
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 | #include "qbarset.h" |
|
21 | #include "qbarset.h" | |
22 | #include "qbarset_p.h" |
|
22 | #include "qbarset_p.h" | |
23 | #include <QToolTip> |
|
23 | #include <QToolTip> | |
24 |
|
24 | |||
25 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
25 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
26 |
|
26 | |||
27 | /*! |
|
27 | /*! | |
28 | \class QBarSet |
|
28 | \class QBarSet | |
29 | \brief part of QtCommercial chart API. |
|
29 | \brief part of QtCommercial chart API. | |
30 |
|
30 | |||
31 | QBarSet represents one set of bars. Set of bars contains one data value for each category. |
|
31 | QBarSet represents one set of bars. Set of bars contains one data value for each category. | |
32 | First value of set is assumed to belong to first category, second to second category and so on. |
|
32 | First value of set is assumed to belong to first category, second to second category and so on. | |
33 | If set has fewer values than there are categories, then the missing values are assumed to be |
|
33 | If set has fewer values than there are categories, then the missing values are assumed to be | |
34 | at the end of set. For missing values in middle of a set, numerical value of zero is used. |
|
34 | at the end of set. For missing values in middle of a set, numerical value of zero is used. | |
35 |
|
35 | |||
36 | \mainclass |
|
36 | \mainclass | |
37 |
|
37 | |||
38 | \sa QBarSeries, QStackedBarSeries, QPercentBarSeries |
|
38 | \sa QBarSeries, QStackedBarSeries, QPercentBarSeries | |
39 | */ |
|
39 | */ | |
40 |
|
40 | |||
41 | /*! |
|
41 | /*! | |
42 | \fn void QBarSet::clicked(QString category, Qt::MouseButtons button) |
|
42 | \fn void QBarSet::clicked(QString category, Qt::MouseButtons button) | |
43 | \brief signals that set has been clicked |
|
43 | \brief signals that set has been clicked | |
44 | Parameter \a category describes on which category was clicked |
|
44 | Parameter \a category describes on which category was clicked | |
45 | Parameter \a button mouse button |
|
45 | Parameter \a button mouse button | |
46 | */ |
|
46 | */ | |
47 |
|
47 | |||
48 | /*! |
|
48 | /*! | |
49 | \fn void QBarSet::hoverEnter(QPoint pos) |
|
49 | \fn void QBarSet::hoverEnter(QPoint pos) | |
50 | \brief signals that mouse has entered over the set at position \a pos. |
|
50 | \brief signals that mouse has entered over the set at position \a pos. | |
51 | */ |
|
51 | */ | |
52 |
|
52 | |||
53 | /*! |
|
53 | /*! | |
54 | \fn void QBarSet::hoverLeave() |
|
54 | \fn void QBarSet::hoverLeave() | |
55 | \brief signals that mouse has left from the set. |
|
55 | \brief signals that mouse has left from the set. | |
56 | */ |
|
56 | */ | |
57 |
|
57 | |||
58 | /*! |
|
58 | /*! | |
59 | \fn void QBarSetPrivate::showToolTip(QPoint pos, QString tip) |
|
59 | \fn void QBarSetPrivate::showToolTip(QPoint pos, QString tip) | |
60 | \brief \internal \a pos \a tip |
|
60 | \brief \internal \a pos \a tip | |
61 | */ |
|
61 | */ | |
62 |
|
62 | |||
63 |
|
63 | |||
64 | /*! |
|
64 | /*! | |
65 | Constructs QBarSet with a name of \a name and with parent of \a parent |
|
65 | Constructs QBarSet with a name of \a name and with parent of \a parent | |
66 | */ |
|
66 | */ | |
67 | QBarSet::QBarSet(QString name, QObject *parent) |
|
67 | QBarSet::QBarSet(QString name, QObject *parent) | |
68 | : QObject(parent) |
|
68 | : QObject(parent) | |
69 | ,d_ptr(new QBarSetPrivate(name,this)) |
|
69 | ,d_ptr(new QBarSetPrivate(name,this)) | |
70 | // ,m_name(name) |
|
70 | // ,m_name(name) | |
71 | // ,m_labelsVisible(false) |
|
71 | // ,m_labelsVisible(false) | |
72 | { |
|
72 | { | |
73 | } |
|
73 | } | |
74 |
|
74 | |||
|
75 | QBarSet::~QBarSet() | |||
|
76 | { | |||
|
77 | ||||
|
78 | } | |||
|
79 | ||||
75 | /*! |
|
80 | /*! | |
76 | Sets new \a name for set. |
|
81 | Sets new \a name for set. | |
77 | */ |
|
82 | */ | |
78 | void QBarSet::setName(QString name) |
|
83 | void QBarSet::setName(QString name) | |
79 | { |
|
84 | { | |
80 | d_ptr->m_name = name; |
|
85 | d_ptr->m_name = name; | |
81 | } |
|
86 | } | |
82 |
|
87 | |||
83 | /*! |
|
88 | /*! | |
84 | Returns name of the set. |
|
89 | Returns name of the set. | |
85 | */ |
|
90 | */ | |
86 | QString QBarSet::name() const |
|
91 | QString QBarSet::name() const | |
87 | { |
|
92 | { | |
88 | return d_ptr->m_name; |
|
93 | return d_ptr->m_name; | |
89 | } |
|
94 | } | |
90 |
|
95 | |||
91 | /*! |
|
96 | /*! | |
92 | Appends new value \a value to the end of set. |
|
97 | Appends new value \a value to the end of set. | |
93 | */ |
|
98 | */ | |
94 | QBarSet& QBarSet::operator << (const qreal &value) |
|
99 | QBarSet& QBarSet::operator << (const qreal &value) | |
95 | { |
|
100 | { | |
96 | d_ptr->m_values.append(value); |
|
101 | d_ptr->m_values.append(value); | |
97 | emit d_ptr->structureChanged(); |
|
102 | emit d_ptr->structureChanged(); | |
98 | return *this; |
|
103 | return *this; | |
99 | } |
|
104 | } | |
100 |
|
105 | |||
101 | /*! |
|
106 | /*! | |
102 | Inserts new \a value on the \a i position. |
|
107 | Inserts new \a value on the \a i position. | |
103 | The value that is currently at this postion is moved to postion i + 1 |
|
108 | The value that is currently at this postion is moved to postion i + 1 | |
104 | \sa removeValue() |
|
109 | \sa removeValue() | |
105 | */ |
|
110 | */ | |
106 | void QBarSet::insertValue(int i, qreal value) |
|
111 | void QBarSet::insertValue(int i, qreal value) | |
107 | { |
|
112 | { | |
108 | d_ptr->m_values.insert(i, value); |
|
113 | d_ptr->m_values.insert(i, value); | |
109 | } |
|
114 | } | |
110 |
|
115 | |||
111 | /*! |
|
116 | /*! | |
112 | Removes the value specified by \a i |
|
117 | Removes the value specified by \a i | |
113 | \sa insertValue() |
|
118 | \sa insertValue() | |
114 | */ |
|
119 | */ | |
115 | void QBarSet::removeValue(int i) |
|
120 | void QBarSet::removeValue(int i) | |
116 | { |
|
121 | { | |
117 | d_ptr->m_values.removeAt(i); |
|
122 | d_ptr->m_values.removeAt(i); | |
118 | } |
|
123 | } | |
119 |
|
124 | |||
120 | /*! |
|
125 | /*! | |
121 | Returns count of values in set. |
|
126 | Returns count of values in set. | |
122 | */ |
|
127 | */ | |
123 | int QBarSet::count() const |
|
128 | int QBarSet::count() const | |
124 | { |
|
129 | { | |
125 | return d_ptr->m_values.count(); |
|
130 | return d_ptr->m_values.count(); | |
126 | } |
|
131 | } | |
127 |
|
132 | |||
128 | /*! |
|
133 | /*! | |
129 | Returns value of set indexed by \a index |
|
134 | Returns value of set indexed by \a index | |
130 | */ |
|
135 | */ | |
131 | qreal QBarSet::valueAt(int index) const |
|
136 | qreal QBarSet::valueAt(int index) const | |
132 | { |
|
137 | { | |
133 | return d_ptr->m_values.at(index); |
|
138 | return d_ptr->m_values.at(index); | |
134 | } |
|
139 | } | |
135 |
|
140 | |||
136 | /*! |
|
141 | /*! | |
137 | Sets a new value \a value to set, indexed by \a index |
|
142 | Sets a new value \a value to set, indexed by \a index | |
138 | */ |
|
143 | */ | |
139 | void QBarSet::setValue(int index, qreal value) |
|
144 | void QBarSet::setValue(int index, qreal value) | |
140 | { |
|
145 | { | |
141 | d_ptr->m_values.replace(index,value); |
|
146 | d_ptr->m_values.replace(index,value); | |
142 | emit d_ptr->valueChanged(); |
|
147 | emit d_ptr->valueChanged(); | |
143 | } |
|
148 | } | |
144 |
|
149 | |||
145 | /*! |
|
150 | /*! | |
146 | Returns sum of all values in barset. |
|
151 | Returns sum of all values in barset. | |
147 | */ |
|
152 | */ | |
148 | qreal QBarSet::sum() const |
|
153 | qreal QBarSet::sum() const | |
149 | { |
|
154 | { | |
150 | qreal total(0); |
|
155 | qreal total(0); | |
151 | for (int i=0; i < d_ptr->m_values.count(); i++) { |
|
156 | for (int i=0; i < d_ptr->m_values.count(); i++) { | |
152 | total += d_ptr->m_values.at(i); |
|
157 | total += d_ptr->m_values.at(i); | |
153 | } |
|
158 | } | |
154 | return total; |
|
159 | return total; | |
155 | } |
|
160 | } | |
156 |
|
161 | |||
157 | /*! |
|
162 | /*! | |
158 | Sets pen for set. Bars of this set are drawn using \a pen |
|
163 | Sets pen for set. Bars of this set are drawn using \a pen | |
159 | */ |
|
164 | */ | |
160 | void QBarSet::setPen(const QPen &pen) |
|
165 | void QBarSet::setPen(const QPen &pen) | |
161 | { |
|
166 | { | |
162 | if(d_ptr->m_pen!=pen){ |
|
167 | if(d_ptr->m_pen!=pen){ | |
163 | d_ptr->m_pen = pen; |
|
168 | d_ptr->m_pen = pen; | |
164 | emit d_ptr->valueChanged(); |
|
169 | emit d_ptr->valueChanged(); | |
165 | } |
|
170 | } | |
166 | } |
|
171 | } | |
167 |
|
172 | |||
168 | /*! |
|
173 | /*! | |
169 | Returns pen of the set. |
|
174 | Returns pen of the set. | |
170 | */ |
|
175 | */ | |
171 | QPen QBarSet::pen() const |
|
176 | QPen QBarSet::pen() const | |
172 | { |
|
177 | { | |
173 | return d_ptr->m_pen; |
|
178 | return d_ptr->m_pen; | |
174 | } |
|
179 | } | |
175 |
|
180 | |||
176 | /*! |
|
181 | /*! | |
177 | Sets brush for the set. Bars of this set are drawn using \a brush |
|
182 | Sets brush for the set. Bars of this set are drawn using \a brush | |
178 | */ |
|
183 | */ | |
179 | void QBarSet::setBrush(const QBrush &brush) |
|
184 | void QBarSet::setBrush(const QBrush &brush) | |
180 | { |
|
185 | { | |
181 | if(d_ptr->m_brush!=brush){ |
|
186 | if(d_ptr->m_brush!=brush){ | |
182 | d_ptr->m_brush = brush; |
|
187 | d_ptr->m_brush = brush; | |
183 | emit d_ptr->valueChanged(); |
|
188 | emit d_ptr->valueChanged(); | |
184 | } |
|
189 | } | |
185 | } |
|
190 | } | |
186 |
|
191 | |||
187 | /*! |
|
192 | /*! | |
188 | Returns brush of the set. |
|
193 | Returns brush of the set. | |
189 | */ |
|
194 | */ | |
190 | QBrush QBarSet::brush() const |
|
195 | QBrush QBarSet::brush() const | |
191 | { |
|
196 | { | |
192 | return d_ptr->m_brush; |
|
197 | return d_ptr->m_brush; | |
193 | } |
|
198 | } | |
194 |
|
199 | |||
195 | /*! |
|
200 | /*! | |
196 | Sets \a pen of the values that are drawn on top of this barset |
|
201 | Sets \a pen of the values that are drawn on top of this barset | |
197 | */ |
|
202 | */ | |
198 | void QBarSet::setLabelPen(const QPen &pen) |
|
203 | void QBarSet::setLabelPen(const QPen &pen) | |
199 | { |
|
204 | { | |
200 | if(d_ptr->m_labelPen!=pen){ |
|
205 | if(d_ptr->m_labelPen!=pen){ | |
201 | d_ptr->m_labelPen = pen; |
|
206 | d_ptr->m_labelPen = pen; | |
202 | emit d_ptr->valueChanged(); |
|
207 | emit d_ptr->valueChanged(); | |
203 | } |
|
208 | } | |
204 | } |
|
209 | } | |
205 |
|
210 | |||
206 | /*! |
|
211 | /*! | |
207 | Returns pen of the values that are drawn on top of this barset |
|
212 | Returns pen of the values that are drawn on top of this barset | |
208 | */ |
|
213 | */ | |
209 | QPen QBarSet::labelPen() const |
|
214 | QPen QBarSet::labelPen() const | |
210 | { |
|
215 | { | |
211 | return d_ptr->m_labelPen; |
|
216 | return d_ptr->m_labelPen; | |
212 | } |
|
217 | } | |
213 |
|
218 | |||
214 | /*! |
|
219 | /*! | |
215 | Sets \a brush of the values that are drawn on top of this barset |
|
220 | Sets \a brush of the values that are drawn on top of this barset | |
216 | */ |
|
221 | */ | |
217 | void QBarSet::setLabelBrush(const QBrush &brush) |
|
222 | void QBarSet::setLabelBrush(const QBrush &brush) | |
218 | { |
|
223 | { | |
219 | if(d_ptr->m_labelBrush!=brush){ |
|
224 | if(d_ptr->m_labelBrush!=brush){ | |
220 | d_ptr->m_labelBrush = brush; |
|
225 | d_ptr->m_labelBrush = brush; | |
221 | emit d_ptr->valueChanged(); |
|
226 | emit d_ptr->valueChanged(); | |
222 | } |
|
227 | } | |
223 | } |
|
228 | } | |
224 |
|
229 | |||
225 | /*! |
|
230 | /*! | |
226 | Returns brush of the values that are drawn on top of this barset |
|
231 | Returns brush of the values that are drawn on top of this barset | |
227 | */ |
|
232 | */ | |
228 | QBrush QBarSet::labelBrush() const |
|
233 | QBrush QBarSet::labelBrush() const | |
229 | { |
|
234 | { | |
230 | return d_ptr->m_labelBrush; |
|
235 | return d_ptr->m_labelBrush; | |
231 | } |
|
236 | } | |
232 |
|
237 | |||
233 | /*! |
|
238 | /*! | |
234 | Sets the \a font for values that are drawn on top of this barset |
|
239 | Sets the \a font for values that are drawn on top of this barset | |
235 | */ |
|
240 | */ | |
236 | void QBarSet::setLabelFont(const QFont &font) |
|
241 | void QBarSet::setLabelFont(const QFont &font) | |
237 | { |
|
242 | { | |
238 | if(d_ptr->m_labelFont!=font) { |
|
243 | if(d_ptr->m_labelFont!=font) { | |
239 | d_ptr->m_labelFont = font; |
|
244 | d_ptr->m_labelFont = font; | |
240 | emit d_ptr->valueChanged(); |
|
245 | emit d_ptr->valueChanged(); | |
241 | } |
|
246 | } | |
242 |
|
247 | |||
243 | } |
|
248 | } | |
244 |
|
249 | |||
245 | /*! |
|
250 | /*! | |
246 | Returns the pen for values that are drawn on top of this set |
|
251 | Returns the pen for values that are drawn on top of this set | |
247 | */ |
|
252 | */ | |
248 | QFont QBarSet::labelFont() const |
|
253 | QFont QBarSet::labelFont() const | |
249 | { |
|
254 | { | |
250 | return d_ptr->m_labelFont; |
|
255 | return d_ptr->m_labelFont; | |
251 | } |
|
256 | } | |
252 |
|
257 | |||
253 | /*! |
|
258 | /*! | |
254 | Sets visibility of bar labels. If \a visible is true, labels are drawn on top of barsets. |
|
259 | Sets visibility of bar labels. If \a visible is true, labels are drawn on top of barsets. | |
255 | */ |
|
260 | */ | |
256 |
|
261 | |||
257 | void QBarSet::setLabelsVisible(bool visible) |
|
262 | void QBarSet::setLabelsVisible(bool visible) | |
258 | { |
|
263 | { | |
259 | if(d_ptr->m_labelsVisible!=visible) { |
|
264 | if(d_ptr->m_labelsVisible!=visible) { | |
260 | d_ptr->m_labelsVisible = visible; |
|
265 | d_ptr->m_labelsVisible = visible; | |
261 | emit d_ptr->labelsVisibleChanged(visible); |
|
266 | emit d_ptr->labelsVisibleChanged(visible); | |
262 | } |
|
267 | } | |
263 | } |
|
268 | } | |
264 |
|
269 | |||
265 | /*! |
|
270 | /*! | |
266 | Returns the visibility of values |
|
271 | Returns the visibility of values | |
267 | */ |
|
272 | */ | |
268 | bool QBarSet::labelsVisible() const |
|
273 | bool QBarSet::labelsVisible() const | |
269 | { |
|
274 | { | |
270 | return d_ptr->m_labelsVisible; |
|
275 | return d_ptr->m_labelsVisible; | |
271 | } |
|
276 | } | |
272 |
|
277 | |||
273 | /* |
|
278 | /* | |
274 | void QBarSet::barHoverEnterEvent(QPoint pos) |
|
279 | void QBarSet::barHoverEnterEvent(QPoint pos) | |
275 | { |
|
280 | { | |
276 | emit showToolTip(pos, m_name); |
|
281 | emit showToolTip(pos, m_name); | |
277 | emit hoverEnter(pos); |
|
282 | emit hoverEnter(pos); | |
278 | } |
|
283 | } | |
279 | */ |
|
284 | */ | |
280 | /* |
|
285 | /* | |
281 | void QBarSet::barHoverLeaveEvent() |
|
286 | void QBarSet::barHoverLeaveEvent() | |
282 | { |
|
287 | { | |
283 | // Emit signal to user of charts |
|
288 | // Emit signal to user of charts | |
284 | emit hoverLeave(); |
|
289 | emit hoverLeave(); | |
285 | } |
|
290 | } | |
286 | */ |
|
291 | */ | |
287 |
|
292 | |||
288 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
293 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
289 |
|
294 | |||
290 | QBarSetPrivate::QBarSetPrivate(QString name, QBarSet *parent) : QObject(parent), |
|
295 | QBarSetPrivate::QBarSetPrivate(QString name, QBarSet *parent) : QObject(parent), | |
291 | q_ptr(parent), |
|
296 | q_ptr(parent), | |
292 | m_name(name), |
|
297 | m_name(name), | |
293 | m_labelsVisible(false) |
|
298 | m_labelsVisible(false) | |
294 | { |
|
299 | { | |
295 |
|
300 | |||
296 | } |
|
301 | } | |
297 |
|
302 | |||
298 | QBarSetPrivate::~QBarSetPrivate() |
|
303 | QBarSetPrivate::~QBarSetPrivate() | |
299 | { |
|
304 | { | |
300 |
|
305 | |||
301 | } |
|
306 | } | |
302 |
|
307 | |||
303 |
|
308 | |||
304 | //TODO: fixme , refactor it and get rid of it |
|
309 | //TODO: fixme , refactor it and get rid of it | |
305 | void QBarSetPrivate::barHoverEnterEvent(QPoint pos) |
|
310 | void QBarSetPrivate::barHoverEnterEvent(QPoint pos) | |
306 | { |
|
311 | { | |
307 | emit showToolTip(pos, m_name); |
|
312 | emit showToolTip(pos, m_name); | |
308 | emit hoverEnter(pos); |
|
313 | emit hoverEnter(pos); | |
309 | } |
|
314 | } | |
310 |
|
315 | |||
311 | //TODO: fixme , refactor it and get rid of it |
|
316 | //TODO: fixme , refactor it and get rid of it | |
312 | void QBarSetPrivate::barHoverLeaveEvent() |
|
317 | void QBarSetPrivate::barHoverLeaveEvent() | |
313 | { |
|
318 | { | |
314 | // Emit signal to user of charts |
|
319 | // Emit signal to user of charts | |
315 | emit hoverLeave(); |
|
320 | emit hoverLeave(); | |
316 | } |
|
321 | } | |
317 |
|
322 | |||
318 | #include "moc_qbarset.cpp" |
|
323 | #include "moc_qbarset.cpp" | |
319 | #include "moc_qbarset_p.cpp" |
|
324 | #include "moc_qbarset_p.cpp" | |
320 |
|
325 | |||
321 | QTCOMMERCIALCHART_END_NAMESPACE |
|
326 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,79 +1,80 | |||||
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 | QBarSet(QString name, QObject *parent = 0); |
|
37 | QBarSet(QString name, QObject *parent = 0); | |
|
38 | virtual ~QBarSet(); | |||
38 |
|
39 | |||
39 | void setName(QString name); |
|
40 | void setName(QString name); | |
40 | QString name() const; |
|
41 | QString name() const; | |
41 | QBarSet& operator << (const qreal &value); // appends new value to set |
|
42 | QBarSet& operator << (const qreal &value); // appends new value to set | |
42 | void insertValue(int i, qreal value); |
|
43 | void insertValue(int i, qreal value); | |
43 | void removeValue(int i); |
|
44 | void removeValue(int i); | |
44 | int count() const; // count of values in set |
|
45 | int count() const; // count of values in set | |
45 | qreal valueAt(int index) const; // for modifying individual values |
|
46 | qreal valueAt(int index) const; // for modifying individual values | |
46 | void setValue(int index, qreal value); // setter for individual value |
|
47 | void setValue(int index, qreal value); // setter for individual value | |
47 | qreal sum() const; // sum of all values in the set |
|
48 | qreal sum() const; // sum of all values in the set | |
48 |
|
49 | |||
49 | void setPen(const QPen &pen); |
|
50 | void setPen(const QPen &pen); | |
50 | QPen pen() const; |
|
51 | QPen pen() const; | |
51 |
|
52 | |||
52 | void setBrush(const QBrush &brush); |
|
53 | void setBrush(const QBrush &brush); | |
53 | QBrush brush() const; |
|
54 | QBrush brush() const; | |
54 |
|
55 | |||
55 | void setLabelPen(const QPen &pen); |
|
56 | void setLabelPen(const QPen &pen); | |
56 | QPen labelPen() const; |
|
57 | QPen labelPen() const; | |
57 |
|
58 | |||
58 | void setLabelBrush(const QBrush &brush); |
|
59 | void setLabelBrush(const QBrush &brush); | |
59 | QBrush labelBrush() const; |
|
60 | QBrush labelBrush() const; | |
60 |
|
61 | |||
61 | void setLabelFont(const QFont &font); |
|
62 | void setLabelFont(const QFont &font); | |
62 | QFont labelFont() const; |
|
63 | QFont labelFont() const; | |
63 |
|
64 | |||
64 | void setLabelsVisible(bool visible = true); |
|
65 | void setLabelsVisible(bool visible = true); | |
65 | bool labelsVisible() const; |
|
66 | bool labelsVisible() const; | |
66 |
|
67 | |||
67 | Q_SIGNALS: |
|
68 | Q_SIGNALS: | |
68 | void clicked(QString category, Qt::MouseButtons button); // Clicked and hover signals exposed to user |
|
69 | void clicked(QString category, Qt::MouseButtons button); // Clicked and hover signals exposed to user | |
69 |
|
70 | |||
70 | private: |
|
71 | private: | |
71 | QScopedPointer<QBarSetPrivate> d_ptr; |
|
72 | QScopedPointer<QBarSetPrivate> d_ptr; | |
72 | Q_DISABLE_COPY(QBarSet) |
|
73 | Q_DISABLE_COPY(QBarSet) | |
73 | friend class QBarSeries; |
|
74 | friend class QBarSeries; | |
74 |
|
75 | |||
75 | }; |
|
76 | }; | |
76 |
|
77 | |||
77 | QTCOMMERCIALCHART_END_NAMESPACE |
|
78 | QTCOMMERCIALCHART_END_NAMESPACE | |
78 |
|
79 | |||
79 | #endif // QBARSET_H |
|
80 | #endif // QBARSET_H |
General Comments 0
You need to be logged in to leave comments.
Login now