##// END OF EJS Templates
XYModelMapper slots for series signals implemented
Marek Rosa -
r1262:61ed30bfe89b
parent child
Show More
@@ -1,383 +1,414
1 #include "qxymodelmapper.h"
1 #include "qxymodelmapper.h"
2 #include "qxymodelmapper_p.h"
2 #include "qxymodelmapper_p.h"
3 #include "qxyseries.h"
3 #include "qxyseries.h"
4 #include <QAbstractItemModel>
4 #include <QAbstractItemModel>
5
5
6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7
7
8 QXYModelMapper::QXYModelMapper(QObject *parent):
8 QXYModelMapper::QXYModelMapper(QObject *parent):
9 QObject(parent),
9 QObject(parent),
10 d_ptr(new QXYModelMapperPrivate(this))
10 d_ptr(new QXYModelMapperPrivate(this))
11 {
11 {
12 }
12 }
13
13
14 QAbstractItemModel* QXYModelMapper::model() const
14 QAbstractItemModel* QXYModelMapper::model() const
15 {
15 {
16 Q_D(const QXYModelMapper);
16 Q_D(const QXYModelMapper);
17 return d->m_model;
17 return d->m_model;
18 }
18 }
19
19
20 void QXYModelMapper::setModel(QAbstractItemModel *model)
20 void QXYModelMapper::setModel(QAbstractItemModel *model)
21 {
21 {
22 if (model == 0)
22 if (model == 0)
23 return;
23 return;
24
24
25 Q_D(QXYModelMapper);
25 Q_D(QXYModelMapper);
26 if (d->m_model) {
26 if (d->m_model) {
27 disconnect(d->m_model, 0, d, 0);
27 disconnect(d->m_model, 0, d, 0);
28 }
28 }
29
29
30 d->m_model = model;
30 d->m_model = model;
31 d->initializeXYFromModel();
31 d->initializeXYFromModel();
32 // connect signals from the model
32 // connect signals from the model
33 connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex)));
33 connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex)));
34 connect(d->m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelRowsAdded(QModelIndex,int,int)));
34 connect(d->m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelRowsAdded(QModelIndex,int,int)));
35 connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int)));
35 connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int)));
36 connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int)));
36 connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int)));
37 connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int)));
37 connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int)));
38 }
38 }
39
39
40 QXYSeries* QXYModelMapper::series() const
40 QXYSeries* QXYModelMapper::series() const
41 {
41 {
42 Q_D(const QXYModelMapper);
42 Q_D(const QXYModelMapper);
43 return d->m_series;
43 return d->m_series;
44 }
44 }
45
45
46 void QXYModelMapper::setSeries(QXYSeries *series)
46 void QXYModelMapper::setSeries(QXYSeries *series)
47 {
47 {
48 Q_D(QXYModelMapper);
48 Q_D(QXYModelMapper);
49 if (d->m_series) {
49 if (d->m_series) {
50 disconnect(d->m_series, 0, d, 0);
50 disconnect(d->m_series, 0, d, 0);
51 }
51 }
52
52
53 if (series == 0)
53 if (series == 0)
54 return;
54 return;
55
55
56 d->m_series = series;
56 d->m_series = series;
57 d->initializeXYFromModel();
57 d->initializeXYFromModel();
58 // connect the signals from the series
58 // connect the signals from the series
59 connect(d->m_series, SIGNAL(pointAdded(int)), d, SLOT(handlePointAdded(int)));
59 connect(d->m_series, SIGNAL(pointAdded(int)), d, SLOT(handlePointAdded(int)));
60 connect(d->m_series, SIGNAL(pointRemoved(int)), d, SLOT(handlePointRemoved(int)));
60 connect(d->m_series, SIGNAL(pointRemoved(int)), d, SLOT(handlePointRemoved(int)));
61 connect(d->m_series, SIGNAL(pointReplaced(int)), d, SLOT(pointReplaced(int)));
61 connect(d->m_series, SIGNAL(pointReplaced(int)), d, SLOT(handlePointReplaced(int)));
62 }
62 }
63
63
64 int QXYModelMapper::first() const
64 int QXYModelMapper::first() const
65 {
65 {
66 Q_D(const QXYModelMapper);
66 Q_D(const QXYModelMapper);
67 return d->m_first;
67 return d->m_first;
68 }
68 }
69
69
70 void QXYModelMapper::setFirst(int first)
70 void QXYModelMapper::setFirst(int first)
71 {
71 {
72 Q_D(QXYModelMapper);
72 Q_D(QXYModelMapper);
73 d->m_first = qMax(first, 0);
73 d->m_first = qMax(first, 0);
74 d->initializeXYFromModel();
74 d->initializeXYFromModel();
75 }
75 }
76
76
77 int QXYModelMapper::count() const
77 int QXYModelMapper::count() const
78 {
78 {
79 Q_D(const QXYModelMapper);
79 Q_D(const QXYModelMapper);
80 return d->m_count;
80 return d->m_count;
81 }
81 }
82
82
83 void QXYModelMapper::setCount(int count)
83 void QXYModelMapper::setCount(int count)
84 {
84 {
85 Q_D(QXYModelMapper);
85 Q_D(QXYModelMapper);
86 d->m_count = qMax(count, -1);
86 d->m_count = qMax(count, -1);
87 d->initializeXYFromModel();
87 d->initializeXYFromModel();
88 }
88 }
89
89
90 Qt::Orientation QXYModelMapper::orientation() const
90 Qt::Orientation QXYModelMapper::orientation() const
91 {
91 {
92 Q_D(const QXYModelMapper);
92 Q_D(const QXYModelMapper);
93 return d->m_orientation;
93 return d->m_orientation;
94 }
94 }
95
95
96 void QXYModelMapper::setOrientation(Qt::Orientation orientation)
96 void QXYModelMapper::setOrientation(Qt::Orientation orientation)
97 {
97 {
98 Q_D(QXYModelMapper);
98 Q_D(QXYModelMapper);
99 d->m_orientation = orientation;
99 d->m_orientation = orientation;
100 d->initializeXYFromModel();
100 d->initializeXYFromModel();
101 }
101 }
102
102
103 int QXYModelMapper::xSection() const
103 int QXYModelMapper::xSection() const
104 {
104 {
105 Q_D(const QXYModelMapper);
105 Q_D(const QXYModelMapper);
106 return d->m_xSection;
106 return d->m_xSection;
107 }
107 }
108
108
109 void QXYModelMapper::setXSection(int xSection)
109 void QXYModelMapper::setXSection(int xSection)
110 {
110 {
111 Q_D(QXYModelMapper);
111 Q_D(QXYModelMapper);
112 d->m_xSection = xSection;
112 d->m_xSection = xSection;
113 d->initializeXYFromModel();
113 d->initializeXYFromModel();
114 }
114 }
115
115
116 int QXYModelMapper::ySection() const
116 int QXYModelMapper::ySection() const
117 {
117 {
118 Q_D(const QXYModelMapper);
118 Q_D(const QXYModelMapper);
119 return d->m_ySection;
119 return d->m_ySection;
120 }
120 }
121
121
122 void QXYModelMapper::setYSection(int ySection)
122 void QXYModelMapper::setYSection(int ySection)
123 {
123 {
124 Q_D(QXYModelMapper);
124 Q_D(QXYModelMapper);
125 d->m_ySection = ySection;
125 d->m_ySection = ySection;
126 d->initializeXYFromModel();
126 d->initializeXYFromModel();
127 }
127 }
128
128
129 void QXYModelMapper::reset()
129 void QXYModelMapper::reset()
130 {
130 {
131 Q_D(QXYModelMapper);
131 Q_D(QXYModelMapper);
132 d->m_first = 0;
132 d->m_first = 0;
133 d->m_count = -1;
133 d->m_count = -1;
134 d->m_orientation = Qt::Vertical;
134 d->m_orientation = Qt::Vertical;
135 d->m_xSection = -1;
135 d->m_xSection = -1;
136 d->m_ySection = -1;
136 d->m_ySection = -1;
137 d->initializeXYFromModel();
137 d->initializeXYFromModel();
138 }
138 }
139
139
140 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
140 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
141
141
142 QXYModelMapperPrivate::QXYModelMapperPrivate(QXYModelMapper *q) :
142 QXYModelMapperPrivate::QXYModelMapperPrivate(QXYModelMapper *q) :
143 m_series(0),
143 m_series(0),
144 m_model(0),
144 m_model(0),
145 m_first(0),
145 m_first(0),
146 m_count(-1),
146 m_count(-1),
147 m_orientation(Qt::Vertical),
147 m_orientation(Qt::Vertical),
148 m_xSection(-1),
148 m_xSection(-1),
149 m_ySection(-1),
149 m_ySection(-1),
150 m_seriesSignalsBlock(false),
150 m_seriesSignalsBlock(false),
151 m_modelSignalsBlock(false),
151 m_modelSignalsBlock(false),
152 q_ptr(q)
152 q_ptr(q)
153 {
153 {
154 }
154 }
155
155
156 void QXYModelMapperPrivate::blockModelSignals(bool block)
156 void QXYModelMapperPrivate::blockModelSignals(bool block)
157 {
157 {
158 m_modelSignalsBlock = block;
158 m_modelSignalsBlock = block;
159 }
159 }
160
160
161 void QXYModelMapperPrivate::blockSeriesSignals(bool block)
161 void QXYModelMapperPrivate::blockSeriesSignals(bool block)
162 {
162 {
163 m_seriesSignalsBlock = block;
163 m_seriesSignalsBlock = block;
164 }
164 }
165
165
166 QModelIndex QXYModelMapperPrivate::xModelIndex(int xPos)
166 QModelIndex QXYModelMapperPrivate::xModelIndex(int xPos)
167 {
167 {
168 if (m_count != -1 && xPos >= m_count)
168 if (m_count != -1 && xPos >= m_count)
169 return QModelIndex(); // invalid
169 return QModelIndex(); // invalid
170
170
171 if (m_orientation == Qt::Vertical)
171 if (m_orientation == Qt::Vertical)
172 return m_model->index(xPos + m_first, m_xSection);
172 return m_model->index(xPos + m_first, m_xSection);
173 else
173 else
174 return m_model->index(m_xSection, xPos + m_first);
174 return m_model->index(m_xSection, xPos + m_first);
175 }
175 }
176
176
177 QModelIndex QXYModelMapperPrivate::yModelIndex(int yPos)
177 QModelIndex QXYModelMapperPrivate::yModelIndex(int yPos)
178 {
178 {
179 if (m_count != -1 && yPos >= m_count)
179 if (m_count != -1 && yPos >= m_count)
180 return QModelIndex(); // invalid
180 return QModelIndex(); // invalid
181
181
182 if (m_orientation == Qt::Vertical)
182 if (m_orientation == Qt::Vertical)
183 return m_model->index(yPos + m_first, m_ySection);
183 return m_model->index(yPos + m_first, m_ySection);
184 else
184 else
185 return m_model->index(m_ySection, yPos + m_first);
185 return m_model->index(m_ySection, yPos + m_first);
186 }
186 }
187
187
188 void QXYModelMapperPrivate::handlePointAdded(int pointPos)
188 void QXYModelMapperPrivate::handlePointAdded(int pointPos)
189 {
189 {
190 Q_UNUSED(pointPos)
190 if (m_seriesSignalsBlock)
191 return;
192
193 if (m_count != -1)
194 m_count += 1;
195
196 blockModelSignals();
197 if (m_orientation == Qt::Vertical)
198 m_model->insertRows(pointPos + m_first, 1);
199 else
200 m_model->insertColumns(pointPos + m_first, 1);
201
202 m_model->setData(xModelIndex(pointPos), m_series->points().at(pointPos).x());
203 m_model->setData(yModelIndex(pointPos), m_series->points().at(pointPos).y());
204 blockModelSignals(false);
191 }
205 }
192
206
193 void QXYModelMapperPrivate::handlePointRemoved(int pointPos)
207 void QXYModelMapperPrivate::handlePointRemoved(int pointPos)
194 {
208 {
195 Q_UNUSED(pointPos)
209 if (m_seriesSignalsBlock)
210 return;
211
212 if (m_count != -1)
213 m_count -= 1;
214
215 blockModelSignals();
216 if (m_orientation == Qt::Vertical)
217 m_model->removeRow(pointPos + m_first);
218 else
219 m_model->removeColumn(pointPos + m_first);
220 blockModelSignals(false);
196 }
221 }
197
222
198 void QXYModelMapperPrivate::handlePointReplaced(int pointPos)
223 void QXYModelMapperPrivate::handlePointReplaced(int pointPos)
199 {
224 {
200 Q_UNUSED(pointPos)
225 if (m_seriesSignalsBlock)
226 return;
227
228 blockModelSignals();
229 m_model->setData(xModelIndex(pointPos), m_series->points().at(pointPos).x());
230 m_model->setData(yModelIndex(pointPos), m_series->points().at(pointPos).y());
231 blockModelSignals(false);
201 }
232 }
202
233
203 void QXYModelMapperPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight)
234 void QXYModelMapperPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight)
204 {
235 {
205 if (m_modelSignalsBlock)
236 if (m_modelSignalsBlock)
206 return;
237 return;
207
238
208 blockSeriesSignals();
239 blockSeriesSignals();
209 QModelIndex index;
240 QModelIndex index;
210 QPointF oldPoint;
241 QPointF oldPoint;
211 QPointF newPoint;
242 QPointF newPoint;
212 for (int row = topLeft.row(); row <= bottomRight.row(); row++) {
243 for (int row = topLeft.row(); row <= bottomRight.row(); row++) {
213 for (int column = topLeft.column(); column <= bottomRight.column(); column++) {
244 for (int column = topLeft.column(); column <= bottomRight.column(); column++) {
214 index = topLeft.sibling(row, column);
245 index = topLeft.sibling(row, column);
215 if (m_orientation == Qt::Vertical && (index.column() == m_xSection|| index.column() == m_ySection)) {
246 if (m_orientation == Qt::Vertical && (index.column() == m_xSection|| index.column() == m_ySection)) {
216 if (index.row() >= m_first && (m_count == - 1 || index.row() < m_first + m_count)) {
247 if (index.row() >= m_first && (m_count == - 1 || index.row() < m_first + m_count)) {
217 oldPoint = m_series->points().at(index.row() - m_first);
248 oldPoint = m_series->points().at(index.row() - m_first);
218 newPoint.setX(m_model->data(m_model->index(index.row(), m_xSection)).toReal());
249 newPoint.setX(m_model->data(m_model->index(index.row(), m_xSection)).toReal());
219 newPoint.setY(m_model->data(m_model->index(index.row(), m_ySection)).toReal());
250 newPoint.setY(m_model->data(m_model->index(index.row(), m_ySection)).toReal());
220 }
251 }
221 } else if (m_orientation == Qt::Horizontal && (index.row() == m_xSection || index.row() == m_ySection)) {
252 } else if (m_orientation == Qt::Horizontal && (index.row() == m_xSection || index.row() == m_ySection)) {
222 if (index.column() >= m_first && (m_count == - 1 || index.column() < m_first + m_count)) {
253 if (index.column() >= m_first && (m_count == - 1 || index.column() < m_first + m_count)) {
223 oldPoint = m_series->points().at(index.column() - m_first);
254 oldPoint = m_series->points().at(index.column() - m_first);
224 newPoint.setX(m_model->data(m_model->index(m_xSection, index.column())).toReal());
255 newPoint.setX(m_model->data(m_model->index(m_xSection, index.column())).toReal());
225 newPoint.setY(m_model->data(m_model->index(m_ySection, index.column())).toReal());
256 newPoint.setY(m_model->data(m_model->index(m_ySection, index.column())).toReal());
226 }
257 }
227 } else {
258 } else {
228 continue;
259 continue;
229 }
260 }
230 m_series->replace(oldPoint, newPoint);
261 m_series->replace(oldPoint, newPoint);
231 }
262 }
232 blockSeriesSignals(false);
263 blockSeriesSignals(false);
233 }
264 }
234 }
265 }
235
266
236 void QXYModelMapperPrivate::modelRowsAdded(QModelIndex parent, int start, int end)
267 void QXYModelMapperPrivate::modelRowsAdded(QModelIndex parent, int start, int end)
237 {
268 {
238 Q_UNUSED(parent);
269 Q_UNUSED(parent);
239 if (m_modelSignalsBlock)
270 if (m_modelSignalsBlock)
240 return;
271 return;
241
272
242 blockSeriesSignals();
273 blockSeriesSignals();
243 if (m_orientation == Qt::Vertical)
274 if (m_orientation == Qt::Vertical)
244 insertData(start, end);
275 insertData(start, end);
245 else if (start <= m_xSection || start <= m_ySection) // if the changes affect the map - reinitialize the xy
276 else if (start <= m_xSection || start <= m_ySection) // if the changes affect the map - reinitialize the xy
246 initializeXYFromModel();
277 initializeXYFromModel();
247 blockSeriesSignals(false);
278 blockSeriesSignals(false);
248 }
279 }
249
280
250 void QXYModelMapperPrivate::modelRowsRemoved(QModelIndex parent, int start, int end)
281 void QXYModelMapperPrivate::modelRowsRemoved(QModelIndex parent, int start, int end)
251 {
282 {
252 Q_UNUSED(parent);
283 Q_UNUSED(parent);
253 if (m_modelSignalsBlock)
284 if (m_modelSignalsBlock)
254 return;
285 return;
255
286
256 blockSeriesSignals();
287 blockSeriesSignals();
257 if (m_orientation == Qt::Vertical)
288 if (m_orientation == Qt::Vertical)
258 removeData(start, end);
289 removeData(start, end);
259 else if (start <= m_xSection || start <= m_ySection) // if the changes affect the map - reinitialize the xy
290 else if (start <= m_xSection || start <= m_ySection) // if the changes affect the map - reinitialize the xy
260 initializeXYFromModel();
291 initializeXYFromModel();
261 blockSeriesSignals(false);
292 blockSeriesSignals(false);
262 }
293 }
263
294
264 void QXYModelMapperPrivate::modelColumnsAdded(QModelIndex parent, int start, int end)
295 void QXYModelMapperPrivate::modelColumnsAdded(QModelIndex parent, int start, int end)
265 {
296 {
266 Q_UNUSED(parent);
297 Q_UNUSED(parent);
267 if (m_modelSignalsBlock)
298 if (m_modelSignalsBlock)
268 return;
299 return;
269
300
270 blockSeriesSignals();
301 blockSeriesSignals();
271 if (m_orientation == Qt::Horizontal)
302 if (m_orientation == Qt::Horizontal)
272 insertData(start, end);
303 insertData(start, end);
273 else if (start <= m_xSection || start <= m_ySection) // if the changes affect the map - reinitialize the xy
304 else if (start <= m_xSection || start <= m_ySection) // if the changes affect the map - reinitialize the xy
274 initializeXYFromModel();
305 initializeXYFromModel();
275 blockSeriesSignals(false);
306 blockSeriesSignals(false);
276 }
307 }
277
308
278 void QXYModelMapperPrivate::modelColumnsRemoved(QModelIndex parent, int start, int end)
309 void QXYModelMapperPrivate::modelColumnsRemoved(QModelIndex parent, int start, int end)
279 {
310 {
280 Q_UNUSED(parent);
311 Q_UNUSED(parent);
281 if (m_modelSignalsBlock)
312 if (m_modelSignalsBlock)
282 return;
313 return;
283
314
284 blockSeriesSignals();
315 blockSeriesSignals();
285 if (m_orientation == Qt::Horizontal)
316 if (m_orientation == Qt::Horizontal)
286 removeData(start, end);
317 removeData(start, end);
287 else if (start <= m_xSection || start <= m_ySection) // if the changes affect the map - reinitialize the xy
318 else if (start <= m_xSection || start <= m_ySection) // if the changes affect the map - reinitialize the xy
288 initializeXYFromModel();
319 initializeXYFromModel();
289 blockSeriesSignals(false);
320 blockSeriesSignals(false);
290 }
321 }
291
322
292 void QXYModelMapperPrivate::insertData(int start, int end)
323 void QXYModelMapperPrivate::insertData(int start, int end)
293 {
324 {
294 if (m_model == 0 || m_series == 0)
325 if (m_model == 0 || m_series == 0)
295 return;
326 return;
296
327
297 if (m_count != -1 && start >= m_first + m_count) {
328 if (m_count != -1 && start >= m_first + m_count) {
298 return;
329 return;
299 } else {
330 } else {
300 int addedCount = end - start + 1;
331 int addedCount = end - start + 1;
301 if (m_count != -1 && addedCount > m_count)
332 if (m_count != -1 && addedCount > m_count)
302 addedCount = m_count;
333 addedCount = m_count;
303 int first = qMax(start, m_first);
334 int first = qMax(start, m_first);
304 int last = qMin(first + addedCount - 1, m_orientation == Qt::Vertical ? m_model->rowCount() - 1 : m_model->columnCount() - 1);
335 int last = qMin(first + addedCount - 1, m_orientation == Qt::Vertical ? m_model->rowCount() - 1 : m_model->columnCount() - 1);
305 for (int i = first; i <= last; i++) {
336 for (int i = first; i <= last; i++) {
306 QPointF point;
337 QPointF point;
307 point.setX(m_model->data(xModelIndex(i - m_first), Qt::DisplayRole).toDouble());
338 point.setX(m_model->data(xModelIndex(i - m_first), Qt::DisplayRole).toDouble());
308 point.setY(m_model->data(yModelIndex(i - m_first), Qt::DisplayRole).toDouble());
339 point.setY(m_model->data(yModelIndex(i - m_first), Qt::DisplayRole).toDouble());
309 m_series->insert(i - m_first, point);
340 m_series->insert(i - m_first, point);
310 }
341 }
311
342
312 // remove excess of slices (abouve m_count)
343 // remove excess of slices (abouve m_count)
313 if (m_count != -1 && m_series->points().size() > m_count)
344 if (m_count != -1 && m_series->points().size() > m_count)
314 for (int i = m_series->points().size() - 1; i >= m_count; i--) {
345 for (int i = m_series->points().size() - 1; i >= m_count; i--) {
315 m_series->remove(m_series->points().at(i));
346 m_series->remove(m_series->points().at(i));
316 }
347 }
317 }
348 }
318 }
349 }
319
350
320 void QXYModelMapperPrivate::removeData(int start, int end)
351 void QXYModelMapperPrivate::removeData(int start, int end)
321 {
352 {
322 if (m_model == 0 || m_series == 0)
353 if (m_model == 0 || m_series == 0)
323 return;
354 return;
324
355
325 int removedCount = end - start + 1;
356 int removedCount = end - start + 1;
326 if (m_count != -1 && start >= m_first + m_count) {
357 if (m_count != -1 && start >= m_first + m_count) {
327 return;
358 return;
328 } else {
359 } else {
329 int toRemove = qMin(m_series->points().size(), removedCount); // first find how many items can actually be removed
360 int toRemove = qMin(m_series->points().size(), removedCount); // first find how many items can actually be removed
330 int first = qMax(start, m_first); // get the index of the first item that will be removed.
361 int first = qMax(start, m_first); // get the index of the first item that will be removed.
331 int last = qMin(first + toRemove - 1, m_series->points().size() + m_first - 1); // get the index of the last item that will be removed.
362 int last = qMin(first + toRemove - 1, m_series->points().size() + m_first - 1); // get the index of the last item that will be removed.
332 for (int i = last; i >= first; i--) {
363 for (int i = last; i >= first; i--) {
333 m_series->remove(m_series->points().at(i - m_first));
364 m_series->remove(m_series->points().at(i - m_first));
334 }
365 }
335
366
336 if (m_count != -1) {
367 if (m_count != -1) {
337 int itemsAvailable; // check how many are available to be added
368 int itemsAvailable; // check how many are available to be added
338 if (m_orientation == Qt::Vertical)
369 if (m_orientation == Qt::Vertical)
339 itemsAvailable = m_model->rowCount() - m_first - m_series->points().size();
370 itemsAvailable = m_model->rowCount() - m_first - m_series->points().size();
340 else
371 else
341 itemsAvailable = m_model->columnCount() - m_first - m_series->points().size();
372 itemsAvailable = m_model->columnCount() - m_first - m_series->points().size();
342 int toBeAdded = qMin(itemsAvailable, m_count - m_series->points().size()); // add not more items than there is space left to be filled.
373 int toBeAdded = qMin(itemsAvailable, m_count - m_series->points().size()); // add not more items than there is space left to be filled.
343 int currentSize = m_series->points().size();
374 int currentSize = m_series->points().size();
344 if (toBeAdded > 0)
375 if (toBeAdded > 0)
345 for (int i = m_series->points().size(); i < currentSize + toBeAdded; i++) {
376 for (int i = m_series->points().size(); i < currentSize + toBeAdded; i++) {
346 QPointF point;
377 QPointF point;
347 point.setX(m_model->data(xModelIndex(i), Qt::DisplayRole).toDouble());
378 point.setX(m_model->data(xModelIndex(i), Qt::DisplayRole).toDouble());
348 point.setY(m_model->data(yModelIndex(i), Qt::DisplayRole).toDouble());
379 point.setY(m_model->data(yModelIndex(i), Qt::DisplayRole).toDouble());
349 m_series->insert(i, point);
380 m_series->insert(i, point);
350 }
381 }
351 }
382 }
352 }
383 }
353 }
384 }
354
385
355 void QXYModelMapperPrivate::initializeXYFromModel()
386 void QXYModelMapperPrivate::initializeXYFromModel()
356 {
387 {
357 if (m_model == 0 || m_series == 0)
388 if (m_model == 0 || m_series == 0)
358 return;
389 return;
359
390
360 blockSeriesSignals();
391 blockSeriesSignals();
361 // clear current content
392 // clear current content
362 m_series->clear();
393 m_series->clear();
363
394
364 // create the initial slices set
395 // create the initial slices set
365 int pointPos = 0;
396 int pointPos = 0;
366 QModelIndex xIndex = xModelIndex(pointPos);
397 QModelIndex xIndex = xModelIndex(pointPos);
367 QModelIndex yIndex = yModelIndex(pointPos);
398 QModelIndex yIndex = yModelIndex(pointPos);
368 while (xIndex.isValid() && yIndex.isValid()) {
399 while (xIndex.isValid() && yIndex.isValid()) {
369 QPointF point;
400 QPointF point;
370 point.setX(m_model->data(xIndex, Qt::DisplayRole).toDouble());
401 point.setX(m_model->data(xIndex, Qt::DisplayRole).toDouble());
371 point.setY(m_model->data(yIndex, Qt::DisplayRole).toDouble());
402 point.setY(m_model->data(yIndex, Qt::DisplayRole).toDouble());
372 m_series->append(point);
403 m_series->append(point);
373 pointPos++;
404 pointPos++;
374 xIndex = xModelIndex(pointPos);
405 xIndex = xModelIndex(pointPos);
375 yIndex = yModelIndex(pointPos);
406 yIndex = yModelIndex(pointPos);
376 }
407 }
377 blockSeriesSignals(false);
408 blockSeriesSignals(false);
378 }
409 }
379
410
380 #include "moc_qxymodelmapper.cpp"
411 #include "moc_qxymodelmapper.cpp"
381 #include "moc_qxymodelmapper_p.cpp"
412 #include "moc_qxymodelmapper_p.cpp"
382
413
383 QTCOMMERCIALCHART_END_NAMESPACE
414 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,336 +1,340
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "qxyseries.h"
21 #include "qxyseries.h"
22 #include "qxyseries_p.h"
22 #include "qxyseries_p.h"
23 #include "domain_p.h"
23 #include "domain_p.h"
24 #include "legendmarker_p.h"
24 #include "legendmarker_p.h"
25
25
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27
27
28 /*!
28 /*!
29 \class QXYSeries
29 \class QXYSeries
30 \brief The QXYSeries class is a base class for line, spline and scatter series.
30 \brief The QXYSeries class is a base class for line, spline and scatter series.
31 */
31 */
32
32
33 /*!
33 /*!
34 \fn QPen QXYSeries::pen() const
34 \fn QPen QXYSeries::pen() const
35 \brief Returns pen used to draw points for series.
35 \brief Returns pen used to draw points for series.
36 \sa setPen()
36 \sa setPen()
37 */
37 */
38
38
39 /*!
39 /*!
40 \fn QBrush QXYSeries::brush() const
40 \fn QBrush QXYSeries::brush() const
41 \brief Returns brush used to draw points for series.
41 \brief Returns brush used to draw points for series.
42 \sa setBrush()
42 \sa setBrush()
43 */
43 */
44
44
45 /*!
45 /*!
46 \fn void QXYSeries::clicked(const QPointF& point)
46 \fn void QXYSeries::clicked(const QPointF& point)
47 \brief Signal is emitted when user clicks the \a point on chart.
47 \brief Signal is emitted when user clicks the \a point on chart.
48 */
48 */
49
49
50
50
51 /*!
51 /*!
52 \fn void QXYSeriesPrivate::pointReplaced(int index)
52 \fn void QXYSeriesPrivate::pointReplaced(int index)
53 \brief \internal \a index
53 \brief \internal \a index
54 */
54 */
55
55
56 /*!
56 /*!
57 \fn void QXYSeriesPrivate::pointAdded(int index)
57 \fn void QXYSeriesPrivate::pointAdded(int index)
58 \brief \internal \a index
58 \brief \internal \a index
59 */
59 */
60
60
61 /*!
61 /*!
62 \fn void QXYSeriesPrivate::pointRemoved(int index)
62 \fn void QXYSeriesPrivate::pointRemoved(int index)
63 \brief \internal \a index
63 \brief \internal \a index
64 */
64 */
65
65
66 /*!
66 /*!
67 \fn void QXYSeriesPrivate::updated()
67 \fn void QXYSeriesPrivate::updated()
68 \brief \internal
68 \brief \internal
69 */
69 */
70
70
71 /*!
71 /*!
72 \internal
72 \internal
73
73
74 Constructs empty series object which is a child of \a parent.
74 Constructs empty series object which is a child of \a parent.
75 When series object is added to QChartView or QChart instance ownerships is transferred.
75 When series object is added to QChartView or QChart instance ownerships is transferred.
76 */
76 */
77 QXYSeries::QXYSeries(QXYSeriesPrivate &d,QObject *parent) : QAbstractSeries(d, parent)
77 QXYSeries::QXYSeries(QXYSeriesPrivate &d,QObject *parent) : QAbstractSeries(d, parent)
78 {
78 {
79
79
80 }
80 }
81 /*!
81 /*!
82 Destroys the object. Series added to QChartView or QChart instances are owned by those,
82 Destroys the object. Series added to QChartView or QChart instances are owned by those,
83 and are deleted when mentioned object are destroyed.
83 and are deleted when mentioned object are destroyed.
84 */
84 */
85 QXYSeries::~QXYSeries()
85 QXYSeries::~QXYSeries()
86 {
86 {
87 }
87 }
88
88
89 /*!
89 /*!
90 Adds data point \a x \a y to the series. Points are connected with lines on the chart.
90 Adds data point \a x \a y to the series. Points are connected with lines on the chart.
91 */
91 */
92 void QXYSeries::append(qreal x,qreal y)
92 void QXYSeries::append(qreal x,qreal y)
93 {
93 {
94 append(QPointF(x,y));
94 append(QPointF(x,y));
95 }
95 }
96
96
97 /*!
97 /*!
98 This is an overloaded function.
98 This is an overloaded function.
99 Adds data \a point to the series. Points are connected with lines on the chart.
99 Adds data \a point to the series. Points are connected with lines on the chart.
100 */
100 */
101 void QXYSeries::append(const QPointF &point)
101 void QXYSeries::append(const QPointF &point)
102 {
102 {
103 Q_D(QXYSeries);
103 Q_D(QXYSeries);
104 d->m_points<<point;
104 d->m_points<<point;
105 emit d->pointAdded(d->m_points.count()-1);
105 // emit d->pointAdded(d->m_points.count()-1);
106 emit pointAdded(d->m_points.count()-1);
106 }
107 }
107
108
108 /*!
109 /*!
109 This is an overloaded function.
110 This is an overloaded function.
110 Adds list of data \a points to the series. Points are connected with lines on the chart.
111 Adds list of data \a points to the series. Points are connected with lines on the chart.
111 */
112 */
112 void QXYSeries::append(const QList<QPointF> &points)
113 void QXYSeries::append(const QList<QPointF> &points)
113 {
114 {
114 foreach(const QPointF& point , points) {
115 foreach(const QPointF& point , points) {
115 append(point);
116 append(point);
116 }
117 }
117 }
118 }
118
119
119
120
120 void QXYSeries::replace(qreal oldX,qreal oldY,qreal newX,qreal newY)
121 void QXYSeries::replace(qreal oldX,qreal oldY,qreal newX,qreal newY)
121 {
122 {
122 replace(QPointF(oldX,oldY),QPointF(newX,newY));
123 replace(QPointF(oldX,oldY),QPointF(newX,newY));
123 }
124 }
124
125
125 void QXYSeries::replace(const QPointF &oldPoint,const QPointF &newPoint)
126 void QXYSeries::replace(const QPointF &oldPoint,const QPointF &newPoint)
126 {
127 {
127 Q_D(QXYSeries);
128 Q_D(QXYSeries);
128 int index = d->m_points.indexOf(oldPoint);
129 int index = d->m_points.indexOf(oldPoint);
129 if(index==-1) return;
130 if(index==-1) return;
130 d->m_points[index] = newPoint;
131 d->m_points[index] = newPoint;
131 emit d->pointReplaced(index);
132 // emit d->pointReplaced(index);
133 emit pointReplaced(index);
132 }
134 }
133
135
134 /*!
136 /*!
135 Removes current \a x and \a y value.
137 Removes current \a x and \a y value.
136 */
138 */
137 void QXYSeries::remove(qreal x,qreal y)
139 void QXYSeries::remove(qreal x,qreal y)
138 {
140 {
139 remove(QPointF(x,y));
141 remove(QPointF(x,y));
140 }
142 }
141
143
142 /*!
144 /*!
143 Removes current \a point x value. Note \a point y value is ignored.
145 Removes current \a point x value. Note \a point y value is ignored.
144 */
146 */
145 void QXYSeries::remove(const QPointF &point)
147 void QXYSeries::remove(const QPointF &point)
146 {
148 {
147 Q_D(QXYSeries);
149 Q_D(QXYSeries);
148 int index = d->m_points.indexOf(point);
150 int index = d->m_points.indexOf(point);
149 if(index==-1) return;
151 if(index==-1) return;
150 d->m_points.remove(index);
152 d->m_points.remove(index);
151 emit d->pointRemoved(index);
153 // emit d->pointRemoved(index);
154 emit pointRemoved(index);
152 }
155 }
153
156
154 /*!
157 /*!
155 Removes all data points from the series.
158 Removes all data points from the series.
156 */
159 */
157 void QXYSeries::removeAll()
160 void QXYSeries::removeAll()
158 {
161 {
159 Q_D(QXYSeries);
162 Q_D(QXYSeries);
160 foreach(const QPointF& point, d->m_points) {
163 foreach(const QPointF& point, d->m_points) {
161 remove(point);
164 remove(point);
162 }
165 }
163 }
166 }
164
167
165 void QXYSeries::insert(int index, const QPointF &point)
168 void QXYSeries::insert(int index, const QPointF &point)
166 {
169 {
167 Q_D(QXYSeries);
170 Q_D(QXYSeries);
168 d->m_points.insert(index, point);
171 d->m_points.insert(index, point);
169 emit d->pointAdded(index);
172 // emit d->pointAdded(index);
173 emit pointAdded(index);
170 }
174 }
171
175
172 void QXYSeries::clear()
176 void QXYSeries::clear()
173 {
177 {
174 Q_D(QXYSeries);
178 Q_D(QXYSeries);
175 for (int i = d->m_points.size() - 1; i >= 0; i--)
179 for (int i = d->m_points.size() - 1; i >= 0; i--)
176 remove(d->m_points.at(i));
180 remove(d->m_points.at(i));
177 }
181 }
178
182
179 /*!
183 /*!
180 \internal \a pos
184 \internal \a pos
181 */
185 */
182 QList<QPointF> QXYSeries::points() const
186 QList<QPointF> QXYSeries::points() const
183 {
187 {
184 Q_D(const QXYSeries);
188 Q_D(const QXYSeries);
185 return d->m_points.toList();
189 return d->m_points.toList();
186 }
190 }
187
191
188 /*!
192 /*!
189 Returns number of data points within series.
193 Returns number of data points within series.
190 */
194 */
191 int QXYSeries::count() const
195 int QXYSeries::count() const
192 {
196 {
193 Q_D(const QXYSeries);
197 Q_D(const QXYSeries);
194 return d->m_points.count();
198 return d->m_points.count();
195 }
199 }
196
200
197
201
198 /*!
202 /*!
199 Sets \a pen used for drawing points on the chart. If the pen is not defined, the
203 Sets \a pen used for drawing points on the chart. If the pen is not defined, the
200 pen from chart theme is used.
204 pen from chart theme is used.
201 \sa QChart::setTheme()
205 \sa QChart::setTheme()
202 */
206 */
203 void QXYSeries::setPen(const QPen &pen)
207 void QXYSeries::setPen(const QPen &pen)
204 {
208 {
205 Q_D(QXYSeries);
209 Q_D(QXYSeries);
206 if (d->m_pen!=pen) {
210 if (d->m_pen!=pen) {
207 d->m_pen = pen;
211 d->m_pen = pen;
208 emit d->updated();
212 emit d->updated();
209 }
213 }
210 }
214 }
211
215
212 QPen QXYSeries::pen() const
216 QPen QXYSeries::pen() const
213 {
217 {
214 Q_D(const QXYSeries);
218 Q_D(const QXYSeries);
215 return d->m_pen;
219 return d->m_pen;
216 }
220 }
217
221
218 /*!
222 /*!
219 Sets \a brush used for drawing points on the chart. If the brush is not defined, brush
223 Sets \a brush used for drawing points on the chart. If the brush is not defined, brush
220 from chart theme setting is used.
224 from chart theme setting is used.
221 \sa QChart::setTheme()
225 \sa QChart::setTheme()
222 */
226 */
223 void QXYSeries::setBrush(const QBrush &brush)
227 void QXYSeries::setBrush(const QBrush &brush)
224 {
228 {
225 Q_D(QXYSeries);
229 Q_D(QXYSeries);
226 if (d->m_brush!=brush) {
230 if (d->m_brush!=brush) {
227 d->m_brush = brush;
231 d->m_brush = brush;
228 emit d->updated();
232 emit d->updated();
229 }
233 }
230 }
234 }
231
235
232 QBrush QXYSeries::brush() const
236 QBrush QXYSeries::brush() const
233 {
237 {
234 Q_D(const QXYSeries);
238 Q_D(const QXYSeries);
235 return d->m_brush;
239 return d->m_brush;
236 }
240 }
237
241
238
242
239 /*!
243 /*!
240 Sets if data points are \a visible and should be drawn on line.
244 Sets if data points are \a visible and should be drawn on line.
241 */
245 */
242 void QXYSeries::setPointsVisible(bool visible)
246 void QXYSeries::setPointsVisible(bool visible)
243 {
247 {
244 Q_D(QXYSeries);
248 Q_D(QXYSeries);
245 if (d->m_pointsVisible != visible){
249 if (d->m_pointsVisible != visible){
246 d->m_pointsVisible = visible;
250 d->m_pointsVisible = visible;
247 emit d->updated();
251 emit d->updated();
248 }
252 }
249 }
253 }
250
254
251 /*!
255 /*!
252 Returns true if drawing the data points of the series is enabled.
256 Returns true if drawing the data points of the series is enabled.
253 */
257 */
254 bool QXYSeries::pointsVisible() const
258 bool QXYSeries::pointsVisible() const
255 {
259 {
256 Q_D(const QXYSeries);
260 Q_D(const QXYSeries);
257 return d->m_pointsVisible;
261 return d->m_pointsVisible;
258 }
262 }
259
263
260
264
261 /*!
265 /*!
262 Stream operator for adding a data \a point to the series.
266 Stream operator for adding a data \a point to the series.
263 \sa append()
267 \sa append()
264 */
268 */
265 QXYSeries& QXYSeries::operator<< (const QPointF &point)
269 QXYSeries& QXYSeries::operator<< (const QPointF &point)
266 {
270 {
267 append(point);
271 append(point);
268 return *this;
272 return *this;
269 }
273 }
270
274
271
275
272 /*!
276 /*!
273 Stream operator for adding a list of \a points to the series.
277 Stream operator for adding a list of \a points to the series.
274 \sa append()
278 \sa append()
275 */
279 */
276
280
277 QXYSeries& QXYSeries::operator<< (const QList<QPointF>& points)
281 QXYSeries& QXYSeries::operator<< (const QList<QPointF>& points)
278 {
282 {
279 append(points);
283 append(points);
280 return *this;
284 return *this;
281 }
285 }
282
286
283 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
287 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
284
288
285
289
286 QXYSeriesPrivate::QXYSeriesPrivate(QXYSeries *q) :
290 QXYSeriesPrivate::QXYSeriesPrivate(QXYSeries *q) :
287 QAbstractSeriesPrivate(q),
291 QAbstractSeriesPrivate(q),
288 m_pointsVisible(false)
292 m_pointsVisible(false)
289 {
293 {
290 }
294 }
291
295
292 void QXYSeriesPrivate::scaleDomain(Domain& domain)
296 void QXYSeriesPrivate::scaleDomain(Domain& domain)
293 {
297 {
294 qreal minX(domain.minX());
298 qreal minX(domain.minX());
295 qreal minY(domain.minY());
299 qreal minY(domain.minY());
296 qreal maxX(domain.maxX());
300 qreal maxX(domain.maxX());
297 qreal maxY(domain.maxY());
301 qreal maxY(domain.maxY());
298 int tickXCount(domain.tickXCount());
302 int tickXCount(domain.tickXCount());
299 int tickYCount(domain.tickYCount());
303 int tickYCount(domain.tickYCount());
300
304
301 Q_Q(QXYSeries);
305 Q_Q(QXYSeries);
302
306
303 const QList<QPointF>& points = q->points();
307 const QList<QPointF>& points = q->points();
304
308
305
309
306 if(points.isEmpty()){
310 if(points.isEmpty()){
307 minX=0.0;
311 minX=0.0;
308 minY=0.0;
312 minY=0.0;
309 maxX=1.0;
313 maxX=1.0;
310 maxY=1.0;
314 maxY=1.0;
311 }
315 }
312
316
313 for (int i = 0; i < points.count(); i++)
317 for (int i = 0; i < points.count(); i++)
314 {
318 {
315 qreal x = points[i].x();
319 qreal x = points[i].x();
316 qreal y = points[i].y();
320 qreal y = points[i].y();
317 minX = qMin(minX, x);
321 minX = qMin(minX, x);
318 minY = qMin(minY, y);
322 minY = qMin(minY, y);
319 maxX = qMax(maxX, x);
323 maxX = qMax(maxX, x);
320 maxY = qMax(maxY, y);
324 maxY = qMax(maxY, y);
321 }
325 }
322
326
323 domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount);
327 domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount);
324 }
328 }
325
329
326 QList<LegendMarker*> QXYSeriesPrivate::createLegendMarker(QLegend* legend)
330 QList<LegendMarker*> QXYSeriesPrivate::createLegendMarker(QLegend* legend)
327 {
331 {
328 Q_Q(QXYSeries);
332 Q_Q(QXYSeries);
329 QList<LegendMarker*> list;
333 QList<LegendMarker*> list;
330 return list << new XYLegendMarker(q,legend);
334 return list << new XYLegendMarker(q,legend);
331 }
335 }
332
336
333 #include "moc_qxyseries.cpp"
337 #include "moc_qxyseries.cpp"
334 #include "moc_qxyseries_p.cpp"
338 #include "moc_qxyseries_p.cpp"
335
339
336 QTCOMMERCIALCHART_END_NAMESPACE
340 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,83 +1,86
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef QXYSERIES_H
21 #ifndef QXYSERIES_H
22 #define QXYSERIES_H
22 #define QXYSERIES_H
23
23
24 #include <qchartglobal.h>
24 #include <qchartglobal.h>
25 #include <qabstractseries.h>
25 #include <qabstractseries.h>
26 #include <QPen>
26 #include <QPen>
27 #include <QBrush>
27 #include <QBrush>
28
28
29 class QModelIndex;
29 class QModelIndex;
30
30
31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32
32
33 class QXYSeriesPrivate;
33 class QXYSeriesPrivate;
34 class QXYModelMapper;
34 class QXYModelMapper;
35
35
36 class QTCOMMERCIALCHART_EXPORT QXYSeries : public QAbstractSeries
36 class QTCOMMERCIALCHART_EXPORT QXYSeries : public QAbstractSeries
37 {
37 {
38 Q_OBJECT
38 Q_OBJECT
39
39
40 protected:
40 protected:
41 explicit QXYSeries(QXYSeriesPrivate &d,QObject *parent = 0);
41 explicit QXYSeries(QXYSeriesPrivate &d,QObject *parent = 0);
42 ~QXYSeries();
42 ~QXYSeries();
43
43
44 public:
44 public:
45 void append(qreal x, qreal y);
45 void append(qreal x, qreal y);
46 void append(const QPointF &point);
46 void append(const QPointF &point);
47 void append(const QList<QPointF> &points);
47 void append(const QList<QPointF> &points);
48 void replace(qreal oldX,qreal oldY,qreal newX,qreal newY);
48 void replace(qreal oldX,qreal oldY,qreal newX,qreal newY);
49 void replace(const QPointF &oldPoint,const QPointF &newPoint);
49 void replace(const QPointF &oldPoint,const QPointF &newPoint);
50 void remove(qreal x, qreal y);
50 void remove(qreal x, qreal y);
51 void remove(const QPointF &point);
51 void remove(const QPointF &point);
52 void removeAll();
52 void removeAll();
53 void insert(int index, const QPointF &point);
53 void insert(int index, const QPointF &point);
54 void clear();
54 void clear();
55
55
56 int count() const;
56 int count() const;
57 QList<QPointF> points() const;
57 QList<QPointF> points() const;
58
58
59 QXYSeries& operator << (const QPointF &point);
59 QXYSeries& operator << (const QPointF &point);
60 QXYSeries& operator << (const QList<QPointF> &points);
60 QXYSeries& operator << (const QList<QPointF> &points);
61
61
62 void setPen(const QPen &pen);
62 void setPen(const QPen &pen);
63 QPen pen() const;
63 QPen pen() const;
64
64
65 void setBrush(const QBrush &brush);
65 void setBrush(const QBrush &brush);
66 QBrush brush() const;
66 QBrush brush() const;
67
67
68 void setPointsVisible(bool visible = true);
68 void setPointsVisible(bool visible = true);
69 bool pointsVisible() const;
69 bool pointsVisible() const;
70
70
71 Q_SIGNALS:
71 Q_SIGNALS:
72 void clicked(const QPointF &point);
72 void clicked(const QPointF &point);
73 void pointReplaced(int index);
74 void pointRemoved(int index);
75 void pointAdded(int index);
73
76
74 private:
77 private:
75 Q_DECLARE_PRIVATE(QXYSeries)
78 Q_DECLARE_PRIVATE(QXYSeries)
76 Q_DISABLE_COPY(QXYSeries)
79 Q_DISABLE_COPY(QXYSeries)
77 friend class XYLegendMarker;
80 friend class XYLegendMarker;
78 friend class XYChart;
81 friend class XYChart;
79 };
82 };
80
83
81 QTCOMMERCIALCHART_END_NAMESPACE
84 QTCOMMERCIALCHART_END_NAMESPACE
82
85
83 #endif
86 #endif
@@ -1,69 +1,69
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 // W A R N I N G
21 // W A R N I N G
22 // -------------
22 // -------------
23 //
23 //
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 // implementation detail. This header file may change from version to
25 // implementation detail. This header file may change from version to
26 // version without notice, or even be removed.
26 // version without notice, or even be removed.
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef QXYSERIES_P_H
30 #ifndef QXYSERIES_P_H
31 #define QXYSERIES_P_H
31 #define QXYSERIES_P_H
32
32
33 #include "qabstractseries_p.h"
33 #include "qabstractseries_p.h"
34
34
35 QTCOMMERCIALCHART_BEGIN_NAMESPACE
35 QTCOMMERCIALCHART_BEGIN_NAMESPACE
36
36
37 class QXYSeries;
37 class QXYSeries;
38
38
39 class QXYSeriesPrivate: public QAbstractSeriesPrivate
39 class QXYSeriesPrivate: public QAbstractSeriesPrivate
40 {
40 {
41 Q_OBJECT
41 Q_OBJECT
42
42
43 public:
43 public:
44 QXYSeriesPrivate(QXYSeries* q);
44 QXYSeriesPrivate(QXYSeries* q);
45
45
46 void scaleDomain(Domain& domain);
46 void scaleDomain(Domain& domain);
47 QList<LegendMarker*> createLegendMarker(QLegend* legend);
47 QList<LegendMarker*> createLegendMarker(QLegend* legend);
48
48
49 Q_SIGNALS:
49 Q_SIGNALS:
50 void updated();
50 void updated();
51 void pointReplaced(int index);
51 // void pointReplaced(int index);
52 void pointRemoved(int index);
52 // void pointRemoved(int index);
53 void pointAdded(int index);
53 // void pointAdded(int index);
54
54
55 protected:
55 protected:
56 QVector<QPointF> m_points;
56 QVector<QPointF> m_points;
57 QPen m_pen;
57 QPen m_pen;
58 QBrush m_brush;
58 QBrush m_brush;
59 bool m_pointsVisible;
59 bool m_pointsVisible;
60
60
61 private:
61 private:
62 Q_DECLARE_PUBLIC(QXYSeries);
62 Q_DECLARE_PUBLIC(QXYSeries);
63 friend class QScatterSeries;
63 friend class QScatterSeries;
64
64
65 };
65 };
66
66
67 QTCOMMERCIALCHART_END_NAMESPACE
67 QTCOMMERCIALCHART_END_NAMESPACE
68
68
69 #endif
69 #endif
@@ -1,238 +1,241
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "xychart_p.h"
21 #include "xychart_p.h"
22 #include "qxyseries.h"
22 #include "qxyseries.h"
23 #include "qxyseries_p.h"
23 #include "qxyseries_p.h"
24 #include "chartpresenter_p.h"
24 #include "chartpresenter_p.h"
25 #include "chartanimator_p.h"
25 #include "chartanimator_p.h"
26 #include <QPainter>
26 #include <QPainter>
27 #include <QAbstractItemModel>
27 #include <QAbstractItemModel>
28 #include "qxymodelmapper.h"
28 #include "qxymodelmapper.h"
29 #include <QDebug>
29 #include <QDebug>
30
30
31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32
32
33 //TODO: optimize : remove points which are not visible
33 //TODO: optimize : remove points which are not visible
34
34
35 XYChart::XYChart(QXYSeries *series, ChartPresenter *presenter):Chart(presenter),
35 XYChart::XYChart(QXYSeries *series, ChartPresenter *presenter):Chart(presenter),
36 m_minX(0),
36 m_minX(0),
37 m_maxX(0),
37 m_maxX(0),
38 m_minY(0),
38 m_minY(0),
39 m_maxY(0),
39 m_maxY(0),
40 m_series(series),
40 m_series(series),
41 m_animation(0),
41 m_animation(0),
42 m_dirty(true)
42 m_dirty(true)
43 {
43 {
44 QObject::connect(series->d_func(),SIGNAL(pointReplaced(int)),this,SLOT(handlePointReplaced(int)));
44 // QObject::connect(series->d_func(),SIGNAL(pointReplaced(int)),this,SLOT(handlePointReplaced(int)));
45 QObject::connect(series->d_func(),SIGNAL(pointAdded(int)),this,SLOT(handlePointAdded(int)));
45 // QObject::connect(series->d_func(),SIGNAL(pointAdded(int)),this,SLOT(handlePointAdded(int)));
46 QObject::connect(series->d_func(),SIGNAL(pointRemoved(int)),this,SLOT(handlePointRemoved(int)));
46 // QObject::connect(series->d_func(),SIGNAL(pointRemoved(int)),this,SLOT(handlePointRemoved(int)));
47 QObject::connect(this,SIGNAL(clicked(QPointF)),series,SIGNAL(clicked(QPointF)));
47 QObject::connect(series, SIGNAL(pointReplaced(int)), this,SLOT(handlePointReplaced(int)));
48 QObject::connect(series, SIGNAL(pointAdded(int)), this,SLOT(handlePointAdded(int)));
49 QObject::connect(series, SIGNAL(pointRemoved(int)), this,SLOT(handlePointRemoved(int)));
50 QObject::connect(this, SIGNAL(clicked(QPointF)), series,SIGNAL(clicked(QPointF)));
48 }
51 }
49
52
50 void XYChart::setGeometryPoints(const QVector<QPointF>& points)
53 void XYChart::setGeometryPoints(const QVector<QPointF>& points)
51 {
54 {
52 m_points = points;
55 m_points = points;
53 }
56 }
54
57
55 void XYChart::setClipRect(const QRectF &rect)
58 void XYChart::setClipRect(const QRectF &rect)
56 {
59 {
57 m_clipRect = rect;
60 m_clipRect = rect;
58 }
61 }
59
62
60 void XYChart::setAnimation(XYAnimation* animation)
63 void XYChart::setAnimation(XYAnimation* animation)
61 {
64 {
62 m_animation=animation;
65 m_animation=animation;
63 }
66 }
64
67
65 void XYChart::setDirty(bool dirty)
68 void XYChart::setDirty(bool dirty)
66 {
69 {
67 m_dirty=dirty;
70 m_dirty=dirty;
68 }
71 }
69
72
70 QPointF XYChart::calculateGeometryPoint(const QPointF &point) const
73 QPointF XYChart::calculateGeometryPoint(const QPointF &point) const
71 {
74 {
72 const qreal deltaX = m_size.width()/(m_maxX-m_minX);
75 const qreal deltaX = m_size.width()/(m_maxX-m_minX);
73 const qreal deltaY = m_size.height()/(m_maxY-m_minY);
76 const qreal deltaY = m_size.height()/(m_maxY-m_minY);
74 qreal x = (point.x() - m_minX)* deltaX;
77 qreal x = (point.x() - m_minX)* deltaX;
75 qreal y = (point.y() - m_minY)*-deltaY + m_size.height();
78 qreal y = (point.y() - m_minY)*-deltaY + m_size.height();
76 return QPointF(x,y);
79 return QPointF(x,y);
77 }
80 }
78
81
79 QPointF XYChart::calculateGeometryPoint(int index) const
82 QPointF XYChart::calculateGeometryPoint(int index) const
80 {
83 {
81 const qreal deltaX = m_size.width()/(m_maxX-m_minX);
84 const qreal deltaX = m_size.width()/(m_maxX-m_minX);
82 const qreal deltaY = m_size.height()/(m_maxY-m_minY);
85 const qreal deltaY = m_size.height()/(m_maxY-m_minY);
83 const QList<QPointF>& vector = m_series->points();
86 const QList<QPointF>& vector = m_series->points();
84 qreal x = (vector[index].x() - m_minX)* deltaX;
87 qreal x = (vector[index].x() - m_minX)* deltaX;
85 qreal y = (vector[index].y() - m_minY)*-deltaY + m_size.height();
88 qreal y = (vector[index].y() - m_minY)*-deltaY + m_size.height();
86 return QPointF(x,y);
89 return QPointF(x,y);
87 }
90 }
88
91
89 QVector<QPointF> XYChart::calculateGeometryPoints() const
92 QVector<QPointF> XYChart::calculateGeometryPoints() const
90 {
93 {
91 const qreal deltaX = m_size.width()/(m_maxX-m_minX);
94 const qreal deltaX = m_size.width()/(m_maxX-m_minX);
92 const qreal deltaY = m_size.height()/(m_maxY-m_minY);
95 const qreal deltaY = m_size.height()/(m_maxY-m_minY);
93
96
94 QVector<QPointF> result;
97 QVector<QPointF> result;
95 result.resize(m_series->count());
98 result.resize(m_series->count());
96 const QList<QPointF>& vector = m_series->points();
99 const QList<QPointF>& vector = m_series->points();
97 for (int i = 0; i < m_series->count(); ++i) {
100 for (int i = 0; i < m_series->count(); ++i) {
98 qreal x = (vector[i].x() - m_minX)* deltaX;
101 qreal x = (vector[i].x() - m_minX)* deltaX;
99 qreal y = (vector[i].y() - m_minY)*-deltaY + m_size.height();
102 qreal y = (vector[i].y() - m_minY)*-deltaY + m_size.height();
100 result[i].setX(x);
103 result[i].setX(x);
101 result[i].setY(y);
104 result[i].setY(y);
102 }
105 }
103 return result;
106 return result;
104 }
107 }
105
108
106 QPointF XYChart::calculateDomainPoint(const QPointF &point) const
109 QPointF XYChart::calculateDomainPoint(const QPointF &point) const
107 {
110 {
108 const qreal deltaX = m_size.width()/(m_maxX-m_minX);
111 const qreal deltaX = m_size.width()/(m_maxX-m_minX);
109 const qreal deltaY = m_size.height()/(m_maxY-m_minY);
112 const qreal deltaY = m_size.height()/(m_maxY-m_minY);
110 qreal x = point.x()/deltaX +m_minX;
113 qreal x = point.x()/deltaX +m_minX;
111 qreal y = (point.y()-m_size.height())/(-deltaY)+ m_minY;
114 qreal y = (point.y()-m_size.height())/(-deltaY)+ m_minY;
112 return QPointF(x,y);
115 return QPointF(x,y);
113 }
116 }
114
117
115 void XYChart::updateChart(QVector<QPointF> &oldPoints, QVector<QPointF> &newPoints,int index)
118 void XYChart::updateChart(QVector<QPointF> &oldPoints, QVector<QPointF> &newPoints,int index)
116 {
119 {
117 if (m_animation) {
120 if (m_animation) {
118 m_animation->setValues(oldPoints, newPoints, index);
121 m_animation->setValues(oldPoints, newPoints, index);
119 setGeometryPoints(newPoints);
122 setGeometryPoints(newPoints);
120 setDirty(false);
123 setDirty(false);
121 presenter()->startAnimation(m_animation);
124 presenter()->startAnimation(m_animation);
122 }
125 }
123 else {
126 else {
124 setGeometryPoints(newPoints);
127 setGeometryPoints(newPoints);
125 updateGeometry();
128 updateGeometry();
126 }
129 }
127 }
130 }
128
131
129 //handlers
132 //handlers
130
133
131 void XYChart::handlePointAdded(int index)
134 void XYChart::handlePointAdded(int index)
132 {
135 {
133 Q_ASSERT(index<m_series->count());
136 Q_ASSERT(index<m_series->count());
134 Q_ASSERT(index>=0);
137 Q_ASSERT(index>=0);
135
138
136 QVector<QPointF> points;
139 QVector<QPointF> points;
137
140
138 if(m_animation) {
141 if(m_animation) {
139 m_animation->setAnimationType(XYAnimation::AddPointAnimation);
142 m_animation->setAnimationType(XYAnimation::AddPointAnimation);
140 }
143 }
141
144
142 if(m_dirty) {
145 if(m_dirty) {
143 points = calculateGeometryPoints();
146 points = calculateGeometryPoints();
144 } else {
147 } else {
145 points = m_points;
148 points = m_points;
146 QPointF point = calculateGeometryPoint(index);
149 QPointF point = calculateGeometryPoint(index);
147 points.insert(index, point);
150 points.insert(index, point);
148 }
151 }
149
152
150 updateChart(m_points,points,index);
153 updateChart(m_points,points,index);
151 }
154 }
152
155
153 void XYChart::handlePointRemoved(int index)
156 void XYChart::handlePointRemoved(int index)
154 {
157 {
155 Q_ASSERT(index<=m_series->count());
158 Q_ASSERT(index<=m_series->count());
156 Q_ASSERT(index>=0);
159 Q_ASSERT(index>=0);
157
160
158 QVector<QPointF> points;
161 QVector<QPointF> points;
159
162
160 if(m_animation) {
163 if(m_animation) {
161 m_animation->setAnimationType(XYAnimation::RemovePointAnimation);
164 m_animation->setAnimationType(XYAnimation::RemovePointAnimation);
162 }
165 }
163
166
164 if(m_dirty) {
167 if(m_dirty) {
165 points = calculateGeometryPoints();
168 points = calculateGeometryPoints();
166 } else {
169 } else {
167 points = m_points;
170 points = m_points;
168 points.remove(index);
171 points.remove(index);
169 }
172 }
170
173
171 updateChart(m_points,points,index);
174 updateChart(m_points,points,index);
172 }
175 }
173
176
174 void XYChart::handlePointReplaced(int index)
177 void XYChart::handlePointReplaced(int index)
175 {
178 {
176 Q_ASSERT(index<m_series->count());
179 Q_ASSERT(index<m_series->count());
177 Q_ASSERT(index>=0);
180 Q_ASSERT(index>=0);
178
181
179 QVector<QPointF> points;
182 QVector<QPointF> points;
180
183
181 if(m_animation) {
184 if(m_animation) {
182 m_animation->setAnimationType(XYAnimation::ReplacePointAnimation);
185 m_animation->setAnimationType(XYAnimation::ReplacePointAnimation);
183 }
186 }
184
187
185 if(m_dirty) {
188 if(m_dirty) {
186 points = calculateGeometryPoints();
189 points = calculateGeometryPoints();
187 } else {
190 } else {
188 QPointF point = calculateGeometryPoint(index);
191 QPointF point = calculateGeometryPoint(index);
189 points = m_points;
192 points = m_points;
190 points.replace(index,point);
193 points.replace(index,point);
191 }
194 }
192
195
193 updateChart(m_points,points,index);
196 updateChart(m_points,points,index);
194 }
197 }
195
198
196 void XYChart::handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY)
199 void XYChart::handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY)
197 {
200 {
198 m_minX=minX;
201 m_minX=minX;
199 m_maxX=maxX;
202 m_maxX=maxX;
200 m_minY=minY;
203 m_minY=minY;
201 m_maxY=maxY;
204 m_maxY=maxY;
202 if (isEmpty()) return;
205 if (isEmpty()) return;
203
206
204 QVector<QPointF> points = calculateGeometryPoints();
207 QVector<QPointF> points = calculateGeometryPoints();
205
208
206 if(m_animation) {
209 if(m_animation) {
207 m_animation->setAnimationType(XYAnimation::ReplacePointAnimation);
210 m_animation->setAnimationType(XYAnimation::ReplacePointAnimation);
208 }
211 }
209
212
210 updateChart(m_points,points);
213 updateChart(m_points,points);
211 }
214 }
212
215
213 void XYChart::handleGeometryChanged(const QRectF &rect)
216 void XYChart::handleGeometryChanged(const QRectF &rect)
214 {
217 {
215 Q_ASSERT(rect.isValid());
218 Q_ASSERT(rect.isValid());
216 m_size=rect.size();
219 m_size=rect.size();
217 m_clipRect=rect.translated(-rect.topLeft());
220 m_clipRect=rect.translated(-rect.topLeft());
218 m_origin=rect.topLeft();
221 m_origin=rect.topLeft();
219
222
220 if (isEmpty()) return;
223 if (isEmpty()) return;
221
224
222 QVector<QPointF> points = calculateGeometryPoints();
225 QVector<QPointF> points = calculateGeometryPoints();
223
226
224 if(m_animation) {
227 if(m_animation) {
225 m_animation->setAnimationType(XYAnimation::NewAnimation);
228 m_animation->setAnimationType(XYAnimation::NewAnimation);
226 }
229 }
227
230
228 updateChart(m_points,points);
231 updateChart(m_points,points);
229 }
232 }
230
233
231 bool XYChart::isEmpty()
234 bool XYChart::isEmpty()
232 {
235 {
233 return !m_clipRect.isValid() || qFuzzyIsNull(m_maxX - m_minX) || qFuzzyIsNull(m_maxY - m_minY) || m_series->points().isEmpty();
236 return !m_clipRect.isValid() || qFuzzyIsNull(m_maxX - m_minX) || qFuzzyIsNull(m_maxY - m_minY) || m_series->points().isEmpty();
234 }
237 }
235
238
236 #include "moc_xychart_p.cpp"
239 #include "moc_xychart_p.cpp"
237
240
238 QTCOMMERCIALCHART_END_NAMESPACE
241 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,524 +1,539
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "tablewidget.h"
21 #include "tablewidget.h"
22 #include <QGridLayout>
22 #include <QGridLayout>
23 #include <QTableView>
23 #include <QTableView>
24 #include <QChart>
24 #include <QChart>
25 #include <QStyledItemDelegate>
25 #include <QStyledItemDelegate>
26 #include <QLineSeries>
26 #include <QLineSeries>
27 #include <QSplineSeries>
27 #include <QSplineSeries>
28 #include <QScatterSeries>
28 #include <QScatterSeries>
29 #include <QVXYModelMapper>
29 #include <QVXYModelMapper>
30 #include "customtablemodel.h"
30 #include "customtablemodel.h"
31 #include <QPieSeries>
31 #include <QPieSeries>
32 #include <QVPieModelMapper>
32 #include <QVPieModelMapper>
33 #include <QPieSlice>
33 #include <QPieSlice>
34 #include <QAreaSeries>
34 #include <QAreaSeries>
35 #include <QBarSeries>
35 #include <QBarSeries>
36 #include <QGroupedBarSeries>
36 #include <QGroupedBarSeries>
37 #include <QBarSet>
37 #include <QBarSet>
38 #include <QBarModelMapper>
38 #include <QBarModelMapper>
39 #include <QPushButton>
39 #include <QPushButton>
40 #include <QRadioButton>
40 #include <QRadioButton>
41 #include <QLabel>
41 #include <QLabel>
42 #include <QSpinBox>
42 #include <QSpinBox>
43 #include <QTime>
43 #include <QTime>
44 #include <QHeaderView>
44 #include <QHeaderView>
45
45
46 TableWidget::TableWidget(QWidget *parent)
46 TableWidget::TableWidget(QWidget *parent)
47 : QWidget(parent)
47 : QWidget(parent)
48 // specialPie(0)
48 // specialPie(0)
49 {
49 {
50 setGeometry(1900, 100, 1000, 600);
50 setGeometry(1900, 100, 1000, 600);
51 qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
51 qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
52 // create simple model for storing data
52 // create simple model for storing data
53 // user's table data model
53 // user's table data model
54 m_model = new CustomTableModel;
54 m_model = new CustomTableModel;
55 m_tableView = new QTableView;
55 m_tableView = new QTableView;
56 m_tableView->setModel(m_model);
56 m_tableView->setModel(m_model);
57 // m_tableView->setMinimumHeight(300);
57 // m_tableView->setMinimumHeight(300);
58 m_tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
58 m_tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
59 m_tableView->verticalHeader()->setResizeMode(QHeaderView::Stretch);
59 m_tableView->verticalHeader()->setResizeMode(QHeaderView::Stretch);
60
60
61 m_chart = new QChart;
61 m_chart = new QChart;
62 m_chart->legend()->setVisible(true);
62 m_chart->legend()->setVisible(true);
63 m_chart->setAnimationOptions(QChart::SeriesAnimations);
63 m_chart->setAnimationOptions(QChart::SeriesAnimations);
64 m_chartView = new QChartView(m_chart);
64 m_chartView = new QChartView(m_chart);
65 m_chartView->setRenderHint(QPainter::Antialiasing);
65 m_chartView->setRenderHint(QPainter::Antialiasing);
66 m_chartView->setMinimumSize(640, 480);
66 m_chartView->setMinimumSize(640, 480);
67
67
68 // add, remove data buttons
68 // add, remove data buttons
69 QPushButton* addRowAboveButton = new QPushButton("Add row above");
69 QPushButton* addRowAboveButton = new QPushButton("Add row above");
70 connect(addRowAboveButton, SIGNAL(clicked()), this, SLOT(addRowAbove()));
70 connect(addRowAboveButton, SIGNAL(clicked()), this, SLOT(addRowAbove()));
71
71
72 QPushButton* addRowBelowButton = new QPushButton("Add row below");
72 QPushButton* addRowBelowButton = new QPushButton("Add row below");
73 connect(addRowBelowButton, SIGNAL(clicked()), this, SLOT(addRowBelow()));
73 connect(addRowBelowButton, SIGNAL(clicked()), this, SLOT(addRowBelow()));
74
74
75 QPushButton* removeRowButton = new QPushButton("Remove row");
75 QPushButton* removeRowButton = new QPushButton("Remove row");
76 connect(removeRowButton, SIGNAL(clicked()), this, SLOT(removeRow()));
76 connect(removeRowButton, SIGNAL(clicked()), this, SLOT(removeRow()));
77
77
78 QPushButton* addColumnRightButton = new QPushButton("Add column to the right");
78 QPushButton* addColumnRightButton = new QPushButton("Add column to the right");
79 connect(addColumnRightButton, SIGNAL(clicked()), this, SLOT(addColumnRight()));
79 connect(addColumnRightButton, SIGNAL(clicked()), this, SLOT(addColumnRight()));
80
80
81 QPushButton* removeColumnButton = new QPushButton("Remove column");
81 QPushButton* removeColumnButton = new QPushButton("Remove column");
82 connect(removeColumnButton, SIGNAL(clicked()), this, SLOT(removeColumn()));
82 connect(removeColumnButton, SIGNAL(clicked()), this, SLOT(removeColumn()));
83
83
84 QPushButton* specialPieButton = new QPushButton("Add slices using series API");
84 QPushButton* specialPieButton = new QPushButton("Add slices using series API");
85 connect(specialPieButton, SIGNAL(clicked()), this, SLOT(testPie()));
85 connect(specialPieButton, SIGNAL(clicked()), this, SLOT(testPie()));
86
86
87 QPushButton* specialPieButton2 = new QPushButton("Remove slices using series API");
87 QPushButton* specialPieButton2 = new QPushButton("Remove slices using series API");
88 connect(specialPieButton2, SIGNAL(clicked()), this, SLOT(testPie2()));
88 connect(specialPieButton2, SIGNAL(clicked()), this, SLOT(testPie2()));
89
89
90 QPushButton* specialPieButton3 = new QPushButton("Modify slices using series API");
90 QPushButton* specialPieButton3 = new QPushButton("Modify slices using series API");
91 connect(specialPieButton3, SIGNAL(clicked()), this, SLOT(testPie3()));
91 connect(specialPieButton3, SIGNAL(clicked()), this, SLOT(testPie3()));
92
92
93 QPushButton* xyTestButton = new QPushButton("Append XY point");
94 connect(xyTestButton, SIGNAL(clicked()), this, SLOT(testXY()));
95
93
96
94 QLabel *spinBoxLabel = new QLabel("Rows affected:");
97 QLabel *spinBoxLabel = new QLabel("Rows affected:");
95
98
96 // spin box for setting number of affected items (add, remove)
99 // spin box for setting number of affected items (add, remove)
97 m_linesCountSpinBox = new QSpinBox;
100 m_linesCountSpinBox = new QSpinBox;
98 m_linesCountSpinBox->setRange(1, 10);
101 m_linesCountSpinBox->setRange(1, 10);
99 m_linesCountSpinBox->setValue(1);
102 m_linesCountSpinBox->setValue(1);
100
103
101 // buttons layout
104 // buttons layout
102 QVBoxLayout* buttonsLayout = new QVBoxLayout;
105 QVBoxLayout* buttonsLayout = new QVBoxLayout;
103 buttonsLayout->addWidget(spinBoxLabel);
106 buttonsLayout->addWidget(spinBoxLabel);
104 buttonsLayout->addWidget(m_linesCountSpinBox);
107 buttonsLayout->addWidget(m_linesCountSpinBox);
105 // buttonsLayout->addWidget(addRowAboveButton);
108 // buttonsLayout->addWidget(addRowAboveButton);
106 buttonsLayout->addWidget(addRowBelowButton);
109 buttonsLayout->addWidget(addRowBelowButton);
107 buttonsLayout->addWidget(removeRowButton);
110 buttonsLayout->addWidget(removeRowButton);
108 // buttonsLayout->addWidget(addColumnRightButton);
111 // buttonsLayout->addWidget(addColumnRightButton);
109 // buttonsLayout->addWidget(removeColumnButton);
112 // buttonsLayout->addWidget(removeColumnButton);
110 buttonsLayout->addWidget(specialPieButton);
113 buttonsLayout->addWidget(specialPieButton);
111 buttonsLayout->addWidget(specialPieButton2);
114 buttonsLayout->addWidget(specialPieButton2);
112 buttonsLayout->addWidget(specialPieButton3);
115 buttonsLayout->addWidget(specialPieButton3);
116 buttonsLayout->addWidget(xyTestButton);
113 buttonsLayout->addStretch();
117 buttonsLayout->addStretch();
114
118
115 // chart type radio buttons
119 // chart type radio buttons
116 m_lineRadioButton = new QRadioButton("Line");
120 m_lineRadioButton = new QRadioButton("Line");
117 m_splineRadioButton = new QRadioButton("Spline");
121 m_splineRadioButton = new QRadioButton("Spline");
118 m_scatterRadioButton = new QRadioButton("Scatter");
122 m_scatterRadioButton = new QRadioButton("Scatter");
119 m_pieRadioButton = new QRadioButton("Pie");
123 m_pieRadioButton = new QRadioButton("Pie");
120 m_areaRadioButton = new QRadioButton("Area");
124 m_areaRadioButton = new QRadioButton("Area");
121 m_barRadioButton = new QRadioButton("Bar");
125 m_barRadioButton = new QRadioButton("Bar");
122
126
123 connect(m_lineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
127 connect(m_lineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
124 connect(m_splineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
128 connect(m_splineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
125 connect(m_scatterRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
129 connect(m_scatterRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
126 connect(m_pieRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
130 connect(m_pieRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
127 connect(m_areaRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
131 connect(m_areaRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
128 connect(m_barRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
132 connect(m_barRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
129 m_lineRadioButton->setChecked(true);
133 m_lineRadioButton->setChecked(true);
130
134
131 // radio buttons layout
135 // radio buttons layout
132 QVBoxLayout* radioLayout = new QVBoxLayout;
136 QVBoxLayout* radioLayout = new QVBoxLayout;
133 radioLayout->addWidget(m_lineRadioButton);
137 radioLayout->addWidget(m_lineRadioButton);
134 radioLayout->addWidget(m_splineRadioButton);
138 radioLayout->addWidget(m_splineRadioButton);
135 // radioLayout->addWidget(m_scatterRadioButton);
139 // radioLayout->addWidget(m_scatterRadioButton);
136 radioLayout->addWidget(m_pieRadioButton);
140 radioLayout->addWidget(m_pieRadioButton);
137 // radioLayout->addWidget(m_areaRadioButton);
141 // radioLayout->addWidget(m_areaRadioButton);
138 radioLayout->addWidget(m_barRadioButton);
142 radioLayout->addWidget(m_barRadioButton);
139 radioLayout->addStretch();
143 radioLayout->addStretch();
140
144
141 // create main layout
145 // create main layout
142 QGridLayout* mainLayout = new QGridLayout;
146 QGridLayout* mainLayout = new QGridLayout;
143 mainLayout->addLayout(buttonsLayout, 2, 0);
147 mainLayout->addLayout(buttonsLayout, 2, 0);
144 mainLayout->addLayout(radioLayout, 3, 0);
148 mainLayout->addLayout(radioLayout, 3, 0);
145 mainLayout->addWidget(m_tableView, 1, 0);
149 mainLayout->addWidget(m_tableView, 1, 0);
146 mainLayout->addWidget(m_chartView, 1, 1, 2, 1);
150 mainLayout->addWidget(m_chartView, 1, 1, 2, 1);
147 setLayout(mainLayout);
151 setLayout(mainLayout);
148 m_lineRadioButton->setFocus();
152 m_lineRadioButton->setFocus();
149 }
153 }
150
154
151 void TableWidget::addRowAbove()
155 void TableWidget::addRowAbove()
152 {
156 {
153 m_model->insertRows(m_tableView->currentIndex().row(), m_linesCountSpinBox->value());
157 m_model->insertRows(m_tableView->currentIndex().row(), m_linesCountSpinBox->value());
154
158
155 }
159 }
156
160
157 void TableWidget::addRowBelow()
161 void TableWidget::addRowBelow()
158 {
162 {
159 m_model->insertRows(m_tableView->currentIndex().row() + 1, m_linesCountSpinBox->value());
163 m_model->insertRows(m_tableView->currentIndex().row() + 1, m_linesCountSpinBox->value());
160
164
161 }
165 }
162
166
163 void TableWidget::removeRow()
167 void TableWidget::removeRow()
164 {
168 {
165 m_model->removeRows(m_tableView->currentIndex().row(), qMin(m_model->rowCount() - m_tableView->currentIndex().row(), m_linesCountSpinBox->value()));
169 m_model->removeRows(m_tableView->currentIndex().row(), qMin(m_model->rowCount() - m_tableView->currentIndex().row(), m_linesCountSpinBox->value()));
166 }
170 }
167
171
168 void TableWidget::addColumnRight()
172 void TableWidget::addColumnRight()
169 {
173 {
170 m_model->insertColumns(m_tableView->currentIndex().column() + 1, m_linesCountSpinBox->value());
174 m_model->insertColumns(m_tableView->currentIndex().column() + 1, m_linesCountSpinBox->value());
171 }
175 }
172
176
173 void TableWidget::removeColumn()
177 void TableWidget::removeColumn()
174 {
178 {
175 m_model->removeColumns(m_tableView->currentIndex().column(), qMin(m_model->columnCount() - m_tableView->currentIndex().column(), m_linesCountSpinBox->value()));
179 m_model->removeColumns(m_tableView->currentIndex().column(), qMin(m_model->columnCount() - m_tableView->currentIndex().column(), m_linesCountSpinBox->value()));
176 }
180 }
177
181
178 void TableWidget::updateChartType(bool toggle)
182 void TableWidget::updateChartType(bool toggle)
179 {
183 {
180 // this if is needed, so that the function is only called once.
184 // this if is needed, so that the function is only called once.
181 // For the radioButton that was enabled.
185 // For the radioButton that was enabled.
182 if (toggle) {
186 if (toggle) {
183 // specialPie = 0;
187 // specialPie = 0;
184 m_chart->removeAllSeries();
188 m_chart->removeAllSeries();
185 // m_chart->axisX()->setNiceNumbersEnabled(false);
189 // m_chart->axisX()->setNiceNumbersEnabled(false);
186 // m_chart->axisY()->setNiceNumbersEnabled(false);
190 // m_chart->axisY()->setNiceNumbersEnabled(false);
187
191
188 // renable axes of the chart (pie hides them)
192 // renable axes of the chart (pie hides them)
189 // x axis
193 // x axis
190 QAxis *axis = m_chart->axisX();
194 QAxis *axis = m_chart->axisX();
191 axis->setAxisVisible(true);
195 axis->setAxisVisible(true);
192 axis->setGridLineVisible(true);
196 axis->setGridLineVisible(true);
193 axis->setLabelsVisible(true);
197 axis->setLabelsVisible(true);
194
198
195 // y axis
199 // y axis
196 axis = m_chart->axisY();
200 axis = m_chart->axisY();
197 axis->setAxisVisible(true);
201 axis->setAxisVisible(true);
198 axis->setGridLineVisible(true);
202 axis->setGridLineVisible(true);
199 axis->setLabelsVisible(true);
203 axis->setLabelsVisible(true);
200
204
201 m_model->clearMapping();
205 m_model->clearMapping();
202
206
203 QString seriesColorHex = "#000000";
207 QString seriesColorHex = "#000000";
204 // QPen pen;
208 // QPen pen;
205 // pen.setWidth(2);
209 // pen.setWidth(2);
206
210
207 if (m_lineRadioButton->isChecked())
211 if (m_lineRadioButton->isChecked())
208 {
212 {
209 // m_chart->setAnimationOptions(QChart::NoAnimation);
213 m_chart->setAnimationOptions(QChart::NoAnimation);
210
214
211 // series 1
215 // series 1
212 m_series = new QLineSeries(this);
216 m_series = new QLineSeries(this);
213
217
214 QVXYModelMapper *mapper = new QVXYModelMapper;
218 QVXYModelMapper *mapper = new QVXYModelMapper;
215 mapper->setModel(m_model);
219 mapper->setModel(m_model);
216 mapper->setSeries(m_series);
220 mapper->setSeries(m_series);
217 mapper->setXColumn(0);
221 mapper->setXColumn(0);
218 mapper->setYColumn(1);
222 mapper->setYColumn(1);
219 mapper->setFirst(3);
223 mapper->setFirst(3);
220 // mapper->setCount(4);
224 mapper->setCount(4);
221
225
222 // m_series->setModelMapping(0,1, Qt::Vertical);
226 // m_series->setModelMapping(0,1, Qt::Vertical);
223 // m_series->setModelMappingRange(3, 4);
227 // m_series->setModelMappingRange(3, 4);
224 m_chart->addSeries(m_series);
228 m_chart->addSeries(m_series);
225 seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
229 seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
226 m_model->addMapping(seriesColorHex, QRect(0, 3, 2, 4));
230 m_model->addMapping(seriesColorHex, QRect(0, 3, 2, 4));
227
231
228 // // series 2
232 // // series 2
229 // m_series = new QLineSeries;
233 // m_series = new QLineSeries;
230 // m_series->setModel(m_model);
234 // m_series->setModel(m_model);
231
235
232 // mapper = new QXYModelMapper;
236 // mapper = new QXYModelMapper;
233 // mapper->setMapX(3);
237 // mapper->setMapX(3);
234 // mapper->setMapY(4);
238 // mapper->setMapY(4);
235 // // mapper->setFirst(3);
239 // // mapper->setFirst(3);
236 // // mapper->setCount(4);
240 // // mapper->setCount(4);
237 // m_series->setModelMapper(mapper);
241 // m_series->setModelMapper(mapper);
238 // // m_series->setModelMapping(2,3, Qt::Vertical);
242 // // m_series->setModelMapping(2,3, Qt::Vertical);
239 // m_chart->addSeries(m_series);
243 // m_chart->addSeries(m_series);
240 // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
244 // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
241 // m_model->addMapping(seriesColorHex, QRect(3, 0, 2, 1000));
245 // m_model->addMapping(seriesColorHex, QRect(3, 0, 2, 1000));
242
246
243 // // series 3
247 // // series 3
244 // m_series = new QLineSeries;
248 // m_series = new QLineSeries;
245 // m_series->setModel(m_model);
249 // m_series->setModel(m_model);
246
250
247 // mapper = new QXYModelMapper;
251 // mapper = new QXYModelMapper;
248 // mapper->setMapX(5);
252 // mapper->setMapX(5);
249 // mapper->setMapY(6);
253 // mapper->setMapY(6);
250 // mapper->setFirst(2);
254 // mapper->setFirst(2);
251 // mapper->setCount(-1);
255 // mapper->setCount(-1);
252 // m_series->setModelMapper(mapper);
256 // m_series->setModelMapper(mapper);
253 // // m_series->setModelMapping(4,5, Qt::Vertical);
257 // // m_series->setModelMapping(4,5, Qt::Vertical);
254 // // m_series->setModelMappingRange(2, -1);
258 // // m_series->setModelMappingRange(2, -1);
255 // m_chart->addSeries(m_series);
259 // m_chart->addSeries(m_series);
256 // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
260 // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
257 // m_model->addMapping(seriesColorHex, QRect(5, 2, 2, 1000));
261 // m_model->addMapping(seriesColorHex, QRect(5, 2, 2, 1000));
258 }
262 }
259 else if (m_splineRadioButton->isChecked())
263 else if (m_splineRadioButton->isChecked())
260 {
264 {
261 // m_chart->setAnimationOptions(QChart::NoAnimation);
265 // m_chart->setAnimationOptions(QChart::NoAnimation);
262
266
263 // // series 1
267 // // series 1
264 // m_series = new QSplineSeries;
268 // m_series = new QSplineSeries;
265 // m_series->setModel(m_model);
269 // m_series->setModel(m_model);
266
270
267 // QXYModelMapper *mapper = new QXYModelMapper;
271 // QXYModelMapper *mapper = new QXYModelMapper;
268 // mapper->setMapX(0);
272 // mapper->setMapX(0);
269 // mapper->setMapY(1);
273 // mapper->setMapY(1);
270 // mapper->setFirst(0);
274 // mapper->setFirst(0);
271 // mapper->setCount(-1);
275 // mapper->setCount(-1);
272
276
273 // m_series->setModelMapper(mapper);
277 // m_series->setModelMapper(mapper);
274
278
275 // m_chart->addSeries(m_series);
279 // m_chart->addSeries(m_series);
276 // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
280 // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
277 // m_model->addMapping(seriesColorHex, QRect(0, 0, 2, 1000));
281 // m_model->addMapping(seriesColorHex, QRect(0, 0, 2, 1000));
278
282
279 // // series 2
283 // // series 2
280 // m_series = new QSplineSeries;
284 // m_series = new QSplineSeries;
281 // m_series->setModel(m_model);
285 // m_series->setModel(m_model);
282
286
283 // mapper = new QXYModelMapper;
287 // mapper = new QXYModelMapper;
284 // mapper->setMapX(2);
288 // mapper->setMapX(2);
285 // mapper->setMapY(3);
289 // mapper->setMapY(3);
286 // mapper->setFirst(2);
290 // mapper->setFirst(2);
287 // mapper->setCount(4);
291 // mapper->setCount(4);
288
292
289 // m_series->setModelMapper(mapper);
293 // m_series->setModelMapper(mapper);
290
294
291 // m_chart->addSeries(m_series);
295 // m_chart->addSeries(m_series);
292 // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
296 // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
293 // m_model->addMapping(seriesColorHex, QRect(2, 2, 2, 4));
297 // m_model->addMapping(seriesColorHex, QRect(2, 2, 2, 4));
294
298
295 // // series 3
299 // // series 3
296 // m_series = new QSplineSeries;
300 // m_series = new QSplineSeries;
297 // m_series->setModel(m_model);
301 // m_series->setModel(m_model);
298
302
299 // mapper = new QXYModelMapper;
303 // mapper = new QXYModelMapper;
300 // mapper->setMapX(4);
304 // mapper->setMapX(4);
301 // mapper->setMapY(5);
305 // mapper->setMapY(5);
302 // mapper->setFirst(2);
306 // mapper->setFirst(2);
303 // mapper->setCount(-1);
307 // mapper->setCount(-1);
304
308
305 // m_series->setModelMapper(mapper);
309 // m_series->setModelMapper(mapper);
306
310
307 // m_chart->addSeries(m_series);
311 // m_chart->addSeries(m_series);
308 // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
312 // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
309 // m_model->addMapping(seriesColorHex, QRect(4, 2, 2, 1000));
313 // m_model->addMapping(seriesColorHex, QRect(4, 2, 2, 1000));
310 }
314 }
311 // else if (m_scatterRadioButton->isChecked())
315 // else if (m_scatterRadioButton->isChecked())
312 // {
316 // {
313 // m_chart->setAnimationOptions(QChart::NoAnimation);
317 // m_chart->setAnimationOptions(QChart::NoAnimation);
314
318
315 // // series 1
319 // // series 1
316 // m_series = new QScatterSeries;
320 // m_series = new QScatterSeries;
317 // m_series->setModel(m_model);
321 // m_series->setModel(m_model);
318 // m_series->setModelMapping(0,1, Qt::Vertical);
322 // m_series->setModelMapping(0,1, Qt::Vertical);
319 // // m_series->setModelMappingRange(2, 0);
323 // // m_series->setModelMappingRange(2, 0);
320 // // series->setModelMapping(0,1, Qt::Horizontal);
324 // // series->setModelMapping(0,1, Qt::Horizontal);
321 // m_chart->addSeries(m_series);
325 // m_chart->addSeries(m_series);
322
326
323 // seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper();
327 // seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper();
324 // m_model->addMapping(seriesColorHex, QRect(0, 2, 2, 1000));
328 // m_model->addMapping(seriesColorHex, QRect(0, 2, 2, 1000));
325
329
326 // // series 2
330 // // series 2
327 // m_series = new QScatterSeries;
331 // m_series = new QScatterSeries;
328 // m_series->setModel(m_model);
332 // m_series->setModel(m_model);
329 // m_series->setModelMapping(2,3, Qt::Vertical);
333 // m_series->setModelMapping(2,3, Qt::Vertical);
330 // // m_series->setModelMappingRange(1, 6);
334 // // m_series->setModelMappingRange(1, 6);
331 // // series->setModelMapping(2,3, Qt::Horizontal);
335 // // series->setModelMapping(2,3, Qt::Horizontal);
332 // m_chart->addSeries(m_series);
336 // m_chart->addSeries(m_series);
333
337
334 // seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper();
338 // seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper();
335 // m_model->addMapping(seriesColorHex, QRect(2, 1, 2, 6));
339 // m_model->addMapping(seriesColorHex, QRect(2, 1, 2, 6));
336
340
337 // // series 3
341 // // series 3
338 // m_series = new QScatterSeries;
342 // m_series = new QScatterSeries;
339 // m_series->setModel(m_model);
343 // m_series->setModel(m_model);
340 // m_series->setModelMapping(4,5, Qt::Vertical);
344 // m_series->setModelMapping(4,5, Qt::Vertical);
341 // // series->setModelMapping(4,5, Qt::Horizontal);
345 // // series->setModelMapping(4,5, Qt::Horizontal);
342 // m_chart->addSeries(m_series);
346 // m_chart->addSeries(m_series);
343 // seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper();
347 // seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper();
344 // m_model->addMapping(seriesColorHex, QRect(4, 0, 2, 1000));
348 // m_model->addMapping(seriesColorHex, QRect(4, 0, 2, 1000));
345 // }
349 // }
346 else if (m_pieRadioButton->isChecked())
350 else if (m_pieRadioButton->isChecked())
347 {
351 {
348 m_chart->setAnimationOptions(QChart::SeriesAnimations);
352 m_chart->setAnimationOptions(QChart::SeriesAnimations);
349
353
350 // pie 1
354 // pie 1
351 m_pieSeries = new QPieSeries;
355 m_pieSeries = new QPieSeries;
352
356
353 m_pieMapper = new QVPieModelMapper;
357 m_pieMapper = new QVPieModelMapper;
354 m_pieMapper->setValuesColumn(1);
358 m_pieMapper->setValuesColumn(1);
355 m_pieMapper->setLabelsColumn(7);
359 m_pieMapper->setLabelsColumn(7);
356 m_pieMapper->setSeries(m_pieSeries);
360 m_pieMapper->setSeries(m_pieSeries);
357 m_pieMapper->setModel(m_model);
361 m_pieMapper->setModel(m_model);
358 // m_pieMapper->setFirst(2);
362 m_pieMapper->setFirst(2);
359 // m_pieMapper->setCount(5);
363 // m_pieMapper->setCount(5);
360 // pieSeries->setModelMapper(mapper);
364 // pieSeries->setModelMapper(mapper);
361
365
362 m_pieSeries->setLabelsVisible(true);
366 m_pieSeries->setLabelsVisible(true);
363 m_pieSeries->setPieSize(0.35);
367 m_pieSeries->setPieSize(0.35);
364 m_pieSeries->setHorizontalPosition(0.25);
368 m_pieSeries->setHorizontalPosition(0.25);
365 m_pieSeries->setVerticalPosition(0.35);
369 m_pieSeries->setVerticalPosition(0.35);
366
370
367 m_chart->addSeries(m_pieSeries);
371 m_chart->addSeries(m_pieSeries);
368 seriesColorHex = "#" + QString::number(m_pieSeries->slices().at(m_pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper();
372 seriesColorHex = "#" + QString::number(m_pieSeries->slices().at(m_pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper();
369 m_model->addMapping(seriesColorHex, QRect(1, 2, 1, 50));
373 m_model->addMapping(seriesColorHex, QRect(1, 2, 1, 50));
370
374
371
375
372 // pieSeries->slices().at(0)->setValue(400);
376 // pieSeries->slices().at(0)->setValue(400);
373 // pieSeries->slices().at(0)->setLabel(QString("36"));
377 // pieSeries->slices().at(0)->setLabel(QString("36"));
374
378
375 // pie 2
379 // pie 2
376 m_pieSeries2 = new QPieSeries;
380 m_pieSeries2 = new QPieSeries;
377
381
378 m_pieMapper = new QVPieModelMapper;
382 m_pieMapper = new QVPieModelMapper;
379 m_pieMapper->setValuesColumn(0);
383 m_pieMapper->setValuesColumn(0);
380 m_pieMapper->setLabelsColumn(7);
384 m_pieMapper->setLabelsColumn(7);
381 m_pieMapper->setModel(m_model);
385 m_pieMapper->setModel(m_model);
382 m_pieMapper->setSeries(m_pieSeries2);
386 m_pieMapper->setSeries(m_pieSeries2);
383 // m_pieMapper->setFirst(2);
387 m_pieMapper->setFirst(2);
384
388
385 m_pieSeries2->setLabelsVisible(true);
389 m_pieSeries2->setLabelsVisible(true);
386 m_pieSeries2->setPieSize(0.35);
390 m_pieSeries2->setPieSize(0.35);
387 m_pieSeries2->setHorizontalPosition(0.75);
391 m_pieSeries2->setHorizontalPosition(0.75);
388 m_pieSeries2->setVerticalPosition(0.65);
392 m_pieSeries2->setVerticalPosition(0.65);
389 m_chart->addSeries(m_pieSeries2);
393 m_chart->addSeries(m_pieSeries2);
390 seriesColorHex = "#" + QString::number(m_pieSeries2->slices().at(m_pieSeries2->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper();
394 seriesColorHex = "#" + QString::number(m_pieSeries2->slices().at(m_pieSeries2->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper();
391 m_model->addMapping(seriesColorHex, QRect(0, 2, 1, 1000));
395 m_model->addMapping(seriesColorHex, QRect(0, 2, 1, 1000));
392
396
393 // // pie 3
397 // // pie 3
394 // pieSeries = new QPieSeries;
398 // pieSeries = new QPieSeries;
395 // pieSeries->setModel(m_model);
399 // pieSeries->setModel(m_model);
396 // pieSeries->setModelMapping(2,2, Qt::Vertical);
400 // pieSeries->setModelMapping(2,2, Qt::Vertical);
397 // pieSeries->setLabelsVisible(true);
401 // pieSeries->setLabelsVisible(true);
398 // pieSeries->setPieSize(0.35);
402 // pieSeries->setPieSize(0.35);
399 // pieSeries->setHorizontalPosition(0.5);
403 // pieSeries->setHorizontalPosition(0.5);
400 // pieSeries->setVerticalPosition(0.75);
404 // pieSeries->setVerticalPosition(0.75);
401 // m_chart->addSeries(pieSeries);
405 // m_chart->addSeries(pieSeries);
402 // seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper();
406 // seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper();
403 // m_model->addMapping(seriesColorHex, QRect(2, 0, 1, 1000));
407 // m_model->addMapping(seriesColorHex, QRect(2, 0, 1, 1000));
404
408
405 // // special pie
409 // // special pie
406 // specialPie = new QPieSeries;
410 // specialPie = new QPieSeries;
407 // specialPie->append(17, "1");
411 // specialPie->append(17, "1");
408 // specialPie->append(45, "2");
412 // specialPie->append(45, "2");
409 // specialPie->append(77, "3");
413 // specialPie->append(77, "3");
410 // specialPie->append(37, "4");
414 // specialPie->append(37, "4");
411 // specialPie->append(27, "5");
415 // specialPie->append(27, "5");
412 // specialPie->append(47, "6");
416 // specialPie->append(47, "6");
413 // specialPie->setPieSize(0.35);
417 // specialPie->setPieSize(0.35);
414 // specialPie->setHorizontalPosition(0.8);
418 // specialPie->setHorizontalPosition(0.8);
415 // specialPie->setVerticalPosition(0.75);
419 // specialPie->setVerticalPosition(0.75);
416 // specialPie->setLabelsVisible(true);
420 // specialPie->setLabelsVisible(true);
417 // m_chart->addSeries(specialPie);
421 // m_chart->addSeries(specialPie);
418 }
422 }
419 // else if (m_areaRadioButton->isChecked())
423 // else if (m_areaRadioButton->isChecked())
420 // {
424 // {
421 // m_chart->setAnimationOptions(QChart::NoAnimation);
425 // m_chart->setAnimationOptions(QChart::NoAnimation);
422
426
423 // QLineSeries* upperLineSeries = new QLineSeries;
427 // QLineSeries* upperLineSeries = new QLineSeries;
424 // upperLineSeries->setModel(m_model);
428 // upperLineSeries->setModel(m_model);
425 // upperLineSeries->setModelMapping(0, 1, Qt::Vertical);
429 // upperLineSeries->setModelMapping(0, 1, Qt::Vertical);
426 // // upperLineSeries->setModelMappingRange(1, 5);
430 // // upperLineSeries->setModelMappingRange(1, 5);
427 // QLineSeries* lowerLineSeries = new QLineSeries;
431 // QLineSeries* lowerLineSeries = new QLineSeries;
428 // lowerLineSeries->setModel(m_model);
432 // lowerLineSeries->setModel(m_model);
429 // lowerLineSeries->setModelMapping(2, 3, Qt::Vertical);
433 // lowerLineSeries->setModelMapping(2, 3, Qt::Vertical);
430 // QAreaSeries* areaSeries = new QAreaSeries(upperLineSeries, lowerLineSeries);
434 // QAreaSeries* areaSeries = new QAreaSeries(upperLineSeries, lowerLineSeries);
431 // m_chart->addSeries(areaSeries);
435 // m_chart->addSeries(areaSeries);
432 // seriesColorHex = "#" + QString::number(areaSeries->brush().color().rgb(), 16).right(6).toUpper();
436 // seriesColorHex = "#" + QString::number(areaSeries->brush().color().rgb(), 16).right(6).toUpper();
433 // m_model->addMapping(seriesColorHex, QRect(0, 1, 2, 5));
437 // m_model->addMapping(seriesColorHex, QRect(0, 1, 2, 5));
434 // m_model->addMapping(seriesColorHex, QRect(2, 0, 2, 1000));
438 // m_model->addMapping(seriesColorHex, QRect(2, 0, 2, 1000));
435 // }
439 // }
436 else if (m_barRadioButton->isChecked())
440 else if (m_barRadioButton->isChecked())
437 {
441 {
438 // m_chart->setAnimationOptions(QChart::SeriesAnimations);
442 // m_chart->setAnimationOptions(QChart::SeriesAnimations);
439
443
440 // QGroupedBarSeries* barSeries = new QGroupedBarSeries();
444 // QGroupedBarSeries* barSeries = new QGroupedBarSeries();
441 // barSeries->setCategories(QStringList());
445 // barSeries->setCategories(QStringList());
442 // barSeries->setModel(m_model);
446 // barSeries->setModel(m_model);
443 // // barSeries->setModelMappingRange(2, 5);
447 // // barSeries->setModelMappingRange(2, 5);
444 //// barSeries->setModelMapping(5, 2, 4, Qt::Vertical);
448 //// barSeries->setModelMapping(5, 2, 4, Qt::Vertical);
445
449
446 // QBarModelMapper *mapper = new QBarModelMapper;
450 // QBarModelMapper *mapper = new QBarModelMapper;
447 // mapper->setMapCategories(5);
451 // mapper->setMapCategories(5);
448 // mapper->setMapBarBottom(2);
452 // mapper->setMapBarBottom(2);
449 // mapper->setMapBarTop(4);
453 // mapper->setMapBarTop(4);
450 // barSeries->setModelMapper(mapper);
454 // barSeries->setModelMapper(mapper);
451 // m_chart->addSeries(barSeries);
455 // m_chart->addSeries(barSeries);
452 // QList<QBarSet*> barsets = barSeries->barSets();
456 // QList<QBarSet*> barsets = barSeries->barSets();
453 // for (int i = 0; i < barsets.count(); i++) {
457 // for (int i = 0; i < barsets.count(); i++) {
454 // seriesColorHex = "#" + QString::number(barsets.at(i)->brush().color().rgb(), 16).right(6).toUpper();
458 // seriesColorHex = "#" + QString::number(barsets.at(i)->brush().color().rgb(), 16).right(6).toUpper();
455 // m_model->addMapping(seriesColorHex, QRect(2 + i, 0, 1, 1000));
459 // m_model->addMapping(seriesColorHex, QRect(2 + i, 0, 1, 1000));
456 // }
460 // }
457 }
461 }
458
462
459
463
460 if (!m_barRadioButton->isChecked()) {
464 if (!m_barRadioButton->isChecked()) {
461 m_chart->axisX()->setRange(0, 500);
465 m_chart->axisX()->setRange(0, 500);
462 m_chart->axisY()->setRange(0, 220);
466 m_chart->axisY()->setRange(0, 220);
463 }
467 }
464 m_chart->legend()->setVisible(true);
468 m_chart->legend()->setVisible(true);
465
469
466 // repaint table view colors
470 // repaint table view colors
467 m_tableView->repaint();
471 m_tableView->repaint();
468 m_tableView->setFocus();
472 m_tableView->setFocus();
469 }
473 }
470 }
474 }
471
475
472 void TableWidget::testPie()
476 void TableWidget::testPie()
473 {
477 {
474 // m_pieMapper->setCount(-1);
478 // m_pieMapper->setCount(-1);
475 QPieSlice *slice = new QPieSlice("Hehe", 145);
479 QPieSlice *slice = new QPieSlice("Hehe", 145);
476 slice->setLabelVisible();
480 slice->setLabelVisible();
477 m_pieSeries->append(slice);
481 m_pieSeries->append(slice);
478
482
479 slice = new QPieSlice("Hoho", 34);
483 slice = new QPieSlice("Hoho", 34);
480 slice->setLabelVisible();
484 slice->setLabelVisible();
481 m_pieSeries->append(slice);
485 m_pieSeries->append(slice);
482 // m_series->modelMapper()->setMapX(4);
486 // m_series->modelMapper()->setMapX(4);
483 // m_tableView->setColumnWidth(10, 250);
487 // m_tableView->setColumnWidth(10, 250);
484 // if (specialPie) {
488 // if (specialPie) {
485 // specialPie->remove(specialPie->slices().at(2));
489 // specialPie->remove(specialPie->slices().at(2));
486 // // specialPie->insert(4, new QPieSlice(45, "Hello"));//specialPie->slices.at(2));
490 // // specialPie->insert(4, new QPieSlice(45, "Hello"));//specialPie->slices.at(2));
487 // specialPie->append(4, "heloo");
491 // specialPie->append(4, "heloo");
488 // }
492 // }
489 }
493 }
490
494
491 void TableWidget::testPie2()
495 void TableWidget::testPie2()
492 {
496 {
493 QPieSlice *slice;
497 QPieSlice *slice;
494 if (m_pieSeries->count() > 0) {
498 if (m_pieSeries->count() > 0) {
495 slice = m_pieSeries->slices().last();
499 slice = m_pieSeries->slices().last();
496 m_pieSeries->remove(slice);
500 m_pieSeries->remove(slice);
497 }
501 }
498
502
499 if (m_pieSeries->count() > 0) {
503 if (m_pieSeries->count() > 0) {
500 slice = m_pieSeries->slices().first();
504 slice = m_pieSeries->slices().first();
501 m_pieSeries->remove(slice);
505 m_pieSeries->remove(slice);
502 }
506 }
503 }
507 }
504
508
505 void TableWidget::testPie3()
509 void TableWidget::testPie3()
506 {
510 {
507 QPieSlice *slice;
511 QPieSlice *slice;
508 if (m_pieSeries->count() > 0) {
512 if (m_pieSeries->count() > 0) {
509 slice = m_pieSeries->slices().last();
513 slice = m_pieSeries->slices().last();
510 slice->setLabel("Dalej");
514 slice->setLabel("Dalej");
511 slice->setValue(222);
515 slice->setValue(222);
512 }
516 }
513
517
514 if (m_pieSeries->count() > 0) {
518 if (m_pieSeries->count() > 0) {
515 slice = m_pieSeries->slices().first();
519 slice = m_pieSeries->slices().first();
516 slice->setLabel("Prawie");
520 slice->setLabel("Prawie");
517 slice->setValue(111);
521 slice->setValue(111);
518 }
522 }
519 }
523 }
520
524
525 void TableWidget::testXY()
526 {
527 // if (m_series->type() != QAbstractSeries::SeriesTypeLine) {
528 // m_series->append(QPointF(150, 75));
529 // }
530
531 if (m_series->count() > 0) {
532 m_series->remove(m_series->points().last());
533 }
534 }
535
521 TableWidget::~TableWidget()
536 TableWidget::~TableWidget()
522 {
537 {
523
538
524 }
539 }
@@ -1,78 +1,80
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef TABLEWIDGET_H
21 #ifndef TABLEWIDGET_H
22 #define TABLEWIDGET_H
22 #define TABLEWIDGET_H
23
23
24 #include <QtGui/QWidget>
24 #include <QtGui/QWidget>
25 //#include <QChartGlobal>
25 //#include <QChartGlobal>
26 #include "qchartview.h"
26 #include "qchartview.h"
27 //#include "qxyseries.h"
27 //#include "qxyseries.h"
28 #include <QPieSeries>
28 #include <QPieSeries>
29 #include <QVPieModelMapper>
29 #include <QVPieModelMapper>
30
30
31 class CustomTableModel;
31 class CustomTableModel;
32 class QTableView;
32 class QTableView;
33 class QRadioButton;
33 class QRadioButton;
34 class QSpinBox;
34 class QSpinBox;
35
35
36 QTCOMMERCIALCHART_USE_NAMESPACE
36 QTCOMMERCIALCHART_USE_NAMESPACE
37
37
38 class TableWidget : public QWidget
38 class TableWidget : public QWidget
39 {
39 {
40 Q_OBJECT
40 Q_OBJECT
41
41
42 public:
42 public:
43 TableWidget(QWidget *parent = 0);
43 TableWidget(QWidget *parent = 0);
44 ~TableWidget();
44 ~TableWidget();
45
45
46
46
47 public slots:
47 public slots:
48 void addRowAbove();
48 void addRowAbove();
49 void addRowBelow();
49 void addRowBelow();
50 void removeRow();
50 void removeRow();
51 void addColumnRight();
51 void addColumnRight();
52 void removeColumn();
52 void removeColumn();
53 void updateChartType(bool toggle);
53 void updateChartType(bool toggle);
54 void testPie();
54 void testPie();
55 void testPie2();
55 void testPie2();
56 void testPie3();
56 void testPie3();
57
57
58 void testXY();
59
58 private:
60 private:
59 QChartView* m_chartView;
61 QChartView* m_chartView;
60 QChart* m_chart;
62 QChart* m_chart;
61 QXYSeries* m_series;
63 QXYSeries* m_series;
62 CustomTableModel* m_model;
64 CustomTableModel* m_model;
63 QTableView* m_tableView;
65 QTableView* m_tableView;
64 QRadioButton* m_lineRadioButton;
66 QRadioButton* m_lineRadioButton;
65 QRadioButton* m_splineRadioButton;
67 QRadioButton* m_splineRadioButton;
66 QRadioButton* m_scatterRadioButton;
68 QRadioButton* m_scatterRadioButton;
67 QRadioButton* m_pieRadioButton;
69 QRadioButton* m_pieRadioButton;
68 QRadioButton* m_areaRadioButton;
70 QRadioButton* m_areaRadioButton;
69 QRadioButton* m_barRadioButton;
71 QRadioButton* m_barRadioButton;
70 QSpinBox* m_linesCountSpinBox;
72 QSpinBox* m_linesCountSpinBox;
71 QVPieModelMapper *m_pieMapper;
73 QVPieModelMapper *m_pieMapper;
72 QPieSeries* m_pieSeries;
74 QPieSeries* m_pieSeries;
73 QVPieModelMapper *m_pieMapper2;
75 QVPieModelMapper *m_pieMapper2;
74 QPieSeries* m_pieSeries2;
76 QPieSeries* m_pieSeries2;
75 // QPieSeries* specialPie;
77 // QPieSeries* specialPie;
76 };
78 };
77
79
78 #endif // TABLEWIDGET_H
80 #endif // TABLEWIDGET_H
General Comments 0
You need to be logged in to leave comments. Login now