##// END OF EJS Templates
changed barseries to abstractbarseries in documentation
changed barseries to abstractbarseries in documentation

File last commit:

r1584:900775017aef
r1590:3b61da5c2fc6
Show More
declarativebarseries.cpp
393 lines | 11.0 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
Bar model mapper to Qml custom model demo
r1313 #include <QVBarModelMapper>
#include <QHBarModelMapper>
Tero Ahola
Added value and category axis to QML api
r1550 #include <QAbstractAxis>
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
Property notifications: axis minmax, bar properties, xyseries p-visibl and count
r1465 connect(this, SIGNAL(valuesAdded(int,int)), this, SLOT(handleCountChanged(int, int)));
connect(this, SIGNAL(valuesRemoved(int,int)), this, SLOT(handleCountChanged(int, int)));
}
void DeclarativeBarSet::handleCountChanged(int index, int count)
{
Q_UNUSED(index)
Q_UNUSED(count)
emit countChanged(QBarSet::count());
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++)
Tero Ahola
QML BarSet data manipulation
r1513 values.append(QVariant(QBarSet::at(i)));
Tero Ahola
Added declarative model for bar series
r1162 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))
Tero Ahola
QML BarSet data manipulation
r1513 QBarSet::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) :
sauimone
QBarSeries to QAbstractBarSeries
r1584 QAbstractBarSeries(parent)
Tero Ahola
Added declarative model for bar series
r1162 {
Tero Ahola
QML BarSeries added/removed signals
r1506 connect(this, SIGNAL(barsetsAdded(QList<QBarSet*>)), this, SLOT(handleAdded(QList<QBarSet*>)));
connect(this, SIGNAL(barsetsRemoved(QList<QBarSet*>)), this, SLOT(handleRemoved(QList<QBarSet*>)));
}
void DeclarativeBarSeries::handleAdded(QList<QBarSet* > barsets)
{
foreach(QBarSet *b, barsets) {
DeclarativeBarSet *barset = qobject_cast<DeclarativeBarSet *>(b);
emit added(barset);
}
}
void DeclarativeBarSeries::handleRemoved(QList<QBarSet* > barsets)
{
foreach(QBarSet *b, barsets) {
DeclarativeBarSet *barset = qobject_cast<DeclarativeBarSet *>(b);
emit removed(barset);
}
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()) {
Tero Ahola
Color properties to QML BarSet API
r1302 if (qobject_cast<DeclarativeBarSet *>(child)) {
sauimone
QBarSeries to QAbstractBarSeries
r1584 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
Tero Ahola
Added value and category axis to QML api
r1550 } else if (qobject_cast<QVBarModelMapper *>(child)) {
Tero Ahola
Bar model mapper to Qml custom model demo
r1313 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
mapper->setSeries(this);
Tero Ahola
Added value and category axis to QML api
r1550 } else if (qobject_cast<QHBarModelMapper *>(child)) {
Tero Ahola
Bar model mapper to Qml custom model demo
r1313 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
mapper->setSeries(this);
Tero Ahola
QML BarSeries API to support BarSet children
r1193 }
}
}
Tero Ahola
Added value and category axis to QML api
r1550 void DeclarativeBarSeries::setAxisX(QAbstractAxis *axis)
{
Michal Klocek
Refactor QChart API...
r1577 chart()->setAxisX(axis, this);
Tero Ahola
Added value and category axis to QML api
r1550 }
QAbstractAxis *DeclarativeBarSeries::axisX()
{
return chart()->axisX(this);
}
void DeclarativeBarSeries::setAxisY(QAbstractAxis *axis)
{
Michal Klocek
Refactor QChart API...
r1577 chart()->setAxisY(axis, this);
Tero Ahola
Added value and category axis to QML api
r1550 }
QAbstractAxis *DeclarativeBarSeries::axisY()
{
return chart()->axisY(this);
}
Tero Ahola
Bar model mapper to Qml custom model demo
r1313 QDeclarativeListProperty<QObject> DeclarativeBarSeries::seriesChildren()
Tero Ahola
QML BarSeries API to support BarSet children
r1193 {
Tero Ahola
Bar model mapper to Qml custom model demo
r1313 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
}
void DeclarativeBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
{
// Empty implementation; the children are parsed in componentComplete instead
Q_UNUSED(list);
Q_UNUSED(element);
Tero Ahola
Added declarative model for bar series
r1162 }
Tero Ahola
Added QML api for bar series
r646
Tero Ahola
Color properties to QML BarSet API
r1302 DeclarativeBarSet *DeclarativeBarSeries::at(int index)
{
QList<QBarSet*> setList = barSets();
Tero Ahola
Implemented BarSeries::append, insert, remove and clear to QML API
r1511 if (index >= 0 && index < setList.count())
Tero Ahola
Color properties to QML BarSet API
r1302 return qobject_cast<DeclarativeBarSet *>(setList[index]);
return 0;
}
Tero Ahola
Implemented BarSeries::append, insert, remove and clear to QML API
r1511 DeclarativeBarSet *DeclarativeBarSeries::insert(int index, QString label, QVariantList values)
{
Tero Ahola
QML methods of series: several fixes and documentation
r1521 int insertIndex = index;
if (insertIndex < 0)
insertIndex = 0;
else if (insertIndex > count())
insertIndex = count();
Tero Ahola
Implemented BarSeries::append, insert, remove and clear to QML API
r1511 DeclarativeBarSet *barset = new DeclarativeBarSet(this);
barset->setLabel(label);
barset->setValues(values);
sauimone
QBarSeries to QAbstractBarSeries
r1584 if (QAbstractBarSeries::insert(insertIndex, barset))
Tero Ahola
Implemented BarSeries::append, insert, remove and clear to QML API
r1511 return barset;
delete barset;
return 0;
}
Tero Ahola
Cleaning up declarative implementation
r1211 DeclarativeGroupedBarSeries::DeclarativeGroupedBarSeries(QDeclarativeItem *parent) :
QGroupedBarSeries(parent)
{
}
void DeclarativeGroupedBarSeries::classBegin()
{
}
void DeclarativeGroupedBarSeries::componentComplete()
{
foreach(QObject *child, children()) {
Tero Ahola
Color properties to QML BarSet API
r1302 if (qobject_cast<DeclarativeBarSet *>(child)) {
sauimone
QBarSeries to QAbstractBarSeries
r1584 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
Tero Ahola
Bar model mapper to Qml custom model demo
r1313 } else if(qobject_cast<QVBarModelMapper *>(child)) {
QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
mapper->setSeries(this);
} else if(qobject_cast<QHBarModelMapper *>(child)) {
QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
mapper->setSeries(this);
Tero Ahola
Cleaning up declarative implementation
r1211 }
}
}
Tero Ahola
Added value and category axis to QML api
r1550 void DeclarativeGroupedBarSeries::setAxisX(QAbstractAxis *axis)
{
Michal Klocek
Refactor QChart API...
r1577 chart()->setAxisX(axis, this);
Tero Ahola
Added value and category axis to QML api
r1550 }
QAbstractAxis *DeclarativeGroupedBarSeries::axisX()
{
return chart()->axisX(this);
}
void DeclarativeGroupedBarSeries::setAxisY(QAbstractAxis *axis)
{
Michal Klocek
Refactor QChart API...
r1577 chart()->setAxisY(axis, this);
Tero Ahola
Added value and category axis to QML api
r1550 }
QAbstractAxis *DeclarativeGroupedBarSeries::axisY()
{
return chart()->axisY(this);
}
Tero Ahola
Bar model mapper to Qml custom model demo
r1313 QDeclarativeListProperty<QObject> DeclarativeGroupedBarSeries::seriesChildren()
{
return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
}
void DeclarativeGroupedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
Tero Ahola
Cleaning up declarative implementation
r1211 {
Tero Ahola
Bar model mapper to Qml custom model demo
r1313 // Empty implementation; the children are parsed in componentComplete instead
Q_UNUSED(list);
Q_UNUSED(element);
Tero Ahola
Cleaning up declarative implementation
r1211 }
Tero Ahola
Color properties to QML BarSet API
r1302 DeclarativeBarSet *DeclarativeGroupedBarSeries::at(int index)
{
QList<QBarSet*> setList = barSets();
Tero Ahola
Implemented BarSeries::append, insert, remove and clear to QML API
r1511 if (index >= 0 && index < setList.count())
Tero Ahola
Color properties to QML BarSet API
r1302 return qobject_cast<DeclarativeBarSet *>(setList[index]);
return 0;
}
Tero Ahola
Implemented BarSeries::append, insert, remove and clear to QML API
r1511 DeclarativeBarSet *DeclarativeGroupedBarSeries::insert(int index, QString label, QVariantList values)
{
DeclarativeBarSet *barset = new DeclarativeBarSet(this);
barset->setLabel(label);
barset->setValues(values);
if (QGroupedBarSeries::insert(index, barset))
return barset;
delete barset;
return 0;
}
Tero Ahola
Added stacked and percent bar series to QML api
r1318 DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QDeclarativeItem *parent) :
QStackedBarSeries(parent)
{
}
void DeclarativeStackedBarSeries::classBegin()
{
}
void DeclarativeStackedBarSeries::componentComplete()
{
foreach(QObject *child, children()) {
if (qobject_cast<DeclarativeBarSet *>(child)) {
sauimone
QBarSeries to QAbstractBarSeries
r1584 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
Tero Ahola
Added stacked and percent bar series to QML api
r1318 } else if(qobject_cast<QVBarModelMapper *>(child)) {
QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
mapper->setSeries(this);
} else if(qobject_cast<QHBarModelMapper *>(child)) {
QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
mapper->setSeries(this);
}
}
}
Tero Ahola
Added value and category axis to QML api
r1550 void DeclarativeStackedBarSeries::setAxisX(QAbstractAxis *axis)
{
Michal Klocek
Refactor QChart API...
r1577 chart()->setAxisX(axis, this);
Tero Ahola
Added value and category axis to QML api
r1550 }
QAbstractAxis *DeclarativeStackedBarSeries::axisX()
{
return chart()->axisX(this);
}
void DeclarativeStackedBarSeries::setAxisY(QAbstractAxis *axis)
{
Michal Klocek
Refactor QChart API...
r1577 chart()->setAxisY(axis, this);
Tero Ahola
Added value and category axis to QML api
r1550 }
QAbstractAxis *DeclarativeStackedBarSeries::axisY()
{
return chart()->axisY(this);
}
Tero Ahola
Added stacked and percent bar series to QML api
r1318 QDeclarativeListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren()
{
return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
}
void DeclarativeStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
{
// Empty implementation; the children are parsed in componentComplete instead
Q_UNUSED(list);
Q_UNUSED(element);
}
DeclarativeBarSet *DeclarativeStackedBarSeries::at(int index)
{
QList<QBarSet*> setList = barSets();
Tero Ahola
Implemented BarSeries::append, insert, remove and clear to QML API
r1511 if (index >= 0 && index < setList.count())
Tero Ahola
Added stacked and percent bar series to QML api
r1318 return qobject_cast<DeclarativeBarSet *>(setList[index]);
return 0;
}
Tero Ahola
Implemented BarSeries::append, insert, remove and clear to QML API
r1511 DeclarativeBarSet *DeclarativeStackedBarSeries::insert(int index, QString label, QVariantList values)
{
DeclarativeBarSet *barset = new DeclarativeBarSet(this);
barset->setLabel(label);
barset->setValues(values);
if (QStackedBarSeries::insert(index, barset))
return barset;
delete barset;
return 0;
}
Tero Ahola
Added stacked and percent bar series to QML api
r1318 DeclarativePercentBarSeries::DeclarativePercentBarSeries(QDeclarativeItem *parent) :
QPercentBarSeries(parent)
{
}
void DeclarativePercentBarSeries::classBegin()
{
}
void DeclarativePercentBarSeries::componentComplete()
{
foreach(QObject *child, children()) {
if (qobject_cast<DeclarativeBarSet *>(child)) {
sauimone
QBarSeries to QAbstractBarSeries
r1584 QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
Tero Ahola
Added stacked and percent bar series to QML api
r1318 } else if(qobject_cast<QVBarModelMapper *>(child)) {
QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
mapper->setSeries(this);
} else if(qobject_cast<QHBarModelMapper *>(child)) {
QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
mapper->setSeries(this);
}
}
}
Tero Ahola
Added value and category axis to QML api
r1550 void DeclarativePercentBarSeries::setAxisX(QAbstractAxis *axis)
{
Michal Klocek
Refactor QChart API...
r1577 chart()->setAxisX(axis, this);
Tero Ahola
Added value and category axis to QML api
r1550 }
QAbstractAxis *DeclarativePercentBarSeries::axisX()
{
return chart()->axisX(this);
}
void DeclarativePercentBarSeries::setAxisY(QAbstractAxis *axis)
{
Michal Klocek
Refactor QChart API...
r1577 chart()->setAxisY(axis, this);
Tero Ahola
Added value and category axis to QML api
r1550 }
QAbstractAxis *DeclarativePercentBarSeries::axisY()
{
return chart()->axisY(this);
}
Tero Ahola
Added stacked and percent bar series to QML api
r1318 QDeclarativeListProperty<QObject> DeclarativePercentBarSeries::seriesChildren()
{
return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
}
void DeclarativePercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
{
// Empty implementation; the children are parsed in componentComplete instead
Q_UNUSED(list);
Q_UNUSED(element);
}
DeclarativeBarSet *DeclarativePercentBarSeries::at(int index)
{
QList<QBarSet*> setList = barSets();
Tero Ahola
Implemented BarSeries::append, insert, remove and clear to QML API
r1511 if (index >= 0 && index < setList.count())
Tero Ahola
Added stacked and percent bar series to QML api
r1318 return qobject_cast<DeclarativeBarSet *>(setList[index]);
return 0;
}
Tero Ahola
Implemented BarSeries::append, insert, remove and clear to QML API
r1511 DeclarativeBarSet *DeclarativePercentBarSeries::insert(int index, QString label, QVariantList values)
{
DeclarativeBarSet *barset = new DeclarativeBarSet(this);
barset->setLabel(label);
barset->setValues(values);
if (QPercentBarSeries::insert(index, barset))
return barset;
delete barset;
return 0;
}
Tero Ahola
Added QML api for bar series
r646 #include "moc_declarativebarseries.cpp"
QTCOMMERCIALCHART_END_NAMESPACE