@@ -56,6 +56,12 | |||
|
56 | 56 | <li><a href="qstackedbarseries.html">QStackedBarSeries</a></li> |
|
57 | 57 | <li><a href="qxyseries.html">QXYSeries</a></li> |
|
58 | 58 |
|
|
59 | <li><a href="qhpiemodelmapper.html">QHPieModelMapper</a></li> | |
|
60 | <li><a href="qvpiemodelmapper.html">QVPieModelMapper</a></li> | |
|
61 | <li><a href="qhbarmodelmapper.html">QHBarModelMapper</a></li> | |
|
62 | <li><a href="qvbarmodelmapper.html">QVBarModelMapper</a></li> | |
|
63 | <li><a href="qhxymodelmapper.html">QHXYModelMapper</a></li> | |
|
64 | <li><a href="qvxymodelmapper.html">QVXYModelMapper</a></li> | |
|
59 | 65 | </ul> |
|
60 | 66 | </td> |
|
61 | 67 | </tr> |
@@ -2,6 +2,8 | |||
|
2 | 2 | #include "qbarmodelmapper_p.h" |
|
3 | 3 | #include "qbarseries.h" |
|
4 | 4 | #include "qbarset.h" |
|
5 | #include "qchart.h" | |
|
6 | #include "qaxis.h" | |
|
5 | 7 | #include <QAbstractItemModel> |
|
6 | 8 | |
|
7 | 9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
@@ -145,7 +147,6 void QBarModelMapper::reset() | |||
|
145 | 147 | Q_D(QBarModelMapper); |
|
146 | 148 | d->m_first = 0; |
|
147 | 149 | d->m_count = -1; |
|
148 | d->m_orientation = Qt::Vertical; | |
|
149 | 150 | d->m_firstBarSetSection = -1; |
|
150 | 151 | d->m_lastBarSetSection = -1; |
|
151 | 152 | d->m_categoriesSection = -1; |
@@ -185,8 +186,12 QBarSet* QBarModelMapperPrivate::barSet(QModelIndex index) | |||
|
185 | 186 | return 0; |
|
186 | 187 | |
|
187 | 188 | if (m_orientation == Qt::Vertical && index.column() >= m_firstBarSetSection && index.column() <= m_lastBarSetSection) { |
|
188 | if (index.row() >= m_first && (m_count == - 1 || index.row() < m_first + m_count)) | |
|
189 | if (index.row() >= m_first && (m_count == - 1 || index.row() < m_first + m_count)) { | |
|
190 | // if (m_model->index(index.row(), m_valuesSection).isValid() && m_model->index(index.row(), m_labelsSection).isValid()) | |
|
189 | 191 | return m_series->barSets().at(index.column() - m_firstBarSetSection); |
|
192 | // else | |
|
193 | // return 0; | |
|
194 | } | |
|
190 | 195 | } else if (m_orientation == Qt::Horizontal && index.row() >= m_firstBarSetSection && index.row() <= m_lastBarSetSection) { |
|
191 | 196 | if (index.column() >= m_first && (m_count == - 1 || index.column() < m_first + m_count)) |
|
192 | 197 | return m_series->barSets().at(index.row() - m_firstBarSetSection); |
@@ -334,6 +339,7 void QBarModelMapperPrivate::insertData(int start, int end) | |||
|
334 | 339 | point.setY(m_model->data(yModelIndex(i - m_first), Qt::DisplayRole).toDouble()); |
|
335 | 340 | m_series->insert(i - m_first, point); |
|
336 | 341 | } |
|
342 | >>>>>>> Stashed changes | |
|
337 | 343 | } |
|
338 | 344 | |
|
339 | 345 | // remove excess of slices (abouve m_count) |
@@ -403,7 +409,7 void QBarModelMapperPrivate::initializeBarFromModel() | |||
|
403 | 409 | m_series->append(barSet); |
|
404 | 410 | } |
|
405 | 411 | |
|
406 | if (m_categoriesSection != -1) { | |
|
412 | if (m_series->chart() && m_categoriesSection != -1) { | |
|
407 | 413 | int posInCategories = 0; |
|
408 | 414 | QStringList categories; |
|
409 | 415 | QModelIndex categoriesIndex = categoriesModelIndex(posInCategories); |
@@ -412,8 +418,7 void QBarModelMapperPrivate::initializeBarFromModel() | |||
|
412 | 418 | posInCategories++; |
|
413 | 419 | categoriesIndex = categoriesModelIndex(posInCategories); |
|
414 | 420 | } |
|
415 | // TODO: set the categories to axis | |
|
416 | // m_series->setCategories(categories); | |
|
421 | m_series->chart()->axisX()->categories()->insert(categories); | |
|
417 | 422 | } |
|
418 | 423 | blockSeriesSignals(false); |
|
419 | 424 | } |
@@ -10,6 +10,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
10 | 10 | |
|
11 | 11 | class QBarModelMapperPrivate; |
|
12 | 12 | class QBarSeries; |
|
13 | class QChart; | |
|
13 | 14 | |
|
14 | 15 | class QTCOMMERCIALCHART_EXPORT QBarModelMapper : public QObject |
|
15 | 16 | { |
@@ -36,6 +37,9 public: | |||
|
36 | 37 | int count() const; |
|
37 | 38 | void setCount(int count); |
|
38 | 39 | |
|
40 | void reset(); | |
|
41 | ||
|
42 | protected: | |
|
39 | 43 | int firstBarSetSection() const; |
|
40 | 44 | void setFirstBarSetSection(int firstBarSetSection); |
|
41 | 45 | |
@@ -45,12 +49,9 public: | |||
|
45 | 49 | int categoriesSection() const; |
|
46 | 50 | void setCategoriesSection(int categoriesSection); |
|
47 | 51 | |
|
48 | protected: | |
|
49 | 52 | Qt::Orientation orientation() const; |
|
50 | 53 | void setOrientation(Qt::Orientation orientation); |
|
51 | 54 |
|
|
52 | void reset(); | |
|
53 | ||
|
54 | 55 | Q_SIGNALS: |
|
55 | 56 | void updated(); |
|
56 | 57 |
@@ -2,6 +2,14 | |||
|
2 | 2 | |
|
3 | 3 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
4 | 4 | |
|
5 | /*! | |
|
6 | \class QHBarModelMapper | |
|
7 | \brief part of QtCommercial chart API. | |
|
8 | \mainclass | |
|
9 | ||
|
10 | Nothing here yet | |
|
11 | */ | |
|
12 | ||
|
5 | 13 | QHBarModelMapper::QHBarModelMapper(QObject *parent) : |
|
6 | 14 | QBarModelMapper(parent) |
|
7 | 15 | { |
@@ -2,6 +2,14 | |||
|
2 | 2 | |
|
3 | 3 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
4 | 4 | |
|
5 | /*! | |
|
6 | \class QVBarModelMapper | |
|
7 | \brief part of QtCommercial chart API. | |
|
8 | \mainclass | |
|
9 | ||
|
10 | Nothing here yet | |
|
11 | */ | |
|
12 | ||
|
5 | 13 | QVBarModelMapper::QVBarModelMapper(QObject *parent) : |
|
6 | 14 | QBarModelMapper(parent) |
|
7 | 15 | { |
@@ -22,6 +22,14 | |||
|
22 | 22 | |
|
23 | 23 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | 24 | |
|
25 | /*! | |
|
26 | \class QHPieModelMapper | |
|
27 | \brief part of QtCommercial chart API. | |
|
28 | \mainclass | |
|
29 | ||
|
30 | Nothing here yet | |
|
31 | */ | |
|
32 | ||
|
25 | 33 | QHPieModelMapper::QHPieModelMapper(QObject *parent) : |
|
26 | 34 | QPieModelMapper(parent) |
|
27 | 35 | { |
@@ -23,6 +23,14 | |||
|
23 | 23 | |
|
24 | 24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
25 | 25 | |
|
26 | /*! | |
|
27 | \class QVPieModelMapper | |
|
28 | \brief part of QtCommercial chart API. | |
|
29 | \mainclass | |
|
30 | ||
|
31 | Nothing here yet | |
|
32 | */ | |
|
33 | ||
|
26 | 34 | QVPieModelMapper::QVPieModelMapper(QObject *parent) : |
|
27 | 35 | QPieModelMapper(parent) |
|
28 | 36 | { |
@@ -2,6 +2,14 | |||
|
2 | 2 | |
|
3 | 3 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
4 | 4 | |
|
5 | /*! | |
|
6 | \class QHXYModelMapper | |
|
7 | \brief part of QtCommercial chart API. | |
|
8 | \mainclass | |
|
9 | ||
|
10 | Nothing here yet | |
|
11 | */ | |
|
12 | ||
|
5 | 13 | QHXYModelMapper::QHXYModelMapper(QObject *parent) : |
|
6 | 14 | QXYModelMapper(parent) |
|
7 | 15 | { |
@@ -2,6 +2,14 | |||
|
2 | 2 | |
|
3 | 3 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
4 | 4 | |
|
5 | /*! | |
|
6 | \class QVXYModelMapper | |
|
7 | \brief part of QtCommercial chart API. | |
|
8 | \mainclass | |
|
9 | ||
|
10 | Nothing here yet | |
|
11 | */ | |
|
12 | ||
|
5 | 13 | QVXYModelMapper::QVXYModelMapper(QObject *parent) : |
|
6 | 14 | QXYModelMapper(parent) |
|
7 | 15 | { |
@@ -136,7 +136,7 TableWidget::TableWidget(QWidget *parent) | |||
|
136 | 136 | connect(m_pieRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); |
|
137 | 137 | connect(m_areaRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); |
|
138 | 138 | connect(m_barRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); |
|
139 |
m_ |
|
|
139 | m_barRadioButton->setChecked(true); | |
|
140 | 140 | |
|
141 | 141 | // radio buttons layout |
|
142 | 142 | QVBoxLayout* radioLayout = new QVBoxLayout; |
@@ -484,23 +484,27 void TableWidget::updateChartType(bool toggle) | |||
|
484 | 484 | // barSeries->setModelMappingRange(2, 5); |
|
485 | 485 | // barSeries->setModelMapping(5, 2, 4, Qt::Vertical); |
|
486 | 486 | |
|
487 | ||
|
487 | 488 | int first = 3; |
|
488 |
|
|
|
489 | int count = 6; | |
|
489 | 490 | QVBarModelMapper *mapper = new QVBarModelMapper; |
|
490 |
mapper->setCategories |
|
|
491 |
mapper->setFirstBarSet |
|
|
492 |
mapper->setLastBarSet |
|
|
491 | mapper->setCategoriesColumn(5); | |
|
492 | mapper->setFirstBarSetColumn(2); | |
|
493 | mapper->setLastBarSetColumn(4); | |
|
493 | 494 | mapper->setFirst(first); |
|
494 |
|
|
|
495 | mapper->setCount(count); | |
|
495 | 496 | mapper->setSeries(barSeries); |
|
496 | 497 | mapper->setModel(m_model); |
|
497 | 498 | // barSeries->setModelMapper(mapper); |
|
498 | 499 | m_chart->addSeries(barSeries); |
|
500 | ||
|
499 | 501 | QList<QBarSet*> barsets = barSeries->barSets(); |
|
500 | 502 | for (int i = 0; i < barsets.count(); i++) { |
|
501 | 503 | seriesColorHex = "#" + QString::number(barsets.at(i)->brush().color().rgb(), 16).right(6).toUpper(); |
|
502 | 504 | m_model->addMapping(seriesColorHex, QRect(2 + i, first, 1, barsets.at(i)->count())); |
|
503 | 505 | } |
|
506 | ||
|
507 | ||
|
504 | 508 | } |
|
505 | 509 | |
|
506 | 510 |
General Comments 0
You need to be logged in to leave comments.
Login now