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