##// END OF EJS Templates
XYSeries: added support for limited mapping area
Marek Rosa -
r734:cfecc74c9bfa
parent child
Show More
@@ -1,22 +1,25
1 1 #include "customtablemodel.h"
2 2 #include <QVector>
3 #include <QTime>
3 4
4 5 CustomTableModel::CustomTableModel(QObject *parent) :
5 6 QAbstractTableModel(parent)
6 7 {
7 // m_points.append(QPointF(10, 50));
8 // m_labels.append("Apples");
9 // m_points.append(QPointF(60, 70));
10 // m_labels.append("Oranges");
11 // m_points.append(QPointF(110, 50));
12 // m_labels.append("Bananas");
13 // m_points.append(QPointF(140, 40));
14 // m_labels.append("Lemons");
15 // m_points.append(QPointF(200, 150));
16 // m_labels.append("Plums");
17 // m_points.append(QPointF(225, 75));
8 // m_points.append(QPointF(10, 50));
9 // m_labels.append("Apples");
10 // m_points.append(QPointF(60, 70));
11 // m_labels.append("Oranges");
12 // m_points.append(QPointF(110, 50));
13 // m_labels.append("Bananas");
14 // m_points.append(QPointF(140, 40));
15 // m_labels.append("Lemons");
16 // m_points.append(QPointF(200, 150));
17 // m_labels.append("Plums");
18 // m_points.append(QPointF(225, 75));
18 19 // m_labels.append("Pearls");
19 20
21 qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
22
20 23 // m_data
21 24 for (int i = 0; i < 6; i++)
22 25 {
@@ -168,10 +171,17 bool CustomTableModel::insertRows ( int row, int count, const QModelIndex & pare
168 171 dataVec->replace(k, m_data[row - 1]->at(k) + qrand()%qMax(1, difference));
169 172 }
170 173 else
171 dataVec->replace(k, qrand()%20);
174 dataVec->replace(k, qrand()%40 + 10);
172 175 }
173 176 else
174 dataVec->replace(k, m_data[row - 1]->at(k) + qrand()%20);
177 if (row - 1 >= 0)
178 {
179 dataVec->replace(k, m_data[row - 1]->at(k) + qrand()%40 + 10);
180 }
181 else
182 {
183 dataVec->replace(k, qrand()%40 + 10);
184 }
175 185 }
176 186 else
177 187 dataVec->replace(k, qrand()%100);
@@ -193,7 +203,7 bool CustomTableModel::removeRows ( int row, int count, const QModelIndex & pare
193 203 beginRemoveRows(parent, row, row + count - 1);
194 204 for (int i = row; i < row + count; i++)
195 205 {
196 // m_points.removeAt(row);
206 // m_points.removeAt(row);
197 207 QVector<qreal>* item = m_data.at(row);
198 208 m_data.removeAt(row);
199 209 delete item;
@@ -126,6 +126,7 void TableWidget::updateChartType()
126 126 series = new QLineSeries;
127 127 series->setModel(m_model);
128 128 series->setModelMapping(0,1, Qt::Vertical);
129 series->setModelMappingShift(1, 4);
129 130 // series->setModelMapping(0,1, Qt::Horizontal);
130 131 chartView->addSeries(series);
131 132
@@ -136,19 +137,20 void TableWidget::updateChartType()
136 137 // series->setModelMapping(2,3, Qt::Horizontal);
137 138 chartView->addSeries(series);
138 139
139 // series 3
140 series = new QLineSeries;
141 series->setModel(m_model);
142 series->setModelMapping(4,5, Qt::Vertical);
143 // series->setModelMapping(4,5, Qt::Horizontal);
144 chartView->addSeries(series);
140 // // series 3
141 // series = new QLineSeries;
142 // series->setModel(m_model);
143 // series->setModelMapping(4,5, Qt::Vertical);
144 //// series->setModelMapping(4,5, Qt::Horizontal);
145 // chartView->addSeries(series);
145 146 }
146 147 else if (splineRadioButton->isChecked())
147 148 {
148 149 // series 1
149 150 series = new QSplineSeries;
150 series->setModel(m_model);
151 series->setModelMapping(0,1, Qt::Vertical);
151 series->setModel(m_model);
152 series->setModelMapping(0,1, Qt::Vertical);
153 series->setModelMappingShift(1, 4);
152 154 // series->setModelMapping(0,1, Qt::Horizontal);
153 155 chartView->addSeries(series);
154 156
@@ -41,6 +41,8 QBarSeries::QBarSeries(QBarCategories categories, QObject *parent)
41 41 m_mapCategories = -1;
42 42 m_mapBarBottom = -1;
43 43 m_mapBarTop = -1;
44 m_mapFirst = 0;
45 m_mapCount = 0;
44 46 m_mapOrientation = Qt::Vertical;
45 47 }
46 48
@@ -234,6 +236,8 bool QBarSeries::setModel(QAbstractItemModel* model)
234 236 m_mapCategories = -1;
235 237 m_mapBarBottom = -1;
236 238 m_mapBarTop = -1;
239 m_mapFirst = 0;
240 m_mapCount = 0;
237 241 m_mapOrientation = Qt::Vertical;
238 242 }
239 243
@@ -258,17 +262,20 void QBarSeries::setModelMapping(int categories, int bottomBoundry, int topBound
258 262 m_mapCategories = categories;
259 263 m_mapBarBottom = bottomBoundry;
260 264 m_mapBarTop = topBoundry;
265 m_mapFirst = 1;
261 266 m_mapOrientation = orientation;
262 267
263 268 // connect the signals
264 269 if (m_mapOrientation == Qt::Vertical)
265 270 {
271 m_mapCount = m_model->rowCount();
266 272 connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex, QModelIndex)));
267 273 connect(m_model,SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(modelDataAdded(QModelIndex,int,int)));
268 274 connect(m_model, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(modelDataRemoved(QModelIndex,int,int)));
269 275 }
270 276 else
271 277 {
278 m_mapCount = m_model->columnCount();
272 279 connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex, QModelIndex)));
273 280 connect(m_model,SIGNAL(columnsInserted(QModelIndex, int, int)), this, SLOT(modelDataAdded(QModelIndex,int,int)));
274 281 connect(m_model, SIGNAL(columnsRemoved(QModelIndex, int, int)), this, SLOT(modelDataRemoved(QModelIndex,int,int)));
@@ -280,14 +287,14 void QBarSeries::setModelMapping(int categories, int bottomBoundry, int topBound
280 287 if (m_mapOrientation == Qt::Vertical)
281 288 {
282 289 QStringList categories;
283 for (int k = 0; k < m_model->rowCount(); k++)
290 for (int k = m_mapFirst; k < m_mapFirst + m_mapCount; k++)
284 291 categories << m_model->data(m_model->index(k, m_mapCategories), Qt::DisplayRole).toString();
285 292 mModel = new BarChartModel(categories, this);
286 293
287 294 for (int i = m_mapBarBottom; i <= m_mapBarTop; i++)
288 295 {
289 296 QBarSet* barSet = new QBarSet(QString("Column: %1").arg(i + 1));
290 for(int m = 0; m < m_model->rowCount(); m++)
297 for(int m = m_mapFirst; m < m_mapFirst + m_mapCount; m++)
291 298 *barSet << m_model->data(m_model->index(m, i), Qt::DisplayRole).toDouble();
292 299 addBarSet(barSet);
293 300 }
@@ -295,37 +302,41 void QBarSeries::setModelMapping(int categories, int bottomBoundry, int topBound
295 302 else
296 303 {
297 304 QStringList categories;
298 for (int k = 0; k < m_model->columnCount(); k++)
305 for (int k = m_mapFirst; k < m_mapFirst + m_mapCount; k++)
299 306 categories << m_model->data(m_model->index(m_mapCategories, k), Qt::DisplayRole).toString();
300 307 mModel = new BarChartModel(categories, this);
301 308
302 309 for (int i = m_mapBarBottom; i <= m_mapBarTop; i++)
303 310 {
304 311 QBarSet* barSet = new QBarSet(QString("Row: %1").arg(i + 1));
305 for(int m = 0; m < m_model->columnCount(); m++)
312 for(int m = m_mapFirst; m < m_mapFirst + m_mapCount; m++)
306 313 *barSet << m_model->data(m_model->index(i, m), Qt::DisplayRole).toDouble();
307 314 addBarSet(barSet);
308 315 }
309 316 }
310 317 }
311 318
319 void QBarSeries::setModelMappingShift(int first, int count)
320 {
321 m_mapFirst = first;
322 m_mapCount = count;
323 }
324
312 325 void QBarSeries::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight)
313 326 {
314 327 Q_UNUSED(bottomRight)
315 328
316 329 if (m_mapOrientation == Qt::Vertical)
317 330 {
318 if (topLeft.column() >= m_mapBarBottom && topLeft.column() <= m_mapBarTop)
319 barsetAt(topLeft.column() - m_mapBarBottom)->setValue(topLeft.row(), m_model->data(topLeft, Qt::DisplayRole).toDouble());
320 // else if (topLeft.column() == m_mapCategories)
321 // slices().at(topLeft.row())->setLabel(m_model->data(topLeft, Qt::DisplayRole).toString());
331 // model update is relevant to BarSeries if the change was made to the part of the model that was mapped to BarSeries
332 if (topLeft.column() >= m_mapBarBottom && topLeft.column() <= m_mapBarTop && topLeft.row() >= m_mapFirst && topLeft.row() < m_mapFirst + m_mapCount)
333 barsetAt(topLeft.column() - m_mapBarBottom)->setValue(topLeft.row() - m_mapFirst, m_model->data(topLeft, Qt::DisplayRole).toDouble());
322 334 }
323 335 else
324 336 {
325 if (topLeft.row() >= m_mapBarBottom && topLeft.row() <= m_mapBarTop)
326 barsetAt(topLeft.row() - m_mapBarBottom)->setValue(topLeft.column(), m_model->data(topLeft, Qt::DisplayRole).toDouble());
327 // else if (topLeft.row() == m_mapCategories)
328 // slices().at(topLeft.column())->setLabel(m_model->data(topLeft, Qt::DisplayRole).toString());
337 // model update is relevant to BarSeries if the change was made to the part of the model that was mapped to BarSeries
338 if (topLeft.row() >= m_mapBarBottom && topLeft.row() <= m_mapBarTop && topLeft.column() >= m_mapFirst && topLeft.column() < m_mapFirst + m_mapCount)
339 barsetAt(topLeft.row() - m_mapBarBottom)->setValue(topLeft.column() - m_mapFirst, m_model->data(topLeft, Qt::DisplayRole).toDouble());
329 340 }
330 341 }
331 342
@@ -333,18 +344,18 void QBarSeries::modelDataAdded(QModelIndex /*parent*/, int start, int /*end*/)
333 344 {
334 345 if (m_mapOrientation == Qt::Vertical)
335 346 {
336 insertCategory(start, QString("Row: %1").arg(start + 1));
347 insertCategory(start - m_mapFirst, QString("Row: %1").arg(start + 1));
337 348 for (int i = 0; i <= m_mapBarTop - m_mapBarBottom; i++)
338 349 {
339 barsetAt(i)->insertValue(start, m_model->data(m_model->index(start, i), Qt::DisplayRole).toDouble());
350 barsetAt(i)->insertValue(start - m_mapFirst, m_model->data(m_model->index(start, i), Qt::DisplayRole).toDouble());
340 351 }
341 352 }
342 353 else
343 354 {
344 insertCategory(start, QString("Column: %1").arg(start + 1));
355 insertCategory(start - m_mapFirst, QString("Column: %1").arg(start + 1));
345 356 for (int i = 0; i <= m_mapBarTop - m_mapBarBottom; i++)
346 357 {
347 barsetAt(i)->insertValue(start, m_model->data(m_model->index(i, start), Qt::DisplayRole).toDouble());
358 barsetAt(i)->insertValue(start - m_mapFirst, m_model->data(m_model->index(i, start), Qt::DisplayRole).toDouble());
348 359 }
349 360 }
350 361 emit restructuredBar(1);
@@ -352,10 +363,10 void QBarSeries::modelDataAdded(QModelIndex /*parent*/, int start, int /*end*/)
352 363
353 364 void QBarSeries::modelDataRemoved(QModelIndex /*parent*/, int start, int /*end*/)
354 365 {
355 removeCategory(start);
366 removeCategory(start - m_mapFirst);
356 367 for (int i = 0; i <= m_mapBarTop - m_mapBarBottom; i++)
357 368 {
358 barsetAt(i)->removeValue(start);
369 barsetAt(i)->removeValue(start - m_mapFirst);
359 370 }
360 371 emit restructuredBar(1);
361 372 }
@@ -35,6 +35,7 public:
35 35 bool setModel(QAbstractItemModel* model);
36 36 QAbstractItemModel* modelExt() {return m_model;}
37 37 void setModelMapping(int categories, int bottomBoundry, int topBoundry, Qt::Orientation orientation = Qt::Vertical);
38 void setModelMappingShift(int first, int count);
38 39
39 40 public:
40 41 // TODO: Functions below this are not part of api and will be moved
@@ -87,6 +88,8 protected:
87 88 int m_mapCategories;
88 89 int m_mapBarBottom;
89 90 int m_mapBarTop;
91 int m_mapFirst;
92 int m_mapCount;
90 93 Qt::Orientation m_mapOrientation;
91 94 };
92 95
@@ -147,6 +147,12 bool QSplineSeries::setModel(QAbstractItemModel* model)
147 147 void QSplineSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation)
148 148 {
149 149 QLineSeries::setModelMapping(modelX, modelY, orientation);
150 // calculateControlPoints();
151 }
152
153 void QSplineSeries::setModelMappingShift(int first, int count)
154 {
155 QLineSeries::setModelMappingShift(first, count);
150 156 calculateControlPoints();
151 157 }
152 158
@@ -22,6 +22,7 public:
22 22 bool setModel(QAbstractItemModel* model);
23 23
24 24 void setModelMapping(int modelX, int modelY, Qt::Orientation orientation = Qt::Vertical);
25 void setModelMappingShift(int first, int count);
25 26
26 27 // TODO: allow the user to set custom control points
27 28 // void setCustomControlPoints(QList<QPointsF> controlPoints);
@@ -52,6 +52,9 QXYSeries::QXYSeries(QObject* parent):QSeries(parent)
52 52 {
53 53 m_mapX = -1;
54 54 m_mapY = -1;
55 m_mapFirst = 0;
56 m_mapCount = 0;
57 m_mapLimited = false;
55 58 m_mapOrientation = Qt::Vertical;
56 59 // m_mapYOrientation = Qt::Vertical;
57 60 }
@@ -171,10 +174,10 qreal QXYSeries::x(int pos) const
171 174 if (m_model)
172 175 if (m_mapOrientation == Qt::Vertical)
173 176 // consecutive data is read from model's column
174 return m_model->data(m_model->index(pos, m_mapX), Qt::DisplayRole).toDouble();
177 return m_model->data(m_model->index(pos + m_mapFirst, m_mapX), Qt::DisplayRole).toDouble();
175 178 else
176 179 // consecutive data is read from model's row
177 return m_model->data(m_model->index(m_mapX, pos), Qt::DisplayRole).toDouble();
180 return m_model->data(m_model->index(m_mapX, pos + m_mapFirst), Qt::DisplayRole).toDouble();
178 181 else
179 182 // model is not specified, return the data from series' internal data store
180 183 return m_x.at(pos);
@@ -188,10 +191,10 qreal QXYSeries::y(int pos) const
188 191 if (m_model)
189 192 if (m_mapOrientation == Qt::Vertical)
190 193 // consecutive data is read from model's column
191 return m_model->data(m_model->index(pos, m_mapY), Qt::DisplayRole).toDouble();
194 return m_model->data(m_model->index(pos + m_mapFirst, m_mapY), Qt::DisplayRole).toDouble();
192 195 else
193 196 // consecutive data is read from model's row
194 return m_model->data(m_model->index(m_mapY, pos), Qt::DisplayRole).toDouble();
197 return m_model->data(m_model->index(m_mapY, pos + m_mapFirst), Qt::DisplayRole).toDouble();
195 198 else
196 199 // model is not specified, return the data from series' internal data store
197 200 return m_y.at(pos);
@@ -206,11 +209,23 int QXYSeries::count() const
206 209
207 210 if (m_model) {
208 211 if (m_mapOrientation == Qt::Vertical)
209 // data is in a column, so return the number of items in single column
210 return m_model->rowCount();
212 {
213 // data is in a column. Return the number of mapped items if the model's column have enough items
214 // or the number of items that can be mapped
215 if (m_mapLimited)
216 return qMin(m_mapCount, qMax(m_model->rowCount() - m_mapFirst, 0));
217 else
218 return qMax(m_model->rowCount() - m_mapFirst, 0);
219 }
211 220 else
212 // data is in a row, so return the number of items in single row
213 return m_model->columnCount();
221 {
222 // data is in a row. Return the number of mapped items if the model's row have enough items
223 // or the number of items that can be mapped
224 if (m_mapLimited)
225 return qMin(m_mapCount, qMax(m_model->columnCount() - m_mapFirst, 0));
226 else
227 return qMax(m_model->columnCount() - m_mapFirst, 0);
228 }
214 229 }
215 230
216 231 // model is not specified, return the number of points in the series internal data store
@@ -286,23 +301,148 void QXYSeries::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight)
286 301 Q_UNUSED(bottomRight)
287 302
288 303 if (m_mapOrientation == Qt::Vertical)
289 emit pointReplaced(topLeft.row());
304 {
305 if (topLeft.row() >= m_mapFirst && (!m_mapLimited || topLeft.row() < m_mapFirst + m_mapCount))
306 emit pointReplaced(topLeft.row() - m_mapFirst);
307 }
308 else
309 {
310 if (topLeft.column() >= m_mapFirst && (!m_mapLimited || topLeft.column() < m_mapFirst + m_mapCount))
311 emit pointReplaced(topLeft.column() - m_mapFirst);
312 }
313 }
314
315 void QXYSeries::modelDataAboutToBeAdded(QModelIndex parent, int start, int end)
316 {
317 Q_UNUSED(parent)
318 // Q_UNUSED(end)
319
320 if (m_mapLimited)
321 {
322 if (start >= m_mapFirst + m_mapCount)
323 // the added data is below mapped area
324 // therefore it has no relevance
325 return;
326 else
327 {
328 // the added data is in the mapped area or before it and update is needed
329
330 // check how many mapped items there is currently (before new items are added)
331 // if the number of items currently is equal the m_mapCount then some needs to be removed from xychartitem
332 // internal storage before new ones can be added
333 if (m_mapCount == count())
334 for (int i = 0; i < qMin(count(), end - start + 1); i++)
335 emit pointRemoved(count() - 1 - i);
336 }
337 }
290 338 else
291 emit pointReplaced(topLeft.column());
339 {
340 // map is not limited (it includes all the items starting from m_mapFirst till the end of model)
341 // nothing to do
342 // emit pointAdded(qMax(start - m_mapFirst, 0));
343 }
292 344 }
293 345
294 346 void QXYSeries::modelDataAdded(QModelIndex parent, int start, int end)
295 347 {
296 348 Q_UNUSED(parent)
297 Q_UNUSED(end)
298 emit pointAdded(start);
349 // Q_UNUSED(end)
350
351 if (m_mapLimited)
352 {
353 if (start >= m_mapFirst + m_mapCount)
354 // the added data is below mapped area
355 // therefore it has no relevance
356 return;
357 else
358 {
359 // the added data is in the mapped area or before it
360 // update needed
361 if (count() > 0)
362 for (int i = 0; i < qMin(m_mapCount, end - start + 1); i++)
363 emit pointAdded(qMax(start + i - m_mapFirst, 0));
364 }
365 }
366 else
367 {
368 // map is not limited (it included all the items starting from m_mapFirst till the end of model)
369 for (int i = 0; i < end - start + 1; i++)
370 emit pointAdded(qMax(start + i - m_mapFirst, 0));
371 }
372 }
373
374 void QXYSeries::modelDataAboutToBeRemoved(QModelIndex parent, int start, int end)
375 {
376 Q_UNUSED(parent)
377 // Q_UNUSED(end)
378
379 if (m_mapLimited)
380 {
381 if (start >= m_mapFirst + m_mapCount)
382 // the removed data is below mapped area
383 // therefore it has no relevance
384 return;
385 else
386 {
387 // the removed data is in the mapped area or before it
388 // update needed
389 int itemsToRemove = qMin(count(), end - start + 1);
390 tempItemsRemoved = itemsToRemove;
391 int z = count();
392 z = z;
393 // if (itemsToRemove > 0)
394 // {
395 for (int i = 0; i < itemsToRemove; i++)
396 emit pointRemoved(qMax(start - m_mapFirst, 0));
397 }
398 }
399 else
400 {
401 // map is not limited (it included all the items starting from m_mapFirst till the end of model)
402 for (int i = 0; i < end - start + 1; i++)
403 emit pointRemoved(qMax(start - m_mapFirst, 0));
404 }
299 405 }
300 406
301 407 void QXYSeries::modelDataRemoved(QModelIndex parent, int start, int end)
302 408 {
303 409 Q_UNUSED(parent)
304 410 Q_UNUSED(end)
305 emit pointRemoved(start);
411
412 // how many items there were before data was removed
413 // int oldCount = count() - 1;
414
415 if (m_mapLimited)
416 {
417 if (start >= m_mapFirst + m_mapCount)
418 // the removed data is below mapped area
419 // therefore it has no relevance
420 return;
421 else
422 {
423 // if there are excess items available (below the map) use them to repopulate mapped area
424 int extraItemsAvailable = 0;
425 if (m_mapOrientation == Qt::Vertical)
426 {
427 extraItemsAvailable = qMax(m_model->rowCount() - m_mapFirst, 0);
428 }
429 else
430 {
431 extraItemsAvailable = qMax(m_model->columnCount() - m_mapFirst, 0);
432 }
433
434 // int extraItemsNeeded = qMin(extraItemsAvailable, tempItemsRemoved);
435 for (int k = 0; k < tempItemsRemoved; k++)
436 if (start - m_mapFirst + k < extraItemsAvailable)
437 {
438 emit pointAdded(count() - m_mapFirst + k);
439 }
440 }
441 }
442 else
443 {
444 // emit pointRemoved(qMax(start - m_mapFirst, 0));
445 }
306 446 }
307 447
308 448 bool QXYSeries::setModel(QAbstractItemModel* model) {
@@ -313,6 +453,9 bool QXYSeries::setModel(QAbstractItemModel* model) {
313 453 disconnect(m_model, 0, this, 0);
314 454 m_mapX = -1;
315 455 m_mapY = -1;
456 m_mapFirst = 0;
457 m_mapCount = 0;
458 m_mapLimited = false;
316 459 m_mapOrientation = Qt::Vertical;
317 460 }
318 461
@@ -335,26 +478,39 void QXYSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientat
335 478 return;
336 479 m_mapX = modelX;
337 480 m_mapY = modelY;
481 m_mapFirst = 0;
338 482 m_mapOrientation = orientation;
339 483 if (m_mapOrientation == Qt::Vertical)
340 484 {
485 // m_mapCount = m_model->rowCount();
341 486 connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex, QModelIndex)));
487 connect(m_model,SIGNAL(rowsAboutToBeInserted(QModelIndex, int, int)), this, SLOT(modelDataAboutToBeAdded(QModelIndex,int,int)));
342 488 connect(m_model,SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(modelDataAdded(QModelIndex,int,int)));
489 connect(m_model, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)), this, SLOT(modelDataAboutToBeRemoved(QModelIndex,int,int)));
343 490 connect(m_model, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(modelDataRemoved(QModelIndex,int,int)));
344 491 }
345 492 else
346 493 {
494 // m_mapCount = m_model->columnCount();
347 495 connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex, QModelIndex)));
496 connect(m_model,SIGNAL(columnsAboutToBeInserted(QModelIndex, int, int)), this, SLOT(modelDataAboutToBeAdded(QModelIndex,int,int)));
348 497 connect(m_model,SIGNAL(columnsInserted(QModelIndex, int, int)), this, SLOT(modelDataAdded(QModelIndex,int,int)));
498 connect(m_model, SIGNAL(columnsAboutToBeRemoved(QModelIndex, int, int)), this, SLOT(modelDataAboutToBeRemoved(QModelIndex,int,int)));
349 499 connect(m_model, SIGNAL(columnsRemoved(QModelIndex, int, int)), this, SLOT(modelDataRemoved(QModelIndex,int,int)));
350 500 }
351 501 }
352 502
353 //void QXYSeries::setModelMappingY(int modelLineIndex, Qt::Orientation orientation)
354 //{
355 // m_mapY = modelLineIndex;
356 // m_mapYOrientation = orientation;
357 //}
503 void QXYSeries::setModelMappingShift(int first, int count)
504 {
505 m_mapFirst = first;
506 if (count == 0)
507 m_mapLimited = false;
508 else
509 {
510 m_mapCount = count;
511 m_mapLimited = true;
512 }
513 }
358 514
359 515 #include "moc_qxyseries.cpp"
360 516
@@ -44,11 +44,13 public:
44 44 QAbstractItemModel* model() {return m_model;}
45 45
46 46 virtual void setModelMapping(int modelX, int modelY, Qt::Orientation orientation = Qt::Vertical);
47 // void setModelMappingY(int modelLineIndex, Qt::Orientation orientation = Qt::Vertical);
47 virtual void setModelMappingShift(int first, int count = 0);
48 48
49 49 private slots:
50 50 void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight);
51 void modelDataAboutToBeAdded(QModelIndex parent, int start, int end);
51 52 void modelDataAdded(QModelIndex parent, int start, int end);
53 void modelDataAboutToBeRemoved(QModelIndex parent, int start, int end);
52 54 void modelDataRemoved(QModelIndex parent, int start, int end);
53 55
54 56 signals:
@@ -65,11 +67,13 protected:
65 67 QPen m_pen;
66 68 QBrush m_brush;
67 69
68 // QAbstractItemModel* m_model;
69 int m_mapX;
70 Qt::Orientation m_mapOrientation;
70 int m_mapX;
71 71 int m_mapY;
72 // Qt::Orientation m_mapYOrientation;
72 int m_mapFirst;
73 int m_mapCount;
74 bool m_mapLimited;
75 Qt::Orientation m_mapOrientation;
76 int tempItemsRemoved;
73 77 };
74 78
75 79 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now