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