##// END OF EJS Templates
Fix spelling errors
Jani Honkonen -
r1940:c7b5c0b5fd0b
parent child
Show More
@@ -1,110 +1,110
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "declarativemodel.h"
22 22 #include <qdeclarativelist.h>
23 23 #include <QStringList>
24 24 #include <QDebug>
25 25
26 26 ////////////// Table model element ///////////////////
27 27
28 28 DeclarativeTableModelElement::DeclarativeTableModelElement(QObject *parent)
29 29 : QObject(parent)
30 30 {
31 31 }
32 32
33 33 QVariantList DeclarativeTableModelElement::values()
34 34 {
35 35 return m_values;
36 36 }
37 37
38 38 void DeclarativeTableModelElement::setValues(QVariantList values)
39 39 {
40 40 m_values = values;
41 41 }
42 42
43 43 ////////////// Table model ///////////////////
44 44
45 45 DeclarativeTableModel::DeclarativeTableModel(QObject *parent) :
46 46 CustomTableModel(parent)
47 47 {
48 48 }
49 49
50 50 void DeclarativeTableModel::classBegin()
51 51 {
52 52 }
53 53
54 54 void DeclarativeTableModel::componentComplete()
55 55 {
56 56 foreach (QObject *child, children()) {
57 57 if (qobject_cast<DeclarativeTableModelElement *>(child)) {
58 58 DeclarativeTableModelElement *element = qobject_cast<DeclarativeTableModelElement *>(child);
59 59 append(element->values());
60 60 }
61 61 }
62 62 }
63 63
64 64 void DeclarativeTableModel::setVerticalHeaders(QStringList headers)
65 65 {
66 66 for (int i(0); i < headers.count(); i++)
67 67 setHeaderData(i, Qt::Vertical, headers.at(i));
68 68 }
69 69
70 70 QStringList DeclarativeTableModel::verticalHeaders()
71 71 {
72 72 return QStringList();
73 73 }
74 74
75 75 QDeclarativeListProperty<QObject> DeclarativeTableModel::modelChildren()
76 76 {
77 77 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeTableModel::appendModelChild);
78 78 }
79 79
80 80 void DeclarativeTableModel::appendModelChild(QDeclarativeListProperty<QObject> *list,
81 81 QObject *child)
82 82 {
83 // childs are added in componentComplete instead
83 // children are added in componentComplete instead
84 84 Q_UNUSED(list)
85 85 Q_UNUSED(child)
86 86 }
87 87
88 88 void DeclarativeTableModel::append(QVariantList values)
89 89 {
90 90 // qDebug() << "DeclarativeTableModel::append:" << values;
91 91
92 92 while (columnCount() < values.count())
93 93 insertColumn(columnCount());
94 94
95 95 insertRow(rowCount());
96 96
97 97 QModelIndex beginIndex = QModelIndex();
98 98 QModelIndex endIndex = QModelIndex();
99 99 for (int i(0); i < values.count(); i++) {
100 100 QModelIndex modelIndex = createIndex(rowCount() - 1, i);
101 101 if (i == 0)
102 102 beginIndex = modelIndex;
103 103 if (i == (values.count() - 1))
104 104 endIndex = modelIndex;
105 105 setData(modelIndex, values.at(i));
106 106 }
107 107 dataChanged(beginIndex, endIndex);
108 108 }
109 109
110 110 #include "moc_declarativemodel.cpp"
@@ -1,49 +1,49
1 1 /*!
2 2 \example demos/nesteddonuts
3 3 \title Nested donuts demo
4 4 \subtitle
5 5
6 6 This example shows how to use create a nested donuts chart using QPieSeries API.
7 7 \image examples_donutchart.png
8 8
9 9 Let's start by creating a QChartView instance and enabling the Antialiasing on it. Last line enables the animations of the chart.
10 10
11 11 \snippet ../demos/nesteddonuts/widget.cpp 1
12 12
13 13 Three variables are defined that will be used to define the donut chart. Min and max size define the relative size of the whole donut.
14 14 minSize is the relative inner size of the smallest donut. maxSize is the relative outer size of the biggest donut.
15 15
16 16 \snippet ../demos/nesteddonuts/widget.cpp 2
17 17
18 18 Following block of code defines the individual donuts and their slices. First new QPieSeries object is created.
19 19 Callign setDonut() changes pie into a donut. The number of slices in each donut is randomized.
20 20 The internal for loop creates the slices with a random value and label same as the value.
21 21 Next the label of the slice is set to be visible and its color is set to white.
22 22 To make the example more interesting the hovered signal of the slice is connected to widget's slot which inner workings are explained later.
23 Finally the slice is added to the donut. The donut's size is adjusted to achive the nesting of the donuts.
23 Finally the slice is added to the donut. The donut's size is adjusted to achieve the nesting of the donuts.
24 24 Then the donut is added to the widget's list of donuts and to the chart.
25 25
26 26 \snippet ../demos/nesteddonuts/widget.cpp 3
27 27
28 28 Finally the widget is placed in a layout used by the application.
29 29
30 30 \snippet ../demos/nesteddonuts/widget.cpp 4
31 31
32 32 To make the example more interesting the donuts are rotated randomly every 1.25 sec.
33 33
34 34 \snippet ../demos/nesteddonuts/widget.cpp 5
35 35
36 36 The widget's updatedRotation slot is defined below.
37 37 It goes through all of the donuts and modifies thier current rotation by a random value.
38 38
39 39 \snippet ../demos/nesteddonuts/widget.cpp 6
40 40
41 41 The earlier mentioned explodeSlice slot code is provided below.
42 42 If the slice is set to exploded then stop the timer that controls the donuts rotation.
43 43 Then the slice's start and end agles are obtained from the slice.
44 44 To highlight the selected slice all the other donuts that lie outward from the one that contains the selected slice
45 45 have their start and end angles modified so that they wouldn't "block" the way for the hightlighted slice.
46 46 If the slice is no longer selected return to the original state.
47 47
48 48 \snippet ../demos/nesteddonuts/widget.cpp 7
49 49 */
@@ -1,45 +1,45
1 1 /*!
2 2 \example examples/stackedbarchartdrilldown
3 3 \title StackedBarChart Drilldown Example
4 4 \subtitle
5 5
6 6 The example shows how to implement drilldown using stacked barchart. In drilldown example we create stacked barchart, which shows the harvest of various chili peppers during season. In season view the harvest is grouped by month. To drill down to weekly view, user clicks selected month with right mouse button. On weekly view, the harvest of clicked month is shown by week. For example purposes each month is 4 weeks long :)
7 7
8 8 Season view looks like this:
9 9 \image examples_stackedbarchartdrilldown1.png
10 10
11 11 Mouse button clicked on a month, shows the harvest from that month:
12 12 \image examples_stackedbarchartdrilldown2.png
13 13
14 14 First we define a drilldown series class, which adds categories to stacked bar series and mapping for categories to other drilldown series.
15 15 Purpose of drilldown series is to contain knowledge of the drilldown structure. The mapDrilldownSeries function maps the category to given series. We can ask the mapping for category with drilldownSeries(int category) function.
16 16
17 17 \snippet ../examples/stackedbarchartdrilldown/drilldownseries.h 1
18 18
19 19 Next we define our own drilldown chart, which implements handler for mouse click. All QBarSeries derived classes send out clicked(QBarSet*, int) signal when series is clicked with mouse. The parameter QBarSet contains pointer to clicked bar set and parameter int contains the index of clicked category.
20 20
21 21 \snippet ../examples/stackedbarchartdrilldown/drilldownchart.h 1
22 22
23 23 Now we have our drilldown classes and we can start using them.
24 24 First create the chart.
25 25
26 26 \snippet ../examples/stackedbarchartdrilldown/main.cpp 1
27 27
28 We define categories, from wich the drilldown series will be constructed.
28 We define categories, from which the drilldown series will be constructed.
29 29
30 30 \snippet ../examples/stackedbarchartdrilldown/main.cpp 2
31 31
32 32 To create the drilldown structure, we first create our top level series, which we call seasonSeries. For each month in seasonSeries we create a drilldown series, called weeklySeries which contains more detailed data for that month.
33 33 In weeklySeries, we use the drilldown handler to bring us back to seasonSeries. To do this we add mapping to the series. The seasonSeries is mapped to weeklySeries for each month. Every weeklySeries is mapped back to the seasonSeries.
34 34 To make mapping work, we connect the clicked signals from our series to the drilldownChart.
35 35
36 36 \snippet ../examples/stackedbarchartdrilldown/main.cpp 3
37 37
38 38 When we have our drilldown structure ready, we can add the data to it. Here we generate random crop for each plant in each week. The monthly crop is calculated from weekly crops and is set as value to monthly series.
39 39
40 40 \snippet ../examples/stackedbarchartdrilldown/main.cpp 4
41 41
42 42 Here we set the chart to show top level series initially.
43 43
44 44 \snippet ../examples/stackedbarchartdrilldown/main.cpp 5
45 45 */
@@ -1,99 +1,99
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "declarativelineseries.h"
22 22
23 23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24 24
25 25 DeclarativeLineSeries::DeclarativeLineSeries(QObject *parent) :
26 26 QLineSeries(parent),
27 27 m_axisX(0),
28 28 m_axisY(0)
29 29 {
30 30 connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int)));
31 31 connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int)));
32 32 }
33 33
34 34 void DeclarativeLineSeries::handleCountChanged(int index)
35 35 {
36 36 Q_UNUSED(index)
37 37 emit countChanged(points().count());
38 38 }
39 39
40 40 qreal DeclarativeLineSeries::width() const
41 41 {
42 42 return pen().widthF();
43 43 }
44 44
45 45 void DeclarativeLineSeries::setWidth(qreal width)
46 46 {
47 47 if (width != pen().widthF()) {
48 48 QPen p = pen();
49 49 p.setWidthF(width);
50 50 setPen(p);
51 51 emit widthChanged(width);
52 52 }
53 53 }
54 54
55 55 Qt::PenStyle DeclarativeLineSeries::style() const
56 56 {
57 57 return pen().style();
58 58 }
59 59
60 60 void DeclarativeLineSeries::setStyle(Qt::PenStyle style)
61 61 {
62 62 if (style != pen().style()) {
63 63 QPen p = pen();
64 64 p.setStyle(style);
65 65 setPen(p);
66 66 emit styleChanged(style);
67 67 }
68 68 }
69 69
70 70 Qt::PenCapStyle DeclarativeLineSeries::capStyle() const
71 71 {
72 72 return pen().capStyle();
73 73 }
74 74
75 75 void DeclarativeLineSeries::setCapStyle(Qt::PenCapStyle capStyle)
76 76 {
77 77 if (capStyle != pen().capStyle()) {
78 78 QPen p = pen();
79 79 p.setCapStyle(capStyle);
80 80 setPen(p);
81 81 emit capStyleChanged(capStyle);
82 82 }
83 83 }
84 84
85 85 QDeclarativeListProperty<QObject> DeclarativeLineSeries::declarativeChildren()
86 86 {
87 87 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
88 88 }
89 89
90 90 void DeclarativeLineSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
91 91 {
92 92 Q_UNUSED(list)
93 93 Q_UNUSED(element)
94 // Empty implementation, childs are parsed in componentComplete
94 // Empty implementation, children are parsed in componentComplete
95 95 }
96 96
97 97 #include "moc_declarativelineseries.cpp"
98 98
99 99 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,69 +1,69
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "declarativescatterseries.h"
22 22
23 23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24 24
25 25 DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) :
26 26 QScatterSeries(parent),
27 27 m_axisX(0),
28 28 m_axisY(0)
29 29 {
30 30 connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int)));
31 31 connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int)));
32 32 }
33 33
34 34 void DeclarativeScatterSeries::handleCountChanged(int index)
35 35 {
36 36 Q_UNUSED(index)
37 37 emit countChanged(QScatterSeries::count());
38 38 }
39 39
40 40 qreal DeclarativeScatterSeries::borderWidth() const
41 41 {
42 42 return pen().widthF();
43 43 }
44 44
45 45 void DeclarativeScatterSeries::setBorderWidth(qreal width)
46 46 {
47 47 if (width != pen().widthF()) {
48 48 QPen p = pen();
49 49 p.setWidthF(width);
50 50 setPen(p);
51 51 emit borderWidthChanged(width);
52 52 }
53 53 }
54 54
55 55 QDeclarativeListProperty<QObject> DeclarativeScatterSeries::declarativeChildren()
56 56 {
57 57 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
58 58 }
59 59
60 60 void DeclarativeScatterSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
61 61 {
62 62 Q_UNUSED(list)
63 63 Q_UNUSED(element)
64 // Empty implementation, childs are parsed in componentComplete
64 // Empty implementation, children are parsed in componentComplete
65 65 }
66 66
67 67 #include "moc_declarativescatterseries.cpp"
68 68
69 69 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,99 +1,99
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "declarativesplineseries.h"
22 22
23 23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24 24
25 25 DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) :
26 26 QSplineSeries(parent),
27 27 m_axisX(0),
28 28 m_axisY(0)
29 29 {
30 30 connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int)));
31 31 connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int)));
32 32 }
33 33
34 34 void DeclarativeSplineSeries::handleCountChanged(int index)
35 35 {
36 36 Q_UNUSED(index)
37 37 emit countChanged(points().count());
38 38 }
39 39
40 40 qreal DeclarativeSplineSeries::width() const
41 41 {
42 42 return pen().widthF();
43 43 }
44 44
45 45 void DeclarativeSplineSeries::setWidth(qreal width)
46 46 {
47 47 if (width != pen().widthF()) {
48 48 QPen p = pen();
49 49 p.setWidthF(width);
50 50 setPen(p);
51 51 emit widthChanged(width);
52 52 }
53 53 }
54 54
55 55 Qt::PenStyle DeclarativeSplineSeries::style() const
56 56 {
57 57 return pen().style();
58 58 }
59 59
60 60 void DeclarativeSplineSeries::setStyle(Qt::PenStyle style)
61 61 {
62 62 if (style != pen().style()) {
63 63 QPen p = pen();
64 64 p.setStyle(style);
65 65 setPen(p);
66 66 emit styleChanged(style);
67 67 }
68 68 }
69 69
70 70 Qt::PenCapStyle DeclarativeSplineSeries::capStyle() const
71 71 {
72 72 return pen().capStyle();
73 73 }
74 74
75 75 void DeclarativeSplineSeries::setCapStyle(Qt::PenCapStyle capStyle)
76 76 {
77 77 if (capStyle != pen().capStyle()) {
78 78 QPen p = pen();
79 79 p.setCapStyle(capStyle);
80 80 setPen(p);
81 81 emit capStyleChanged(capStyle);
82 82 }
83 83 }
84 84
85 85 QDeclarativeListProperty<QObject> DeclarativeSplineSeries::declarativeChildren()
86 86 {
87 87 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
88 88 }
89 89
90 90 void DeclarativeSplineSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
91 91 {
92 92 Q_UNUSED(list)
93 93 Q_UNUSED(element)
94 // Empty implementation, childs are parsed in componentComplete
94 // Empty implementation, children are parsed in componentComplete
95 95 }
96 96
97 97 #include "moc_declarativesplineseries.cpp"
98 98
99 99 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,638 +1,638
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include <QtTest/QtTest>
22 22 #include <qchartview.h>
23 23 #include <qchart.h>
24 24 #include <qpieseries.h>
25 25 #include <qpieslice.h>
26 26 #include <qpiemodelmapper.h>
27 27 #include <QStandardItemModel>
28 28 #include <tst_definitions.h>
29 29
30 30 QTCOMMERCIALCHART_USE_NAMESPACE
31 31
32 32 Q_DECLARE_METATYPE(QPieSlice*)
33 33 Q_DECLARE_METATYPE(QList<QPieSlice*>)
34 34
35 35 class tst_qpieseries : public QObject
36 36 {
37 37 Q_OBJECT
38 38
39 39 public slots:
40 40 void initTestCase();
41 41 void cleanupTestCase();
42 42 void init();
43 43 void cleanup();
44 44
45 45 private slots:
46 46 void properties();
47 47 void append();
48 48 void appendAnimated();
49 49 void insert();
50 50 void insertAnimated();
51 51 void remove();
52 52 void removeAnimated();
53 53 void take();
54 54 void takeAnimated();
55 55 void calculatedValues();
56 56 void clickedSignal();
57 57 void hoverSignal();
58 58 void sliceSeries();
59 59 void destruction();
60 60
61 61 private:
62 62 void verifyCalculatedData(const QPieSeries &series, bool *ok);
63 63
64 64 private:
65 65 QChartView *m_view;
66 66 QPieSeries *m_series;
67 67 };
68 68
69 69 void tst_qpieseries::initTestCase()
70 70 {
71 71 qRegisterMetaType<QPieSlice*>("QPieSlice*");
72 72 qRegisterMetaType<QList<QPieSlice*> >("QList<QPieSlice*>");
73 73 }
74 74
75 75 void tst_qpieseries::cleanupTestCase()
76 76 {
77 77 }
78 78
79 79 void tst_qpieseries::init()
80 80 {
81 81 m_view = new QChartView();
82 82 m_series = new QPieSeries(m_view);
83 83 m_view->show();
84 84 QTest::qWaitForWindowShown(m_view);
85 85
86 86 }
87 87
88 88 void tst_qpieseries::cleanup()
89 89 {
90 90 delete m_view;
91 91 m_view = 0;
92 92 m_series = 0;
93 93 }
94 94
95 95 void tst_qpieseries::properties()
96 96 {
97 97 QSignalSpy countSpy(m_series, SIGNAL(countChanged()));
98 98 QSignalSpy sumSpy(m_series, SIGNAL(sumChanged()));
99 99
100 100 QVERIFY(m_series->type() == QAbstractSeries::SeriesTypePie);
101 101 QVERIFY(m_series->count() == 0);
102 102 QVERIFY(m_series->isEmpty());
103 103 QCOMPARE(m_series->sum(), 0.0);
104 104 QCOMPARE(m_series->horizontalPosition(), 0.5);
105 105 QCOMPARE(m_series->verticalPosition(), 0.5);
106 106 QCOMPARE(m_series->pieSize(), 0.7);
107 107 QCOMPARE(m_series->pieStartAngle(), 0.0);
108 108 QCOMPARE(m_series->pieEndAngle(), 360.0);
109 109
110 110 m_series->append("s1", 1);
111 111 m_series->append("s2", 1);
112 112 m_series->append("s3", 1);
113 113 m_series->insert(1, new QPieSlice("s4", 1));
114 114 m_series->remove(m_series->slices().first());
115 115 QCOMPARE(m_series->count(), 3);
116 116 QCOMPARE(m_series->sum(), 3.0);
117 117 m_series->clear();
118 118 QCOMPARE(m_series->count(), 0);
119 119 QCOMPARE(m_series->sum(), 0.0);
120 120 QCOMPARE(countSpy.count(), 6);
121 121 QCOMPARE(sumSpy.count(), 6);
122 122
123 123 m_series->setPieSize(-1.0);
124 124 QCOMPARE(m_series->pieSize(), 0.0);
125 125 m_series->setPieSize(0.0);
126 126 m_series->setPieSize(0.9);
127 127 m_series->setPieSize(2.0);
128 128 QCOMPARE(m_series->pieSize(), 1.0);
129 129
130 130 m_series->setPieSize(0.7);
131 131 QCOMPARE(m_series->pieSize(), 0.7);
132 132
133 133 m_series->setHoleSize(-1.0);
134 134 QCOMPARE(m_series->holeSize(), 0.0);
135 135 m_series->setHoleSize(0.5);
136 136 QCOMPARE(m_series->holeSize(), 0.5);
137 137
138 138 m_series->setHoleSize(0.8);
139 139 QCOMPARE(m_series->holeSize(), 0.8);
140 140 QCOMPARE(m_series->pieSize(), 0.8);
141 141
142 142 m_series->setPieSize(0.4);
143 143 QCOMPARE(m_series->pieSize(), 0.4);
144 144 QCOMPARE(m_series->holeSize(), 0.4);
145 145
146 146 m_series->setPieStartAngle(0);
147 147 m_series->setPieStartAngle(-180);
148 148 m_series->setPieStartAngle(180);
149 149 QCOMPARE(m_series->pieStartAngle(), 180.0);
150 150
151 151 m_series->setPieEndAngle(360);
152 152 m_series->setPieEndAngle(-180);
153 153 m_series->setPieEndAngle(180);
154 154 QCOMPARE(m_series->pieEndAngle(), 180.0);
155 155
156 156 m_series->setHorizontalPosition(0.5);
157 157 m_series->setHorizontalPosition(-1.0);
158 158 QCOMPARE(m_series->horizontalPosition(), 0.0);
159 159 m_series->setHorizontalPosition(1.0);
160 160 m_series->setHorizontalPosition(2.0);
161 161 QCOMPARE(m_series->horizontalPosition(), 1.0);
162 162
163 163 m_series->setVerticalPosition(0.5);
164 164 m_series->setVerticalPosition(-1.0);
165 165 QCOMPARE(m_series->verticalPosition(), 0.0);
166 166 m_series->setVerticalPosition(1.0);
167 167 m_series->setVerticalPosition(2.0);
168 168 QCOMPARE(m_series->verticalPosition(), 1.0);
169 169 }
170 170
171 171 void tst_qpieseries::append()
172 172 {
173 173 m_view->chart()->addSeries(m_series);
174 174 QSignalSpy addedSpy(m_series, SIGNAL(added(QList<QPieSlice*>)));
175 175
176 176 // append pointer
177 177 QPieSlice *slice1 = 0;
178 178 QVERIFY(!m_series->append(slice1));
179 179 slice1 = new QPieSlice("slice 1", 1);
180 180 QVERIFY(m_series->append(slice1));
181 181 QVERIFY(!m_series->append(slice1));
182 182 QCOMPARE(m_series->count(), 1);
183 183 QCOMPARE(addedSpy.count(), 1);
184 184 QList<QPieSlice*> added = qvariant_cast<QList<QPieSlice*> >(addedSpy.at(0).at(0));
185 185 QCOMPARE(added.count(), 1);
186 186 QCOMPARE(added.first(), slice1);
187 187
188 188 // try to append same slice to another series
189 189 QPieSeries series2;
190 190 QVERIFY(!series2.append(slice1));
191 191
192 192 // append pointer list
193 193 QList<QPieSlice *> list;
194 194 QVERIFY(!m_series->append(list));
195 195 list << (QPieSlice *) 0;
196 196 QVERIFY(!m_series->append(list));
197 197 list.clear();
198 198 list << new QPieSlice("slice 2", 2);
199 199 list << new QPieSlice("slice 3", 3);
200 200 QVERIFY(m_series->append(list));
201 201 QVERIFY(!m_series->append(list));
202 202 QCOMPARE(m_series->count(), 3);
203 203 QCOMPARE(addedSpy.count(), 2);
204 204 added = qvariant_cast<QList<QPieSlice*> >(addedSpy.at(1).at(0));
205 205 QCOMPARE(added.count(), 2);
206 206 QCOMPARE(added, list);
207 207
208 208 // append operator
209 209 QPieSlice *slice4 = new QPieSlice("slice 4", 4);
210 210 *m_series << slice4;
211 211 *m_series << slice1; // fails because already added
212 212 QCOMPARE(m_series->count(), 4);
213 213 QCOMPARE(addedSpy.count(), 3);
214 214 added = qvariant_cast<QList<QPieSlice*> >(addedSpy.at(2).at(0));
215 215 QCOMPARE(added.count(), 1);
216 216 QCOMPARE(added.first(), slice4);
217 217
218 218 // append with params
219 219 QPieSlice *slice5 = m_series->append("slice 5", 5);
220 220 QVERIFY(slice5 != 0);
221 221 QCOMPARE(slice5->value(), 5.0);
222 222 QCOMPARE(slice5->label(), QString("slice 5"));
223 223 QCOMPARE(m_series->count(), 5);
224 224 QCOMPARE(addedSpy.count(), 4);
225 225 added = qvariant_cast<QList<QPieSlice*> >(addedSpy.at(3).at(0));
226 226 QCOMPARE(added.count(), 1);
227 227 QCOMPARE(added.first(), slice5);
228 228
229 229 // check slices
230 230 QVERIFY(!m_series->isEmpty());
231 231 for (int i=0; i<m_series->count(); i++) {
232 232 QCOMPARE(m_series->slices().at(i)->value(), (qreal) i+1);
233 233 QCOMPARE(m_series->slices().at(i)->label(), QString("slice ") + QString::number(i+1));
234 234 }
235 235 }
236 236
237 237 void tst_qpieseries::appendAnimated()
238 238 {
239 239 m_view->chart()->setAnimationOptions(QChart::AllAnimations);
240 240 append();
241 241 }
242 242
243 243 void tst_qpieseries::insert()
244 244 {
245 245 m_view->chart()->addSeries(m_series);
246 246 QSignalSpy addedSpy(m_series, SIGNAL(added(QList<QPieSlice*>)));
247 247
248 248 // insert one slice
249 249 QPieSlice *slice1 = 0;
250 250 QVERIFY(!m_series->insert(0, slice1));
251 251 slice1 = new QPieSlice("slice 1", 1);
252 252 QVERIFY(!m_series->insert(-1, slice1));
253 253 QVERIFY(!m_series->insert(5, slice1));
254 254 QVERIFY(m_series->insert(0, slice1));
255 255 QVERIFY(!m_series->insert(0, slice1));
256 256 QCOMPARE(m_series->count(), 1);
257 257 QCOMPARE(addedSpy.count(), 1);
258 258 QList<QPieSlice*> added = qvariant_cast<QList<QPieSlice*> >(addedSpy.at(0).at(0));
259 259 QCOMPARE(added.count(), 1);
260 260 QCOMPARE(added.first(), slice1);
261 261
262 262 // try to insert same slice to another series
263 263 QPieSeries series2;
264 264 QVERIFY(!series2.insert(0, slice1));
265 265
266 266 // add some more slices
267 267 QPieSlice *slice2 = m_series->append("slice 2", 2);
268 268 QPieSlice *slice4 = m_series->append("slice 4", 4);
269 269 QCOMPARE(m_series->count(), 3);
270 270 QCOMPARE(addedSpy.count(), 3);
271 271 added = qvariant_cast<QList<QPieSlice*> >(addedSpy.at(1).at(0));
272 272 QCOMPARE(added.count(), 1);
273 273 QCOMPARE(added.first(), slice2);
274 274 added = qvariant_cast<QList<QPieSlice*> >(addedSpy.at(2).at(0));
275 275 QCOMPARE(added.count(), 1);
276 276 QCOMPARE(added.first(), slice4);
277 277
278 278 // insert between slices
279 279 QPieSlice *slice3 = new QPieSlice("slice 3", 3);
280 280 m_series->insert(2, slice3);
281 281 QCOMPARE(m_series->count(), 4);
282 282 QCOMPARE(addedSpy.count(), 4);
283 283 added = qvariant_cast<QList<QPieSlice*> >(addedSpy.at(3).at(0));
284 284 QCOMPARE(added.count(), 1);
285 285 QCOMPARE(added.first(), slice3);
286 286
287 287 // check slices
288 288 for (int i=0; i<m_series->count(); i++) {
289 289 QCOMPARE(m_series->slices().at(i)->value(), (qreal) i+1);
290 290 QCOMPARE(m_series->slices().at(i)->label(), QString("slice ") + QString::number(i+1));
291 291 QVERIFY(m_series->slices().at(i)->parent() == m_series);
292 292 }
293 293 }
294 294
295 295 void tst_qpieseries::insertAnimated()
296 296 {
297 297 m_view->chart()->setAnimationOptions(QChart::AllAnimations);
298 298 insert();
299 299 }
300 300
301 301 void tst_qpieseries::remove()
302 302 {
303 303 m_view->chart()->addSeries(m_series);
304 304 QSignalSpy removedSpy(m_series, SIGNAL(removed(QList<QPieSlice*>)));
305 305
306 306 // add some slices
307 307 QPieSlice *slice1 = m_series->append("slice 1", 1);
308 308 QPieSlice *slice2 = m_series->append("slice 2", 2);
309 309 QPieSlice *slice3 = m_series->append("slice 3", 3);
310 310 QSignalSpy spy1(slice1, SIGNAL(destroyed()));
311 311 QSignalSpy spy2(slice2, SIGNAL(destroyed()));
312 312 QSignalSpy spy3(slice3, SIGNAL(destroyed()));
313 313 QCOMPARE(m_series->count(), 3);
314 314
315 315 // null pointer remove
316 316 QVERIFY(!m_series->remove(0));
317 317
318 318 // remove first
319 319 QVERIFY(m_series->remove(slice1));
320 320 QVERIFY(!m_series->remove(slice1));
321 321 QCOMPARE(m_series->count(), 2);
322 322 QCOMPARE(m_series->slices().at(0)->label(), slice2->label());
323 323 QCOMPARE(removedSpy.count(), 1);
324 324 QList<QPieSlice*> removed = qvariant_cast<QList<QPieSlice*> >(removedSpy.at(0).at(0));
325 325 QCOMPARE(removed.count(), 1);
326 326 QCOMPARE(removed.first(), slice1);
327 327
328 328 // remove all
329 329 m_series->clear();
330 330 QVERIFY(m_series->isEmpty());
331 331 QVERIFY(m_series->slices().isEmpty());
332 332 QCOMPARE(m_series->count(), 0);
333 333 QCOMPARE(removedSpy.count(), 2);
334 334 removed = qvariant_cast<QList<QPieSlice*> >(removedSpy.at(1).at(0));
335 335 QCOMPARE(removed.count(), 2);
336 336 QCOMPARE(removed.first(), slice2);
337 337 QCOMPARE(removed.last(), slice3);
338 338
339 339 // check that slices were actually destroyed
340 340 TRY_COMPARE(spy1.count(), 1);
341 341 TRY_COMPARE(spy2.count(), 1);
342 342 TRY_COMPARE(spy3.count(), 1);
343 343 }
344 344
345 345 void tst_qpieseries::removeAnimated()
346 346 {
347 347 m_view->chart()->setAnimationOptions(QChart::AllAnimations);
348 348 remove();
349 349 }
350 350
351 351 void tst_qpieseries::take()
352 352 {
353 353 m_view->chart()->addSeries(m_series);
354 354 QSignalSpy removedSpy(m_series, SIGNAL(removed(QList<QPieSlice*>)));
355 355
356 356 // add some slices
357 357 QPieSlice *slice1 = m_series->append("slice 1", 1);
358 358 QPieSlice *slice2 = m_series->append("slice 2", 2);
359 359 m_series->append("slice 3", 3);
360 360 QSignalSpy spy1(slice1, SIGNAL(destroyed()));
361 361 QCOMPARE(m_series->count(), 3);
362 362
363 363 // null pointer remove
364 364 QVERIFY(!m_series->take(0));
365 365
366 366 // take first
367 367 QVERIFY(m_series->take(slice1));
368 368 TRY_COMPARE(spy1.count(), 0);
369 369 QVERIFY(slice1->parent() == m_series); // series is still the parent object
370 370 QVERIFY(!m_series->take(slice1));
371 371 QCOMPARE(m_series->count(), 2);
372 372 QCOMPARE(m_series->slices().at(0)->label(), slice2->label());
373 373 QCOMPARE(removedSpy.count(), 1);
374 374 QList<QPieSlice*> removed = qvariant_cast<QList<QPieSlice*> >(removedSpy.at(0).at(0));
375 375 QCOMPARE(removed.count(), 1);
376 376 QCOMPARE(removed.first(), slice1);
377 377 }
378 378
379 379 void tst_qpieseries::takeAnimated()
380 380 {
381 381 m_view->chart()->setAnimationOptions(QChart::AllAnimations);
382 382 take();
383 383 }
384 384
385 385 void tst_qpieseries::calculatedValues()
386 386 {
387 387 m_view->chart()->addSeries(m_series);
388 388
389 389 QPieSlice *slice1 = new QPieSlice("slice 1", 1);
390 390 QSignalSpy percentageSpy(slice1, SIGNAL(percentageChanged()));
391 391 QSignalSpy startAngleSpy(slice1, SIGNAL(startAngleChanged()));
392 392 QSignalSpy angleSpanSpy(slice1, SIGNAL(angleSpanChanged()));
393 393
394 394 // add a slice
395 395 m_series->append(slice1);
396 396 bool ok;
397 397 verifyCalculatedData(*m_series, &ok);
398 398 if (!ok)
399 399 return;
400 400 QCOMPARE(percentageSpy.count(), 1);
401 401 QCOMPARE(startAngleSpy.count(), 0);
402 402 QCOMPARE(angleSpanSpy.count(), 1);
403 403
404 404 // add some more slices
405 405 QList<QPieSlice *> list;
406 406 list << new QPieSlice("slice 2", 2);
407 407 list << new QPieSlice("slice 3", 3);
408 408 m_series->append(list);
409 409 verifyCalculatedData(*m_series, &ok);
410 410 if (!ok)
411 411 return;
412 412 QCOMPARE(percentageSpy.count(), 2);
413 413 QCOMPARE(startAngleSpy.count(), 0);
414 414 QCOMPARE(angleSpanSpy.count(), 2);
415 415
416 416 // remove a slice
417 417 m_series->remove(list.first()); // remove slice 2
418 418 verifyCalculatedData(*m_series, &ok);
419 419 if (!ok)
420 420 return;
421 421 QCOMPARE(percentageSpy.count(), 3);
422 422 QCOMPARE(startAngleSpy.count(), 0);
423 423 QCOMPARE(angleSpanSpy.count(), 3);
424 424
425 425 // insert a slice
426 426 m_series->insert(0, new QPieSlice("Slice 4", 4));
427 427 verifyCalculatedData(*m_series, &ok);
428 428 if (!ok)
429 429 return;
430 430 QCOMPARE(percentageSpy.count(), 4);
431 431 QCOMPARE(startAngleSpy.count(), 1);
432 432 QCOMPARE(angleSpanSpy.count(), 4);
433 433
434 434 // modify pie angles
435 435 m_series->setPieStartAngle(-90);
436 436 m_series->setPieEndAngle(90);
437 437 verifyCalculatedData(*m_series, &ok);
438 438 if (!ok)
439 439 return;
440 440 QCOMPARE(percentageSpy.count(), 4);
441 441 QCOMPARE(startAngleSpy.count(), 3);
442 442 QCOMPARE(angleSpanSpy.count(), 6);
443 443
444 444 // clear all
445 445 m_series->clear();
446 446 verifyCalculatedData(*m_series, &ok);
447 447 if (!ok)
448 448 return;
449 449 QCOMPARE(percentageSpy.count(), 4);
450 450 QCOMPARE(startAngleSpy.count(), 3);
451 451 QCOMPARE(angleSpanSpy.count(), 6);
452 452 }
453 453
454 454 void tst_qpieseries::verifyCalculatedData(const QPieSeries &series, bool *ok)
455 455 {
456 456 *ok = false;
457 457
458 458 qreal sum = 0;
459 459 foreach (const QPieSlice *slice, series.slices())
460 460 sum += slice->value();
461 461 QCOMPARE(series.sum(), sum);
462 462
463 463 qreal startAngle = series.pieStartAngle();
464 464 qreal pieAngleSpan = series.pieEndAngle() - series.pieStartAngle();
465 465 foreach (const QPieSlice *slice, series.slices()) {
466 466 qreal ratio = slice->value() / sum;
467 467 qreal sliceSpan = pieAngleSpan * ratio;
468 468 QCOMPARE(slice->startAngle(), startAngle);
469 469 QCOMPARE(slice->angleSpan(), sliceSpan);
470 470 QCOMPARE(slice->percentage(), ratio);
471 471 startAngle += sliceSpan;
472 472 }
473 473
474 474 if (!series.isEmpty())
475 475 QCOMPARE(series.slices().last()->startAngle() + series.slices().last()->angleSpan(), series.pieEndAngle());
476 476
477 477 *ok = true;
478 478 }
479 479
480 480
481 481 void tst_qpieseries::clickedSignal()
482 482 {
483 483 // add some slices
484 484 QPieSlice *s1 = m_series->append("slice 1", 1);
485 485 QPieSlice *s2 = m_series->append("slice 2", 1);
486 486 QPieSlice *s3 = m_series->append("slice 3", 1);
487 487 QPieSlice *s4 = m_series->append("slice 4", 1);
488 488 QSignalSpy clickSpy(m_series, SIGNAL(clicked(QPieSlice*)));
489 489
490 490 // add series to the chart
491 491 m_view->chart()->legend()->setVisible(false);
492 492 m_view->resize(200, 200);
493 493 m_view->chart()->addSeries(m_series);
494 494 m_view->show();
495 495 QTest::qWaitForWindowShown(m_view);
496 496
497 // if you devide the chart in four equal tiles these
497 // if you divide the chart in four equal tiles these
498 498 // are the center points of those tiles
499 499 QPoint p1(90.25, 90);
500 500 QPoint p2(150, 90);
501 501 QPoint p3(90, 150);
502 502 QPoint p4(150, 150);
503 503
504 504 QPoint center(120, 120);
505 505
506 506 m_series->setPieSize(1.0);
507 507 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p1);
508 508 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p2);
509 509 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p3);
510 510 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p4);
511 511 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, center);
512 512 TRY_COMPARE(clickSpy.count(), 5); // all hit
513 513 QCOMPARE(qvariant_cast<QPieSlice*>(clickSpy.at(0).at(0)), s4);
514 514 QCOMPARE(qvariant_cast<QPieSlice*>(clickSpy.at(1).at(0)), s1);
515 515 QCOMPARE(qvariant_cast<QPieSlice*>(clickSpy.at(2).at(0)), s3);
516 516 QCOMPARE(qvariant_cast<QPieSlice*>(clickSpy.at(3).at(0)), s2);
517 517 clickSpy.clear();
518 518
519 519 m_series->setPieSize(0.5);
520 520 m_series->setVerticalPosition(0.25);
521 521 m_series->setHorizontalPosition(0.25);
522 522 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p1); // hits
523 523 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p2);
524 524 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p3);
525 525 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p4);
526 526 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, center);
527 527 TRY_COMPARE(clickSpy.count(), 1);
528 528 clickSpy.clear();
529 529
530 530 m_series->setVerticalPosition(0.25);
531 531 m_series->setHorizontalPosition(0.75);
532 532 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p1);
533 533 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p2); // hits
534 534 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p3);
535 535 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p4);
536 536 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, center);
537 537 TRY_COMPARE(clickSpy.count(), 1);
538 538 clickSpy.clear();
539 539
540 540 m_series->setVerticalPosition(0.75);
541 541 m_series->setHorizontalPosition(0.25);
542 542 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p1);
543 543 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p2);
544 544 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p3); // hits
545 545 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p4);
546 546 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, center);
547 547 TRY_COMPARE(clickSpy.count(), 1);
548 548 clickSpy.clear();
549 549
550 550 m_series->setVerticalPosition(0.75);
551 551 m_series->setHorizontalPosition(0.75);
552 552 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p1);
553 553 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p2);
554 554 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p3);
555 555 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p4); // hits
556 556 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, center);
557 557 TRY_COMPARE(clickSpy.count(), 1);
558 558 clickSpy.clear();
559 559 }
560 560
561 561 void tst_qpieseries::hoverSignal()
562 562 {
563 563 // add some slices
564 564 m_series->setPieSize(1.0);
565 565 QPieSlice *s1 = m_series->append("slice 1", 1);
566 566 m_series->append("slice 2", 2);
567 567 m_series->append("slice 3", 3);
568 568
569 569 // add series to the chart
570 570 m_view->chart()->legend()->setVisible(false);
571 571 m_view->resize(200, 200);
572 572 m_view->chart()->addSeries(m_series);
573 573 m_view->show();
574 574 QTest::qWaitForWindowShown(m_view);
575 575
576 576 // first move to right top corner
577 577 QTest::mouseMove(m_view->viewport(), QPoint(200, 0));
578 578 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
579 579
580 580 // move inside the slice
581 581 // pie rectangle: QRectF(60,60 121x121)
582 582 QSignalSpy hoverSpy(m_series, SIGNAL(hovered(QPieSlice*,bool)));
583 583 QTest::mouseMove(m_view->viewport(), QPoint(139, 85));
584 584 TRY_COMPARE(hoverSpy.count(), 1);
585 585 QCOMPARE(qvariant_cast<QPieSlice*>(hoverSpy.at(0).at(0)), s1);
586 586 QCOMPARE(qvariant_cast<bool>(hoverSpy.at(0).at(1)), true);
587 587
588 588 // move outside the slice
589 589 QTest::mouseMove(m_view->viewport(), QPoint(200, 0));
590 590 TRY_COMPARE(hoverSpy.count(), 2);
591 591 QCOMPARE(qvariant_cast<QPieSlice*>(hoverSpy.at(1).at(0)), s1);
592 592 QCOMPARE(qvariant_cast<bool>(hoverSpy.at(1).at(1)), false);
593 593 }
594 594
595 595 void tst_qpieseries::sliceSeries()
596 596 {
597 597 QPieSlice *slice = new QPieSlice();
598 598 QVERIFY(!slice->series());
599 599 delete slice;
600 600
601 601 slice = new QPieSlice(m_series);
602 602 QVERIFY(!slice->series());
603 603
604 604 m_series->append(slice);
605 605 QCOMPARE(slice->series(), m_series);
606 606
607 607 slice = new QPieSlice();
608 608 m_series->insert(0, slice);
609 609 QCOMPARE(slice->series(), m_series);
610 610
611 611 m_series->take(slice);
612 612 QCOMPARE(slice->series(), (QPieSeries*) 0);
613 613 }
614 614
615 615 void tst_qpieseries::destruction()
616 616 {
617 617 // add some slices
618 618 QPieSlice *slice1 = m_series->append("slice 1", 1);
619 619 QPieSlice *slice2 = m_series->append("slice 2", 2);
620 620 QPieSlice *slice3 = m_series->append("slice 3", 3);
621 621 QSignalSpy spy1(slice1, SIGNAL(destroyed()));
622 622 QSignalSpy spy2(slice2, SIGNAL(destroyed()));
623 623 QSignalSpy spy3(slice3, SIGNAL(destroyed()));
624 624
625 625 // destroy series
626 626 delete m_series;
627 627 m_series = 0;
628 628
629 629 // check that series has destroyed its slices
630 630 QCOMPARE(spy1.count(), 1);
631 631 QCOMPARE(spy2.count(), 1);
632 632 QCOMPARE(spy3.count(), 1);
633 633 }
634 634
635 635 QTEST_MAIN(tst_qpieseries)
636 636
637 637 #include "tst_qpieseries.moc"
638 638
General Comments 0
You need to be logged in to leave comments. Login now