##// END OF EJS Templates
Use labelBrush instead of labelPen for text labels
Tero Ahola -
r1307:7b3a3ea4ca65
parent child
Show More
@@ -152,8 +152,8 MainWidget::MainWidget(QWidget* parent)
152 m_brush = new QPushButton();
152 m_brush = new QPushButton();
153 m_brushTool = new BrushTool("Slice brush", this);
153 m_brushTool = new BrushTool("Slice brush", this);
154 m_font = new QPushButton();
154 m_font = new QPushButton();
155 m_labelPen = new QPushButton();
155 m_labelBrush = new QPushButton();
156 m_labelPenTool = new PenTool("Label pen", this);
156 m_labelBrushTool = new BrushTool("Label brush", this);
157 QPushButton *removeSlice = new QPushButton("Remove slice");
157 QPushButton *removeSlice = new QPushButton("Remove slice");
158
158
159 QFormLayout* sliceSettingsLayout = new QFormLayout();
159 QFormLayout* sliceSettingsLayout = new QFormLayout();
@@ -163,7 +163,7 MainWidget::MainWidget(QWidget* parent)
163 sliceSettingsLayout->addRow("Brush", m_brush);
163 sliceSettingsLayout->addRow("Brush", m_brush);
164 sliceSettingsLayout->addRow("Label visible", m_sliceLabelVisible);
164 sliceSettingsLayout->addRow("Label visible", m_sliceLabelVisible);
165 sliceSettingsLayout->addRow("Label font", m_font);
165 sliceSettingsLayout->addRow("Label font", m_font);
166 sliceSettingsLayout->addRow("Label pen", m_labelPen);
166 sliceSettingsLayout->addRow("Label pen", m_labelBrush);
167 sliceSettingsLayout->addRow("Label arm length", m_sliceLabelArmFactor);
167 sliceSettingsLayout->addRow("Label arm length", m_sliceLabelArmFactor);
168 sliceSettingsLayout->addRow("Exploded", m_sliceExploded);
168 sliceSettingsLayout->addRow("Exploded", m_sliceExploded);
169 sliceSettingsLayout->addRow("Explode distance", m_sliceExplodedFactor);
169 sliceSettingsLayout->addRow("Explode distance", m_sliceExplodedFactor);
@@ -177,8 +177,8 MainWidget::MainWidget(QWidget* parent)
177 connect(m_brush, SIGNAL(clicked()), m_brushTool, SLOT(show()));
177 connect(m_brush, SIGNAL(clicked()), m_brushTool, SLOT(show()));
178 connect(m_brushTool, SIGNAL(changed()), this, SLOT(updateSliceSettings()));
178 connect(m_brushTool, SIGNAL(changed()), this, SLOT(updateSliceSettings()));
179 connect(m_font, SIGNAL(clicked()), this, SLOT(showFontDialog()));
179 connect(m_font, SIGNAL(clicked()), this, SLOT(showFontDialog()));
180 connect(m_labelPen, SIGNAL(clicked()), m_labelPenTool, SLOT(show()));
180 connect(m_labelBrush, SIGNAL(clicked()), m_labelBrushTool, SLOT(show()));
181 connect(m_labelPenTool, SIGNAL(changed()), this, SLOT(updateSliceSettings()));
181 connect(m_labelBrushTool, SIGNAL(changed()), this, SLOT(updateSliceSettings()));
182 connect(m_sliceLabelVisible, SIGNAL(toggled(bool)), this, SLOT(updateSliceSettings()));
182 connect(m_sliceLabelVisible, SIGNAL(toggled(bool)), this, SLOT(updateSliceSettings()));
183 connect(m_sliceLabelVisible, SIGNAL(toggled(bool)), this, SLOT(updateSliceSettings()));
183 connect(m_sliceLabelVisible, SIGNAL(toggled(bool)), this, SLOT(updateSliceSettings()));
184 connect(m_sliceLabelArmFactor, SIGNAL(valueChanged(double)), this, SLOT(updateSliceSettings()));
184 connect(m_sliceLabelArmFactor, SIGNAL(valueChanged(double)), this, SLOT(updateSliceSettings()));
@@ -241,7 +241,7 void MainWidget::updateSliceSettings()
241 m_slice->setPen(m_penTool->pen());
241 m_slice->setPen(m_penTool->pen());
242 m_slice->setBrush(m_brushTool->brush());
242 m_slice->setBrush(m_brushTool->brush());
243
243
244 m_slice->setLabelPen(m_labelPenTool->pen());
244 m_slice->setLabelBrush(m_labelBrushTool->brush());
245 m_slice->setLabelVisible(m_sliceLabelVisible->isChecked());
245 m_slice->setLabelVisible(m_sliceLabelVisible->isChecked());
246 m_slice->setLabelArmLengthFactor(m_sliceLabelArmFactor->value());
246 m_slice->setLabelArmLengthFactor(m_sliceLabelArmFactor->value());
247
247
@@ -270,8 +270,8 void MainWidget::handleSliceClicked(QPieSlice* slice)
270 m_brushTool->setBrush(m_slice->originalBrush());
270 m_brushTool->setBrush(m_slice->originalBrush());
271
271
272 // label
272 // label
273 m_labelPen->setText(PenTool::name(m_slice->labelPen()));
273 m_labelBrush->setText(BrushTool::name(m_slice->labelBrush()));
274 m_labelPenTool->setPen(m_slice->labelPen());
274 m_labelBrushTool->setBrush(m_slice->labelBrush());
275 m_font->setText(slice->labelFont().toString());
275 m_font->setText(slice->labelFont().toString());
276 m_sliceLabelVisible->blockSignals(true);
276 m_sliceLabelVisible->blockSignals(true);
277 m_sliceLabelVisible->setChecked(slice->isLabelVisible());
277 m_sliceLabelVisible->setChecked(slice->isLabelVisible());
@@ -84,8 +84,8 private:
84 QPushButton *m_pen;
84 QPushButton *m_pen;
85 PenTool *m_penTool;
85 PenTool *m_penTool;
86 QPushButton *m_font;
86 QPushButton *m_font;
87 QPushButton *m_labelPen;
87 QPushButton *m_labelBrush;
88 PenTool *m_labelPenTool;
88 BrushTool *m_labelBrushTool;
89 };
89 };
90
90
91 #endif // MAINWIDGET_H
91 #endif // MAINWIDGET_H
@@ -70,14 +70,15 void DeclarativePieSlice::setBorderWidth(int width)
70
70
71 QColor DeclarativePieSlice::labelColor()
71 QColor DeclarativePieSlice::labelColor()
72 {
72 {
73 return labelPen().color();
73 return labelBrush().color();
74 }
74 }
75
75
76 void DeclarativePieSlice::setLabelColor(QColor color)
76 void DeclarativePieSlice::setLabelColor(QColor color)
77 {
77 {
78 QPen p = labelPen();
78 // TODO: use brush instead for label color
79 p.setColor(color);
79 QBrush b = labelBrush();
80 setLabelPen(p);
80 b.setColor(color);
81 setLabelBrush(b);
81 }
82 }
82
83
83 DeclarativePieSeries::DeclarativePieSeries(QObject *parent) :
84 DeclarativePieSeries::DeclarativePieSeries(QObject *parent) :
@@ -267,25 +267,6 QBrush QBarSet::brush() const
267 }
267 }
268
268
269 /*!
269 /*!
270 Sets \a pen of the values that are drawn on top of this barset
271 */
272 void QBarSet::setLabelPen(const QPen &pen)
273 {
274 if(d_ptr->m_labelPen!=pen){
275 d_ptr->m_labelPen = pen;
276 emit d_ptr->updatedBars();
277 }
278 }
279
280 /*!
281 Returns pen of the values that are drawn on top of this barset
282 */
283 QPen QBarSet::labelPen() const
284 {
285 return d_ptr->m_labelPen;
286 }
287
288 /*!
289 Sets \a brush of the values that are drawn on top of this barset
270 Sets \a brush of the values that are drawn on top of this barset
290 */
271 */
291 void QBarSet::setLabelBrush(const QBrush &brush)
272 void QBarSet::setLabelBrush(const QBrush &brush)
@@ -63,9 +63,6 public:
63 void setBrush(const QBrush &brush);
63 void setBrush(const QBrush &brush);
64 QBrush brush() const;
64 QBrush brush() const;
65
65
66 void setLabelPen(const QPen &pen);
67 QPen labelPen() const;
68
69 void setLabelBrush(const QBrush &brush);
66 void setLabelBrush(const QBrush &brush);
70 QBrush labelBrush() const;
67 QBrush labelBrush() const;
71
68
@@ -57,7 +57,6 public:
57 QList<QPointF> m_values;
57 QList<QPointF> m_values;
58 QPen m_pen;
58 QPen m_pen;
59 QBrush m_brush;
59 QBrush m_brush;
60 QPen m_labelPen;
61 QBrush m_labelBrush;
60 QBrush m_labelBrush;
62 QFont m_labelFont;
61 QFont m_labelFont;
63
62
@@ -234,8 +234,8 void ChartTheme::decorate(QPieSeries *series, int index)
234 if (d->m_data.m_sliceBrush.isThemed() || m_force)
234 if (d->m_data.m_sliceBrush.isThemed() || m_force)
235 d->setBrush(brushColor, true);
235 d->setBrush(brushColor, true);
236
236
237 if (d->m_data.m_labelPen.isThemed() || m_force)
237 if (d->m_data.m_labelBrush.isThemed() || m_force)
238 d->setLabelPen(QPen(m_titleBrush.color()), true);
238 d->setLabelBrush(QBrush(m_titleBrush.color()), true);
239
239
240 if (d->m_data.m_labelFont.isThemed() || m_force)
240 if (d->m_data.m_labelFont.isThemed() || m_force)
241 d->setLabelFont(m_labelFont, true);
241 d->setLabelFont(m_labelFont, true);
@@ -143,7 +143,7 void PieChartItem::handleSlicesAdded(QList<QPieSlice*> slices)
143 connect(slice, SIGNAL(explodedChanged()), this, SLOT(handleSliceChanged()));
143 connect(slice, SIGNAL(explodedChanged()), this, SLOT(handleSliceChanged()));
144 connect(slice, SIGNAL(penChanged()), this, SLOT(handleSliceChanged()));
144 connect(slice, SIGNAL(penChanged()), this, SLOT(handleSliceChanged()));
145 connect(slice, SIGNAL(brushChanged()), this, SLOT(handleSliceChanged()));
145 connect(slice, SIGNAL(brushChanged()), this, SLOT(handleSliceChanged()));
146 connect(slice, SIGNAL(labelPenChanged()), 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(labelArmLengthFactorChanged()), this, SLOT(handleSliceChanged()));
148 connect(slice, SIGNAL(labelArmLengthFactorChanged()), this, SLOT(handleSliceChanged()));
149 connect(slice, SIGNAL(explodeDistanceFactorChanged()), this, SLOT(handleSliceChanged()));
149 connect(slice, SIGNAL(explodeDistanceFactorChanged()), this, SLOT(handleSliceChanged()));
@@ -91,7 +91,7 public:
91 m_labelText != other.m_labelText ||
91 m_labelText != other.m_labelText ||
92 m_labelFont != other.m_labelFont ||
92 m_labelFont != other.m_labelFont ||
93 !qFuzzyIsNull(m_labelArmLengthFactor - other.m_labelArmLengthFactor) ||
93 !qFuzzyIsNull(m_labelArmLengthFactor - other.m_labelArmLengthFactor) ||
94 m_labelPen != other.m_labelPen)
94 m_labelBrush != other.m_labelBrush)
95 return true;
95 return true;
96
96
97 if (!qFuzzyIsNull(m_percentage - other.m_percentage) ||
97 if (!qFuzzyIsNull(m_percentage - other.m_percentage) ||
@@ -116,7 +116,7 public:
116 QString m_labelText;
116 QString m_labelText;
117 Themed<QFont> m_labelFont;
117 Themed<QFont> m_labelFont;
118 qreal m_labelArmLengthFactor;
118 qreal m_labelArmLengthFactor;
119 Themed<QPen> m_labelPen;
119 Themed<QBrush> m_labelBrush;
120
120
121 qreal m_percentage;
121 qreal m_percentage;
122 QPointF m_center;
122 QPointF m_center;
@@ -81,9 +81,10 void PieSliceItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*op
81 if (m_data.m_isLabelVisible) {
81 if (m_data.m_isLabelVisible) {
82 painter->save();
82 painter->save();
83 painter->setClipRect(parentItem()->boundingRect());
83 painter->setClipRect(parentItem()->boundingRect());
84 painter->setPen(m_data.m_labelPen);
84 // Pen for label arm not defined in the QPieSeries api, let's use brush's color instead
85 // Also, the drawText actually uses the pen color for the text color (unlike QGraphicsSimpleTextItem)
86 painter->setPen(m_data.m_labelBrush.color());
85 painter->drawPath(m_labelArmPath);
87 painter->drawPath(m_labelArmPath);
86 // the pen color will affect the font color as well
87 painter->setFont(m_data.m_labelFont);
88 painter->setFont(m_data.m_labelFont);
88 painter->drawText(m_labelTextRect.bottomLeft(), m_data.m_labelText);
89 painter->drawText(m_labelTextRect.bottomLeft(), m_data.m_labelText);
89 painter->restore();
90 painter->restore();
@@ -43,7 +43,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
43
43
44 Label of the slice.
44 Label of the slice.
45
45
46 \sa labelVisible, labelPen, labelFont, labelArmLengthFactor
46 \sa labelVisible, labelBrush, labelFont, labelArmLengthFactor
47 */
47 */
48
48
49 /*!
49 /*!
@@ -79,7 +79,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
79
79
80 Default is not visible.
80 Default is not visible.
81
81
82 \sa label, labelPen, labelFont, labelArmLengthFactor
82 \sa label, labelBrush, labelFont, labelArmLengthFactor
83 */
83 */
84
84
85 /*!
85 /*!
@@ -135,7 +135,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
135 */
135 */
136
136
137 /*!
137 /*!
138 \property QPieSlice::labelPen
138 \property QPieSlice::labelBrush
139
139
140 Pen used to draw label and label arm of the slice.
140 Pen used to draw label and label arm of the slice.
141
141
@@ -143,11 +143,11 QTCOMMERCIALCHART_BEGIN_NAMESPACE
143 */
143 */
144
144
145 /*!
145 /*!
146 \fn void QPieSlice::labelPenChanged()
146 \fn void QPieSlice::labelBrushChanged()
147
147
148 This signal is emitted when the label pen of the slice has changed.
148 This signal is emitted when the label pen of the slice has changed.
149
149
150 \sa labelPen
150 \sa labelBrush
151 */
151 */
152
152
153 /*!
153 /*!
@@ -177,7 +177,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
177
177
178 Default value is 0.15
178 Default value is 0.15
179
179
180 \sa label, labelVisible, labelPen, labelFont
180 \sa label, labelVisible, labelBrush, labelFont
181 */
181 */
182
182
183 /*!
183 /*!
@@ -391,14 +391,14 QBrush QPieSlice::brush() const
391 return d_ptr->m_data.m_sliceBrush;
391 return d_ptr->m_data.m_sliceBrush;
392 }
392 }
393
393
394 void QPieSlice::setLabelPen(const QPen &pen)
394 void QPieSlice::setLabelBrush(const QBrush &brush)
395 {
395 {
396 d_ptr->setLabelPen(pen, false);
396 d_ptr->setLabelBrush(brush, false);
397 }
397 }
398
398
399 QPen QPieSlice::labelPen() const
399 QBrush QPieSlice::labelBrush() const
400 {
400 {
401 return d_ptr->m_data.m_labelPen;
401 return d_ptr->m_data.m_labelBrush;
402 }
402 }
403
403
404 void QPieSlice::setLabelFont(const QFont &font)
404 void QPieSlice::setLabelFont(const QFont &font)
@@ -487,12 +487,12 void QPieSlicePrivate::setBrush(const QBrush &brush, bool themed)
487 }
487 }
488 }
488 }
489
489
490 void QPieSlicePrivate::setLabelPen(const QPen &pen, bool themed)
490 void QPieSlicePrivate::setLabelBrush(const QBrush &brush, bool themed)
491 {
491 {
492 if (m_data.m_labelPen != pen) {
492 if (m_data.m_labelBrush != brush) {
493 m_data.m_labelPen = pen;
493 m_data.m_labelBrush = brush;
494 m_data.m_labelPen.setThemed(themed);
494 m_data.m_labelBrush.setThemed(themed);
495 emit q_ptr->labelPenChanged();
495 emit q_ptr->labelBrushChanged();
496 }
496 }
497 }
497 }
498
498
@@ -39,7 +39,7 class QTCOMMERCIALCHART_EXPORT QPieSlice : public QObject
39 Q_PROPERTY(bool exploded READ isExploded WRITE setExploded NOTIFY explodedChanged)
39 Q_PROPERTY(bool exploded READ isExploded WRITE setExploded NOTIFY explodedChanged)
40 Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged)
40 Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged)
41 Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged)
41 Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged)
42 Q_PROPERTY(QPen labelPen READ labelPen WRITE setLabelPen NOTIFY labelPenChanged)
42 Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush NOTIFY labelBrushChanged)
43 Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont NOTIFY labelFontChanged)
43 Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont NOTIFY labelFontChanged)
44 Q_PROPERTY(qreal labelArmLengthFactor READ labelArmLengthFactor WRITE setLabelArmLengthFactor)
44 Q_PROPERTY(qreal labelArmLengthFactor READ labelArmLengthFactor WRITE setLabelArmLengthFactor)
45 Q_PROPERTY(qreal explodeDistanceFactor READ explodeDistanceFactor WRITE setExplodeDistanceFactor)
45 Q_PROPERTY(qreal explodeDistanceFactor READ explodeDistanceFactor WRITE setExplodeDistanceFactor)
@@ -70,8 +70,8 public:
70 void setBrush(const QBrush &brush);
70 void setBrush(const QBrush &brush);
71 QBrush brush() const;
71 QBrush brush() const;
72
72
73 void setLabelPen(const QPen &pen);
73 void setLabelBrush(const QBrush &brush);
74 QPen labelPen() const;
74 QBrush labelBrush() const;
75
75
76 void setLabelFont(const QFont &font);
76 void setLabelFont(const QFont &font);
77 QFont labelFont() const;
77 QFont labelFont() const;
@@ -93,7 +93,7 Q_SIGNALS:
93 void explodedChanged();
93 void explodedChanged();
94 void penChanged();
94 void penChanged();
95 void brushChanged();
95 void brushChanged();
96 void labelPenChanged();
96 void labelBrushChanged();
97 void labelFontChanged();
97 void labelFontChanged();
98 void labelArmLengthFactorChanged();
98 void labelArmLengthFactorChanged();
99 void explodeDistanceFactorChanged();
99 void explodeDistanceFactorChanged();
@@ -19,7 +19,7 public:
19
19
20 void setPen(const QPen &pen, bool themed);
20 void setPen(const QPen &pen, bool themed);
21 void setBrush(const QBrush &brush, bool themed);
21 void setBrush(const QBrush &brush, bool themed);
22 void setLabelPen(const QPen &pen, bool themed);
22 void setLabelBrush(const QBrush &brush, bool themed);
23 void setLabelFont(const QFont &font, bool themed);
23 void setLabelFont(const QFont &font, bool themed);
24
24
25 void setPercentage(qreal percentage);
25 void setPercentage(qreal percentage);
@@ -60,8 +60,6 private slots:
60 void setPen();
60 void setPen();
61 void setBrush_data();
61 void setBrush_data();
62 void setBrush();
62 void setBrush();
63 void setLabelPen_data();
64 void setLabelPen();
65 void setLabelBrush_data();
63 void setLabelBrush_data();
66 void setLabelBrush();
64 void setLabelBrush();
67 void setLabelFont_data();
65 void setLabelFont_data();
@@ -380,22 +378,6 void tst_QBarSet::setBrush()
380 QVERIFY(m_barset->brush() == brush);
378 QVERIFY(m_barset->brush() == brush);
381 }
379 }
382
380
383 void tst_QBarSet::setLabelPen_data()
384 {
385
386 }
387
388 void tst_QBarSet::setLabelPen()
389 {
390 QVERIFY(m_barset->labelPen() == QPen());
391
392 QPen pen;
393 pen.setColor(QColor(128,128,128,128));
394 m_barset->setLabelPen(pen);
395
396 QVERIFY(m_barset->labelPen() == pen);
397 }
398
399 void tst_QBarSet::setLabelBrush_data()
381 void tst_QBarSet::setLabelBrush_data()
400 {
382 {
401
383
@@ -79,7 +79,7 void tst_qpieslice::construction()
79 QVERIFY(!slice1.isExploded());
79 QVERIFY(!slice1.isExploded());
80 QCOMPARE(slice1.pen(), QPen());
80 QCOMPARE(slice1.pen(), QPen());
81 QCOMPARE(slice1.brush(), QBrush());
81 QCOMPARE(slice1.brush(), QBrush());
82 QCOMPARE(slice1.labelPen(), QPen());
82 QCOMPARE(slice1.labelBrush(), QBrush());
83 QCOMPARE(slice1.labelFont(), QFont());
83 QCOMPARE(slice1.labelFont(), QFont());
84 QCOMPARE(slice1.labelArmLengthFactor(), 0.15); // default value
84 QCOMPARE(slice1.labelArmLengthFactor(), 0.15); // default value
85 QCOMPARE(slice1.explodeDistanceFactor(), 0.15); // default value
85 QCOMPARE(slice1.explodeDistanceFactor(), 0.15); // default value
@@ -95,7 +95,7 void tst_qpieslice::construction()
95 QVERIFY(!slice2.isExploded());
95 QVERIFY(!slice2.isExploded());
96 QCOMPARE(slice2.pen(), QPen());
96 QCOMPARE(slice2.pen(), QPen());
97 QCOMPARE(slice2.brush(), QBrush());
97 QCOMPARE(slice2.brush(), QBrush());
98 QCOMPARE(slice2.labelPen(), QPen());
98 QCOMPARE(slice2.labelBrush(), QBrush());
99 QCOMPARE(slice2.labelFont(), QFont());
99 QCOMPARE(slice2.labelFont(), QFont());
100 QCOMPARE(slice2.labelArmLengthFactor(), 0.15); // default value
100 QCOMPARE(slice2.labelArmLengthFactor(), 0.15); // default value
101 QCOMPARE(slice2.explodeDistanceFactor(), 0.15); // default value
101 QCOMPARE(slice2.explodeDistanceFactor(), 0.15); // default value
@@ -113,7 +113,7 void tst_qpieslice::changedSignals()
113 QSignalSpy explodedSpy(&slice, SIGNAL(explodedChanged()));
113 QSignalSpy explodedSpy(&slice, SIGNAL(explodedChanged()));
114 QSignalSpy penSpy(&slice, SIGNAL(penChanged()));
114 QSignalSpy penSpy(&slice, SIGNAL(penChanged()));
115 QSignalSpy brushSpy(&slice, SIGNAL(brushChanged()));
115 QSignalSpy brushSpy(&slice, SIGNAL(brushChanged()));
116 QSignalSpy labelPenSpy(&slice, SIGNAL(labelPenChanged()));
116 QSignalSpy labelBrushSpy(&slice, SIGNAL(labelBrushChanged()));
117 QSignalSpy labelFontSpy(&slice, SIGNAL(labelFontChanged()));
117 QSignalSpy labelFontSpy(&slice, SIGNAL(labelFontChanged()));
118 QSignalSpy labelArmLengthFactorSpy(&slice, SIGNAL(labelArmLengthFactorChanged()));
118 QSignalSpy labelArmLengthFactorSpy(&slice, SIGNAL(labelArmLengthFactorChanged()));
119 QSignalSpy explodeDistanceFactorSpy(&slice, SIGNAL(explodeDistanceFactorChanged()));
119 QSignalSpy explodeDistanceFactorSpy(&slice, SIGNAL(explodeDistanceFactorChanged()));
@@ -134,8 +134,8 void tst_qpieslice::changedSignals()
134 slice.setPen(QPen(Qt::red));
134 slice.setPen(QPen(Qt::red));
135 slice.setBrush(QBrush(Qt::red));
135 slice.setBrush(QBrush(Qt::red));
136 slice.setBrush(QBrush(Qt::red));
136 slice.setBrush(QBrush(Qt::red));
137 slice.setLabelPen(QPen(Qt::green));
137 slice.setLabelBrush(QBrush(Qt::green));
138 slice.setLabelPen(QPen(Qt::green));
138 slice.setLabelBrush(QBrush(Qt::green));
139 slice.setLabelFont(QFont("Tahoma"));
139 slice.setLabelFont(QFont("Tahoma"));
140 slice.setLabelFont(QFont("Tahoma"));
140 slice.setLabelFont(QFont("Tahoma"));
141 slice.setLabelArmLengthFactor(0.1);
141 slice.setLabelArmLengthFactor(0.1);
@@ -148,7 +148,7 void tst_qpieslice::changedSignals()
148 TRY_COMPARE(explodedSpy.count(), 1);
148 TRY_COMPARE(explodedSpy.count(), 1);
149 TRY_COMPARE(penSpy.count(), 1);
149 TRY_COMPARE(penSpy.count(), 1);
150 TRY_COMPARE(brushSpy.count(), 1);
150 TRY_COMPARE(brushSpy.count(), 1);
151 TRY_COMPARE(labelPenSpy.count(), 1);
151 TRY_COMPARE(labelBrushSpy.count(), 1);
152 TRY_COMPARE(labelFontSpy.count(), 1);
152 TRY_COMPARE(labelFontSpy.count(), 1);
153 TRY_COMPARE(labelArmLengthFactorSpy.count(), 1);
153 TRY_COMPARE(labelArmLengthFactorSpy.count(), 1);
154 TRY_COMPARE(explodeDistanceFactorSpy.count(), 1);
154 TRY_COMPARE(explodeDistanceFactorSpy.count(), 1);
@@ -167,7 +167,7 void tst_qpieslice::customize()
167 s1->setPen(p1);
167 s1->setPen(p1);
168 QBrush b1(Qt::red);
168 QBrush b1(Qt::red);
169 s1->setBrush(b1);
169 s1->setBrush(b1);
170 s1->setLabelPen(p1);
170 s1->setLabelBrush(b1);
171 QFont f1("Consolas");
171 QFont f1("Consolas");
172 s1->setLabelFont(f1);
172 s1->setLabelFont(f1);
173
173
@@ -182,28 +182,28 void tst_qpieslice::customize()
182 // check that customizations persist
182 // check that customizations persist
183 QCOMPARE(s1->pen(), p1);
183 QCOMPARE(s1->pen(), p1);
184 QCOMPARE(s1->brush(), b1);
184 QCOMPARE(s1->brush(), b1);
185 QCOMPARE(s1->labelPen(), p1);
185 QCOMPARE(s1->labelBrush(), b1);
186 QCOMPARE(s1->labelFont(), f1);
186 QCOMPARE(s1->labelFont(), f1);
187
187
188 // remove a slice
188 // remove a slice
189 series->remove(s2);
189 series->remove(s2);
190 QCOMPARE(s1->pen(), p1);
190 QCOMPARE(s1->pen(), p1);
191 QCOMPARE(s1->brush(), b1);
191 QCOMPARE(s1->brush(), b1);
192 QCOMPARE(s1->labelPen(), p1);
192 QCOMPARE(s1->labelBrush(), b1);
193 QCOMPARE(s1->labelFont(), f1);
193 QCOMPARE(s1->labelFont(), f1);
194
194
195 // add a slice
195 // add a slice
196 series->append("slice 4", 4);
196 series->append("slice 4", 4);
197 QCOMPARE(s1->pen(), p1);
197 QCOMPARE(s1->pen(), p1);
198 QCOMPARE(s1->brush(), b1);
198 QCOMPARE(s1->brush(), b1);
199 QCOMPARE(s1->labelPen(), p1);
199 QCOMPARE(s1->labelBrush(), b1);
200 QCOMPARE(s1->labelFont(), f1);
200 QCOMPARE(s1->labelFont(), f1);
201
201
202 // insert a slice
202 // insert a slice
203 series->insert(0, new QPieSlice("slice 5", 5));
203 series->insert(0, new QPieSlice("slice 5", 5));
204 QCOMPARE(s1->pen(), p1);
204 QCOMPARE(s1->pen(), p1);
205 QCOMPARE(s1->brush(), b1);
205 QCOMPARE(s1->brush(), b1);
206 QCOMPARE(s1->labelPen(), p1);
206 QCOMPARE(s1->labelBrush(), b1);
207 QCOMPARE(s1->labelFont(), f1);
207 QCOMPARE(s1->labelFont(), f1);
208
208
209 // change theme
209 // change theme
@@ -211,7 +211,7 void tst_qpieslice::customize()
211 view.chart()->setTheme(QChart::ChartThemeHighContrast);
211 view.chart()->setTheme(QChart::ChartThemeHighContrast);
212 QVERIFY(s1->pen() != p1);
212 QVERIFY(s1->pen() != p1);
213 QVERIFY(s1->brush() != b1);
213 QVERIFY(s1->brush() != b1);
214 QVERIFY(s1->labelPen() != p1);
214 QVERIFY(s1->labelBrush() != b1);
215 QVERIFY(s1->labelFont() != f1);
215 QVERIFY(s1->labelFont() != f1);
216 }
216 }
217
217
General Comments 0
You need to be logged in to leave comments. Login now