##// END OF EJS Templates
Removed unnecessary signals from QPieSlice
Tero Ahola -
r1494:0e4d11fde6b8
parent child
Show More
@@ -138,18 +138,20 void PieChartItem::handleSlicesAdded(QList<QPieSlice*> slices)
138 PieSliceItem* sliceItem = new PieSliceItem(this);
138 PieSliceItem* sliceItem = new PieSliceItem(this);
139 m_sliceItems.insert(slice, sliceItem);
139 m_sliceItems.insert(slice, sliceItem);
140
140
141 // Note: do need to connect to slice valueChanged() etc.
141 // Note: no need to connect to slice valueChanged() etc.
142 // This is handled through calculatedDataChanged signal.
142 // This is handled through calculatedDataChanged signal.
143 connect(slice, SIGNAL(labelChanged()), this, SLOT(handleSliceChanged()));
143 connect(slice, SIGNAL(labelChanged()), this, SLOT(handleSliceChanged()));
144 connect(slice, SIGNAL(labelVisibleChanged()), this, SLOT(handleSliceChanged()));
144 connect(slice, SIGNAL(labelVisibleChanged()), this, SLOT(handleSliceChanged()));
145 connect(slice, SIGNAL(explodedChanged()), this, SLOT(handleSliceChanged()));
146 connect(slice, SIGNAL(penChanged()), this, SLOT(handleSliceChanged()));
145 connect(slice, SIGNAL(penChanged()), this, SLOT(handleSliceChanged()));
147 connect(slice, SIGNAL(brushChanged()), this, SLOT(handleSliceChanged()));
146 connect(slice, SIGNAL(brushChanged()), this, SLOT(handleSliceChanged()));
148 connect(slice, SIGNAL(labelBrushChanged()), this, SLOT(handleSliceChanged()));
147 connect(slice, SIGNAL(labelBrushChanged()), this, SLOT(handleSliceChanged()));
149 connect(slice, SIGNAL(labelFontChanged()), this, SLOT(handleSliceChanged()));
148 connect(slice, SIGNAL(labelFontChanged()), this, SLOT(handleSliceChanged()));
150 connect(slice, SIGNAL(labelPositionChanged()), this, SLOT(handleSliceChanged()));
149
151 connect(slice, SIGNAL(labelArmLengthFactorChanged()), this, SLOT(handleSliceChanged()));
150 QPieSlicePrivate *p = QPieSlicePrivate::fromSlice(slice);
152 connect(slice, SIGNAL(explodeDistanceFactorChanged()), this, SLOT(handleSliceChanged()));
151 connect(p, SIGNAL(labelPositionChanged()), this, SLOT(handleSliceChanged()));
152 connect(p, SIGNAL(explodedChanged()), this, SLOT(handleSliceChanged()));
153 connect(p, SIGNAL(labelArmLengthFactorChanged()), this, SLOT(handleSliceChanged()));
154 connect(p, SIGNAL(explodeDistanceFactorChanged()), this, SLOT(handleSliceChanged()));
153
155
154 connect(sliceItem, SIGNAL(clicked(Qt::MouseButtons)), slice, SIGNAL(clicked()));
156 connect(sliceItem, SIGNAL(clicked(Qt::MouseButtons)), slice, SIGNAL(clicked()));
155 connect(sliceItem, SIGNAL(hovered(bool)), slice, SIGNAL(hovered(bool)));
157 connect(sliceItem, SIGNAL(hovered(bool)), slice, SIGNAL(hovered(bool)));
@@ -186,6 +188,10 void PieChartItem::handleSlicesRemoved(QList<QPieSlice*> slices)
186 void PieChartItem::handleSliceChanged()
188 void PieChartItem::handleSliceChanged()
187 {
189 {
188 QPieSlice* slice = qobject_cast<QPieSlice *>(sender());
190 QPieSlice* slice = qobject_cast<QPieSlice *>(sender());
191 if (!slice) {
192 QPieSlicePrivate* slicep = qobject_cast<QPieSlicePrivate *>(sender());
193 slice = slicep->q_ptr;
194 }
189 Q_ASSERT(m_sliceItems.contains(slice));
195 Q_ASSERT(m_sliceItems.contains(slice));
190
196
191 PieSliceItem *sliceItem = m_sliceItems.value(slice);
197 PieSliceItem *sliceItem = m_sliceItems.value(slice);
@@ -140,17 +140,6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
140 */
140 */
141
141
142 /*!
142 /*!
143 \fn void QPieSlice::explodedChanged()
144 This signal is emitted the the slice has been exploded from the pie or is returned back to the pie.
145 \sa exploded
146 */
147 /*!
148 \qmlsignal PieSlice::explodedChanged()
149 This signal is emitted the the slice has been exploded from the pie or is returned back to the pie.
150 \sa exploded
151 */
152
153 /*!
154 \property QPieSlice::pen
143 \property QPieSlice::pen
155 Pen used to draw the slice border.
144 Pen used to draw the slice border.
156 */
145 */
@@ -298,17 +287,6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
298 */
287 */
299
288
300 /*!
289 /*!
301 \fn void QPieSlice::labelPositionChanged()
302 This signal is emitted when the label position of the slice has changed.
303 \sa labelPosition
304 */
305 /*!
306 \qmlsignal PieSlice::labelPositionChanged()
307 This signal is emitted when the label position of the slice has changed.
308 \sa labelPosition
309 */
310
311 /*!
312 \property QPieSlice::labelArmLengthFactor
290 \property QPieSlice::labelArmLengthFactor
313 Defines the length of the label arm.
291 Defines the length of the label arm.
314 The factor is relative to pie radius. For example:
292 The factor is relative to pie radius. For example:
@@ -328,17 +306,6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
328 */
306 */
329
307
330 /*!
308 /*!
331 \fn void QPieSlice::labelArmLengthFactorChanged()
332 This signal is emitted when the label arm factor of the slice has changed.
333 \sa labelArmLengthFactor
334 */
335 /*!
336 \qmlsignal PieSlice::labelArmLengthFactorChanged()
337 This signal is emitted when the label arm factor of the slice has changed.
338 \sa labelArmLengthFactor
339 */
340
341 /*!
342 \property QPieSlice::explodeDistanceFactor
309 \property QPieSlice::explodeDistanceFactor
343 When the slice is exploded this factor defines how far the slice is exploded away from the pie.
310 When the slice is exploded this factor defines how far the slice is exploded away from the pie.
344 The factor is relative to pie radius. For example:
311 The factor is relative to pie radius. For example:
@@ -358,17 +325,6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
358 */
325 */
359
326
360 /*!
327 /*!
361 \fn void QPieSlice::explodeDistanceFactorChanged()
362 This signal is emitted when the explode distance factor of the slice has changed.
363 \sa explodeDistanceFactor
364 */
365 /*!
366 \qmlsignal PieSlice::explodeDistanceFactorChanged()
367 This signal is emitted when the explode distance factor of the slice has changed.
368 \sa explodeDistanceFactor
369 */
370
371 /*!
372 \property QPieSlice::percentage
328 \property QPieSlice::percentage
373 Percentage of the slice compared to the sum of all slices in the series.
329 Percentage of the slice compared to the sum of all slices in the series.
374 The actual value ranges from 0.0 to 1.0.
330 The actual value ranges from 0.0 to 1.0.
@@ -539,7 +495,7 void QPieSlice::setExploded(bool exploded)
539 {
495 {
540 if (d_ptr->m_data.m_isExploded != exploded) {
496 if (d_ptr->m_data.m_isExploded != exploded) {
541 d_ptr->m_data.m_isExploded = exploded;
497 d_ptr->m_data.m_isExploded = exploded;
542 emit explodedChanged();
498 emit d_ptr->explodedChanged();
543 }
499 }
544 }
500 }
545
501
@@ -552,7 +508,7 void QPieSlice::setLabelPosition(LabelPosition position)
552 {
508 {
553 if (d_ptr->m_data.m_labelPosition != position) {
509 if (d_ptr->m_data.m_labelPosition != position) {
554 d_ptr->m_data.m_labelPosition = position;
510 d_ptr->m_data.m_labelPosition = position;
555 emit labelPositionChanged();
511 emit d_ptr->labelPositionChanged();
556 }
512 }
557 }
513 }
558
514
@@ -661,7 +617,7 void QPieSlice::setLabelArmLengthFactor(qreal factor)
661 {
617 {
662 if (!qFuzzyIsNull(d_ptr->m_data.m_labelArmLengthFactor - factor)) {
618 if (!qFuzzyIsNull(d_ptr->m_data.m_labelArmLengthFactor - factor)) {
663 d_ptr->m_data.m_labelArmLengthFactor = factor;
619 d_ptr->m_data.m_labelArmLengthFactor = factor;
664 emit labelArmLengthFactorChanged();
620 emit d_ptr->labelArmLengthFactorChanged();
665 }
621 }
666 }
622 }
667
623
@@ -674,7 +630,7 void QPieSlice::setExplodeDistanceFactor(qreal factor)
674 {
630 {
675 if (!qFuzzyIsNull(d_ptr->m_data.m_explodeDistanceFactor - factor)) {
631 if (!qFuzzyIsNull(d_ptr->m_data.m_explodeDistanceFactor - factor)) {
676 d_ptr->m_data.m_explodeDistanceFactor = factor;
632 d_ptr->m_data.m_explodeDistanceFactor = factor;
677 emit explodeDistanceFactorChanged();
633 emit d_ptr->explodeDistanceFactorChanged();
678 }
634 }
679 }
635 }
680
636
@@ -38,8 +38,8 class QTCOMMERCIALCHART_EXPORT QPieSlice : public QObject
38 Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged)
38 Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged)
39 Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged)
39 Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged)
40 Q_PROPERTY(bool labelVisible READ isLabelVisible WRITE setLabelVisible NOTIFY labelVisibleChanged)
40 Q_PROPERTY(bool labelVisible READ isLabelVisible WRITE setLabelVisible NOTIFY labelVisibleChanged)
41 Q_PROPERTY(LabelPosition labelPosition READ labelPosition WRITE setLabelPosition NOTIFY labelPositionChanged)
41 Q_PROPERTY(LabelPosition labelPosition READ labelPosition WRITE setLabelPosition)
42 Q_PROPERTY(bool exploded READ isExploded WRITE setExploded NOTIFY explodedChanged)
42 Q_PROPERTY(bool exploded READ isExploded WRITE setExploded)
43 Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged)
43 Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged)
44 Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged)
44 Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged)
45 Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged)
45 Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged)
@@ -48,8 +48,8 class QTCOMMERCIALCHART_EXPORT QPieSlice : public QObject
48 Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush NOTIFY labelBrushChanged)
48 Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush NOTIFY labelBrushChanged)
49 Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor NOTIFY labelColorChanged)
49 Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor NOTIFY labelColorChanged)
50 Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont NOTIFY labelFontChanged)
50 Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont NOTIFY labelFontChanged)
51 Q_PROPERTY(qreal labelArmLengthFactor READ labelArmLengthFactor WRITE setLabelArmLengthFactor NOTIFY labelArmLengthFactorChanged)
51 Q_PROPERTY(qreal labelArmLengthFactor READ labelArmLengthFactor WRITE setLabelArmLengthFactor)
52 Q_PROPERTY(qreal explodeDistanceFactor READ explodeDistanceFactor WRITE setExplodeDistanceFactor NOTIFY explodeDistanceFactorChanged)
52 Q_PROPERTY(qreal explodeDistanceFactor READ explodeDistanceFactor WRITE setExplodeDistanceFactor)
53 Q_PROPERTY(qreal percentage READ percentage NOTIFY percentageChanged)
53 Q_PROPERTY(qreal percentage READ percentage NOTIFY percentageChanged)
54 Q_PROPERTY(qreal startAngle READ startAngle NOTIFY startAngleChanged)
54 Q_PROPERTY(qreal startAngle READ startAngle NOTIFY startAngleChanged)
55 Q_PROPERTY(qreal angleSpan READ angleSpan NOTIFY angleSpanChanged)
55 Q_PROPERTY(qreal angleSpan READ angleSpan NOTIFY angleSpanChanged)
@@ -117,17 +117,15 public:
117 QPieSeries *series() const;
117 QPieSeries *series() const;
118
118
119 Q_SIGNALS:
119 Q_SIGNALS:
120 void clicked();
121 void hovered(bool state);
120 void labelChanged();
122 void labelChanged();
121 void valueChanged();
123 void valueChanged();
122 void labelVisibleChanged();
124 void labelVisibleChanged();
123 void labelPositionChanged();
124 void explodedChanged();
125 void penChanged();
125 void penChanged();
126 void brushChanged();
126 void brushChanged();
127 void labelBrushChanged();
127 void labelBrushChanged();
128 void labelFontChanged();
128 void labelFontChanged();
129 void labelArmLengthFactorChanged();
130 void explodeDistanceFactorChanged();
131 void percentageChanged();
129 void percentageChanged();
132 void startAngleChanged();
130 void startAngleChanged();
133 void angleSpanChanged();
131 void angleSpanChanged();
@@ -135,8 +133,6 Q_SIGNALS:
135 void borderColorChanged();
133 void borderColorChanged();
136 void borderWidthChanged();
134 void borderWidthChanged();
137 void labelColorChanged();
135 void labelColorChanged();
138 void clicked();
139 void hovered(bool state);
140
136
141 private:
137 private:
142 QPieSlicePrivate * const d_ptr;
138 QPieSlicePrivate * const d_ptr;
@@ -56,6 +56,12 public:
56 void setStartAngle(qreal angle);
56 void setStartAngle(qreal angle);
57 void setAngleSpan(qreal span);
57 void setAngleSpan(qreal span);
58
58
59 Q_SIGNALS:
60 void labelPositionChanged();
61 void explodedChanged();
62 void labelArmLengthFactorChanged();
63 void explodeDistanceFactorChanged();
64
59 private:
65 private:
60 friend class QPieSeries;
66 friend class QPieSeries;
61 friend class QPieSeriesPrivate;
67 friend class QPieSeriesPrivate;
@@ -110,14 +110,10 void tst_qpieslice::changedSignals()
110
110
111 QSignalSpy valueSpy(&slice, SIGNAL(valueChanged()));
111 QSignalSpy valueSpy(&slice, SIGNAL(valueChanged()));
112 QSignalSpy labelSpy(&slice, SIGNAL(labelChanged()));
112 QSignalSpy labelSpy(&slice, SIGNAL(labelChanged()));
113 QSignalSpy explodedSpy(&slice, SIGNAL(explodedChanged()));
114 QSignalSpy penSpy(&slice, SIGNAL(penChanged()));
113 QSignalSpy penSpy(&slice, SIGNAL(penChanged()));
115 QSignalSpy brushSpy(&slice, SIGNAL(brushChanged()));
114 QSignalSpy brushSpy(&slice, SIGNAL(brushChanged()));
116 QSignalSpy labelBrushSpy(&slice, SIGNAL(labelBrushChanged()));
115 QSignalSpy labelBrushSpy(&slice, SIGNAL(labelBrushChanged()));
117 QSignalSpy labelFontSpy(&slice, SIGNAL(labelFontChanged()));
116 QSignalSpy labelFontSpy(&slice, SIGNAL(labelFontChanged()));
118 QSignalSpy labelPositionSpy(&slice, SIGNAL(labelPositionChanged()));
119 QSignalSpy labelArmLengthFactorSpy(&slice, SIGNAL(labelArmLengthFactorChanged()));
120 QSignalSpy explodeDistanceFactorSpy(&slice, SIGNAL(explodeDistanceFactorChanged()));
121 QSignalSpy colorSpy(&slice, SIGNAL(colorChanged()));
117 QSignalSpy colorSpy(&slice, SIGNAL(colorChanged()));
122 QSignalSpy borderColorSpy(&slice, SIGNAL(borderColorChanged()));
118 QSignalSpy borderColorSpy(&slice, SIGNAL(borderColorChanged()));
123 QSignalSpy borderWidthSpy(&slice, SIGNAL(borderWidthChanged()));
119 QSignalSpy borderWidthSpy(&slice, SIGNAL(borderWidthChanged()));
@@ -152,14 +148,10 void tst_qpieslice::changedSignals()
152
148
153 TRY_COMPARE(valueSpy.count(), 1);
149 TRY_COMPARE(valueSpy.count(), 1);
154 TRY_COMPARE(labelSpy.count(), 1);
150 TRY_COMPARE(labelSpy.count(), 1);
155 TRY_COMPARE(explodedSpy.count(), 1);
156 TRY_COMPARE(penSpy.count(), 2);
151 TRY_COMPARE(penSpy.count(), 2);
157 TRY_COMPARE(brushSpy.count(), 1);
152 TRY_COMPARE(brushSpy.count(), 1);
158 TRY_COMPARE(labelBrushSpy.count(), 1);
153 TRY_COMPARE(labelBrushSpy.count(), 1);
159 TRY_COMPARE(labelFontSpy.count(), 1);
154 TRY_COMPARE(labelFontSpy.count(), 1);
160 TRY_COMPARE(labelPositionSpy.count(), 1);
161 TRY_COMPARE(labelArmLengthFactorSpy.count(), 1);
162 TRY_COMPARE(explodeDistanceFactorSpy.count(), 1);
163 TRY_COMPARE(colorSpy.count(), 1);
155 TRY_COMPARE(colorSpy.count(), 1);
164 TRY_COMPARE(borderColorSpy.count(), 1);
156 TRY_COMPARE(borderColorSpy.count(), 1);
165 TRY_COMPARE(borderWidthSpy.count(), 1);
157 TRY_COMPARE(borderWidthSpy.count(), 1);
@@ -50,8 +50,6 Flow {
50 target: null
50 target: null
51 onValueChanged: console.log("slice.onValueChanged: " + series.at(0).value);
51 onValueChanged: console.log("slice.onValueChanged: " + series.at(0).value);
52 onLabelVisibleChanged: console.log("slice.onLabelVisibleChanged: " + series.at(0).labelVisible);
52 onLabelVisibleChanged: console.log("slice.onLabelVisibleChanged: " + series.at(0).labelVisible);
53 onLabelPositionChanged: console.log("slice.onLabelPositionChanged: " + series.at(0).labelPosition);
54 onExplodedChanged: console.log("slice.onExplodedChanged: " + series.at(0).exploded);
55 onPenChanged: console.log("slice.onPenChanged: " + series.at(0).pen);
53 onPenChanged: console.log("slice.onPenChanged: " + series.at(0).pen);
56 onBorderColorChanged: console.log("slice.onBorderColorChanged: " + series.at(0).borderColor);
54 onBorderColorChanged: console.log("slice.onBorderColorChanged: " + series.at(0).borderColor);
57 onBorderWidthChanged: console.log("slice.onBorderWidthChanged: " + series.at(0).borderWidth);
55 onBorderWidthChanged: console.log("slice.onBorderWidthChanged: " + series.at(0).borderWidth);
@@ -60,8 +58,6 Flow {
60 onLabelColorChanged: console.log("slice.onLabelColorChanged: " + series.at(0).labelColor);
58 onLabelColorChanged: console.log("slice.onLabelColorChanged: " + series.at(0).labelColor);
61 onLabelBrushChanged: console.log("slice.onLabelBrushChanged: " + series.at(0).labelBrush);
59 onLabelBrushChanged: console.log("slice.onLabelBrushChanged: " + series.at(0).labelBrush);
62 onLabelFontChanged: console.log("slice.onLabelFontChanged: " + series.at(0).labelFont);
60 onLabelFontChanged: console.log("slice.onLabelFontChanged: " + series.at(0).labelFont);
63 onLabelArmLengthFactorChanged: console.log("slice.onLabelArmLengthFactorChanged: " + series.at(0).labelArmLengthFactor);
64 onExplodeDistanceFactorChanged: console.log("slice.onExplodeDistanceFactorChanged: " + series.at(0).explodeDistanceFactor);
65 onPercentageChanged: console.log("slice.onPercentageChanged: " + series.at(0).percentage);
61 onPercentageChanged: console.log("slice.onPercentageChanged: " + series.at(0).percentage);
66 onStartAngleChanged: console.log("slice.onStartAngleChanged: " + series.at(0).startAngle);
62 onStartAngleChanged: console.log("slice.onStartAngleChanged: " + series.at(0).startAngle);
67 onAngleSpanChanged: console.log("slice.onAngleSpanChanged: " + series.at(0).angleSpan);
63 onAngleSpanChanged: console.log("slice.onAngleSpanChanged: " + series.at(0).angleSpan);
General Comments 0
You need to be logged in to leave comments. Login now