##// END OF EJS Templates
Refactored PieSeriesModelMapper
Refactored PieSeriesModelMapper

File last commit:

r1230:39fc8bad4e45
r1231:c31e07d12ed2
Show More
declarativebarseries.cpp
157 lines | 4.2 KiB | text/x-c | CppLexer
/ plugins / declarative / declarativebarseries.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
Added QML api for bar series
r646 #include "declarativebarseries.h"
#include "declarativechart.h"
Tero Ahola
Added declarative model for bar series
r1162 #include <QBarSet>
Tero Ahola
Added QML api for bar series
r646
QTCOMMERCIALCHART_BEGIN_NAMESPACE
Tero Ahola
Added declarative model for bar series
r1162 DeclarativeBarSet::DeclarativeBarSet(QObject *parent) :
QBarSet("", parent)
Tero Ahola
Added QML api for bar series
r646 {
}
Tero Ahola
Added declarative model for bar series
r1162 QVariantList DeclarativeBarSet::values()
Tero Ahola
Added QML api for bar series
r646 {
Tero Ahola
Added declarative model for bar series
r1162 QVariantList values;
for (int i(0); i < count(); i++)
values.append(QVariant(at(i)));
return values;
Tero Ahola
Enabled dummy bar chart impl in QML again
r1004 }
Tero Ahola
Added QML api for bar series
r646
Tero Ahola
Added declarative model for bar series
r1162 void DeclarativeBarSet::setValues(QVariantList values)
Tero Ahola
Enabled dummy bar chart impl in QML again
r1004 {
Tero Ahola
Added declarative model for bar series
r1162 while (count())
remove(count() - 1);
Tero Ahola
Added QML api for bar series
r646
Tero Ahola
Added declarative model for bar series
r1162 for (int i(0); i < values.count(); i++) {
if (values.at(i).canConvert(QVariant::Double))
append(values[i].toDouble());
Tero Ahola
Enabled dummy bar chart impl in QML again
r1004 }
Tero Ahola
Added declarative model for bar series
r1162 }
Tero Ahola
Added QML api for bar series
r646
Tero Ahola
Added declarative model for bar series
r1162 DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) :
Tero Ahola
QML weather example to use data API instead of model
r1222 QBarSeries(parent)
Tero Ahola
Added declarative model for bar series
r1162 {
}
Tero Ahola
Added QML api for bar series
r646
Tero Ahola
Added declarative model for bar series
r1162 void DeclarativeBarSeries::classBegin()
{
}
Tero Ahola
Added QML api for bar series
r646
Tero Ahola
Added declarative model for bar series
r1162 void DeclarativeBarSeries::componentComplete()
{
Tero Ahola
QML BarSeries API to support BarSet children
r1193 foreach(QObject *child, children()) {
if (qobject_cast<QBarSet *>(child)) {
Marek Rosa
Removed unnecessary include
r1196 QBarSeries::append(qobject_cast<QBarSet *>(child));
Tero Ahola
QML BarSeries API to support BarSet children
r1193 }
}
}
QDeclarativeListProperty<DeclarativeBarSet> DeclarativeBarSeries::initialBarSets()
{
return QDeclarativeListProperty<DeclarativeBarSet>(this, 0, &DeclarativeBarSeries::appendInitialBarSets);
Tero Ahola
Added declarative model for bar series
r1162 }
Tero Ahola
Added QML api for bar series
r646
Tero Ahola
QML BarSeries API to support BarSet children
r1193 bool DeclarativeBarSeries::setDeclarativeModel(DeclarativeTableModel *model)
Tero Ahola
Added declarative model for bar series
r1162 {
QAbstractItemModel *m = qobject_cast<QAbstractItemModel *>(model);
bool value(false);
if (m) {
Marek Rosa
All model related methods and members removed from the series. QML stuff commented out where complaining
r1230 // setModel(m);
Tero Ahola
Added declarative model for bar series
r1162 //setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical);
Marek Rosa
Commented out some lines in declarative examples as barseries model is for now disabled
r1165 // setModelMapping(0, 1, 1, Qt::Vertical);
Tero Ahola
Added declarative model for bar series
r1162 } else {
qWarning("DeclarativeBarSeries: Illegal model");
}
return value;
}
Tero Ahola
Added QML api for bar series
r646
Tero Ahola
QML BarSeries API to support BarSet children
r1193 DeclarativeTableModel *DeclarativeBarSeries::declarativeModel()
Tero Ahola
Added declarative model for bar series
r1162 {
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
Added declarative model for bar series
r1162 }
Tero Ahola
Enabled dummy bar chart impl in QML again
r1004
Tero Ahola
QML weather example to use data API instead of model
r1222 void DeclarativeBarSeries::setBarCategories(QStringList categories)
{
setCategories(categories);
}
QStringList DeclarativeBarSeries::barCategories()
{
return categories();
}
Tero Ahola
Cleaning up declarative implementation
r1211 DeclarativeGroupedBarSeries::DeclarativeGroupedBarSeries(QDeclarativeItem *parent) :
QGroupedBarSeries(parent)
{
}
void DeclarativeGroupedBarSeries::classBegin()
{
}
void DeclarativeGroupedBarSeries::componentComplete()
{
foreach(QObject *child, children()) {
if (qobject_cast<QBarSet *>(child)) {
QBarSeries::append(qobject_cast<QBarSet *>(child));
}
}
}
QDeclarativeListProperty<DeclarativeBarSet> DeclarativeGroupedBarSeries::initialBarSets()
{
return QDeclarativeListProperty<DeclarativeBarSet>(this, 0, &DeclarativeGroupedBarSeries::appendInitialBarSets);
}
bool DeclarativeGroupedBarSeries::setDeclarativeModel(DeclarativeTableModel *model)
{
QAbstractItemModel *m = qobject_cast<QAbstractItemModel *>(model);
bool value(false);
if (m) {
Marek Rosa
All model related methods and members removed from the series. QML stuff commented out where complaining
r1230 // setModel(m);
Tero Ahola
Cleaning up declarative implementation
r1211 //setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical);
// setModelMapping(0, 1, 1, Qt::Vertical);
} else {
qWarning("DeclarativeGroupedBarSeries: Illegal model");
}
return value;
}
DeclarativeTableModel *DeclarativeGroupedBarSeries::declarativeModel()
{
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
Cleaning up declarative implementation
r1211 }
void DeclarativeGroupedBarSeries::setBarCategories(QStringList categories)
Tero Ahola
Added declarative model for bar series
r1162 {
setCategories(categories);
Tero Ahola
QML bar series categories
r726 }
Tero Ahola
Cleaning up declarative implementation
r1211 QStringList DeclarativeGroupedBarSeries::barCategories()
Tero Ahola
QML bar series categories
r726 {
Tero Ahola
Added declarative model for bar series
r1162 return categories();
Tero Ahola
QML bar series categories
r726 }
Tero Ahola
Added QML api for bar series
r646 #include "moc_declarativebarseries.cpp"
QTCOMMERCIALCHART_END_NAMESPACE