##// END OF EJS Templates
Update candlestick chart model mappers API...
Alexander Mishin -
r2897:f5164ec8f20d dev
parent child
Show More
@@ -57,7 +57,7 CandlestickChartItem::CandlestickChartItem(QCandlestickSeries *series, QGraphics
57 57
58 58 setZValue(ChartPresenter::CandlestickSeriesZValue);
59 59
60 handleCandlestickSetsAdd(m_series->candlestickSets());
60 handleCandlestickSetsAdd(m_series->sets());
61 61 }
62 62
63 63 CandlestickChartItem::~CandlestickChartItem()
@@ -233,7 +233,7 void CandlestickChartItem::handleDataStructureChanged()
233 233 updateTimePeriod();
234 234
235 235 for (int i = 0; i < m_series->count(); ++i) {
236 QCandlestickSet *set = m_series->candlestickSets().at(i);
236 QCandlestickSet *set = m_series->sets().at(i);
237 237 Candlestick *item = m_candlesticks.value(set);
238 238
239 239 updateCandlestickGeometry(item, i);
@@ -252,7 +252,7 bool CandlestickChartItem::updateCandlestickGeometry(Candlestick *item, int inde
252 252 {
253 253 bool changed = false;
254 254
255 QCandlestickSet *set = m_series->candlestickSets().at(index);
255 QCandlestickSet *set = m_series->sets().at(index);
256 256 CandlestickData &data = item->m_data;
257 257
258 258 if ((data.m_open != set->open())
@@ -310,19 +310,19 int QCandlestickModelMapper::close() const
310 310
311 311 /*!
312 312 Sets the section of the model that is used as the data source for the first candlestick set.
313 Parameter \a firstCandlestickSetSection specifies the section of the model. Default value is -1.
313 Parameter \a firstSetSection specifies the section of the model. Default value is -1.
314 314 */
315 void QCandlestickModelMapper::setFirstCandlestickSetSection(int firstCandlestickSetSection)
315 void QCandlestickModelMapper::setFirstSetSection(int firstSetSection)
316 316 {
317 317 Q_D(QCandlestickModelMapper);
318 318
319 firstCandlestickSetSection = qMax(firstCandlestickSetSection, -1);
319 firstSetSection = qMax(firstSetSection, -1);
320 320
321 if (d->m_firstCandlestickSetSection == firstCandlestickSetSection)
321 if (d->m_firstSetSection == firstSetSection)
322 322 return;
323 323
324 d->m_firstCandlestickSetSection = firstCandlestickSetSection;
325 emit d->firstCandlestickSetSectionChanged();
324 d->m_firstSetSection = firstSetSection;
325 emit d->firstSetSectionChanged();
326 326 d->initializeCandlestickFromModel();
327 327 }
328 328
@@ -330,28 +330,28 void QCandlestickModelMapper::setFirstCandlestickSetSection(int firstCandlestick
330 330 Returns the section of the model that is used as the data source for the first candlestick set.
331 331 Default value is -1 (invalid mapping).
332 332 */
333 int QCandlestickModelMapper::firstCandlestickSetSection() const
333 int QCandlestickModelMapper::firstSetSection() const
334 334 {
335 335 Q_D(const QCandlestickModelMapper);
336 336
337 return d->m_firstCandlestickSetSection;
337 return d->m_firstSetSection;
338 338 }
339 339
340 340 /*!
341 341 Sets the section of the model that is used as the data source for the last candlestick set.
342 Parameter \a lastCandlestickSetSection specifies the section of the model. Default value is -1.
342 Parameter \a lastSetSection specifies the section of the model. Default value is -1.
343 343 */
344 void QCandlestickModelMapper::setLastCandlestickSetSection(int lastCandlestickSetSection)
344 void QCandlestickModelMapper::setLastSetSection(int lastSetSection)
345 345 {
346 346 Q_D(QCandlestickModelMapper);
347 347
348 lastCandlestickSetSection = qMax(lastCandlestickSetSection, -1);
348 lastSetSection = qMax(lastSetSection, -1);
349 349
350 if (d->m_lastCandlestickSetSection == lastCandlestickSetSection)
350 if (d->m_lastSetSection == lastSetSection)
351 351 return;
352 352
353 d->m_lastCandlestickSetSection = lastCandlestickSetSection;
354 emit d->lastCandlestickSetSectionChanged();
353 d->m_lastSetSection = lastSetSection;
354 emit d->lastSetSectionChanged();
355 355 d->initializeCandlestickFromModel();
356 356 }
357 357
@@ -359,11 +359,11 void QCandlestickModelMapper::setLastCandlestickSetSection(int lastCandlestickSe
359 359 Returns the section of the model that is used as the data source for the last candlestick set.
360 360 Default value is -1 (invalid mapping).
361 361 */
362 int QCandlestickModelMapper::lastCandlestickSetSection() const
362 int QCandlestickModelMapper::lastSetSection() const
363 363 {
364 364 Q_D(const QCandlestickModelMapper);
365 365
366 return d->m_lastCandlestickSetSection;
366 return d->m_lastSetSection;
367 367 }
368 368
369 369 ////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -377,8 +377,8 QCandlestickModelMapperPrivate::QCandlestickModelMapperPrivate(QCandlestickModel
377 377 m_high(-1),
378 378 m_low(-1),
379 379 m_close(-1),
380 m_firstCandlestickSetSection(-1),
381 m_lastCandlestickSetSection(-1),
380 m_firstSetSection(-1),
381 m_lastSetSection(-1),
382 382 m_modelSignalsBlock(false),
383 383 m_seriesSignalsBlock(false),
384 384 q_ptr(q)
@@ -393,11 +393,11 void QCandlestickModelMapperPrivate::initializeCandlestickFromModel()
393 393 blockSeriesSignals();
394 394 // clear current content
395 395 m_series->clear();
396 m_candlestickSets.clear();
396 m_sets.clear();
397 397
398 398 // create the initial candlestick sets
399 QList<QCandlestickSet *> candlestickSets;
400 for (int i = m_firstCandlestickSetSection; i <= m_lastCandlestickSetSection; ++i) {
399 QList<QCandlestickSet *> sets;
400 for (int i = m_firstSetSection; i <= m_lastSetSection; ++i) {
401 401 QModelIndex timestampIndex = candlestickModelIndex(i, m_timestamp);
402 402 QModelIndex openIndex = candlestickModelIndex(i, m_open);
403 403 QModelIndex highIndex = candlestickModelIndex(i, m_high);
@@ -421,13 +421,13 void QCandlestickModelMapperPrivate::initializeCandlestickFromModel()
421 421 connect(set, SIGNAL(lowChanged()), this, SLOT(candlestickSetChanged()));
422 422 connect(set, SIGNAL(closeChanged()), this, SLOT(candlestickSetChanged()));
423 423
424 candlestickSets.append(set);
424 sets.append(set);
425 425 } else {
426 426 break;
427 427 }
428 428 }
429 m_series->append(candlestickSets);
430 m_candlestickSets.append(candlestickSets);
429 m_series->append(sets);
430 m_sets.append(sets);
431 431 blockSeriesSignals(false);
432 432 }
433 433
@@ -485,7 +485,7 void QCandlestickModelMapperPrivate::modelRowsInserted(QModelIndex parent, int s
485 485 blockSeriesSignals();
486 486 if (q->orientation() == Qt::Vertical)
487 487 insertData(start, end);
488 else if (start <= m_firstCandlestickSetSection || start <= m_lastCandlestickSetSection)
488 else if (start <= m_firstSetSection || start <= m_lastSetSection)
489 489 initializeCandlestickFromModel(); // if the changes affect the map - reinitialize
490 490 blockSeriesSignals(false);
491 491 }
@@ -502,7 +502,7 void QCandlestickModelMapperPrivate::modelRowsRemoved(QModelIndex parent, int st
502 502 blockSeriesSignals();
503 503 if (q->orientation() == Qt::Vertical)
504 504 removeData(start, end);
505 else if (start <= m_firstCandlestickSetSection || start <= m_lastCandlestickSetSection)
505 else if (start <= m_firstSetSection || start <= m_lastSetSection)
506 506 initializeCandlestickFromModel(); // if the changes affect the map - reinitialize
507 507 blockSeriesSignals(false);
508 508 }
@@ -519,7 +519,7 void QCandlestickModelMapperPrivate::modelColumnsInserted(QModelIndex parent, in
519 519 blockSeriesSignals();
520 520 if (q->orientation() == Qt::Horizontal)
521 521 insertData(start, end);
522 else if (start <= m_firstCandlestickSetSection || start <= m_lastCandlestickSetSection)
522 else if (start <= m_firstSetSection || start <= m_lastSetSection)
523 523 initializeCandlestickFromModel(); // if the changes affect the map - reinitialize
524 524 blockSeriesSignals(false);
525 525 }
@@ -536,7 +536,7 void QCandlestickModelMapperPrivate::modelColumnsRemoved(QModelIndex parent, int
536 536 blockSeriesSignals();
537 537 if (q->orientation() == Qt::Horizontal)
538 538 removeData(start, end);
539 else if (start <= m_firstCandlestickSetSection || start <= m_lastCandlestickSetSection)
539 else if (start <= m_firstSetSection || start <= m_lastSetSection)
540 540 initializeCandlestickFromModel(); // if the changes affect the map - reinitialize
541 541 blockSeriesSignals(false);
542 542 }
@@ -556,20 +556,20 void QCandlestickModelMapperPrivate::candlestickSetsAdded(const QList<QCandlesti
556 556 if (sets.isEmpty())
557 557 return;
558 558
559 int firstIndex = m_series->candlestickSets().indexOf(sets.at(0));
559 int firstIndex = m_series->sets().indexOf(sets.at(0));
560 560 if (firstIndex == -1)
561 561 return;
562 562
563 m_lastCandlestickSetSection += sets.count();
563 m_lastSetSection += sets.count();
564 564
565 565 blockModelSignals();
566 566 if (q->orientation() == Qt::Vertical)
567 m_model->insertColumns(firstIndex + m_firstCandlestickSetSection, sets.count());
567 m_model->insertColumns(firstIndex + m_firstSetSection, sets.count());
568 568 else
569 m_model->insertRows(firstIndex + m_firstCandlestickSetSection, sets.count());
569 m_model->insertRows(firstIndex + m_firstSetSection, sets.count());
570 570
571 571 for (int i = 0; i < sets.count(); ++i) {
572 int section = i + firstIndex + m_firstCandlestickSetSection;
572 int section = i + firstIndex + m_firstSetSection;
573 573 m_model->setData(candlestickModelIndex(section, m_timestamp), sets.at(i)->timestamp());
574 574 m_model->setData(candlestickModelIndex(section, m_open), sets.at(i)->open());
575 575 m_model->setData(candlestickModelIndex(section, m_high), sets.at(i)->high());
@@ -590,20 +590,20 void QCandlestickModelMapperPrivate::candlestickSetsRemoved(const QList<QCandles
590 590 if (sets.isEmpty())
591 591 return;
592 592
593 int firstIndex = m_candlestickSets.indexOf(sets.at(0));
593 int firstIndex = m_sets.indexOf(sets.at(0));
594 594 if (firstIndex == -1)
595 595 return;
596 596
597 m_lastCandlestickSetSection -= sets.count();
597 m_lastSetSection -= sets.count();
598 598
599 599 for (int i = firstIndex + sets.count() - 1; i >= firstIndex; --i)
600 m_candlestickSets.removeAt(i);
600 m_sets.removeAt(i);
601 601
602 602 blockModelSignals();
603 603 if (q->orientation() == Qt::Vertical)
604 m_model->removeColumns(firstIndex + m_firstCandlestickSetSection, sets.count());
604 m_model->removeColumns(firstIndex + m_firstSetSection, sets.count());
605 605 else
606 m_model->removeRows(firstIndex + m_firstCandlestickSetSection, sets.count());
606 m_model->removeRows(firstIndex + m_firstSetSection, sets.count());
607 607 blockModelSignals(false);
608 608 initializeCandlestickFromModel();
609 609 }
@@ -617,11 +617,11 void QCandlestickModelMapperPrivate::candlestickSetChanged()
617 617 if (!set)
618 618 return;
619 619
620 int section = m_series->candlestickSets().indexOf(set);
620 int section = m_series->sets().indexOf(set);
621 621 if (section < 0)
622 622 return;
623 623
624 section += m_firstCandlestickSetSection;
624 section += m_firstSetSection;
625 625
626 626 blockModelSignals();
627 627 m_model->setData(candlestickModelIndex(section, m_timestamp), set->timestamp());
@@ -647,20 +647,20 QCandlestickSet *QCandlestickModelMapperPrivate::candlestickSet(QModelIndex inde
647 647 int section = (q->orientation() == Qt::Vertical) ? index.column() : index.row();
648 648 int pos = (q->orientation() == Qt::Vertical) ? index.row() : index.column();
649 649
650 if (section < m_firstCandlestickSetSection || section > m_lastCandlestickSetSection)
650 if (section < m_firstSetSection || section > m_lastSetSection)
651 651 return 0; // This part of model has not been mapped to any candlestick set.
652 652
653 653 if (pos != m_timestamp && pos != m_open && pos != m_high && pos != m_low && pos != m_close)
654 654 return 0; // This part of model has not been mapped to any candlestick set.
655 655
656 return m_series->candlestickSets().at(section - m_firstCandlestickSetSection);
656 return m_series->sets().at(section - m_firstSetSection);
657 657 }
658 658
659 659 QModelIndex QCandlestickModelMapperPrivate::candlestickModelIndex(int section, int pos)
660 660 {
661 661 Q_Q(QCandlestickModelMapper);
662 662
663 if (section < m_firstCandlestickSetSection || section > m_lastCandlestickSetSection)
663 if (section < m_firstSetSection || section > m_lastSetSection)
664 664 return QModelIndex(); // invalid
665 665
666 666 if (pos != m_timestamp && pos != m_open && pos != m_high && pos != m_low && pos != m_close)
@@ -79,11 +79,11 protected:
79 79 void setClose(int close);
80 80 int close() const;
81 81
82 void setFirstCandlestickSetSection(int firstCandlestickSetSection);
83 int firstCandlestickSetSection() const;
82 void setFirstSetSection(int firstSetSection);
83 int firstSetSection() const;
84 84
85 void setLastCandlestickSetSection(int lastCandlestickSetSection);
86 int lastCandlestickSetSection() const;
85 void setLastSetSection(int lastSetSection);
86 int lastSetSection() const;
87 87
88 88 protected:
89 89 QCandlestickModelMapperPrivate * const d_ptr;
@@ -63,8 +63,8 Q_SIGNALS:
63 63 void highChanged();
64 64 void lowChanged();
65 65 void closeChanged();
66 void firstCandlestickSetSectionChanged();
67 void lastCandlestickSetSectionChanged();
66 void firstSetSectionChanged();
67 void lastSetSectionChanged();
68 68
69 69 private Q_SLOTS:
70 70 void initializeCandlestickFromModel();
@@ -100,9 +100,9 private:
100 100 int m_high;
101 101 int m_low;
102 102 int m_close;
103 int m_firstCandlestickSetSection;
104 int m_lastCandlestickSetSection;
105 QList<QCandlestickSet *> m_candlestickSets;
103 int m_firstSetSection;
104 int m_lastSetSection;
105 QList<QCandlestickSet *> m_sets;
106 106 bool m_modelSignalsBlock;
107 107 bool m_seriesSignalsBlock;
108 108
@@ -602,7 +602,7 void QCandlestickSeries::clear()
602 602 {
603 603 Q_D(QCandlestickSeries);
604 604
605 QList<QCandlestickSet *> sets = candlestickSets();
605 QList<QCandlestickSet *> sets = this->sets();
606 606
607 607 bool success = d->remove(sets);
608 608 if (success) {
@@ -616,11 +616,11 void QCandlestickSeries::clear()
616 616 /*!
617 617 Returns the list of sets in the series. Ownership of the sets is unchanged.
618 618 */
619 QList<QCandlestickSet *> QCandlestickSeries::candlestickSets() const
619 QList<QCandlestickSet *> QCandlestickSeries::sets() const
620 620 {
621 621 Q_D(const QCandlestickSeries);
622 622
623 return d->m_candlestickSets;
623 return d->m_sets;
624 624 }
625 625
626 626 /*!
@@ -628,7 +628,7 QList<QCandlestickSet *> QCandlestickSeries::candlestickSets() const
628 628 */
629 629 int QCandlestickSeries::count() const
630 630 {
631 return candlestickSets().count();
631 return sets().count();
632 632 }
633 633
634 634 /*!
@@ -918,20 +918,20 void QCandlestickSeriesPrivate::initializeDomain()
918 918 qreal minY(domain()->minY());
919 919 qreal maxY(domain()->maxY());
920 920
921 if (m_candlestickSets.count()) {
922 QCandlestickSet *set = m_candlestickSets.first();
921 if (m_sets.count()) {
922 QCandlestickSet *set = m_sets.first();
923 923 minX = set->timestamp();
924 924 maxX = set->timestamp();
925 925 minY = set->low();
926 926 maxY = set->high();
927 for (int i = 1; i < m_candlestickSets.count(); ++i) {
928 set = m_candlestickSets.at(i);
927 for (int i = 1; i < m_sets.count(); ++i) {
928 set = m_sets.at(i);
929 929 minX = qMin(minX, qreal(set->timestamp()));
930 930 maxX = qMax(maxX, qreal(set->timestamp()));
931 931 minY = qMin(minY, set->low());
932 932 maxY = qMax(maxY, set->high());
933 933 }
934 qreal extra = (maxX - minX) / m_candlestickSets.count() / 2;
934 qreal extra = (maxX - minX) / m_sets.count() / 2;
935 935 minX = minX - extra;
936 936 maxX = maxX + extra;
937 937 }
@@ -1039,14 +1039,14 QAbstractAxis* QCandlestickSeriesPrivate::createDefaultAxis(Qt::Orientation orie
1039 1039 bool QCandlestickSeriesPrivate::append(const QList<QCandlestickSet *> &sets)
1040 1040 {
1041 1041 foreach (QCandlestickSet *set, sets) {
1042 if ((set == 0) || m_candlestickSets.contains(set) || set->d_ptr->m_series)
1042 if ((set == 0) || m_sets.contains(set) || set->d_ptr->m_series)
1043 1043 return false; // Fail if any of the sets is null or is already appended.
1044 1044 if (sets.count(set) != 1)
1045 1045 return false; // Also fail if the same set occurs more than once in the given list.
1046 1046 }
1047 1047
1048 1048 foreach (QCandlestickSet *set, sets) {
1049 m_candlestickSets.append(set);
1049 m_sets.append(set);
1050 1050 connect(set->d_func(), SIGNAL(updatedLayout()), this, SIGNAL(updatedLayout()));
1051 1051 connect(set->d_func(), SIGNAL(updatedCandlestick()), this, SIGNAL(updatedCandlesticks()));
1052 1052 set->d_ptr->m_series = this;
@@ -1061,7 +1061,7 bool QCandlestickSeriesPrivate::remove(const QList<QCandlestickSet *> &sets)
1061 1061 return false;
1062 1062
1063 1063 foreach (QCandlestickSet *set, sets) {
1064 if ((set == 0) || (!m_candlestickSets.contains(set)))
1064 if ((set == 0) || (!m_sets.contains(set)))
1065 1065 return false; // Fail if any of the sets is null or is not in series.
1066 1066 if (sets.count(set) != 1)
1067 1067 return false; // Also fail if the same set occurs more than once in the given list.
@@ -1069,7 +1069,7 bool QCandlestickSeriesPrivate::remove(const QList<QCandlestickSet *> &sets)
1069 1069
1070 1070 foreach (QCandlestickSet *set, sets) {
1071 1071 set->d_ptr->m_series = nullptr;
1072 m_candlestickSets.removeOne(set);
1072 m_sets.removeOne(set);
1073 1073 disconnect(set->d_func(), SIGNAL(updatedLayout()), this, SIGNAL(updatedLayout()));
1074 1074 disconnect(set->d_func(), SIGNAL(updatedCandlestick()),this, SIGNAL(updatedCandlesticks()));
1075 1075 }
@@ -1079,10 +1079,10 bool QCandlestickSeriesPrivate::remove(const QList<QCandlestickSet *> &sets)
1079 1079
1080 1080 bool QCandlestickSeriesPrivate::insert(int index, QCandlestickSet *set)
1081 1081 {
1082 if ((m_candlestickSets.contains(set)) || (set == 0) || set->d_ptr->m_series)
1082 if ((m_sets.contains(set)) || (set == 0) || set->d_ptr->m_series)
1083 1083 return false; // Fail if set is already in list or set is null.
1084 1084
1085 m_candlestickSets.insert(index, set);
1085 m_sets.insert(index, set);
1086 1086 connect(set->d_func(), SIGNAL(updatedLayout()), this, SIGNAL(updatedLayout()));
1087 1087 connect(set->d_func(), SIGNAL(updatedCandlestick()), this, SIGNAL(updatedCandlesticks()));
1088 1088 set->d_ptr->m_series = this;
@@ -1123,8 +1123,8 void QCandlestickSeriesPrivate::populateBarCategories(QBarCategoryAxis *axis)
1123 1123 {
1124 1124 if (axis->categories().isEmpty()) {
1125 1125 QStringList categories;
1126 for (int i = 0; i < m_candlestickSets.count(); ++i) {
1127 const qint64 timestamp = qRound64(m_candlestickSets.at(i)->timestamp());
1126 for (int i = 0; i < m_sets.count(); ++i) {
1127 const qint64 timestamp = qRound64(m_sets.at(i)->timestamp());
1128 1128 const QString timestampFormat = m_chart->locale().dateTimeFormat(QLocale::ShortFormat);
1129 1129 categories << QDateTime::fromMSecsSinceEpoch(timestamp).toString(timestampFormat);
1130 1130 }
@@ -64,7 +64,7 public:
64 64 bool take(QCandlestickSet *set);
65 65 void clear();
66 66
67 QList<QCandlestickSet *> candlestickSets() const;
67 QList<QCandlestickSet *> sets() const;
68 68 int count() const;
69 69
70 70 QAbstractSeries::SeriesType type() const;
@@ -89,7 +89,7 private:
89 89 void populateBarCategories(QBarCategoryAxis *axis);
90 90
91 91 protected:
92 QList<QCandlestickSet *> m_candlestickSets;
92 QList<QCandlestickSet *> m_sets;
93 93 qreal m_maximumColumnWidth;
94 94 qreal m_minimumColumnWidth;
95 95 qreal m_bodyWidth;
@@ -71,8 +71,8 QT_CHARTS_BEGIN_NAMESPACE
71 71 highColumn: 3
72 72 lowColumn: 4
73 73 closeColumn: 5
74 firstCandlestickSetRow: 1
75 lastCandlestickSetRow: 3
74 firstSetRow: 1
75 lastSetRow: 3
76 76 }
77 77 }
78 78 \endqml
@@ -158,25 +158,25 QT_CHARTS_BEGIN_NAMESPACE
158 158 */
159 159
160 160 /*!
161 \property QHCandlestickModelMapper::firstCandlestickSetRow
161 \property QHCandlestickModelMapper::firstSetRow
162 162 \brief Defines the row of the model that is used as the data source for the first set. Default
163 163 value is -1 (invalid mapping).
164 164 */
165 165
166 166 /*!
167 \qmlproperty int HCandlestickModelMapper::firstCandlestickSetRow
167 \qmlproperty int HCandlestickModelMapper::firstSetRow
168 168 \brief Defines the row of the model that is used as the data source for the first set. Default
169 169 value is -1 (invalid mapping).
170 170 */
171 171
172 172 /*!
173 \property QHCandlestickModelMapper::lastCandlestickSetRow
173 \property QHCandlestickModelMapper::lastSetRow
174 174 \brief Defines the row of the model that is used as the data source for the last set. Default
175 175 value is -1 (invalid mapping).
176 176 */
177 177
178 178 /*!
179 \qmlproperty int HCandlestickModelMapper::lastCandlestickSetRow
179 \qmlproperty int HCandlestickModelMapper::lastSetRow
180 180 \brief Defines the row of the model that is used as the data source for the last set. Default
181 181 value is -1 (invalid mapping).
182 182 */
@@ -211,15 +211,15 QT_CHARTS_BEGIN_NAMESPACE
211 211 */
212 212
213 213 /*!
214 \fn void QHCandlestickModelMapper::firstCandlestickSetRowChanged()
214 \fn void QHCandlestickModelMapper::firstSetRowChanged()
215 215 \brief Emitted when the row of the model that contains the data of the first set is changed.
216 \sa firstCandlestickSetRow
216 \sa firstSetRow
217 217 */
218 218
219 219 /*!
220 \fn void QHCandlestickModelMapper::lastCandlestickSetRowChanged()
220 \fn void QHCandlestickModelMapper::lastSetRowChanged()
221 221 \brief Emitted when the row of the model that contains the data of the last set is changed.
222 \sa lastCandlestickSetRow
222 \sa lastSetRow
223 223 */
224 224
225 225 /*!
@@ -233,10 +233,8 QHCandlestickModelMapper::QHCandlestickModelMapper(QObject *parent)
233 233 connect(d_ptr, SIGNAL(highChanged()), this, SIGNAL(highColumnChanged()));
234 234 connect(d_ptr, SIGNAL(lowChanged()), this, SIGNAL(lowColumnChanged()));
235 235 connect(d_ptr, SIGNAL(closeChanged()), this, SIGNAL(closeColumnChanged()));
236 connect(d_ptr, SIGNAL(firstCandlestickSetSectionChanged()),
237 this, SIGNAL(firstCandlestickSetRowChanged()));
238 connect(d_ptr, SIGNAL(lastCandlestickSetSectionChanged()),
239 this, SIGNAL(lastCandlestickSetRowChanged()));
236 connect(d_ptr, SIGNAL(firstSetSectionChanged()), this, SIGNAL(firstSetRowChanged()));
237 connect(d_ptr, SIGNAL(lastSetSectionChanged()), this, SIGNAL(lastSetRowChanged()));
240 238 }
241 239
242 240 /*!
@@ -297,24 +295,24 int QHCandlestickModelMapper::closeColumn() const
297 295 return QCandlestickModelMapper::close();
298 296 }
299 297
300 void QHCandlestickModelMapper::setFirstCandlestickSetRow(int firstCandlestickSetRow)
298 void QHCandlestickModelMapper::setFirstSetRow(int firstSetRow)
301 299 {
302 QCandlestickModelMapper::setFirstCandlestickSetSection(firstCandlestickSetRow);
300 QCandlestickModelMapper::setFirstSetSection(firstSetRow);
303 301 }
304 302
305 int QHCandlestickModelMapper::firstCandlestickSetRow() const
303 int QHCandlestickModelMapper::firstSetRow() const
306 304 {
307 return QCandlestickModelMapper::firstCandlestickSetSection();
305 return QCandlestickModelMapper::firstSetSection();
308 306 }
309 307
310 void QHCandlestickModelMapper::setLastCandlestickSetRow(int lastCandlestickSetRow)
308 void QHCandlestickModelMapper::setLastSetRow(int lastSetRow)
311 309 {
312 QCandlestickModelMapper::setLastCandlestickSetSection(lastCandlestickSetRow);
310 QCandlestickModelMapper::setLastSetSection(lastSetRow);
313 311 }
314 312
315 int QHCandlestickModelMapper::lastCandlestickSetRow() const
313 int QHCandlestickModelMapper::lastSetRow() const
316 314 {
317 return QCandlestickModelMapper::lastCandlestickSetSection();
315 return QCandlestickModelMapper::lastSetSection();
318 316 }
319 317
320 318 #include "moc_qhcandlestickmodelmapper.cpp"
@@ -42,8 +42,8 class QT_CHARTS_EXPORT QHCandlestickModelMapper : public QCandlestickModelMapper
42 42 Q_PROPERTY(int highColumn READ highColumn WRITE setHighColumn NOTIFY highColumnChanged)
43 43 Q_PROPERTY(int lowColumn READ lowColumn WRITE setLowColumn NOTIFY lowColumnChanged)
44 44 Q_PROPERTY(int closeColumn READ closeColumn WRITE setCloseColumn NOTIFY closeColumnChanged)
45 Q_PROPERTY(int firstCandlestickSetRow READ firstCandlestickSetRow WRITE setFirstCandlestickSetRow NOTIFY firstCandlestickSetRowChanged)
46 Q_PROPERTY(int lastCandlestickSetRow READ lastCandlestickSetRow WRITE setLastCandlestickSetRow NOTIFY lastCandlestickSetRowChanged)
45 Q_PROPERTY(int firstSetRow READ firstSetRow WRITE setFirstSetRow NOTIFY firstSetRowChanged)
46 Q_PROPERTY(int lastSetRow READ lastSetRow WRITE setLastSetRow NOTIFY lastSetRowChanged)
47 47
48 48 public:
49 49 explicit QHCandlestickModelMapper(QObject *parent = nullptr);
@@ -65,11 +65,11 public:
65 65 void setCloseColumn(int closeColumn);
66 66 int closeColumn() const;
67 67
68 void setFirstCandlestickSetRow(int firstCandlestickSetRow);
69 int firstCandlestickSetRow() const;
68 void setFirstSetRow(int firstSetRow);
69 int firstSetRow() const;
70 70
71 void setLastCandlestickSetRow(int lastCandlestickSetRow);
72 int lastCandlestickSetRow() const;
71 void setLastSetRow(int lastSetRow);
72 int lastSetRow() const;
73 73
74 74 Q_SIGNALS:
75 75 void timestampColumnChanged();
@@ -77,8 +77,8 Q_SIGNALS:
77 77 void highColumnChanged();
78 78 void lowColumnChanged();
79 79 void closeColumnChanged();
80 void firstCandlestickSetRowChanged();
81 void lastCandlestickSetRowChanged();
80 void firstSetRowChanged();
81 void lastSetRowChanged();
82 82 };
83 83
84 84 QT_CHARTS_END_NAMESPACE
@@ -71,8 +71,8 QT_CHARTS_BEGIN_NAMESPACE
71 71 highRow: 3
72 72 lowRow: 4
73 73 closeRow: 5
74 firstCandlestickSetColumn: 1
75 lastCandlestickSetColumn: 3
74 firstSetColumn: 1
75 lastSetColumn: 3
76 76 }
77 77 }
78 78 \endqml
@@ -158,25 +158,25 QT_CHARTS_BEGIN_NAMESPACE
158 158 */
159 159
160 160 /*!
161 \property QVCandlestickModelMapper::firstCandlestickSetColumn
161 \property QVCandlestickModelMapper::firstSetColumn
162 162 \brief Defines the column of the model that is used as the data source for the first set.
163 163 Default value is -1 (invalid mapping).
164 164 */
165 165
166 166 /*!
167 \qmlproperty int VCandlestickModelMapper::firstCandlestickSetColumn
167 \qmlproperty int VCandlestickModelMapper::firstSetColumn
168 168 \brief Defines the column of the model that is used as the data source for the first set.
169 169 Default value is -1 (invalid mapping).
170 170 */
171 171
172 172 /*!
173 \property QVCandlestickModelMapper::lastCandlestickSetColumn
173 \property QVCandlestickModelMapper::lastSetColumn
174 174 \brief Defines the column of the model that is used as the data source for the last set. Default
175 175 value is -1 (invalid mapping).
176 176 */
177 177
178 178 /*!
179 \qmlproperty int VCandlestickModelMapper::lastCandlestickSetColumn
179 \qmlproperty int VCandlestickModelMapper::lastSetColumn
180 180 \brief Defines the column of the model that is used as the data source for the last set. Default
181 181 value is -1 (invalid mapping).
182 182 */
@@ -212,15 +212,15 QT_CHARTS_BEGIN_NAMESPACE
212 212 */
213 213
214 214 /*!
215 \fn void QVCandlestickModelMapper::firstCandlestickSetColumnChanged()
215 \fn void QVCandlestickModelMapper::firstSetColumnChanged()
216 216 \brief Emitted when the column of the model that contains the data of the first set is changed.
217 \sa firstCandlestickSetColumn
217 \sa firstSetColumn
218 218 */
219 219
220 220 /*!
221 \fn void QVCandlestickModelMapper::lastCandlestickSetColumnChanged()
221 \fn void QVCandlestickModelMapper::lastSetColumnChanged()
222 222 \brief Emitted when the column of the model that contains the data of the last set is changed.
223 \sa lastCandlestickSetColumn
223 \sa lastSetColumn
224 224 */
225 225
226 226 /*!
@@ -234,10 +234,8 QVCandlestickModelMapper::QVCandlestickModelMapper(QObject *parent)
234 234 connect(d_ptr, SIGNAL(highChanged()), this, SIGNAL(highRowChanged()));
235 235 connect(d_ptr, SIGNAL(lowChanged()), this, SIGNAL(lowRowChanged()));
236 236 connect(d_ptr, SIGNAL(closeChanged()), this, SIGNAL(closeRowChanged()));
237 connect(d_ptr, SIGNAL(firstCandlestickSetSectionChanged()),
238 this, SIGNAL(firstCandlestickSetColumnChanged()));
239 connect(d_ptr, SIGNAL(lastCandlestickSetSectionChanged()),
240 this, SIGNAL(lastCandlestickSetColumnChanged()));
237 connect(d_ptr, SIGNAL(firstSetSectionChanged()), this, SIGNAL(firstSetColumnChanged()));
238 connect(d_ptr, SIGNAL(lastSetSectionChanged()), this, SIGNAL(lastSetColumnChanged()));
241 239 }
242 240
243 241 /*!
@@ -298,24 +296,24 int QVCandlestickModelMapper::closeRow() const
298 296 return QCandlestickModelMapper::close();
299 297 }
300 298
301 void QVCandlestickModelMapper::setFirstCandlestickSetColumn(int firstCandlestickSetColumn)
299 void QVCandlestickModelMapper::setFirstSetColumn(int firstSetColumn)
302 300 {
303 QCandlestickModelMapper::setFirstCandlestickSetSection(firstCandlestickSetColumn);
301 QCandlestickModelMapper::setFirstSetSection(firstSetColumn);
304 302 }
305 303
306 int QVCandlestickModelMapper::firstCandlestickSetColumn() const
304 int QVCandlestickModelMapper::firstSetColumn() const
307 305 {
308 return QCandlestickModelMapper::firstCandlestickSetSection();
306 return QCandlestickModelMapper::firstSetSection();
309 307 }
310 308
311 void QVCandlestickModelMapper::setLastCandlestickSetColumn(int lastCandlestickSetColumn)
309 void QVCandlestickModelMapper::setLastSetColumn(int lastSetColumn)
312 310 {
313 QCandlestickModelMapper::setLastCandlestickSetSection(lastCandlestickSetColumn);
311 QCandlestickModelMapper::setLastSetSection(lastSetColumn);
314 312 }
315 313
316 int QVCandlestickModelMapper::lastCandlestickSetColumn() const
314 int QVCandlestickModelMapper::lastSetColumn() const
317 315 {
318 return QCandlestickModelMapper::lastCandlestickSetSection();
316 return QCandlestickModelMapper::lastSetSection();
319 317 }
320 318
321 319 #include "moc_qvcandlestickmodelmapper.cpp"
@@ -42,8 +42,8 class QT_CHARTS_EXPORT QVCandlestickModelMapper : public QCandlestickModelMapper
42 42 Q_PROPERTY(int highRow READ highRow WRITE setHighRow NOTIFY highRowChanged)
43 43 Q_PROPERTY(int lowRow READ lowRow WRITE setLowRow NOTIFY lowRowChanged)
44 44 Q_PROPERTY(int closeRow READ closeRow WRITE setCloseRow NOTIFY closeRowChanged)
45 Q_PROPERTY(int firstCandlestickSetColumn READ firstCandlestickSetColumn WRITE setFirstCandlestickSetColumn NOTIFY firstCandlestickSetColumnChanged)
46 Q_PROPERTY(int lastCandlestickSetColumn READ lastCandlestickSetColumn WRITE setLastCandlestickSetColumn NOTIFY lastCandlestickSetColumnChanged)
45 Q_PROPERTY(int firstSetColumn READ firstSetColumn WRITE setFirstSetColumn NOTIFY firstSetColumnChanged)
46 Q_PROPERTY(int lastSetColumn READ lastSetColumn WRITE setLastSetColumn NOTIFY lastSetColumnChanged)
47 47
48 48 public:
49 49 explicit QVCandlestickModelMapper(QObject *parent = nullptr);
@@ -65,11 +65,11 public:
65 65 void setCloseRow(int closeRow);
66 66 int closeRow() const;
67 67
68 void setFirstCandlestickSetColumn(int firstCandlestickSetColumn);
69 int firstCandlestickSetColumn() const;
68 void setFirstSetColumn(int firstSetColumn);
69 int firstSetColumn() const;
70 70
71 void setLastCandlestickSetColumn(int lastCandlestickSetColumn);
72 int lastCandlestickSetColumn() const;
71 void setLastSetColumn(int lastSetColumn);
72 int lastSetColumn() const;
73 73
74 74 Q_SIGNALS:
75 75 void timestampRowChanged();
@@ -77,8 +77,8 Q_SIGNALS:
77 77 void highRowChanged();
78 78 void lowRowChanged();
79 79 void closeRowChanged();
80 void firstCandlestickSetColumnChanged();
81 void lastCandlestickSetColumnChanged();
80 void firstSetColumnChanged();
81 void lastSetColumnChanged();
82 82 };
83 83
84 84 QT_CHARTS_END_NAMESPACE
@@ -126,7 +126,7 QString DeclarativeCandlestickSeries::brushFilename() const
126 126
127 127 DeclarativeCandlestickSet *DeclarativeCandlestickSeries::at(int index)
128 128 {
129 QList<QCandlestickSet *> sets = candlestickSets();
129 QList<QCandlestickSet *> sets = this->sets();
130 130 if (index >= 0 && index < sets.count())
131 131 return qobject_cast<DeclarativeCandlestickSet *>(sets[index]);
132 132
@@ -158,7 +158,7 bool DeclarativeCandlestickSeries::append(qreal open, qreal high, qreal low, qre
158 158 bool DeclarativeCandlestickSeries::remove(qreal timestamp)
159 159 {
160 160 for (int i = 0; i < count(); ++i) {
161 QCandlestickSet *set = candlestickSets().at(i);
161 QCandlestickSet *set = sets().at(i);
162 162 if (set->timestamp() == timestamp)
163 163 return QCandlestickSeries::remove(set);
164 164 }
@@ -110,8 +110,8 void tst_qcandlestickmodelmapper::createHorizontalMapper()
110 110 m_hMapper->setHighColumn(3);
111 111 m_hMapper->setLowColumn(5);
112 112 m_hMapper->setCloseColumn(6);
113 m_hMapper->setFirstCandlestickSetRow(0);
114 m_hMapper->setLastCandlestickSetRow(4);
113 m_hMapper->setFirstSetRow(0);
114 m_hMapper->setLastSetRow(4);
115 115 m_hMapper->setModel(m_model);
116 116 m_hMapper->setSeries(m_series);
117 117 }
@@ -125,8 +125,8 void tst_qcandlestickmodelmapper::createVerticalMapper()
125 125 m_vMapper->setHighRow(3);
126 126 m_vMapper->setLowRow(5);
127 127 m_vMapper->setCloseRow(6);
128 m_vMapper->setFirstCandlestickSetColumn(0);
129 m_vMapper->setLastCandlestickSetColumn(4);
128 m_vMapper->setFirstSetColumn(0);
129 m_vMapper->setLastSetColumn(4);
130 130 m_vMapper->setModel(m_model);
131 131 m_vMapper->setSeries(m_series);
132 132 }
@@ -179,9 +179,9 void tst_qcandlestickmodelmapper::cleanup()
179 179
180 180 void tst_qcandlestickmodelmapper::verticalMapper_data()
181 181 {
182 QTest::addColumn<int>("firstCandlestickSetColumn");
183 QTest::addColumn<int>("lastCandlestickSetColumn");
184 QTest::addColumn<int>("expectedCandlestickSetCount");
182 QTest::addColumn<int>("firstSetColumn");
183 QTest::addColumn<int>("lastSetColumn");
184 QTest::addColumn<int>("expectedSetCount");
185 185
186 186 QTest::newRow("last column greater than first column") << 0 << 1 << 2;
187 187 QTest::newRow("last column equal to first column") << 1 << 1 << 1;
@@ -193,21 +193,21 void tst_qcandlestickmodelmapper::verticalMapper_data()
193 193
194 194 void tst_qcandlestickmodelmapper::verticalMapper()
195 195 {
196 QFETCH(int, firstCandlestickSetColumn);
197 QFETCH(int, lastCandlestickSetColumn);
198 QFETCH(int, expectedCandlestickSetCount);
196 QFETCH(int, firstSetColumn);
197 QFETCH(int, lastSetColumn);
198 QFETCH(int, expectedSetCount);
199 199
200 200 QCandlestickSeries *series = new QCandlestickSeries();
201 201 m_chart->addSeries(series);
202 202
203 203 createVerticalMapper();
204 m_vMapper->setFirstCandlestickSetColumn(firstCandlestickSetColumn);
205 m_vMapper->setLastCandlestickSetColumn(lastCandlestickSetColumn);
204 m_vMapper->setFirstSetColumn(firstSetColumn);
205 m_vMapper->setLastSetColumn(lastSetColumn);
206 206 m_vMapper->setSeries(series);
207 207
208 QCOMPARE(m_vMapper->firstCandlestickSetColumn(), qMax(firstCandlestickSetColumn, -1));
209 QCOMPARE(m_vMapper->lastCandlestickSetColumn(), qMax(lastCandlestickSetColumn, -1));
210 QCOMPARE(series->count(), expectedCandlestickSetCount);
208 QCOMPARE(m_vMapper->firstSetColumn(), qMax(firstSetColumn, -1));
209 QCOMPARE(m_vMapper->lastSetColumn(), qMax(lastSetColumn, -1));
210 QCOMPARE(series->count(), expectedSetCount);
211 211
212 212 m_chart->removeSeries(series);
213 213 delete series;
@@ -272,14 +272,14 void tst_qcandlestickmodelmapper::verticalMapperCustomMapping()
272 272 && (m_vMapper->highRow() >= 0 && m_vMapper->highRow() < m_modelRowCount)
273 273 && (m_vMapper->lowRow() >= 0 && m_vMapper->lowRow() < m_modelRowCount)
274 274 && (m_vMapper->closeRow() >= 0 && m_vMapper->closeRow() < m_modelRowCount))
275 count = m_vMapper->lastCandlestickSetColumn() - m_vMapper->firstCandlestickSetColumn() + 1;
275 count = m_vMapper->lastSetColumn() - m_vMapper->firstSetColumn() + 1;
276 276 else
277 277 count = 0;
278 278 QCOMPARE(series->count(), count);
279 279
280 280 // change values column mapping to invalid
281 m_vMapper->setFirstCandlestickSetColumn(-1);
282 m_vMapper->setLastCandlestickSetColumn(1);
281 m_vMapper->setFirstSetColumn(-1);
282 m_vMapper->setLastSetColumn(1);
283 283 QCOMPARE(series->count(), 0);
284 284
285 285 m_chart->removeSeries(series);
@@ -288,9 +288,9 void tst_qcandlestickmodelmapper::verticalMapperCustomMapping()
288 288
289 289 void tst_qcandlestickmodelmapper::horizontalMapper_data()
290 290 {
291 QTest::addColumn<int>("firstCandlestickSetRow");
292 QTest::addColumn<int>("lastCandlestickSetRow");
293 QTest::addColumn<int>("expectedCandlestickSetCount");
291 QTest::addColumn<int>("firstSetRow");
292 QTest::addColumn<int>("lastSetRow");
293 QTest::addColumn<int>("expectedSetCount");
294 294
295 295 QTest::newRow("last row greater than first row") << 0 << 1 << 2;
296 296 QTest::newRow("last row equal to first row") << 1 << 1 << 1;
@@ -302,21 +302,21 void tst_qcandlestickmodelmapper::horizontalMapper_data()
302 302
303 303 void tst_qcandlestickmodelmapper::horizontalMapper()
304 304 {
305 QFETCH(int, firstCandlestickSetRow);
306 QFETCH(int, lastCandlestickSetRow);
307 QFETCH(int, expectedCandlestickSetCount);
305 QFETCH(int, firstSetRow);
306 QFETCH(int, lastSetRow);
307 QFETCH(int, expectedSetCount);
308 308
309 309 QCandlestickSeries *series = new QCandlestickSeries();
310 310 m_chart->addSeries(series);
311 311
312 312 createHorizontalMapper();
313 m_hMapper->setFirstCandlestickSetRow(firstCandlestickSetRow);
314 m_hMapper->setLastCandlestickSetRow(lastCandlestickSetRow);
313 m_hMapper->setFirstSetRow(firstSetRow);
314 m_hMapper->setLastSetRow(lastSetRow);
315 315 m_hMapper->setSeries(series);
316 316
317 QCOMPARE(m_hMapper->firstCandlestickSetRow(), qMax(firstCandlestickSetRow, -1));
318 QCOMPARE(m_hMapper->lastCandlestickSetRow(), qMax(lastCandlestickSetRow, -1));
319 QCOMPARE(series->count(), expectedCandlestickSetCount);
317 QCOMPARE(m_hMapper->firstSetRow(), qMax(firstSetRow, -1));
318 QCOMPARE(m_hMapper->lastSetRow(), qMax(lastSetRow, -1));
319 QCOMPARE(series->count(), expectedSetCount);
320 320
321 321 m_chart->removeSeries(series);
322 322 delete series;
@@ -381,14 +381,14 void tst_qcandlestickmodelmapper::horizontalMapperCustomMapping()
381 381 && (m_hMapper->highColumn() >= 0 && m_hMapper->highColumn() < m_modelColumnCount)
382 382 && (m_hMapper->lowColumn() >= 0 && m_hMapper->lowColumn() < m_modelColumnCount)
383 383 && (m_hMapper->closeColumn() >= 0 && m_hMapper->closeColumn() < m_modelColumnCount))
384 count = m_hMapper->lastCandlestickSetRow() - m_hMapper->firstCandlestickSetRow() + 1;
384 count = m_hMapper->lastSetRow() - m_hMapper->firstSetRow() + 1;
385 385 else
386 386 count = 0;
387 387 QCOMPARE(series->count(), count);
388 388
389 389 // change values row mapping to invalid
390 m_hMapper->setFirstCandlestickSetRow(-1);
391 m_hMapper->setLastCandlestickSetRow(1);
390 m_hMapper->setFirstSetRow(-1);
391 m_hMapper->setLastSetRow(1);
392 392 QCOMPARE(series->count(), 0);
393 393
394 394 m_chart->removeSeries(series);
@@ -400,7 +400,7 void tst_qcandlestickmodelmapper::seriesUpdated()
400 400 createVerticalMapper();
401 401 QVERIFY(m_vMapper->model() != nullptr);
402 402
403 QCandlestickSet *set = m_series->candlestickSets().value(0, 0);
403 QCandlestickSet *set = m_series->sets().value(0, 0);
404 404 QVERIFY(set != nullptr);
405 405
406 406 // update values
@@ -429,8 +429,8 void tst_qcandlestickmodelmapper::seriesUpdated()
429 429
430 430 // remove sets
431 431 newCandlestickSets.clear();
432 newCandlestickSets << m_series->candlestickSets().at(m_series->count() - 1);
433 newCandlestickSets << m_series->candlestickSets().at(m_series->count() - 2);
432 newCandlestickSets << m_series->sets().at(m_series->count() - 1);
433 newCandlestickSets << m_series->sets().at(m_series->count() - 2);
434 434 m_series->remove(newCandlestickSets);
435 435 QCOMPARE(m_model->columnCount(), m_modelColumnCount);
436 436 }
@@ -438,7 +438,7 void tst_qcandlestickmodelmapper::seriesUpdated()
438 438 void tst_qcandlestickmodelmapper::verticalModelInsertRows()
439 439 {
440 440 createVerticalMapper();
441 int count = m_vMapper->lastCandlestickSetColumn() - m_vMapper->firstCandlestickSetColumn() + 1;
441 int count = m_vMapper->lastSetColumn() - m_vMapper->firstSetColumn() + 1;
442 442 QVERIFY(m_vMapper->model() != 0);
443 443 QCOMPARE(m_series->count(), count);
444 444
@@ -449,7 +449,7 void tst_qcandlestickmodelmapper::verticalModelInsertRows()
449 449 void tst_qcandlestickmodelmapper::verticalModelRemoveRows()
450 450 {
451 451 createVerticalMapper();
452 int count = m_vMapper->lastCandlestickSetColumn() - m_vMapper->firstCandlestickSetColumn() + 1;
452 int count = m_vMapper->lastSetColumn() - m_vMapper->firstSetColumn() + 1;
453 453 QVERIFY(m_vMapper->model() != 0);
454 454 QCOMPARE(m_series->count(), count);
455 455
@@ -464,7 +464,7 void tst_qcandlestickmodelmapper::verticalModelRemoveRows()
464 464 void tst_qcandlestickmodelmapper::verticalModelInsertColumns()
465 465 {
466 466 createVerticalMapper();
467 int count = m_vMapper->lastCandlestickSetColumn() - m_vMapper->firstCandlestickSetColumn() + 1;
467 int count = m_vMapper->lastSetColumn() - m_vMapper->firstSetColumn() + 1;
468 468 QVERIFY(m_vMapper->model() != 0);
469 469 QCOMPARE(m_series->count(), count);
470 470
@@ -475,7 +475,7 void tst_qcandlestickmodelmapper::verticalModelInsertColumns()
475 475 void tst_qcandlestickmodelmapper::verticalModelRemoveColumns()
476 476 {
477 477 createVerticalMapper();
478 int count = m_vMapper->lastCandlestickSetColumn() - m_vMapper->firstCandlestickSetColumn() + 1;
478 int count = m_vMapper->lastSetColumn() - m_vMapper->firstSetColumn() + 1;
479 479 QVERIFY(m_vMapper->model() != 0);
480 480 QCOMPARE(m_series->count(), count);
481 481
@@ -491,7 +491,7 void tst_qcandlestickmodelmapper::verticalModelRemoveColumns()
491 491 void tst_qcandlestickmodelmapper::horizontalModelInsertRows()
492 492 {
493 493 createHorizontalMapper();
494 int count = m_hMapper->lastCandlestickSetRow() - m_hMapper->firstCandlestickSetRow() + 1;
494 int count = m_hMapper->lastSetRow() - m_hMapper->firstSetRow() + 1;
495 495 QVERIFY(m_hMapper->model() != 0);
496 496 QCOMPARE(m_series->count(), count);
497 497
@@ -502,7 +502,7 void tst_qcandlestickmodelmapper::horizontalModelInsertRows()
502 502 void tst_qcandlestickmodelmapper::horizontalModelRemoveRows()
503 503 {
504 504 createHorizontalMapper();
505 int count = m_hMapper->lastCandlestickSetRow() - m_hMapper->firstCandlestickSetRow() + 1;
505 int count = m_hMapper->lastSetRow() - m_hMapper->firstSetRow() + 1;
506 506 QVERIFY(m_hMapper->model() != 0);
507 507 QCOMPARE(m_series->count(), qMin(m_model->rowCount(), count));
508 508
@@ -518,7 +518,7 void tst_qcandlestickmodelmapper::horizontalModelRemoveRows()
518 518 void tst_qcandlestickmodelmapper::horizontalModelInsertColumns()
519 519 {
520 520 createHorizontalMapper();
521 int count = m_hMapper->lastCandlestickSetRow() - m_hMapper->firstCandlestickSetRow() + 1;
521 int count = m_hMapper->lastSetRow() - m_hMapper->firstSetRow() + 1;
522 522 QVERIFY(m_hMapper->model() != 0);
523 523 QCOMPARE(m_series->count(), count);
524 524
@@ -529,7 +529,7 void tst_qcandlestickmodelmapper::horizontalModelInsertColumns()
529 529 void tst_qcandlestickmodelmapper::horizontalModelRemoveColumns()
530 530 {
531 531 createHorizontalMapper();
532 int count = m_hMapper->lastCandlestickSetRow() - m_hMapper->firstCandlestickSetRow() + 1;
532 int count = m_hMapper->lastSetRow() - m_hMapper->firstSetRow() + 1;
533 533 QVERIFY(m_hMapper->model() != 0);
534 534 QCOMPARE(m_series->count(), count);
535 535
@@ -550,7 +550,7 void tst_qcandlestickmodelmapper::modelUpdateCell()
550 550 qreal newValue = 44.0;
551 551 QVERIFY(m_model->setData(index, newValue));
552 552 QCOMPARE(m_model->data(index).toReal(), newValue);
553 QCOMPARE(m_series->candlestickSets().at(index.row())->timestamp(), newValue);
553 QCOMPARE(m_series->sets().at(index.row())->timestamp(), newValue);
554 554 }
555 555
556 556 void tst_qcandlestickmodelmapper::verticalMapperSignals()
@@ -564,8 +564,8 void tst_qcandlestickmodelmapper::verticalMapperSignals()
564 564 QSignalSpy spy4(mapper, SIGNAL(highRowChanged()));
565 565 QSignalSpy spy5(mapper, SIGNAL(lowRowChanged()));
566 566 QSignalSpy spy6(mapper, SIGNAL(closeRowChanged()));
567 QSignalSpy spy7(mapper, SIGNAL(firstCandlestickSetColumnChanged()));
568 QSignalSpy spy8(mapper, SIGNAL(lastCandlestickSetColumnChanged()));
567 QSignalSpy spy7(mapper, SIGNAL(firstSetColumnChanged()));
568 QSignalSpy spy8(mapper, SIGNAL(lastSetColumnChanged()));
569 569
570 570 mapper->setModel(m_model);
571 571 mapper->setSeries(m_series);
@@ -574,8 +574,8 void tst_qcandlestickmodelmapper::verticalMapperSignals()
574 574 mapper->setHighRow(3);
575 575 mapper->setLowRow(4);
576 576 mapper->setCloseRow(5);
577 mapper->setFirstCandlestickSetColumn(0);
578 mapper->setLastCandlestickSetColumn(1);
577 mapper->setFirstSetColumn(0);
578 mapper->setLastSetColumn(1);
579 579
580 580 QCOMPARE(spy0.count(), 1);
581 581 QCOMPARE(spy1.count(), 1);
@@ -601,8 +601,8 void tst_qcandlestickmodelmapper::horizontalMapperSignals()
601 601 QSignalSpy spy4(mapper, SIGNAL(highColumnChanged()));
602 602 QSignalSpy spy5(mapper, SIGNAL(lowColumnChanged()));
603 603 QSignalSpy spy6(mapper, SIGNAL(closeColumnChanged()));
604 QSignalSpy spy7(mapper, SIGNAL(firstCandlestickSetRowChanged()));
605 QSignalSpy spy8(mapper, SIGNAL(lastCandlestickSetRowChanged()));
604 QSignalSpy spy7(mapper, SIGNAL(firstSetRowChanged()));
605 QSignalSpy spy8(mapper, SIGNAL(lastSetRowChanged()));
606 606
607 607 mapper->setModel(m_model);
608 608 mapper->setSeries(m_series);
@@ -611,8 +611,8 void tst_qcandlestickmodelmapper::horizontalMapperSignals()
611 611 mapper->setHighColumn(3);
612 612 mapper->setLowColumn(4);
613 613 mapper->setCloseColumn(5);
614 mapper->setFirstCandlestickSetRow(0);
615 mapper->setLastCandlestickSetRow(1);
614 mapper->setFirstSetRow(0);
615 mapper->setLastSetRow(1);
616 616
617 617 QCOMPARE(spy0.count(), 1);
618 618 QCOMPARE(spy1.count(), 1);
@@ -57,7 +57,7 private Q_SLOTS:
57 57 void insert();
58 58 void take();
59 59 void clear();
60 void candlestickSets();
60 void sets();
61 61 void count();
62 62 void type();
63 63 void maximumColumnWidth_data();
@@ -182,7 +182,7 void tst_QCandlestickSeries::remove()
182 182 QCOMPARE(m_series->count(), m_sets.count() - removeCount);
183 183
184 184 for (int i = removeCount; i < m_sets.count(); ++i)
185 QCOMPARE(m_series->candlestickSets().at(i - removeCount), m_sets.at(i));
185 QCOMPARE(m_series->sets().at(i - removeCount), m_sets.at(i));
186 186
187 187 // Try removing all sets again (should be ok, even if some sets have already been removed)
188 188 for (int i = 0; i < m_sets.count(); ++i)
@@ -313,23 +313,23 void tst_QCandlestickSeries::clear()
313 313 QCOMPARE(m_series->count(), 0);
314 314 }
315 315
316 void tst_QCandlestickSeries::candlestickSets()
316 void tst_QCandlestickSeries::sets()
317 317 {
318 318 m_series->append(m_sets);
319 QCOMPARE(m_series->candlestickSets(), m_sets);
319 QCOMPARE(m_series->sets(), m_sets);
320 320
321 321 for (int i = 0; i < m_sets.count(); ++i)
322 QCOMPARE(m_series->candlestickSets().at(i), m_sets.at(i));
322 QCOMPARE(m_series->sets().at(i), m_sets.at(i));
323 323
324 324 m_series->clear();
325 QCOMPARE(m_series->candlestickSets(), QList<QCandlestickSet *>());
325 QCOMPARE(m_series->sets(), QList<QCandlestickSet *>());
326 326 }
327 327
328 328 void tst_QCandlestickSeries::count()
329 329 {
330 330 m_series->append(m_sets);
331 331 QCOMPARE(m_series->count(), m_sets.count());
332 QCOMPARE(m_series->count(), m_series->candlestickSets().count());
332 QCOMPARE(m_series->count(), m_series->sets().count());
333 333 }
334 334
335 335 void tst_QCandlestickSeries::type()
@@ -586,8 +586,8 void tst_QCandlestickSeries::mouseClicked()
586 586 QVERIFY(m_series->append(m_sets));
587 587 QCOMPARE(m_series->count(), m_sets.count());
588 588
589 QCandlestickSet *set1 = m_series->candlestickSets().at(1);
590 QCandlestickSet *set2 = m_series->candlestickSets().at(2);
589 QCandlestickSet *set1 = m_series->sets().at(1);
590 QCandlestickSet *set2 = m_series->sets().at(2);
591 591
592 592 QSignalSpy seriesSpy(m_series, SIGNAL(clicked(QCandlestickSet *)));
593 593 QSignalSpy setSpy1(set1, SIGNAL(clicked()));
@@ -649,8 +649,8 void tst_QCandlestickSeries::mouseHovered()
649 649 QVERIFY(m_series->append(m_sets));
650 650 QCOMPARE(m_series->count(), m_sets.count());
651 651
652 QCandlestickSet *set1 = m_series->candlestickSets().at(1);
653 QCandlestickSet *set2 = m_series->candlestickSets().at(2);
652 QCandlestickSet *set1 = m_series->sets().at(1);
653 QCandlestickSet *set2 = m_series->sets().at(2);
654 654
655 655 QSignalSpy seriesSpy(m_series, SIGNAL(hovered(bool, QCandlestickSet *)));
656 656 QSignalSpy setSpy1(set1, SIGNAL(hovered(bool)));
@@ -764,8 +764,8 void tst_QCandlestickSeries::mousePressed()
764 764 QVERIFY(m_series->append(m_sets));
765 765 QCOMPARE(m_series->count(), m_sets.count());
766 766
767 QCandlestickSet *set1 = m_series->candlestickSets().at(1);
768 QCandlestickSet *set2 = m_series->candlestickSets().at(2);
767 QCandlestickSet *set1 = m_series->sets().at(1);
768 QCandlestickSet *set2 = m_series->sets().at(2);
769 769
770 770 QSignalSpy seriesSpy(m_series, SIGNAL(pressed(QCandlestickSet *)));
771 771 QSignalSpy setSpy1(set1, SIGNAL(pressed()));
@@ -827,8 +827,8 void tst_QCandlestickSeries::mouseReleased()
827 827 QVERIFY(m_series->append(m_sets));
828 828 QCOMPARE(m_series->count(), m_sets.count());
829 829
830 QCandlestickSet *set1 = m_series->candlestickSets().at(1);
831 QCandlestickSet *set2 = m_series->candlestickSets().at(2);
830 QCandlestickSet *set1 = m_series->sets().at(1);
831 QCandlestickSet *set2 = m_series->sets().at(2);
832 832
833 833 QSignalSpy seriesSpy(m_series, SIGNAL(released(QCandlestickSet *)));
834 834 QSignalSpy setSpy1(set1, SIGNAL(released()));
@@ -890,8 +890,8 void tst_QCandlestickSeries::mouseDoubleClicked()
890 890 QVERIFY(m_series->append(m_sets));
891 891 QCOMPARE(m_series->count(), m_sets.count());
892 892
893 QCandlestickSet *set1 = m_series->candlestickSets().at(1);
894 QCandlestickSet *set2 = m_series->candlestickSets().at(2);
893 QCandlestickSet *set1 = m_series->sets().at(1);
894 QCandlestickSet *set2 = m_series->sets().at(2);
895 895
896 896 QSignalSpy seriesSpy(m_series, SIGNAL(doubleClicked(QCandlestickSet *)));
897 897 QSignalSpy setSpy1(set1, SIGNAL(doubleClicked()));
@@ -311,17 +311,17 void MainWidget::updateAxes()
311 311 series = nullptr;
312 312
313 313 m_axisX = m_chart->axes(Qt::Horizontal).first();
314 if (series && !series->candlestickSets().isEmpty()) {
314 if (series && !series->sets().isEmpty()) {
315 315 if (m_axisX->type() == QAbstractAxis::AxisTypeBarCategory) {
316 316 QBarCategoryAxis *axisX = qobject_cast<QBarCategoryAxis *>(m_axisX);
317 317 QStringList categories;
318 for (int i = 0; i < series->candlestickSets().count(); ++i)
318 for (int i = 0; i < series->sets().count(); ++i)
319 319 categories.append(QString::number(i));
320 320 axisX->setCategories(categories);
321 321 } else { // QAbstractAxis::AxisTypeDateTime || QAbstractAxis::AxisTypeValue
322 322 qreal msInMonth = 31.0 * 24.0 * 60.0 * 60.0 * 1000.0;
323 qreal min = series->candlestickSets().first()->timestamp() - msInMonth;
324 qreal max = series->candlestickSets().last()->timestamp() + msInMonth;
323 qreal min = series->sets().first()->timestamp() - msInMonth;
324 qreal max = series->sets().last()->timestamp() + msInMonth;
325 325 QDateTime minDateTime = QDateTime::fromMSecsSinceEpoch(min);
326 326 QDateTime maxDateTime = QDateTime::fromMSecsSinceEpoch(max);
327 327
@@ -369,8 +369,8 void MainWidget::addSeries()
369 369 }
370 370 } else {
371 371 QCandlestickSeries *s = qobject_cast<QCandlestickSeries *>(m_chart->series().at(0));
372 for (int i = 0; i < s->candlestickSets().count(); ++i) {
373 QCandlestickSet *set = randomSet(s->candlestickSets().at(i)->timestamp());
372 for (int i = 0; i < s->sets().count(); ++i) {
373 QCandlestickSet *set = randomSet(s->sets().at(i)->timestamp());
374 374 series->append(set);
375 375 }
376 376 }
@@ -424,7 +424,7 void MainWidget::addSet()
424 424
425 425 QDateTime dateTime;
426 426 if (series->count()) {
427 dateTime.setMSecsSinceEpoch(series->candlestickSets().last()->timestamp());
427 dateTime.setMSecsSinceEpoch(series->sets().last()->timestamp());
428 428 dateTime = dateTime.addMonths(1);
429 429 } else {
430 430 dateTime.setDate(QDate(QDateTime::currentDateTime().date().year(), 1, 1));
@@ -450,7 +450,7 void MainWidget::insertSet()
450 450
451 451 QDateTime dateTime;
452 452 if (series->count()) {
453 dateTime.setMSecsSinceEpoch(series->candlestickSets().first()->timestamp());
453 dateTime.setMSecsSinceEpoch(series->sets().first()->timestamp());
454 454 dateTime = dateTime.addMonths(-1);
455 455 } else {
456 456 dateTime.setDate(QDate(QDateTime::currentDateTime().date().year(), 1, 1));
@@ -473,10 +473,10 void MainWidget::removeSet()
473 473
474 474 foreach (QAbstractSeries *s, m_chart->series()) {
475 475 QCandlestickSeries *series = qobject_cast<QCandlestickSeries *>(s);
476 if (series->candlestickSets().isEmpty())
476 if (series->sets().isEmpty())
477 477 qDebug() << "Create a set first";
478 478 else
479 series->remove(series->candlestickSets().last());
479 series->remove(series->sets().last());
480 480 }
481 481
482 482 updateAxes();
@@ -491,7 +491,7 void MainWidget::removeAllSets()
491 491
492 492 foreach (QAbstractSeries *s, m_chart->series()) {
493 493 QCandlestickSeries *series = qobject_cast<QCandlestickSeries *>(s);
494 if (series->candlestickSets().isEmpty())
494 if (series->sets().isEmpty())
495 495 qDebug() << "Create a set first";
496 496 else
497 497 series->clear();
@@ -665,11 +665,11 void MainWidget::attachModelMapper()
665 665 series->setName(QStringLiteral("SWMM")); // Series With Model Mapper
666 666
667 667 CustomTableModel *model = qobject_cast<CustomTableModel *>(m_hModelMapper->model());
668 foreach (QCandlestickSet *set, series->candlestickSets())
668 foreach (QCandlestickSet *set, series->sets())
669 669 model->addRow(set);
670 670
671 m_hModelMapper->setFirstCandlestickSetRow(0);
672 m_hModelMapper->setLastCandlestickSetRow(model->rowCount() - 1);
671 m_hModelMapper->setFirstSetRow(0);
672 m_hModelMapper->setLastSetRow(model->rowCount() - 1);
673 673 m_hModelMapper->setSeries(series);
674 674 }
675 675
@@ -683,8 +683,8 void MainWidget::detachModelMapper()
683 683 series->setName(QStringLiteral("S1"));
684 684
685 685 m_hModelMapper->setSeries(nullptr);
686 m_hModelMapper->setFirstCandlestickSetRow(-1);
687 m_hModelMapper->setLastCandlestickSetRow(-1);
686 m_hModelMapper->setFirstSetRow(-1);
687 m_hModelMapper->setLastSetRow(-1);
688 688
689 689 CustomTableModel *model = qobject_cast<CustomTableModel *>(m_hModelMapper->model());
690 690 model->clearRows();
General Comments 0
You need to be logged in to leave comments. Login now