##// END OF EJS Templates
Fix Krazy issues
Fix Krazy issues

File last commit:

r1904:966b9cf96344
r1935:beaeb7cee6fe
Show More
declarativebarseries.cpp
433 lines | 13.6 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"
Tero Ahola
Removed unneeded includes from declarative plugin
r1831 #include "qbarset.h"
#include "qvbarmodelmapper.h"
#include "qhbarmodelmapper.h"
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
Adding missing QML series API line/border properties
r1904 qreal DeclarativeBarSet::borderWidth() const
{
return pen().widthF();
}
void DeclarativeBarSet::setBorderWidth(qreal width)
{
if (width != pen().widthF()) {
QPen p = pen();
p.setWidthF(width);
setPen(p);
emit borderWidthChanged(width);
}
}
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
sauimone
declarative series for horizontal barcharts
r1806 // Declarative bar series ======================================================================================
sauimone
GroupedBarSeries to BarSeries
r1594 DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) :
Tero Ahola
Refactored QML axis handling
r1813 QBarSeries(parent),
m_axisX(0),
m_axisY(0)
Tero Ahola
Cleaning up declarative implementation
r1211 {
}
sauimone
GroupedBarSeries to BarSeries
r1594 void DeclarativeBarSeries::classBegin()
Tero Ahola
Cleaning up declarative implementation
r1211 {
}
sauimone
GroupedBarSeries to BarSeries
r1594 void DeclarativeBarSeries::componentComplete()
Tero Ahola
Cleaning up declarative implementation
r1211 {
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 }
}
}
sauimone
GroupedBarSeries to BarSeries
r1594 QDeclarativeListProperty<QObject> DeclarativeBarSeries::seriesChildren()
Tero Ahola
Bar model mapper to Qml custom model demo
r1313 {
Michal Klocek
Adds axis to qml...
r1604 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
Tero Ahola
Bar model mapper to Qml custom model demo
r1313 }
sauimone
GroupedBarSeries to BarSeries
r1594 void DeclarativeBarSeries::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 }
sauimone
GroupedBarSeries to BarSeries
r1594 DeclarativeBarSet *DeclarativeBarSeries::at(int index)
Tero Ahola
Color properties to QML BarSet API
r1302 {
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;
}
sauimone
GroupedBarSeries to BarSeries
r1594 DeclarativeBarSet *DeclarativeBarSeries::insert(int index, QString label, QVariantList values)
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
GroupedBarSeries to BarSeries
r1594 if (QBarSeries::insert(index, barset))
Tero Ahola
Implemented BarSeries::append, insert, remove and clear to QML API
r1511 return barset;
delete barset;
return 0;
}
sauimone
declarative series for horizontal barcharts
r1806 // Declarative stacked bar series ==============================================================================
Tero Ahola
Added stacked and percent bar series to QML api
r1318 DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QDeclarativeItem *parent) :
Tero Ahola
Refactored QML axis handling
r1813 QStackedBarSeries(parent),
m_axisX(0),
m_axisY(0)
Tero Ahola
Added stacked and percent bar series to QML api
r1318 {
}
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
Tero Ahola
Added stacked and percent bar series to QML api
r1318 QDeclarativeListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren()
{
Michal Klocek
Adds axis to qml...
r1604 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
Tero Ahola
Added stacked and percent bar series to QML api
r1318 }
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;
}
sauimone
declarative series for horizontal barcharts
r1806 // Declarative percent bar series ==============================================================================
Tero Ahola
Added stacked and percent bar series to QML api
r1318 DeclarativePercentBarSeries::DeclarativePercentBarSeries(QDeclarativeItem *parent) :
Tero Ahola
Refactored QML axis handling
r1813 QPercentBarSeries(parent),
m_axisX(0),
m_axisY(0)
Tero Ahola
Added stacked and percent bar series to QML api
r1318 {
}
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);
}
}
}
QDeclarativeListProperty<QObject> DeclarativePercentBarSeries::seriesChildren()
{
Michal Klocek
Adds axis to qml...
r1604 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
Tero Ahola
Added stacked and percent bar series to QML api
r1318 }
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;
}
sauimone
declarative series for horizontal barcharts
r1806 // Declarative horizontal bar series ===========================================================================
DeclarativeHorizontalBarSeries::DeclarativeHorizontalBarSeries(QDeclarativeItem *parent) :
Tero Ahola
Refactored QML axis handling
r1813 QHorizontalBarSeries(parent),
m_axisX(0),
m_axisY(0)
sauimone
declarative series for horizontal barcharts
r1806 {
}
void DeclarativeHorizontalBarSeries::classBegin()
{
}
void DeclarativeHorizontalBarSeries::componentComplete()
{
foreach(QObject *child, children()) {
if (qobject_cast<DeclarativeBarSet *>(child)) {
QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
} 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);
}
}
}
QDeclarativeListProperty<QObject> DeclarativeHorizontalBarSeries::seriesChildren()
{
return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeHorizontalBarSeries::appendSeriesChildren);
}
void DeclarativeHorizontalBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
{
// Empty implementation; the children are parsed in componentComplete instead
Q_UNUSED(list);
Q_UNUSED(element);
}
DeclarativeBarSet *DeclarativeHorizontalBarSeries::at(int index)
{
QList<QBarSet*> setList = barSets();
if (index >= 0 && index < setList.count())
return qobject_cast<DeclarativeBarSet *>(setList[index]);
return 0;
}
DeclarativeBarSet *DeclarativeHorizontalBarSeries::insert(int index, QString label, QVariantList values)
{
DeclarativeBarSet *barset = new DeclarativeBarSet(this);
barset->setLabel(label);
barset->setValues(values);
if (QHorizontalBarSeries::insert(index, barset))
return barset;
delete barset;
return 0;
}
// Declarative horizontal stacked bar series ===================================================================
DeclarativeHorizontalStackedBarSeries::DeclarativeHorizontalStackedBarSeries(QDeclarativeItem *parent) :
Tero Ahola
Refactored QML axis handling
r1813 QHorizontalStackedBarSeries(parent),
m_axisX(0),
m_axisY(0)
sauimone
declarative series for horizontal barcharts
r1806 {
}
void DeclarativeHorizontalStackedBarSeries::classBegin()
{
}
void DeclarativeHorizontalStackedBarSeries::componentComplete()
{
foreach(QObject *child, children()) {
if (qobject_cast<DeclarativeBarSet *>(child)) {
QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
} 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);
}
}
}
QDeclarativeListProperty<QObject> DeclarativeHorizontalStackedBarSeries::seriesChildren()
{
return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeHorizontalStackedBarSeries::appendSeriesChildren);
}
void DeclarativeHorizontalStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
{
// Empty implementation; the children are parsed in componentComplete instead
Q_UNUSED(list);
Q_UNUSED(element);
}
DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::at(int index)
{
QList<QBarSet*> setList = barSets();
if (index >= 0 && index < setList.count())
return qobject_cast<DeclarativeBarSet *>(setList[index]);
return 0;
}
DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::insert(int index, QString label, QVariantList values)
{
DeclarativeBarSet *barset = new DeclarativeBarSet(this);
barset->setLabel(label);
barset->setValues(values);
if (QHorizontalStackedBarSeries::insert(index, barset))
return barset;
delete barset;
return 0;
}
// Declarative horizontal percent bar series ===================================================================
DeclarativeHorizontalPercentBarSeries::DeclarativeHorizontalPercentBarSeries(QDeclarativeItem *parent) :
Tero Ahola
Refactored QML axis handling
r1813 QHorizontalPercentBarSeries(parent),
m_axisX(0),
m_axisY(0)
sauimone
declarative series for horizontal barcharts
r1806 {
}
void DeclarativeHorizontalPercentBarSeries::classBegin()
{
}
void DeclarativeHorizontalPercentBarSeries::componentComplete()
{
foreach(QObject *child, children()) {
if (qobject_cast<DeclarativeBarSet *>(child)) {
QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
} 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);
}
}
}
QDeclarativeListProperty<QObject> DeclarativeHorizontalPercentBarSeries::seriesChildren()
{
return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeHorizontalPercentBarSeries::appendSeriesChildren);
}
void DeclarativeHorizontalPercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
{
// Empty implementation; the children are parsed in componentComplete instead
Q_UNUSED(list);
Q_UNUSED(element);
}
DeclarativeBarSet *DeclarativeHorizontalPercentBarSeries::at(int index)
{
QList<QBarSet*> setList = barSets();
if (index >= 0 && index < setList.count())
return qobject_cast<DeclarativeBarSet *>(setList[index]);
return 0;
}
DeclarativeBarSet *DeclarativeHorizontalPercentBarSeries::insert(int index, QString label, QVariantList values)
{
DeclarativeBarSet *barset = new DeclarativeBarSet(this);
barset->setLabel(label);
barset->setValues(values);
if (QHorizontalPercentBarSeries::insert(index, barset))
return barset;
delete barset;
return 0;
}
sauimone
fixed moc name in declarative barseries
r1592 #include "moc_declarativebarseries.cpp"
Tero Ahola
Added QML api for bar series
r646
QTCOMMERCIALCHART_END_NAMESPACE