@@ -154,6 +154,9 MainWidget::MainWidget(QWidget* parent) | |||||
154 | m_font = new QPushButton(); |
|
154 | m_font = new QPushButton(); | |
155 | m_labelBrush = new QPushButton(); |
|
155 | m_labelBrush = new QPushButton(); | |
156 | m_labelBrushTool = new BrushTool("Label brush", this); |
|
156 | m_labelBrushTool = new BrushTool("Label brush", this); | |
|
157 | m_labelPosition = new QComboBox(this); | |||
|
158 | m_labelPosition->addItem("Outside", QPieSlice::LabelOutside); | |||
|
159 | m_labelPosition->addItem("Inside", QPieSlice::LabelInside); | |||
157 | QPushButton *removeSlice = new QPushButton("Remove slice"); |
|
160 | QPushButton *removeSlice = new QPushButton("Remove slice"); | |
158 |
|
161 | |||
159 | QFormLayout* sliceSettingsLayout = new QFormLayout(); |
|
162 | QFormLayout* sliceSettingsLayout = new QFormLayout(); | |
@@ -163,7 +166,8 MainWidget::MainWidget(QWidget* parent) | |||||
163 | sliceSettingsLayout->addRow("Brush", m_brush); |
|
166 | sliceSettingsLayout->addRow("Brush", m_brush); | |
164 | sliceSettingsLayout->addRow("Label visible", m_sliceLabelVisible); |
|
167 | sliceSettingsLayout->addRow("Label visible", m_sliceLabelVisible); | |
165 | sliceSettingsLayout->addRow("Label font", m_font); |
|
168 | sliceSettingsLayout->addRow("Label font", m_font); | |
166 |
sliceSettingsLayout->addRow("Label |
|
169 | sliceSettingsLayout->addRow("Label brush", m_labelBrush); | |
|
170 | sliceSettingsLayout->addRow("Label position", m_labelPosition); | |||
167 | sliceSettingsLayout->addRow("Label arm length", m_sliceLabelArmFactor); |
|
171 | sliceSettingsLayout->addRow("Label arm length", m_sliceLabelArmFactor); | |
168 | sliceSettingsLayout->addRow("Exploded", m_sliceExploded); |
|
172 | sliceSettingsLayout->addRow("Exploded", m_sliceExploded); | |
169 | sliceSettingsLayout->addRow("Explode distance", m_sliceExplodedFactor); |
|
173 | sliceSettingsLayout->addRow("Explode distance", m_sliceExplodedFactor); | |
@@ -184,6 +188,7 MainWidget::MainWidget(QWidget* parent) | |||||
184 | connect(m_sliceLabelArmFactor, SIGNAL(valueChanged(double)), this, SLOT(updateSliceSettings())); |
|
188 | connect(m_sliceLabelArmFactor, SIGNAL(valueChanged(double)), this, SLOT(updateSliceSettings())); | |
185 | connect(m_sliceExploded, SIGNAL(toggled(bool)), this, SLOT(updateSliceSettings())); |
|
189 | connect(m_sliceExploded, SIGNAL(toggled(bool)), this, SLOT(updateSliceSettings())); | |
186 | connect(m_sliceExplodedFactor, SIGNAL(valueChanged(double)), this, SLOT(updateSliceSettings())); |
|
190 | connect(m_sliceExplodedFactor, SIGNAL(valueChanged(double)), this, SLOT(updateSliceSettings())); | |
|
191 | connect(m_labelPosition, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSliceSettings())); | |||
187 | connect(removeSlice, SIGNAL(clicked()), this, SLOT(removeSlice())); |
|
192 | connect(removeSlice, SIGNAL(clicked()), this, SLOT(removeSlice())); | |
188 |
|
193 | |||
189 | // create chart view |
|
194 | // create chart view | |
@@ -244,6 +249,7 void MainWidget::updateSliceSettings() | |||||
244 | m_slice->setLabelBrush(m_labelBrushTool->brush()); |
|
249 | m_slice->setLabelBrush(m_labelBrushTool->brush()); | |
245 | m_slice->setLabelVisible(m_sliceLabelVisible->isChecked()); |
|
250 | m_slice->setLabelVisible(m_sliceLabelVisible->isChecked()); | |
246 | m_slice->setLabelArmLengthFactor(m_sliceLabelArmFactor->value()); |
|
251 | m_slice->setLabelArmLengthFactor(m_sliceLabelArmFactor->value()); | |
|
252 | m_slice->setLabelPosition((QPieSlice::LabelPosition)m_labelPosition->currentIndex()); // assumes that index is in sync with the enum | |||
247 |
|
253 | |||
248 | m_slice->setExploded(m_sliceExploded->isChecked()); |
|
254 | m_slice->setExploded(m_sliceExploded->isChecked()); | |
249 | m_slice->setExplodeDistanceFactor(m_sliceExplodedFactor->value()); |
|
255 | m_slice->setExplodeDistanceFactor(m_sliceExplodedFactor->value()); | |
@@ -279,6 +285,9 void MainWidget::handleSliceClicked(QPieSlice* slice) | |||||
279 | m_sliceLabelArmFactor->blockSignals(true); |
|
285 | m_sliceLabelArmFactor->blockSignals(true); | |
280 | m_sliceLabelArmFactor->setValue(slice->labelArmLengthFactor()); |
|
286 | m_sliceLabelArmFactor->setValue(slice->labelArmLengthFactor()); | |
281 | m_sliceLabelArmFactor->blockSignals(false); |
|
287 | m_sliceLabelArmFactor->blockSignals(false); | |
|
288 | m_labelPosition->blockSignals(true); | |||
|
289 | m_labelPosition->setCurrentIndex(slice->labelPosition()); // assumes that index is in sync with the enum | |||
|
290 | m_labelPosition->blockSignals(false); | |||
282 |
|
291 | |||
283 | // exploded |
|
292 | // exploded | |
284 | m_sliceExploded->blockSignals(true); |
|
293 | m_sliceExploded->blockSignals(true); |
@@ -85,6 +85,7 private: | |||||
85 | PenTool *m_penTool; |
|
85 | PenTool *m_penTool; | |
86 | QPushButton *m_font; |
|
86 | QPushButton *m_font; | |
87 | QPushButton *m_labelBrush; |
|
87 | QPushButton *m_labelBrush; | |
|
88 | QComboBox *m_labelPosition; | |||
88 | BrushTool *m_labelBrushTool; |
|
89 | BrushTool *m_labelBrushTool; | |
89 | }; |
|
90 | }; | |
90 |
|
91 |
@@ -145,6 +145,7 void PieChartItem::handleSlicesAdded(QList<QPieSlice*> slices) | |||||
145 | connect(slice, SIGNAL(brushChanged()), this, SLOT(handleSliceChanged())); |
|
145 | connect(slice, SIGNAL(brushChanged()), this, SLOT(handleSliceChanged())); | |
146 | connect(slice, SIGNAL(labelBrushChanged()), this, SLOT(handleSliceChanged())); |
|
146 | connect(slice, SIGNAL(labelBrushChanged()), this, SLOT(handleSliceChanged())); | |
147 | connect(slice, SIGNAL(labelFontChanged()), this, SLOT(handleSliceChanged())); |
|
147 | connect(slice, SIGNAL(labelFontChanged()), this, SLOT(handleSliceChanged())); | |
|
148 | connect(slice, SIGNAL(labelPositionChanged()), this, SLOT(handleSliceChanged())); | |||
148 | connect(slice, SIGNAL(labelArmLengthFactorChanged()), this, SLOT(handleSliceChanged())); |
|
149 | connect(slice, SIGNAL(labelArmLengthFactorChanged()), this, SLOT(handleSliceChanged())); | |
149 | connect(slice, SIGNAL(explodeDistanceFactorChanged()), this, SLOT(handleSliceChanged())); |
|
150 | connect(slice, SIGNAL(explodeDistanceFactorChanged()), this, SLOT(handleSliceChanged())); | |
150 |
|
151 |
@@ -75,6 +75,7 public: | |||||
75 | m_explodeDistanceFactor = 0.15; |
|
75 | m_explodeDistanceFactor = 0.15; | |
76 |
|
76 | |||
77 | m_isLabelVisible = false; |
|
77 | m_isLabelVisible = false; | |
|
78 | m_labelPosition = QPieSlice::LabelOutside; | |||
78 | m_labelArmLengthFactor = 0.15; |
|
79 | m_labelArmLengthFactor = 0.15; | |
79 |
|
80 | |||
80 | m_percentage = 0; |
|
81 | m_percentage = 0; | |
@@ -99,6 +100,7 public: | |||||
99 | if (m_isLabelVisible != other.m_isLabelVisible || |
|
100 | if (m_isLabelVisible != other.m_isLabelVisible || | |
100 | m_labelText != other.m_labelText || |
|
101 | m_labelText != other.m_labelText || | |
101 | m_labelFont != other.m_labelFont || |
|
102 | m_labelFont != other.m_labelFont || | |
|
103 | m_labelPosition != other.m_labelPosition || | |||
102 | !qFuzzyIsNull(m_labelArmLengthFactor - other.m_labelArmLengthFactor) || |
|
104 | !qFuzzyIsNull(m_labelArmLengthFactor - other.m_labelArmLengthFactor) || | |
103 | m_labelBrush != other.m_labelBrush) |
|
105 | m_labelBrush != other.m_labelBrush) | |
104 | return true; |
|
106 | return true; | |
@@ -124,6 +126,7 public: | |||||
124 | bool m_isLabelVisible; |
|
126 | bool m_isLabelVisible; | |
125 | QString m_labelText; |
|
127 | QString m_labelText; | |
126 | Themed<QFont> m_labelFont; |
|
128 | Themed<QFont> m_labelFont; | |
|
129 | QPieSlice::LabelPosition m_labelPosition; | |||
127 | qreal m_labelArmLengthFactor; |
|
130 | qreal m_labelArmLengthFactor; | |
128 | Themed<QBrush> m_labelBrush; |
|
131 | Themed<QBrush> m_labelBrush; | |
129 |
|
132 |
@@ -78,13 +78,20 void PieSliceItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*op | |||||
78 |
|
78 | |||
79 | if (m_data.m_isLabelVisible) { |
|
79 | if (m_data.m_isLabelVisible) { | |
80 | painter->save(); |
|
80 | painter->save(); | |
81 | painter->setClipRect(parentItem()->boundingRect()); |
|
81 | ||
82 | // Pen for label arm not defined in the QPieSeries api, let's use brush's color instead |
|
82 | // Pen for label arm not defined in the QPieSeries api, let's use brush's color instead | |
83 | // Also, the drawText actually uses the pen color for the text color (unlike QGraphicsSimpleTextItem) |
|
83 | // Also, the drawText actually uses the pen color for the text color (unlike QGraphicsSimpleTextItem) | |
84 | painter->setPen(m_data.m_labelBrush.color()); |
|
84 | painter->setPen(m_data.m_labelBrush.color()); | |
85 |
painter-> |
|
85 | painter->setBrush(m_data.m_labelBrush); | |
86 | painter->setFont(m_data.m_labelFont); |
|
86 | painter->setFont(m_data.m_labelFont); | |
87 | painter->drawText(m_labelTextRect.bottomLeft(), m_data.m_labelText); |
|
87 | if (m_data.m_labelPosition == QPieSlice::LabelOutside) { | |
|
88 | painter->setClipRect(parentItem()->boundingRect()); | |||
|
89 | painter->strokePath(m_labelArmPath, m_data.m_labelBrush.color()); | |||
|
90 | } else { // QPieSlice::LabelInside | |||
|
91 | painter->setClipPath(m_slicePath); | |||
|
92 | } | |||
|
93 | painter->drawText(m_labelTextRect, Qt::AlignCenter, m_data.m_labelText); | |||
|
94 | ||||
88 | painter->restore(); |
|
95 | painter->restore(); | |
89 | } |
|
96 | } | |
90 | } |
|
97 | } | |
@@ -120,22 +127,28 void PieSliceItem::updateGeometry() | |||||
120 |
|
127 | |||
121 | prepareGeometryChange(); |
|
128 | prepareGeometryChange(); | |
122 |
|
129 | |||
123 |
// |
|
130 | // slice path | |
124 | qreal centerAngle; |
|
131 | qreal centerAngle; | |
125 | QPointF armStart; |
|
132 | QPointF armStart; | |
126 | m_slicePath = slicePath(m_data.m_center, m_data.m_radius, m_data.m_startAngle, m_data.m_angleSpan, ¢erAngle, &armStart); |
|
133 | m_slicePath = slicePath(m_data.m_center, m_data.m_radius, m_data.m_startAngle, m_data.m_angleSpan, ¢erAngle, &armStart); | |
127 |
|
134 | |||
128 |
// |
|
135 | // text rect | |
129 | m_labelTextRect = labelTextRect(m_data.m_labelFont, m_data.m_labelText); |
|
136 | QFontMetricsF fm(m_data.m_labelFont); | |
|
137 | m_labelTextRect = QRectF(0, 0, fm.width(m_data.m_labelText), fm.height()); | |||
130 |
|
138 | |||
131 |
// |
|
139 | // label arm path | |
132 | QPointF labelTextStart; |
|
140 | QPointF labelTextStart; | |
133 | m_labelArmPath = labelArmPath(armStart, centerAngle, m_data.m_radius * m_data.m_labelArmLengthFactor, m_labelTextRect.width(), &labelTextStart); |
|
141 | m_labelArmPath = labelArmPath(armStart, centerAngle, m_data.m_radius * m_data.m_labelArmLengthFactor, m_labelTextRect.width(), &labelTextStart); | |
134 |
|
142 | |||
135 |
// |
|
143 | // text position | |
136 | m_labelTextRect.moveBottomLeft(labelTextStart); |
|
144 | if (m_data.m_labelPosition == QPieSlice::LabelOutside) | |
|
145 | m_labelTextRect.moveBottomLeft(labelTextStart); | |||
|
146 | else {// QPieSlice::LabelInside | |||
|
147 | QPointF sliceCenter = m_data.m_center + offset(centerAngle, m_data.m_radius / 2); | |||
|
148 | m_labelTextRect.moveCenter(sliceCenter); | |||
|
149 | } | |||
137 |
|
150 | |||
138 |
// |
|
151 | // bounding rect | |
139 | if (m_data.m_isLabelVisible) |
|
152 | if (m_data.m_isLabelVisible) | |
140 | m_boundingRect = m_slicePath.boundingRect().united(m_labelArmPath.boundingRect()).united(m_labelTextRect); |
|
153 | m_boundingRect = m_slicePath.boundingRect().united(m_labelArmPath.boundingRect()).united(m_labelTextRect); | |
141 | else |
|
154 | else | |
@@ -208,9 +221,6 QPainterPath PieSliceItem::labelArmPath(QPointF start, qreal angle, qreal length | |||||
208 | *textStart = parm2; |
|
221 | *textStart = parm2; | |
209 | } |
|
222 | } | |
210 |
|
223 | |||
211 | // elevate the text position a bit so that it does not hit the line |
|
|||
212 | *textStart += QPointF(0, -3); |
|
|||
213 |
|
||||
214 | QPainterPath path; |
|
224 | QPainterPath path; | |
215 | path.moveTo(start); |
|
225 | path.moveTo(start); | |
216 | path.lineTo(parm1); |
|
226 | path.lineTo(parm1); | |
@@ -219,12 +229,6 QPainterPath PieSliceItem::labelArmPath(QPointF start, qreal angle, qreal length | |||||
219 | return path; |
|
229 | return path; | |
220 | } |
|
230 | } | |
221 |
|
231 | |||
222 | QRectF PieSliceItem::labelTextRect(QFont font, QString text) |
|
|||
223 | { |
|
|||
224 | QFontMetricsF fm(font); |
|
|||
225 | return fm.boundingRect(text); |
|
|||
226 | } |
|
|||
227 |
|
||||
228 | #include "moc_piesliceitem_p.cpp" |
|
232 | #include "moc_piesliceitem_p.cpp" | |
229 |
|
233 | |||
230 | QTCOMMERCIALCHART_END_NAMESPACE |
|
234 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -73,7 +73,6 private: | |||||
73 | void updateGeometry(); |
|
73 | void updateGeometry(); | |
74 | QPainterPath slicePath(QPointF center, qreal radius, qreal startAngle, qreal angleSpan, qreal *centerAngle, QPointF *armStart); |
|
74 | QPainterPath slicePath(QPointF center, qreal radius, qreal startAngle, qreal angleSpan, qreal *centerAngle, QPointF *armStart); | |
75 | QPainterPath labelArmPath(QPointF start, qreal angle, qreal length, qreal textWidth, QPointF *textStart); |
|
75 | QPainterPath labelArmPath(QPointF start, qreal angle, qreal length, qreal textWidth, QPointF *textStart); | |
76 | QRectF labelTextRect(QFont font, QString text); |
|
|||
77 |
|
76 | |||
78 | private: |
|
77 | private: | |
79 | PieSliceData m_data; |
|
78 | PieSliceData m_data; |
@@ -39,6 +39,16 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
39 | */ |
|
39 | */ | |
40 |
|
40 | |||
41 | /*! |
|
41 | /*! | |
|
42 | \enum QPieSlice::LabelPosition | |||
|
43 | ||||
|
44 | This enum describes the position of the slice label. | |||
|
45 | ||||
|
46 | \value LabelOutside Label is outside the slice with an arm. | |||
|
47 | \value LabelInside Label is centered inside the slice. | |||
|
48 | ||||
|
49 | */ | |||
|
50 | ||||
|
51 | /*! | |||
42 | \property QPieSlice::label |
|
52 | \property QPieSlice::label | |
43 |
|
53 | |||
44 | Label of the slice. |
|
54 | Label of the slice. | |
@@ -239,6 +249,22 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
239 | */ |
|
249 | */ | |
240 |
|
250 | |||
241 | /*! |
|
251 | /*! | |
|
252 | \property QPieSlice::labelPosition | |||
|
253 | ||||
|
254 | Position of the slice label. | |||
|
255 | ||||
|
256 | \sa label, labelVisible | |||
|
257 | */ | |||
|
258 | ||||
|
259 | /*! | |||
|
260 | \fn void QPieSlice::labelPositionChanged() | |||
|
261 | ||||
|
262 | This signal is emitted when the label position of the slice has changed. | |||
|
263 | ||||
|
264 | \sa labelPosition | |||
|
265 | */ | |||
|
266 | ||||
|
267 | /*! | |||
242 | \property QPieSlice::labelArmLengthFactor |
|
268 | \property QPieSlice::labelArmLengthFactor | |
243 |
|
269 | |||
244 | Defines the length of the label arm. |
|
270 | Defines the length of the label arm. | |
@@ -438,6 +464,19 void QPieSlice::setExploded(bool exploded) | |||||
438 | } |
|
464 | } | |
439 | } |
|
465 | } | |
440 |
|
466 | |||
|
467 | QPieSlice::LabelPosition QPieSlice::labelPosition() | |||
|
468 | { | |||
|
469 | return d_ptr->m_data.m_labelPosition; | |||
|
470 | } | |||
|
471 | ||||
|
472 | void QPieSlice::setLabelPosition(LabelPosition position) | |||
|
473 | { | |||
|
474 | if (d_ptr->m_data.m_labelPosition != position) { | |||
|
475 | d_ptr->m_data.m_labelPosition = position; | |||
|
476 | emit labelPositionChanged(); | |||
|
477 | } | |||
|
478 | } | |||
|
479 | ||||
441 | bool QPieSlice::isExploded() const |
|
480 | bool QPieSlice::isExploded() const | |
442 | { |
|
481 | { | |
443 | return d_ptr->m_data.m_isExploded; |
|
482 | return d_ptr->m_data.m_isExploded; |
@@ -34,9 +34,11 class QPieSeries; | |||||
34 | class QTCOMMERCIALCHART_EXPORT QPieSlice : public QObject |
|
34 | class QTCOMMERCIALCHART_EXPORT QPieSlice : public QObject | |
35 | { |
|
35 | { | |
36 | Q_OBJECT |
|
36 | Q_OBJECT | |
|
37 | Q_ENUMS(LabelPosition) | |||
37 | Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) |
|
38 | Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) | |
38 | Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged) |
|
39 | Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged) | |
39 | 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) | |||
40 | Q_PROPERTY(bool exploded READ isExploded WRITE setExploded NOTIFY explodedChanged) |
|
42 | Q_PROPERTY(bool exploded READ isExploded WRITE setExploded NOTIFY explodedChanged) | |
41 | Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged) |
|
43 | Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged) | |
42 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) |
|
44 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) | |
@@ -53,6 +55,12 class QTCOMMERCIALCHART_EXPORT QPieSlice : public QObject | |||||
53 | Q_PROPERTY(qreal angleSpan READ angleSpan NOTIFY angleSpanChanged) |
|
55 | Q_PROPERTY(qreal angleSpan READ angleSpan NOTIFY angleSpanChanged) | |
54 |
|
56 | |||
55 | public: |
|
57 | public: | |
|
58 | enum LabelPosition { | |||
|
59 | LabelOutside, | |||
|
60 | LabelInside | |||
|
61 | }; | |||
|
62 | ||||
|
63 | public: | |||
56 | explicit QPieSlice(QObject *parent = 0); |
|
64 | explicit QPieSlice(QObject *parent = 0); | |
57 | QPieSlice(QString label, qreal value, QObject *parent = 0); |
|
65 | QPieSlice(QString label, qreal value, QObject *parent = 0); | |
58 | virtual ~QPieSlice(); |
|
66 | virtual ~QPieSlice(); | |
@@ -66,6 +74,9 public: | |||||
66 | void setLabelVisible(bool visible = true); |
|
74 | void setLabelVisible(bool visible = true); | |
67 | bool isLabelVisible() const; |
|
75 | bool isLabelVisible() const; | |
68 |
|
76 | |||
|
77 | LabelPosition labelPosition(); | |||
|
78 | void setLabelPosition(LabelPosition position); | |||
|
79 | ||||
69 | void setExploded(bool exploded = true); |
|
80 | void setExploded(bool exploded = true); | |
70 | bool isExploded() const; |
|
81 | bool isExploded() const; | |
71 |
|
82 | |||
@@ -109,6 +120,7 Q_SIGNALS: | |||||
109 | void labelChanged(); |
|
120 | void labelChanged(); | |
110 | void valueChanged(); |
|
121 | void valueChanged(); | |
111 | void labelVisibleChanged(); |
|
122 | void labelVisibleChanged(); | |
|
123 | void labelPositionChanged(); | |||
112 | void explodedChanged(); |
|
124 | void explodedChanged(); | |
113 | void penChanged(); |
|
125 | void penChanged(); | |
114 | void brushChanged(); |
|
126 | void brushChanged(); |
@@ -115,6 +115,7 void tst_qpieslice::changedSignals() | |||||
115 | QSignalSpy brushSpy(&slice, SIGNAL(brushChanged())); |
|
115 | QSignalSpy brushSpy(&slice, SIGNAL(brushChanged())); | |
116 | QSignalSpy labelBrushSpy(&slice, SIGNAL(labelBrushChanged())); |
|
116 | QSignalSpy labelBrushSpy(&slice, SIGNAL(labelBrushChanged())); | |
117 | QSignalSpy labelFontSpy(&slice, SIGNAL(labelFontChanged())); |
|
117 | QSignalSpy labelFontSpy(&slice, SIGNAL(labelFontChanged())); | |
|
118 | QSignalSpy labelPositionSpy(&slice, SIGNAL(labelPositionChanged())); | |||
118 | QSignalSpy labelArmLengthFactorSpy(&slice, SIGNAL(labelArmLengthFactorChanged())); |
|
119 | QSignalSpy labelArmLengthFactorSpy(&slice, SIGNAL(labelArmLengthFactorChanged())); | |
119 | QSignalSpy explodeDistanceFactorSpy(&slice, SIGNAL(explodeDistanceFactorChanged())); |
|
120 | QSignalSpy explodeDistanceFactorSpy(&slice, SIGNAL(explodeDistanceFactorChanged())); | |
120 | QSignalSpy colorSpy(&slice, SIGNAL(colorChanged())); |
|
121 | QSignalSpy colorSpy(&slice, SIGNAL(colorChanged())); | |
@@ -142,6 +143,8 void tst_qpieslice::changedSignals() | |||||
142 | slice.setLabelBrush(QBrush(Qt::green)); |
|
143 | slice.setLabelBrush(QBrush(Qt::green)); | |
143 | slice.setLabelFont(QFont("Tahoma")); |
|
144 | slice.setLabelFont(QFont("Tahoma")); | |
144 | slice.setLabelFont(QFont("Tahoma")); |
|
145 | slice.setLabelFont(QFont("Tahoma")); | |
|
146 | slice.setLabelPosition(QPieSlice::LabelInside); | |||
|
147 | slice.setLabelPosition(QPieSlice::LabelInside); | |||
145 | slice.setLabelArmLengthFactor(0.1); |
|
148 | slice.setLabelArmLengthFactor(0.1); | |
146 | slice.setLabelArmLengthFactor(0.1); |
|
149 | slice.setLabelArmLengthFactor(0.1); | |
147 | slice.setExplodeDistanceFactor(0.1); |
|
150 | slice.setExplodeDistanceFactor(0.1); | |
@@ -154,6 +157,7 void tst_qpieslice::changedSignals() | |||||
154 | TRY_COMPARE(brushSpy.count(), 1); |
|
157 | TRY_COMPARE(brushSpy.count(), 1); | |
155 | TRY_COMPARE(labelBrushSpy.count(), 1); |
|
158 | TRY_COMPARE(labelBrushSpy.count(), 1); | |
156 | TRY_COMPARE(labelFontSpy.count(), 1); |
|
159 | TRY_COMPARE(labelFontSpy.count(), 1); | |
|
160 | TRY_COMPARE(labelPositionSpy.count(), 1); | |||
157 | TRY_COMPARE(labelArmLengthFactorSpy.count(), 1); |
|
161 | TRY_COMPARE(labelArmLengthFactorSpy.count(), 1); | |
158 | TRY_COMPARE(explodeDistanceFactorSpy.count(), 1); |
|
162 | TRY_COMPARE(explodeDistanceFactorSpy.count(), 1); | |
159 | TRY_COMPARE(colorSpy.count(), 1); |
|
163 | TRY_COMPARE(colorSpy.count(), 1); |
@@ -50,6 +50,7 Flow { | |||||
50 | ignoreUnknownSignals: true |
|
50 | ignoreUnknownSignals: true | |
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); | |||
53 | onExplodedChanged: console.log("slice.onExplodedChanged: " + series.at(0).exploded); |
|
54 | onExplodedChanged: console.log("slice.onExplodedChanged: " + series.at(0).exploded); | |
54 | onPenChanged: console.log("slice.onPenChanged: " + series.at(0).pen); |
|
55 | onPenChanged: console.log("slice.onPenChanged: " + series.at(0).pen); | |
55 | onBorderColorChanged: console.log("slice.onBorderColorChanged: " + series.at(0).borderColor); |
|
56 | onBorderColorChanged: console.log("slice.onBorderColorChanged: " + series.at(0).borderColor); | |
@@ -131,6 +132,14 Flow { | |||||
131 | onClicked: series.at(0).labelVisible = !series.at(0).labelVisible; |
|
132 | onClicked: series.at(0).labelVisible = !series.at(0).labelVisible; | |
132 | } |
|
133 | } | |
133 | Button { |
|
134 | Button { | |
|
135 | text: "slice label position inside" | |||
|
136 | onClicked: series.at(0).labelPosition = PieSlice.LabelInside; | |||
|
137 | } | |||
|
138 | Button { | |||
|
139 | text: "slice label position outside" | |||
|
140 | onClicked: series.at(0).labelPosition = PieSlice.LabelOutside; | |||
|
141 | } | |||
|
142 | Button { | |||
134 | text: "slice label arm len +" |
|
143 | text: "slice label arm len +" | |
135 | onClicked: series.at(0).labelArmLengthFactor += 0.1; |
|
144 | onClicked: series.at(0).labelArmLengthFactor += 0.1; | |
136 | } |
|
145 | } |
General Comments 0
You need to be logged in to leave comments.
Login now