##// END OF EJS Templates
fix compilation error with qpiemodelmapper
fix compilation error with qpiemodelmapper

File last commit:

r1230:39fc8bad4e45
r1234:6ba759c4c3bd
Show More
declarativepieseries.cpp
104 lines | 2.8 KiB | text/x-c | CppLexer
/ plugins / declarative / declarativepieseries.cpp
Jani Honkonen
Add/modify license headers
r830 /****************************************************************************
**
** Copyright (C) 2012 Digia Plc
** All rights reserved.
** For any questions to Digia, please use contact form at http://qt.digia.com
**
** This file is part of the Qt Commercial Charts Add-on.
**
** $QT_BEGIN_LICENSE$
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.
**
** If you have questions regarding the use of this file, please use
** contact form at http://qt.digia.com
** $QT_END_LICENSE$
**
****************************************************************************/
Tero Ahola
Dynamic data for QML pie and line series
r215 #include "declarativepieseries.h"
#include "declarativechart.h"
#include "qchart.h"
Tero Ahola
Draft version for QML PieSeries model API
r1130 #include <qdeclarativelist.h>
Marek Rosa
Mapper class added for xyseries and pieseries. Model support commented out for barseries for now.
r1164 #include "qpiemodelmapper.h"
Tero Ahola
Dynamic data for QML pie and line series
r215
QTCOMMERCIALCHART_BEGIN_NAMESPACE
Tero Ahola
Declarative series classed now derived from QSeries childs
r789 DeclarativePieSeries::DeclarativePieSeries(QObject *parent) :
Tero Ahola
Simplified declarative implementation
r1117 QPieSeries(parent)
Tero Ahola
Dynamic data for QML pie and line series
r215 {
Tero Ahola
Now using only one declarative model
r1169 // TODO: set default model on init?
Tero Ahola
Removed usage of model in QML pie example
r1189 // setModel(new DeclarativeTableModel());
Tero Ahola
Now using only one declarative model
r1169
Tero Ahola
Removed usage of model in QML pie example
r1189 // TODO: Set default mapper parameters to allow easy to use PieSeries api?
Tero Ahola
Commented out problematic pie model mapper in declarative impl
r1212 // QPieModelMapper *mapper = modelMapper();//new QPieModelMapper();
// mapper->setMapLabels(0);
// mapper->setMapValues(1);
// mapper->setOrientation(Qt::Vertical);
// mapper->setFirst(0);
// mapper->setCount(-1);
Marek Rosa
Pie now has defualt Model to which slice data is copied.
r1195 // setModelMapper(mapper);
Tero Ahola
Dynamic data for QML pie and line series
r215 }
Tero Ahola
QML and static data in pie and xy series
r1186 void DeclarativePieSeries::classBegin()
{
}
void DeclarativePieSeries::componentComplete()
{
foreach(QObject *child, children()) {
if (qobject_cast<QPieSlice *>(child)) {
Tero Ahola
Removed usage of model in QML pie example
r1189 QPieSeries::append(qobject_cast<QPieSlice *>(child));
Tero Ahola
QML and static data in pie and xy series
r1186 }
}
}
QDeclarativeListProperty<QPieSlice> DeclarativePieSeries::initialSlices()
{
return QDeclarativeListProperty<QPieSlice>(this, 0, &DeclarativePieSeries::appendInitialSlices);
}
Tero Ahola
Removed usage of model in QML pie example
r1189 QPieSlice *DeclarativePieSeries::at(int index)
Tero Ahola
Added declarative model for bar series
r1162 {
QList<QPieSlice*> sliceList = slices();
if (index < sliceList.count())
return sliceList[index];
return 0;
}
Tero Ahola
Separated series model stuff from data api in QML examples
r1202 QPieSlice* DeclarativePieSeries::find(QString label)
{
foreach (QPieSlice *slice, slices()) {
if (slice->label() == label)
return slice;
}
return 0;
}
Tero Ahola
Removed usage of model in QML pie example
r1189 QPieSlice* DeclarativePieSeries::append(QString name, qreal value)
{
// TODO: parameter order is wrong, switch it:
Jani Honkonen
pie: change the order of parameters when creating slices to be more intuitive
r1206 return QPieSeries::append(name, value);
Tero Ahola
Removed usage of model in QML pie example
r1189 }
Tero Ahola
Now using only one declarative model
r1169 void DeclarativePieSeries::setPieModel(DeclarativeTableModel *model)
Tero Ahola
Dynamic data for QML pie and line series
r215 {
Tero Ahola
Draft version for QML PieSeries model API
r1130 QAbstractItemModel *m = qobject_cast<QAbstractItemModel *>(model);
if (m) {
Marek Rosa
All model related methods and members removed from the series. QML stuff commented out where complaining
r1230 // QPieSeries::setModel(m);
Tero Ahola
Draft for QML demo that shows weather forecasts
r1139 } else {
qWarning("DeclarativePieSeries: Illegal model");
Tero Ahola
Draft version for QML PieSeries model API
r1130 }
Tero Ahola
Dynamic data for QML pie and line series
r215 }
Tero Ahola
Now using only one declarative model
r1169 DeclarativeTableModel *DeclarativePieSeries::pieModel()
Tero Ahola
Dynamic data for QML pie and line series
r215 {
Marek Rosa
All model related methods and members removed from the series. QML stuff commented out where complaining
r1230 return 0;//qobject_cast<DeclarativeTableModel *>(model());
Tero Ahola
Dynamic data for QML pie and line series
r215 }
#include "moc_declarativepieseries.cpp"
QTCOMMERCIALCHART_END_NAMESPACE