@@ -1,394 +1,406 | |||
|
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 "customtablemodel.h" |
|
30 | 30 | #include <QPieSeries> |
|
31 | 31 | #include <QPieSlice> |
|
32 | 32 | #include <QAreaSeries> |
|
33 | 33 | #include <QBarSeries> |
|
34 | 34 | #include <QBarSet> |
|
35 | 35 | #include <QPushButton> |
|
36 | 36 | #include <QRadioButton> |
|
37 | 37 | #include <QLabel> |
|
38 | 38 | #include <QSpinBox> |
|
39 | 39 | #include <QTime> |
|
40 | 40 | |
|
41 | 41 | TableWidget::TableWidget(QWidget *parent) |
|
42 | 42 | : QWidget(parent) |
|
43 | 43 | // specialPie(0) |
|
44 | 44 | { |
|
45 | 45 | setGeometry(1900, 100, 1000, 600); |
|
46 | 46 | qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); |
|
47 | 47 | // create simple model for storing data |
|
48 | 48 | // user's table data model |
|
49 | 49 | m_model = new CustomTableModel; |
|
50 | 50 | m_tableView = new QTableView; |
|
51 | 51 | m_tableView->setModel(m_model); |
|
52 | 52 | m_tableView->setMinimumHeight(300); |
|
53 | 53 | m_chart = new QChart; |
|
54 | 54 | m_chart->legend()->setVisible(true); |
|
55 | 55 | m_chart->setAnimationOptions(QChart::SeriesAnimations); |
|
56 | 56 | m_chartView = new QChartView(m_chart); |
|
57 | 57 | m_chartView->setRenderHint(QPainter::Antialiasing); |
|
58 | 58 | m_chartView->setMinimumSize(640, 480); |
|
59 | 59 | |
|
60 | 60 | // add, remove data buttons |
|
61 | 61 | QPushButton* addRowAboveButton = new QPushButton("Add row above"); |
|
62 | 62 | connect(addRowAboveButton, SIGNAL(clicked()), this, SLOT(addRowAbove())); |
|
63 | 63 | |
|
64 | 64 | QPushButton* addRowBelowButton = new QPushButton("Add row below"); |
|
65 | 65 | connect(addRowBelowButton, SIGNAL(clicked()), this, SLOT(addRowBelow())); |
|
66 | 66 | |
|
67 | 67 | QPushButton* removeRowButton = new QPushButton("Remove row"); |
|
68 | 68 | connect(removeRowButton, SIGNAL(clicked()), this, SLOT(removeRow())); |
|
69 | 69 | |
|
70 | 70 | QPushButton* addColumnRightButton = new QPushButton("Add column to the right"); |
|
71 | 71 | connect(addColumnRightButton, SIGNAL(clicked()), this, SLOT(addColumnRight())); |
|
72 | 72 | |
|
73 | 73 | QPushButton* removeColumnButton = new QPushButton("Remove column"); |
|
74 | 74 | connect(removeColumnButton, SIGNAL(clicked()), this, SLOT(removeColumn())); |
|
75 | 75 | |
|
76 | 76 | QPushButton* specialPieButton = new QPushButton("Test pie"); |
|
77 | 77 | connect(specialPieButton, SIGNAL(clicked()), this, SLOT(testPie())); |
|
78 | 78 | |
|
79 | 79 | |
|
80 | 80 | QLabel *spinBoxLabel = new QLabel("Rows affected:"); |
|
81 | 81 | |
|
82 | 82 | // spin box for setting number of affected items (add, remove) |
|
83 | 83 | m_linesCountSpinBox = new QSpinBox; |
|
84 | 84 | m_linesCountSpinBox->setRange(1, 10); |
|
85 | 85 | m_linesCountSpinBox->setValue(1); |
|
86 | 86 | |
|
87 | 87 | // buttons layout |
|
88 | 88 | QVBoxLayout* buttonsLayout = new QVBoxLayout; |
|
89 | 89 | buttonsLayout->addWidget(spinBoxLabel); |
|
90 | 90 | buttonsLayout->addWidget(m_linesCountSpinBox); |
|
91 | 91 | buttonsLayout->addWidget(addRowAboveButton); |
|
92 | 92 | buttonsLayout->addWidget(addRowBelowButton); |
|
93 | 93 | buttonsLayout->addWidget(removeRowButton); |
|
94 | 94 | buttonsLayout->addWidget(addColumnRightButton); |
|
95 | 95 | buttonsLayout->addWidget(removeColumnButton); |
|
96 | 96 | // buttonsLayout->addWidget(specialPieButton); |
|
97 | 97 | buttonsLayout->addStretch(); |
|
98 | 98 | |
|
99 | 99 | // chart type radio buttons |
|
100 | 100 | m_lineRadioButton = new QRadioButton("Line"); |
|
101 | 101 | m_splineRadioButton = new QRadioButton("Spline"); |
|
102 | 102 | m_scatterRadioButton = new QRadioButton("Scatter"); |
|
103 | 103 | m_pieRadioButton = new QRadioButton("Pie"); |
|
104 | 104 | m_areaRadioButton = new QRadioButton("Area"); |
|
105 | 105 | m_barRadioButton = new QRadioButton("Bar"); |
|
106 | 106 | |
|
107 | 107 | connect(m_lineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); |
|
108 | 108 | connect(m_splineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); |
|
109 | 109 | connect(m_scatterRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); |
|
110 | 110 | connect(m_pieRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); |
|
111 | 111 | connect(m_areaRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); |
|
112 | 112 | connect(m_barRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); |
|
113 | 113 | m_lineRadioButton->setChecked(true); |
|
114 | 114 | |
|
115 | 115 | // radio buttons layout |
|
116 | 116 | QVBoxLayout* radioLayout = new QVBoxLayout; |
|
117 | 117 | radioLayout->addWidget(m_lineRadioButton); |
|
118 | radioLayout->addWidget(m_splineRadioButton); | |
|
119 | radioLayout->addWidget(m_scatterRadioButton); | |
|
118 | // radioLayout->addWidget(m_splineRadioButton); | |
|
119 | // radioLayout->addWidget(m_scatterRadioButton); | |
|
120 | 120 | radioLayout->addWidget(m_pieRadioButton); |
|
121 | radioLayout->addWidget(m_areaRadioButton); | |
|
121 | // radioLayout->addWidget(m_areaRadioButton); | |
|
122 | 122 | radioLayout->addWidget(m_barRadioButton); |
|
123 | 123 | radioLayout->addStretch(); |
|
124 | 124 | |
|
125 | 125 | // create main layout |
|
126 | 126 | QGridLayout* mainLayout = new QGridLayout; |
|
127 | 127 | mainLayout->addLayout(buttonsLayout, 1, 1); |
|
128 | 128 | mainLayout->addLayout(radioLayout, 2, 1); |
|
129 | 129 | mainLayout->addWidget(m_tableView, 1, 0); |
|
130 | 130 | mainLayout->addWidget(m_chartView, 2, 0); |
|
131 | 131 | setLayout(mainLayout); |
|
132 | 132 | m_lineRadioButton->setFocus(); |
|
133 | 133 | } |
|
134 | 134 | |
|
135 | 135 | void TableWidget::addRowAbove() |
|
136 | 136 | { |
|
137 | 137 | m_model->insertRows(m_tableView->currentIndex().row(), m_linesCountSpinBox->value()); |
|
138 | 138 | |
|
139 | 139 | } |
|
140 | 140 | |
|
141 | 141 | void TableWidget::addRowBelow() |
|
142 | 142 | { |
|
143 | 143 | m_model->insertRows(m_tableView->currentIndex().row() + 1, m_linesCountSpinBox->value()); |
|
144 | 144 | |
|
145 | 145 | } |
|
146 | 146 | |
|
147 | 147 | void TableWidget::removeRow() |
|
148 | 148 | { |
|
149 | 149 | m_model->removeRows(m_tableView->currentIndex().row(), qMin(m_model->rowCount() - m_tableView->currentIndex().row(), m_linesCountSpinBox->value())); |
|
150 | 150 | } |
|
151 | 151 | |
|
152 | 152 | void TableWidget::addColumnRight() |
|
153 | 153 | { |
|
154 | 154 | m_model->insertColumns(m_tableView->currentIndex().column() + 1, m_linesCountSpinBox->value()); |
|
155 | 155 | } |
|
156 | 156 | |
|
157 | 157 | void TableWidget::removeColumn() |
|
158 | 158 | { |
|
159 | 159 | m_model->removeColumns(m_tableView->currentIndex().column(), qMin(m_model->columnCount() - m_tableView->currentIndex().column(), m_linesCountSpinBox->value())); |
|
160 | 160 | } |
|
161 | 161 | |
|
162 | 162 | void TableWidget::updateChartType(bool toggle) |
|
163 | 163 | { |
|
164 | 164 | // this if is needed, so that the function is only called once. |
|
165 | 165 | // For the radioButton that was enabled. |
|
166 | 166 | if (toggle) { |
|
167 | 167 | // specialPie = 0; |
|
168 | 168 | m_chart->removeAllSeries(); |
|
169 | 169 | m_chart->axisX()->setNiceNumbersEnabled(false); |
|
170 | 170 | m_chart->axisY()->setNiceNumbersEnabled(false); |
|
171 | 171 | |
|
172 | 172 | // renable axes of the chart (pie hides them) |
|
173 | 173 | // x axis |
|
174 | 174 | QAxis *axis = m_chart->axisX(); |
|
175 | 175 | axis->setAxisVisible(true); |
|
176 | 176 | axis->setGridLineVisible(true); |
|
177 | 177 | axis->setLabelsVisible(true); |
|
178 | 178 | |
|
179 | 179 | // y axis |
|
180 | 180 | axis = m_chart->axisY(); |
|
181 | 181 | axis->setAxisVisible(true); |
|
182 | 182 | axis->setGridLineVisible(true); |
|
183 | 183 | axis->setLabelsVisible(true); |
|
184 | 184 | |
|
185 | 185 | m_model->clearMapping(); |
|
186 | 186 | |
|
187 | 187 | QString seriesColorHex = "#000000"; |
|
188 | 188 | QPen pen; |
|
189 | 189 | pen.setWidth(2); |
|
190 | 190 | |
|
191 | 191 | if (m_lineRadioButton->isChecked()) |
|
192 | 192 | { |
|
193 | m_chart->setAnimationOptions(QChart::NoAnimation); | |
|
194 | ||
|
193 | 195 | // series 1 |
|
194 | 196 | m_series = new QLineSeries; |
|
195 | 197 | m_series->setModel(m_model); |
|
196 | 198 | m_series->setModelMapping(0,1, Qt::Vertical); |
|
197 | 199 | m_series->setModelMappingRange(3, 4); |
|
198 | 200 | m_chart->addSeries(m_series); |
|
199 | 201 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); |
|
200 | 202 | m_model->addMapping(seriesColorHex, QRect(0, 3, 2, 4)); |
|
201 | 203 | |
|
202 | 204 | // series 2 |
|
203 | 205 | m_series = new QLineSeries; |
|
204 | 206 | m_series->setModel(m_model); |
|
205 | 207 | m_series->setModelMapping(2,3, Qt::Vertical); |
|
206 | 208 | m_chart->addSeries(m_series); |
|
207 | 209 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); |
|
208 | 210 | m_model->addMapping(seriesColorHex, QRect(2, 0, 2, 1000)); |
|
209 | 211 | |
|
210 | 212 | // series 3 |
|
211 | 213 | m_series = new QLineSeries; |
|
212 | 214 | m_series->setModel(m_model); |
|
213 | 215 | m_series->setModelMapping(4,5, Qt::Vertical); |
|
214 | 216 | m_series->setModelMappingRange(2, -1); |
|
215 | 217 | m_chart->addSeries(m_series); |
|
216 | 218 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); |
|
217 | 219 | m_model->addMapping(seriesColorHex, QRect(4, 2, 2, 1000)); |
|
218 | 220 | } |
|
219 | 221 | else if (m_splineRadioButton->isChecked()) |
|
220 | 222 | { |
|
223 | m_chart->setAnimationOptions(QChart::NoAnimation); | |
|
224 | ||
|
221 | 225 | // series 1 |
|
222 | 226 | m_series = new QSplineSeries; |
|
223 | 227 | m_series->setModel(m_model); |
|
224 | 228 | m_series->setModelMapping(0,1, Qt::Vertical); |
|
225 | 229 | // m_series->setModelMappingRange(1, 4); |
|
226 | 230 | // series->setModelMapping(0,1, Qt::Horizontal); |
|
227 | 231 | m_chart->addSeries(m_series); |
|
228 | 232 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); |
|
229 | 233 | m_model->addMapping(seriesColorHex, QRect(0, 0, 2, 1000)); |
|
230 | 234 | |
|
231 | 235 | // series 2 |
|
232 | 236 | m_series = new QSplineSeries; |
|
233 | 237 | m_series->setModel(m_model); |
|
234 | 238 | m_series->setModelMapping(2,3, Qt::Vertical); |
|
235 | 239 | m_series->setModelMappingRange(2, 4); |
|
236 | 240 | // series->setModelMapping(2,3, Qt::Horizontal); |
|
237 | 241 | m_chart->addSeries(m_series); |
|
238 | 242 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); |
|
239 | 243 | m_model->addMapping(seriesColorHex, QRect(2, 2, 2, 4)); |
|
240 | 244 | |
|
241 | 245 | // series 3 |
|
242 | 246 | m_series = new QSplineSeries; |
|
243 | 247 | m_series->setModel(m_model); |
|
244 | 248 | m_series->setModelMapping(4,5, Qt::Vertical); |
|
245 | 249 | m_series->setModelMappingRange(2, -1); |
|
246 | 250 | // series->setModelMapping(4,5, Qt::Horizontal); |
|
247 | 251 | m_chart->addSeries(m_series); |
|
248 | 252 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); |
|
249 | 253 | m_model->addMapping(seriesColorHex, QRect(4, 2, 2, 1000)); |
|
250 | 254 | } |
|
251 | 255 | else if (m_scatterRadioButton->isChecked()) |
|
252 | 256 | { |
|
257 | m_chart->setAnimationOptions(QChart::NoAnimation); | |
|
258 | ||
|
253 | 259 | // series 1 |
|
254 | 260 | m_series = new QScatterSeries; |
|
255 | 261 | m_series->setModel(m_model); |
|
256 | 262 | m_series->setModelMapping(0,1, Qt::Vertical); |
|
257 | 263 | // m_series->setModelMappingRange(2, 0); |
|
258 | 264 | // series->setModelMapping(0,1, Qt::Horizontal); |
|
259 | 265 | m_chart->addSeries(m_series); |
|
260 | 266 | |
|
261 | 267 | seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper(); |
|
262 | 268 | m_model->addMapping(seriesColorHex, QRect(0, 2, 2, 1000)); |
|
263 | 269 | |
|
264 | 270 | // series 2 |
|
265 | 271 | m_series = new QScatterSeries; |
|
266 | 272 | m_series->setModel(m_model); |
|
267 | 273 | m_series->setModelMapping(2,3, Qt::Vertical); |
|
268 | 274 | // m_series->setModelMappingRange(1, 6); |
|
269 | 275 | // series->setModelMapping(2,3, Qt::Horizontal); |
|
270 | 276 | m_chart->addSeries(m_series); |
|
271 | 277 | |
|
272 | 278 | seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper(); |
|
273 | 279 | m_model->addMapping(seriesColorHex, QRect(2, 1, 2, 6)); |
|
274 | 280 | |
|
275 | 281 | // series 3 |
|
276 | 282 | m_series = new QScatterSeries; |
|
277 | 283 | m_series->setModel(m_model); |
|
278 | 284 | m_series->setModelMapping(4,5, Qt::Vertical); |
|
279 | 285 | // series->setModelMapping(4,5, Qt::Horizontal); |
|
280 | 286 | m_chart->addSeries(m_series); |
|
281 | 287 | seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper(); |
|
282 | 288 | m_model->addMapping(seriesColorHex, QRect(4, 0, 2, 1000)); |
|
283 | 289 | } |
|
284 | 290 | else if (m_pieRadioButton->isChecked()) |
|
285 | 291 | { |
|
292 | m_chart->setAnimationOptions(QChart::SeriesAnimations); | |
|
293 | ||
|
286 | 294 | // pie 1 |
|
287 | 295 | QPieSeries* pieSeries = new QPieSeries; |
|
288 | 296 | pieSeries->setModel(m_model); |
|
289 | 297 | pieSeries->setModelMappingRange(3, 3); |
|
290 | 298 | pieSeries->setModelMapping(0,0, Qt::Vertical); |
|
291 | 299 | pieSeries->setLabelsVisible(true); |
|
292 | 300 | pieSeries->setPieSize(0.35); |
|
293 | 301 | pieSeries->setHorizontalPosition(0.2); |
|
294 | 302 | pieSeries->setVerticalPosition(0.3); |
|
295 | 303 | |
|
296 | 304 | m_chart->addSeries(pieSeries); |
|
297 | 305 | seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper(); |
|
298 | 306 | m_model->addMapping(seriesColorHex, QRect(0, 3, 1, 3)); |
|
299 | 307 | |
|
300 | 308 | // pie 2 |
|
301 | 309 | pieSeries = new QPieSeries; |
|
302 | 310 | pieSeries->setModel(m_model); |
|
303 | 311 | pieSeries->setModelMappingRange(2, -1); |
|
304 | 312 | pieSeries->setModelMapping(1,1, Qt::Vertical); |
|
305 | 313 | pieSeries->setLabelsVisible(true); |
|
306 | 314 | pieSeries->setPieSize(0.35); |
|
307 | 315 | pieSeries->setHorizontalPosition(0.8); |
|
308 | 316 | pieSeries->setVerticalPosition(0.3); |
|
309 | 317 | m_chart->addSeries(pieSeries); |
|
310 | 318 | seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper(); |
|
311 | 319 | m_model->addMapping(seriesColorHex, QRect(1, 2, 1, 1000)); |
|
312 | 320 | |
|
313 | 321 | // pie 3 |
|
314 | 322 | pieSeries = new QPieSeries; |
|
315 | 323 | pieSeries->setModel(m_model); |
|
316 | 324 | pieSeries->setModelMapping(2,2, Qt::Vertical); |
|
317 | 325 | pieSeries->setLabelsVisible(true); |
|
318 | 326 | pieSeries->setPieSize(0.35); |
|
319 | 327 | pieSeries->setHorizontalPosition(0.5); |
|
320 | 328 | pieSeries->setVerticalPosition(0.75); |
|
321 | 329 | m_chart->addSeries(pieSeries); |
|
322 | 330 | seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper(); |
|
323 | 331 | m_model->addMapping(seriesColorHex, QRect(2, 0, 1, 1000)); |
|
324 | 332 | |
|
325 | 333 | // // special pie |
|
326 | 334 | // specialPie = new QPieSeries; |
|
327 | 335 | // specialPie->append(17, "1"); |
|
328 | 336 | // specialPie->append(45, "2"); |
|
329 | 337 | // specialPie->append(77, "3"); |
|
330 | 338 | // specialPie->append(37, "4"); |
|
331 | 339 | // specialPie->append(27, "5"); |
|
332 | 340 | // specialPie->append(47, "6"); |
|
333 | 341 | // specialPie->setPieSize(0.35); |
|
334 | 342 | // specialPie->setHorizontalPosition(0.8); |
|
335 | 343 | // specialPie->setVerticalPosition(0.75); |
|
336 | 344 | // specialPie->setLabelsVisible(true); |
|
337 | 345 | // m_chart->addSeries(specialPie); |
|
338 | 346 | } |
|
339 | 347 | else if (m_areaRadioButton->isChecked()) |
|
340 | 348 | { |
|
349 | m_chart->setAnimationOptions(QChart::NoAnimation); | |
|
350 | ||
|
341 | 351 | QLineSeries* upperLineSeries = new QLineSeries; |
|
342 | 352 | upperLineSeries->setModel(m_model); |
|
343 | 353 | upperLineSeries->setModelMapping(0, 1, Qt::Vertical); |
|
344 | 354 | // upperLineSeries->setModelMappingRange(1, 5); |
|
345 | 355 | QLineSeries* lowerLineSeries = new QLineSeries; |
|
346 | 356 | lowerLineSeries->setModel(m_model); |
|
347 | 357 | lowerLineSeries->setModelMapping(2, 3, Qt::Vertical); |
|
348 | 358 | QAreaSeries* areaSeries = new QAreaSeries(upperLineSeries, lowerLineSeries); |
|
349 | 359 | m_chart->addSeries(areaSeries); |
|
350 | 360 | seriesColorHex = "#" + QString::number(areaSeries->brush().color().rgb(), 16).right(6).toUpper(); |
|
351 | 361 | m_model->addMapping(seriesColorHex, QRect(0, 1, 2, 5)); |
|
352 | 362 | m_model->addMapping(seriesColorHex, QRect(2, 0, 2, 1000)); |
|
353 | 363 | } |
|
354 | 364 | else if (m_barRadioButton->isChecked()) |
|
355 | 365 | { |
|
366 | m_chart->setAnimationOptions(QChart::SeriesAnimations); | |
|
367 | ||
|
356 | 368 | QBarSeries* barSeries = new QBarSeries(QStringList()); |
|
357 | 369 | barSeries->setModel(m_model); |
|
358 | 370 | // barSeries->setModelMappingRange(2, 5); |
|
359 | 371 | barSeries->setModelMapping(5, 2, 4, Qt::Vertical); |
|
360 | 372 | m_chart->addSeries(barSeries); |
|
361 | 373 | QList<QBarSet*> barsets = barSeries->barSets(); |
|
362 | 374 | for (int i = 0; i < barsets.count(); i++) { |
|
363 | 375 | seriesColorHex = "#" + QString::number(barsets.at(i)->brush().color().rgb(), 16).right(6).toUpper(); |
|
364 | 376 | m_model->addMapping(seriesColorHex, QRect(2 + i, 0, 1, 1000)); |
|
365 | 377 | } |
|
366 | 378 | } |
|
367 | 379 | |
|
368 | 380 | |
|
369 | 381 | if (!m_barRadioButton->isChecked()) { |
|
370 | 382 | m_chart->axisX()->setRange(0, 500); |
|
371 | 383 | m_chart->axisY()->setRange(0, 220); |
|
372 | 384 | } |
|
373 | 385 | m_chart->legend()->setVisible(true); |
|
374 | 386 | |
|
375 | 387 | // repaint table view colors |
|
376 | 388 | m_tableView->repaint(); |
|
377 | 389 | m_tableView->setFocus(); |
|
378 | 390 | } |
|
379 | 391 | } |
|
380 | 392 | |
|
381 | 393 | void TableWidget::testPie() |
|
382 | 394 | { |
|
383 | 395 | m_tableView->setColumnWidth(10, 250); |
|
384 | 396 | // if (specialPie) { |
|
385 | 397 | // specialPie->remove(specialPie->slices().at(2)); |
|
386 | 398 | // // specialPie->insert(4, new QPieSlice(45, "Hello"));//specialPie->slices.at(2)); |
|
387 | 399 | // specialPie->append(4, "heloo"); |
|
388 | 400 | // } |
|
389 | 401 | } |
|
390 | 402 | |
|
391 | 403 | TableWidget::~TableWidget() |
|
392 | 404 | { |
|
393 | 405 | |
|
394 | 406 | } |
General Comments 0
You need to be logged in to leave comments.
Login now