declarativebarseries.cpp
456 lines
| 16.5 KiB
| text/x-c
|
CppLexer
Jani Honkonen
|
r830 | /**************************************************************************** | ||
** | ||||
Miikka Heikkinen
|
r2433 | ** Copyright (C) 2013 Digia Plc | ||
Jani Honkonen
|
r830 | ** 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
|
r646 | #include "declarativebarseries.h" | ||
Tero Ahola
|
r1831 | #include "qbarset.h" | ||
#include "qvbarmodelmapper.h" | ||||
#include "qhbarmodelmapper.h" | ||||
Tero Ahola
|
r646 | |||
QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||||
Jani Honkonen
|
r2101 | DeclarativeBarSet::DeclarativeBarSet(QObject *parent) | ||
: QBarSet("", parent) | ||||
Tero Ahola
|
r646 | { | ||
Jani Honkonen
|
r1937 | connect(this, SIGNAL(valuesAdded(int,int)), this, SLOT(handleCountChanged(int,int))); | ||
connect(this, SIGNAL(valuesRemoved(int,int)), this, SLOT(handleCountChanged(int,int))); | ||||
Tero Ahola
|
r1465 | } | ||
void DeclarativeBarSet::handleCountChanged(int index, int count) | ||||
{ | ||||
Q_UNUSED(index) | ||||
Q_UNUSED(count) | ||||
emit countChanged(QBarSet::count()); | ||||
Tero Ahola
|
r646 | } | ||
Tero Ahola
|
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
|
r1162 | QVariantList DeclarativeBarSet::values() | ||
Tero Ahola
|
r646 | { | ||
Tero Ahola
|
r1162 | QVariantList values; | ||
for (int i(0); i < count(); i++) | ||||
Tero Ahola
|
r1513 | values.append(QVariant(QBarSet::at(i))); | ||
Tero Ahola
|
r1162 | return values; | ||
Tero Ahola
|
r1004 | } | ||
Tero Ahola
|
r646 | |||
Tero Ahola
|
r1162 | void DeclarativeBarSet::setValues(QVariantList values) | ||
Tero Ahola
|
r1004 | { | ||
Tero Ahola
|
r1162 | while (count()) | ||
remove(count() - 1); | ||||
Tero Ahola
|
r646 | |||
Tero Ahola
|
r1162 | for (int i(0); i < values.count(); i++) { | ||
if (values.at(i).canConvert(QVariant::Double)) | ||||
Tero Ahola
|
r1513 | QBarSet::append(values[i].toDouble()); | ||
Tero Ahola
|
r1004 | } | ||
Tero Ahola
|
r1162 | } | ||
Tero Ahola
|
r646 | |||
sauimone
|
r1806 | // Declarative bar series ====================================================================================== | ||
Miikka Heikkinen
|
r2488 | DeclarativeBarSeries::DeclarativeBarSeries(QDECLARATIVE_ITEM *parent) : | ||
Tero Ahola
|
r1813 | QBarSeries(parent), | ||
Tero Ahola
|
r2296 | m_axes(new DeclarativeAxes(this)) | ||
Tero Ahola
|
r1211 | { | ||
Tero Ahola
|
r2296 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); | ||
connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); | ||||
connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); | ||||
connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); | ||||
Tero Ahola
|
r1211 | } | ||
sauimone
|
r1594 | void DeclarativeBarSeries::classBegin() | ||
Tero Ahola
|
r1211 | { | ||
} | ||||
sauimone
|
r1594 | void DeclarativeBarSeries::componentComplete() | ||
Tero Ahola
|
r1211 | { | ||
Jani Honkonen
|
r2100 | foreach (QObject *child, children()) { | ||
Tero Ahola
|
r1302 | if (qobject_cast<DeclarativeBarSet *>(child)) { | ||
sauimone
|
r1584 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | ||
Jani Honkonen
|
r2101 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | ||
Tero Ahola
|
r1313 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | ||
mapper->setSeries(this); | ||||
Jani Honkonen
|
r2101 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | ||
Tero Ahola
|
r1313 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | ||
mapper->setSeries(this); | ||||
Tero Ahola
|
r1211 | } | ||
} | ||||
} | ||||
Miikka Heikkinen
|
r2488 | QDECLARATIVE_LIST_PROPERTY<QObject> DeclarativeBarSeries::seriesChildren() | ||
Tero Ahola
|
r1313 | { | ||
Miikka Heikkinen
|
r2488 | return QDECLARATIVE_LIST_PROPERTY<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren LIST_PROPERTY_PARAM_DEFAULTS); | ||
Tero Ahola
|
r1313 | } | ||
Miikka Heikkinen
|
r2488 | void DeclarativeBarSeries::appendSeriesChildren(QDECLARATIVE_LIST_PROPERTY<QObject> *list, QObject *element) | ||
Tero Ahola
|
r1211 | { | ||
Tero Ahola
|
r1313 | // Empty implementation; the children are parsed in componentComplete instead | ||
Q_UNUSED(list); | ||||
Q_UNUSED(element); | ||||
Tero Ahola
|
r1211 | } | ||
sauimone
|
r1594 | DeclarativeBarSet *DeclarativeBarSeries::at(int index) | ||
Tero Ahola
|
r1302 | { | ||
Jani Honkonen
|
r2101 | QList<QBarSet *> setList = barSets(); | ||
Tero Ahola
|
r1511 | if (index >= 0 && index < setList.count()) | ||
Tero Ahola
|
r1302 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | ||
return 0; | ||||
} | ||||
sauimone
|
r1594 | DeclarativeBarSet *DeclarativeBarSeries::insert(int index, QString label, QVariantList values) | ||
Tero Ahola
|
r1511 | { | ||
DeclarativeBarSet *barset = new DeclarativeBarSet(this); | ||||
barset->setLabel(label); | ||||
barset->setValues(values); | ||||
sauimone
|
r1594 | if (QBarSeries::insert(index, barset)) | ||
Tero Ahola
|
r1511 | return barset; | ||
delete barset; | ||||
return 0; | ||||
} | ||||
sauimone
|
r1806 | // Declarative stacked bar series ============================================================================== | ||
Miikka Heikkinen
|
r2488 | DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QDECLARATIVE_ITEM *parent) : | ||
Tero Ahola
|
r1813 | QStackedBarSeries(parent), | ||
Tero Ahola
|
r2296 | m_axes(0) | ||
Tero Ahola
|
r1318 | { | ||
Tero Ahola
|
r2296 | m_axes = new DeclarativeAxes(this); | ||
connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); | ||||
connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); | ||||
connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); | ||||
connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); | ||||
Tero Ahola
|
r1318 | } | ||
void DeclarativeStackedBarSeries::classBegin() | ||||
{ | ||||
} | ||||
void DeclarativeStackedBarSeries::componentComplete() | ||||
{ | ||||
Jani Honkonen
|
r2100 | foreach (QObject *child, children()) { | ||
Tero Ahola
|
r1318 | if (qobject_cast<DeclarativeBarSet *>(child)) { | ||
sauimone
|
r1584 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | ||
Jani Honkonen
|
r2101 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | ||
Tero Ahola
|
r1318 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | ||
mapper->setSeries(this); | ||||
Jani Honkonen
|
r2101 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | ||
Tero Ahola
|
r1318 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | ||
mapper->setSeries(this); | ||||
} | ||||
} | ||||
} | ||||
Tero Ahola
|
r1550 | |||
Miikka Heikkinen
|
r2488 | QDECLARATIVE_LIST_PROPERTY<QObject> DeclarativeStackedBarSeries::seriesChildren() | ||
Tero Ahola
|
r1318 | { | ||
Miikka Heikkinen
|
r2488 | return QDECLARATIVE_LIST_PROPERTY<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren LIST_PROPERTY_PARAM_DEFAULTS); | ||
Tero Ahola
|
r1318 | } | ||
Miikka Heikkinen
|
r2488 | void DeclarativeStackedBarSeries::appendSeriesChildren(QDECLARATIVE_LIST_PROPERTY<QObject> * list, QObject *element) | ||
Tero Ahola
|
r1318 | { | ||
// Empty implementation; the children are parsed in componentComplete instead | ||||
Q_UNUSED(list); | ||||
Q_UNUSED(element); | ||||
} | ||||
DeclarativeBarSet *DeclarativeStackedBarSeries::at(int index) | ||||
{ | ||||
Jani Honkonen
|
r2101 | QList<QBarSet *> setList = barSets(); | ||
Tero Ahola
|
r1511 | if (index >= 0 && index < setList.count()) | ||
Tero Ahola
|
r1318 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | ||
return 0; | ||||
} | ||||
Tero Ahola
|
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
|
r1806 | // Declarative percent bar series ============================================================================== | ||
Miikka Heikkinen
|
r2488 | DeclarativePercentBarSeries::DeclarativePercentBarSeries(QDECLARATIVE_ITEM *parent) : | ||
Tero Ahola
|
r1813 | QPercentBarSeries(parent), | ||
Tero Ahola
|
r2296 | m_axes(0) | ||
Tero Ahola
|
r1318 | { | ||
Tero Ahola
|
r2296 | m_axes = new DeclarativeAxes(this); | ||
connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); | ||||
connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); | ||||
connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); | ||||
connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); | ||||
Tero Ahola
|
r1318 | } | ||
void DeclarativePercentBarSeries::classBegin() | ||||
{ | ||||
} | ||||
void DeclarativePercentBarSeries::componentComplete() | ||||
{ | ||||
Jani Honkonen
|
r2100 | foreach (QObject *child, children()) { | ||
Tero Ahola
|
r1318 | if (qobject_cast<DeclarativeBarSet *>(child)) { | ||
sauimone
|
r1584 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | ||
Jani Honkonen
|
r2101 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | ||
Tero Ahola
|
r1318 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | ||
mapper->setSeries(this); | ||||
Jani Honkonen
|
r2101 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | ||
Tero Ahola
|
r1318 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | ||
mapper->setSeries(this); | ||||
} | ||||
} | ||||
} | ||||
Miikka Heikkinen
|
r2488 | QDECLARATIVE_LIST_PROPERTY<QObject> DeclarativePercentBarSeries::seriesChildren() | ||
Tero Ahola
|
r1318 | { | ||
Miikka Heikkinen
|
r2488 | return QDECLARATIVE_LIST_PROPERTY<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren LIST_PROPERTY_PARAM_DEFAULTS); | ||
Tero Ahola
|
r1318 | } | ||
Miikka Heikkinen
|
r2488 | void DeclarativePercentBarSeries::appendSeriesChildren(QDECLARATIVE_LIST_PROPERTY<QObject> * list, QObject *element) | ||
Tero Ahola
|
r1318 | { | ||
// Empty implementation; the children are parsed in componentComplete instead | ||||
Q_UNUSED(list); | ||||
Q_UNUSED(element); | ||||
} | ||||
DeclarativeBarSet *DeclarativePercentBarSeries::at(int index) | ||||
{ | ||||
Jani Honkonen
|
r2101 | QList<QBarSet *> setList = barSets(); | ||
Tero Ahola
|
r1511 | if (index >= 0 && index < setList.count()) | ||
Tero Ahola
|
r1318 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | ||
return 0; | ||||
} | ||||
Tero Ahola
|
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
|
r1806 | // Declarative horizontal bar series =========================================================================== | ||
Miikka Heikkinen
|
r2488 | DeclarativeHorizontalBarSeries::DeclarativeHorizontalBarSeries(QDECLARATIVE_ITEM *parent) : | ||
Tero Ahola
|
r1813 | QHorizontalBarSeries(parent), | ||
Tero Ahola
|
r2296 | m_axes(0) | ||
sauimone
|
r1806 | { | ||
Tero Ahola
|
r2296 | m_axes = new DeclarativeAxes(this); | ||
connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); | ||||
connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); | ||||
connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); | ||||
connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); | ||||
sauimone
|
r1806 | } | ||
void DeclarativeHorizontalBarSeries::classBegin() | ||||
{ | ||||
} | ||||
void DeclarativeHorizontalBarSeries::componentComplete() | ||||
{ | ||||
Jani Honkonen
|
r2100 | foreach (QObject *child, children()) { | ||
sauimone
|
r1806 | if (qobject_cast<DeclarativeBarSet *>(child)) { | ||
QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | ||||
Jani Honkonen
|
r2101 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | ||
sauimone
|
r1806 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | ||
mapper->setSeries(this); | ||||
Jani Honkonen
|
r2101 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | ||
sauimone
|
r1806 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | ||
mapper->setSeries(this); | ||||
} | ||||
} | ||||
} | ||||
Miikka Heikkinen
|
r2488 | QDECLARATIVE_LIST_PROPERTY<QObject> DeclarativeHorizontalBarSeries::seriesChildren() | ||
sauimone
|
r1806 | { | ||
Miikka Heikkinen
|
r2488 | return QDECLARATIVE_LIST_PROPERTY<QObject>(this, 0, &DeclarativeHorizontalBarSeries::appendSeriesChildren LIST_PROPERTY_PARAM_DEFAULTS); | ||
sauimone
|
r1806 | } | ||
Miikka Heikkinen
|
r2488 | void DeclarativeHorizontalBarSeries::appendSeriesChildren(QDECLARATIVE_LIST_PROPERTY<QObject> * list, QObject *element) | ||
sauimone
|
r1806 | { | ||
// Empty implementation; the children are parsed in componentComplete instead | ||||
Q_UNUSED(list); | ||||
Q_UNUSED(element); | ||||
} | ||||
DeclarativeBarSet *DeclarativeHorizontalBarSeries::at(int index) | ||||
{ | ||||
Jani Honkonen
|
r2101 | QList<QBarSet *> setList = barSets(); | ||
sauimone
|
r1806 | 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 =================================================================== | ||||
Miikka Heikkinen
|
r2488 | DeclarativeHorizontalStackedBarSeries::DeclarativeHorizontalStackedBarSeries(QDECLARATIVE_ITEM *parent) : | ||
Tero Ahola
|
r1813 | QHorizontalStackedBarSeries(parent), | ||
Tero Ahola
|
r2296 | m_axes(0) | ||
sauimone
|
r1806 | { | ||
Tero Ahola
|
r2296 | m_axes = new DeclarativeAxes(this); | ||
connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); | ||||
connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); | ||||
connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); | ||||
connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); | ||||
sauimone
|
r1806 | } | ||
void DeclarativeHorizontalStackedBarSeries::classBegin() | ||||
{ | ||||
} | ||||
void DeclarativeHorizontalStackedBarSeries::componentComplete() | ||||
{ | ||||
Jani Honkonen
|
r2100 | foreach (QObject *child, children()) { | ||
sauimone
|
r1806 | if (qobject_cast<DeclarativeBarSet *>(child)) { | ||
QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | ||||
Jani Honkonen
|
r2101 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | ||
sauimone
|
r1806 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | ||
mapper->setSeries(this); | ||||
Jani Honkonen
|
r2101 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | ||
sauimone
|
r1806 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | ||
mapper->setSeries(this); | ||||
} | ||||
} | ||||
} | ||||
Miikka Heikkinen
|
r2488 | QDECLARATIVE_LIST_PROPERTY<QObject> DeclarativeHorizontalStackedBarSeries::seriesChildren() | ||
sauimone
|
r1806 | { | ||
Miikka Heikkinen
|
r2488 | return QDECLARATIVE_LIST_PROPERTY<QObject>(this, 0, &DeclarativeHorizontalStackedBarSeries::appendSeriesChildren LIST_PROPERTY_PARAM_DEFAULTS); | ||
sauimone
|
r1806 | } | ||
Miikka Heikkinen
|
r2488 | void DeclarativeHorizontalStackedBarSeries::appendSeriesChildren(QDECLARATIVE_LIST_PROPERTY<QObject> * list, QObject *element) | ||
sauimone
|
r1806 | { | ||
// Empty implementation; the children are parsed in componentComplete instead | ||||
Q_UNUSED(list); | ||||
Q_UNUSED(element); | ||||
} | ||||
DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::at(int index) | ||||
{ | ||||
Jani Honkonen
|
r2101 | QList<QBarSet *> setList = barSets(); | ||
sauimone
|
r1806 | 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 =================================================================== | ||||
Miikka Heikkinen
|
r2488 | DeclarativeHorizontalPercentBarSeries::DeclarativeHorizontalPercentBarSeries(QDECLARATIVE_ITEM *parent) : | ||
Tero Ahola
|
r1813 | QHorizontalPercentBarSeries(parent), | ||
Tero Ahola
|
r2296 | m_axes(0) | ||
sauimone
|
r1806 | { | ||
Tero Ahola
|
r2296 | m_axes = new DeclarativeAxes(this); | ||
connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); | ||||
connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); | ||||
connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); | ||||
connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); | ||||
sauimone
|
r1806 | } | ||
void DeclarativeHorizontalPercentBarSeries::classBegin() | ||||
{ | ||||
} | ||||
void DeclarativeHorizontalPercentBarSeries::componentComplete() | ||||
{ | ||||
Jani Honkonen
|
r2100 | foreach (QObject *child, children()) { | ||
sauimone
|
r1806 | if (qobject_cast<DeclarativeBarSet *>(child)) { | ||
QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | ||||
Jani Honkonen
|
r2101 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | ||
sauimone
|
r1806 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | ||
mapper->setSeries(this); | ||||
Jani Honkonen
|
r2101 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | ||
sauimone
|
r1806 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | ||
mapper->setSeries(this); | ||||
} | ||||
} | ||||
} | ||||
Miikka Heikkinen
|
r2488 | QDECLARATIVE_LIST_PROPERTY<QObject> DeclarativeHorizontalPercentBarSeries::seriesChildren() | ||
sauimone
|
r1806 | { | ||
Miikka Heikkinen
|
r2488 | return QDECLARATIVE_LIST_PROPERTY<QObject>(this, 0, &DeclarativeHorizontalPercentBarSeries::appendSeriesChildren LIST_PROPERTY_PARAM_DEFAULTS); | ||
sauimone
|
r1806 | } | ||
Miikka Heikkinen
|
r2488 | void DeclarativeHorizontalPercentBarSeries::appendSeriesChildren(QDECLARATIVE_LIST_PROPERTY<QObject> * list, QObject *element) | ||
sauimone
|
r1806 | { | ||
// Empty implementation; the children are parsed in componentComplete instead | ||||
Q_UNUSED(list); | ||||
Q_UNUSED(element); | ||||
} | ||||
DeclarativeBarSet *DeclarativeHorizontalPercentBarSeries::at(int index) | ||||
{ | ||||
Jani Honkonen
|
r2101 | QList<QBarSet *> setList = barSets(); | ||
sauimone
|
r1806 | 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
|
r1592 | #include "moc_declarativebarseries.cpp" | ||
Tero Ahola
|
r646 | |||
QTCOMMERCIALCHART_END_NAMESPACE | ||||