@@ -329,7 +329,7 void QBarModelMapperPrivate::modelHeaderDataUpdated(Qt::Orientation orientation, | |||
|
329 | 329 | if (section >= m_firstBarSetSection && section <= m_lastBarSetSection) { |
|
330 | 330 | QBarSet* bar = m_series->barSets().at(section - m_firstBarSetSection); |
|
331 | 331 | if (bar) |
|
332 |
bar->set |
|
|
332 | bar->setLabel(m_model->headerData(section, orientation).toString()); | |
|
333 | 333 | } |
|
334 | 334 | } |
|
335 | 335 | } |
@@ -155,6 +155,7 void QBarSeries::setBarWidth(qreal width) | |||
|
155 | 155 | { |
|
156 | 156 | Q_D(QBarSeries); |
|
157 | 157 | d->setBarWidth(width); |
|
158 | emit barWidthChanged(); | |
|
158 | 159 | } |
|
159 | 160 | |
|
160 | 161 | /*! |
@@ -179,6 +180,7 bool QBarSeries::append(QBarSet *set) | |||
|
179 | 180 | QList<QBarSet*> sets; |
|
180 | 181 | sets.append(set); |
|
181 | 182 | emit barsetsAdded(sets); |
|
183 | emit barsetCountChanged(); | |
|
182 | 184 | } |
|
183 | 185 | return success; |
|
184 | 186 | } |
@@ -195,6 +197,7 bool QBarSeries::remove(QBarSet *set) | |||
|
195 | 197 | QList<QBarSet*> sets; |
|
196 | 198 | sets.append(set); |
|
197 | 199 | emit barsetsRemoved(sets); |
|
200 | emit barsetCountChanged(); | |
|
198 | 201 | } |
|
199 | 202 | return success; |
|
200 | 203 | } |
@@ -211,6 +214,7 bool QBarSeries::append(QList<QBarSet* > sets) | |||
|
211 | 214 | bool success = d->append(sets); |
|
212 | 215 | if (success) { |
|
213 | 216 | emit barsetsAdded(sets); |
|
217 | emit barsetCountChanged(); | |
|
214 | 218 | } |
|
215 | 219 | return success; |
|
216 | 220 | } |
@@ -228,6 +232,7 bool QBarSeries::insert(int index, QBarSet *set) | |||
|
228 | 232 | QList<QBarSet*> sets; |
|
229 | 233 | sets.append(set); |
|
230 | 234 | emit barsetsAdded(sets); |
|
235 | emit barsetCountChanged(); | |
|
231 | 236 | } |
|
232 | 237 | return success; |
|
233 | 238 | } |
@@ -242,6 +247,7 void QBarSeries::clear() | |||
|
242 | 247 | bool success = d->remove(sets); |
|
243 | 248 | if (success) { |
|
244 | 249 | emit barsetsRemoved(sets); |
|
250 | emit barsetCountChanged(); | |
|
245 | 251 | } |
|
246 | 252 | } |
|
247 | 253 |
@@ -33,9 +33,9 class QBarSeriesPrivate; | |||
|
33 | 33 | class QTCOMMERCIALCHART_EXPORT QBarSeries : public QAbstractSeries |
|
34 | 34 | { |
|
35 | 35 | Q_OBJECT |
|
36 | Q_PROPERTY(qreal barWidth READ barWidth WRITE setBarWidth) | |
|
37 | Q_PROPERTY(int count READ barsetCount) | |
|
38 | Q_PROPERTY(bool labelsVisible READ isLabelsVisible WRITE setLabelsVisible) | |
|
36 | Q_PROPERTY(qreal barWidth READ barWidth WRITE setBarWidth NOTIFY barWidthChanged) | |
|
37 | Q_PROPERTY(int count READ barsetCount NOTIFY barsetCountChanged) | |
|
38 | Q_PROPERTY(bool labelsVisible READ isLabelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged) | |
|
39 | 39 | |
|
40 | 40 | public: |
|
41 | 41 | explicit QBarSeries(QObject *parent = 0); |
@@ -63,6 +63,8 protected: | |||
|
63 | 63 | Q_SIGNALS: |
|
64 | 64 | void clicked(QBarSet *barset, int index); |
|
65 | 65 | void hovered(QBarSet* barset, bool status); |
|
66 | void barWidthChanged(); | |
|
67 | void barsetCountChanged(); | |
|
66 | 68 | void labelsVisibleChanged(); |
|
67 | 69 | |
|
68 | 70 | void barsetsAdded(QList<QBarSet*> sets); |
@@ -38,8 +38,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
38 | 38 | */ |
|
39 | 39 | |
|
40 | 40 | /*! |
|
41 |
\property QBarSet:: |
|
|
42 |
\brief Defines the |
|
|
41 | \property QBarSet::label | |
|
42 | \brief Defines the label of the barSet. | |
|
43 | 43 | */ |
|
44 | 44 | |
|
45 | 45 | /*! |
@@ -63,11 +63,11 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
63 | 63 | */ |
|
64 | 64 | |
|
65 | 65 | /*! |
|
66 |
\fn void QBarSet:: |
|
|
66 | \fn void QBarSet::labelChanged() | |
|
67 | 67 | |
|
68 |
This signal is emitted when the |
|
|
68 | This signal is emitted when the label of the barSet has changed. | |
|
69 | 69 | |
|
70 |
\sa |
|
|
70 | \sa label | |
|
71 | 71 | */ |
|
72 | 72 | |
|
73 | 73 | /*! |
@@ -87,12 +87,6 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
87 | 87 | */ |
|
88 | 88 | |
|
89 | 89 | /*! |
|
90 | \fn void QBarSet::labelChanged() | |
|
91 | ||
|
92 | This signal is emitted when the label of the barSet has changed. | |
|
93 | */ | |
|
94 | ||
|
95 | /*! | |
|
96 | 90 | \fn void QBarSet::labelBrushChanged() |
|
97 | 91 | |
|
98 | 92 | This signal is emitted when the brush of the barSet's label has changed. |
@@ -139,11 +133,11 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
139 | 133 | void valueChanged(int index); |
|
140 | 134 | |
|
141 | 135 | /*! |
|
142 |
Constructs QBarSet with a |
|
|
136 | Constructs QBarSet with a label of \a label and with parent of \a parent | |
|
143 | 137 | */ |
|
144 |
QBarSet::QBarSet(const QString |
|
|
138 | QBarSet::QBarSet(const QString label, QObject *parent) | |
|
145 | 139 | : QObject(parent) |
|
146 |
,d_ptr(new QBarSetPrivate( |
|
|
140 | ,d_ptr(new QBarSetPrivate(label,this)) | |
|
147 | 141 | { |
|
148 | 142 | } |
|
149 | 143 | |
@@ -156,20 +150,20 QBarSet::~QBarSet() | |||
|
156 | 150 | } |
|
157 | 151 | |
|
158 | 152 | /*! |
|
159 |
Sets new \a |
|
|
153 | Sets new \a label for set. | |
|
160 | 154 | */ |
|
161 |
void QBarSet::set |
|
|
155 | void QBarSet::setLabel(const QString label) | |
|
162 | 156 | { |
|
163 |
d_ptr->m_ |
|
|
164 |
emit |
|
|
157 | d_ptr->m_label = label; | |
|
158 | emit labelChanged(); | |
|
165 | 159 | } |
|
166 | 160 | |
|
167 | 161 | /*! |
|
168 |
Returns |
|
|
162 | Returns label of the set. | |
|
169 | 163 | */ |
|
170 |
QString QBarSet:: |
|
|
164 | QString QBarSet::label() const | |
|
171 | 165 | { |
|
172 |
return d_ptr->m_ |
|
|
166 | return d_ptr->m_label; | |
|
173 | 167 | } |
|
174 | 168 | |
|
175 | 169 | /*! |
@@ -421,9 +415,9 QFont QBarSet::labelFont() const | |||
|
421 | 415 | |
|
422 | 416 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
423 | 417 | |
|
424 |
QBarSetPrivate::QBarSetPrivate(const QString |
|
|
418 | QBarSetPrivate::QBarSetPrivate(const QString label, QBarSet *parent) : QObject(parent), | |
|
425 | 419 | q_ptr(parent), |
|
426 |
m_ |
|
|
420 | m_label(label) | |
|
427 | 421 | { |
|
428 | 422 | } |
|
429 | 423 |
@@ -32,18 +32,18 class QBarSetPrivate; | |||
|
32 | 32 | class QTCOMMERCIALCHART_EXPORT QBarSet : public QObject |
|
33 | 33 | { |
|
34 | 34 | Q_OBJECT |
|
35 |
Q_PROPERTY(QString |
|
|
36 | Q_PROPERTY(QPen pen READ pen WRITE setPen) | |
|
37 | Q_PROPERTY(QBrush brush READ brush WRITE setBrush) | |
|
38 | Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush) | |
|
39 | Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont) | |
|
35 | Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) | |
|
36 | Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged) | |
|
37 | Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged) | |
|
38 | Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush NOTIFY labelBrushChanged) | |
|
39 | Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont NOTIFY labelFontChanged) | |
|
40 | 40 | |
|
41 | 41 | public: |
|
42 |
explicit QBarSet(const QString |
|
|
42 | explicit QBarSet(const QString label, QObject *parent = 0); | |
|
43 | 43 | virtual ~QBarSet(); |
|
44 | 44 | |
|
45 |
void set |
|
|
46 |
QString |
|
|
45 | void setLabel(const QString label); | |
|
46 | QString label() const; | |
|
47 | 47 | |
|
48 | 48 | void append(const QPointF value); |
|
49 | 49 | void append(const QList<QPointF> values); |
@@ -76,7 +76,6 public: | |||
|
76 | 76 | QFont labelFont() const; |
|
77 | 77 | |
|
78 | 78 | Q_SIGNALS: |
|
79 | void nameChanged(); | |
|
80 | 79 | void penChanged(); |
|
81 | 80 | void brushChanged(); |
|
82 | 81 | void labelChanged(); |
@@ -43,7 +43,7 class QBarSetPrivate : public QObject | |||
|
43 | 43 | Q_OBJECT |
|
44 | 44 | |
|
45 | 45 | public: |
|
46 |
QBarSetPrivate(const QString |
|
|
46 | QBarSetPrivate(const QString label, QBarSet *parent); | |
|
47 | 47 | ~QBarSetPrivate(); |
|
48 | 48 | |
|
49 | 49 | void append(QPointF value); |
@@ -63,7 +63,7 Q_SIGNALS: | |||
|
63 | 63 | |
|
64 | 64 | public: |
|
65 | 65 | QBarSet * const q_ptr; |
|
66 |
QString m_ |
|
|
66 | QString m_label; | |
|
67 | 67 | QList<QPointF> m_values; |
|
68 | 68 | QPen m_pen; |
|
69 | 69 | QBrush m_brush; |
@@ -71,9 +71,9 QBrush LegendMarker::brush() const | |||
|
71 | 71 | return m_rectItem->brush(); |
|
72 | 72 | } |
|
73 | 73 | |
|
74 |
void LegendMarker::setLabel(const QString |
|
|
74 | void LegendMarker::setLabel(const QString label) | |
|
75 | 75 | { |
|
76 |
m_textItem->setText( |
|
|
76 | m_textItem->setText(label); | |
|
77 | 77 | updateLayout(); |
|
78 | 78 | } |
|
79 | 79 | |
@@ -149,7 +149,7 m_barset(barset) | |||
|
149 | 149 | void BarLegendMarker::updated() |
|
150 | 150 | { |
|
151 | 151 | setBrush(m_barset->brush()); |
|
152 |
setLabel(m_barset-> |
|
|
152 | setLabel(m_barset->label()); | |
|
153 | 153 | } |
|
154 | 154 | |
|
155 | 155 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
@@ -38,8 +38,8 public slots: | |||
|
38 | 38 | private slots: |
|
39 | 39 | void qbarset_data(); |
|
40 | 40 | void qbarset(); |
|
41 |
void |
|
|
42 |
void |
|
|
41 | void label_data(); | |
|
42 | void label(); | |
|
43 | 43 | void append_data(); |
|
44 | 44 | void append(); |
|
45 | 45 | void appendOperator_data(); |
@@ -74,7 +74,7 void tst_QBarSet::cleanupTestCase() | |||
|
74 | 74 | |
|
75 | 75 | void tst_QBarSet::init() |
|
76 | 76 | { |
|
77 |
m_barset = new QBarSet(QString(" |
|
|
77 | m_barset = new QBarSet(QString("label")); | |
|
78 | 78 | } |
|
79 | 79 | |
|
80 | 80 | void tst_QBarSet::cleanup() |
@@ -89,29 +89,29 void tst_QBarSet::qbarset_data() | |||
|
89 | 89 | |
|
90 | 90 | void tst_QBarSet::qbarset() |
|
91 | 91 | { |
|
92 |
QBarSet barset(QString(" |
|
|
93 |
QCOMPARE(barset. |
|
|
92 | QBarSet barset(QString("label")); | |
|
93 | QCOMPARE(barset.label(), QString("label")); | |
|
94 | 94 | QCOMPARE(barset.count(), 0); |
|
95 | 95 | QVERIFY(qFuzzyIsNull(barset.sum())); |
|
96 | 96 | } |
|
97 | 97 | |
|
98 |
void tst_QBarSet:: |
|
|
98 | void tst_QBarSet::label_data() | |
|
99 | 99 | { |
|
100 |
QTest::addColumn<QString> (" |
|
|
100 | QTest::addColumn<QString> ("label"); | |
|
101 | 101 | QTest::addColumn<QString> ("result"); |
|
102 |
QTest::newRow(" |
|
|
103 |
QTest::newRow(" |
|
|
102 | QTest::newRow("label0") << QString("label0") << QString("label0"); | |
|
103 | QTest::newRow("label1") << QString("label1") << QString("label1"); | |
|
104 | 104 | } |
|
105 | 105 | |
|
106 |
void tst_QBarSet:: |
|
|
106 | void tst_QBarSet::label() | |
|
107 | 107 | { |
|
108 |
QFETCH(QString, |
|
|
108 | QFETCH(QString, label); | |
|
109 | 109 | QFETCH(QString, result); |
|
110 | 110 | |
|
111 |
QSignalSpy |
|
|
112 |
m_barset->set |
|
|
113 |
QCOMPARE(m_barset-> |
|
|
114 |
QVERIFY( |
|
|
111 | QSignalSpy labelSpy(m_barset,SIGNAL(labelChanged())); | |
|
112 | m_barset->setLabel(label); | |
|
113 | QCOMPARE(m_barset->label(), result); | |
|
114 | QVERIFY(labelSpy.count() == 1); | |
|
115 | 115 | } |
|
116 | 116 | |
|
117 | 117 | void tst_QBarSet::append_data() |
General Comments 0
You need to be logged in to leave comments.
Login now