summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTero Ahola <tero.ahola@digia.com>2012-06-19 13:33:24 +0300
committerTero Ahola <tero.ahola@digia.com>2012-06-19 13:33:48 +0300
commit0e4d11fde6b8ae9c2687323178771379a0cac5d1 (patch)
treec99ea88ff28cc52f69a9ba3183c550d68c3b5fdc
parent32c9b390e95140f583f5b9a284636d410a94b7b3 (diff)
Removed unnecessary signals from QPieSlice
-rw-r--r--src/piechart/piechartitem.cpp16
-rw-r--r--src/piechart/qpieslice.cpp52
-rw-r--r--src/piechart/qpieslice.h16
-rw-r--r--src/piechart/qpieslice_p.h6
-rw-r--r--tests/auto/qpieslice/tst_qpieslice.cpp8
-rw-r--r--tests/qmlchartproperties/qml/qmlchartproperties/PieEditor.qml4
6 files changed, 27 insertions, 75 deletions
diff --git a/src/piechart/piechartitem.cpp b/src/piechart/piechartitem.cpp
index 6bb58ce3..a1851bb8 100644
--- a/src/piechart/piechartitem.cpp
+++ b/src/piechart/piechartitem.cpp
@@ -138,18 +138,20 @@ void PieChartItem::handleSlicesAdded(QList<QPieSlice*> slices)
PieSliceItem* sliceItem = new PieSliceItem(this);
m_sliceItems.insert(slice, sliceItem);
- // Note: do need to connect to slice valueChanged() etc.
+ // Note: no need to connect to slice valueChanged() etc.
// This is handled through calculatedDataChanged signal.
connect(slice, SIGNAL(labelChanged()), this, SLOT(handleSliceChanged()));
connect(slice, SIGNAL(labelVisibleChanged()), this, SLOT(handleSliceChanged()));
- connect(slice, SIGNAL(explodedChanged()), this, SLOT(handleSliceChanged()));
connect(slice, SIGNAL(penChanged()), this, SLOT(handleSliceChanged()));
connect(slice, SIGNAL(brushChanged()), this, SLOT(handleSliceChanged()));
connect(slice, SIGNAL(labelBrushChanged()), this, SLOT(handleSliceChanged()));
connect(slice, SIGNAL(labelFontChanged()), this, SLOT(handleSliceChanged()));
- connect(slice, SIGNAL(labelPositionChanged()), this, SLOT(handleSliceChanged()));
- connect(slice, SIGNAL(labelArmLengthFactorChanged()), this, SLOT(handleSliceChanged()));
- connect(slice, SIGNAL(explodeDistanceFactorChanged()), this, SLOT(handleSliceChanged()));
+
+ QPieSlicePrivate *p = QPieSlicePrivate::fromSlice(slice);
+ connect(p, SIGNAL(labelPositionChanged()), this, SLOT(handleSliceChanged()));
+ connect(p, SIGNAL(explodedChanged()), this, SLOT(handleSliceChanged()));
+ connect(p, SIGNAL(labelArmLengthFactorChanged()), this, SLOT(handleSliceChanged()));
+ connect(p, SIGNAL(explodeDistanceFactorChanged()), this, SLOT(handleSliceChanged()));
connect(sliceItem, SIGNAL(clicked(Qt::MouseButtons)), slice, SIGNAL(clicked()));
connect(sliceItem, SIGNAL(hovered(bool)), slice, SIGNAL(hovered(bool)));
@@ -186,6 +188,10 @@ void PieChartItem::handleSlicesRemoved(QList<QPieSlice*> slices)
void PieChartItem::handleSliceChanged()
{
QPieSlice* slice = qobject_cast<QPieSlice *>(sender());
+ if (!slice) {
+ QPieSlicePrivate* slicep = qobject_cast<QPieSlicePrivate *>(sender());
+ slice = slicep->q_ptr;
+ }
Q_ASSERT(m_sliceItems.contains(slice));
PieSliceItem *sliceItem = m_sliceItems.value(slice);
diff --git a/src/piechart/qpieslice.cpp b/src/piechart/qpieslice.cpp
index a05f8e03..4806b836 100644
--- a/src/piechart/qpieslice.cpp
+++ b/src/piechart/qpieslice.cpp
@@ -140,17 +140,6 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE
*/
/*!
- \fn void QPieSlice::explodedChanged()
- This signal is emitted the the slice has been exploded from the pie or is returned back to the pie.
- \sa exploded
-*/
-/*!
- \qmlsignal PieSlice::explodedChanged()
- This signal is emitted the the slice has been exploded from the pie or is returned back to the pie.
- \sa exploded
-*/
-
-/*!
\property QPieSlice::pen
Pen used to draw the slice border.
*/
@@ -298,17 +287,6 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE
*/
/*!
- \fn void QPieSlice::labelPositionChanged()
- This signal is emitted when the label position of the slice has changed.
- \sa labelPosition
-*/
-/*!
- \qmlsignal PieSlice::labelPositionChanged()
- This signal is emitted when the label position of the slice has changed.
- \sa labelPosition
-*/
-
-/*!
\property QPieSlice::labelArmLengthFactor
Defines the length of the label arm.
The factor is relative to pie radius. For example:
@@ -328,17 +306,6 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE
*/
/*!
- \fn void QPieSlice::labelArmLengthFactorChanged()
- This signal is emitted when the label arm factor of the slice has changed.
- \sa labelArmLengthFactor
-*/
-/*!
- \qmlsignal PieSlice::labelArmLengthFactorChanged()
- This signal is emitted when the label arm factor of the slice has changed.
- \sa labelArmLengthFactor
-*/
-
-/*!
\property QPieSlice::explodeDistanceFactor
When the slice is exploded this factor defines how far the slice is exploded away from the pie.
The factor is relative to pie radius. For example:
@@ -358,17 +325,6 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE
*/
/*!
- \fn void QPieSlice::explodeDistanceFactorChanged()
- This signal is emitted when the explode distance factor of the slice has changed.
- \sa explodeDistanceFactor
-*/
-/*!
- \qmlsignal PieSlice::explodeDistanceFactorChanged()
- This signal is emitted when the explode distance factor of the slice has changed.
- \sa explodeDistanceFactor
-*/
-
-/*!
\property QPieSlice::percentage
Percentage of the slice compared to the sum of all slices in the series.
The actual value ranges from 0.0 to 1.0.
@@ -539,7 +495,7 @@ void QPieSlice::setExploded(bool exploded)
{
if (d_ptr->m_data.m_isExploded != exploded) {
d_ptr->m_data.m_isExploded = exploded;
- emit explodedChanged();
+ emit d_ptr->explodedChanged();
}
}
@@ -552,7 +508,7 @@ void QPieSlice::setLabelPosition(LabelPosition position)
{
if (d_ptr->m_data.m_labelPosition != position) {
d_ptr->m_data.m_labelPosition = position;
- emit labelPositionChanged();
+ emit d_ptr->labelPositionChanged();
}
}
@@ -661,7 +617,7 @@ void QPieSlice::setLabelArmLengthFactor(qreal factor)
{
if (!qFuzzyIsNull(d_ptr->m_data.m_labelArmLengthFactor - factor)) {
d_ptr->m_data.m_labelArmLengthFactor = factor;
- emit labelArmLengthFactorChanged();
+ emit d_ptr->labelArmLengthFactorChanged();
}
}
@@ -674,7 +630,7 @@ void QPieSlice::setExplodeDistanceFactor(qreal factor)
{
if (!qFuzzyIsNull(d_ptr->m_data.m_explodeDistanceFactor - factor)) {
d_ptr->m_data.m_explodeDistanceFactor = factor;
- emit explodeDistanceFactorChanged();
+ emit d_ptr->explodeDistanceFactorChanged();
}
}
diff --git a/src/piechart/qpieslice.h b/src/piechart/qpieslice.h
index 0975a6b0..8c8f2f0c 100644
--- a/src/piechart/qpieslice.h
+++ b/src/piechart/qpieslice.h
@@ -38,8 +38,8 @@ class QTCOMMERCIALCHART_EXPORT QPieSlice : public QObject
Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged)
Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged)
Q_PROPERTY(bool labelVisible READ isLabelVisible WRITE setLabelVisible NOTIFY labelVisibleChanged)
- Q_PROPERTY(LabelPosition labelPosition READ labelPosition WRITE setLabelPosition NOTIFY labelPositionChanged)
- Q_PROPERTY(bool exploded READ isExploded WRITE setExploded NOTIFY explodedChanged)
+ Q_PROPERTY(LabelPosition labelPosition READ labelPosition WRITE setLabelPosition)
+ Q_PROPERTY(bool exploded READ isExploded WRITE setExploded)
Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged)
Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged)
Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged)
@@ -48,8 +48,8 @@ class QTCOMMERCIALCHART_EXPORT QPieSlice : public QObject
Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush NOTIFY labelBrushChanged)
Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor NOTIFY labelColorChanged)
Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont NOTIFY labelFontChanged)
- Q_PROPERTY(qreal labelArmLengthFactor READ labelArmLengthFactor WRITE setLabelArmLengthFactor NOTIFY labelArmLengthFactorChanged)
- Q_PROPERTY(qreal explodeDistanceFactor READ explodeDistanceFactor WRITE setExplodeDistanceFactor NOTIFY explodeDistanceFactorChanged)
+ Q_PROPERTY(qreal labelArmLengthFactor READ labelArmLengthFactor WRITE setLabelArmLengthFactor)
+ Q_PROPERTY(qreal explodeDistanceFactor READ explodeDistanceFactor WRITE setExplodeDistanceFactor)
Q_PROPERTY(qreal percentage READ percentage NOTIFY percentageChanged)
Q_PROPERTY(qreal startAngle READ startAngle NOTIFY startAngleChanged)
Q_PROPERTY(qreal angleSpan READ angleSpan NOTIFY angleSpanChanged)
@@ -117,17 +117,15 @@ public:
QPieSeries *series() const;
Q_SIGNALS:
+ void clicked();
+ void hovered(bool state);
void labelChanged();
void valueChanged();
void labelVisibleChanged();
- void labelPositionChanged();
- void explodedChanged();
void penChanged();
void brushChanged();
void labelBrushChanged();
void labelFontChanged();
- void labelArmLengthFactorChanged();
- void explodeDistanceFactorChanged();
void percentageChanged();
void startAngleChanged();
void angleSpanChanged();
@@ -135,8 +133,6 @@ Q_SIGNALS:
void borderColorChanged();
void borderWidthChanged();
void labelColorChanged();
- void clicked();
- void hovered(bool state);
private:
QPieSlicePrivate * const d_ptr;
diff --git a/src/piechart/qpieslice_p.h b/src/piechart/qpieslice_p.h
index 00d969ad..4cfda698 100644
--- a/src/piechart/qpieslice_p.h
+++ b/src/piechart/qpieslice_p.h
@@ -56,6 +56,12 @@ public:
void setStartAngle(qreal angle);
void setAngleSpan(qreal span);
+Q_SIGNALS:
+ void labelPositionChanged();
+ void explodedChanged();
+ void labelArmLengthFactorChanged();
+ void explodeDistanceFactorChanged();
+
private:
friend class QPieSeries;
friend class QPieSeriesPrivate;
diff --git a/tests/auto/qpieslice/tst_qpieslice.cpp b/tests/auto/qpieslice/tst_qpieslice.cpp
index ccf80c22..4e020138 100644
--- a/tests/auto/qpieslice/tst_qpieslice.cpp
+++ b/tests/auto/qpieslice/tst_qpieslice.cpp
@@ -110,14 +110,10 @@ void tst_qpieslice::changedSignals()
QSignalSpy valueSpy(&slice, SIGNAL(valueChanged()));
QSignalSpy labelSpy(&slice, SIGNAL(labelChanged()));
- QSignalSpy explodedSpy(&slice, SIGNAL(explodedChanged()));
QSignalSpy penSpy(&slice, SIGNAL(penChanged()));
QSignalSpy brushSpy(&slice, SIGNAL(brushChanged()));
QSignalSpy labelBrushSpy(&slice, SIGNAL(labelBrushChanged()));
QSignalSpy labelFontSpy(&slice, SIGNAL(labelFontChanged()));
- QSignalSpy labelPositionSpy(&slice, SIGNAL(labelPositionChanged()));
- QSignalSpy labelArmLengthFactorSpy(&slice, SIGNAL(labelArmLengthFactorChanged()));
- QSignalSpy explodeDistanceFactorSpy(&slice, SIGNAL(explodeDistanceFactorChanged()));
QSignalSpy colorSpy(&slice, SIGNAL(colorChanged()));
QSignalSpy borderColorSpy(&slice, SIGNAL(borderColorChanged()));
QSignalSpy borderWidthSpy(&slice, SIGNAL(borderWidthChanged()));
@@ -152,14 +148,10 @@ void tst_qpieslice::changedSignals()
TRY_COMPARE(valueSpy.count(), 1);
TRY_COMPARE(labelSpy.count(), 1);
- TRY_COMPARE(explodedSpy.count(), 1);
TRY_COMPARE(penSpy.count(), 2);
TRY_COMPARE(brushSpy.count(), 1);
TRY_COMPARE(labelBrushSpy.count(), 1);
TRY_COMPARE(labelFontSpy.count(), 1);
- TRY_COMPARE(labelPositionSpy.count(), 1);
- TRY_COMPARE(labelArmLengthFactorSpy.count(), 1);
- TRY_COMPARE(explodeDistanceFactorSpy.count(), 1);
TRY_COMPARE(colorSpy.count(), 1);
TRY_COMPARE(borderColorSpy.count(), 1);
TRY_COMPARE(borderWidthSpy.count(), 1);
diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/PieEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/PieEditor.qml
index 37ca60fa..bcbd3b9b 100644
--- a/tests/qmlchartproperties/qml/qmlchartproperties/PieEditor.qml
+++ b/tests/qmlchartproperties/qml/qmlchartproperties/PieEditor.qml
@@ -50,8 +50,6 @@ Flow {
target: null
onValueChanged: console.log("slice.onValueChanged: " + series.at(0).value);
onLabelVisibleChanged: console.log("slice.onLabelVisibleChanged: " + series.at(0).labelVisible);
- onLabelPositionChanged: console.log("slice.onLabelPositionChanged: " + series.at(0).labelPosition);
- onExplodedChanged: console.log("slice.onExplodedChanged: " + series.at(0).exploded);
onPenChanged: console.log("slice.onPenChanged: " + series.at(0).pen);
onBorderColorChanged: console.log("slice.onBorderColorChanged: " + series.at(0).borderColor);
onBorderWidthChanged: console.log("slice.onBorderWidthChanged: " + series.at(0).borderWidth);
@@ -60,8 +58,6 @@ Flow {
onLabelColorChanged: console.log("slice.onLabelColorChanged: " + series.at(0).labelColor);
onLabelBrushChanged: console.log("slice.onLabelBrushChanged: " + series.at(0).labelBrush);
onLabelFontChanged: console.log("slice.onLabelFontChanged: " + series.at(0).labelFont);
- onLabelArmLengthFactorChanged: console.log("slice.onLabelArmLengthFactorChanged: " + series.at(0).labelArmLengthFactor);
- onExplodeDistanceFactorChanged: console.log("slice.onExplodeDistanceFactorChanged: " + series.at(0).explodeDistanceFactor);
onPercentageChanged: console.log("slice.onPercentageChanged: " + series.at(0).percentage);
onStartAngleChanged: console.log("slice.onStartAngleChanged: " + series.at(0).startAngle);
onAngleSpanChanged: console.log("slice.onAngleSpanChanged: " + series.at(0).angleSpan);