@@ -38,13 +38,14 PieChartItem::PieChartItem(QPieSeries *series, ChartPresenter* presenter) | |||||
38 | { |
|
38 | { | |
39 | Q_ASSERT(series); |
|
39 | Q_ASSERT(series); | |
40 |
|
40 | |||
|
41 | QPieSeriesPrivate *p = QPieSeriesPrivate::fromSeries(series); | |||
41 | connect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged())); |
|
42 | connect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged())); | |
42 | connect(series, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleSlicesAdded(QList<QPieSlice*>))); |
|
43 | connect(series, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleSlicesAdded(QList<QPieSlice*>))); | |
43 | connect(series, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleSlicesRemoved(QList<QPieSlice*>))); |
|
44 | connect(series, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleSlicesRemoved(QList<QPieSlice*>))); | |
44 |
connect( |
|
45 | connect(p, SIGNAL(horizontalPositionChanged()), this, SLOT(updateLayout())); | |
45 |
connect( |
|
46 | connect(p, SIGNAL(verticalPositionChanged()), this, SLOT(updateLayout())); | |
46 |
connect( |
|
47 | connect(p, SIGNAL(pieSizeChanged()), this, SLOT(updateLayout())); | |
47 |
connect( |
|
48 | connect(p, SIGNAL(calculatedDataChanged()), this, SLOT(updateLayout())); | |
48 |
|
49 | |||
49 | // Note: the following does not affect as long as the item does not have anything to paint |
|
50 | // Note: the following does not affect as long as the item does not have anything to paint | |
50 | setZValue(ChartPresenter::PieSeriesZValue); |
|
51 | setZValue(ChartPresenter::PieSeriesZValue); |
@@ -66,14 +66,6 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
66 | */ |
|
66 | */ | |
67 |
|
67 | |||
68 | /*! |
|
68 | /*! | |
69 | \fn void QPieSeries::horizontalPositionChanged() |
|
|||
70 |
|
||||
71 | Emitted then the horizontal position of the pie has changed. |
|
|||
72 |
|
||||
73 | \sa horizontalPosition |
|
|||
74 | */ |
|
|||
75 |
|
||||
76 | /*! |
|
|||
77 | \property QPieSeries::verticalPosition |
|
69 | \property QPieSeries::verticalPosition | |
78 | \brief Defines the vertical position of the pie. |
|
70 | \brief Defines the vertical position of the pie. | |
79 |
|
71 | |||
@@ -90,14 +82,6 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
90 | */ |
|
82 | */ | |
91 |
|
83 | |||
92 | /*! |
|
84 | /*! | |
93 | \fn void QPieSeries::verticalPositionChanged() |
|
|||
94 |
|
||||
95 | Emitted then the vertical position of the pie has changed. |
|
|||
96 |
|
||||
97 | \sa verticalPosition |
|
|||
98 | */ |
|
|||
99 |
|
||||
100 | /*! |
|
|||
101 | \property QPieSeries::size |
|
85 | \property QPieSeries::size | |
102 | \brief Defines the pie size. |
|
86 | \brief Defines the pie size. | |
103 |
|
87 | |||
@@ -112,14 +96,6 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
112 | */ |
|
96 | */ | |
113 |
|
97 | |||
114 | /*! |
|
98 | /*! | |
115 | \fn void QPieSeries::pieSizeChanged() |
|
|||
116 |
|
||||
117 | Emitted when the pie size has changed. |
|
|||
118 |
|
||||
119 | \sa size |
|
|||
120 | */ |
|
|||
121 |
|
||||
122 | /*! |
|
|||
123 | \property QPieSeries::startAngle |
|
99 | \property QPieSeries::startAngle | |
124 | \brief Defines the starting angle of the pie. |
|
100 | \brief Defines the starting angle of the pie. | |
125 |
|
101 | |||
@@ -129,14 +105,6 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
129 | */ |
|
105 | */ | |
130 |
|
106 | |||
131 | /*! |
|
107 | /*! | |
132 | \fn void QPieSeries::pieStartAngleChanged() |
|
|||
133 |
|
||||
134 | Emitted when the starting angle of the pie has changed. |
|
|||
135 |
|
||||
136 | \sa startAngle |
|
|||
137 | */ |
|
|||
138 |
|
||||
139 | /*! |
|
|||
140 | \property QPieSeries::endAngle |
|
108 | \property QPieSeries::endAngle | |
141 | \brief Defines the ending angle of the pie. |
|
109 | \brief Defines the ending angle of the pie. | |
142 |
|
110 | |||
@@ -146,14 +114,6 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
146 | */ |
|
114 | */ | |
147 |
|
115 | |||
148 | /*! |
|
116 | /*! | |
149 | \fn void QPieSeries::pieEndAngleChanged() |
|
|||
150 |
|
||||
151 | Emitted when the ending angle of the pie has changed. |
|
|||
152 |
|
||||
153 | \sa endAngle |
|
|||
154 | */ |
|
|||
155 |
|
||||
156 | /*! |
|
|||
157 | \property QPieSeries::count |
|
117 | \property QPieSeries::count | |
158 |
|
118 | |||
159 | Number of slices in the series. |
|
119 | Number of slices in the series. | |
@@ -445,7 +405,7 void QPieSeries::setHorizontalPosition(qreal relativePosition) | |||||
445 |
|
405 | |||
446 | if (!qFuzzyIsNull(d->m_pieRelativeHorPos - relativePosition)) { |
|
406 | if (!qFuzzyIsNull(d->m_pieRelativeHorPos - relativePosition)) { | |
447 | d->m_pieRelativeHorPos = relativePosition; |
|
407 | d->m_pieRelativeHorPos = relativePosition; | |
448 | emit horizontalPositionChanged(); |
|
408 | emit d->horizontalPositionChanged(); | |
449 | } |
|
409 | } | |
450 | } |
|
410 | } | |
451 |
|
411 | |||
@@ -466,7 +426,7 void QPieSeries::setVerticalPosition(qreal relativePosition) | |||||
466 |
|
426 | |||
467 | if (!qFuzzyIsNull(d->m_pieRelativeVerPos - relativePosition)) { |
|
427 | if (!qFuzzyIsNull(d->m_pieRelativeVerPos - relativePosition)) { | |
468 | d->m_pieRelativeVerPos = relativePosition; |
|
428 | d->m_pieRelativeVerPos = relativePosition; | |
469 | emit verticalPositionChanged(); |
|
429 | emit d->verticalPositionChanged(); | |
470 | } |
|
430 | } | |
471 | } |
|
431 | } | |
472 |
|
432 | |||
@@ -487,7 +447,7 void QPieSeries::setPieSize(qreal relativeSize) | |||||
487 |
|
447 | |||
488 | if (!qFuzzyIsNull(d->m_pieRelativeSize - relativeSize)) { |
|
448 | if (!qFuzzyIsNull(d->m_pieRelativeSize - relativeSize)) { | |
489 | d->m_pieRelativeSize = relativeSize; |
|
449 | d->m_pieRelativeSize = relativeSize; | |
490 | emit pieSizeChanged(); |
|
450 | emit d->pieSizeChanged(); | |
491 | } |
|
451 | } | |
492 | } |
|
452 | } | |
493 |
|
453 | |||
@@ -505,7 +465,7 void QPieSeries::setPieStartAngle(qreal angle) | |||||
505 | return; |
|
465 | return; | |
506 | d->m_pieStartAngle = angle; |
|
466 | d->m_pieStartAngle = angle; | |
507 | d->updateDerivativeData(); |
|
467 | d->updateDerivativeData(); | |
508 | emit pieStartAngleChanged(); |
|
468 | emit d->pieStartAngleChanged(); | |
509 | } |
|
469 | } | |
510 |
|
470 | |||
511 | qreal QPieSeries::pieStartAngle() const |
|
471 | qreal QPieSeries::pieStartAngle() const | |
@@ -530,7 +490,7 void QPieSeries::setPieEndAngle(qreal angle) | |||||
530 | return; |
|
490 | return; | |
531 | d->m_pieEndAngle = angle; |
|
491 | d->m_pieEndAngle = angle; | |
532 | d->updateDerivativeData(); |
|
492 | d->updateDerivativeData(); | |
533 | emit pieEndAngleChanged(); |
|
493 | emit d->pieEndAngleChanged(); | |
534 | } |
|
494 | } | |
535 |
|
495 | |||
536 | /*! |
|
496 | /*! |
@@ -30,11 +30,11 class QPieSlice; | |||||
30 | class QTCOMMERCIALCHART_EXPORT QPieSeries : public QAbstractSeries |
|
30 | class QTCOMMERCIALCHART_EXPORT QPieSeries : public QAbstractSeries | |
31 | { |
|
31 | { | |
32 | Q_OBJECT |
|
32 | Q_OBJECT | |
33 |
Q_PROPERTY(qreal horizontalPosition READ horizontalPosition WRITE setHorizontalPosition |
|
33 | Q_PROPERTY(qreal horizontalPosition READ horizontalPosition WRITE setHorizontalPosition) | |
34 |
Q_PROPERTY(qreal verticalPosition READ verticalPosition WRITE setVerticalPosition |
|
34 | Q_PROPERTY(qreal verticalPosition READ verticalPosition WRITE setVerticalPosition) | |
35 |
Q_PROPERTY(qreal size READ pieSize WRITE setPieSize |
|
35 | Q_PROPERTY(qreal size READ pieSize WRITE setPieSize) | |
36 |
Q_PROPERTY(qreal startAngle READ pieStartAngle WRITE setPieStartAngle |
|
36 | Q_PROPERTY(qreal startAngle READ pieStartAngle WRITE setPieStartAngle) | |
37 |
Q_PROPERTY(qreal endAngle READ pieEndAngle WRITE setPieEndAngle |
|
37 | Q_PROPERTY(qreal endAngle READ pieEndAngle WRITE setPieEndAngle) | |
38 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
|
38 | Q_PROPERTY(int count READ count NOTIFY countChanged) | |
39 | Q_PROPERTY(qreal sum READ sum NOTIFY sumChanged) |
|
39 | Q_PROPERTY(qreal sum READ sum NOTIFY sumChanged) | |
40 |
|
40 | |||
@@ -85,11 +85,6 Q_SIGNALS: | |||||
85 | void hovered(QPieSlice* slice, bool state); |
|
85 | void hovered(QPieSlice* slice, bool state); | |
86 | void countChanged(); |
|
86 | void countChanged(); | |
87 | void sumChanged(); |
|
87 | void sumChanged(); | |
88 | void pieSizeChanged(); |
|
|||
89 | void pieStartAngleChanged(); |
|
|||
90 | void pieEndAngleChanged(); |
|
|||
91 | void horizontalPositionChanged(); |
|
|||
92 | void verticalPositionChanged(); |
|
|||
93 |
|
88 | |||
94 | private: |
|
89 | private: | |
95 | Q_DECLARE_PRIVATE(QPieSeries) |
|
90 | Q_DECLARE_PRIVATE(QPieSeries) |
@@ -54,6 +54,11 public: | |||||
54 |
|
54 | |||
55 | signals: |
|
55 | signals: | |
56 | void calculatedDataChanged(); |
|
56 | void calculatedDataChanged(); | |
|
57 | void pieSizeChanged(); | |||
|
58 | void pieStartAngleChanged(); | |||
|
59 | void pieEndAngleChanged(); | |||
|
60 | void horizontalPositionChanged(); | |||
|
61 | void verticalPositionChanged(); | |||
57 |
|
62 | |||
58 | public Q_SLOTS: |
|
63 | public Q_SLOTS: | |
59 | void sliceValueChanged(); |
|
64 | void sliceValueChanged(); |
@@ -90,11 +90,6 void tst_qpieseries::properties() | |||||
90 | { |
|
90 | { | |
91 | QSignalSpy countSpy(m_series, SIGNAL(countChanged())); |
|
91 | QSignalSpy countSpy(m_series, SIGNAL(countChanged())); | |
92 | QSignalSpy sumSpy(m_series, SIGNAL(sumChanged())); |
|
92 | QSignalSpy sumSpy(m_series, SIGNAL(sumChanged())); | |
93 | QSignalSpy sizeSpy(m_series, SIGNAL(pieSizeChanged())); |
|
|||
94 | QSignalSpy startAngleSpy(m_series, SIGNAL(pieStartAngleChanged())); |
|
|||
95 | QSignalSpy endAngleSpy(m_series, SIGNAL(pieEndAngleChanged())); |
|
|||
96 | QSignalSpy horPosSpy(m_series, SIGNAL(horizontalPositionChanged())); |
|
|||
97 | QSignalSpy verPosSpy(m_series, SIGNAL(verticalPositionChanged())); |
|
|||
98 |
|
93 | |||
99 | QVERIFY(m_series->type() == QAbstractSeries::SeriesTypePie); |
|
94 | QVERIFY(m_series->type() == QAbstractSeries::SeriesTypePie); | |
100 | QVERIFY(m_series->count() == 0); |
|
95 | QVERIFY(m_series->count() == 0); | |
@@ -125,17 +120,16 void tst_qpieseries::properties() | |||||
125 | m_series->setPieSize(0.9); |
|
120 | m_series->setPieSize(0.9); | |
126 | m_series->setPieSize(2.0); |
|
121 | m_series->setPieSize(2.0); | |
127 | QCOMPARE(m_series->pieSize(), 1.0); |
|
122 | QCOMPARE(m_series->pieSize(), 1.0); | |
128 | QCOMPARE(sizeSpy.count(), 3); |
|
|||
129 |
|
123 | |||
130 | m_series->setPieStartAngle(0); |
|
124 | m_series->setPieStartAngle(0); | |
131 | m_series->setPieStartAngle(-180); |
|
125 | m_series->setPieStartAngle(-180); | |
132 | m_series->setPieStartAngle(180); |
|
126 | m_series->setPieStartAngle(180); | |
133 |
QCOMPARE(startAngle |
|
127 | QCOMPARE(m_series->pieStartAngle(), 180.0); | |
134 |
|
128 | |||
135 | m_series->setPieEndAngle(360); |
|
129 | m_series->setPieEndAngle(360); | |
136 | m_series->setPieEndAngle(-180); |
|
130 | m_series->setPieEndAngle(-180); | |
137 | m_series->setPieEndAngle(180); |
|
131 | m_series->setPieEndAngle(180); | |
138 |
QCOMPARE(endAngle |
|
132 | QCOMPARE(m_series->pieEndAngle(), 180.0); | |
139 |
|
133 | |||
140 | m_series->setHorizontalPosition(0.5); |
|
134 | m_series->setHorizontalPosition(0.5); | |
141 | m_series->setHorizontalPosition(-1.0); |
|
135 | m_series->setHorizontalPosition(-1.0); | |
@@ -143,7 +137,6 void tst_qpieseries::properties() | |||||
143 | m_series->setHorizontalPosition(1.0); |
|
137 | m_series->setHorizontalPosition(1.0); | |
144 | m_series->setHorizontalPosition(2.0); |
|
138 | m_series->setHorizontalPosition(2.0); | |
145 | QCOMPARE(m_series->horizontalPosition(), 1.0); |
|
139 | QCOMPARE(m_series->horizontalPosition(), 1.0); | |
146 | QCOMPARE(horPosSpy.count(), 2); |
|
|||
147 |
|
140 | |||
148 | m_series->setVerticalPosition(0.5); |
|
141 | m_series->setVerticalPosition(0.5); | |
149 | m_series->setVerticalPosition(-1.0); |
|
142 | m_series->setVerticalPosition(-1.0); | |
@@ -151,7 +144,6 void tst_qpieseries::properties() | |||||
151 | m_series->setVerticalPosition(1.0); |
|
144 | m_series->setVerticalPosition(1.0); | |
152 | m_series->setVerticalPosition(2.0); |
|
145 | m_series->setVerticalPosition(2.0); | |
153 | QCOMPARE(m_series->verticalPosition(), 1.0); |
|
146 | QCOMPARE(m_series->verticalPosition(), 1.0); | |
154 | QCOMPARE(verPosSpy.count(), 2); |
|
|||
155 | } |
|
147 | } | |
156 |
|
148 | |||
157 | void tst_qpieseries::append() |
|
149 | void tst_qpieseries::append() |
@@ -41,11 +41,6 Flow { | |||||
41 | id: seriesConnections |
|
41 | id: seriesConnections | |
42 | target: null |
|
42 | target: null | |
43 | onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible); |
|
43 | onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible); | |
44 | onHorizontalPositionChanged:console.log("series.onHorizontalPositionChanged: " + series.horizontalPosition); |
|
|||
45 | onVerticalPositionChanged: console.log("series.onVerticalPositionChanged: " + series.verticalPosition); |
|
|||
46 | onSizeChanged: console.log("series.onSizeChanged: " + series.size); |
|
|||
47 | onStartAngleChanged: console.log("series.onStartAngleChanged: " + series.startAngle); |
|
|||
48 | onEndAngleChanged: console.log("series.onEndAngleChanged: " + series.endAngle); |
|
|||
49 | onCountChanged: console.log("series.onCountChanged: " + series.count); |
|
44 | onCountChanged: console.log("series.onCountChanged: " + series.count); | |
50 | onSumChanged: console.log("series.onSumChanged: " + series.sum); |
|
45 | onSumChanged: console.log("series.onSumChanged: " + series.sum); | |
51 | } |
|
46 | } |
General Comments 0
You need to be logged in to leave comments.
Login now