@@ -0,0 +1,8 | |||
|
1 | !include( ../auto.pri ) { | |
|
2 | error( "Couldn't find the auto.pri file!" ) | |
|
3 | } | |
|
4 | ||
|
5 | SOURCES += \ | |
|
6 | tst_qpiemodelmapper.cpp | |
|
7 | ||
|
8 | !system_build:mac: QMAKE_POST_LINK += "$$MAC_POST_LINK_PREFIX $$MAC_AUTOTESTS_BIN_DIR" |
@@ -0,0 +1,241 | |||
|
1 | #include <QtCore/QString> | |
|
2 | #include <QtTest/QtTest> | |
|
3 | ||
|
4 | #include <qchart.h> | |
|
5 | #include <qchartview.h> | |
|
6 | #include <qpieseries.h> | |
|
7 | #include <qvpiemodelmapper.h> | |
|
8 | #include <qhpiemodelmapper.h> | |
|
9 | #include <QStandardItemModel> | |
|
10 | ||
|
11 | QTCOMMERCIALCHART_USE_NAMESPACE | |
|
12 | ||
|
13 | class tst_piemodelmapper : public QObject | |
|
14 | { | |
|
15 | Q_OBJECT | |
|
16 | ||
|
17 | public: | |
|
18 | tst_piemodelmapper(); | |
|
19 | ||
|
20 | private Q_SLOTS: | |
|
21 | void initTestCase(); | |
|
22 | void cleanupTestCase(); | |
|
23 | void init(); | |
|
24 | void cleanup(); | |
|
25 | void verticalMapper_data(); | |
|
26 | void verticalMapper(); | |
|
27 | void verticalMapperCustomMapping_data(); | |
|
28 | void verticalMapperCustomMapping(); | |
|
29 | void horizontalMapper_data(); | |
|
30 | void horizontalMapper(); | |
|
31 | void horizontalMapperCustomMapping_data(); | |
|
32 | void horizontalMapperCustomMapping(); | |
|
33 | ||
|
34 | ||
|
35 | private: | |
|
36 | QStandardItemModel *m_model; | |
|
37 | int m_modelRowCount; | |
|
38 | int m_modelColumnCount; | |
|
39 | ||
|
40 | QPieSeries *m_series; | |
|
41 | QChart *m_chart; | |
|
42 | }; | |
|
43 | ||
|
44 | tst_piemodelmapper::tst_piemodelmapper(): | |
|
45 | m_model(0), | |
|
46 | m_modelRowCount(10), | |
|
47 | m_modelColumnCount(8) | |
|
48 | { | |
|
49 | } | |
|
50 | ||
|
51 | void tst_piemodelmapper::init() | |
|
52 | { | |
|
53 | m_series = new QPieSeries; | |
|
54 | m_chart->addSeries(m_series); | |
|
55 | } | |
|
56 | ||
|
57 | void tst_piemodelmapper::cleanup() | |
|
58 | { | |
|
59 | m_chart->removeSeries(m_series); | |
|
60 | delete m_series; | |
|
61 | m_series = 0; | |
|
62 | } | |
|
63 | ||
|
64 | void tst_piemodelmapper::initTestCase() | |
|
65 | { | |
|
66 | m_chart = new QChart; | |
|
67 | QChartView *chartView = new QChartView(m_chart); | |
|
68 | chartView->show(); | |
|
69 | ||
|
70 | m_model = new QStandardItemModel(this); | |
|
71 | for (int row = 0; row < m_modelRowCount; ++row) { | |
|
72 | for (int column = 0; column < m_modelColumnCount; column++) { | |
|
73 | QStandardItem *item = new QStandardItem(row * column); | |
|
74 | m_model->setItem(row, column, item); | |
|
75 | } | |
|
76 | } | |
|
77 | } | |
|
78 | ||
|
79 | void tst_piemodelmapper::cleanupTestCase() | |
|
80 | { | |
|
81 | m_model->clear(); | |
|
82 | } | |
|
83 | ||
|
84 | void tst_piemodelmapper::verticalMapper_data() | |
|
85 | { | |
|
86 | QTest::addColumn<int>("valuesColumn"); | |
|
87 | QTest::addColumn<int>("labelsColumn"); | |
|
88 | QTest::addColumn<int>("expectedCount"); | |
|
89 | QTest::newRow("different values and labels columns") << 0 << 1 << m_modelRowCount; | |
|
90 | QTest::newRow("same values and labels columns") << 1 << 1 << m_modelRowCount; | |
|
91 | QTest::newRow("invalid values column and correct labels column") << -3 << 1 << 0; | |
|
92 | QTest::newRow("values column beyond the size of model and correct labels column") << m_modelColumnCount << 1 << 0; | |
|
93 | QTest::newRow("values column beyond the size of model and correct labels column") << m_modelColumnCount << -1 << 0; | |
|
94 | } | |
|
95 | ||
|
96 | void tst_piemodelmapper::verticalMapper() | |
|
97 | { | |
|
98 | QFETCH(int, valuesColumn); | |
|
99 | QFETCH(int, labelsColumn); | |
|
100 | QFETCH(int, expectedCount); | |
|
101 | ||
|
102 | QVPieModelMapper *mapper = new QVPieModelMapper; | |
|
103 | mapper->setValuesColumn(valuesColumn); | |
|
104 | mapper->setLabelsColumn(labelsColumn); | |
|
105 | mapper->setModel(m_model); | |
|
106 | mapper->setSeries(m_series); | |
|
107 | ||
|
108 | QCOMPARE(m_series->count(), expectedCount); | |
|
109 | QCOMPARE(mapper->valuesColumn(), qMax(-1, valuesColumn)); | |
|
110 | QCOMPARE(mapper->labelsColumn(), qMax(-1, labelsColumn)); | |
|
111 | ||
|
112 | delete mapper; | |
|
113 | mapper = 0; | |
|
114 | } | |
|
115 | ||
|
116 | void tst_piemodelmapper::verticalMapperCustomMapping_data() | |
|
117 | { | |
|
118 | QTest::addColumn<int>("first"); | |
|
119 | QTest::addColumn<int>("countLimit"); | |
|
120 | QTest::addColumn<int>("expectedCount"); | |
|
121 | QTest::newRow("first: 0, unlimited count") << 0 << -1 << m_modelRowCount; | |
|
122 | QTest::newRow("first: 3, unlimited count") << 3 << -1 << m_modelRowCount - 3; | |
|
123 | QTest::newRow("first: 0, count: 5") << 0 << 5 << qMin(5, m_modelRowCount); | |
|
124 | QTest::newRow("first: 3, count: 5") << 3 << 5 << qMin(5, m_modelRowCount - 3); | |
|
125 | QTest::newRow("first: +1 greater then the number of rows in the model, unlimited count") << m_modelRowCount + 1 << -1 << 0; | |
|
126 | QTest::newRow("first: +1 greater then the number of rows in the model, count: 5") << m_modelRowCount + 1 << 5 << 0; | |
|
127 | QTest::newRow("first: 0, count: +3 greater than the number of rows in the model (should limit to the size of model)") << 0 << m_modelRowCount + 3 << m_modelRowCount; | |
|
128 | QTest::newRow("first: -3(invalid - should default to 0), unlimited count") << -3 << -1 << m_modelRowCount; | |
|
129 | QTest::newRow("first: 0, count: -3 (invalid - shlould default to -1)") << 0 << -3 << m_modelRowCount; | |
|
130 | QTest::newRow("first: -3(invalid - should default to 0), count: -3 (invalid - shlould default to -1)") << -3 << -3 << m_modelRowCount; | |
|
131 | ||
|
132 | } | |
|
133 | ||
|
134 | void tst_piemodelmapper::verticalMapperCustomMapping() | |
|
135 | { | |
|
136 | QFETCH(int, first); | |
|
137 | QFETCH(int, countLimit); | |
|
138 | QFETCH(int, expectedCount); | |
|
139 | ||
|
140 | QCOMPARE(m_series->count(), 0); | |
|
141 | ||
|
142 | QVPieModelMapper *mapper = new QVPieModelMapper; | |
|
143 | mapper->setValuesColumn(0); | |
|
144 | mapper->setLabelsColumn(1); | |
|
145 | mapper->setModel(m_model); | |
|
146 | mapper->setSeries(m_series); | |
|
147 | mapper->setFirst(first); | |
|
148 | mapper->setCount(countLimit); | |
|
149 | ||
|
150 | QCOMPARE(m_series->count(), expectedCount); | |
|
151 | ||
|
152 | // change values column mappings to invalid | |
|
153 | mapper->setValuesColumn(-1); | |
|
154 | mapper->setLabelsColumn(1); | |
|
155 | ||
|
156 | QCOMPARE(m_series->count(), 0); | |
|
157 | ||
|
158 | delete mapper; | |
|
159 | mapper = 0; | |
|
160 | } | |
|
161 | ||
|
162 | void tst_piemodelmapper::horizontalMapper_data() | |
|
163 | { | |
|
164 | QTest::addColumn<int>("valuesRow"); | |
|
165 | QTest::addColumn<int>("labelsRow"); | |
|
166 | QTest::addColumn<int>("expectedCount"); | |
|
167 | QTest::newRow("different values and labels rows") << 0 << 1 << m_modelColumnCount; | |
|
168 | QTest::newRow("same values and labels rows") << 1 << 1 << m_modelColumnCount; | |
|
169 | QTest::newRow("invalid values row and correct labels row") << -3 << 1 << 0; | |
|
170 | QTest::newRow("values row beyond the size of model and correct labels row") << m_modelRowCount << 1 << 0; | |
|
171 | QTest::newRow("values row beyond the size of model and invalid labels row") << m_modelRowCount << -1 << 0; | |
|
172 | } | |
|
173 | ||
|
174 | void tst_piemodelmapper::horizontalMapper() | |
|
175 | { | |
|
176 | QFETCH(int, valuesRow); | |
|
177 | QFETCH(int, labelsRow); | |
|
178 | QFETCH(int, expectedCount); | |
|
179 | ||
|
180 | QHPieModelMapper *mapper = new QHPieModelMapper; | |
|
181 | mapper->setValuesRow(valuesRow); | |
|
182 | mapper->setLabelsRow(labelsRow); | |
|
183 | mapper->setModel(m_model); | |
|
184 | mapper->setSeries(m_series); | |
|
185 | ||
|
186 | QCOMPARE(m_series->count(), expectedCount); | |
|
187 | QCOMPARE(mapper->valuesRow(), qMax(-1, valuesRow)); | |
|
188 | QCOMPARE(mapper->labelsRow(), qMax(-1, labelsRow)); | |
|
189 | ||
|
190 | delete mapper; | |
|
191 | mapper = 0; | |
|
192 | } | |
|
193 | ||
|
194 | void tst_piemodelmapper::horizontalMapperCustomMapping_data() | |
|
195 | { | |
|
196 | QTest::addColumn<int>("first"); | |
|
197 | QTest::addColumn<int>("countLimit"); | |
|
198 | QTest::addColumn<int>("expectedCount"); | |
|
199 | QTest::newRow("first: 0, unlimited count") << 0 << -1 << m_modelColumnCount; | |
|
200 | QTest::newRow("first: 3, unlimited count") << 3 << -1 << m_modelColumnCount - 3; | |
|
201 | QTest::newRow("first: 0, count: 5") << 0 << 5 << qMin(5, m_modelColumnCount); | |
|
202 | QTest::newRow("first: 3, count: 5") << 3 << 5 << qMin(5, m_modelColumnCount - 3); | |
|
203 | QTest::newRow("first: +1 greater then the number of columns in the model, unlimited count") << m_modelColumnCount + 1 << -1 << 0; | |
|
204 | QTest::newRow("first: +1 greater then the number of columns in the model, count: 5") << m_modelColumnCount + 1 << 5 << 0; | |
|
205 | QTest::newRow("first: 0, count: +3 greater than the number of columns in the model (should limit to the size of model)") << 0 << m_modelColumnCount + 3 << m_modelColumnCount; | |
|
206 | QTest::newRow("first: -3(invalid - should default to 0), unlimited count") << -3 << -1 << m_modelColumnCount; | |
|
207 | QTest::newRow("first: 0, count: -3 (invalid - shlould default to -1)") << 0 << -3 << m_modelColumnCount; | |
|
208 | QTest::newRow("first: -3(invalid - should default to 0), count: -3 (invalid - shlould default to -1)") << -3 << -3 << m_modelColumnCount; | |
|
209 | } | |
|
210 | ||
|
211 | void tst_piemodelmapper::horizontalMapperCustomMapping() | |
|
212 | { | |
|
213 | QFETCH(int, first); | |
|
214 | QFETCH(int, countLimit); | |
|
215 | QFETCH(int, expectedCount); | |
|
216 | ||
|
217 | QCOMPARE(m_series->count(), 0); | |
|
218 | ||
|
219 | QHPieModelMapper *mapper = new QHPieModelMapper; | |
|
220 | mapper->setValuesRow(0); | |
|
221 | mapper->setLabelsRow(1); | |
|
222 | mapper->setModel(m_model); | |
|
223 | mapper->setSeries(m_series); | |
|
224 | mapper->setFirst(first); | |
|
225 | mapper->setCount(countLimit); | |
|
226 | ||
|
227 | QCOMPARE(m_series->count(), expectedCount); | |
|
228 | ||
|
229 | // change values column mappings to invalid | |
|
230 | mapper->setValuesRow(-1); | |
|
231 | mapper->setLabelsRow(1); | |
|
232 | ||
|
233 | QCOMPARE(m_series->count(), 0); | |
|
234 | ||
|
235 | delete mapper; | |
|
236 | mapper = 0; | |
|
237 | } | |
|
238 | ||
|
239 | QTEST_MAIN(tst_piemodelmapper) | |
|
240 | ||
|
241 | #include "tst_qpiemodelmapper.moc" |
@@ -1,475 +1,465 | |||
|
1 | 1 | #include "qpiemodelmapper_p.h" |
|
2 | 2 | #include "qpiemodelmapper.h" |
|
3 | 3 | #include "qpieseries.h" |
|
4 | 4 | #include "qpieslice.h" |
|
5 | 5 | #include <QAbstractItemModel> |
|
6 | 6 | |
|
7 | 7 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
8 | 8 | |
|
9 | 9 | QPieModelMapper::QPieModelMapper(QObject *parent) : |
|
10 | 10 | QObject(parent), |
|
11 | 11 | d_ptr(new QPieModelMapperPrivate(this)) |
|
12 | 12 | { |
|
13 | 13 | } |
|
14 | 14 | |
|
15 | 15 | QAbstractItemModel* QPieModelMapper::model() const |
|
16 | 16 | { |
|
17 | 17 | Q_D(const QPieModelMapper); |
|
18 | 18 | return d->m_model; |
|
19 | 19 | } |
|
20 | 20 | |
|
21 | 21 | void QPieModelMapper::setModel(QAbstractItemModel *model) |
|
22 | 22 | { |
|
23 | 23 | if (model == 0) |
|
24 | 24 | return; |
|
25 | 25 | |
|
26 | 26 | Q_D(QPieModelMapper); |
|
27 | 27 | if (d->m_model) { |
|
28 | 28 | disconnect(d->m_model, 0, d, 0); |
|
29 | 29 | } |
|
30 | 30 | |
|
31 | 31 | d->m_model = model; |
|
32 | 32 | d->initializePieFromModel(); |
|
33 | 33 | // connect signals from the model |
|
34 | 34 | connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex))); |
|
35 | 35 | connect(d->m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelRowsAdded(QModelIndex,int,int))); |
|
36 | 36 | connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int))); |
|
37 | 37 | connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int))); |
|
38 | 38 | connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int))); |
|
39 | 39 | } |
|
40 | 40 | |
|
41 | 41 | QPieSeries* QPieModelMapper::series() const |
|
42 | 42 | { |
|
43 | 43 | Q_D(const QPieModelMapper); |
|
44 | 44 | return d->m_series; |
|
45 | 45 | } |
|
46 | 46 | |
|
47 | 47 | void QPieModelMapper::setSeries(QPieSeries *series) |
|
48 | 48 | { |
|
49 | 49 | if (series == 0) |
|
50 | 50 | return; |
|
51 | 51 | |
|
52 | 52 | Q_D(QPieModelMapper); |
|
53 | 53 | if (d->m_series) { |
|
54 | 54 | disconnect(d->m_series, 0, d, 0); |
|
55 | 55 | } |
|
56 | 56 | |
|
57 | 57 | d->m_series = series; |
|
58 | 58 | d->initializePieFromModel(); |
|
59 | 59 | // connect the signals from the series |
|
60 | 60 | connect(d->m_series, SIGNAL(added(QList<QPieSlice*>)), d, SLOT(slicesAdded(QList<QPieSlice*>))); |
|
61 | 61 | connect(d->m_series, SIGNAL(removed(QList<QPieSlice*>)), d, SLOT(slicesRemoved(QList<QPieSlice*>))); |
|
62 | 62 | // connect(d->m_model, SIGNAL(), d, SLOT()); |
|
63 | 63 | } |
|
64 | 64 | |
|
65 | 65 | int QPieModelMapper::first() const |
|
66 | 66 | { |
|
67 | 67 | Q_D(const QPieModelMapper); |
|
68 | 68 | return d->m_first; |
|
69 | 69 | } |
|
70 | 70 | |
|
71 | 71 | void QPieModelMapper::setFirst(int first) |
|
72 | 72 | { |
|
73 | 73 | Q_D(QPieModelMapper); |
|
74 | 74 | d->m_first = qMax(first, 0); |
|
75 | 75 | d->initializePieFromModel(); |
|
76 | // emit updated(); | |
|
77 | 76 | } |
|
78 | 77 | |
|
79 | 78 | int QPieModelMapper::count() const |
|
80 | 79 | { |
|
81 | 80 | Q_D(const QPieModelMapper); |
|
82 | 81 | return d->m_count; |
|
83 | 82 | } |
|
84 | 83 | |
|
85 | 84 | void QPieModelMapper::setCount(int count) |
|
86 | 85 | { |
|
87 | 86 | Q_D(QPieModelMapper); |
|
88 | 87 | d->m_count = qMax(count, -1); |
|
89 | 88 | d->initializePieFromModel(); |
|
90 | // emit updated(); | |
|
91 | 89 | } |
|
92 | 90 | |
|
93 | 91 | Qt::Orientation QPieModelMapper::orientation() const |
|
94 | 92 | { |
|
95 | 93 | Q_D(const QPieModelMapper); |
|
96 | 94 | return d->m_orientation; |
|
97 | 95 | } |
|
98 | 96 | |
|
99 | 97 | void QPieModelMapper::setOrientation(Qt::Orientation orientation) |
|
100 | 98 | { |
|
101 | 99 | Q_D(QPieModelMapper); |
|
102 | 100 | d->m_orientation = orientation; |
|
103 | 101 | d->initializePieFromModel(); |
|
104 | // emit updated(); | |
|
105 | 102 | } |
|
106 | 103 | |
|
107 | 104 | int QPieModelMapper::valuesIndex() const |
|
108 | 105 | { |
|
109 | 106 | Q_D(const QPieModelMapper); |
|
110 | 107 | return d->m_valuesIndex; |
|
111 | 108 | } |
|
112 | 109 | |
|
113 |
void QPieModelMapper::setValuesIndex(int |
|
|
110 | void QPieModelMapper::setValuesIndex(int valuesIndex) | |
|
114 | 111 | { |
|
115 | 112 | Q_D(QPieModelMapper); |
|
116 |
d->m_valuesIndex = |
|
|
113 | d->m_valuesIndex = qMax(-1, valuesIndex); | |
|
117 | 114 | d->initializePieFromModel(); |
|
118 | // emit updated(); | |
|
119 | 115 | } |
|
120 | 116 | |
|
121 | 117 | int QPieModelMapper::labelsIndex() const |
|
122 | 118 | { |
|
123 | 119 | Q_D(const QPieModelMapper); |
|
124 | 120 | return d->m_labelsIndex; |
|
125 | 121 | } |
|
126 | 122 | |
|
127 |
void QPieModelMapper::setLabelsIndex(int |
|
|
123 | void QPieModelMapper::setLabelsIndex(int labelsIndex) | |
|
128 | 124 | { |
|
129 | 125 | Q_D(QPieModelMapper); |
|
130 |
d->m_labelsIndex = |
|
|
126 | d->m_labelsIndex = qMax(-1, labelsIndex); | |
|
131 | 127 | d->initializePieFromModel(); |
|
132 | // emit updated(); | |
|
133 | 128 | } |
|
134 | 129 | |
|
135 | 130 | void QPieModelMapper::reset() |
|
136 | 131 | { |
|
137 | 132 | Q_D(QPieModelMapper); |
|
138 | 133 | d->m_first = 0; |
|
139 | 134 | d->m_count = -1; |
|
140 | 135 | d->m_orientation = Qt::Vertical; |
|
141 | 136 | d->m_valuesIndex = -1; |
|
142 | 137 | d->m_labelsIndex = -1; |
|
143 | // emit updated(); | |
|
144 | 138 | } |
|
145 | 139 | |
|
146 | 140 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
147 | 141 | |
|
148 | 142 | QPieModelMapperPrivate::QPieModelMapperPrivate(QPieModelMapper *q) : |
|
149 | 143 | q_ptr(q) |
|
150 | 144 | { |
|
151 | 145 | m_series = 0; |
|
152 | 146 | m_model = 0; |
|
153 | 147 | m_first = 0; |
|
154 | 148 | m_count = -1; |
|
155 | 149 | m_orientation = Qt::Vertical; |
|
156 | 150 | m_valuesIndex = -1; |
|
157 | 151 | m_labelsIndex = -1; |
|
158 | 152 | m_seriesSignalsBlock = false; |
|
159 | 153 | m_modelSignalsBlock = false; |
|
160 | 154 | } |
|
161 | 155 | |
|
162 | 156 | void QPieModelMapperPrivate::blockModelSignals(bool block) |
|
163 | 157 | { |
|
164 | 158 | m_modelSignalsBlock = block; |
|
165 | 159 | } |
|
166 | 160 | |
|
167 | 161 | void QPieModelMapperPrivate::blockSeriesSignals(bool block) |
|
168 | 162 | { |
|
169 | 163 | m_seriesSignalsBlock = block; |
|
170 | 164 | } |
|
171 | 165 | |
|
172 | 166 | |
|
173 | 167 | QPieSlice* QPieModelMapperPrivate::pieSlice(QModelIndex index) const |
|
174 | 168 | { |
|
175 | 169 | if (m_orientation == Qt::Vertical && (index.column() == m_valuesIndex || index.column() == m_labelsIndex)) { |
|
176 | 170 | if (index.row() >= m_first && (m_count == - 1 || index.row() < m_first + m_count)) |
|
177 | 171 | return m_series->slices().at(index.row() - m_first); |
|
178 | 172 | } else if (m_orientation == Qt::Horizontal && (index.row() == m_valuesIndex || index.row() == m_labelsIndex)) { |
|
179 | 173 | if (index.column() >= m_first && (m_count == - 1 || index.column() < m_first + m_count)) |
|
180 | 174 | return m_series->slices().at(index.column() - m_first); |
|
181 | 175 | } |
|
182 | 176 | return 0; // This part of model has not been mapped to any slice |
|
183 | 177 | } |
|
184 | 178 | |
|
185 | 179 | QModelIndex QPieModelMapperPrivate::valueModelIndex(int slicePos) |
|
186 | 180 | { |
|
187 | 181 | if (m_count != -1 && slicePos >= m_count) |
|
188 | 182 | return QModelIndex(); // invalid |
|
189 | 183 | |
|
190 | 184 | if (m_orientation == Qt::Vertical) |
|
191 | 185 | return m_model->index(slicePos + m_first, m_valuesIndex); |
|
192 | 186 | else |
|
193 | 187 | return m_model->index(m_valuesIndex, slicePos + m_first); |
|
194 | 188 | } |
|
195 | 189 | |
|
196 | 190 | QModelIndex QPieModelMapperPrivate::labelModelIndex(int slicePos) |
|
197 | 191 | { |
|
198 | 192 | if (m_count != -1 && slicePos >= m_count) |
|
199 | 193 | return QModelIndex(); // invalid |
|
200 | 194 | |
|
201 | 195 | if (m_orientation == Qt::Vertical) |
|
202 | 196 | return m_model->index(slicePos + m_first, m_labelsIndex); |
|
203 | 197 | else |
|
204 | 198 | return m_model->index(m_labelsIndex, slicePos + m_first); |
|
205 | 199 | } |
|
206 | 200 | |
|
207 | 201 | void QPieModelMapperPrivate::slicesAdded(QList<QPieSlice*> slices) |
|
208 | 202 | { |
|
209 | 203 | if (m_seriesSignalsBlock) |
|
210 | 204 | return; |
|
211 | 205 | |
|
212 | 206 | if (slices.count() == 0) |
|
213 | 207 | return; |
|
214 | 208 | |
|
215 | 209 | int firstIndex = m_series->slices().indexOf(slices.at(0)); |
|
216 | 210 | if (firstIndex == -1) |
|
217 | 211 | return; |
|
218 | 212 | |
|
219 | 213 | if (m_count != -1) |
|
220 | 214 | m_count += slices.count(); |
|
221 | 215 | |
|
222 | 216 | for (int i = firstIndex; i < firstIndex + slices.count(); i++) { |
|
223 | 217 | m_slices.insert(i, slices.at(i - firstIndex)); |
|
224 | 218 | connect(slices.at(i - firstIndex), SIGNAL(labelChanged()), this, SLOT(sliceLabelChanged())); |
|
225 | 219 | connect(slices.at(i - firstIndex), SIGNAL(valueChanged()), this, SLOT(sliceValueChanged())); |
|
226 | 220 | } |
|
227 | 221 | |
|
228 | 222 | blockModelSignals(); |
|
229 | 223 | if (m_orientation == Qt::Vertical) |
|
230 | 224 | m_model->insertRows(firstIndex + m_first, slices.count()); |
|
231 | 225 | else |
|
232 | 226 | m_model->insertColumns(firstIndex + m_first, slices.count()); |
|
233 | 227 | |
|
234 | 228 | for(int i = firstIndex; i < firstIndex + slices.count(); i++) { |
|
235 | 229 | m_model->setData(valueModelIndex(i), slices.at(i - firstIndex)->value()); |
|
236 | 230 | m_model->setData(labelModelIndex(i), slices.at(i - firstIndex)->label()); |
|
237 | 231 | } |
|
238 | 232 | blockModelSignals(false); |
|
239 | 233 | } |
|
240 | 234 | |
|
241 | 235 | void QPieModelMapperPrivate::slicesRemoved(QList<QPieSlice*> slices) |
|
242 | 236 | { |
|
243 | 237 | if (m_seriesSignalsBlock) |
|
244 | 238 | return; |
|
245 | 239 | |
|
246 | 240 | if (slices.count() == 0) |
|
247 | 241 | return; |
|
248 | 242 | |
|
249 | 243 | int firstIndex = m_slices.indexOf(slices.at(0)); |
|
250 | 244 | if (firstIndex == -1) |
|
251 | 245 | return; |
|
252 | 246 | |
|
253 | 247 | if (m_count != -1) |
|
254 | 248 | m_count -= slices.count(); |
|
255 | 249 | |
|
256 | 250 | for (int i = firstIndex + slices.count() - 1; i >= firstIndex; i--) |
|
257 | 251 | m_slices.removeAt(i); |
|
258 | 252 | |
|
259 | 253 | blockModelSignals(); |
|
260 | 254 | if (m_orientation == Qt::Vertical) |
|
261 | 255 | m_model->removeRows(firstIndex + m_first, slices.count()); |
|
262 | 256 | else |
|
263 | 257 | m_model->removeColumns(firstIndex + m_first, slices.count()); |
|
264 | 258 | blockModelSignals(false); |
|
265 | 259 | } |
|
266 | 260 | |
|
267 | 261 | void QPieModelMapperPrivate::sliceLabelChanged() |
|
268 | 262 | { |
|
269 | 263 | if (m_seriesSignalsBlock) |
|
270 | 264 | return; |
|
271 | 265 | |
|
272 | 266 | blockModelSignals(); |
|
273 | 267 | QPieSlice *slice = qobject_cast<QPieSlice *>(QObject::sender()); |
|
274 | 268 | m_model->setData(labelModelIndex(m_series->slices().indexOf(slice)), slice->label()); |
|
275 | 269 | blockModelSignals(false); |
|
276 | 270 | } |
|
277 | 271 | |
|
278 | 272 | void QPieModelMapperPrivate::sliceValueChanged() |
|
279 | 273 | { |
|
280 | 274 | if (m_seriesSignalsBlock) |
|
281 | 275 | return; |
|
282 | 276 | |
|
283 | 277 | blockModelSignals(); |
|
284 | 278 | QPieSlice *slice = qobject_cast<QPieSlice *>(QObject::sender()); |
|
285 | 279 | m_model->setData(valueModelIndex(m_series->slices().indexOf(slice)), slice->value()); |
|
286 | 280 | blockModelSignals(false); |
|
287 | 281 | } |
|
288 | 282 | |
|
289 | 283 | void QPieModelMapperPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) |
|
290 | 284 | { |
|
291 | 285 | if (m_modelSignalsBlock) |
|
292 | 286 | return; |
|
293 | 287 | |
|
294 | 288 | blockSeriesSignals(); |
|
295 | 289 | QModelIndex index; |
|
296 | 290 | QPieSlice *slice; |
|
297 | 291 | for (int row = topLeft.row(); row <= bottomRight.row(); row++) { |
|
298 | 292 | for (int column = topLeft.column(); column <= bottomRight.column(); column++) { |
|
299 | 293 | index = topLeft.sibling(row, column); |
|
300 | 294 | slice = pieSlice(index); |
|
301 | 295 | if (slice) { |
|
302 | 296 | slice->setValue(m_model->data(index, Qt::DisplayRole).toReal()); |
|
303 | 297 | slice->setLabel(m_model->data(index, Qt::DisplayRole).toString()); |
|
304 | 298 | } |
|
305 | 299 | } |
|
306 | 300 | } |
|
307 | 301 | blockSeriesSignals(false); |
|
308 | 302 | } |
|
309 | 303 | |
|
310 | 304 | |
|
311 | 305 | void QPieModelMapperPrivate::modelRowsAdded(QModelIndex parent, int start, int end) |
|
312 | 306 | { |
|
313 | 307 | Q_UNUSED(parent); |
|
314 | 308 | if (m_modelSignalsBlock) |
|
315 | 309 | return; |
|
316 | 310 | |
|
317 | 311 | blockSeriesSignals(); |
|
318 | 312 | if (m_orientation == Qt::Vertical) |
|
319 | 313 | insertData(start, end); |
|
320 | 314 | else if (start <= m_valuesIndex || start <= m_labelsIndex) // if the changes affect the map - reinitialize the pie |
|
321 | 315 | initializePieFromModel(); |
|
322 | 316 | blockSeriesSignals(false); |
|
323 | 317 | } |
|
324 | 318 | |
|
325 | 319 | void QPieModelMapperPrivate::modelRowsRemoved(QModelIndex parent, int start, int end) |
|
326 | 320 | { |
|
327 | 321 | Q_UNUSED(parent); |
|
328 | 322 | if (m_modelSignalsBlock) |
|
329 | 323 | return; |
|
330 | 324 | |
|
331 | 325 | blockSeriesSignals(); |
|
332 | 326 | if (m_orientation == Qt::Vertical) |
|
333 | 327 | removeData(start, end); |
|
334 | 328 | else if (start <= m_valuesIndex || start <= m_labelsIndex) // if the changes affect the map - reinitialize the pie |
|
335 | 329 | initializePieFromModel(); |
|
336 | 330 | blockSeriesSignals(false); |
|
337 | 331 | } |
|
338 | 332 | |
|
339 | 333 | void QPieModelMapperPrivate::modelColumnsAdded(QModelIndex parent, int start, int end) |
|
340 | 334 | { |
|
341 | 335 | Q_UNUSED(parent); |
|
342 | 336 | if (m_modelSignalsBlock) |
|
343 | 337 | return; |
|
344 | 338 | |
|
345 | 339 | blockSeriesSignals(); |
|
346 | 340 | if (m_orientation == Qt::Horizontal) |
|
347 | 341 | insertData(start, end); |
|
348 | 342 | else if (start <= m_valuesIndex || start <= m_labelsIndex) // if the changes affect the map - reinitialize the pie |
|
349 | 343 | initializePieFromModel(); |
|
350 | 344 | blockSeriesSignals(false); |
|
351 | 345 | } |
|
352 | 346 | |
|
353 | 347 | void QPieModelMapperPrivate::modelColumnsRemoved(QModelIndex parent, int start, int end) |
|
354 | 348 | { |
|
355 | 349 | Q_UNUSED(parent); |
|
356 | 350 | if (m_modelSignalsBlock) |
|
357 | 351 | return; |
|
358 | 352 | |
|
359 | 353 | blockSeriesSignals(); |
|
360 | 354 | if (m_orientation == Qt::Horizontal) |
|
361 | 355 | removeData(start, end); |
|
362 | 356 | else if (start <= m_valuesIndex || start <= m_labelsIndex) // if the changes affect the map - reinitialize the pie |
|
363 | 357 | initializePieFromModel(); |
|
364 | 358 | blockSeriesSignals(false); |
|
365 | 359 | } |
|
366 | 360 | |
|
367 | 361 | void QPieModelMapperPrivate::insertData(int start, int end) |
|
368 | 362 | { |
|
369 | 363 | if (m_count != -1 && start >= m_first + m_count) { |
|
370 | 364 | return; |
|
371 | 365 | } else { |
|
372 | 366 | int addedCount = end - start + 1; |
|
373 | 367 | if (m_count != -1 && addedCount > m_count) |
|
374 | 368 | addedCount = m_count; |
|
375 | 369 | int first = qMax(start, m_first); |
|
376 | 370 | int last = qMin(first + addedCount - 1, m_orientation == Qt::Vertical ? m_model->rowCount() - 1 : m_model->columnCount() - 1); |
|
377 | 371 | for (int i = first; i <= last; i++) { |
|
378 | 372 | QPieSlice *slice = new QPieSlice; |
|
379 | 373 | slice->setValue(m_model->data(valueModelIndex(i - m_first), Qt::DisplayRole).toDouble()); |
|
380 | 374 | slice->setLabel(m_model->data(labelModelIndex(i - m_first), Qt::DisplayRole).toString()); |
|
381 | 375 | slice->setLabelVisible(); |
|
382 | 376 | connect(slice, SIGNAL(labelChanged()), this, SLOT(sliceLabelChanged())); |
|
383 | 377 | connect(slice, SIGNAL(valueChanged()), this, SLOT(sliceValueChanged())); |
|
384 | 378 | m_series->insert(i - m_first, slice); |
|
385 | 379 | m_slices.insert(i - m_first, slice); |
|
386 | 380 | } |
|
387 | 381 | |
|
388 | 382 | // remove excess of slices (abouve m_count) |
|
389 | 383 | if (m_count != -1 && m_series->slices().size() > m_count) |
|
390 | 384 | for (int i = m_series->slices().size() - 1; i >= m_count; i--) { |
|
391 | 385 | m_series->remove(m_series->slices().at(i)); |
|
392 | 386 | m_slices.removeAt(i); |
|
393 | 387 | } |
|
394 | 388 | } |
|
395 | 389 | } |
|
396 | 390 | |
|
397 | 391 | void QPieModelMapperPrivate::removeData(int start, int end) |
|
398 | 392 | { |
|
399 | 393 | int removedCount = end - start + 1; |
|
400 | 394 | if (m_count != -1 && start >= m_first + m_count) { |
|
401 | 395 | return; |
|
402 | 396 | } else { |
|
403 | 397 | int toRemove = qMin(m_series->slices().size(), removedCount); // first find how many items can actually be removed |
|
404 | 398 | int first = qMax(start, m_first); // get the index of the first item that will be removed. |
|
405 | 399 | int last = qMin(first + toRemove - 1, m_series->slices().size() + m_first - 1); // get the index of the last item that will be removed. |
|
406 | 400 | for (int i = last; i >= first; i--) { |
|
407 | 401 | m_series->remove(m_series->slices().at(i - m_first)); |
|
408 | 402 | m_slices.removeAt(i - m_first); |
|
409 | 403 | } |
|
410 | 404 | |
|
411 | 405 | if (m_count != -1) { |
|
412 | 406 | int itemsAvailable; // check how many are available to be added |
|
413 | 407 | if (m_orientation == Qt::Vertical) |
|
414 | 408 | itemsAvailable = m_model->rowCount() - m_first - m_series->slices().size(); |
|
415 | 409 | else |
|
416 | 410 | itemsAvailable = m_model->columnCount() - m_first - m_series->slices().size(); |
|
417 | 411 | int toBeAdded = qMin(itemsAvailable, m_count - m_series->slices().size()); // add not more items than there is space left to be filled. |
|
418 | 412 | int currentSize = m_series->slices().size(); |
|
419 | 413 | if (toBeAdded > 0) |
|
420 | 414 | for (int i = m_series->slices().size(); i < currentSize + toBeAdded; i++) { |
|
421 | 415 | QPieSlice *slice = new QPieSlice; |
|
422 | 416 | if (m_orientation == Qt::Vertical) { |
|
423 | 417 | slice->setValue(m_model->data(m_model->index(i + m_first, m_valuesIndex), Qt::DisplayRole).toDouble()); |
|
424 | 418 | slice->setLabel(m_model->data(m_model->index(i + m_first, m_labelsIndex), Qt::DisplayRole).toString()); |
|
425 | 419 | } else { |
|
426 | 420 | slice->setValue(m_model->data(m_model->index(m_valuesIndex, i + m_first), Qt::DisplayRole).toDouble()); |
|
427 | 421 | slice->setLabel(m_model->data(m_model->index(m_labelsIndex, i + m_first), Qt::DisplayRole).toString()); |
|
428 | 422 | } |
|
429 | 423 | slice->setLabelVisible(); |
|
430 | 424 | m_series->insert(i, slice); |
|
431 | 425 | m_slices.insert(i, slice); |
|
432 | 426 | } |
|
433 | 427 | } |
|
434 | 428 | } |
|
435 | 429 | } |
|
436 | 430 | |
|
437 | 431 | void QPieModelMapperPrivate::initializePieFromModel() |
|
438 | 432 | { |
|
439 | 433 | if (m_model == 0 || m_series == 0) |
|
440 | 434 | return; |
|
441 | 435 | |
|
442 | // check if mappings are set | |
|
443 | if (m_valuesIndex == -1 || m_labelsIndex == -1) | |
|
444 | return; | |
|
445 | ||
|
446 | 436 | blockSeriesSignals(); |
|
447 | 437 | // clear current content |
|
448 | 438 | m_series->clear(); |
|
449 | 439 | m_slices.clear(); |
|
450 | 440 | |
|
451 | 441 | // create the initial slices set |
|
452 | 442 | int slicePos = 0; |
|
453 | 443 | QModelIndex valueIndex = valueModelIndex(slicePos); |
|
454 | 444 | QModelIndex labelIndex = labelModelIndex(slicePos); |
|
455 | 445 | while (valueIndex.isValid() && labelIndex.isValid()) { |
|
456 | 446 | QPieSlice *slice = new QPieSlice; |
|
457 | 447 | slice->setLabel(m_model->data(labelIndex, Qt::DisplayRole).toString()); |
|
458 | 448 | slice->setValue(m_model->data(valueIndex, Qt::DisplayRole).toDouble()); |
|
459 | 449 | connect(slice, SIGNAL(labelChanged()), this, SLOT(sliceLabelChanged())); |
|
460 | 450 | connect(slice, SIGNAL(valueChanged()), this, SLOT(sliceValueChanged())); |
|
461 | 451 | m_series->append(slice); |
|
462 | 452 | m_slices.append(slice); |
|
463 | 453 | // m_series->append(m_model->data(labelIndex, Qt::DisplayRole).toString(), m_model->data(valueIndex, Qt::DisplayRole).toDouble()); |
|
464 | 454 | slicePos++; |
|
465 | 455 | valueIndex = valueModelIndex(slicePos); |
|
466 | 456 | labelIndex = labelModelIndex(slicePos); |
|
467 | 457 | } |
|
468 | 458 | m_series->setLabelsVisible(true); |
|
469 | 459 | blockSeriesSignals(false); |
|
470 | 460 | } |
|
471 | 461 | |
|
472 | 462 | #include "moc_qpiemodelmapper_p.cpp" |
|
473 | 463 | #include "moc_qpiemodelmapper.cpp" |
|
474 | 464 | |
|
475 | 465 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,10 +1,10 | |||
|
1 | 1 | !include( ../tests.pri ) { |
|
2 | 2 | error( "Couldn't find the tests.pri file!" ) |
|
3 | 3 | } |
|
4 | 4 | |
|
5 | 5 | TEMPLATE = subdirs |
|
6 | SUBDIRS += qchartview qchart qlineseries qbarset qbarseries qstackedbarseries qpercentbarseries qgroupedbarseries qpieslice qpieseries | |
|
6 | SUBDIRS += qchartview qchart qlineseries qbarset qbarseries qstackedbarseries qpercentbarseries qgroupedbarseries qpieslice qpieseries qpiemodelmapper | |
|
7 | 7 | |
|
8 | 8 | test_private:{ |
|
9 | 9 | SUBDIRS += chartdataset domain |
|
10 | 10 | } |
@@ -1,519 +1,519 | |||
|
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 "tablewidget.h" |
|
22 | 22 | #include <QGridLayout> |
|
23 | 23 | #include <QTableView> |
|
24 | 24 | #include <QChart> |
|
25 | 25 | #include <QStyledItemDelegate> |
|
26 | 26 | #include <QLineSeries> |
|
27 | 27 | #include <QSplineSeries> |
|
28 | 28 | #include <QScatterSeries> |
|
29 | 29 | #include <QXYModelMapper> |
|
30 | 30 | #include "customtablemodel.h" |
|
31 | 31 | #include <QPieSeries> |
|
32 | 32 | #include <QVPieModelMapper> |
|
33 | 33 | #include <QPieSlice> |
|
34 | 34 | #include <QAreaSeries> |
|
35 | 35 | #include <QBarSeries> |
|
36 | 36 | #include <QGroupedBarSeries> |
|
37 | 37 | #include <QBarSet> |
|
38 | 38 | #include <QBarModelMapper> |
|
39 | 39 | #include <QPushButton> |
|
40 | 40 | #include <QRadioButton> |
|
41 | 41 | #include <QLabel> |
|
42 | 42 | #include <QSpinBox> |
|
43 | 43 | #include <QTime> |
|
44 | 44 | #include <QHeaderView> |
|
45 | 45 | |
|
46 | 46 | TableWidget::TableWidget(QWidget *parent) |
|
47 | 47 | : QWidget(parent) |
|
48 | 48 | // specialPie(0) |
|
49 | 49 | { |
|
50 | 50 | setGeometry(1900, 100, 1000, 600); |
|
51 | 51 | qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); |
|
52 | 52 | // create simple model for storing data |
|
53 | 53 | // user's table data model |
|
54 | 54 | m_model = new CustomTableModel; |
|
55 | 55 | m_tableView = new QTableView; |
|
56 | 56 | m_tableView->setModel(m_model); |
|
57 | 57 | // m_tableView->setMinimumHeight(300); |
|
58 | 58 | m_tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch); |
|
59 | 59 | m_tableView->verticalHeader()->setResizeMode(QHeaderView::Stretch); |
|
60 | 60 | |
|
61 | 61 | m_chart = new QChart; |
|
62 | 62 | m_chart->legend()->setVisible(true); |
|
63 | 63 | m_chart->setAnimationOptions(QChart::SeriesAnimations); |
|
64 | 64 | m_chartView = new QChartView(m_chart); |
|
65 | 65 | m_chartView->setRenderHint(QPainter::Antialiasing); |
|
66 | 66 | m_chartView->setMinimumSize(640, 480); |
|
67 | 67 | |
|
68 | 68 | // add, remove data buttons |
|
69 | 69 | QPushButton* addRowAboveButton = new QPushButton("Add row above"); |
|
70 | 70 | connect(addRowAboveButton, SIGNAL(clicked()), this, SLOT(addRowAbove())); |
|
71 | 71 | |
|
72 | 72 | QPushButton* addRowBelowButton = new QPushButton("Add row below"); |
|
73 | 73 | connect(addRowBelowButton, SIGNAL(clicked()), this, SLOT(addRowBelow())); |
|
74 | 74 | |
|
75 | 75 | QPushButton* removeRowButton = new QPushButton("Remove row"); |
|
76 | 76 | connect(removeRowButton, SIGNAL(clicked()), this, SLOT(removeRow())); |
|
77 | 77 | |
|
78 | 78 | QPushButton* addColumnRightButton = new QPushButton("Add column to the right"); |
|
79 | 79 | connect(addColumnRightButton, SIGNAL(clicked()), this, SLOT(addColumnRight())); |
|
80 | 80 | |
|
81 | 81 | QPushButton* removeColumnButton = new QPushButton("Remove column"); |
|
82 | 82 | connect(removeColumnButton, SIGNAL(clicked()), this, SLOT(removeColumn())); |
|
83 | 83 | |
|
84 | 84 | QPushButton* specialPieButton = new QPushButton("Add slices from series"); |
|
85 | 85 | connect(specialPieButton, SIGNAL(clicked()), this, SLOT(testPie())); |
|
86 | 86 | |
|
87 | 87 | QPushButton* specialPieButton2 = new QPushButton("Remove slices from series"); |
|
88 | 88 | connect(specialPieButton2, SIGNAL(clicked()), this, SLOT(testPie2())); |
|
89 | 89 | |
|
90 | 90 | QPushButton* specialPieButton3 = new QPushButton("Remove slices from series"); |
|
91 | 91 | connect(specialPieButton3, SIGNAL(clicked()), this, SLOT(testPie3())); |
|
92 | 92 | |
|
93 | 93 | |
|
94 | 94 | // QLabel *spinBoxLabel = new QLabel("Rows affected:"); |
|
95 | 95 | |
|
96 | 96 | // spin box for setting number of affected items (add, remove) |
|
97 | 97 | m_linesCountSpinBox = new QSpinBox; |
|
98 | 98 | m_linesCountSpinBox->setRange(1, 10); |
|
99 | 99 | m_linesCountSpinBox->setValue(1); |
|
100 | 100 | |
|
101 | 101 | // buttons layout |
|
102 | 102 | QVBoxLayout* buttonsLayout = new QVBoxLayout; |
|
103 | 103 | // buttonsLayout->addWidget(spinBoxLabel); |
|
104 | 104 | // buttonsLayout->addWidget(m_linesCountSpinBox); |
|
105 | 105 | // buttonsLayout->addWidget(addRowAboveButton); |
|
106 | 106 | buttonsLayout->addWidget(addRowBelowButton); |
|
107 | 107 | buttonsLayout->addWidget(removeRowButton); |
|
108 | 108 | // buttonsLayout->addWidget(addColumnRightButton); |
|
109 | 109 | // buttonsLayout->addWidget(removeColumnButton); |
|
110 | 110 | buttonsLayout->addWidget(specialPieButton); |
|
111 | 111 | buttonsLayout->addWidget(specialPieButton2); |
|
112 | 112 | buttonsLayout->addWidget(specialPieButton3); |
|
113 | 113 | buttonsLayout->addStretch(); |
|
114 | 114 | |
|
115 | 115 | // chart type radio buttons |
|
116 | 116 | m_lineRadioButton = new QRadioButton("Line"); |
|
117 | 117 | m_splineRadioButton = new QRadioButton("Spline"); |
|
118 | 118 | m_scatterRadioButton = new QRadioButton("Scatter"); |
|
119 | 119 | m_pieRadioButton = new QRadioButton("Pie"); |
|
120 | 120 | m_areaRadioButton = new QRadioButton("Area"); |
|
121 | 121 | m_barRadioButton = new QRadioButton("Bar"); |
|
122 | 122 | |
|
123 | 123 | connect(m_lineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); |
|
124 | 124 | connect(m_splineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); |
|
125 | 125 | connect(m_scatterRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); |
|
126 | 126 | connect(m_pieRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); |
|
127 | 127 | connect(m_areaRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); |
|
128 | 128 | connect(m_barRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); |
|
129 | 129 | m_lineRadioButton->setChecked(true); |
|
130 | 130 | |
|
131 | 131 | // radio buttons layout |
|
132 | 132 | QVBoxLayout* radioLayout = new QVBoxLayout; |
|
133 | 133 | radioLayout->addWidget(m_lineRadioButton); |
|
134 | 134 | radioLayout->addWidget(m_splineRadioButton); |
|
135 | 135 | // radioLayout->addWidget(m_scatterRadioButton); |
|
136 | 136 | radioLayout->addWidget(m_pieRadioButton); |
|
137 | 137 | // radioLayout->addWidget(m_areaRadioButton); |
|
138 | 138 | radioLayout->addWidget(m_barRadioButton); |
|
139 | 139 | radioLayout->addStretch(); |
|
140 | 140 | |
|
141 | 141 | // create main layout |
|
142 | 142 | QGridLayout* mainLayout = new QGridLayout; |
|
143 | 143 | mainLayout->addLayout(buttonsLayout, 2, 0); |
|
144 | 144 | mainLayout->addLayout(radioLayout, 3, 0); |
|
145 | 145 | mainLayout->addWidget(m_tableView, 1, 0); |
|
146 | 146 | mainLayout->addWidget(m_chartView, 1, 1, 2, 1); |
|
147 | 147 | setLayout(mainLayout); |
|
148 | 148 | m_lineRadioButton->setFocus(); |
|
149 | 149 | } |
|
150 | 150 | |
|
151 | 151 | void TableWidget::addRowAbove() |
|
152 | 152 | { |
|
153 | 153 | m_model->insertRows(m_tableView->currentIndex().row(), m_linesCountSpinBox->value()); |
|
154 | 154 | |
|
155 | 155 | } |
|
156 | 156 | |
|
157 | 157 | void TableWidget::addRowBelow() |
|
158 | 158 | { |
|
159 | 159 | m_model->insertRows(m_tableView->currentIndex().row() + 1, m_linesCountSpinBox->value()); |
|
160 | 160 | |
|
161 | 161 | } |
|
162 | 162 | |
|
163 | 163 | void TableWidget::removeRow() |
|
164 | 164 | { |
|
165 | 165 | m_model->removeRows(m_tableView->currentIndex().row(), qMin(m_model->rowCount() - m_tableView->currentIndex().row(), m_linesCountSpinBox->value())); |
|
166 | 166 | } |
|
167 | 167 | |
|
168 | 168 | void TableWidget::addColumnRight() |
|
169 | 169 | { |
|
170 | 170 | m_model->insertColumns(m_tableView->currentIndex().column() + 1, m_linesCountSpinBox->value()); |
|
171 | 171 | } |
|
172 | 172 | |
|
173 | 173 | void TableWidget::removeColumn() |
|
174 | 174 | { |
|
175 | 175 | m_model->removeColumns(m_tableView->currentIndex().column(), qMin(m_model->columnCount() - m_tableView->currentIndex().column(), m_linesCountSpinBox->value())); |
|
176 | 176 | } |
|
177 | 177 | |
|
178 | 178 | void TableWidget::updateChartType(bool toggle) |
|
179 | 179 | { |
|
180 | 180 | // this if is needed, so that the function is only called once. |
|
181 | 181 | // For the radioButton that was enabled. |
|
182 | 182 | if (toggle) { |
|
183 | 183 | // specialPie = 0; |
|
184 | 184 | m_chart->removeAllSeries(); |
|
185 | 185 | // m_chart->axisX()->setNiceNumbersEnabled(false); |
|
186 | 186 | // m_chart->axisY()->setNiceNumbersEnabled(false); |
|
187 | 187 | |
|
188 | 188 | // // renable axes of the chart (pie hides them) |
|
189 | 189 | // // x axis |
|
190 | 190 | // QAxis *axis = m_chart->axisX(); |
|
191 | 191 | // axis->setAxisVisible(true); |
|
192 | 192 | // axis->setGridLineVisible(true); |
|
193 | 193 | // axis->setLabelsVisible(true); |
|
194 | 194 | |
|
195 | 195 | // // y axis |
|
196 | 196 | // axis = m_chart->axisY(); |
|
197 | 197 | // axis->setAxisVisible(true); |
|
198 | 198 | // axis->setGridLineVisible(true); |
|
199 | 199 | // axis->setLabelsVisible(true); |
|
200 | 200 | |
|
201 | 201 | // m_model->clearMapping(); |
|
202 | 202 | |
|
203 | 203 | QString seriesColorHex = "#000000"; |
|
204 | 204 | // QPen pen; |
|
205 | 205 | // pen.setWidth(2); |
|
206 | 206 | |
|
207 | 207 | if (m_lineRadioButton->isChecked()) |
|
208 | 208 | { |
|
209 | 209 | // m_chart->setAnimationOptions(QChart::NoAnimation); |
|
210 | 210 | |
|
211 | 211 | // // series 1 |
|
212 | 212 | // m_series = new QLineSeries; |
|
213 | 213 | // m_series->setModel(m_model); |
|
214 | 214 | |
|
215 | 215 | // QXYModelMapper *mapper = new QXYModelMapper; |
|
216 | 216 | // mapper->setMapX(0); |
|
217 | 217 | // mapper->setMapY(1); |
|
218 | 218 | // mapper->setFirst(3); |
|
219 | 219 | // mapper->setCount(4); |
|
220 | 220 | // m_series->setModelMapper(mapper); |
|
221 | 221 | // // m_series->setModelMapping(0,1, Qt::Vertical); |
|
222 | 222 | // // m_series->setModelMappingRange(3, 4); |
|
223 | 223 | // m_chart->addSeries(m_series); |
|
224 | 224 | // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); |
|
225 | 225 | // m_model->addMapping(seriesColorHex, QRect(0, 3, 2, 4)); |
|
226 | 226 | |
|
227 | 227 | // // series 2 |
|
228 | 228 | // m_series = new QLineSeries; |
|
229 | 229 | // m_series->setModel(m_model); |
|
230 | 230 | |
|
231 | 231 | // mapper = new QXYModelMapper; |
|
232 | 232 | // mapper->setMapX(3); |
|
233 | 233 | // mapper->setMapY(4); |
|
234 | 234 | // // mapper->setFirst(3); |
|
235 | 235 | // // mapper->setCount(4); |
|
236 | 236 | // m_series->setModelMapper(mapper); |
|
237 | 237 | // // m_series->setModelMapping(2,3, Qt::Vertical); |
|
238 | 238 | // m_chart->addSeries(m_series); |
|
239 | 239 | // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); |
|
240 | 240 | // m_model->addMapping(seriesColorHex, QRect(3, 0, 2, 1000)); |
|
241 | 241 | |
|
242 | 242 | // // series 3 |
|
243 | 243 | // m_series = new QLineSeries; |
|
244 | 244 | // m_series->setModel(m_model); |
|
245 | 245 | |
|
246 | 246 | // mapper = new QXYModelMapper; |
|
247 | 247 | // mapper->setMapX(5); |
|
248 | 248 | // mapper->setMapY(6); |
|
249 | 249 | // mapper->setFirst(2); |
|
250 | 250 | // mapper->setCount(-1); |
|
251 | 251 | // m_series->setModelMapper(mapper); |
|
252 | 252 | // // m_series->setModelMapping(4,5, Qt::Vertical); |
|
253 | 253 | // // m_series->setModelMappingRange(2, -1); |
|
254 | 254 | // m_chart->addSeries(m_series); |
|
255 | 255 | // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); |
|
256 | 256 | // m_model->addMapping(seriesColorHex, QRect(5, 2, 2, 1000)); |
|
257 | 257 | } |
|
258 | 258 | else if (m_splineRadioButton->isChecked()) |
|
259 | 259 | { |
|
260 | 260 | // m_chart->setAnimationOptions(QChart::NoAnimation); |
|
261 | 261 | |
|
262 | 262 | // // series 1 |
|
263 | 263 | // m_series = new QSplineSeries; |
|
264 | 264 | // m_series->setModel(m_model); |
|
265 | 265 | |
|
266 | 266 | // QXYModelMapper *mapper = new QXYModelMapper; |
|
267 | 267 | // mapper->setMapX(0); |
|
268 | 268 | // mapper->setMapY(1); |
|
269 | 269 | // mapper->setFirst(0); |
|
270 | 270 | // mapper->setCount(-1); |
|
271 | 271 | |
|
272 | 272 | // m_series->setModelMapper(mapper); |
|
273 | 273 | |
|
274 | 274 | // m_chart->addSeries(m_series); |
|
275 | 275 | // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); |
|
276 | 276 | // m_model->addMapping(seriesColorHex, QRect(0, 0, 2, 1000)); |
|
277 | 277 | |
|
278 | 278 | // // series 2 |
|
279 | 279 | // m_series = new QSplineSeries; |
|
280 | 280 | // m_series->setModel(m_model); |
|
281 | 281 | |
|
282 | 282 | // mapper = new QXYModelMapper; |
|
283 | 283 | // mapper->setMapX(2); |
|
284 | 284 | // mapper->setMapY(3); |
|
285 | 285 | // mapper->setFirst(2); |
|
286 | 286 | // mapper->setCount(4); |
|
287 | 287 | |
|
288 | 288 | // m_series->setModelMapper(mapper); |
|
289 | 289 | |
|
290 | 290 | // m_chart->addSeries(m_series); |
|
291 | 291 | // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); |
|
292 | 292 | // m_model->addMapping(seriesColorHex, QRect(2, 2, 2, 4)); |
|
293 | 293 | |
|
294 | 294 | // // series 3 |
|
295 | 295 | // m_series = new QSplineSeries; |
|
296 | 296 | // m_series->setModel(m_model); |
|
297 | 297 | |
|
298 | 298 | // mapper = new QXYModelMapper; |
|
299 | 299 | // mapper->setMapX(4); |
|
300 | 300 | // mapper->setMapY(5); |
|
301 | 301 | // mapper->setFirst(2); |
|
302 | 302 | // mapper->setCount(-1); |
|
303 | 303 | |
|
304 | 304 | // m_series->setModelMapper(mapper); |
|
305 | 305 | |
|
306 | 306 | // m_chart->addSeries(m_series); |
|
307 | 307 | // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); |
|
308 | 308 | // m_model->addMapping(seriesColorHex, QRect(4, 2, 2, 1000)); |
|
309 | 309 | } |
|
310 | 310 | // else if (m_scatterRadioButton->isChecked()) |
|
311 | 311 | // { |
|
312 | 312 | // m_chart->setAnimationOptions(QChart::NoAnimation); |
|
313 | 313 | |
|
314 | 314 | // // series 1 |
|
315 | 315 | // m_series = new QScatterSeries; |
|
316 | 316 | // m_series->setModel(m_model); |
|
317 | 317 | // m_series->setModelMapping(0,1, Qt::Vertical); |
|
318 | 318 | // // m_series->setModelMappingRange(2, 0); |
|
319 | 319 | // // series->setModelMapping(0,1, Qt::Horizontal); |
|
320 | 320 | // m_chart->addSeries(m_series); |
|
321 | 321 | |
|
322 | 322 | // seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper(); |
|
323 | 323 | // m_model->addMapping(seriesColorHex, QRect(0, 2, 2, 1000)); |
|
324 | 324 | |
|
325 | 325 | // // series 2 |
|
326 | 326 | // m_series = new QScatterSeries; |
|
327 | 327 | // m_series->setModel(m_model); |
|
328 | 328 | // m_series->setModelMapping(2,3, Qt::Vertical); |
|
329 | 329 | // // m_series->setModelMappingRange(1, 6); |
|
330 | 330 | // // series->setModelMapping(2,3, Qt::Horizontal); |
|
331 | 331 | // m_chart->addSeries(m_series); |
|
332 | 332 | |
|
333 | 333 | // seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper(); |
|
334 | 334 | // m_model->addMapping(seriesColorHex, QRect(2, 1, 2, 6)); |
|
335 | 335 | |
|
336 | 336 | // // series 3 |
|
337 | 337 | // m_series = new QScatterSeries; |
|
338 | 338 | // m_series->setModel(m_model); |
|
339 | 339 | // m_series->setModelMapping(4,5, Qt::Vertical); |
|
340 | 340 | // // series->setModelMapping(4,5, Qt::Horizontal); |
|
341 | 341 | // m_chart->addSeries(m_series); |
|
342 | 342 | // seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper(); |
|
343 | 343 | // m_model->addMapping(seriesColorHex, QRect(4, 0, 2, 1000)); |
|
344 | 344 | // } |
|
345 | 345 | else if (m_pieRadioButton->isChecked()) |
|
346 | 346 | { |
|
347 | 347 | m_chart->setAnimationOptions(QChart::SeriesAnimations); |
|
348 | 348 | |
|
349 | 349 | // pie 1 |
|
350 | 350 | m_pieSeries = new QPieSeries; |
|
351 | 351 | |
|
352 | 352 | m_pieMapper = new QVPieModelMapper; |
|
353 | 353 | m_pieMapper->setValuesColumn(1); |
|
354 | 354 | m_pieMapper->setLabelsColumn(7); |
|
355 | 355 | m_pieMapper->setSeries(m_pieSeries); |
|
356 | 356 | m_pieMapper->setModel(m_model); |
|
357 | 357 | m_pieMapper->setFirst(2); |
|
358 | m_pieMapper->setCount(5); | |
|
358 | // m_pieMapper->setCount(5); | |
|
359 | 359 | // pieSeries->setModelMapper(mapper); |
|
360 | 360 | |
|
361 | 361 | m_pieSeries->setLabelsVisible(true); |
|
362 | 362 | m_pieSeries->setPieSize(0.75); |
|
363 | 363 | // pieSeries->setHorizontalPosition(0.2); |
|
364 | 364 | // pieSeries->setVerticalPosition(0.3); |
|
365 | 365 | |
|
366 | 366 | m_chart->addSeries(m_pieSeries); |
|
367 | 367 | seriesColorHex = "#" + QString::number(m_pieSeries->slices().at(m_pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper(); |
|
368 | 368 | m_model->addMapping(seriesColorHex, QRect(0, 2, 2, 5)); |
|
369 | 369 | |
|
370 | 370 | |
|
371 | 371 | // pieSeries->slices().at(0)->setValue(400); |
|
372 | 372 | // pieSeries->slices().at(0)->setLabel(QString("36")); |
|
373 | 373 | |
|
374 | 374 | // // pie 2 |
|
375 | 375 | // pieSeries = new QPieSeries; |
|
376 | 376 | // pieSeries->setModel(m_model); |
|
377 | 377 | |
|
378 | 378 | // pieSeries->setModelMapping(1,1, Qt::Vertical); |
|
379 | 379 | // pieSeries->setModelMappingRange(2, -1); |
|
380 | 380 | // pieSeries->setLabelsVisible(true); |
|
381 | 381 | // pieSeries->setPieSize(0.35); |
|
382 | 382 | // pieSeries->setHorizontalPosition(0.8); |
|
383 | 383 | // pieSeries->setVerticalPosition(0.3); |
|
384 | 384 | // m_chart->addSeries(pieSeries); |
|
385 | 385 | // seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper(); |
|
386 | 386 | // m_model->addMapping(seriesColorHex, QRect(1, 2, 1, 1000)); |
|
387 | 387 | |
|
388 | 388 | // // pie 3 |
|
389 | 389 | // pieSeries = new QPieSeries; |
|
390 | 390 | // pieSeries->setModel(m_model); |
|
391 | 391 | // pieSeries->setModelMapping(2,2, Qt::Vertical); |
|
392 | 392 | // pieSeries->setLabelsVisible(true); |
|
393 | 393 | // pieSeries->setPieSize(0.35); |
|
394 | 394 | // pieSeries->setHorizontalPosition(0.5); |
|
395 | 395 | // pieSeries->setVerticalPosition(0.75); |
|
396 | 396 | // m_chart->addSeries(pieSeries); |
|
397 | 397 | // seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper(); |
|
398 | 398 | // m_model->addMapping(seriesColorHex, QRect(2, 0, 1, 1000)); |
|
399 | 399 | |
|
400 | 400 | // // special pie |
|
401 | 401 | // specialPie = new QPieSeries; |
|
402 | 402 | // specialPie->append(17, "1"); |
|
403 | 403 | // specialPie->append(45, "2"); |
|
404 | 404 | // specialPie->append(77, "3"); |
|
405 | 405 | // specialPie->append(37, "4"); |
|
406 | 406 | // specialPie->append(27, "5"); |
|
407 | 407 | // specialPie->append(47, "6"); |
|
408 | 408 | // specialPie->setPieSize(0.35); |
|
409 | 409 | // specialPie->setHorizontalPosition(0.8); |
|
410 | 410 | // specialPie->setVerticalPosition(0.75); |
|
411 | 411 | // specialPie->setLabelsVisible(true); |
|
412 | 412 | // m_chart->addSeries(specialPie); |
|
413 | 413 | } |
|
414 | 414 | // else if (m_areaRadioButton->isChecked()) |
|
415 | 415 | // { |
|
416 | 416 | // m_chart->setAnimationOptions(QChart::NoAnimation); |
|
417 | 417 | |
|
418 | 418 | // QLineSeries* upperLineSeries = new QLineSeries; |
|
419 | 419 | // upperLineSeries->setModel(m_model); |
|
420 | 420 | // upperLineSeries->setModelMapping(0, 1, Qt::Vertical); |
|
421 | 421 | // // upperLineSeries->setModelMappingRange(1, 5); |
|
422 | 422 | // QLineSeries* lowerLineSeries = new QLineSeries; |
|
423 | 423 | // lowerLineSeries->setModel(m_model); |
|
424 | 424 | // lowerLineSeries->setModelMapping(2, 3, Qt::Vertical); |
|
425 | 425 | // QAreaSeries* areaSeries = new QAreaSeries(upperLineSeries, lowerLineSeries); |
|
426 | 426 | // m_chart->addSeries(areaSeries); |
|
427 | 427 | // seriesColorHex = "#" + QString::number(areaSeries->brush().color().rgb(), 16).right(6).toUpper(); |
|
428 | 428 | // m_model->addMapping(seriesColorHex, QRect(0, 1, 2, 5)); |
|
429 | 429 | // m_model->addMapping(seriesColorHex, QRect(2, 0, 2, 1000)); |
|
430 | 430 | // } |
|
431 | 431 | else if (m_barRadioButton->isChecked()) |
|
432 | 432 | { |
|
433 | 433 | // m_chart->setAnimationOptions(QChart::SeriesAnimations); |
|
434 | 434 | |
|
435 | 435 | // QGroupedBarSeries* barSeries = new QGroupedBarSeries(); |
|
436 | 436 | // barSeries->setCategories(QStringList()); |
|
437 | 437 | // barSeries->setModel(m_model); |
|
438 | 438 | // // barSeries->setModelMappingRange(2, 5); |
|
439 | 439 | //// barSeries->setModelMapping(5, 2, 4, Qt::Vertical); |
|
440 | 440 | |
|
441 | 441 | // QBarModelMapper *mapper = new QBarModelMapper; |
|
442 | 442 | // mapper->setMapCategories(5); |
|
443 | 443 | // mapper->setMapBarBottom(2); |
|
444 | 444 | // mapper->setMapBarTop(4); |
|
445 | 445 | // barSeries->setModelMapper(mapper); |
|
446 | 446 | // m_chart->addSeries(barSeries); |
|
447 | 447 | // QList<QBarSet*> barsets = barSeries->barSets(); |
|
448 | 448 | // for (int i = 0; i < barsets.count(); i++) { |
|
449 | 449 | // seriesColorHex = "#" + QString::number(barsets.at(i)->brush().color().rgb(), 16).right(6).toUpper(); |
|
450 | 450 | // m_model->addMapping(seriesColorHex, QRect(2 + i, 0, 1, 1000)); |
|
451 | 451 | // } |
|
452 | 452 | } |
|
453 | 453 | |
|
454 | 454 | |
|
455 | 455 | if (!m_barRadioButton->isChecked()) { |
|
456 | 456 | m_chart->axisX()->setRange(0, 500); |
|
457 | 457 | m_chart->axisY()->setRange(0, 220); |
|
458 | 458 | } |
|
459 | 459 | m_chart->legend()->setVisible(true); |
|
460 | 460 | |
|
461 | 461 | // repaint table view colors |
|
462 | 462 | m_tableView->repaint(); |
|
463 | 463 | m_tableView->setFocus(); |
|
464 | 464 | } |
|
465 | 465 | } |
|
466 | 466 | |
|
467 | 467 | void TableWidget::testPie() |
|
468 | 468 | { |
|
469 | 469 | // m_pieMapper->setCount(-1); |
|
470 | 470 | QPieSlice *slice = new QPieSlice("Hehe", 145); |
|
471 | 471 | slice->setLabelVisible(); |
|
472 | 472 | m_pieSeries->append(slice); |
|
473 | 473 | |
|
474 | 474 | slice = new QPieSlice("Hoho", 34); |
|
475 | 475 | slice->setLabelVisible(); |
|
476 | 476 | m_pieSeries->append(slice); |
|
477 | 477 | // m_series->modelMapper()->setMapX(4); |
|
478 | 478 | // m_tableView->setColumnWidth(10, 250); |
|
479 | 479 | // if (specialPie) { |
|
480 | 480 | // specialPie->remove(specialPie->slices().at(2)); |
|
481 | 481 | // // specialPie->insert(4, new QPieSlice(45, "Hello"));//specialPie->slices.at(2)); |
|
482 | 482 | // specialPie->append(4, "heloo"); |
|
483 | 483 | // } |
|
484 | 484 | } |
|
485 | 485 | |
|
486 | 486 | void TableWidget::testPie2() |
|
487 | 487 | { |
|
488 | 488 | QPieSlice *slice; |
|
489 | 489 | if (m_pieSeries->count() > 0) { |
|
490 | 490 | slice = m_pieSeries->slices().last(); |
|
491 | 491 | m_pieSeries->remove(slice); |
|
492 | 492 | } |
|
493 | 493 | |
|
494 | 494 | if (m_pieSeries->count() > 0) { |
|
495 | 495 | slice = m_pieSeries->slices().first(); |
|
496 | 496 | m_pieSeries->remove(slice); |
|
497 | 497 | } |
|
498 | 498 | } |
|
499 | 499 | |
|
500 | 500 | void TableWidget::testPie3() |
|
501 | 501 | { |
|
502 | 502 | QPieSlice *slice; |
|
503 | 503 | if (m_pieSeries->count() > 0) { |
|
504 | 504 | slice = m_pieSeries->slices().last(); |
|
505 | 505 | slice->setLabel("Dalej"); |
|
506 | 506 | slice->setValue(222); |
|
507 | 507 | } |
|
508 | 508 | |
|
509 | 509 | if (m_pieSeries->count() > 0) { |
|
510 | 510 | slice = m_pieSeries->slices().first(); |
|
511 | 511 | slice->setLabel("Prawie"); |
|
512 | 512 | slice->setValue(111); |
|
513 | 513 | } |
|
514 | 514 | } |
|
515 | 515 | |
|
516 | 516 | TableWidget::~TableWidget() |
|
517 | 517 | { |
|
518 | 518 | |
|
519 | 519 | } |
General Comments 0
You need to be logged in to leave comments.
Login now