declarativebarseries.cpp
518 lines
| 18.4 KiB
| text/x-c
|
CppLexer
|
r2854 | /**************************************************************************** | ||
|
r830 | ** | ||
|
r2854 | ** Copyright (C) 2016 The Qt Company Ltd. | ||
** Contact: https://www.qt.io/licensing/ | ||||
|
r830 | ** | ||
|
r2854 | ** This file is part of the Qt Charts module of the Qt Toolkit. | ||
|
r830 | ** | ||
|
r2854 | ** $QT_BEGIN_LICENSE:GPL$ | ||
|
r2845 | ** Commercial License Usage | ||
** Licensees holding valid commercial Qt licenses may use this file in | ||||
** accordance with the commercial license agreement provided with the | ||||
** Software or, alternatively, in accordance with the terms contained in | ||||
** a written agreement between you and The Qt Company. For licensing terms | ||||
|
r2854 | ** and conditions see https://www.qt.io/terms-conditions. For further | ||
** information use the contact form at https://www.qt.io/contact-us. | ||||
** | ||||
** GNU General Public License Usage | ||||
** Alternatively, this file may be used under the terms of the GNU | ||||
** General Public License version 3 or (at your option) any later version | ||||
** approved by the KDE Free Qt Foundation. The licenses are as published by | ||||
** the Free Software Foundation and appearing in the file LICENSE.GPL3 | ||||
** included in the packaging of this file. Please review the following | ||||
** information to ensure the GNU General Public License requirements will | ||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html. | ||||
|
r830 | ** | ||
|
r2845 | ** $QT_END_LICENSE$ | ||
** | ||||
|
r2854 | ****************************************************************************/ | ||
|
r830 | |||
|
r646 | #include "declarativebarseries.h" | ||
|
r2714 | #include <QtCharts/QBarSet> | ||
#include <QtCharts/QVBarModelMapper> | ||||
#include <QtCharts/QHBarModelMapper> | ||||
|
r646 | |||
|
r2712 | QT_CHARTS_BEGIN_NAMESPACE | ||
|
r646 | |||
|
r2101 | DeclarativeBarSet::DeclarativeBarSet(QObject *parent) | ||
: QBarSet("", parent) | ||||
|
r646 | { | ||
|
r1937 | connect(this, SIGNAL(valuesAdded(int,int)), this, SLOT(handleCountChanged(int,int))); | ||
connect(this, SIGNAL(valuesRemoved(int,int)), this, SLOT(handleCountChanged(int,int))); | ||||
|
r2681 | connect(this, SIGNAL(brushChanged()), this, SLOT(handleBrushChanged())); | ||
|
r1465 | } | ||
void DeclarativeBarSet::handleCountChanged(int index, int count) | ||||
{ | ||||
Q_UNUSED(index) | ||||
Q_UNUSED(count) | ||||
emit countChanged(QBarSet::count()); | ||||
|
r646 | } | ||
|
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); | ||||
} | ||||
} | ||||
|
r1162 | QVariantList DeclarativeBarSet::values() | ||
|
r646 | { | ||
|
r1162 | QVariantList values; | ||
for (int i(0); i < count(); i++) | ||||
|
r1513 | values.append(QVariant(QBarSet::at(i))); | ||
|
r1162 | return values; | ||
|
r1004 | } | ||
|
r646 | |||
|
r1162 | void DeclarativeBarSet::setValues(QVariantList values) | ||
|
r1004 | { | ||
|
r1162 | while (count()) | ||
remove(count() - 1); | ||||
|
r646 | |||
|
r2678 | if (values.at(0).canConvert(QVariant::Point)) { | ||
// Create list of values for appending if the first item is Qt.point | ||||
int maxValue = 0; | ||||
for (int i = 0; i < values.count(); i++) { | ||||
if (values.at(i).canConvert(QVariant::Point) && | ||||
values.at(i).toPoint().x() > maxValue) { | ||||
maxValue = values.at(i).toPoint().x(); | ||||
} | ||||
} | ||||
QVector<int> indexValueList; | ||||
indexValueList.resize(maxValue + 1); | ||||
for (int i = 0; i < values.count(); i++) { | ||||
if (values.at(i).canConvert(QVariant::Point)) { | ||||
indexValueList.replace(values.at(i).toPoint().x(), values.at(i).toPoint().y()); | ||||
} | ||||
} | ||||
for (int i = 0; i < indexValueList.count(); i++) | ||||
QBarSet::append(indexValueList.at(i)); | ||||
} else { | ||||
for (int i(0); i < values.count(); i++) { | ||||
if (values.at(i).canConvert(QVariant::Double)) | ||||
QBarSet::append(values[i].toDouble()); | ||||
} | ||||
|
r1004 | } | ||
|
r1162 | } | ||
|
r646 | |||
|
r2681 | QString DeclarativeBarSet::brushFilename() const | ||
{ | ||||
return m_brushFilename; | ||||
} | ||||
void DeclarativeBarSet::setBrushFilename(const QString &brushFilename) | ||||
{ | ||||
QImage brushImage(brushFilename); | ||||
if (QBarSet::brush().textureImage() != brushImage) { | ||||
QBrush brush = QBarSet::brush(); | ||||
brush.setTextureImage(brushImage); | ||||
QBarSet::setBrush(brush); | ||||
m_brushFilename = brushFilename; | ||||
m_brushImage = brushImage; | ||||
emit brushFilenameChanged(brushFilename); | ||||
} | ||||
} | ||||
void DeclarativeBarSet::handleBrushChanged() | ||||
{ | ||||
// If the texture image of the brush has changed along the brush | ||||
// the brush file name needs to be cleared. | ||||
if (!m_brushFilename.isEmpty() && QBarSet::brush().textureImage() != m_brushImage) { | ||||
m_brushFilename.clear(); | ||||
emit brushFilenameChanged(QString("")); | ||||
} | ||||
} | ||||
|
r1806 | // Declarative bar series ====================================================================================== | ||
|
r2712 | DeclarativeBarSeries::DeclarativeBarSeries(QQuickItem *parent) : | ||
|
r1813 | QBarSeries(parent), | ||
|
r2296 | m_axes(new DeclarativeAxes(this)) | ||
|
r1211 | { | ||
|
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*))); | ||||
|
r1211 | } | ||
|
r1594 | void DeclarativeBarSeries::classBegin() | ||
|
r1211 | { | ||
} | ||||
|
r1594 | void DeclarativeBarSeries::componentComplete() | ||
|
r1211 | { | ||
|
r2100 | foreach (QObject *child, children()) { | ||
|
r1302 | if (qobject_cast<DeclarativeBarSet *>(child)) { | ||
|
r1584 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | ||
|
r2101 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | ||
|
r1313 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | ||
mapper->setSeries(this); | ||||
|
r2101 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | ||
|
r1313 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | ||
mapper->setSeries(this); | ||||
|
r1211 | } | ||
} | ||||
} | ||||
|
r2712 | QQmlListProperty<QObject> DeclarativeBarSeries::seriesChildren() | ||
|
r1313 | { | ||
|
r2712 | return QQmlListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren ,0,0,0); | ||
|
r1313 | } | ||
|
r2712 | void DeclarativeBarSeries::appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element) | ||
|
r1211 | { | ||
|
r1313 | // Empty implementation; the children are parsed in componentComplete instead | ||
Q_UNUSED(list); | ||||
Q_UNUSED(element); | ||||
|
r1211 | } | ||
|
r1594 | DeclarativeBarSet *DeclarativeBarSeries::at(int index) | ||
|
r1302 | { | ||
|
r2101 | QList<QBarSet *> setList = barSets(); | ||
|
r1511 | if (index >= 0 && index < setList.count()) | ||
|
r1302 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | ||
return 0; | ||||
} | ||||
|
r1594 | DeclarativeBarSet *DeclarativeBarSeries::insert(int index, QString label, QVariantList values) | ||
|
r1511 | { | ||
DeclarativeBarSet *barset = new DeclarativeBarSet(this); | ||||
barset->setLabel(label); | ||||
barset->setValues(values); | ||||
|
r1594 | if (QBarSeries::insert(index, barset)) | ||
|
r1511 | return barset; | ||
delete barset; | ||||
return 0; | ||||
} | ||||
|
r1806 | // Declarative stacked bar series ============================================================================== | ||
|
r2712 | DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QQuickItem *parent) : | ||
|
r1813 | QStackedBarSeries(parent), | ||
|
r2296 | m_axes(0) | ||
|
r1318 | { | ||
|
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*))); | ||||
|
r1318 | } | ||
void DeclarativeStackedBarSeries::classBegin() | ||||
{ | ||||
} | ||||
void DeclarativeStackedBarSeries::componentComplete() | ||||
{ | ||||
|
r2100 | foreach (QObject *child, children()) { | ||
|
r1318 | if (qobject_cast<DeclarativeBarSet *>(child)) { | ||
|
r1584 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | ||
|
r2101 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | ||
|
r1318 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | ||
mapper->setSeries(this); | ||||
|
r2101 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | ||
|
r1318 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | ||
mapper->setSeries(this); | ||||
} | ||||
} | ||||
} | ||||
|
r1550 | |||
|
r2712 | QQmlListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren() | ||
|
r1318 | { | ||
|
r2712 | return QQmlListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren ,0,0,0); | ||
|
r1318 | } | ||
|
r2712 | void DeclarativeStackedBarSeries::appendSeriesChildren(QQmlListProperty<QObject> * list, QObject *element) | ||
|
r1318 | { | ||
// Empty implementation; the children are parsed in componentComplete instead | ||||
Q_UNUSED(list); | ||||
Q_UNUSED(element); | ||||
} | ||||
DeclarativeBarSet *DeclarativeStackedBarSeries::at(int index) | ||||
{ | ||||
|
r2101 | QList<QBarSet *> setList = barSets(); | ||
|
r1511 | if (index >= 0 && index < setList.count()) | ||
|
r1318 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | ||
return 0; | ||||
} | ||||
|
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; | ||||
} | ||||
|
r1806 | // Declarative percent bar series ============================================================================== | ||
|
r2712 | DeclarativePercentBarSeries::DeclarativePercentBarSeries(QQuickItem *parent) : | ||
|
r1813 | QPercentBarSeries(parent), | ||
|
r2296 | m_axes(0) | ||
|
r1318 | { | ||
|
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*))); | ||||
|
r1318 | } | ||
void DeclarativePercentBarSeries::classBegin() | ||||
{ | ||||
} | ||||
void DeclarativePercentBarSeries::componentComplete() | ||||
{ | ||||
|
r2100 | foreach (QObject *child, children()) { | ||
|
r1318 | if (qobject_cast<DeclarativeBarSet *>(child)) { | ||
|
r1584 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | ||
|
r2101 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | ||
|
r1318 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | ||
mapper->setSeries(this); | ||||
|
r2101 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | ||
|
r1318 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | ||
mapper->setSeries(this); | ||||
} | ||||
} | ||||
} | ||||
|
r2712 | QQmlListProperty<QObject> DeclarativePercentBarSeries::seriesChildren() | ||
|
r1318 | { | ||
|
r2712 | return QQmlListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren ,0,0,0); | ||
|
r1318 | } | ||
|
r2712 | void DeclarativePercentBarSeries::appendSeriesChildren(QQmlListProperty<QObject> * list, QObject *element) | ||
|
r1318 | { | ||
// Empty implementation; the children are parsed in componentComplete instead | ||||
Q_UNUSED(list); | ||||
Q_UNUSED(element); | ||||
} | ||||
DeclarativeBarSet *DeclarativePercentBarSeries::at(int index) | ||||
{ | ||||
|
r2101 | QList<QBarSet *> setList = barSets(); | ||
|
r1511 | if (index >= 0 && index < setList.count()) | ||
|
r1318 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | ||
return 0; | ||||
} | ||||
|
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; | ||||
} | ||||
|
r1806 | // Declarative horizontal bar series =========================================================================== | ||
|
r2712 | DeclarativeHorizontalBarSeries::DeclarativeHorizontalBarSeries(QQuickItem *parent) : | ||
|
r1813 | QHorizontalBarSeries(parent), | ||
|
r2296 | m_axes(0) | ||
|
r1806 | { | ||
|
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*))); | ||||
|
r1806 | } | ||
void DeclarativeHorizontalBarSeries::classBegin() | ||||
{ | ||||
} | ||||
void DeclarativeHorizontalBarSeries::componentComplete() | ||||
{ | ||||
|
r2100 | foreach (QObject *child, children()) { | ||
|
r1806 | if (qobject_cast<DeclarativeBarSet *>(child)) { | ||
QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | ||||
|
r2101 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | ||
|
r1806 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | ||
mapper->setSeries(this); | ||||
|
r2101 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | ||
|
r1806 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | ||
mapper->setSeries(this); | ||||
} | ||||
} | ||||
} | ||||
|
r2712 | QQmlListProperty<QObject> DeclarativeHorizontalBarSeries::seriesChildren() | ||
|
r1806 | { | ||
|
r2712 | return QQmlListProperty<QObject>(this, 0, &DeclarativeHorizontalBarSeries::appendSeriesChildren ,0,0,0); | ||
|
r1806 | } | ||
|
r2712 | void DeclarativeHorizontalBarSeries::appendSeriesChildren(QQmlListProperty<QObject> * list, QObject *element) | ||
|
r1806 | { | ||
// Empty implementation; the children are parsed in componentComplete instead | ||||
Q_UNUSED(list); | ||||
Q_UNUSED(element); | ||||
} | ||||
DeclarativeBarSet *DeclarativeHorizontalBarSeries::at(int index) | ||||
{ | ||||
|
r2101 | QList<QBarSet *> setList = barSets(); | ||
|
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 =================================================================== | ||||
|
r2712 | DeclarativeHorizontalStackedBarSeries::DeclarativeHorizontalStackedBarSeries(QQuickItem *parent) : | ||
|
r1813 | QHorizontalStackedBarSeries(parent), | ||
|
r2296 | m_axes(0) | ||
|
r1806 | { | ||
|
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*))); | ||||
|
r1806 | } | ||
void DeclarativeHorizontalStackedBarSeries::classBegin() | ||||
{ | ||||
} | ||||
void DeclarativeHorizontalStackedBarSeries::componentComplete() | ||||
{ | ||||
|
r2100 | foreach (QObject *child, children()) { | ||
|
r1806 | if (qobject_cast<DeclarativeBarSet *>(child)) { | ||
QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | ||||
|
r2101 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | ||
|
r1806 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | ||
mapper->setSeries(this); | ||||
|
r2101 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | ||
|
r1806 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | ||
mapper->setSeries(this); | ||||
} | ||||
} | ||||
} | ||||
|
r2712 | QQmlListProperty<QObject> DeclarativeHorizontalStackedBarSeries::seriesChildren() | ||
|
r1806 | { | ||
|
r2712 | return QQmlListProperty<QObject>(this, 0, &DeclarativeHorizontalStackedBarSeries::appendSeriesChildren ,0,0,0); | ||
|
r1806 | } | ||
|
r2712 | void DeclarativeHorizontalStackedBarSeries::appendSeriesChildren(QQmlListProperty<QObject> * list, QObject *element) | ||
|
r1806 | { | ||
// Empty implementation; the children are parsed in componentComplete instead | ||||
Q_UNUSED(list); | ||||
Q_UNUSED(element); | ||||
} | ||||
DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::at(int index) | ||||
{ | ||||
|
r2101 | QList<QBarSet *> setList = barSets(); | ||
|
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 =================================================================== | ||||
|
r2712 | DeclarativeHorizontalPercentBarSeries::DeclarativeHorizontalPercentBarSeries(QQuickItem *parent) : | ||
|
r1813 | QHorizontalPercentBarSeries(parent), | ||
|
r2296 | m_axes(0) | ||
|
r1806 | { | ||
|
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*))); | ||||
|
r1806 | } | ||
void DeclarativeHorizontalPercentBarSeries::classBegin() | ||||
{ | ||||
} | ||||
void DeclarativeHorizontalPercentBarSeries::componentComplete() | ||||
{ | ||||
|
r2100 | foreach (QObject *child, children()) { | ||
|
r1806 | if (qobject_cast<DeclarativeBarSet *>(child)) { | ||
QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | ||||
|
r2101 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | ||
|
r1806 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | ||
mapper->setSeries(this); | ||||
|
r2101 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | ||
|
r1806 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | ||
mapper->setSeries(this); | ||||
} | ||||
} | ||||
} | ||||
|
r2712 | QQmlListProperty<QObject> DeclarativeHorizontalPercentBarSeries::seriesChildren() | ||
|
r1806 | { | ||
|
r2712 | return QQmlListProperty<QObject>(this, 0, &DeclarativeHorizontalPercentBarSeries::appendSeriesChildren ,0,0,0); | ||
|
r1806 | } | ||
|
r2712 | void DeclarativeHorizontalPercentBarSeries::appendSeriesChildren(QQmlListProperty<QObject> * list, QObject *element) | ||
|
r1806 | { | ||
// Empty implementation; the children are parsed in componentComplete instead | ||||
Q_UNUSED(list); | ||||
Q_UNUSED(element); | ||||
} | ||||
DeclarativeBarSet *DeclarativeHorizontalPercentBarSeries::at(int index) | ||||
{ | ||||
|
r2101 | QList<QBarSet *> setList = barSets(); | ||
|
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; | ||||
} | ||||
|
r1592 | #include "moc_declarativebarseries.cpp" | ||
|
r646 | |||
|
r2712 | QT_CHARTS_END_NAMESPACE | ||