##// END OF EJS Templates
Fix compilation issue of chartdesigner
Michal Klocek -
r1199:84c5353058e3
parent child
Show More
@@ -21,6 +21,9
21 #include "engine.h"
21 #include "engine.h"
22 #include <QItemSelectionModel>
22 #include <QItemSelectionModel>
23 #include <QStandardItemModel>
23 #include <QStandardItemModel>
24 #include <QXYModelMapper>
25 #include <QBarModelMapper>
26 #include <QPieModelMapper>
24 #include <QLineSeries>
27 #include <QLineSeries>
25 #include <QSplineSeries>
28 #include <QSplineSeries>
26 #include <QScatterSeries>
29 #include <QScatterSeries>
@@ -32,6 +35,7
32 #include <QChart>
35 #include <QChart>
33 #include <QBarSet>
36 #include <QBarSet>
34
37
38
35 const qint32 MAGIC_NUMBER = 0x66666666;
39 const qint32 MAGIC_NUMBER = 0x66666666;
36
40
37 Engine::Engine(QObject* parent) :
41 Engine::Engine(QObject* parent) :
@@ -116,21 +120,21 QList<QAbstractSeries*> Engine::addSeries(QAbstractSeries::SeriesType type)
116 case QAbstractSeries::SeriesTypeBar:
120 case QAbstractSeries::SeriesTypeBar:
117 {
121 {
118 //TODO: fix me
122 //TODO: fix me
119 QBarSeries *bar = new QBarSeries(QBarCategories() << "temp");
123 QBarSeries *bar = new QBarSeries();
120 setupBarSeries(bar,keys,minRow,maxRow);
124 setupBarSeries(bar,keys,minRow,maxRow);
121 result << bar;
125 result << bar;
122 break;
126 break;
123 }
127 }
124 case QAbstractSeries::SeriesTypePercentBar:
128 case QAbstractSeries::SeriesTypePercentBar:
125 {
129 {
126 QPercentBarSeries *bar = new QPercentBarSeries(QBarCategories() << "temp");
130 QPercentBarSeries *bar = new QPercentBarSeries();
127 setupBarSeries(bar,keys,minRow,maxRow);
131 setupBarSeries(bar,keys,minRow,maxRow);
128 result << bar;
132 result << bar;
129 break;
133 break;
130 }
134 }
131 case QAbstractSeries::SeriesTypeStackedBar:
135 case QAbstractSeries::SeriesTypeStackedBar:
132 {
136 {
133 QStackedBarSeries *bar = new QStackedBarSeries(QBarCategories() << "temp");
137 QStackedBarSeries *bar = new QStackedBarSeries();
134 setupBarSeries(bar,keys,minRow,maxRow);
138 setupBarSeries(bar,keys,minRow,maxRow);
135 result << bar;
139 result << bar;
136 break;
140 break;
@@ -252,8 +256,13 bool Engine::load(const QString &filename)
252 void Engine::setupXYSeries(QXYSeries *xyseries, const QList<int>& columns, int column, int minRow, int maxRow)
256 void Engine::setupXYSeries(QXYSeries *xyseries, const QList<int>& columns, int column, int minRow, int maxRow)
253 {
257 {
254 xyseries->setModel(m_model);
258 xyseries->setModel(m_model);
255 xyseries->setModelMapping(columns.first(), columns.at(column), Qt::Vertical);
259 QXYModelMapper* mapper = new QXYModelMapper(xyseries);
256 xyseries->setModelMappingRange(minRow, maxRow - minRow + 1);
260 xyseries->setModelMapper(mapper);
261 mapper->setMapX(columns.first());
262 mapper->setMapY(columns.at(column));
263 mapper->setOrientation(Qt::Vertical);
264 mapper->setFirst(minRow);
265 mapper->setCount(maxRow - minRow + 1);
257 m_chart->addSeries(xyseries);
266 m_chart->addSeries(xyseries);
258 xyseries->setName(QString("Series %1").arg(m_chart->series().count()));
267 xyseries->setName(QString("Series %1").arg(m_chart->series().count()));
259 QObject::connect(xyseries,SIGNAL(clicked(const QPointF&)),this,SIGNAL(selected()));
268 QObject::connect(xyseries,SIGNAL(clicked(const QPointF&)),this,SIGNAL(selected()));
@@ -271,8 +280,14 void Engine::setupXYSeries(QXYSeries *xyseries, const QList<int>& columns, int c
271 void Engine::setupBarSeries(QBarSeries *bar, const QList<int>& columns, int minRow, int maxRow)
280 void Engine::setupBarSeries(QBarSeries *bar, const QList<int>& columns, int minRow, int maxRow)
272 {
281 {
273 bar->setModel(m_model);
282 bar->setModel(m_model);
274 bar->setModelMapping(columns.first(), columns.at(1), columns.last(), Qt::Vertical);
283 QBarModelMapper* mapper = new QBarModelMapper(bar);
275 bar->setModelMappingRange(minRow, maxRow - minRow + 1);
284 bar->setModelMapper(mapper);
285 mapper->setMapCategories(columns.first());
286 mapper->setMapBarTop(columns.last());
287 mapper->setMapBarBottom(columns.at(1));
288 mapper->setOrientation(Qt::Vertical);
289 mapper->setFirst(minRow);
290 mapper->setCount(maxRow - minRow + 1);
276 m_chart->addSeries(bar);
291 m_chart->addSeries(bar);
277 bar->setName(QString("Series %1").arg(m_chart->series().count()));
292 bar->setName(QString("Series %1").arg(m_chart->series().count()));
278
293
@@ -287,8 +302,13 void Engine::setupBarSeries(QBarSeries *bar, const QList<int>& columns, int minR
287 void Engine::setupPieSeries(QPieSeries *pie, const QList<int>& columns, int minRow, int maxRow)
302 void Engine::setupPieSeries(QPieSeries *pie, const QList<int>& columns, int minRow, int maxRow)
288 {
303 {
289 pie->setModel(m_model);
304 pie->setModel(m_model);
290 pie->setModelMapping(columns.at(1),columns.first() ,Qt::Vertical);
305 QPieModelMapper* mapper = new QPieModelMapper(pie);
291 pie->setModelMappingRange(minRow, maxRow - minRow + 1);
306 pie->setModelMapper(mapper);
307 mapper->setMapValues(columns.at(1));
308 mapper->setMapLabels(columns.first());
309 mapper->setOrientation(Qt::Vertical);
310 mapper->setFirst(minRow);
311 mapper->setCount(maxRow - minRow + 1);
292 m_chart->addSeries(pie);
312 m_chart->addSeries(pie);
293 pie->setName(QString("Series %1").arg(m_chart->series().count()));
313 pie->setName(QString("Series %1").arg(m_chart->series().count()));
294
314
@@ -302,10 +322,20 void Engine::setupAreaSeries(QAreaSeries *series, const QList<int>& columns, int
302 {
322 {
303 series->lowerSeries()->setModel(m_model);
323 series->lowerSeries()->setModel(m_model);
304 series->upperSeries()->setModel(m_model);
324 series->upperSeries()->setModel(m_model);
305 series->upperSeries()->setModelMapping(columns.first(), columns.at(1), Qt::Vertical);
325 QXYModelMapper* umapper = new QXYModelMapper(series);
306 series->lowerSeries()->setModelMapping(columns.first(), columns.at(2), Qt::Vertical);
326 umapper->setMapX(columns.first());
307 series->upperSeries()->setModelMappingRange(minRow, maxRow - minRow + 1);
327 umapper->setMapY(columns.at(1));
308 series->lowerSeries()->setModelMappingRange(minRow, maxRow - minRow + 1);
328 umapper->setOrientation(Qt::Vertical);
329 umapper->setFirst(minRow);
330 umapper->setCount(maxRow - minRow + 1);
331 QXYModelMapper* lmapper = new QXYModelMapper(series);
332 lmapper->setMapX(columns.first());
333 lmapper->setMapY(columns.at(2));
334 lmapper->setOrientation(Qt::Vertical);
335 lmapper->setFirst(minRow);
336 lmapper->setCount(maxRow - minRow + 1);
337 series->upperSeries()->setModelMapper(umapper);
338 series->lowerSeries()->setModelMapper(lmapper);
309 m_chart->addSeries(series);
339 m_chart->addSeries(series);
310 series->setName(QString("Series %1").arg(m_chart->series().count()));
340 series->setName(QString("Series %1").arg(m_chart->series().count()));
311
341
General Comments 0
You need to be logged in to leave comments. Login now