diff options
Diffstat (limited to 'src/chartsqml2')
32 files changed, 7372 insertions, 0 deletions
diff --git a/src/chartsqml2/chartsqml2.pro b/src/chartsqml2/chartsqml2.pro new file mode 100644 index 00000000..8fc6e92d --- /dev/null +++ b/src/chartsqml2/chartsqml2.pro @@ -0,0 +1,69 @@ + +TARGET = qtchartsqml2 +QT += qml quick +QT += charts +TARGETPATH = QtCharts + +IMPORT_VERSION = $$MODULE_VERSION + +# Only build qml plugin static if Qt itself is also built static +!contains(QT_CONFIG, static): CONFIG -= static staticlib + +INCLUDEPATH += ../../include \ + ../../include/QtCharts \ + ../charts \ + ../charts/animations \ + ../charts/axis \ + ../charts/domain + +SOURCES += \ + chartsqml2_plugin.cpp \ + declarativechart.cpp \ + declarativexypoint.cpp \ + declarativexyseries.cpp \ + declarativelineseries.cpp \ + declarativesplineseries.cpp \ + declarativeareaseries.cpp \ + declarativescatterseries.cpp \ + declarativepieseries.cpp \ + declarativebarseries.cpp \ + declarativecategoryaxis.cpp \ + declarativemargins.cpp \ + declarativeaxes.cpp \ + declarativepolarchart.cpp \ + declarativeboxplotseries.cpp + +HEADERS += \ + declarativechart.h \ + declarativexypoint.h \ + declarativexyseries.h \ + declarativelineseries.h \ + declarativesplineseries.h \ + declarativeareaseries.h \ + declarativescatterseries.h \ + declarativepieseries.h \ + declarativebarseries.h \ + declarativecategoryaxis.h \ + declarativemargins.h \ + declarativeaxes.h \ + declarativepolarchart.h \ + declarativeboxplotseries.h + +OTHER_FILES = qmldir + +CONFIG += no_cxx_module + +load(qml_plugin) + +# Copy qmldir to DESTDIR so we can use the plugin directly from there in our examples +# without having to do 'make install'. +!android:!ios { + copy_qmldir.target = $$DESTDIR/qmldir + copy_qmldir.depends = $$_PRO_FILE_PWD_/qmldir + copy_qmldir.commands = $(COPY_FILE) \"$$replace(copy_qmldir.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_qmldir.target, /, $$QMAKE_DIR_SEP)\" + QMAKE_EXTRA_TARGETS += copy_qmldir + PRE_TARGETDEPS += $$copy_qmldir.target +} + +QML_FILES += \ + $$PWD/plugins.qmltypes diff --git a/src/chartsqml2/chartsqml2_plugin.cpp b/src/chartsqml2/chartsqml2_plugin.cpp new file mode 100644 index 00000000..477f088c --- /dev/null +++ b/src/chartsqml2/chartsqml2_plugin.cpp @@ -0,0 +1,312 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise 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$ +** +****************************************************************************/ + +#include "qchart.h" +#include "qabstractaxis.h" +#include "qvalueaxis.h" +#include "qlogvalueaxis.h" +#include "declarativecategoryaxis.h" +#include "qbarcategoryaxis.h" +#include "declarativechart.h" +#include "declarativepolarchart.h" +#include "declarativexypoint.h" +#include "declarativelineseries.h" +#include "declarativesplineseries.h" +#include "declarativeareaseries.h" +#include "declarativescatterseries.h" +#include "declarativebarseries.h" +#include "declarativeboxplotseries.h" +#include "declarativepieseries.h" +#include "declarativeaxes.h" +#include "qvxymodelmapper.h" +#include "qhxymodelmapper.h" +#include "qhpiemodelmapper.h" +#include "qvpiemodelmapper.h" +#include "qhbarmodelmapper.h" +#include "qvbarmodelmapper.h" +#include "declarativemargins.h" +#include "qarealegendmarker.h" +#include "qbarlegendmarker.h" +#include "qpielegendmarker.h" +#include "qxylegendmarker.h" +#include "qboxplotmodelmapper.h" +#include "qvboxplotmodelmapper.h" +#ifndef QT_ON_ARM + #include "qdatetimeaxis.h" +#endif +#include <QAbstractItemModel> +#include <QtQml> + +QT_CHARTS_USE_NAMESPACE + +QML_DECLARE_TYPE(QList<QPieSlice *>) +QML_DECLARE_TYPE(QList<QBarSet *>) +QML_DECLARE_TYPE(QList<QAbstractAxis *>) + +QML_DECLARE_TYPE(DeclarativeChart) +QML_DECLARE_TYPE(DeclarativePolarChart) +QML_DECLARE_TYPE(DeclarativeMargins) +QML_DECLARE_TYPE(DeclarativeAreaSeries) +QML_DECLARE_TYPE(DeclarativeBarSeries) +QML_DECLARE_TYPE(DeclarativeBarSet) +QML_DECLARE_TYPE(DeclarativeBoxPlotSeries) +QML_DECLARE_TYPE(DeclarativeBoxSet) +QML_DECLARE_TYPE(DeclarativeLineSeries) +QML_DECLARE_TYPE(DeclarativePieSeries) +QML_DECLARE_TYPE(DeclarativePieSlice) +QML_DECLARE_TYPE(DeclarativeScatterSeries) +QML_DECLARE_TYPE(DeclarativeSplineSeries) + +QML_DECLARE_TYPE(QAbstractAxis) +QML_DECLARE_TYPE(QValueAxis) +QML_DECLARE_TYPE(QBarCategoryAxis) +QML_DECLARE_TYPE(QCategoryAxis) +QML_DECLARE_TYPE(QDateTimeAxis) +QML_DECLARE_TYPE(QLogValueAxis) + +QML_DECLARE_TYPE(QLegend) +QML_DECLARE_TYPE(QLegendMarker) +QML_DECLARE_TYPE(QAreaLegendMarker) +QML_DECLARE_TYPE(QBarLegendMarker) +QML_DECLARE_TYPE(QPieLegendMarker) + +QML_DECLARE_TYPE(QHPieModelMapper) +QML_DECLARE_TYPE(QHXYModelMapper) +QML_DECLARE_TYPE(QPieModelMapper) +QML_DECLARE_TYPE(QHBarModelMapper) +QML_DECLARE_TYPE(QBarModelMapper) +QML_DECLARE_TYPE(QVBarModelMapper) +QML_DECLARE_TYPE(QVPieModelMapper) +QML_DECLARE_TYPE(QVXYModelMapper) +QML_DECLARE_TYPE(QXYLegendMarker) +QML_DECLARE_TYPE(QXYModelMapper) +QML_DECLARE_TYPE(QBoxPlotModelMapper) +QML_DECLARE_TYPE(QVBoxPlotModelMapper) + +QML_DECLARE_TYPE(QAbstractSeries) +QML_DECLARE_TYPE(QXYSeries) +QML_DECLARE_TYPE(QAbstractBarSeries) +QML_DECLARE_TYPE(QBarSeries) +QML_DECLARE_TYPE(QBarSet) +QML_DECLARE_TYPE(QAreaSeries) +QML_DECLARE_TYPE(QHorizontalBarSeries) +QML_DECLARE_TYPE(QHorizontalPercentBarSeries) +QML_DECLARE_TYPE(QHorizontalStackedBarSeries) +QML_DECLARE_TYPE(QLineSeries) +QML_DECLARE_TYPE(QPercentBarSeries) +QML_DECLARE_TYPE(QPieSeries) +QML_DECLARE_TYPE(QPieSlice) +QML_DECLARE_TYPE(QScatterSeries) +QML_DECLARE_TYPE(QSplineSeries) +QML_DECLARE_TYPE(QStackedBarSeries) + +QT_CHARTS_BEGIN_NAMESPACE + +class QtChartsQml2Plugin : public QQmlExtensionPlugin +{ + Q_OBJECT + + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + +public: + virtual void registerTypes(const char *uri) + { + Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCharts")); + + // @uri QtCharts + + qRegisterMetaType<QList<QPieSlice *> >(); + qRegisterMetaType<QList<QBarSet *> >(); + qRegisterMetaType<QList<QAbstractAxis *> >(); + + // QtCharts 1.0 + qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView"); + qmlRegisterType<DeclarativeXYPoint>(uri, 1, 0, "XYPoint"); + qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); + qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries"); + qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries"); + qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries"); + qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); + qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries"); + qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries"); + qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); + qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice"); + qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); + qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper"); + qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper"); + qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper"); + qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper"); + qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper"); + qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper"); + + qmlRegisterType<QValueAxis>(uri, 1, 0, "ValuesAxis"); + qmlRegisterType<QBarCategoryAxis>(uri, 1, 0, "BarCategoriesAxis"); + qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend", + QLatin1String("Trying to create uncreatable: Legend.")); + qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries", + QLatin1String("Trying to create uncreatable: XYSeries.")); + qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", + QLatin1String("Trying to create uncreatable: AbstractItemModel.")); + qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", + QLatin1String("Trying to create uncreatable: XYModelMapper.")); + qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", + QLatin1String("Trying to create uncreatable: PieModelMapper.")); + qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper", + QLatin1String("Trying to create uncreatable: BarModelMapper.")); + qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries", + QLatin1String("Trying to create uncreatable: AbstractSeries.")); + qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 0, "AbstractBarSeries", + QLatin1String("Trying to create uncreatable: AbstractBarSeries.")); + qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis", + QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead.")); + qmlRegisterUncreatableType<QBarSet>(uri, 1, 0, "BarSetBase", + QLatin1String("Trying to create uncreatable: BarsetBase.")); + qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries", + QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead.")); + qmlRegisterUncreatableType<DeclarativeAxes>(uri, 1, 0, "DeclarativeAxes", + QLatin1String("Trying to create uncreatable: DeclarativeAxes.")); + + // QtCharts 1.1 + qmlRegisterType<DeclarativeChart, 1>(uri, 1, 1, "ChartView"); + qmlRegisterType<DeclarativeScatterSeries, 1>(uri, 1, 1, "ScatterSeries"); + qmlRegisterType<DeclarativeLineSeries, 1>(uri, 1, 1, "LineSeries"); + qmlRegisterType<DeclarativeSplineSeries, 1>(uri, 1, 1, "SplineSeries"); + qmlRegisterType<DeclarativeAreaSeries, 1>(uri, 1, 1, "AreaSeries"); + qmlRegisterType<DeclarativeBarSeries, 1>(uri, 1, 1, "BarSeries"); + qmlRegisterType<DeclarativeStackedBarSeries, 1>(uri, 1, 1, "StackedBarSeries"); + qmlRegisterType<DeclarativePercentBarSeries, 1>(uri, 1, 1, "PercentBarSeries"); + qmlRegisterType<DeclarativeHorizontalBarSeries, 1>(uri, 1, 1, "HorizontalBarSeries"); + qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 1>(uri, 1, 1, "HorizontalStackedBarSeries"); + qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 1>(uri, 1, 1, "HorizontalPercentBarSeries"); + qmlRegisterType<DeclarativePieSeries>(uri, 1, 1, "PieSeries"); + qmlRegisterType<DeclarativeBarSet>(uri, 1, 1, "BarSet"); + qmlRegisterType<QValueAxis>(uri, 1, 1, "ValueAxis"); +#ifndef QT_ON_ARM + qmlRegisterType<QDateTimeAxis>(uri, 1, 1, "DateTimeAxis"); +#endif + qmlRegisterType<DeclarativeCategoryAxis>(uri, 1, 1, "CategoryAxis"); + qmlRegisterType<DeclarativeCategoryRange>(uri, 1, 1, "CategoryRange"); + qmlRegisterType<QBarCategoryAxis>(uri, 1, 1, "BarCategoryAxis"); + qmlRegisterUncreatableType<DeclarativeMargins>(uri, 1, 1, "Margins", + QLatin1String("Trying to create uncreatable: Margins.")); + + // QtCharts 1.2 + qmlRegisterType<DeclarativeChart, 2>(uri, 1, 2, "ChartView"); + qmlRegisterType<DeclarativeScatterSeries, 2>(uri, 1, 2, "ScatterSeries"); + qmlRegisterType<DeclarativeLineSeries, 2>(uri, 1, 2, "LineSeries"); + qmlRegisterType<DeclarativeSplineSeries, 2>(uri, 1, 2, "SplineSeries"); + qmlRegisterType<DeclarativeAreaSeries, 2>(uri, 1, 2, "AreaSeries"); + qmlRegisterType<DeclarativeBarSeries, 2>(uri, 1, 2, "BarSeries"); + qmlRegisterType<DeclarativeStackedBarSeries, 2>(uri, 1, 2, "StackedBarSeries"); + qmlRegisterType<DeclarativePercentBarSeries, 2>(uri, 1, 2, "PercentBarSeries"); + qmlRegisterType<DeclarativeHorizontalBarSeries, 2>(uri, 1, 2, "HorizontalBarSeries"); + qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 2>(uri, 1, 2, "HorizontalStackedBarSeries"); + qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 2>(uri, 1, 2, "HorizontalPercentBarSeries"); + + // QtCharts 1.3 + qmlRegisterType<DeclarativeChart, 3>(uri, 1, 3, "ChartView"); + qmlRegisterType<DeclarativePolarChart, 1>(uri, 1, 3, "PolarChartView"); + qmlRegisterType<DeclarativeSplineSeries, 3>(uri, 1, 3, "SplineSeries"); + qmlRegisterType<DeclarativeScatterSeries, 3>(uri, 1, 3, "ScatterSeries"); + qmlRegisterType<DeclarativeLineSeries, 3>(uri, 1, 3, "LineSeries"); + qmlRegisterType<DeclarativeAreaSeries, 3>(uri, 1, 3, "AreaSeries"); + qmlRegisterType<QLogValueAxis>(uri, 1, 3, "LogValueAxis"); + qmlRegisterType<DeclarativeBoxPlotSeries>(uri, 1, 3, "BoxPlotSeries"); + qmlRegisterType<DeclarativeBoxSet>(uri, 1, 3, "BoxSet"); + + // QtCharts 1.4 + qmlRegisterType<DeclarativeAreaSeries, 4>(uri, 1, 4, "AreaSeries"); + qmlRegisterType<DeclarativeBarSet, 2>(uri, 1, 4, "BarSet"); + qmlRegisterType<DeclarativeBoxPlotSeries, 1>(uri, 1, 4, "BoxPlotSeries"); + qmlRegisterType<DeclarativeBoxSet, 1>(uri, 1, 4, "BoxSet"); + qmlRegisterType<DeclarativePieSlice>(uri, 1, 4, "PieSlice"); + qmlRegisterType<DeclarativeScatterSeries, 4>(uri, 1, 4, "ScatterSeries"); + + // QtCharts 2.0 + qmlRegisterType<QVBoxPlotModelMapper>(uri, 2, 0, "VBoxPlotModelMapper"); + qmlRegisterUncreatableType<QBoxPlotModelMapper>(uri, 2, 0, "BoxPlotModelMapper", + QLatin1String("Trying to create uncreatable: BoxPlotModelMapper.")); + qmlRegisterType<DeclarativeChart, 4>(uri, 2, 0, "ChartView"); + qmlRegisterType<DeclarativeXYPoint>(uri, 2, 0, "XYPoint"); + qmlRegisterType<DeclarativeScatterSeries, 4>(uri, 2, 0, "ScatterSeries"); + qmlRegisterType<DeclarativeLineSeries, 3>(uri, 2, 0, "LineSeries"); + qmlRegisterType<DeclarativeSplineSeries, 3>(uri, 2, 0, "SplineSeries"); + qmlRegisterType<DeclarativeAreaSeries, 4>(uri, 2, 0, "AreaSeries"); + qmlRegisterType<DeclarativeBarSeries, 2>(uri, 2, 0, "BarSeries"); + qmlRegisterType<DeclarativeStackedBarSeries, 2>(uri, 2, 0, "StackedBarSeries"); + qmlRegisterType<DeclarativePercentBarSeries, 2>(uri, 2, 0, "PercentBarSeries"); + qmlRegisterType<DeclarativePieSeries>(uri, 2, 0, "PieSeries"); + qmlRegisterType<QPieSlice>(uri, 2, 0, "PieSlice"); + qmlRegisterType<DeclarativeBarSet, 2>(uri, 2, 0, "BarSet"); + qmlRegisterType<QHXYModelMapper>(uri, 2, 0, "HXYModelMapper"); + qmlRegisterType<QVXYModelMapper>(uri, 2, 0, "VXYModelMapper"); + qmlRegisterType<QHPieModelMapper>(uri, 2, 0, "HPieModelMapper"); + qmlRegisterType<QVPieModelMapper>(uri, 2, 0, "VPieModelMapper"); + qmlRegisterType<QHBarModelMapper>(uri, 2, 0, "HBarModelMapper"); + qmlRegisterType<QVBarModelMapper>(uri, 2, 0, "VBarModelMapper"); + qmlRegisterType<QValueAxis>(uri, 2, 0, "ValueAxis"); +#ifndef QT_ON_ARM + qmlRegisterType<QDateTimeAxis>(uri, 2, 0, "DateTimeAxis"); +#endif + qmlRegisterType<DeclarativeCategoryAxis>(uri, 2, 0, "CategoryAxis"); + qmlRegisterType<DeclarativeCategoryRange>(uri, 2, 0, "CategoryRange"); + qmlRegisterType<QBarCategoryAxis>(uri, 2, 0, "BarCategoryAxis"); + qmlRegisterType<DeclarativePolarChart, 1>(uri, 2, 0, "PolarChartView"); + qmlRegisterType<QLogValueAxis, 1>(uri, 2, 0, "LogValueAxis"); + qmlRegisterType<DeclarativeBoxPlotSeries, 1>(uri, 2, 0, "BoxPlotSeries"); + qmlRegisterType<DeclarativeBoxSet, 1>(uri, 2, 0, "BoxSet"); + qmlRegisterType<DeclarativeHorizontalBarSeries, 2>(uri, 2, 0, "HorizontalBarSeries"); + qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 2>(uri, 2, 0, "HorizontalStackedBarSeries"); + qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 2>(uri, 2, 0, "HorizontalPercentBarSeries"); + qmlRegisterType<DeclarativePieSlice>(uri, 2, 0, "PieSlice"); + qmlRegisterUncreatableType<QLegend>(uri, 2, 0, "Legend", + QLatin1String("Trying to create uncreatable: Legend.")); + qmlRegisterUncreatableType<QXYSeries>(uri, 2, 0, "XYSeries", + QLatin1String("Trying to create uncreatable: XYSeries.")); + qmlRegisterUncreatableType<QAbstractItemModel>(uri, 2, 0, "AbstractItemModel", + QLatin1String("Trying to create uncreatable: AbstractItemModel.")); + qmlRegisterUncreatableType<QXYModelMapper>(uri, 2, 0, "XYModelMapper", + QLatin1String("Trying to create uncreatable: XYModelMapper.")); + qmlRegisterUncreatableType<QPieModelMapper>(uri, 2, 0, "PieModelMapper", + QLatin1String("Trying to create uncreatable: PieModelMapper.")); + qmlRegisterUncreatableType<QBarModelMapper>(uri, 2, 0, "BarModelMapper", + QLatin1String("Trying to create uncreatable: BarModelMapper.")); + qmlRegisterUncreatableType<QAbstractSeries>(uri, 2, 0, "AbstractSeries", + QLatin1String("Trying to create uncreatable: AbstractSeries.")); + qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 2, 0, "AbstractBarSeries", + QLatin1String("Trying to create uncreatable: AbstractBarSeries.")); + qmlRegisterUncreatableType<QAbstractAxis>(uri, 2, 0, "AbstractAxis", + QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead.")); + qmlRegisterUncreatableType<QBarSet>(uri, 2, 0, "BarSetBase", + QLatin1String("Trying to create uncreatable: BarsetBase.")); + qmlRegisterUncreatableType<QPieSeries>(uri, 2, 0, "QPieSeries", + QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead.")); + qmlRegisterUncreatableType<DeclarativeAxes>(uri, 2, 0, "DeclarativeAxes", + QLatin1String("Trying to create uncreatable: DeclarativeAxes.")); + qmlRegisterUncreatableType<DeclarativeMargins>(uri, 2, 0, "Margins", + QLatin1String("Trying to create uncreatable: Margins.")); + } +}; + +QT_CHARTS_END_NAMESPACE + +#include "chartsqml2_plugin.moc" + +QT_CHARTS_USE_NAMESPACE diff --git a/src/chartsqml2/declarativeareaseries.cpp b/src/chartsqml2/declarativeareaseries.cpp new file mode 100644 index 00000000..90d2ed4b --- /dev/null +++ b/src/chartsqml2/declarativeareaseries.cpp @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise 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$ +** +****************************************************************************/ + +#include "declarativeareaseries.h" +#include "declarativelineseries.h" + +QT_CHARTS_BEGIN_NAMESPACE + +DeclarativeAreaSeries::DeclarativeAreaSeries(QObject *parent) : + QAreaSeries(parent), + 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*))); + connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisAngularChanged(QAbstractAxis*))); + connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisRadialChanged(QAbstractAxis*))); + connect(this, SIGNAL(brushChanged()), this, SLOT(handleBrushChanged())); +} + +void DeclarativeAreaSeries::setUpperSeries(DeclarativeLineSeries *series) +{ + QAreaSeries::setUpperSeries(series); +} + +DeclarativeLineSeries *DeclarativeAreaSeries::upperSeries() const +{ + return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::upperSeries()); +} + +void DeclarativeAreaSeries::setLowerSeries(DeclarativeLineSeries *series) +{ + QAreaSeries::setLowerSeries(series); +} + +DeclarativeLineSeries *DeclarativeAreaSeries::lowerSeries() const +{ + return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::lowerSeries()); +} + +qreal DeclarativeAreaSeries::borderWidth() const +{ + return pen().widthF(); +} + +void DeclarativeAreaSeries::setBorderWidth(qreal width) +{ + if (width != pen().widthF()) { + QPen p = pen(); + p.setWidthF(width); + setPen(p); + emit borderWidthChanged(width); + } +} + +QString DeclarativeAreaSeries::brushFilename() const +{ + return m_brushFilename; +} + +void DeclarativeAreaSeries::setBrushFilename(const QString &brushFilename) +{ + QImage brushImage(brushFilename); + if (QAreaSeries::brush().textureImage() != brushImage) { + QBrush brush = QAreaSeries::brush(); + brush.setTextureImage(brushImage); + QAreaSeries::setBrush(brush); + m_brushFilename = brushFilename; + m_brushImage = brushImage; + emit brushFilenameChanged(brushFilename); + } +} + +void DeclarativeAreaSeries::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() && QAreaSeries::brush().textureImage() != m_brushImage) { + m_brushFilename.clear(); + emit brushFilenameChanged(QString("")); + } +} + +void DeclarativeAreaSeries::setBrush(const QBrush &brush) +{ + QAreaSeries::setBrush(brush); + emit brushChanged(); +} + +QBrush DeclarativeAreaSeries::brush() const +{ + return QAreaSeries::brush(); +} + +#include "moc_declarativeareaseries.cpp" + +QT_CHARTS_END_NAMESPACE diff --git a/src/chartsqml2/declarativeareaseries.h b/src/chartsqml2/declarativeareaseries.h new file mode 100644 index 00000000..7072ff07 --- /dev/null +++ b/src/chartsqml2/declarativeareaseries.h @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise 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$ +** +****************************************************************************/ + +#ifndef DECLARATIVEAREASERIES_H +#define DECLARATIVEAREASERIES_H + +#include "qareaseries.h" +#include "declarativeaxes.h" + +QT_CHARTS_BEGIN_NAMESPACE +class DeclarativeLineSeries; + +class DeclarativeAreaSeries : public QAreaSeries +{ + Q_OBJECT + Q_PROPERTY(DeclarativeLineSeries *upperSeries READ upperSeries WRITE setUpperSeries) + Q_PROPERTY(DeclarativeLineSeries *lowerSeries READ lowerSeries WRITE setLowerSeries) + Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) + Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) + Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2) + Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2) + Q_PROPERTY(QAbstractAxis *axisAngular READ axisAngular WRITE setAxisAngular NOTIFY axisAngularChanged REVISION 3) + Q_PROPERTY(QAbstractAxis *axisRadial READ axisRadial WRITE setAxisRadial NOTIFY axisRadialChanged REVISION 3) + Q_PROPERTY(qreal borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged REVISION 1) + Q_PROPERTY(QString brushFilename READ brushFilename WRITE setBrushFilename NOTIFY brushFilenameChanged REVISION 4) + Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged REVISION 4) + +public: + explicit DeclarativeAreaSeries(QObject *parent = 0); + void setUpperSeries(DeclarativeLineSeries *series); + DeclarativeLineSeries *upperSeries() const; + void setLowerSeries(DeclarativeLineSeries *series); + DeclarativeLineSeries *lowerSeries() const; + QAbstractAxis *axisX() { return m_axes->axisX(); } + void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } + QAbstractAxis *axisY() { return m_axes->axisY(); } + void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); } + Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); } + Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); } + Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); } + Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); } + Q_REVISION(3) QAbstractAxis *axisAngular() { return m_axes->axisX(); } + Q_REVISION(3) void setAxisAngular(QAbstractAxis *axis) { m_axes->setAxisX(axis); } + Q_REVISION(3) QAbstractAxis *axisRadial() { return m_axes->axisY(); } + Q_REVISION(3) void setAxisRadial(QAbstractAxis *axis) { m_axes->setAxisY(axis); } + qreal borderWidth() const; + void setBorderWidth(qreal borderWidth); + QString brushFilename() const; + void setBrushFilename(const QString &brushFilename); + void setBrush(const QBrush &brush); + QBrush brush() const; + +Q_SIGNALS: + Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); + Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); + Q_REVISION(1) void borderWidthChanged(qreal width); + Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis); + Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis); + Q_REVISION(3) void axisAngularChanged(QAbstractAxis *axis); + Q_REVISION(3) void axisRadialChanged(QAbstractAxis *axis); + Q_REVISION(4) void brushChanged(); + Q_REVISION(4) void brushFilenameChanged(const QString &brushFilename); + +private Q_SLOTS: + void handleBrushChanged(); + +public: + DeclarativeAxes *m_axes; + +private: + QString m_brushFilename; + QImage m_brushImage; +}; + +QT_CHARTS_END_NAMESPACE + +#endif // DECLARATIVEAREASERIES_H diff --git a/src/chartsqml2/declarativeaxes.cpp b/src/chartsqml2/declarativeaxes.cpp new file mode 100644 index 00000000..9c6d9ad8 --- /dev/null +++ b/src/chartsqml2/declarativeaxes.cpp @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise 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$ +** +****************************************************************************/ + +#include "declarativeaxes.h" +#include "qabstractaxis.h" + +QT_CHARTS_BEGIN_NAMESPACE + +DeclarativeAxes::DeclarativeAxes(QObject *parent) : + QObject(parent), + m_axisX(0), + m_axisY(0), + m_axisXTop(0), + m_axisYRight(0) +{ +} + +void DeclarativeAxes::setAxisX(QAbstractAxis *axis) +{ + m_axisX = axis; + emit axisXChanged(axis); +} + +void DeclarativeAxes::setAxisY(QAbstractAxis *axis) +{ + m_axisY = axis; + emit axisYChanged(axis); +} + +void DeclarativeAxes::setAxisXTop(QAbstractAxis *axis) +{ + m_axisXTop = axis; + emit axisXTopChanged(axis); +} + +void DeclarativeAxes::setAxisYRight(QAbstractAxis *axis) +{ + m_axisYRight = axis; + emit axisYRightChanged(axis); +} + +#include "moc_declarativeaxes.cpp" + +QT_CHARTS_END_NAMESPACE diff --git a/src/chartsqml2/declarativeaxes.h b/src/chartsqml2/declarativeaxes.h new file mode 100644 index 00000000..6e7d2346 --- /dev/null +++ b/src/chartsqml2/declarativeaxes.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise 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$ +** +****************************************************************************/ + +#ifndef DECLARATIVEAXES_H +#define DECLARATIVEAXES_H + +#include "qchartglobal.h" +#include <QObject> + +QT_CHARTS_BEGIN_NAMESPACE + +class QAbstractAxis; + +class DeclarativeAxes : public QObject +{ + Q_OBJECT + Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged) + Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged) + Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged) + Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged) + +public: + explicit DeclarativeAxes(QObject *parent = 0); + + QAbstractAxis *axisX() { return m_axisX; } + void setAxisX(QAbstractAxis *axis); + QAbstractAxis *axisY() { return m_axisY; } + void setAxisY(QAbstractAxis *axis); + QAbstractAxis *axisXTop() { return m_axisXTop; } + void setAxisXTop(QAbstractAxis *axis); + QAbstractAxis *axisYRight() { return m_axisYRight; } + void setAxisYRight(QAbstractAxis *axis); + +public: + void emitAxisXChanged() { emit axisXChanged(m_axisX); } + void emitAxisYChanged() { emit axisYChanged(m_axisY); } + void emitAxisXTopChanged() { emit axisXTopChanged(m_axisXTop); } + void emitAxisYRightChanged() { emit axisYRightChanged(m_axisYRight); } + +signals: + void axisXChanged(QAbstractAxis *axis); + void axisYChanged(QAbstractAxis *axis); + void axisXTopChanged(QAbstractAxis *axis); + void axisYRightChanged(QAbstractAxis *axis); + +private: + QAbstractAxis *m_axisX; + QAbstractAxis *m_axisY; + QAbstractAxis *m_axisXTop; + QAbstractAxis *m_axisYRight; +}; + +QT_CHARTS_END_NAMESPACE + +#endif // DECLARATIVEAXES_H diff --git a/src/chartsqml2/declarativebarseries.cpp b/src/chartsqml2/declarativebarseries.cpp new file mode 100644 index 00000000..b773eb7b --- /dev/null +++ b/src/chartsqml2/declarativebarseries.cpp @@ -0,0 +1,509 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise 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$ +** +****************************************************************************/ + +#include "declarativebarseries.h" +#include "qbarset.h" +#include "qvbarmodelmapper.h" +#include "qhbarmodelmapper.h" + +QT_CHARTS_BEGIN_NAMESPACE + +DeclarativeBarSet::DeclarativeBarSet(QObject *parent) + : QBarSet("", parent) +{ + connect(this, SIGNAL(valuesAdded(int,int)), this, SLOT(handleCountChanged(int,int))); + connect(this, SIGNAL(valuesRemoved(int,int)), this, SLOT(handleCountChanged(int,int))); + connect(this, SIGNAL(brushChanged()), this, SLOT(handleBrushChanged())); +} + +void DeclarativeBarSet::handleCountChanged(int index, int count) +{ + Q_UNUSED(index) + Q_UNUSED(count) + emit countChanged(QBarSet::count()); +} + +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); + } +} + +QVariantList DeclarativeBarSet::values() +{ + QVariantList values; + for (int i(0); i < count(); i++) + values.append(QVariant(QBarSet::at(i))); + return values; +} + +void DeclarativeBarSet::setValues(QVariantList values) +{ + while (count()) + remove(count() - 1); + + 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()); + } + } +} + +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("")); + } +} + +// Declarative bar series ====================================================================================== +DeclarativeBarSeries::DeclarativeBarSeries(QQuickItem *parent) : + QBarSeries(parent), + 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*))); +} + +void DeclarativeBarSeries::classBegin() +{ +} + +void DeclarativeBarSeries::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); + } + } +} + +QQmlListProperty<QObject> DeclarativeBarSeries::seriesChildren() +{ + return QQmlListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren ,0,0,0); +} + +void DeclarativeBarSeries::appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element) +{ + // Empty implementation; the children are parsed in componentComplete instead + Q_UNUSED(list); + Q_UNUSED(element); +} + +DeclarativeBarSet *DeclarativeBarSeries::at(int index) +{ + QList<QBarSet *> setList = barSets(); + if (index >= 0 && index < setList.count()) + return qobject_cast<DeclarativeBarSet *>(setList[index]); + + return 0; +} + +DeclarativeBarSet *DeclarativeBarSeries::insert(int index, QString label, QVariantList values) +{ + DeclarativeBarSet *barset = new DeclarativeBarSet(this); + barset->setLabel(label); + barset->setValues(values); + if (QBarSeries::insert(index, barset)) + return barset; + delete barset; + return 0; +} + +// Declarative stacked bar series ============================================================================== +DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QQuickItem *parent) : + QStackedBarSeries(parent), + m_axes(0) +{ + 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*))); +} + +void DeclarativeStackedBarSeries::classBegin() +{ +} + +void DeclarativeStackedBarSeries::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); + } + } +} + + +QQmlListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren() +{ + return QQmlListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren ,0,0,0); +} + +void DeclarativeStackedBarSeries::appendSeriesChildren(QQmlListProperty<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(); + if (index >= 0 && index < setList.count()) + return qobject_cast<DeclarativeBarSet *>(setList[index]); + + return 0; +} + +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; +} + +// Declarative percent bar series ============================================================================== +DeclarativePercentBarSeries::DeclarativePercentBarSeries(QQuickItem *parent) : + QPercentBarSeries(parent), + m_axes(0) +{ + 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*))); +} + +void DeclarativePercentBarSeries::classBegin() +{ +} + +void DeclarativePercentBarSeries::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); + } + } +} + +QQmlListProperty<QObject> DeclarativePercentBarSeries::seriesChildren() +{ + return QQmlListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren ,0,0,0); +} + +void DeclarativePercentBarSeries::appendSeriesChildren(QQmlListProperty<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(); + if (index >= 0 && index < setList.count()) + return qobject_cast<DeclarativeBarSet *>(setList[index]); + + return 0; +} + +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; +} + +// Declarative horizontal bar series =========================================================================== +DeclarativeHorizontalBarSeries::DeclarativeHorizontalBarSeries(QQuickItem *parent) : + QHorizontalBarSeries(parent), + m_axes(0) +{ + 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*))); +} + +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); + } + } +} + +QQmlListProperty<QObject> DeclarativeHorizontalBarSeries::seriesChildren() +{ + return QQmlListProperty<QObject>(this, 0, &DeclarativeHorizontalBarSeries::appendSeriesChildren ,0,0,0); +} + +void DeclarativeHorizontalBarSeries::appendSeriesChildren(QQmlListProperty<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(QQuickItem *parent) : + QHorizontalStackedBarSeries(parent), + m_axes(0) +{ + 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*))); +} + +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); + } + } +} + +QQmlListProperty<QObject> DeclarativeHorizontalStackedBarSeries::seriesChildren() +{ + return QQmlListProperty<QObject>(this, 0, &DeclarativeHorizontalStackedBarSeries::appendSeriesChildren ,0,0,0); +} + +void DeclarativeHorizontalStackedBarSeries::appendSeriesChildren(QQmlListProperty<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(QQuickItem *parent) : + QHorizontalPercentBarSeries(parent), + m_axes(0) +{ + 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*))); +} + +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); + } + } +} + +QQmlListProperty<QObject> DeclarativeHorizontalPercentBarSeries::seriesChildren() +{ + return QQmlListProperty<QObject>(this, 0, &DeclarativeHorizontalPercentBarSeries::appendSeriesChildren ,0,0,0); +} + +void DeclarativeHorizontalPercentBarSeries::appendSeriesChildren(QQmlListProperty<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; +} + +#include "moc_declarativebarseries.cpp" + +QT_CHARTS_END_NAMESPACE diff --git a/src/chartsqml2/declarativebarseries.h b/src/chartsqml2/declarativebarseries.h new file mode 100644 index 00000000..6c3b6d89 --- /dev/null +++ b/src/chartsqml2/declarativebarseries.h @@ -0,0 +1,361 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise 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$ +** +****************************************************************************/ + +#ifndef DECLARATIVEBARSERIES_H +#define DECLARATIVEBARSERIES_H + +#include "qbarseries.h" +#include "qstackedbarseries.h" +#include "qpercentbarseries.h" +#include "qhorizontalbarseries.h" +#include "qhorizontalstackedbarseries.h" +#include "qhorizontalpercentbarseries.h" +#include "qbarset.h" +#include "declarativeaxes.h" + +#include <QtQuick/QQuickItem> +#include <QtQml/QQmlParserStatus> + +QT_CHARTS_BEGIN_NAMESPACE + +class QChart; + +class DeclarativeBarSet : public QBarSet +{ + Q_OBJECT + Q_PROPERTY(QVariantList values READ values WRITE setValues) + Q_PROPERTY(qreal borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged REVISION 1) + Q_PROPERTY(int count READ count NOTIFY countChanged) + Q_PROPERTY(QString brushFilename READ brushFilename WRITE setBrushFilename NOTIFY brushFilenameChanged REVISION 2) + +public: + explicit DeclarativeBarSet(QObject *parent = 0); + QVariantList values(); + void setValues(QVariantList values); + qreal borderWidth() const; + void setBorderWidth(qreal borderWidth); + QString brushFilename() const; + void setBrushFilename(const QString &brushFilename); + +public: // From QBarSet + Q_INVOKABLE void append(qreal value) { QBarSet::append(value); } + Q_INVOKABLE void remove(const int index, const int count = 1) { QBarSet::remove(index, count); } + Q_INVOKABLE void replace(int index, qreal value) { QBarSet::replace(index, value); } + Q_INVOKABLE qreal at(int index) { return QBarSet::at(index); } + +Q_SIGNALS: + void countChanged(int count); + Q_REVISION(1) void borderWidthChanged(qreal width); + Q_REVISION(2) void brushFilenameChanged(const QString &brushFilename); + +private Q_SLOTS: + void handleCountChanged(int index, int count); + void handleBrushChanged(); + +private: + QString m_brushFilename; + QImage m_brushImage; +}; + +class DeclarativeBarSeries : public QBarSeries, public QQmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QQmlParserStatus) + Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) + Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) + Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2) + Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2) + Q_PROPERTY(QQmlListProperty<QObject> seriesChildren READ seriesChildren) + Q_CLASSINFO("DefaultProperty", "seriesChildren") + +public: + explicit DeclarativeBarSeries(QQuickItem *parent = 0); + QAbstractAxis *axisX() { return m_axes->axisX(); } + void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } + QAbstractAxis *axisY() { return m_axes->axisY(); } + void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); } + Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); } + Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); } + Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); } + Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); } + QQmlListProperty<QObject> seriesChildren(); + +public: + Q_INVOKABLE DeclarativeBarSet *at(int index); + Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } + Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); + Q_INVOKABLE bool remove(QBarSet *barset) { return QBarSeries::remove(barset); } + Q_INVOKABLE void clear() { return QBarSeries::clear(); } + +public: // from QDeclarativeParserStatus + void classBegin(); + void componentComplete(); + +Q_SIGNALS: + Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); + Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); + Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis); + Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis); + +public Q_SLOTS: + static void appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element); + +public: + DeclarativeAxes *m_axes; +}; + +class DeclarativeStackedBarSeries : public QStackedBarSeries, public QQmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QQmlParserStatus) + Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) + Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) + Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2) + Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2) + Q_PROPERTY(QQmlListProperty<QObject> seriesChildren READ seriesChildren) + Q_CLASSINFO("DefaultProperty", "seriesChildren") + +public: + explicit DeclarativeStackedBarSeries(QQuickItem *parent = 0); + QAbstractAxis *axisX() { return m_axes->axisX(); } + void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } + QAbstractAxis *axisY() { return m_axes->axisY(); } + void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); } + Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); } + Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); } + Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); } + Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); } + QQmlListProperty<QObject> seriesChildren(); + +public: + Q_INVOKABLE DeclarativeBarSet *at(int index); + Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } + Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); + Q_INVOKABLE bool remove(QBarSet *barset) { return QStackedBarSeries::remove(barset); } + Q_INVOKABLE void clear() { return QStackedBarSeries::clear(); } + +public: // from QDeclarativeParserStatus + void classBegin(); + void componentComplete(); + +Q_SIGNALS: + Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); + Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); + Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis); + Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis); + +public Q_SLOTS: + static void appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element); + +public: + DeclarativeAxes *m_axes; +}; + +class DeclarativePercentBarSeries : public QPercentBarSeries, public QQmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QQmlParserStatus) + Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) + Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) + Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2) + Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2) + Q_PROPERTY(QQmlListProperty<QObject> seriesChildren READ seriesChildren) + Q_CLASSINFO("DefaultProperty", "seriesChildren") + +public: + explicit DeclarativePercentBarSeries(QQuickItem *parent = 0); + QAbstractAxis *axisX() { return m_axes->axisX(); } + void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } + QAbstractAxis *axisY() { return m_axes->axisY(); } + void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); } + Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); } + Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); } + Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); } + Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); } + QQmlListProperty<QObject> seriesChildren(); + +public: + Q_INVOKABLE DeclarativeBarSet *at(int index); + Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } + Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); + Q_INVOKABLE bool remove(QBarSet *barset) { return QPercentBarSeries::remove(barset); } + Q_INVOKABLE void clear() { return QPercentBarSeries::clear(); } + +public: // from QDeclarativeParserStatus + void classBegin(); + void componentComplete(); + +Q_SIGNALS: + Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); + Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); + Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis); + Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis); + +public Q_SLOTS: + static void appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element); + +public: + DeclarativeAxes *m_axes; +}; + +class DeclarativeHorizontalBarSeries : public QHorizontalBarSeries, public QQmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QQmlParserStatus) + Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) + Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) + Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2) + Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2) + Q_PROPERTY(QQmlListProperty<QObject> seriesChildren READ seriesChildren) + Q_CLASSINFO("DefaultProperty", "seriesChildren") + +public: + explicit DeclarativeHorizontalBarSeries(QQuickItem *parent = 0); + QAbstractAxis *axisX() { return m_axes->axisX(); } + void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } + QAbstractAxis *axisY() { return m_axes->axisY(); } + void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); } + Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); } + Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); } + Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); } + Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); } + QQmlListProperty<QObject> seriesChildren(); + +public: + Q_INVOKABLE DeclarativeBarSet *at(int index); + Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } + Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); + Q_INVOKABLE bool remove(QBarSet *barset) { return QHorizontalBarSeries::remove(barset); } + Q_INVOKABLE void clear() { return QHorizontalBarSeries::clear(); } + +public: // from QDeclarativeParserStatus + void classBegin(); + void componentComplete(); + +Q_SIGNALS: + Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); + Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); + Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis); + Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis); + +public Q_SLOTS: + static void appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element); + +public: + DeclarativeAxes *m_axes; +}; + +class DeclarativeHorizontalStackedBarSeries : public QHorizontalStackedBarSeries, public QQmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QQmlParserStatus) + Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) + Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) + Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2) + Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2) + Q_PROPERTY(QQmlListProperty<QObject> seriesChildren READ seriesChildren) + Q_CLASSINFO("DefaultProperty", "seriesChildren") + +public: + explicit DeclarativeHorizontalStackedBarSeries(QQuickItem *parent = 0); + QAbstractAxis *axisX() { return m_axes->axisX(); } + void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } + QAbstractAxis *axisY() { return m_axes->axisY(); } + void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); } + Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); } + Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); } + Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); } + Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); } + QQmlListProperty<QObject> seriesChildren(); + +public: + Q_INVOKABLE DeclarativeBarSet *at(int index); + Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } + Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); + Q_INVOKABLE bool remove(QBarSet *barset) { return QHorizontalStackedBarSeries::remove(barset); } + Q_INVOKABLE void clear() { return QHorizontalStackedBarSeries::clear(); } + +public: // from QDeclarativeParserStatus + void classBegin(); + void componentComplete(); + +Q_SIGNALS: + Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); + Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); + Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis); + Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis); + +public Q_SLOTS: + static void appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element); + +public: + DeclarativeAxes *m_axes; +}; + +class DeclarativeHorizontalPercentBarSeries : public QHorizontalPercentBarSeries, public QQmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QQmlParserStatus) + Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) + Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) + Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2) + Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2) + Q_PROPERTY(QQmlListProperty<QObject> seriesChildren READ seriesChildren) + Q_CLASSINFO("DefaultProperty", "seriesChildren") + +public: + explicit DeclarativeHorizontalPercentBarSeries(QQuickItem *parent = 0); + QAbstractAxis *axisX() { return m_axes->axisX(); } + void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } + QAbstractAxis *axisY() { return m_axes->axisY(); } + void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); } + Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); } + Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); } + Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); } + Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); } + QQmlListProperty<QObject> seriesChildren(); + +public: + Q_INVOKABLE DeclarativeBarSet *at(int index); + Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } + Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); + Q_INVOKABLE bool remove(QBarSet *barset) { return QHorizontalPercentBarSeries::remove(barset); } + Q_INVOKABLE void clear() { return QHorizontalPercentBarSeries::clear(); } + +public: // from QDeclarativeParserStatus + void classBegin(); + void componentComplete(); + +Q_SIGNALS: + Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); + Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); + Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis); + Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis); + +public Q_SLOTS: + static void appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element); + +public: + DeclarativeAxes *m_axes; +}; + +QT_CHARTS_END_NAMESPACE + +#endif // DECLARATIVEBARSERIES_H diff --git a/src/chartsqml2/declarativeboxplotseries.cpp b/src/chartsqml2/declarativeboxplotseries.cpp new file mode 100644 index 00000000..101dab58 --- /dev/null +++ b/src/chartsqml2/declarativeboxplotseries.cpp @@ -0,0 +1,423 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise 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$ +** +****************************************************************************/ + +#include "declarativebarseries.h" +#include "declarativeboxplotseries.h" +#include "qboxset.h" +#include "qvboxplotmodelmapper.h" + +QT_CHARTS_BEGIN_NAMESPACE + +/*! + \qmltype BoxSet + \instantiates QBoxSet + \inqmlmodule QtCharts + + BoxSet represents one box-and-whiskers item. It takes five values to create a graphical + representation of range and three medians. There are two ways to give the values. The first one + is with constructor or with append method. In these the values have to be given in the following + order: lower extreme, lower quartile, median, upper quartile and upper extreme. The second + method is to create an empty QBoxSet instance and give the values using value specific methods. + \sa BoxPlotSeries +*/ +/*! + \qmlproperty string BoxSet::values + The values on the box-and-whiskers set. +*/ +/*! + \qmlproperty string BoxSet::label + Defines the label of the box-and-whiskers set. +*/ +/*! + \qmlproperty int BoxSet::count + The count of values on the box-and-whiskers set +*/ +/*! + \qmlmethod void BoxSet::at(int index) + Returns the value at \a index position. +*/ +/*! + \qmlmethod void BoxSet::append(qreal value) + Appends new value \a value to the end of set. +*/ +/*! + \qmlmethod void BoxSet::clear() + Sets all values on the set to 0. +*/ +/*! + \qmlmethod void BoxSet::setValue(int index, qreal value) + Sets a new \a value on the \a index position. +*/ +/*! + \qmlsignal BoxSet::onClicked() + This signal is emitted when the user clicks with a mouse on top of box-and-whiskers item. +*/ +/*! + \qmlsignal BoxSet::onHovered(bool status) + The signal is emitted if mouse is hovered on top of box-and-whiskers item. + Parameter \a status is true, if mouse entered on top of the item, and false if mouse left from top of the item. +*/ +/*! + \qmlsignal BoxSet::onPenChanged() + This signal is emitted when the pen of the box-and-whiskers item has changed. +*/ +/*! + \qmlsignal BoxSet::onBrushChanged() + This signal is emitted when the brush of the box-and-whiskers item has changed. +*/ +/*! + \qmlsignal BoxSet::onChangedValues() + This signal is emitted when multiple values have been changed on the box-and-whiskers item. +*/ +/*! + \qmlsignal BoxSet::onChangedValue(int index) + This signal is emitted values the value in the box-and-whiskers item has been modified. + Parameter \a index indicates the position of the modified value. +*/ +/*! + \qmlsignal BoxSet::onCleared() + This signal is emitted when all the values on the set are cleared to 0. +*/ + +/*! + \qmltype BoxPlotSeries + \instantiates QBoxPlotSeries + \inqmlmodule QtCharts + + \inherits AbstractSeries + + BoxPlotSeries represents a series of data shown as box-and-whiskers bars. The purpose of this + class is to act as a container for single box-and-whiskers items. Each item is drawn to own + slot. If chart includes multiple instances of BoxPlotSeries then box-and-whiskers items with the + same index are drawn to same slot. + + The following QML shows how to create a simple box-and-whiskers chart: + \code + import QtQuick 2.0 + import QtCharts 2.0 + + ChartView { + title: "Box Plot series" + width: 400 + height: 300 + theme: ChartView.ChartThemeBrownSand + legend.alignment: Qt.AlignBottom + + BoxPlotSeries { + id: plotSeries + name: "Income" + BoxSet { label: "Jan"; values: [3, 4, 5.1, 6.2, 8.5] } + BoxSet { label: "Feb"; values: [5, 6, 7.5, 8.6, 11.8] } + BoxSet { label: "Mar"; values: [3.2, 5, 5.7, 8, 9.2] } + BoxSet { label: "Apr"; values: [3.8, 5, 6.4, 7, 8] } + BoxSet { label: "May"; values: [4, 5, 5.2, 6, 7] } + } + } + \endcode + + \beginfloatleft + \image examples_qmlboxplot.png + \endfloat + \clearfloat +*/ + +/*! + \qmlmethod BoxPlotSeries::append(string label, VariantList values) + Appends a new box-and-whiskers set with \a label and \a values to the series. + */ +/*! + \qmlmethod BoxPlotSeries::append(BoxSet box) + Appends the \a box to the series. +*/ +/*! + \qmlmethod BoxPlotSeries::insert(int index, string label, VariantList values) + Inserts a new box-and-whiskers set with \a label and \a values at the \a index position. +*/ +/*! + \qmlmethod BoxPlotSeries::remove(QBoxSet boxset) + Removes the \a boxset from the series. +*/ +/*! + \qmlmethod BoxPlotSeries::clear() + Removes all boxsets from the series. Deletes removed sets. +*/ +/*! + \qmlsignal BoxPlotSeries::onClicked(BoxSet boxset); + Signal is emitted when the user clicks the \a boxset on the chart. +*/ +/*! + \qmlsignal BoxPlotSeries::onHovered(bool status, BoxSet boxset); + Signal is emitted when there is change in hover \a status over \a boxset. +*/ +/*! + \qmlsignal BoxPlotSeries::onCountChanged(); + Signal is emitted when there is change in count of box-and-whiskers items in the series. +*/ +/*! + \qmlsignal BoxPlotSeries::onBoxsetsAdded() + Signal is emitted when new box-and-whiskers sets are added to the series. + */ +/*! + \qmlsignal BoxPlotSeries::onBoxsetsRemoved() + Signal is emitted when new box-and-whiskers sets are removed from the series. + */ +/*! + \qmlproperty AbstractAxis BoxPlotSeries::axisX + The x axis used for the series. If you leave both axisX and axisXTop undefined, a BarCategoriesAxis is created for + the series. + \sa axisXTop +*/ +/*! + \qmlproperty AbstractAxis BoxPlotSeries::axisY + The y axis used for the series. If you leave both axisY and axisYRight undefined, a ValueAxis is created for + the series. + \sa axisYRight +*/ +/*! + \qmlproperty AbstractAxis BoxPlotSeries::axisXTop + The x axis used for the series, drawn on top of the chart view. Note that you can only provide either axisX or + axisXTop, but not both. + \sa axisX +*/ +/*! + \qmlproperty AbstractAxis BoxPlotSeries::axisYRight + The y axis used for the series, drawn to the right on the chart view. Note that you can only provide either axisY + or axisYRight, but not both. + \sa axisY +*/ +/*! + \qmlproperty bool BoxPlotSeries::boxOutlineVisible + This property configures the visibility of the middle box outline. +*/ +/*! + \qmlproperty qreal BoxPlotSeries::boxWidth + This property configures the width of the box-and-whiskers item. The value signifies the relative + width of the box-and-whiskers item inside its own slot. The value can between 0.0 and 1.0. Negative values + are clamped to 0.0 and values over 1.0 are clamped to 1.0. +*/ +/*! + \qmlproperty Pen BoxPlotSeries::pen + This property configures the pen of the box-and-whiskers items. +*/ +/*! + \qmlproperty Brush BoxPlotSeries::brush + This property configures the brush of the box-and-whiskers items. +*/ +/*! + \qmlproperty int BoxPlotSeries::count + The count of sets in series. +*/ +/*! + \qmlsignal BoxPlotSeries::onBoxOutlineVisibilityChanged() + Signal is emitted when the middle box outline visibility is changed. + */ +/*! + \qmlsignal BoxPlotSeries::onBoxWidthChanged() + Signal is emitted when the width of the box-and-whiskers item is changed. + */ +/*! + \qmlsignal BoxPlotSeries::onPenChanged() + Signal is emitted when the pen for box-and-whiskers items has changed. +*/ +/*! + \qmlsignal BoxPlotSeries::onBrushChanged() + Signal is emitted when the brush for box-and-whiskers items has changed. +*/ +/*! + \qmlsignal BoxPlotSeries::onClicked(BoxSet boxset) + Signal is emitted when the user clicks the \a boxset on the chart. +*/ +/*! + \qmlsignal BoxPlotSeries::onHovered(bool status, BoxSet boxset) + Signal is emitted when there is change in hover \a status over \a boxset. +*/ +/*! + \qmlsignal BoxPlotSeries::onAxisXChanged(AbstractAxis axis) + Signal is emitted when there is change in X axis. +*/ +/*! + \qmlsignal BoxPlotSeries::onAxisYChanged(AbstractAxis axis) + Signal is emitted when there is change in Y axis. +*/ +/*! + \qmlsignal BoxPlotSeries::onAxisXTopChanged(AbstractAxis axis) + Signal is emitted when there is change in top X axis. +*/ +/*! + \qmlsignal BoxPlotSeries::onAxisYRightChanged(AbstractAxis axis) + Signal is emitted when there is change in Y right axis. +*/ + + +DeclarativeBoxSet::DeclarativeBoxSet(const QString label, QObject *parent) + : QBoxSet(label, parent) +{ + connect(this, SIGNAL(valuesChanged()), this, SIGNAL(changedValues())); + connect(this, SIGNAL(valueChanged(int)), this, SIGNAL(changedValue(int))); + connect(this, SIGNAL(brushChanged()), this, SLOT(handleBrushChanged())); +} + +QVariantList DeclarativeBoxSet::values() +{ + QVariantList values; + for (int i(0); i < 5; i++) + values.append(QVariant(QBoxSet::at(i))); + return values; +} + +void DeclarativeBoxSet::setValues(QVariantList values) +{ + for (int i(0); i < values.count(); i++) { + if (values.at(i).canConvert(QVariant::Double)) + QBoxSet::append(values[i].toDouble()); + } +} + +QString DeclarativeBoxSet::brushFilename() const +{ + return m_brushFilename; +} + +void DeclarativeBoxSet::setBrushFilename(const QString &brushFilename) +{ + QImage brushImage(brushFilename); + if (QBoxSet::brush().textureImage() != brushImage) { + QBrush brush = QBoxSet::brush(); + brush.setTextureImage(brushImage); + QBoxSet::setBrush(brush); + m_brushFilename = brushFilename; + m_brushImage = brushImage; + emit brushFilenameChanged(brushFilename); + } +} + +void DeclarativeBoxSet::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() && QBoxSet::brush().textureImage() != m_brushImage) { + m_brushFilename.clear(); + emit brushFilenameChanged(QString("")); + } +} + +// ===================================================== + +DeclarativeBoxPlotSeries::DeclarativeBoxPlotSeries(QQuickItem *parent) : + QBoxPlotSeries(parent), + 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*))); + connect(this, SIGNAL(hovered(bool, QBoxSet*)), this, SLOT(onHovered(bool, QBoxSet*))); + connect(this, SIGNAL(clicked(QBoxSet*)), this, SLOT(onClicked(QBoxSet*))); + connect(this, SIGNAL(brushChanged()), this, SLOT(handleBrushChanged())); +} + +void DeclarativeBoxPlotSeries::classBegin() +{ +} + +void DeclarativeBoxPlotSeries::componentComplete() +{ + foreach (QObject *child, children()) { + if (qobject_cast<DeclarativeBoxSet *>(child)) { + QBoxPlotSeries::append(qobject_cast<DeclarativeBoxSet *>(child)); + } else if (qobject_cast<QVBoxPlotModelMapper *>(child)) { + QVBoxPlotModelMapper *mapper = qobject_cast<QVBoxPlotModelMapper *>(child); + mapper->setSeries(this); + } + } +} + +QQmlListProperty<QObject> DeclarativeBoxPlotSeries::seriesChildren() +{ + return QQmlListProperty<QObject>(this, 0, &DeclarativeBoxPlotSeries::appendSeriesChildren ,0,0,0); +} + +void DeclarativeBoxPlotSeries::appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element) +{ + // Empty implementation; the children are parsed in componentComplete instead + Q_UNUSED(list); + Q_UNUSED(element); +} + +DeclarativeBoxSet *DeclarativeBoxPlotSeries::at(int index) +{ + QList<QBoxSet *> setList = boxSets(); + if (index >= 0 && index < setList.count()) + return qobject_cast<DeclarativeBoxSet *>(setList[index]); + + return 0; +} + +DeclarativeBoxSet *DeclarativeBoxPlotSeries::insert(int index, const QString label, QVariantList values) +{ + DeclarativeBoxSet *barset = new DeclarativeBoxSet(label, this); + barset->setValues(values); + if (QBoxPlotSeries::insert(index, barset)) + return barset; + delete barset; + return 0; +} + +void DeclarativeBoxPlotSeries::onHovered(bool status, QBoxSet *boxset) +{ + emit hovered(status, qobject_cast<DeclarativeBoxSet *>(boxset)); +} + +void DeclarativeBoxPlotSeries::onClicked(QBoxSet *boxset) +{ + emit clicked(qobject_cast<DeclarativeBoxSet *>(boxset)); +} + +QString DeclarativeBoxPlotSeries::brushFilename() const +{ + return m_brushFilename; +} + +void DeclarativeBoxPlotSeries::setBrushFilename(const QString &brushFilename) +{ + QImage brushImage(brushFilename); + if (QBoxPlotSeries::brush().textureImage() != brushImage) { + QBrush brush = QBoxPlotSeries::brush(); + brush.setTextureImage(brushImage); + QBoxPlotSeries::setBrush(brush); + m_brushFilename = brushFilename; + m_brushImage = brushImage; + emit brushFilenameChanged(brushFilename); + } +} + +void DeclarativeBoxPlotSeries::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() && QBoxPlotSeries::brush().textureImage() != m_brushImage) { + m_brushFilename.clear(); + emit brushFilenameChanged(QString("")); + } +} + +#include "moc_declarativeboxplotseries.cpp" + +QT_CHARTS_END_NAMESPACE diff --git a/src/chartsqml2/declarativeboxplotseries.h b/src/chartsqml2/declarativeboxplotseries.h new file mode 100644 index 00000000..10dab699 --- /dev/null +++ b/src/chartsqml2/declarativeboxplotseries.h @@ -0,0 +1,142 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise 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$ +** +****************************************************************************/ + +#ifndef DECLARATIVEBOXPLOT_H +#define DECLARATIVEBOXPLOT_H + +#include "qboxset.h" +#include "declarativeaxes.h" +#include "qboxplotseries.h" + +#include <QtQuick/QQuickItem> +#include <QtQml/QQmlParserStatus> + +QT_CHARTS_BEGIN_NAMESPACE + +class DeclarativeBoxSet : public QBoxSet +{ + Q_OBJECT + Q_PROPERTY(QVariantList values READ values WRITE setValues) + Q_PROPERTY(QString label READ label WRITE setLabel) + Q_PROPERTY(int count READ count) + Q_PROPERTY(QString brushFilename READ brushFilename WRITE setBrushFilename NOTIFY brushFilenameChanged REVISION 1) + Q_ENUMS(ValuePositions) + +public: // duplicate from QBoxSet + enum ValuePositions { + LowerExtreme = 0x0, + LowerQuartile, + Median, + UpperQuartile, + UpperExtreme + }; + +public: + explicit DeclarativeBoxSet(const QString label = "", QObject *parent = 0); + QVariantList values(); + void setValues(QVariantList values); + QString brushFilename() const; + void setBrushFilename(const QString &brushFilename); + +public: // From QBoxSet + Q_INVOKABLE void append(qreal value) { QBoxSet::append(value); } + Q_INVOKABLE void clear() {QBoxSet::clear(); } + Q_INVOKABLE qreal at(int index) { return QBoxSet::at(index); } + Q_INVOKABLE void setValue(int index, qreal value) { QBoxSet::setValue(index, value); } + +Q_SIGNALS: + void changedValues(); + void changedValue(int index); + Q_REVISION(1) void brushFilenameChanged(const QString &brushFilename); + +private Q_SLOTS: + void handleBrushChanged(); + +private: + QString m_brushFilename; + QImage m_brushImage; +}; + +class DeclarativeBoxPlotSeries : public QBoxPlotSeries, public QQmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QQmlParserStatus) + Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged) + Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged) + Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged) + Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged) + Q_PROPERTY(QQmlListProperty<QObject> seriesChildren READ seriesChildren) + Q_PROPERTY(QString brushFilename READ brushFilename WRITE setBrushFilename NOTIFY brushFilenameChanged REVISION 1) + Q_CLASSINFO("DefaultProperty", "seriesChildren") + +public: + explicit DeclarativeBoxPlotSeries(QQuickItem *parent = 0); + QAbstractAxis *axisX() { return m_axes->axisX(); } + void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } + QAbstractAxis *axisY() { return m_axes->axisY(); } + void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); } + QAbstractAxis *axisXTop() { return m_axes->axisXTop(); } + void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); } + QAbstractAxis *axisYRight() { return m_axes->axisYRight(); } + void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); } + QQmlListProperty<QObject> seriesChildren(); + QString brushFilename() const; + void setBrushFilename(const QString &brushFilename); + +public: + Q_INVOKABLE DeclarativeBoxSet *at(int index); + Q_INVOKABLE DeclarativeBoxSet *append(const QString label, QVariantList values) { return insert(count(), label, values); } + Q_INVOKABLE void append(DeclarativeBoxSet *box) { QBoxPlotSeries::append(box); } + Q_INVOKABLE DeclarativeBoxSet *insert(int index, const QString label, QVariantList values); + Q_INVOKABLE bool remove(DeclarativeBoxSet *box) { return QBoxPlotSeries::remove(qobject_cast<QBoxSet *>(box)); } + Q_INVOKABLE void clear() { return QBoxPlotSeries::clear(); } + +public: // from QDeclarativeParserStatus + void classBegin(); + void componentComplete(); + +Q_SIGNALS: + void axisXChanged(QAbstractAxis *axis); + void axisYChanged(QAbstractAxis *axis); + void axisXTopChanged(QAbstractAxis *axis); + void axisYRightChanged(QAbstractAxis *axis); + void clicked(DeclarativeBoxSet *boxset); + void hovered(bool status, DeclarativeBoxSet *boxset); + Q_REVISION(1) void brushFilenameChanged(const QString &brushFilename); + +public Q_SLOTS: + static void appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element); + void onHovered(bool status, QBoxSet *boxset); + void onClicked(QBoxSet *boxset); + +private Q_SLOTS: + void handleBrushChanged(); + +public: + DeclarativeAxes *m_axes; + +private: + QString m_brushFilename; + QImage m_brushImage; +}; + +QT_CHARTS_END_NAMESPACE + +#endif // DECLARATIVEBOXPLOT_H diff --git a/src/chartsqml2/declarativecategoryaxis.cpp b/src/chartsqml2/declarativecategoryaxis.cpp new file mode 100644 index 00000000..423aab67 --- /dev/null +++ b/src/chartsqml2/declarativecategoryaxis.cpp @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise 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$ +** +****************************************************************************/ + +#include "declarativecategoryaxis.h" +#include <QDebug> + +QT_CHARTS_BEGIN_NAMESPACE + +/*! + \qmltype CategoryRange + \inqmlmodule QtCharts + + \brief With CategoryRange you can define a range used by a CategoryAxis. + \sa CategoryAxis +*/ + +DeclarativeCategoryRange::DeclarativeCategoryRange(QObject *parent) : + QObject(parent), + m_endValue(0), + m_label(QString()) +{ +} + +DeclarativeCategoryAxis::DeclarativeCategoryAxis(QObject *parent) : + QCategoryAxis(parent) +{ +} + +void DeclarativeCategoryAxis::classBegin() +{ +} + +void DeclarativeCategoryAxis::componentComplete() +{ + QList<QPair<QString, qreal> > ranges; + foreach (QObject *child, children()) { + if (qobject_cast<DeclarativeCategoryRange *>(child)) { + DeclarativeCategoryRange *range = qobject_cast<DeclarativeCategoryRange *>(child); + ranges.append(QPair<QString, qreal>(range->label(), range->endValue())); + } + } + + // Sort and append the range objects according to end value + qSort(ranges.begin(), ranges.end(), endValueLessThan); + for (int i(0); i < ranges.count(); i++) + append(ranges.at(i).first, ranges.at(i).second); +} + +bool DeclarativeCategoryAxis::endValueLessThan(const QPair<QString, qreal> &value1, const QPair<QString, qreal> &value2) +{ + return value1.second < value2.second; +} + +QQmlListProperty<QObject> DeclarativeCategoryAxis::axisChildren() +{ + return QQmlListProperty<QObject>(this, 0, &DeclarativeCategoryAxis::appendAxisChildren ,0,0,0); +} + +void DeclarativeCategoryAxis::append(const QString &label, qreal categoryEndValue) +{ + QCategoryAxis::append(label, categoryEndValue); +} + +void DeclarativeCategoryAxis::remove(const QString &label) +{ + QCategoryAxis::remove(label); +} + +void DeclarativeCategoryAxis::replace(const QString &oldLabel, const QString &newLabel) +{ + QCategoryAxis::replaceLabel(oldLabel, newLabel); +} + +void DeclarativeCategoryAxis::appendAxisChildren(QQmlListProperty<QObject> *list, QObject *element) +{ + // Empty implementation; the children are parsed in componentComplete instead + Q_UNUSED(list) + Q_UNUSED(element) +} + +#include "moc_declarativecategoryaxis.cpp" + +QT_CHARTS_END_NAMESPACE diff --git a/src/chartsqml2/declarativecategoryaxis.h b/src/chartsqml2/declarativecategoryaxis.h new file mode 100644 index 00000000..3a6dda95 --- /dev/null +++ b/src/chartsqml2/declarativecategoryaxis.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise 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$ +** +****************************************************************************/ + +#ifndef DECLARATIVECATEGORYAXIS_H +#define DECLARATIVECATEGORYAXIS_H + +#include "qcategoryaxis.h" + +#include <QtQml/QQmlListProperty> +#include <QtQml/QQmlParserStatus> + +QT_CHARTS_BEGIN_NAMESPACE + +class DeclarativeCategoryRange : public QObject +{ + Q_OBJECT + Q_PROPERTY(qreal endValue READ endValue WRITE setEndValue) + Q_PROPERTY(QString label READ label WRITE setLabel) + +public: + explicit DeclarativeCategoryRange(QObject *parent = 0); + qreal endValue() { return m_endValue; } + void setEndValue(qreal endValue) { m_endValue = endValue; } + QString label() { return m_label; } + void setLabel(QString label) { m_label = label; } + +private: + qreal m_endValue; + QString m_label; +}; + +class DeclarativeCategoryAxis : public QCategoryAxis, public QQmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QQmlParserStatus) + Q_PROPERTY(QQmlListProperty<QObject> axisChildren READ axisChildren) + Q_CLASSINFO("DefaultProperty", "axisChildren") + +public: + explicit DeclarativeCategoryAxis(QObject *parent = 0); + QQmlListProperty<QObject> axisChildren(); + +public: // from QDeclarativeParserStatus + void classBegin(); + void componentComplete(); + +public Q_SLOTS: + Q_INVOKABLE void append(const QString &label, qreal categoryEndValue); + Q_INVOKABLE void remove(const QString &label); + Q_INVOKABLE void replace(const QString &oldLabel, const QString &newLabel); + static void appendAxisChildren(QQmlListProperty<QObject> *list, QObject *element); + +private: + static bool endValueLessThan(const QPair<QString, qreal> &value1, const QPair<QString, qreal> &value2); +}; + +QT_CHARTS_END_NAMESPACE + +#endif // DECLARATIVECATEGORYAXIS_H diff --git a/src/chartsqml2/declarativechart.cpp b/src/chartsqml2/declarativechart.cpp new file mode 100644 index 00000000..d2044ed0 --- /dev/null +++ b/src/chartsqml2/declarativechart.cpp @@ -0,0 +1,1063 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise 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$ +** +****************************************************************************/ + +#include "declarativechart.h" +#include <QPainter> +#include "declarativelineseries.h" +#include "declarativeareaseries.h" +#include "declarativebarseries.h" +#include "declarativepieseries.h" +#include "declarativesplineseries.h" +#include "declarativeboxplotseries.h" +#include "declarativescatterseries.h" +#include "qbarcategoryaxis.h" +#include "qvalueaxis.h" +#include "qlogvalueaxis.h" +#include "qcategoryaxis.h" +#include "qabstractseries_p.h" +#include "declarativemargins.h" +#include "chartdataset_p.h" +#include "declarativeaxes.h" +#include "qchart_p.h" +#include "qpolarchart.h" + +#ifndef QT_ON_ARM + #include "qdatetimeaxis.h" +#endif + +#include <QGraphicsSceneMouseEvent> +#include <QGraphicsSceneHoverEvent> +#include <QApplication> +#include <QTimer> +#include <QThread> + +QT_CHARTS_BEGIN_NAMESPACE + +/*! + \qmltype ChartView + \instantiates DeclarativeChart + \inqmlmodule QtCharts + + ChartView element is the parent that is responsible for showing different chart series types. + + The following QML shows how to create a simple chart with one pie series: + \snippet qmlpiechart/qml/qmlpiechart/main.qml 1 + \snippet qmlpiechart/qml/qmlpiechart/main.qml 2 + \snippet qmlpiechart/qml/qmlpiechart/main.qml 3 + + \beginfloatleft + \image examples_qmlpiechart.png + \endfloat + \clearfloat +*/ + +/*! + \qmlproperty Theme ChartView::theme + Theme defines the visual appearance of the chart, including for example colors, fonts, line + widths and chart background. +*/ + +/*! + \qmlproperty Animation ChartView::animationOptions + Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations, + ChartView.SeriesAnimations or ChartView.AllAnimations. +*/ + +/*! + \qmlproperty Font ChartView::titleFont + The title font of the chart. + + See the Qt documentation for more details of Font. +*/ + +/*! + \qmlproperty string ChartView::title + The title of the chart, shown on top of the chart. + \sa ChartView::titleColor +*/ + +/*! + \qmlproperty color ChartView::titleColor + The color of the title text. +*/ + +/*! + \qmlproperty Legend ChartView::legend + The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart. +*/ + +/*! + \qmlproperty int ChartView::count + The count of series added to the chart. +*/ + +/*! + \qmlproperty color ChartView::backgroundColor + The color of the chart's background. By default background color is defined by chart theme. + \sa ChartView::theme +*/ + +/*! + \qmlproperty real ChartView::backgroundRoundness + The diameter of the rounding cirle at the corners of the chart background. +*/ + +/*! + \qmlproperty color ChartView::plotAreaColor + The color of the background of the chart's plot area. By default plot area background uses chart's + background color. + \sa ChartView::backgroundColor +*/ + +/*! + \qmlproperty bool ChartView::dropShadowEnabled + The chart's border drop shadow. Set to true to enable drop shadow. +*/ + +/*! + \qmlproperty real ChartView::topMargin + Deprecated; use margins instead. +*/ + +/*! + \qmlproperty real ChartView::bottomMargin + Deprecated; use margins instead. +*/ + +/*! + \qmlproperty real ChartView::leftMargin + Deprecated; use margins instead. +*/ + +/*! + \qmlproperty real ChartView::rightMargin + Deprecated; use margins instead. +*/ + +/*! + \qmlproperty Margins ChartView::minimumMargins + Deprecated; use margins instead. + The minimum margins allowed between the outer bounds and the plotArea of the ChartView. Margins + area of ChartView is used for drawing title, axes and legend. Please note that setting the + properties of minimumMargins may be bigger than the defined value, depending on other ChartView + properties that affect it's layout. If you need to know the actual plotting area used at any + given time, you can check ChartView::plotArea instead. +*/ + +/*! + \qmlproperty rect ChartView::plotArea + The area on the ChartView that is used for drawing series. This is the ChartView rect without the + margins. + \sa ChartView::minimumMargins +*/ + +/*! + \qmlproperty Margins ChartView::margins + The minimum margins allowed between the outer bounds and the plotArea of the ChartView. Margins + area of ChartView is used for drawing title, axes and legend. +*/ + +/*! + \qmlproperty bool ChartView::localizeNumbers + \since QtCharts 2.0 + When \c{true}, all generated numbers appearing in various series and axis labels will be + localized using the default QLocale of the application, which defaults to the system locale. + When \c{false}, the "C" locale is always used. + Defaults to \c{false}. + + \sa locale +*/ + +/*! + \qmlproperty locale ChartView::locale + \since QtCharts 2.0 + Sets the locale used to format various chart labels when localizeNumbers is \c{true}. + This also determines the locale used to format DateTimeAxis labels regardless of + localizeNumbers property. + Defaults to application default locale at the time the chart is constructed. + + \sa localizeNumbers +*/ + +/*! + \qmlmethod AbstractSeries ChartView::series(int index) + Returns the series with \a index on the chart. This allows you to loop through the series of a chart together with + the count property of the chart. +*/ + +/*! + \qmlmethod AbstractSeries ChartView::series(string name) + Returns the first series on the chart with \a name. If there is no series with that name, returns null. +*/ + +/*! + \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name, AbstractAxis axisX, AbstractAxis axisY) + Creates a series object of \a type to the chart with name \a name, optional axis \a axisX and + optional axis \a axisY. For example: + \code + // lineSeries is a LineSeries object that has already been added to the ChartView; re-use it's axes + var myAxisX = chartView.axisX(lineSeries); + var myAxisY = chartView.axisY(lineSeries); + var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series", myAxisX, myAxisY); + \endcode +*/ + +/*! + \qmlmethod ChartView::removeSeries(AbstractSeries series) + Removes the \a series from the chart. The series object is also destroyed. +*/ + +/*! + \qmlmethod ChartView::removeAllSeries() + Removes all series from the chart. All the series objects are also destroyed. +*/ + +/*! + \qmlmethod Axis ChartView::axisX(AbstractSeries series) + The x-axis of the series. +*/ + +/*! + \qmlmethod Axis ChartView::axisY(AbstractSeries series) + The y-axis of the series. +*/ + +/*! + \qmlmethod ChartView::zoomY(real factor) + Zooms in by \a factor on the center of the chart. +*/ + +/*! + \qmlmethod ChartView::scrollLeft(real pixels) + Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation. +*/ + +/*! + \qmlmethod ChartView::scrollRight(real pixels) + Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation. +*/ + +/*! + \qmlmethod ChartView::scrollUp(real pixels) + Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation. +*/ + +/*! + \qmlmethod ChartView::scrollDown(real pixels) + Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation. +*/ + +/*! + \qmlsignal ChartView::onPlotAreaChanged(rect plotArea) + The plot area of the chart has changed. This may happen for example, if you modify minimumMargins + or if you resize the chart, or if you modify font size related properties of the legend or chart + title. +*/ + +/*! + \qmlsignal ChartView::seriesAdded(AbstractSeries series) + The \a series has been added to the chart. +*/ + +/*! + \qmlsignal ChartView::seriesRemoved(AbstractSeries series) + The \a series has been removed from the chart. Please note that \a series is no longer a valid + object after the signal handler has completed. +*/ + +DeclarativeChart::DeclarativeChart(QQuickItem *parent) + : QQuickPaintedItem(parent) +{ + initChart(QChart::ChartTypeCartesian); +} + +DeclarativeChart::DeclarativeChart(QChart::ChartType type, QQuickItem *parent) + : QQuickPaintedItem(parent) +{ + initChart(type); +} + +void DeclarativeChart::initChart(QChart::ChartType type) +{ + m_currentSceneImage = 0; + m_guiThreadId = QThread::currentThreadId(); + m_paintThreadId = 0; + m_updatePending = false; + + if (type == QChart::ChartTypePolar) + m_chart = new QPolarChart(); + else + m_chart = new QChart(); + + m_scene = new QGraphicsScene(this); + m_scene->addItem(m_chart); + + setAntialiasing(QQuickItem::antialiasing()); + connect(m_scene, SIGNAL(changed(QList<QRectF>)), this, SLOT(sceneChanged(QList<QRectF>))); + connect(this, SIGNAL(antialiasingChanged(bool)), this, SLOT(handleAntialiasingChanged(bool))); + + setAcceptedMouseButtons(Qt::AllButtons); + setAcceptHoverEvents(true); + + m_margins = new DeclarativeMargins(this); + m_margins->setTop(m_chart->margins().top()); + m_margins->setLeft(m_chart->margins().left()); + m_margins->setRight(m_chart->margins().right()); + m_margins->setBottom(m_chart->margins().bottom()); + connect(m_margins, SIGNAL(topChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); + connect(m_margins, SIGNAL(bottomChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); + connect(m_margins, SIGNAL(leftChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); + connect(m_margins, SIGNAL(rightChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); + connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesAdded(QAbstractSeries*)), this, SLOT(handleSeriesAdded(QAbstractSeries*))); + connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), this, SIGNAL(seriesRemoved(QAbstractSeries*))); +} + +void DeclarativeChart::handleSeriesAdded(QAbstractSeries *series) +{ + emit seriesAdded(series); +} + +void DeclarativeChart::changeMinimumMargins(int top, int bottom, int left, int right) +{ + m_chart->setMargins(QMargins(left, top, right, bottom)); + emit minimumMarginsChanged(); + emit plotAreaChanged(m_chart->plotArea()); +} + +DeclarativeChart::~DeclarativeChart() +{ + delete m_chart; + m_sceneImageLock.lock(); + delete m_currentSceneImage; + m_currentSceneImage = 0; + m_sceneImageLock.unlock(); +} + +void DeclarativeChart::childEvent(QChildEvent *event) +{ + if (event->type() == QEvent::ChildAdded) { + if (qobject_cast<QAbstractSeries *>(event->child())) { + m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); + } + } +} + +void DeclarativeChart::componentComplete() +{ + foreach (QObject *child, children()) { + if (qobject_cast<QAbstractSeries *>(child)) { + // Add series to the chart + QAbstractSeries *series = qobject_cast<QAbstractSeries *>(child); + m_chart->addSeries(series); + + // Connect to axis changed signals (unless this is a pie series) + if (!qobject_cast<DeclarativePieSeries *>(series)) { + connect(series, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); + connect(series, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SLOT(handleAxisXTopSet(QAbstractAxis*))); + connect(series, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); + connect(series, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SLOT(handleAxisYRightSet(QAbstractAxis*))); + } + + initializeAxes(series); + } + } + + QQuickItem::componentComplete(); +} + +void DeclarativeChart::handleAxisXSet(QAbstractAxis *axis) +{ + QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); + if (axis && s) { + if (!m_chart->axes(Qt::Horizontal).contains(axis)) + m_chart->setAxisX(axis, s); + if (!s->attachedAxes().contains(axis)) + s->attachAxis(axis); + } else { + qWarning() << "Trying to set axisX to null."; + } +} + +void DeclarativeChart::handleAxisXTopSet(QAbstractAxis *axis) +{ + QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); + if (axis && s) { + if (!m_chart->axes(Qt::Horizontal).contains(axis)) { + QList<QAbstractAxis *> oldAxes = m_chart->axes(Qt::Horizontal, s); + foreach (QAbstractAxis* a, oldAxes) { + m_chart->removeAxis(a); + delete a; + } + m_chart->addAxis(axis, Qt::AlignTop); + } + if (!s->attachedAxes().contains(axis)) + s->attachAxis(axis); + } else { + qWarning() << "Trying to set axisXTop to null."; + } +} + +void DeclarativeChart::handleAxisYSet(QAbstractAxis *axis) +{ + QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); + if (axis && s) { + if (!m_chart->axes(Qt::Vertical).contains(axis)) + m_chart->setAxisY(axis, s); + if (!s->attachedAxes().contains(axis)) + s->attachAxis(axis); + } else { + qWarning() << "Trying to set axisY to null."; + } +} + +void DeclarativeChart::handleAxisYRightSet(QAbstractAxis *axis) +{ + QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); + if (axis && s) { + if (!m_chart->axes(Qt::Vertical).contains(axis)) { + QList<QAbstractAxis *> oldAxes = m_chart->axes((Qt::Vertical), s); + foreach (QAbstractAxis* a, oldAxes) { + m_chart->removeAxis(a); + delete a; + } + m_chart->addAxis(axis, Qt::AlignRight); + } + if (!s->attachedAxes().contains(axis)) + s->attachAxis(axis); + } else { + qWarning() << "Trying to set axisYRight to null."; + } +} + +void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) +{ + if (newGeometry.isValid()) { + if (newGeometry.width() > 0 && newGeometry.height() > 0) { + m_chart->resize(newGeometry.width(), newGeometry.height()); + } + } + QQuickItem::geometryChanged(newGeometry, oldGeometry); + + // It would be better to trigger the plotAreaChanged signal from QChart::plotAreaChanged or + // similar. Since that kind of a signal is not clearly needed in the C++ API the work-around is + // to implement it here for the QML API purposes. + emit plotAreaChanged(m_chart->plotArea()); +} + +void DeclarativeChart::sceneChanged(QList<QRectF> region) +{ + Q_UNUSED(region); + + if (m_guiThreadId == m_paintThreadId) { + // Rendering in gui thread, no need for shenannigans, just update + update(); + } else { + // Multi-threaded rendering, need to ensure scene is actually rendered in gui thread + if (!m_updatePending) { + m_updatePending = true; + // Do async render to avoid some unnecessary renders. + QTimer::singleShot(0, this, SLOT(renderScene())); + } + } +} + +void DeclarativeChart::renderScene() +{ + m_updatePending = false; + m_sceneImageLock.lock(); + delete m_currentSceneImage; + m_currentSceneImage = new QImage(m_chart->size().toSize(), QImage::Format_ARGB32); + m_currentSceneImage->fill(Qt::transparent); + QPainter painter(m_currentSceneImage); + if (antialiasing()) + painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform); + QRect renderRect(QPoint(0, 0), m_chart->size().toSize()); + m_scene->render(&painter, renderRect, renderRect); + m_sceneImageLock.unlock(); + + update(); +} + +void DeclarativeChart::paint(QPainter *painter) +{ + if (!m_paintThreadId) { + m_paintThreadId = QThread::currentThreadId(); + if (m_guiThreadId == m_paintThreadId) { + // No need for scene image in single threaded rendering, so delete + // the one that got made by default before the rendering type was + // detected. + delete m_currentSceneImage; + m_currentSceneImage = 0; + } + } + + if (m_guiThreadId == m_paintThreadId) { + QRectF renderRect(QPointF(0, 0), m_chart->size()); + m_scene->render(painter, renderRect, renderRect); + } else { + m_sceneImageLock.lock(); + if (m_currentSceneImage) { + QRect imageRect(QPoint(0, 0), m_currentSceneImage->size()); + QRect itemRect(QPoint(0, 0), QSize(width(), height())); + painter->drawImage(itemRect, *m_currentSceneImage, imageRect); + } + m_sceneImageLock.unlock(); + } +} + +void DeclarativeChart::mousePressEvent(QMouseEvent *event) +{ + m_mousePressScenePoint = event->pos(); + m_mousePressScreenPoint = event->globalPos(); + m_lastMouseMoveScenePoint = m_mousePressScenePoint; + m_lastMouseMoveScreenPoint = m_mousePressScreenPoint; + m_mousePressButton = event->button(); + m_mousePressButtons = event->buttons(); + + QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMousePress); + mouseEvent.setWidget(0); + mouseEvent.setButtonDownScenePos(m_mousePressButton, m_mousePressScenePoint); + mouseEvent.setButtonDownScreenPos(m_mousePressButton, m_mousePressScreenPoint); + mouseEvent.setScenePos(m_mousePressScenePoint); + mouseEvent.setScreenPos(m_mousePressScreenPoint); + mouseEvent.setLastScenePos(m_lastMouseMoveScenePoint); + mouseEvent.setLastScreenPos(m_lastMouseMoveScreenPoint); + mouseEvent.setButtons(m_mousePressButtons); + mouseEvent.setButton(m_mousePressButton); + mouseEvent.setModifiers(event->modifiers()); + mouseEvent.setAccepted(false); + + QApplication::sendEvent(m_scene, &mouseEvent); +} + +void DeclarativeChart::mouseReleaseEvent(QMouseEvent *event) +{ + QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseRelease); + mouseEvent.setWidget(0); + mouseEvent.setButtonDownScenePos(m_mousePressButton, m_mousePressScenePoint); + mouseEvent.setButtonDownScreenPos(m_mousePressButton, m_mousePressScreenPoint); + mouseEvent.setScenePos(event->pos()); + mouseEvent.setScreenPos(event->globalPos()); + mouseEvent.setLastScenePos(m_lastMouseMoveScenePoint); + mouseEvent.setLastScreenPos(m_lastMouseMoveScreenPoint); + mouseEvent.setButtons(event->buttons()); + mouseEvent.setButton(event->button()); + mouseEvent.setModifiers(event->modifiers()); + mouseEvent.setAccepted(false); + + QApplication::sendEvent(m_scene, &mouseEvent); + + m_mousePressButtons = event->buttons(); + m_mousePressButton = Qt::NoButton; +} + +void DeclarativeChart::hoverMoveEvent(QHoverEvent *event) +{ + // Convert hover move to mouse move, since we don't seem to get actual mouse move events. + // QGraphicsScene generates hover events from mouse move events, so we don't need + // to pass hover events there. + QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseMove); + mouseEvent.setWidget(0); + mouseEvent.setButtonDownScenePos(m_mousePressButton, m_mousePressScenePoint); + mouseEvent.setButtonDownScreenPos(m_mousePressButton, m_mousePressScreenPoint); + mouseEvent.setScenePos(event->pos()); + // Hover events do not have global pos in them, and the screen position doesn't seem to + // matter anyway in this use case, so just pass event pos instead of trying to + // calculate the real screen position. + mouseEvent.setScreenPos(event->pos()); + mouseEvent.setLastScenePos(m_lastMouseMoveScenePoint); + mouseEvent.setLastScreenPos(m_lastMouseMoveScreenPoint); + mouseEvent.setButtons(m_mousePressButtons); + mouseEvent.setButton(m_mousePressButton); + mouseEvent.setModifiers(event->modifiers()); + m_lastMouseMoveScenePoint = mouseEvent.scenePos(); + m_lastMouseMoveScreenPoint = mouseEvent.screenPos(); + mouseEvent.setAccepted(false); + + QApplication::sendEvent(m_scene, &mouseEvent); +} + +void DeclarativeChart::handleAntialiasingChanged(bool enable) +{ + setAntialiasing(enable); +} + +void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) +{ + QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; + if (chartTheme != m_chart->theme()) + m_chart->setTheme(chartTheme); +} + +DeclarativeChart::Theme DeclarativeChart::theme() +{ + return (DeclarativeChart::Theme) m_chart->theme(); +} + +void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) +{ + QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations; + if (animationOptions != m_chart->animationOptions()) + m_chart->setAnimationOptions(animationOptions); +} + +DeclarativeChart::Animation DeclarativeChart::animationOptions() +{ + if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) + return DeclarativeChart::AllAnimations; + else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) + return DeclarativeChart::GridAxisAnimations; + else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) + return DeclarativeChart::SeriesAnimations; + else + return DeclarativeChart::NoAnimation; +} + +void DeclarativeChart::setTitle(QString title) +{ + if (title != m_chart->title()) + m_chart->setTitle(title); +} +QString DeclarativeChart::title() +{ + return m_chart->title(); +} + +QAbstractAxis *DeclarativeChart::axisX(QAbstractSeries *series) +{ + QList<QAbstractAxis *> axes = m_chart->axes(Qt::Horizontal, series); + if (axes.count()) + return axes[0]; + return 0; +} + +QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series) +{ + QList<QAbstractAxis *> axes = m_chart->axes(Qt::Vertical, series); + if (axes.count()) + return axes[0]; + return 0; +} + +QLegend *DeclarativeChart::legend() +{ + return m_chart->legend(); +} + +void DeclarativeChart::setTitleColor(QColor color) +{ + QBrush b = m_chart->titleBrush(); + if (color != b.color()) { + b.setColor(color); + m_chart->setTitleBrush(b); + emit titleColorChanged(color); + } +} + +QFont DeclarativeChart::titleFont() const +{ + return m_chart->titleFont(); +} + +void DeclarativeChart::setTitleFont(const QFont &font) +{ + m_chart->setTitleFont(font); +} + +QColor DeclarativeChart::titleColor() +{ + return m_chart->titleBrush().color(); +} + +void DeclarativeChart::setBackgroundColor(QColor color) +{ + QBrush b = m_chart->backgroundBrush(); + if (b.style() != Qt::SolidPattern || color != b.color()) { + b.setStyle(Qt::SolidPattern); + b.setColor(color); + m_chart->setBackgroundBrush(b); + emit backgroundColorChanged(); + } +} + +QColor DeclarativeChart::backgroundColor() +{ + return m_chart->backgroundBrush().color(); +} + +void QtCharts::DeclarativeChart::setPlotAreaColor(QColor color) +{ + QBrush b = m_chart->plotAreaBackgroundBrush(); + if (b.style() != Qt::SolidPattern || color != b.color()) { + b.setStyle(Qt::SolidPattern); + b.setColor(color); + m_chart->setPlotAreaBackgroundBrush(b); + m_chart->setPlotAreaBackgroundVisible(true); + emit plotAreaColorChanged(); + } +} + +QColor QtCharts::DeclarativeChart::plotAreaColor() +{ + return m_chart->plotAreaBackgroundBrush().color(); +} + +void DeclarativeChart::setLocalizeNumbers(bool localize) +{ + if (m_chart->localizeNumbers() != localize) { + m_chart->setLocalizeNumbers(localize); + emit localizeNumbersChanged(); + } +} + +bool DeclarativeChart::localizeNumbers() const +{ + return m_chart->localizeNumbers(); +} + +void QtCharts::DeclarativeChart::setLocale(const QLocale &locale) +{ + if (m_chart->locale() != locale) { + m_chart->setLocale(locale); + emit localeChanged(); + } +} + +QLocale QtCharts::DeclarativeChart::locale() const +{ + return m_chart->locale(); +} + +int DeclarativeChart::count() +{ + return m_chart->series().count(); +} + +void DeclarativeChart::setDropShadowEnabled(bool enabled) +{ + if (enabled != m_chart->isDropShadowEnabled()) { + m_chart->setDropShadowEnabled(enabled); + dropShadowEnabledChanged(enabled); + } +} + +bool DeclarativeChart::dropShadowEnabled() +{ + return m_chart->isDropShadowEnabled(); +} + +qreal DeclarativeChart::backgroundRoundness() const +{ + return m_chart->backgroundRoundness(); +} + +void DeclarativeChart::setBackgroundRoundness(qreal diameter) +{ + if (m_chart->backgroundRoundness() != diameter) { + m_chart->setBackgroundRoundness(diameter); + emit backgroundRoundnessChanged(diameter); + } +} + +qreal DeclarativeChart::topMargin() +{ + qWarning() << "ChartView.topMargin is deprecated. Use margins instead."; + return m_chart->margins().top(); +} + +qreal DeclarativeChart::bottomMargin() +{ + qWarning() << "ChartView.bottomMargin is deprecated. Use margins instead."; + return m_chart->margins().bottom(); +} + +qreal DeclarativeChart::leftMargin() +{ + qWarning() << "ChartView.leftMargin is deprecated. Use margins instead."; + return m_chart->margins().left(); +} + +qreal DeclarativeChart::rightMargin() +{ + qWarning() << "ChartView.rightMargin is deprecated. Use margins instead."; + return m_chart->margins().right(); +} + +void DeclarativeChart::zoom(qreal factor) +{ + m_chart->zoom(factor); +} + +void DeclarativeChart::scrollLeft(qreal pixels) +{ + m_chart->scroll(-pixels, 0); +} + +void DeclarativeChart::scrollRight(qreal pixels) +{ + m_chart->scroll(pixels, 0); +} + +void DeclarativeChart::scrollUp(qreal pixels) +{ + m_chart->scroll(0, pixels); +} + +void DeclarativeChart::scrollDown(qreal pixels) +{ + m_chart->scroll(0, -pixels); +} + +QQmlListProperty<QAbstractAxis> DeclarativeChart::axes() +{ + return QQmlListProperty<QAbstractAxis>(this, 0, + &DeclarativeChart::axesAppendFunc, + &DeclarativeChart::axesCountFunc, + &DeclarativeChart::axesAtFunc, + &DeclarativeChart::axesClearFunc); +} + +void DeclarativeChart::axesAppendFunc(QQmlListProperty<QAbstractAxis> *list, QAbstractAxis *element) +{ + // Empty implementation + Q_UNUSED(list); + Q_UNUSED(element); +} + +int DeclarativeChart::axesCountFunc(QQmlListProperty<QAbstractAxis> *list) +{ + if (qobject_cast<DeclarativeChart *>(list->object)) { + DeclarativeChart *chart = qobject_cast<DeclarativeChart *>(list->object); + return chart->m_chart->axes(Qt::Horizontal | Qt::Vertical).count(); + } + return 0; +} + +QAbstractAxis *DeclarativeChart::axesAtFunc(QQmlListProperty<QAbstractAxis> *list, int index) +{ + if (qobject_cast<DeclarativeChart *>(list->object)) { + DeclarativeChart *chart = qobject_cast<DeclarativeChart *>(list->object); + QList<QAbstractAxis *> axes = chart->m_chart->axes(Qt::Horizontal | Qt::Vertical, chart->m_chart->series()[0]); + return axes.at(index); + } + return 0; +} + +void DeclarativeChart::axesClearFunc(QQmlListProperty<QAbstractAxis> *list) +{ + // Empty implementation + Q_UNUSED(list); +} + + +QAbstractSeries *DeclarativeChart::series(int index) +{ + if (index < m_chart->series().count()) { + return m_chart->series().at(index); + } + return 0; +} + +QAbstractSeries *DeclarativeChart::series(QString seriesName) +{ + foreach (QAbstractSeries *series, m_chart->series()) { + if (series->name() == seriesName) + return series; + } + return 0; +} + +QAbstractSeries *DeclarativeChart::createSeries(int type, QString name, QAbstractAxis *axisX, QAbstractAxis *axisY) +{ + QAbstractSeries *series = 0; + + switch (type) { + case DeclarativeChart::SeriesTypeLine: + series = new DeclarativeLineSeries(); + break; + case DeclarativeChart::SeriesTypeArea: { + DeclarativeAreaSeries *area = new DeclarativeAreaSeries(); + area->setUpperSeries(new DeclarativeLineSeries()); + series = area; + break; + } + case DeclarativeChart::SeriesTypeStackedBar: + series = new DeclarativeStackedBarSeries(); + break; + case DeclarativeChart::SeriesTypePercentBar: + series = new DeclarativePercentBarSeries(); + break; + case DeclarativeChart::SeriesTypeBar: + series = new DeclarativeBarSeries(); + break; + case DeclarativeChart::SeriesTypeHorizontalBar: + series = new DeclarativeHorizontalBarSeries(); + break; + case DeclarativeChart::SeriesTypeHorizontalPercentBar: + series = new DeclarativeHorizontalPercentBarSeries(); + break; + case DeclarativeChart::SeriesTypeHorizontalStackedBar: + series = new DeclarativeHorizontalStackedBarSeries(); + break; + case DeclarativeChart::SeriesTypeBoxPlot: + series = new DeclarativeBoxPlotSeries(); + break; + case DeclarativeChart::SeriesTypePie: + series = new DeclarativePieSeries(); + break; + case DeclarativeChart::SeriesTypeScatter: + series = new DeclarativeScatterSeries(); + break; + case DeclarativeChart::SeriesTypeSpline: + series = new DeclarativeSplineSeries(); + break; + default: + qWarning() << "Illegal series type"; + } + + if (series) { + // Connect to axis changed signals (unless this is a pie series) + if (!qobject_cast<DeclarativePieSeries *>(series)) { + connect(series, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); + connect(series, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); + connect(series, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); + connect(series, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SLOT(handleAxisYRightSet(QAbstractAxis*))); + } + + series->setName(name); + m_chart->addSeries(series); + + if (axisX) + setAxisX(axisX, series); + if (axisY) + setAxisY(axisY, series); + + if (series->attachedAxes().count() < 2) + initializeAxes(series); + } + + return series; +} + +void DeclarativeChart::removeSeries(QAbstractSeries *series) +{ + if (series) + m_chart->removeSeries(series); + else + qWarning("removeSeries: cannot remove null"); +} + +void DeclarativeChart::setAxisX(QAbstractAxis *axis, QAbstractSeries *series) +{ + if (axis) + m_chart->setAxisX(axis, series); +} + +void DeclarativeChart::setAxisY(QAbstractAxis *axis, QAbstractSeries *series) +{ + if (axis) + m_chart->setAxisY(axis, series); +} + +void DeclarativeChart::createDefaultAxes() +{ + qWarning() << "ChartView.createDefaultAxes() is deprecated. Axes are created automatically."; +} + +QAbstractAxis *DeclarativeChart::defaultAxis(Qt::Orientation orientation, QAbstractSeries *series) +{ + if (!series) { + qWarning() << "No axis type defined for null series"; + return 0; + } + + foreach (QAbstractAxis *existingAxis, m_chart->axes(orientation)) { + if (existingAxis->type() == series->d_ptr->defaultAxisType(orientation)) + return existingAxis; + } + + switch (series->d_ptr->defaultAxisType(orientation)) { + case QAbstractAxis::AxisTypeValue: + return new QValueAxis(this); + case QAbstractAxis::AxisTypeBarCategory: + return new QBarCategoryAxis(this); + case QAbstractAxis::AxisTypeCategory: + return new QCategoryAxis(this); +#ifndef QT_ON_ARM + case QAbstractAxis::AxisTypeDateTime: + return new QDateTimeAxis(this); +#endif + case QAbstractAxis::AxisTypeLogValue: + return new QLogValueAxis(this); + default: + // assume AxisTypeNoAxis + return 0; + } +} + +void DeclarativeChart::initializeAxes(QAbstractSeries *series) +{ + if (qobject_cast<DeclarativeLineSeries *>(series)) + doInitializeAxes(series, qobject_cast<DeclarativeLineSeries *>(series)->m_axes); + else if (qobject_cast<DeclarativeScatterSeries *>(series)) + doInitializeAxes(series, qobject_cast<DeclarativeScatterSeries *>(series)->m_axes); + else if (qobject_cast<DeclarativeSplineSeries *>(series)) + doInitializeAxes(series, qobject_cast<DeclarativeSplineSeries *>(series)->m_axes); + else if (qobject_cast<DeclarativeAreaSeries *>(series)) + doInitializeAxes(series, qobject_cast<DeclarativeAreaSeries *>(series)->m_axes); + else if (qobject_cast<DeclarativeBarSeries *>(series)) + doInitializeAxes(series, qobject_cast<DeclarativeBarSeries *>(series)->m_axes); + else if (qobject_cast<DeclarativeStackedBarSeries *>(series)) + doInitializeAxes(series, qobject_cast<DeclarativeStackedBarSeries *>(series)->m_axes); + else if (qobject_cast<DeclarativePercentBarSeries *>(series)) + doInitializeAxes(series, qobject_cast<DeclarativePercentBarSeries *>(series)->m_axes); + else if (qobject_cast<DeclarativeHorizontalBarSeries *>(series)) + doInitializeAxes(series, qobject_cast<DeclarativeHorizontalBarSeries *>(series)->m_axes); + else if (qobject_cast<DeclarativeHorizontalStackedBarSeries *>(series)) + doInitializeAxes(series, qobject_cast<DeclarativeHorizontalStackedBarSeries *>(series)->m_axes); + else if (qobject_cast<DeclarativeHorizontalPercentBarSeries *>(series)) + doInitializeAxes(series, qobject_cast<DeclarativeHorizontalPercentBarSeries *>(series)->m_axes); + else if (qobject_cast<DeclarativeBoxPlotSeries *>(series)) + doInitializeAxes(series, qobject_cast<DeclarativeBoxPlotSeries *>(series)->m_axes); + // else: do nothing +} + +void DeclarativeChart::doInitializeAxes(QAbstractSeries *series, DeclarativeAxes *axes) +{ + // Initialize axis X + if (axes->axisX()) + axes->emitAxisXChanged(); + else if (axes->axisXTop()) + axes->emitAxisXTopChanged(); + else + axes->setAxisX(defaultAxis(Qt::Horizontal, series)); + + // Initialize axis Y + if (axes->axisY()) + axes->emitAxisYChanged(); + else if (axes->axisYRight()) + axes->emitAxisYRightChanged(); + else + axes->setAxisY(defaultAxis(Qt::Vertical, series)); +} + +#include "moc_declarativechart.cpp" + +QT_CHARTS_END_NAMESPACE diff --git a/src/chartsqml2/declarativechart.h b/src/chartsqml2/declarativechart.h new file mode 100644 index 00000000..b9936eb6 --- /dev/null +++ b/src/chartsqml2/declarativechart.h @@ -0,0 +1,231 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise 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$ +** +****************************************************************************/ + +#ifndef DECLARATIVECHART_H +#define DECLARATIVECHART_H + +#include <QtCore/QtGlobal> +#include <QtQuick/QQuickItem> +#include <QtQuick/QQuickPaintedItem> +#include <QtWidgets/QGraphicsScene> +#include <QtCore/QMutex> + +#include "qchart.h" +#include <QtCore/QLocale> + +QT_CHARTS_BEGIN_NAMESPACE + +class DeclarativeMargins; +class Domain; +class DeclarativeAxes; + +class DeclarativeChart : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(Theme theme READ theme WRITE setTheme) + Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions) + Q_PROPERTY(QString title READ title WRITE setTitle) + Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont) + Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged) + Q_PROPERTY(QLegend *legend READ legend CONSTANT) + Q_PROPERTY(int count READ count) + Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) + Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged) + Q_PROPERTY(qreal backgroundRoundness READ backgroundRoundness WRITE setBackgroundRoundness NOTIFY backgroundRoundnessChanged REVISION 3) + Q_PROPERTY(qreal topMargin READ topMargin) + Q_PROPERTY(qreal bottomMargin READ bottomMargin) + Q_PROPERTY(qreal leftMargin READ leftMargin) + Q_PROPERTY(qreal rightMargin READ rightMargin) + Q_PROPERTY(DeclarativeMargins *minimumMargins READ minimumMargins NOTIFY minimumMarginsChanged REVISION 1) + Q_PROPERTY(DeclarativeMargins *margins READ margins NOTIFY marginsChanged REVISION 2) + Q_PROPERTY(QRectF plotArea READ plotArea NOTIFY plotAreaChanged REVISION 1) + Q_PROPERTY(QColor plotAreaColor READ plotAreaColor WRITE setPlotAreaColor NOTIFY plotAreaColorChanged REVISION 3) + Q_PROPERTY(QQmlListProperty<QAbstractAxis> axes READ axes REVISION 2) + Q_PROPERTY(bool localizeNumbers READ localizeNumbers WRITE setLocalizeNumbers NOTIFY localizeNumbersChanged REVISION 4) + Q_PROPERTY(QLocale locale READ locale WRITE setLocale NOTIFY localeChanged REVISION 4) + Q_ENUMS(Animation) + Q_ENUMS(Theme) + Q_ENUMS(SeriesType) + +public: + // duplicating enums from QChart to make the QML api namings 1-to-1 with the C++ api + enum Theme { + ChartThemeLight = 0, + ChartThemeBlueCerulean, + ChartThemeDark, + ChartThemeBrownSand, + ChartThemeBlueNcs, + ChartThemeHighContrast, + ChartThemeBlueIcy, + ChartThemeQt + }; + + enum Animation { + NoAnimation = 0x0, + GridAxisAnimations = 0x1, + SeriesAnimations = 0x2, + AllAnimations = 0x3 + }; + + enum SeriesType { + SeriesTypeLine, + SeriesTypeArea, + SeriesTypeBar, + SeriesTypeStackedBar, + SeriesTypePercentBar, + SeriesTypeBoxPlot, + SeriesTypePie, + SeriesTypeScatter, + SeriesTypeSpline, + SeriesTypeHorizontalBar, + SeriesTypeHorizontalStackedBar, + SeriesTypeHorizontalPercentBar + }; + +public: + DeclarativeChart(QQuickItem *parent = 0); + ~DeclarativeChart(); + +public: // From parent classes + void childEvent(QChildEvent *event); + void componentComplete(); + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); + void paint(QPainter *painter); +protected: + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void hoverMoveEvent(QHoverEvent *event); +private Q_SLOTS: + void handleAntialiasingChanged(bool enable); + void sceneChanged(QList<QRectF> region); + void renderScene(); + +public: + void setTheme(DeclarativeChart::Theme theme); + DeclarativeChart::Theme theme(); + void setAnimationOptions(DeclarativeChart::Animation animations); + DeclarativeChart::Animation animationOptions(); + void setTitle(QString title); + QString title(); + QLegend *legend(); + QFont titleFont() const; + void setTitleFont(const QFont &font); + void setTitleColor(QColor color); + QColor titleColor(); + void setBackgroundColor(QColor color); + QColor backgroundColor(); + Q_REVISION(3) void setPlotAreaColor(QColor color); + Q_REVISION(3) QColor plotAreaColor(); + Q_REVISION(4) void setLocalizeNumbers(bool localize); + Q_REVISION(4) bool localizeNumbers() const; + Q_REVISION(4) void setLocale(const QLocale &locale); + Q_REVISION(4) QLocale locale() const; + + int count(); + void setDropShadowEnabled(bool enabled); + bool dropShadowEnabled(); + Q_REVISION(3) qreal backgroundRoundness() const; + Q_REVISION(3) void setBackgroundRoundness(qreal diameter); + + // Margins & plotArea + qreal topMargin(); + qreal bottomMargin(); + qreal leftMargin(); + qreal rightMargin(); + DeclarativeMargins *minimumMargins() { return m_margins; } + Q_REVISION(2) DeclarativeMargins *margins() { return m_margins; } + QRectF plotArea() { return m_chart->plotArea(); } + + // Axis handling + QAbstractAxis *defaultAxis(Qt::Orientation orientation, QAbstractSeries *series); + void initializeAxes(QAbstractSeries *series); + void doInitializeAxes(QAbstractSeries *series, DeclarativeAxes *axes); + QQmlListProperty<QAbstractAxis> axes(); + static void axesAppendFunc(QQmlListProperty<QAbstractAxis> *list, QAbstractAxis *element); + static int axesCountFunc(QQmlListProperty<QAbstractAxis> *list); + static QAbstractAxis *axesAtFunc(QQmlListProperty<QAbstractAxis> *list, int index); + static void axesClearFunc(QQmlListProperty<QAbstractAxis> *list); + +public: + Q_INVOKABLE QAbstractSeries *series(int index); + Q_INVOKABLE QAbstractSeries *series(QString seriesName); + Q_INVOKABLE QAbstractSeries *createSeries(int type, QString name = "", QAbstractAxis *axisX = 0, QAbstractAxis *axisY = 0); + Q_INVOKABLE void removeSeries(QAbstractSeries *series); + Q_INVOKABLE void removeAllSeries() { m_chart->removeAllSeries(); } + Q_INVOKABLE void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = 0); + Q_INVOKABLE void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = 0); + Q_INVOKABLE void createDefaultAxes(); + Q_INVOKABLE QAbstractAxis *axisX(QAbstractSeries *series = 0); + Q_INVOKABLE QAbstractAxis *axisY(QAbstractSeries *series = 0); + Q_INVOKABLE void zoom(qreal factor); + Q_INVOKABLE void scrollLeft(qreal pixels); + Q_INVOKABLE void scrollRight(qreal pixels); + Q_INVOKABLE void scrollUp(qreal pixels); + Q_INVOKABLE void scrollDown(qreal pixels); + +Q_SIGNALS: + void axisLabelsChanged(); + void titleColorChanged(QColor color); + void backgroundColorChanged(); + void dropShadowEnabledChanged(bool enabled); + void minimumMarginsChanged(); + Q_REVISION(2) void marginsChanged(); + void plotAreaChanged(QRectF plotArea); + void seriesAdded(QAbstractSeries *series); + void seriesRemoved(QAbstractSeries *series); + Q_REVISION(3) void plotAreaColorChanged(); + Q_REVISION(3) void backgroundRoundnessChanged(qreal diameter); + Q_REVISION(4) void localizeNumbersChanged(); + Q_REVISION(4) void localeChanged(); + +private Q_SLOTS: + void changeMinimumMargins(int top, int bottom, int left, int right); + void handleAxisXSet(QAbstractAxis *axis); + void handleAxisYSet(QAbstractAxis *axis); + void handleAxisXTopSet(QAbstractAxis *axis); + void handleAxisYRightSet(QAbstractAxis *axis); + void handleSeriesAdded(QAbstractSeries *series); + +protected: + explicit DeclarativeChart(QChart::ChartType type, QQuickItem *parent); + +private: + void initChart(QChart::ChartType type); + // Extending QChart with DeclarativeChart is not possible because QObject does not support + // multi inheritance, so we now have a QChart as a member instead + QChart *m_chart; + QGraphicsScene *m_scene; + QPointF m_mousePressScenePoint; + QPoint m_mousePressScreenPoint; + QPointF m_lastMouseMoveScenePoint; + QPoint m_lastMouseMoveScreenPoint; + Qt::MouseButton m_mousePressButton; + Qt::MouseButtons m_mousePressButtons; + QMutex m_sceneImageLock; + QImage *m_currentSceneImage; + bool m_updatePending; + Qt::HANDLE m_paintThreadId; + Qt::HANDLE m_guiThreadId; + DeclarativeMargins *m_margins; +}; + +QT_CHARTS_END_NAMESPACE + +#endif // DECLARATIVECHART_H diff --git a/src/chartsqml2/declarativelineseries.cpp b/src/chartsqml2/declarativelineseries.cpp new file mode 100644 index 00000000..70914a91 --- /dev/null +++ b/src/chartsqml2/declarativelineseries.cpp @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise 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$ +** +****************************************************************************/ + +#include "declarativelineseries.h" + +QT_CHARTS_BEGIN_NAMESPACE + +DeclarativeLineSeries::DeclarativeLineSeries(QObject *parent) : + QLineSeries(parent), + 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*))); + connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisAngularChanged(QAbstractAxis*))); + connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisRadialChanged(QAbstractAxis*))); + connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int))); + connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int))); +} + +void DeclarativeLineSeries::handleCountChanged(int index) +{ + Q_UNUSED(index) + emit countChanged(points().count()); +} + +qreal DeclarativeLineSeries::width() const +{ + return pen().widthF(); +} + +void DeclarativeLineSeries::setWidth(qreal width) +{ + if (width != pen().widthF()) { + QPen p = pen(); + p.setWidthF(width); + setPen(p); + emit widthChanged(width); + } +} + +Qt::PenStyle DeclarativeLineSeries::style() const +{ + return pen().style(); +} + +void DeclarativeLineSeries::setStyle(Qt::PenStyle style) +{ + if (style != pen().style()) { + QPen p = pen(); + p.setStyle(style); + setPen(p); + emit styleChanged(style); + } +} + +Qt::PenCapStyle DeclarativeLineSeries::capStyle() const +{ + return pen().capStyle(); +} + +void DeclarativeLineSeries::setCapStyle(Qt::PenCapStyle capStyle) +{ + if (capStyle != pen().capStyle()) { + QPen p = pen(); + p.setCapStyle(capStyle); + setPen(p); + emit capStyleChanged(capStyle); + } +} + +QQmlListProperty<QObject> DeclarativeLineSeries::declarativeChildren() +{ + return QQmlListProperty<QObject>(this, 0, &appendDeclarativeChildren ,0,0,0); +} + +void DeclarativeLineSeries::appendDeclarativeChildren(QQmlListProperty<QObject> *list, QObject *element) +{ + Q_UNUSED(list) + Q_UNUSED(element) + // Empty implementation, children are parsed in componentComplete +} + +#include "moc_declarativelineseries.cpp" + +QT_CHARTS_END_NAMESPACE diff --git a/src/chartsqml2/declarativelineseries.h b/src/chartsqml2/declarativelineseries.h new file mode 100644 index 00000000..aab115c1 --- /dev/null +++ b/src/chartsqml2/declarativelineseries.h @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise 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$ +** +****************************************************************************/ + +#ifndef DECLARATIVELINESERIES_H +#define DECLARATIVELINESERIES_H + +#include "qlineseries.h" +#include "declarativexyseries.h" +#include "declarativeaxes.h" + +#include <QtQml/QQmlListProperty> +#include <QtQml/QQmlParserStatus> + +QT_CHARTS_BEGIN_NAMESPACE + +class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries, public QQmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QQmlParserStatus) + Q_PROPERTY(int count READ count NOTIFY countChanged) + Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) + Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) + Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2) + Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2) + Q_PROPERTY(QAbstractAxis *axisAngular READ axisAngular WRITE setAxisAngular NOTIFY axisAngularChanged REVISION 3) + Q_PROPERTY(QAbstractAxis *axisRadial READ axisRadial WRITE setAxisRadial NOTIFY axisRadialChanged REVISION 3) + Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged REVISION 1) + Q_PROPERTY(Qt::PenStyle style READ style WRITE setStyle NOTIFY styleChanged REVISION 1) + Q_PROPERTY(Qt::PenCapStyle capStyle READ capStyle WRITE setCapStyle NOTIFY capStyleChanged REVISION 1) + Q_PROPERTY(QQmlListProperty<QObject> declarativeChildren READ declarativeChildren) + Q_CLASSINFO("DefaultProperty", "declarativeChildren") + +public: + explicit DeclarativeLineSeries(QObject *parent = 0); + QXYSeries *xySeries() { return this; } + QAbstractAxis *axisX() { return m_axes->axisX(); } + void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } + QAbstractAxis *axisY() { return m_axes->axisY(); } + void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); } + Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); } + Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); } + Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); } + Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); } + Q_REVISION(3) QAbstractAxis *axisAngular() { return m_axes->axisX(); } + Q_REVISION(3) void setAxisAngular(QAbstractAxis *axis) { m_axes->setAxisX(axis); } + Q_REVISION(3) QAbstractAxis *axisRadial() { return m_axes->axisY(); } + Q_REVISION(3) void setAxisRadial(QAbstractAxis *axis) { m_axes->setAxisY(axis); } + qreal width() const; + void setWidth(qreal width); + Qt::PenStyle style() const; + void setStyle(Qt::PenStyle style); + Qt::PenCapStyle capStyle() const; + void setCapStyle(Qt::PenCapStyle capStyle); + QQmlListProperty<QObject> declarativeChildren(); + +public: // from QDeclarativeParserStatus + void classBegin() { DeclarativeXySeries::classBegin(); } + void componentComplete() { DeclarativeXySeries::componentComplete(); } + +public: + Q_INVOKABLE void append(qreal x, qreal y) { DeclarativeXySeries::append(x, y); } + Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { DeclarativeXySeries::replace(oldX, oldY, newX, newY); } + Q_REVISION(3) Q_INVOKABLE void replace(int index, qreal newX, qreal newY) { DeclarativeXySeries::replace(index, newX, newY); } + Q_INVOKABLE void remove(qreal x, qreal y) { DeclarativeXySeries::remove(x, y); } + Q_REVISION(3) Q_INVOKABLE void remove(int index) { DeclarativeXySeries::remove(index); } + Q_INVOKABLE void insert(int index, qreal x, qreal y) { DeclarativeXySeries::insert(index, x, y); } + Q_INVOKABLE void clear() { DeclarativeXySeries::clear(); } + Q_INVOKABLE QPointF at(int index) { return DeclarativeXySeries::at(index); } + +Q_SIGNALS: + void countChanged(int count); + Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); + Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); + Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis); + Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis); + Q_REVISION(3) void axisAngularChanged(QAbstractAxis *axis); + Q_REVISION(3) void axisRadialChanged(QAbstractAxis *axis); + Q_REVISION(1) void widthChanged(qreal width); + Q_REVISION(1) void styleChanged(Qt::PenStyle style); + Q_REVISION(1) void capStyleChanged(Qt::PenCapStyle capStyle); + +public Q_SLOTS: + static void appendDeclarativeChildren(QQmlListProperty<QObject> *list, QObject *element); + void handleCountChanged(int index); + +public: + DeclarativeAxes *m_axes; +}; + +QT_CHARTS_END_NAMESPACE + +#endif // DECLARATIVELINESERIES_H diff --git a/src/chartsqml2/declarativemargins.cpp b/src/chartsqml2/declarativemargins.cpp new file mode 100644 index 00000000..f9a913c8 --- /dev/null +++ b/src/chartsqml2/declarativemargins.cpp @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise 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$ +** +****************************************************************************/ + +#include "declarativemargins.h" +#include <QDataStream> +#include <QDebug> + +QT_CHARTS_BEGIN_NAMESPACE + +/*! + \qmltype Margins + \inqmlmodule QtCharts + + Uncreatable type that is used to define top, bottom, left and right margins. +*/ + +/*! + \qmlproperty int Margins::top + The top margin. +*/ + +/*! + \qmlproperty int Margins::bottom + The bottom margin. +*/ + +/*! + \qmlproperty int Margins::left + The left margin. +*/ + +/*! + \qmlproperty int Margins::right + The right margin. +*/ + +DeclarativeMargins::DeclarativeMargins(QObject *parent) : + QObject(parent) +{ + QMargins::setTop(0); + QMargins::setBottom(0); + QMargins::setLeft(0); + QMargins::setRight(0); +} + +void DeclarativeMargins::setTop(int top) +{ + if (top < 0) { + qWarning() << "Cannot set top margin to a negative value:" << top; + } else { + if (top != QMargins::top()) { + QMargins::setTop(top); + emit topChanged(QMargins::top(), QMargins::bottom(), QMargins::left(), QMargins::right()); + } + } +} + +void DeclarativeMargins::setBottom(int bottom) +{ + if (bottom < 0) { + qWarning() << "Cannot set bottom margin to a negative value:" << bottom; + } else { + if (bottom != QMargins::bottom()) { + QMargins::setBottom(bottom); + emit bottomChanged(QMargins::top(), QMargins::bottom(), QMargins::left(), QMargins::right()); + } + } +} + +void DeclarativeMargins::setLeft(int left) +{ + if (left < 0) { + qWarning() << "Cannot set left margin to a negative value:" << left; + } else { + if (left != QMargins::left()) { + QMargins::setLeft(left); + emit leftChanged(QMargins::top(), QMargins::bottom(), QMargins::left(), QMargins::right()); + } + } +} + +void DeclarativeMargins::setRight(int right) +{ + if (right < 0) { + qWarning() << "Cannot set left margin to a negative value:" << right; + } else { + if (right != QMargins::right()) { + QMargins::setRight(right); + emit rightChanged(QMargins::top(), QMargins::bottom(), QMargins::left(), QMargins::right()); + } + } +} + +#include "moc_declarativemargins.cpp" + +QT_CHARTS_END_NAMESPACE diff --git a/src/chartsqml2/declarativemargins.h b/src/chartsqml2/declarativemargins.h new file mode 100644 index 00000000..3a346ce7 --- /dev/null +++ b/src/chartsqml2/declarativemargins.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise 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$ +** +****************************************************************************/ + +#ifndef DECLARATIVE_MARGINS_H +#define DECLARATIVE_MARGINS_H + +#include "qchartglobal.h" +#include <QObject> +#include <QMargins> + +QT_CHARTS_BEGIN_NAMESPACE + +class DeclarativeMargins : public QObject, public QMargins +{ + Q_OBJECT + Q_PROPERTY(int top READ top WRITE setTop NOTIFY topChanged) + Q_PROPERTY(int bottom READ bottom WRITE setBottom NOTIFY bottomChanged) + Q_PROPERTY(int left READ left WRITE setLeft NOTIFY leftChanged) + Q_PROPERTY(int right READ right WRITE setRight NOTIFY rightChanged) + +public: + explicit DeclarativeMargins(QObject *parent = 0); + void setTop(int top); + void setBottom(int bottom); + void setLeft(int left); + void setRight(int right); + +Q_SIGNALS: + void topChanged(int top, int bottom, int left, int right); + void bottomChanged(int top, int bottom, int left, int right); + void leftChanged(int top, int bottom, int left, int right); + void rightChanged(int top, int bottom, int left, int right); +}; + +QT_CHARTS_END_NAMESPACE + +#endif // DECLARATIVE_MARGINS_H diff --git a/src/chartsqml2/declarativepieseries.cpp b/src/chartsqml2/declarativepieseries.cpp new file mode 100644 index 00000000..619d7c32 --- /dev/null +++ b/src/chartsqml2/declarativepieseries.cpp @@ -0,0 +1,154 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise 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$ +** +****************************************************************************/ + +#include "declarativepieseries.h" +#include "qpieslice.h" +#include "qvpiemodelmapper.h" +#include "qhpiemodelmapper.h" + +QT_CHARTS_BEGIN_NAMESPACE + +DeclarativePieSlice::DeclarativePieSlice(QObject *parent) + : QPieSlice(parent) +{ + connect(this, SIGNAL(brushChanged()), this, SLOT(handleBrushChanged())); +} + +QString DeclarativePieSlice::brushFilename() const +{ + return m_brushFilename; +} + +void DeclarativePieSlice::setBrushFilename(const QString &brushFilename) +{ + QImage brushImage(brushFilename); + if (QPieSlice::brush().textureImage() != brushImage) { + QBrush brush = QPieSlice::brush(); + brush.setTextureImage(brushImage); + QPieSlice::setBrush(brush); + m_brushFilename = brushFilename; + m_brushImage = brushImage; + emit brushFilenameChanged(brushFilename); + } +} + +void DeclarativePieSlice::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() && QPieSlice::brush().textureImage() != m_brushImage) { + m_brushFilename.clear(); + emit brushFilenameChanged(QString("")); + } +} + +// Declarative pie series ========================================================================= +DeclarativePieSeries::DeclarativePieSeries(QQuickItem *parent) : + QPieSeries(parent) +{ + connect(this, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleAdded(QList<QPieSlice*>))); + connect(this, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleRemoved(QList<QPieSlice*>))); +} + +void DeclarativePieSeries::classBegin() +{ +} + +void DeclarativePieSeries::componentComplete() +{ + foreach (QObject *child, children()) { + if (qobject_cast<QPieSlice *>(child)) { + QPieSeries::append(qobject_cast<QPieSlice *>(child)); + } else if (qobject_cast<QVPieModelMapper *>(child)) { + QVPieModelMapper *mapper = qobject_cast<QVPieModelMapper *>(child); + mapper->setSeries(this); + } else if (qobject_cast<QHPieModelMapper *>(child)) { + QHPieModelMapper *mapper = qobject_cast<QHPieModelMapper *>(child); + mapper->setSeries(this); + } + } +} + +QQmlListProperty<QObject> DeclarativePieSeries::seriesChildren() +{ + return QQmlListProperty<QObject>(this, 0, &DeclarativePieSeries::appendSeriesChildren ,0,0,0); +} + +void DeclarativePieSeries::appendSeriesChildren(QQmlListProperty<QObject> * list, QObject *element) +{ + // Empty implementation; the children are parsed in componentComplete instead + Q_UNUSED(list); + Q_UNUSED(element); +} + +QPieSlice *DeclarativePieSeries::at(int index) +{ + QList<QPieSlice *> sliceList = slices(); + if (index >= 0 && index < sliceList.count()) + return sliceList[index]; + + return 0; +} + +QPieSlice *DeclarativePieSeries::find(QString label) +{ + foreach (QPieSlice *slice, slices()) { + if (slice->label() == label) + return slice; + } + return 0; +} + +DeclarativePieSlice *DeclarativePieSeries::append(QString label, qreal value) +{ + DeclarativePieSlice *slice = new DeclarativePieSlice(this); + slice->setLabel(label); + slice->setValue(value); + if (QPieSeries::append(slice)) + return slice; + delete slice; + return 0; +} + +bool DeclarativePieSeries::remove(QPieSlice *slice) +{ + return QPieSeries::remove(slice); +} + +void DeclarativePieSeries::clear() +{ + QPieSeries::clear(); +} + +void DeclarativePieSeries::handleAdded(QList<QPieSlice *> slices) +{ + foreach (QPieSlice *slice, slices) + emit sliceAdded(slice); +} + +void DeclarativePieSeries::handleRemoved(QList<QPieSlice *> slices) +{ + foreach (QPieSlice *slice, slices) + emit sliceRemoved(slice); +} + +#include "moc_declarativepieseries.cpp" + +QT_CHARTS_END_NAMESPACE diff --git a/src/chartsqml2/declarativepieseries.h b/src/chartsqml2/declarativepieseries.h new file mode 100644 index 00000000..2fbddb67 --- /dev/null +++ b/src/chartsqml2/declarativepieseries.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise 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$ +** +****************************************************************************/ + +#ifndef DECLARATIVEPIESERIES_H +#define DECLARATIVEPIESERIES_H + +#include "qpieseries.h" +#include "qpieslice.h" + +#include <QtQuick/QQuickItem> +#include <QtQml/QQmlParserStatus> + +QT_CHARTS_BEGIN_NAMESPACE + +class DeclarativePieSlice : public QPieSlice +{ + Q_OBJECT + Q_PROPERTY(QString brushFilename READ brushFilename WRITE setBrushFilename NOTIFY brushFilenameChanged) + +public: + explicit DeclarativePieSlice(QObject *parent = 0); + QString brushFilename() const; + void setBrushFilename(const QString &brushFilename); + +Q_SIGNALS: + void brushFilenameChanged(const QString &brushFilename); + +private Q_SLOTS: + void handleBrushChanged(); + +private: + QString m_brushFilename; + QImage m_brushImage; +}; + +class DeclarativePieSeries : public QPieSeries, public QQmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QQmlParserStatus) + Q_PROPERTY(QQmlListProperty<QObject> seriesChildren READ seriesChildren) + Q_CLASSINFO("DefaultProperty", "seriesChildren") + +public: + explicit DeclarativePieSeries(QQuickItem *parent = 0); + QQmlListProperty<QObject> seriesChildren(); + Q_INVOKABLE QPieSlice *at(int index); + Q_INVOKABLE QPieSlice *find(QString label); + Q_INVOKABLE DeclarativePieSlice *append(QString label, qreal value); + Q_INVOKABLE bool remove(QPieSlice *slice); + Q_INVOKABLE void clear(); + +public: + void classBegin(); + void componentComplete(); + +Q_SIGNALS: + void sliceAdded(QPieSlice *slice); + void sliceRemoved(QPieSlice *slice); + +public Q_SLOTS: + static void appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element); + void handleAdded(QList<QPieSlice *> slices); + void handleRemoved(QList<QPieSlice *> slices); +}; + +QT_CHARTS_END_NAMESPACE + +#endif // DECLARATIVEPIESERIES_H diff --git a/src/chartsqml2/declarativepolarchart.cpp b/src/chartsqml2/declarativepolarchart.cpp new file mode 100644 index 00000000..0d5328cd --- /dev/null +++ b/src/chartsqml2/declarativepolarchart.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise 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$ +** +****************************************************************************/ + +#include "declarativepolarchart.h" +#include "qchart.h" + +QT_CHARTS_BEGIN_NAMESPACE + +/*! + \qmltype PolarChartView + \instantiates DeclarativePolarChart + \inqmlmodule QtCharts + + PolarChartView element is the parent that is responsible for showing different chart series + types in a polar chart. + + Polar charts support line, spline, area, and scatter series, and all axis types + supported by those series. + + \note When setting ticks to an angular ValueAxis, keep in mind that the first and last tick + are co-located at 0/360 degree angle. + + \note If the angular distance between two consecutive points in a series is more than 180 + degrees, any line connecting the two points becomes meaningless, so choose the axis ranges + accordingly when displaying line, spline, or area series. + + The following QML shows how to create a polar chart with two series: + \snippet qmlpolarchart/qml/qmlpolarchart/View1.qml 1 + + \beginfloatleft + \image examples_qmlpolarchart1.png + \endfloat + \clearfloat +*/ + +DeclarativePolarChart::DeclarativePolarChart(QQuickItem *parent) + : DeclarativeChart(QChart::ChartTypePolar, parent) +{ +} + +DeclarativePolarChart::~DeclarativePolarChart() +{ +} + +#include "moc_declarativepolarchart.cpp" + +QT_CHARTS_END_NAMESPACE diff --git a/src/chartsqml2/declarativepolarchart.h b/src/chartsqml2/declarativepolarchart.h new file mode 100644 index 00000000..80b80b3e --- /dev/null +++ b/src/chartsqml2/declarativepolarchart.h @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise 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$ +** +****************************************************************************/ + +#ifndef DECLARATIVEPOLARCHART_H +#define DECLARATIVEPOLARCHART_H + +#include <QtCore/QtGlobal> +#include <QtQuick/QQuickItem> + +#include "declarativechart.h" + +QT_CHARTS_BEGIN_NAMESPACE + +class DeclarativePolarChart : public DeclarativeChart +{ + Q_OBJECT +public: + DeclarativePolarChart(QQuickItem *parent = 0); + ~DeclarativePolarChart(); +}; + +QT_CHARTS_END_NAMESPACE + +#endif // DECLARATIVEPOLARCHART_H diff --git a/src/chartsqml2/declarativescatterseries.cpp b/src/chartsqml2/declarativescatterseries.cpp new file mode 100644 index 00000000..557d36ea --- /dev/null +++ b/src/chartsqml2/declarativescatterseries.cpp @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise 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$ +** +****************************************************************************/ + +#include "declarativescatterseries.h" + +QT_CHARTS_BEGIN_NAMESPACE + +DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) : + QScatterSeries(parent), + 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*))); + connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisAngularChanged(QAbstractAxis*))); + connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisRadialChanged(QAbstractAxis*))); + connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int))); + connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int))); + connect(this, SIGNAL(brushChanged()), this, SLOT(handleBrushChanged())); +} + +void DeclarativeScatterSeries::handleCountChanged(int index) +{ + Q_UNUSED(index) + emit countChanged(QScatterSeries::count()); +} + +qreal DeclarativeScatterSeries::borderWidth() const +{ + return pen().widthF(); +} + +void DeclarativeScatterSeries::setBorderWidth(qreal width) +{ + if (width != pen().widthF()) { + QPen p = pen(); + p.setWidthF(width); + setPen(p); + emit borderWidthChanged(width); + } +} + +QQmlListProperty<QObject> DeclarativeScatterSeries::declarativeChildren() +{ + return QQmlListProperty<QObject>(this, 0, &appendDeclarativeChildren ,0,0,0); +} + +void DeclarativeScatterSeries::appendDeclarativeChildren(QQmlListProperty<QObject> *list, QObject *element) +{ + Q_UNUSED(list) + Q_UNUSED(element) + // Empty implementation, children are parsed in componentComplete +} + +QString DeclarativeScatterSeries::brushFilename() const +{ + return m_brushFilename; +} + +void DeclarativeScatterSeries::setBrushFilename(const QString &brushFilename) +{ + QImage brushImage(brushFilename); + if (QScatterSeries::brush().textureImage() != brushImage) { + QBrush brush = QScatterSeries::brush(); + brush.setTextureImage(brushImage); + QScatterSeries::setBrush(brush); + m_brushFilename = brushFilename; + m_brushImage = brushImage; + emit brushFilenameChanged(brushFilename); + } +} + +void DeclarativeScatterSeries::setBrush(const QBrush &brush) +{ + QScatterSeries::setBrush(brush); + emit brushChanged(); +} + +QBrush DeclarativeScatterSeries::brush() const +{ + return QScatterSeries::brush(); +} + +void DeclarativeScatterSeries::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() && QScatterSeries::brush().textureImage() != m_brushImage) { + m_brushFilename.clear(); + emit brushFilenameChanged(QString("")); + } +} + +#include "moc_declarativescatterseries.cpp" + +QT_CHARTS_END_NAMESPACE diff --git a/src/chartsqml2/declarativescatterseries.h b/src/chartsqml2/declarativescatterseries.h new file mode 100644 index 00000000..9745e06b --- /dev/null +++ b/src/chartsqml2/declarativescatterseries.h @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise 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$ +** +****************************************************************************/ + +#ifndef DECLARATIVESCATTERSERIES_H +#define DECLARATIVESCATTERSERIES_H + +#include "qscatterseries.h" +#include "declarativexyseries.h" +#include "declarativeaxes.h" + +#include <QtQml/QQmlListProperty> +#include <QtQml/QQmlParserStatus> + +QT_CHARTS_BEGIN_NAMESPACE + +class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeries, public QQmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QQmlParserStatus) + Q_PROPERTY(int count READ count NOTIFY countChanged) + Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) + Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) + Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2) + Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2) + Q_PROPERTY(QAbstractAxis *axisAngular READ axisAngular WRITE setAxisAngular NOTIFY axisAngularChanged REVISION 3) + Q_PROPERTY(QAbstractAxis *axisRadial READ axisRadial WRITE setAxisRadial NOTIFY axisRadialChanged REVISION 3) + Q_PROPERTY(qreal borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged REVISION 1) + Q_PROPERTY(QQmlListProperty<QObject> declarativeChildren READ declarativeChildren) + Q_PROPERTY(QString brushFilename READ brushFilename WRITE setBrushFilename NOTIFY brushFilenameChanged REVISION 4) + Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged REVISION 4) + Q_CLASSINFO("DefaultProperty", "declarativeChildren") + +public: + explicit DeclarativeScatterSeries(QObject *parent = 0); + QXYSeries *xySeries() { return this; } + QAbstractAxis *axisX() { return m_axes->axisX(); } + void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } + QAbstractAxis *axisY() { return m_axes->axisY(); } + void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); } + Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); } + Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); } + Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); } + Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); } + Q_REVISION(3) QAbstractAxis *axisAngular() { return m_axes->axisX(); } + Q_REVISION(3) void setAxisAngular(QAbstractAxis *axis) { m_axes->setAxisX(axis); } + Q_REVISION(3) QAbstractAxis *axisRadial() { return m_axes->axisY(); } + Q_REVISION(3) void setAxisRadial(QAbstractAxis *axis) { m_axes->setAxisY(axis); } + qreal borderWidth() const; + void setBorderWidth(qreal borderWidth); + QQmlListProperty<QObject> declarativeChildren(); + QString brushFilename() const; + void setBrushFilename(const QString &brushFilename); + void setBrush(const QBrush &brush); + QBrush brush() const; + +public: // from QDeclarativeParserStatus + void classBegin() { DeclarativeXySeries::classBegin(); } + void componentComplete() { DeclarativeXySeries::componentComplete(); } + +public: + Q_INVOKABLE void append(qreal x, qreal y) { DeclarativeXySeries::append(x, y); } + Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { DeclarativeXySeries::replace(oldX, oldY, newX, newY); } + Q_REVISION(3) Q_INVOKABLE void replace(int index, qreal newX, qreal newY) { DeclarativeXySeries::replace(index, newX, newY); } + Q_INVOKABLE void remove(qreal x, qreal y) { DeclarativeXySeries::remove(x, y); } + Q_REVISION(3) Q_INVOKABLE void remove(int index) { DeclarativeXySeries::remove(index); } + Q_INVOKABLE void insert(int index, qreal x, qreal y) { DeclarativeXySeries::insert(index, x, y); } + Q_INVOKABLE void clear() { DeclarativeXySeries::clear(); } + Q_INVOKABLE QPointF at(int index) { return DeclarativeXySeries::at(index); } + +Q_SIGNALS: + void countChanged(int count); + Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); + Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); + Q_REVISION(1) void borderWidthChanged(qreal width); + Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis); + Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis); + Q_REVISION(3) void axisAngularChanged(QAbstractAxis *axis); + Q_REVISION(3) void axisRadialChanged(QAbstractAxis *axis); + Q_REVISION(4) void brushFilenameChanged(const QString &brushFilename); + Q_REVISION(4) void brushChanged(); + +public Q_SLOTS: + static void appendDeclarativeChildren(QQmlListProperty<QObject> *list, QObject *element); + void handleCountChanged(int index); + +private Q_SLOTS: + void handleBrushChanged(); + +public: + DeclarativeAxes *m_axes; + +private: + QString m_brushFilename; + QImage m_brushImage; +}; + +QT_CHARTS_END_NAMESPACE + +#endif // DECLARATIVESCATTERSERIES_H diff --git a/src/chartsqml2/declarativesplineseries.cpp b/src/chartsqml2/declarativesplineseries.cpp new file mode 100644 index 00000000..8c882288 --- /dev/null +++ b/src/chartsqml2/declarativesplineseries.cpp @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise 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$ +** +****************************************************************************/ + +#include "declarativesplineseries.h" + +QT_CHARTS_BEGIN_NAMESPACE + +DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) : + QSplineSeries(parent), + 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*))); + connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisAngularChanged(QAbstractAxis*))); + connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisRadialChanged(QAbstractAxis*))); + connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int))); + connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int))); +} + +void DeclarativeSplineSeries::handleCountChanged(int index) +{ + Q_UNUSED(index) + emit countChanged(points().count()); +} + +qreal DeclarativeSplineSeries::width() const +{ + return pen().widthF(); +} + +void DeclarativeSplineSeries::setWidth(qreal width) +{ + if (width != pen().widthF()) { + QPen p = pen(); + p.setWidthF(width); + setPen(p); + emit widthChanged(width); + } +} + +Qt::PenStyle DeclarativeSplineSeries::style() const +{ + return pen().style(); +} + +void DeclarativeSplineSeries::setStyle(Qt::PenStyle style) +{ + if (style != pen().style()) { + QPen p = pen(); + p.setStyle(style); + setPen(p); + emit styleChanged(style); + } +} + +Qt::PenCapStyle DeclarativeSplineSeries::capStyle() const +{ + return pen().capStyle(); +} + +void DeclarativeSplineSeries::setCapStyle(Qt::PenCapStyle capStyle) +{ + if (capStyle != pen().capStyle()) { + QPen p = pen(); + p.setCapStyle(capStyle); + setPen(p); + emit capStyleChanged(capStyle); + } +} + +QQmlListProperty<QObject> DeclarativeSplineSeries::declarativeChildren() +{ + return QQmlListProperty<QObject>(this, 0, &appendDeclarativeChildren ,0,0,0); +} + +void DeclarativeSplineSeries::appendDeclarativeChildren(QQmlListProperty<QObject> *list, QObject *element) +{ + Q_UNUSED(list) + Q_UNUSED(element) + // Empty implementation, children are parsed in componentComplete +} + +#include "moc_declarativesplineseries.cpp" + +QT_CHARTS_END_NAMESPACE diff --git a/src/chartsqml2/declarativesplineseries.h b/src/chartsqml2/declarativesplineseries.h new file mode 100644 index 00000000..369206f0 --- /dev/null +++ b/src/chartsqml2/declarativesplineseries.h @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise 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$ +** +****************************************************************************/ + +#ifndef DECLARATIVESPLINESERIES_H +#define DECLARATIVESPLINESERIES_H + +#include "qsplineseries.h" +#include "declarativexyseries.h" +#include "declarativeaxes.h" + +#include <QtQml/QQmlListProperty> +#include <QtQml/QQmlParserStatus> + +QT_CHARTS_BEGIN_NAMESPACE + +class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries, public QQmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QQmlParserStatus) + Q_PROPERTY(int count READ count NOTIFY countChanged) + Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) + Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) + Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2) + Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2) + Q_PROPERTY(QAbstractAxis *axisAngular READ axisAngular WRITE setAxisAngular NOTIFY axisAngularChanged REVISION 3) + Q_PROPERTY(QAbstractAxis *axisRadial READ axisRadial WRITE setAxisRadial NOTIFY axisRadialChanged REVISION 3) + Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged REVISION 1) + Q_PROPERTY(Qt::PenStyle style READ style WRITE setStyle NOTIFY styleChanged REVISION 1) + Q_PROPERTY(Qt::PenCapStyle capStyle READ capStyle WRITE setCapStyle NOTIFY capStyleChanged REVISION 1) + Q_PROPERTY(QQmlListProperty<QObject> declarativeChildren READ declarativeChildren) + Q_CLASSINFO("DefaultProperty", "declarativeChildren") + +public: + explicit DeclarativeSplineSeries(QObject *parent = 0); + QXYSeries *xySeries() { return this; } + QAbstractAxis *axisX() { return m_axes->axisX(); } + void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } + QAbstractAxis *axisY() { return m_axes->axisY(); } + void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); } + Q_REVISION(2) QAbstractAxis *axisXTop() { return m_axes->axisXTop(); } + Q_REVISION(2) void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); } + Q_REVISION(2) QAbstractAxis *axisYRight() { return m_axes->axisYRight(); } + Q_REVISION(2) void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); } + Q_REVISION(3) QAbstractAxis *axisAngular() { return m_axes->axisX(); } + Q_REVISION(3) void setAxisAngular(QAbstractAxis *axis) { m_axes->setAxisX(axis); } + Q_REVISION(3) QAbstractAxis *axisRadial() { return m_axes->axisY(); } + Q_REVISION(3) void setAxisRadial(QAbstractAxis *axis) { m_axes->setAxisY(axis); } + qreal width() const; + void setWidth(qreal width); + Qt::PenStyle style() const; + void setStyle(Qt::PenStyle style); + Qt::PenCapStyle capStyle() const; + void setCapStyle(Qt::PenCapStyle capStyle); + QQmlListProperty<QObject> declarativeChildren(); + +public: // from QDeclarativeParserStatus + void classBegin() { DeclarativeXySeries::classBegin(); } + void componentComplete() { DeclarativeXySeries::componentComplete(); } + +public: + Q_INVOKABLE void append(qreal x, qreal y) { DeclarativeXySeries::append(x, y); } + Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { DeclarativeXySeries::replace(oldX, oldY, newX, newY); } + Q_REVISION(3) Q_INVOKABLE void replace(int index, qreal newX, qreal newY) { DeclarativeXySeries::replace(index, newX, newY); } + Q_INVOKABLE void remove(qreal x, qreal y) { DeclarativeXySeries::remove(x, y); } + Q_REVISION(3) Q_INVOKABLE void remove(int index) { DeclarativeXySeries::remove(index); } + Q_INVOKABLE void insert(int index, qreal x, qreal y) { DeclarativeXySeries::insert(index, x, y); } + Q_INVOKABLE void clear() { DeclarativeXySeries::clear(); } + Q_INVOKABLE QPointF at(int index) { return DeclarativeXySeries::at(index); } + +Q_SIGNALS: + void countChanged(int count); + Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); + Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); + Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis); + Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis); + Q_REVISION(3) void axisAngularChanged(QAbstractAxis *axis); + Q_REVISION(3) void axisRadialChanged(QAbstractAxis *axis); + Q_REVISION(1) void widthChanged(qreal width); + Q_REVISION(1) void styleChanged(Qt::PenStyle style); + Q_REVISION(1) void capStyleChanged(Qt::PenCapStyle capStyle); + +public Q_SLOTS: + static void appendDeclarativeChildren(QQmlListProperty<QObject> *list, QObject *element); + void handleCountChanged(int index); + +public: + DeclarativeAxes *m_axes; +}; + +QT_CHARTS_END_NAMESPACE + +#endif // DECLARATIVESPLINESERIES_H diff --git a/src/chartsqml2/declarativexypoint.cpp b/src/chartsqml2/declarativexypoint.cpp new file mode 100644 index 00000000..8df506e9 --- /dev/null +++ b/src/chartsqml2/declarativexypoint.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise 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$ +** +****************************************************************************/ + +#include "declarativexypoint.h" +#include <QDataStream> + +QT_CHARTS_BEGIN_NAMESPACE + +/*! + \qmltype XYPoint + \inqmlmodule QtCharts + + XYPoint is a convenience element for initializing XY-series with static coordinate data. To + manipulate an XY-series dynamically, use it's data manipulation functions instead. + \sa LineSeries, AreaSeries, ScatterSeries, SplineSeries +*/ + +/*! + \qmlproperty real XYPoint::x + The x-coordinate of the point. +*/ + +/*! + \qmlproperty real XYPoint::y + The y-coordinate of the point. +*/ + +DeclarativeXYPoint::DeclarativeXYPoint(QObject *parent) : + QObject(parent) +{ + setX(0.0); + setY(0.0); +} + +#include "moc_declarativexypoint.cpp" + +QT_CHARTS_END_NAMESPACE diff --git a/src/chartsqml2/declarativexypoint.h b/src/chartsqml2/declarativexypoint.h new file mode 100644 index 00000000..578b4b99 --- /dev/null +++ b/src/chartsqml2/declarativexypoint.h @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise 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$ +** +****************************************************************************/ + +#ifndef DECLARATIVE_XY_POINT_H +#define DECLARATIVE_XY_POINT_H + +#include "qchartglobal.h" +#include <QObject> +#include <QPointF> + +QT_CHARTS_BEGIN_NAMESPACE + +class DeclarativeXYPoint : public QObject, public QPointF +{ + Q_OBJECT + Q_PROPERTY(qreal x READ x WRITE setX) + Q_PROPERTY(qreal y READ y WRITE setY) + +public: + explicit DeclarativeXYPoint(QObject *parent = 0); +}; + +QT_CHARTS_END_NAMESPACE + +#endif // DECLARATIVE_XY_POINT_H diff --git a/src/chartsqml2/declarativexyseries.cpp b/src/chartsqml2/declarativexyseries.cpp new file mode 100644 index 00000000..55fb31d9 --- /dev/null +++ b/src/chartsqml2/declarativexyseries.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise 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$ +** +****************************************************************************/ + + +#include "declarativexyseries.h" +#include "declarativexypoint.h" +#include "qvxymodelmapper.h" +#include "qhxymodelmapper.h" + +QT_CHARTS_BEGIN_NAMESPACE + +DeclarativeXySeries::DeclarativeXySeries() +{ +} + +DeclarativeXySeries::~DeclarativeXySeries() +{ +} + +void DeclarativeXySeries::classBegin() +{ +} + +void DeclarativeXySeries::componentComplete() +{ + QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); + Q_ASSERT(series); + + foreach (QObject *child, series->children()) { + if (qobject_cast<DeclarativeXYPoint *>(child)) { + DeclarativeXYPoint *point = qobject_cast<DeclarativeXYPoint *>(child); + series->append(point->x(), point->y()); + } else if (qobject_cast<QVXYModelMapper *>(child)) { + QVXYModelMapper *mapper = qobject_cast<QVXYModelMapper *>(child); + mapper->setSeries(series); + } else if (qobject_cast<QHXYModelMapper *>(child)) { + QHXYModelMapper *mapper = qobject_cast<QHXYModelMapper *>(child); + mapper->setSeries(series); + } + } +} + +void DeclarativeXySeries::append(qreal x, qreal y) +{ + QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); + Q_ASSERT(series); + series->append(x, y); +} + +void DeclarativeXySeries::replace(qreal oldX, qreal oldY, qreal newX, qreal newY) +{ + QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); + Q_ASSERT(series); + series->replace(oldX, oldY, newX, newY); +} + +void DeclarativeXySeries::replace(int index, qreal newX, qreal newY) +{ + QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); + Q_ASSERT(series); + series->replace(index, newX, newY); +} + +void DeclarativeXySeries::remove(qreal x, qreal y) +{ + QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); + Q_ASSERT(series); + series->remove(x, y); +} + +void DeclarativeXySeries::remove(int index) +{ + QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); + Q_ASSERT(series); + series->remove(index); +} + +void DeclarativeXySeries::insert(int index, qreal x, qreal y) +{ + QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); + Q_ASSERT(series); + series->insert(index, QPointF(x, y)); +} + +void DeclarativeXySeries::clear() +{ + QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); + Q_ASSERT(series); + series->clear(); +} + +QPointF DeclarativeXySeries::at(int index) +{ + QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); + Q_ASSERT(series); + if (index >= 0 || index < series->count()) + return series->points().at(index); + return QPointF(0, 0); +} + +QT_CHARTS_END_NAMESPACE diff --git a/src/chartsqml2/declarativexyseries.h b/src/chartsqml2/declarativexyseries.h new file mode 100644 index 00000000..237080bb --- /dev/null +++ b/src/chartsqml2/declarativexyseries.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise 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$ +** +****************************************************************************/ + +#ifndef DECLARATIVE_XY_SERIES_H +#define DECLARATIVE_XY_SERIES_H + +#include <QXYSeries> + +QT_CHARTS_BEGIN_NAMESPACE + +class QChart; +class QAbstractSeries; + +class DeclarativeXySeries +{ +public: + explicit DeclarativeXySeries(); + ~DeclarativeXySeries(); + +public: + void classBegin(); + void componentComplete(); + virtual QXYSeries *xySeries() = 0; + + void append(qreal x, qreal y); + void replace(qreal oldX, qreal oldY, qreal newX, qreal newY); + void replace(int index, qreal newX, qreal newY); + void remove(qreal x, qreal y); + void remove(int index); + void insert(int index, qreal x, qreal y); + void clear(); + QPointF at(int index); +}; + +QT_CHARTS_END_NAMESPACE + +#endif // DECLARATIVE_XY_SERIES_H diff --git a/src/chartsqml2/plugins.qmltypes b/src/chartsqml2/plugins.qmltypes new file mode 100644 index 00000000..ab15ac3d --- /dev/null +++ b/src/chartsqml2/plugins.qmltypes @@ -0,0 +1,2305 @@ +import QtQuick.tooling 1.1 + +// This file describes the plugin-supplied types contained in the library. +// It is used for QML tooling purposes only. +// +// This file was auto-generated by: +// 'qmlplugindump -nonrelocatable QtCharts 2.0' + +Module { + Component { + name: "QGraphicsObject" + defaultProperty: "children" + prototype: "QObject" + Property { name: "parent"; type: "QGraphicsObject"; isPointer: true } + Property { name: "opacity"; type: "double" } + Property { name: "enabled"; type: "bool" } + Property { name: "visible"; type: "bool" } + Property { name: "pos"; type: "QPointF" } + Property { name: "x"; type: "double" } + Property { name: "y"; type: "double" } + Property { name: "z"; type: "double" } + Property { name: "rotation"; type: "double" } + Property { name: "scale"; type: "double" } + Property { name: "transformOriginPoint"; type: "QPointF" } + Property { name: "effect"; type: "QGraphicsEffect"; isPointer: true } + Property { + name: "children" + type: "QDeclarativeListProperty<QGraphicsObject>" + isReadonly: true + } + Property { name: "width"; type: "double" } + Property { name: "height"; type: "double" } + } + Component { + name: "QGraphicsWidget" + defaultProperty: "children" + prototype: "QGraphicsObject" + Property { name: "palette"; type: "QPalette" } + Property { name: "font"; type: "QFont" } + Property { name: "layoutDirection"; type: "Qt::LayoutDirection" } + Property { name: "size"; type: "QSizeF" } + Property { name: "minimumSize"; type: "QSizeF" } + Property { name: "preferredSize"; type: "QSizeF" } + Property { name: "maximumSize"; type: "QSizeF" } + Property { name: "sizePolicy"; type: "QSizePolicy" } + Property { name: "focusPolicy"; type: "Qt::FocusPolicy" } + Property { name: "windowFlags"; type: "Qt::WindowFlags" } + Property { name: "windowTitle"; type: "string" } + Property { name: "geometry"; type: "QRectF" } + Property { name: "autoFillBackground"; type: "bool" } + Property { name: "layout"; type: "QGraphicsLayout"; isPointer: true } + Method { name: "close"; type: "bool" } + } + Component { + name: "QtCharts::DeclarativeAreaSeries" + prototype: "QtCharts::QAreaSeries" + exports: [ + "QtCharts/AreaSeries 1.0", + "QtCharts/AreaSeries 1.1", + "QtCharts/AreaSeries 1.2", + "QtCharts/AreaSeries 1.3", + "QtCharts/AreaSeries 1.4", + "QtCharts/AreaSeries 2.0" + ] + exportMetaObjectRevisions: [0, 1, 2, 3, 4, 4] + Property { name: "upperSeries"; type: "DeclarativeLineSeries"; isPointer: true } + Property { name: "lowerSeries"; type: "DeclarativeLineSeries"; isPointer: true } + Property { name: "axisX"; revision: 1; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisY"; revision: 1; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisXTop"; revision: 2; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisYRight"; revision: 2; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisAngular"; revision: 3; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisRadial"; revision: 3; type: "QAbstractAxis"; isPointer: true } + Property { name: "borderWidth"; revision: 1; type: "double" } + Property { name: "brushFilename"; revision: 4; type: "string" } + Property { name: "brush"; revision: 4; type: "QBrush" } + Signal { + name: "axisXChanged" + revision: 1 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisYChanged" + revision: 1 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "borderWidthChanged" + revision: 1 + Parameter { name: "width"; type: "double" } + } + Signal { + name: "axisXTopChanged" + revision: 2 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisYRightChanged" + revision: 2 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisAngularChanged" + revision: 3 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisRadialChanged" + revision: 3 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { name: "brushChanged"; revision: 4 } + Signal { + name: "brushFilenameChanged" + revision: 4 + Parameter { name: "brushFilename"; type: "string" } + } + } + Component { + name: "QtCharts::DeclarativeAxes" + prototype: "QObject" + exports: [ + "QtCharts/DeclarativeAxes 1.0", + "QtCharts/DeclarativeAxes 2.0" + ] + isCreatable: false + exportMetaObjectRevisions: [0, 0] + Property { name: "axisX"; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisY"; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisXTop"; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisYRight"; type: "QAbstractAxis"; isPointer: true } + Signal { + name: "axisXChanged" + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisYChanged" + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisXTopChanged" + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisYRightChanged" + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + } + Component { + name: "QtCharts::DeclarativeBarSeries" + defaultProperty: "seriesChildren" + prototype: "QtCharts::QBarSeries" + exports: [ + "QtCharts/BarSeries 1.0", + "QtCharts/BarSeries 1.1", + "QtCharts/BarSeries 1.2", + "QtCharts/BarSeries 2.0" + ] + exportMetaObjectRevisions: [0, 1, 2, 2] + Property { name: "axisX"; revision: 1; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisY"; revision: 1; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisXTop"; revision: 2; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisYRight"; revision: 2; type: "QAbstractAxis"; isPointer: true } + Property { name: "seriesChildren"; type: "QObject"; isList: true; isReadonly: true } + Signal { + name: "axisXChanged" + revision: 1 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisYChanged" + revision: 1 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisXTopChanged" + revision: 2 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisYRightChanged" + revision: 2 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Method { + name: "appendSeriesChildren" + Parameter { name: "list"; type: "QObject"; isList: true; isPointer: true } + Parameter { name: "element"; type: "QObject"; isPointer: true } + } + Method { + name: "at" + type: "DeclarativeBarSet*" + Parameter { name: "index"; type: "int" } + } + Method { + name: "append" + type: "DeclarativeBarSet*" + Parameter { name: "label"; type: "string" } + Parameter { name: "values"; type: "QVariantList" } + } + Method { + name: "insert" + type: "DeclarativeBarSet*" + Parameter { name: "index"; type: "int" } + Parameter { name: "label"; type: "string" } + Parameter { name: "values"; type: "QVariantList" } + } + Method { + name: "remove" + type: "bool" + Parameter { name: "barset"; type: "QBarSet"; isPointer: true } + } + Method { name: "clear" } + } + Component { + name: "QtCharts::DeclarativeBarSet" + prototype: "QtCharts::QBarSet" + exports: [ + "QtCharts/BarSet 1.0", + "QtCharts/BarSet 1.1", + "QtCharts/BarSet 1.4", + "QtCharts/BarSet 2.0" + ] + exportMetaObjectRevisions: [0, 0, 2, 2] + Property { name: "values"; type: "QVariantList" } + Property { name: "borderWidth"; revision: 1; type: "double" } + Property { name: "count"; type: "int"; isReadonly: true } + Property { name: "brushFilename"; revision: 2; type: "string" } + Signal { + name: "countChanged" + Parameter { name: "count"; type: "int" } + } + Signal { + name: "borderWidthChanged" + revision: 1 + Parameter { name: "width"; type: "double" } + } + Signal { + name: "brushFilenameChanged" + revision: 2 + Parameter { name: "brushFilename"; type: "string" } + } + Method { + name: "append" + Parameter { name: "value"; type: "double" } + } + Method { + name: "remove" + Parameter { name: "index"; type: "int" } + Parameter { name: "count"; type: "int" } + } + Method { + name: "remove" + Parameter { name: "index"; type: "int" } + } + Method { + name: "replace" + Parameter { name: "index"; type: "int" } + Parameter { name: "value"; type: "double" } + } + Method { + name: "at" + type: "double" + Parameter { name: "index"; type: "int" } + } + } + Component { + name: "QtCharts::DeclarativeBoxPlotSeries" + defaultProperty: "seriesChildren" + prototype: "QtCharts::QBoxPlotSeries" + exports: [ + "QtCharts/BoxPlotSeries 1.3", + "QtCharts/BoxPlotSeries 1.4", + "QtCharts/BoxPlotSeries 2.0" + ] + exportMetaObjectRevisions: [0, 1, 1] + Property { name: "axisX"; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisY"; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisXTop"; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisYRight"; type: "QAbstractAxis"; isPointer: true } + Property { name: "seriesChildren"; type: "QObject"; isList: true; isReadonly: true } + Property { name: "brushFilename"; revision: 1; type: "string" } + Signal { + name: "axisXChanged" + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisYChanged" + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisXTopChanged" + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisYRightChanged" + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "clicked" + Parameter { name: "boxset"; type: "DeclarativeBoxSet"; isPointer: true } + } + Signal { + name: "hovered" + Parameter { name: "status"; type: "bool" } + Parameter { name: "boxset"; type: "DeclarativeBoxSet"; isPointer: true } + } + Signal { + name: "brushFilenameChanged" + revision: 1 + Parameter { name: "brushFilename"; type: "string" } + } + Method { + name: "appendSeriesChildren" + Parameter { name: "list"; type: "QObject"; isList: true; isPointer: true } + Parameter { name: "element"; type: "QObject"; isPointer: true } + } + Method { + name: "onHovered" + Parameter { name: "status"; type: "bool" } + Parameter { name: "boxset"; type: "QBoxSet"; isPointer: true } + } + Method { + name: "onClicked" + Parameter { name: "boxset"; type: "QBoxSet"; isPointer: true } + } + Method { + name: "at" + type: "DeclarativeBoxSet*" + Parameter { name: "index"; type: "int" } + } + Method { + name: "append" + type: "DeclarativeBoxSet*" + Parameter { name: "label"; type: "string" } + Parameter { name: "values"; type: "QVariantList" } + } + Method { + name: "append" + Parameter { name: "box"; type: "DeclarativeBoxSet"; isPointer: true } + } + Method { + name: "insert" + type: "DeclarativeBoxSet*" + Parameter { name: "index"; type: "int" } + Parameter { name: "label"; type: "string" } + Parameter { name: "values"; type: "QVariantList" } + } + Method { + name: "remove" + type: "bool" + Parameter { name: "box"; type: "DeclarativeBoxSet"; isPointer: true } + } + Method { name: "clear" } + } + Component { + name: "QtCharts::DeclarativeBoxSet" + prototype: "QtCharts::QBoxSet" + exports: [ + "QtCharts/BoxSet 1.3", + "QtCharts/BoxSet 1.4", + "QtCharts/BoxSet 2.0" + ] + exportMetaObjectRevisions: [0, 1, 1] + Enum { + name: "ValuePositions" + values: { + "LowerExtreme": 0, + "LowerQuartile": 1, + "Median": 2, + "UpperQuartile": 3, + "UpperExtreme": 4 + } + } + Property { name: "values"; type: "QVariantList" } + Property { name: "label"; type: "string" } + Property { name: "count"; type: "int"; isReadonly: true } + Property { name: "brushFilename"; revision: 1; type: "string" } + Signal { name: "changedValues" } + Signal { + name: "changedValue" + Parameter { name: "index"; type: "int" } + } + Signal { + name: "brushFilenameChanged" + revision: 1 + Parameter { name: "brushFilename"; type: "string" } + } + Method { + name: "append" + Parameter { name: "value"; type: "double" } + } + Method { name: "clear" } + Method { + name: "at" + type: "double" + Parameter { name: "index"; type: "int" } + } + Method { + name: "setValue" + Parameter { name: "index"; type: "int" } + Parameter { name: "value"; type: "double" } + } + } + Component { + name: "QtCharts::DeclarativeCategoryAxis" + defaultProperty: "axisChildren" + prototype: "QtCharts::QCategoryAxis" + exports: ["QtCharts/CategoryAxis 1.1", "QtCharts/CategoryAxis 2.0"] + exportMetaObjectRevisions: [0, 0] + Property { name: "axisChildren"; type: "QObject"; isList: true; isReadonly: true } + Method { + name: "append" + Parameter { name: "label"; type: "string" } + Parameter { name: "categoryEndValue"; type: "double" } + } + Method { + name: "remove" + Parameter { name: "label"; type: "string" } + } + Method { + name: "replace" + Parameter { name: "oldLabel"; type: "string" } + Parameter { name: "newLabel"; type: "string" } + } + Method { + name: "appendAxisChildren" + Parameter { name: "list"; type: "QObject"; isList: true; isPointer: true } + Parameter { name: "element"; type: "QObject"; isPointer: true } + } + } + Component { + name: "QtCharts::DeclarativeCategoryRange" + prototype: "QObject" + exports: ["QtCharts/CategoryRange 1.1", "QtCharts/CategoryRange 2.0"] + exportMetaObjectRevisions: [0, 0] + Property { name: "endValue"; type: "double" } + Property { name: "label"; type: "string" } + } + Component { + name: "QtCharts::DeclarativeChart" + defaultProperty: "data" + prototype: "QQuickPaintedItem" + exports: [ + "QtCharts/ChartView 1.0", + "QtCharts/ChartView 1.1", + "QtCharts/ChartView 1.2", + "QtCharts/ChartView 1.3", + "QtCharts/ChartView 2.0" + ] + exportMetaObjectRevisions: [0, 1, 2, 3, 4] + Enum { + name: "Theme" + values: { + "ChartThemeLight": 0, + "ChartThemeBlueCerulean": 1, + "ChartThemeDark": 2, + "ChartThemeBrownSand": 3, + "ChartThemeBlueNcs": 4, + "ChartThemeHighContrast": 5, + "ChartThemeBlueIcy": 6, + "ChartThemeQt": 7 + } + } + Enum { + name: "Animation" + values: { + "NoAnimation": 0, + "GridAxisAnimations": 1, + "SeriesAnimations": 2, + "AllAnimations": 3 + } + } + Enum { + name: "SeriesType" + values: { + "SeriesTypeLine": 0, + "SeriesTypeArea": 1, + "SeriesTypeBar": 2, + "SeriesTypeStackedBar": 3, + "SeriesTypePercentBar": 4, + "SeriesTypeBoxPlot": 5, + "SeriesTypePie": 6, + "SeriesTypeScatter": 7, + "SeriesTypeSpline": 8, + "SeriesTypeHorizontalBar": 9, + "SeriesTypeHorizontalStackedBar": 10, + "SeriesTypeHorizontalPercentBar": 11 + } + } + Property { name: "theme"; type: "Theme" } + Property { name: "animationOptions"; type: "Animation" } + Property { name: "title"; type: "string" } + Property { name: "titleFont"; type: "QFont" } + Property { name: "titleColor"; type: "QColor" } + Property { name: "legend"; type: "QLegend"; isReadonly: true; isPointer: true } + Property { name: "count"; type: "int"; isReadonly: true } + Property { name: "backgroundColor"; type: "QColor" } + Property { name: "dropShadowEnabled"; type: "bool" } + Property { name: "backgroundRoundness"; revision: 3; type: "double" } + Property { name: "topMargin"; type: "double"; isReadonly: true } + Property { name: "bottomMargin"; type: "double"; isReadonly: true } + Property { name: "leftMargin"; type: "double"; isReadonly: true } + Property { name: "rightMargin"; type: "double"; isReadonly: true } + Property { + name: "minimumMargins" + revision: 1 + type: "DeclarativeMargins" + isReadonly: true + isPointer: true + } + Property { + name: "margins" + revision: 2 + type: "DeclarativeMargins" + isReadonly: true + isPointer: true + } + Property { name: "plotArea"; revision: 1; type: "QRectF"; isReadonly: true } + Property { name: "plotAreaColor"; revision: 3; type: "QColor" } + Property { name: "axes"; revision: 2; type: "QAbstractAxis"; isList: true; isReadonly: true } + Property { name: "localizeNumbers"; revision: 4; type: "bool" } + Property { name: "locale"; revision: 4; type: "QLocale" } + Signal { name: "axisLabelsChanged" } + Signal { + name: "titleColorChanged" + Parameter { name: "color"; type: "QColor" } + } + Signal { + name: "dropShadowEnabledChanged" + Parameter { name: "enabled"; type: "bool" } + } + Signal { name: "marginsChanged"; revision: 2 } + Signal { + name: "plotAreaChanged" + Parameter { name: "plotArea"; type: "QRectF" } + } + Signal { + name: "seriesAdded" + Parameter { name: "series"; type: "QAbstractSeries"; isPointer: true } + } + Signal { + name: "seriesRemoved" + Parameter { name: "series"; type: "QAbstractSeries"; isPointer: true } + } + Signal { name: "plotAreaColorChanged"; revision: 3 } + Signal { + name: "backgroundRoundnessChanged" + revision: 3 + Parameter { name: "diameter"; type: "double" } + } + Signal { name: "localizeNumbersChanged"; revision: 4 } + Signal { name: "localeChanged"; revision: 4 } + Method { + name: "series" + type: "QAbstractSeries*" + Parameter { name: "index"; type: "int" } + } + Method { + name: "series" + type: "QAbstractSeries*" + Parameter { name: "seriesName"; type: "string" } + } + Method { + name: "createSeries" + type: "QAbstractSeries*" + Parameter { name: "type"; type: "int" } + Parameter { name: "name"; type: "string" } + Parameter { name: "axisX"; type: "QAbstractAxis"; isPointer: true } + Parameter { name: "axisY"; type: "QAbstractAxis"; isPointer: true } + } + Method { + name: "createSeries" + type: "QAbstractSeries*" + Parameter { name: "type"; type: "int" } + Parameter { name: "name"; type: "string" } + Parameter { name: "axisX"; type: "QAbstractAxis"; isPointer: true } + } + Method { + name: "createSeries" + type: "QAbstractSeries*" + Parameter { name: "type"; type: "int" } + Parameter { name: "name"; type: "string" } + } + Method { + name: "createSeries" + type: "QAbstractSeries*" + Parameter { name: "type"; type: "int" } + } + Method { + name: "removeSeries" + Parameter { name: "series"; type: "QAbstractSeries"; isPointer: true } + } + Method { name: "removeAllSeries" } + Method { + name: "setAxisX" + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + Parameter { name: "series"; type: "QAbstractSeries"; isPointer: true } + } + Method { + name: "setAxisX" + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Method { + name: "setAxisY" + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + Parameter { name: "series"; type: "QAbstractSeries"; isPointer: true } + } + Method { + name: "setAxisY" + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Method { name: "createDefaultAxes" } + Method { + name: "axisX" + type: "QAbstractAxis*" + Parameter { name: "series"; type: "QAbstractSeries"; isPointer: true } + } + Method { name: "axisX"; type: "QAbstractAxis*" } + Method { + name: "axisY" + type: "QAbstractAxis*" + Parameter { name: "series"; type: "QAbstractSeries"; isPointer: true } + } + Method { name: "axisY"; type: "QAbstractAxis*" } + Method { + name: "zoom" + Parameter { name: "factor"; type: "double" } + } + Method { + name: "scrollLeft" + Parameter { name: "pixels"; type: "double" } + } + Method { + name: "scrollRight" + Parameter { name: "pixels"; type: "double" } + } + Method { + name: "scrollUp" + Parameter { name: "pixels"; type: "double" } + } + Method { + name: "scrollDown" + Parameter { name: "pixels"; type: "double" } + } + } + Component { + name: "QtCharts::DeclarativeHorizontalBarSeries" + defaultProperty: "seriesChildren" + prototype: "QtCharts::QHorizontalBarSeries" + exports: [ + "QtCharts/HorizontalBarSeries 1.1", + "QtCharts/HorizontalBarSeries 1.2", + "QtCharts/HorizontalBarSeries 2.0" + ] + exportMetaObjectRevisions: [1, 2, 2] + Property { name: "axisX"; revision: 1; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisY"; revision: 1; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisXTop"; revision: 2; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisYRight"; revision: 2; type: "QAbstractAxis"; isPointer: true } + Property { name: "seriesChildren"; type: "QObject"; isList: true; isReadonly: true } + Signal { + name: "axisXChanged" + revision: 1 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisYChanged" + revision: 1 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisXTopChanged" + revision: 2 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisYRightChanged" + revision: 2 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Method { + name: "appendSeriesChildren" + Parameter { name: "list"; type: "QObject"; isList: true; isPointer: true } + Parameter { name: "element"; type: "QObject"; isPointer: true } + } + Method { + name: "at" + type: "DeclarativeBarSet*" + Parameter { name: "index"; type: "int" } + } + Method { + name: "append" + type: "DeclarativeBarSet*" + Parameter { name: "label"; type: "string" } + Parameter { name: "values"; type: "QVariantList" } + } + Method { + name: "insert" + type: "DeclarativeBarSet*" + Parameter { name: "index"; type: "int" } + Parameter { name: "label"; type: "string" } + Parameter { name: "values"; type: "QVariantList" } + } + Method { + name: "remove" + type: "bool" + Parameter { name: "barset"; type: "QBarSet"; isPointer: true } + } + Method { name: "clear" } + } + Component { + name: "QtCharts::DeclarativeHorizontalPercentBarSeries" + defaultProperty: "seriesChildren" + prototype: "QtCharts::QHorizontalPercentBarSeries" + exports: [ + "QtCharts/HorizontalPercentBarSeries 1.1", + "QtCharts/HorizontalPercentBarSeries 1.2", + "QtCharts/HorizontalPercentBarSeries 2.0" + ] + exportMetaObjectRevisions: [1, 2, 2] + Property { name: "axisX"; revision: 1; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisY"; revision: 1; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisXTop"; revision: 2; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisYRight"; revision: 2; type: "QAbstractAxis"; isPointer: true } + Property { name: "seriesChildren"; type: "QObject"; isList: true; isReadonly: true } + Signal { + name: "axisXChanged" + revision: 1 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisYChanged" + revision: 1 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisXTopChanged" + revision: 2 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisYRightChanged" + revision: 2 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Method { + name: "appendSeriesChildren" + Parameter { name: "list"; type: "QObject"; isList: true; isPointer: true } + Parameter { name: "element"; type: "QObject"; isPointer: true } + } + Method { + name: "at" + type: "DeclarativeBarSet*" + Parameter { name: "index"; type: "int" } + } + Method { + name: "append" + type: "DeclarativeBarSet*" + Parameter { name: "label"; type: "string" } + Parameter { name: "values"; type: "QVariantList" } + } + Method { + name: "insert" + type: "DeclarativeBarSet*" + Parameter { name: "index"; type: "int" } + Parameter { name: "label"; type: "string" } + Parameter { name: "values"; type: "QVariantList" } + } + Method { + name: "remove" + type: "bool" + Parameter { name: "barset"; type: "QBarSet"; isPointer: true } + } + Method { name: "clear" } + } + Component { + name: "QtCharts::DeclarativeHorizontalStackedBarSeries" + defaultProperty: "seriesChildren" + prototype: "QtCharts::QHorizontalStackedBarSeries" + exports: [ + "QtCharts/HorizontalStackedBarSeries 1.1", + "QtCharts/HorizontalStackedBarSeries 1.2", + "QtCharts/HorizontalStackedBarSeries 2.0" + ] + exportMetaObjectRevisions: [1, 2, 2] + Property { name: "axisX"; revision: 1; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisY"; revision: 1; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisXTop"; revision: 2; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisYRight"; revision: 2; type: "QAbstractAxis"; isPointer: true } + Property { name: "seriesChildren"; type: "QObject"; isList: true; isReadonly: true } + Signal { + name: "axisXChanged" + revision: 1 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisYChanged" + revision: 1 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisXTopChanged" + revision: 2 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisYRightChanged" + revision: 2 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Method { + name: "appendSeriesChildren" + Parameter { name: "list"; type: "QObject"; isList: true; isPointer: true } + Parameter { name: "element"; type: "QObject"; isPointer: true } + } + Method { + name: "at" + type: "DeclarativeBarSet*" + Parameter { name: "index"; type: "int" } + } + Method { + name: "append" + type: "DeclarativeBarSet*" + Parameter { name: "label"; type: "string" } + Parameter { name: "values"; type: "QVariantList" } + } + Method { + name: "insert" + type: "DeclarativeBarSet*" + Parameter { name: "index"; type: "int" } + Parameter { name: "label"; type: "string" } + Parameter { name: "values"; type: "QVariantList" } + } + Method { + name: "remove" + type: "bool" + Parameter { name: "barset"; type: "QBarSet"; isPointer: true } + } + Method { name: "clear" } + } + Component { + name: "QtCharts::DeclarativeLineSeries" + defaultProperty: "declarativeChildren" + prototype: "QtCharts::QLineSeries" + exports: [ + "QtCharts/LineSeries 1.0", + "QtCharts/LineSeries 1.1", + "QtCharts/LineSeries 1.2", + "QtCharts/LineSeries 1.3", + "QtCharts/LineSeries 2.0" + ] + exportMetaObjectRevisions: [0, 1, 2, 3, 3] + Property { name: "count"; type: "int"; isReadonly: true } + Property { name: "axisX"; revision: 1; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisY"; revision: 1; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisXTop"; revision: 2; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisYRight"; revision: 2; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisAngular"; revision: 3; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisRadial"; revision: 3; type: "QAbstractAxis"; isPointer: true } + Property { name: "width"; revision: 1; type: "double" } + Property { name: "style"; revision: 1; type: "Qt::PenStyle" } + Property { name: "capStyle"; revision: 1; type: "Qt::PenCapStyle" } + Property { name: "declarativeChildren"; type: "QObject"; isList: true; isReadonly: true } + Signal { + name: "countChanged" + Parameter { name: "count"; type: "int" } + } + Signal { + name: "axisXChanged" + revision: 1 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisYChanged" + revision: 1 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisXTopChanged" + revision: 2 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisYRightChanged" + revision: 2 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisAngularChanged" + revision: 3 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisRadialChanged" + revision: 3 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "widthChanged" + revision: 1 + Parameter { name: "width"; type: "double" } + } + Signal { + name: "styleChanged" + revision: 1 + Parameter { name: "style"; type: "Qt::PenStyle" } + } + Signal { + name: "capStyleChanged" + revision: 1 + Parameter { name: "capStyle"; type: "Qt::PenCapStyle" } + } + Method { + name: "appendDeclarativeChildren" + Parameter { name: "list"; type: "QObject"; isList: true; isPointer: true } + Parameter { name: "element"; type: "QObject"; isPointer: true } + } + Method { + name: "handleCountChanged" + Parameter { name: "index"; type: "int" } + } + Method { + name: "append" + Parameter { name: "x"; type: "double" } + Parameter { name: "y"; type: "double" } + } + Method { + name: "replace" + Parameter { name: "oldX"; type: "double" } + Parameter { name: "oldY"; type: "double" } + Parameter { name: "newX"; type: "double" } + Parameter { name: "newY"; type: "double" } + } + Method { + name: "replace" + revision: 3 + Parameter { name: "index"; type: "int" } + Parameter { name: "newX"; type: "double" } + Parameter { name: "newY"; type: "double" } + } + Method { + name: "remove" + Parameter { name: "x"; type: "double" } + Parameter { name: "y"; type: "double" } + } + Method { + name: "remove" + revision: 3 + Parameter { name: "index"; type: "int" } + } + Method { + name: "insert" + Parameter { name: "index"; type: "int" } + Parameter { name: "x"; type: "double" } + Parameter { name: "y"; type: "double" } + } + Method { name: "clear" } + Method { + name: "at" + type: "QPointF" + Parameter { name: "index"; type: "int" } + } + } + Component { + name: "QtCharts::DeclarativeMargins" + prototype: "QObject" + exports: ["QtCharts/Margins 1.1", "QtCharts/Margins 2.0"] + isCreatable: false + exportMetaObjectRevisions: [0, 0] + Property { name: "top"; type: "int" } + Property { name: "bottom"; type: "int" } + Property { name: "left"; type: "int" } + Property { name: "right"; type: "int" } + Signal { + name: "topChanged" + Parameter { name: "top"; type: "int" } + Parameter { name: "bottom"; type: "int" } + Parameter { name: "left"; type: "int" } + Parameter { name: "right"; type: "int" } + } + Signal { + name: "bottomChanged" + Parameter { name: "top"; type: "int" } + Parameter { name: "bottom"; type: "int" } + Parameter { name: "left"; type: "int" } + Parameter { name: "right"; type: "int" } + } + Signal { + name: "leftChanged" + Parameter { name: "top"; type: "int" } + Parameter { name: "bottom"; type: "int" } + Parameter { name: "left"; type: "int" } + Parameter { name: "right"; type: "int" } + } + Signal { + name: "rightChanged" + Parameter { name: "top"; type: "int" } + Parameter { name: "bottom"; type: "int" } + Parameter { name: "left"; type: "int" } + Parameter { name: "right"; type: "int" } + } + } + Component { + name: "QtCharts::DeclarativePercentBarSeries" + defaultProperty: "seriesChildren" + prototype: "QtCharts::QPercentBarSeries" + exports: [ + "QtCharts/PercentBarSeries 1.0", + "QtCharts/PercentBarSeries 1.1", + "QtCharts/PercentBarSeries 1.2", + "QtCharts/PercentBarSeries 2.0" + ] + exportMetaObjectRevisions: [0, 1, 2, 2] + Property { name: "axisX"; revision: 1; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisY"; revision: 1; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisXTop"; revision: 2; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisYRight"; revision: 2; type: "QAbstractAxis"; isPointer: true } + Property { name: "seriesChildren"; type: "QObject"; isList: true; isReadonly: true } + Signal { + name: "axisXChanged" + revision: 1 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisYChanged" + revision: 1 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisXTopChanged" + revision: 2 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisYRightChanged" + revision: 2 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Method { + name: "appendSeriesChildren" + Parameter { name: "list"; type: "QObject"; isList: true; isPointer: true } + Parameter { name: "element"; type: "QObject"; isPointer: true } + } + Method { + name: "at" + type: "DeclarativeBarSet*" + Parameter { name: "index"; type: "int" } + } + Method { + name: "append" + type: "DeclarativeBarSet*" + Parameter { name: "label"; type: "string" } + Parameter { name: "values"; type: "QVariantList" } + } + Method { + name: "insert" + type: "DeclarativeBarSet*" + Parameter { name: "index"; type: "int" } + Parameter { name: "label"; type: "string" } + Parameter { name: "values"; type: "QVariantList" } + } + Method { + name: "remove" + type: "bool" + Parameter { name: "barset"; type: "QBarSet"; isPointer: true } + } + Method { name: "clear" } + } + Component { + name: "QtCharts::DeclarativePieSeries" + defaultProperty: "seriesChildren" + prototype: "QtCharts::QPieSeries" + exports: [ + "QtCharts/PieSeries 1.0", + "QtCharts/PieSeries 1.1", + "QtCharts/PieSeries 2.0" + ] + exportMetaObjectRevisions: [0, 0, 0] + Property { name: "seriesChildren"; type: "QObject"; isList: true; isReadonly: true } + Signal { + name: "sliceAdded" + Parameter { name: "slice"; type: "QPieSlice"; isPointer: true } + } + Signal { + name: "sliceRemoved" + Parameter { name: "slice"; type: "QPieSlice"; isPointer: true } + } + Method { + name: "appendSeriesChildren" + Parameter { name: "list"; type: "QObject"; isList: true; isPointer: true } + Parameter { name: "element"; type: "QObject"; isPointer: true } + } + Method { + name: "handleAdded" + Parameter { name: "slices"; type: "QList<QPieSlice*>" } + } + Method { + name: "handleRemoved" + Parameter { name: "slices"; type: "QList<QPieSlice*>" } + } + Method { + name: "at" + type: "QPieSlice*" + Parameter { name: "index"; type: "int" } + } + Method { + name: "find" + type: "QPieSlice*" + Parameter { name: "label"; type: "string" } + } + Method { + name: "append" + type: "DeclarativePieSlice*" + Parameter { name: "label"; type: "string" } + Parameter { name: "value"; type: "double" } + } + Method { + name: "remove" + type: "bool" + Parameter { name: "slice"; type: "QPieSlice"; isPointer: true } + } + Method { name: "clear" } + } + Component { + name: "QtCharts::DeclarativePieSlice" + prototype: "QtCharts::QPieSlice" + exports: ["QtCharts/PieSlice 1.4", "QtCharts/PieSlice 2.0"] + exportMetaObjectRevisions: [0, 0] + Property { name: "brushFilename"; type: "string" } + Signal { + name: "brushFilenameChanged" + Parameter { name: "brushFilename"; type: "string" } + } + } + Component { + name: "QtCharts::DeclarativePolarChart" + defaultProperty: "data" + prototype: "QtCharts::DeclarativeChart" + exports: [ + "QtCharts/PolarChartView 1.3", + "QtCharts/PolarChartView 2.0" + ] + exportMetaObjectRevisions: [1, 1] + } + Component { + name: "QtCharts::DeclarativeScatterSeries" + defaultProperty: "declarativeChildren" + prototype: "QtCharts::QScatterSeries" + exports: [ + "QtCharts/ScatterSeries 1.0", + "QtCharts/ScatterSeries 1.1", + "QtCharts/ScatterSeries 1.2", + "QtCharts/ScatterSeries 1.3", + "QtCharts/ScatterSeries 1.4", + "QtCharts/ScatterSeries 2.0" + ] + exportMetaObjectRevisions: [0, 1, 2, 3, 4, 4] + Property { name: "count"; type: "int"; isReadonly: true } + Property { name: "axisX"; revision: 1; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisY"; revision: 1; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisXTop"; revision: 2; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisYRight"; revision: 2; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisAngular"; revision: 3; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisRadial"; revision: 3; type: "QAbstractAxis"; isPointer: true } + Property { name: "borderWidth"; revision: 1; type: "double" } + Property { name: "declarativeChildren"; type: "QObject"; isList: true; isReadonly: true } + Property { name: "brushFilename"; revision: 4; type: "string" } + Property { name: "brush"; revision: 4; type: "QBrush" } + Signal { + name: "countChanged" + Parameter { name: "count"; type: "int" } + } + Signal { + name: "axisXChanged" + revision: 1 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisYChanged" + revision: 1 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "borderWidthChanged" + revision: 1 + Parameter { name: "width"; type: "double" } + } + Signal { + name: "axisXTopChanged" + revision: 2 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisYRightChanged" + revision: 2 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisAngularChanged" + revision: 3 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisRadialChanged" + revision: 3 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "brushFilenameChanged" + revision: 4 + Parameter { name: "brushFilename"; type: "string" } + } + Signal { name: "brushChanged"; revision: 4 } + Method { + name: "appendDeclarativeChildren" + Parameter { name: "list"; type: "QObject"; isList: true; isPointer: true } + Parameter { name: "element"; type: "QObject"; isPointer: true } + } + Method { + name: "handleCountChanged" + Parameter { name: "index"; type: "int" } + } + Method { + name: "append" + Parameter { name: "x"; type: "double" } + Parameter { name: "y"; type: "double" } + } + Method { + name: "replace" + Parameter { name: "oldX"; type: "double" } + Parameter { name: "oldY"; type: "double" } + Parameter { name: "newX"; type: "double" } + Parameter { name: "newY"; type: "double" } + } + Method { + name: "replace" + revision: 3 + Parameter { name: "index"; type: "int" } + Parameter { name: "newX"; type: "double" } + Parameter { name: "newY"; type: "double" } + } + Method { + name: "remove" + Parameter { name: "x"; type: "double" } + Parameter { name: "y"; type: "double" } + } + Method { + name: "remove" + revision: 3 + Parameter { name: "index"; type: "int" } + } + Method { + name: "insert" + Parameter { name: "index"; type: "int" } + Parameter { name: "x"; type: "double" } + Parameter { name: "y"; type: "double" } + } + Method { name: "clear" } + Method { + name: "at" + type: "QPointF" + Parameter { name: "index"; type: "int" } + } + } + Component { + name: "QtCharts::DeclarativeSplineSeries" + defaultProperty: "declarativeChildren" + prototype: "QtCharts::QSplineSeries" + exports: [ + "QtCharts/SplineSeries 1.0", + "QtCharts/SplineSeries 1.1", + "QtCharts/SplineSeries 1.2", + "QtCharts/SplineSeries 1.3", + "QtCharts/SplineSeries 2.0" + ] + exportMetaObjectRevisions: [0, 1, 2, 3, 3] + Property { name: "count"; type: "int"; isReadonly: true } + Property { name: "axisX"; revision: 1; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisY"; revision: 1; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisXTop"; revision: 2; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisYRight"; revision: 2; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisAngular"; revision: 3; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisRadial"; revision: 3; type: "QAbstractAxis"; isPointer: true } + Property { name: "width"; revision: 1; type: "double" } + Property { name: "style"; revision: 1; type: "Qt::PenStyle" } + Property { name: "capStyle"; revision: 1; type: "Qt::PenCapStyle" } + Property { name: "declarativeChildren"; type: "QObject"; isList: true; isReadonly: true } + Signal { + name: "countChanged" + Parameter { name: "count"; type: "int" } + } + Signal { + name: "axisXChanged" + revision: 1 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisYChanged" + revision: 1 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisXTopChanged" + revision: 2 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisYRightChanged" + revision: 2 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisAngularChanged" + revision: 3 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisRadialChanged" + revision: 3 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "widthChanged" + revision: 1 + Parameter { name: "width"; type: "double" } + } + Signal { + name: "styleChanged" + revision: 1 + Parameter { name: "style"; type: "Qt::PenStyle" } + } + Signal { + name: "capStyleChanged" + revision: 1 + Parameter { name: "capStyle"; type: "Qt::PenCapStyle" } + } + Method { + name: "appendDeclarativeChildren" + Parameter { name: "list"; type: "QObject"; isList: true; isPointer: true } + Parameter { name: "element"; type: "QObject"; isPointer: true } + } + Method { + name: "handleCountChanged" + Parameter { name: "index"; type: "int" } + } + Method { + name: "append" + Parameter { name: "x"; type: "double" } + Parameter { name: "y"; type: "double" } + } + Method { + name: "replace" + Parameter { name: "oldX"; type: "double" } + Parameter { name: "oldY"; type: "double" } + Parameter { name: "newX"; type: "double" } + Parameter { name: "newY"; type: "double" } + } + Method { + name: "replace" + revision: 3 + Parameter { name: "index"; type: "int" } + Parameter { name: "newX"; type: "double" } + Parameter { name: "newY"; type: "double" } + } + Method { + name: "remove" + Parameter { name: "x"; type: "double" } + Parameter { name: "y"; type: "double" } + } + Method { + name: "remove" + revision: 3 + Parameter { name: "index"; type: "int" } + } + Method { + name: "insert" + Parameter { name: "index"; type: "int" } + Parameter { name: "x"; type: "double" } + Parameter { name: "y"; type: "double" } + } + Method { name: "clear" } + Method { + name: "at" + type: "QPointF" + Parameter { name: "index"; type: "int" } + } + } + Component { + name: "QtCharts::DeclarativeStackedBarSeries" + defaultProperty: "seriesChildren" + prototype: "QtCharts::QStackedBarSeries" + exports: [ + "QtCharts/StackedBarSeries 1.0", + "QtCharts/StackedBarSeries 1.1", + "QtCharts/StackedBarSeries 1.2", + "QtCharts/StackedBarSeries 2.0" + ] + exportMetaObjectRevisions: [0, 1, 2, 2] + Property { name: "axisX"; revision: 1; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisY"; revision: 1; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisXTop"; revision: 2; type: "QAbstractAxis"; isPointer: true } + Property { name: "axisYRight"; revision: 2; type: "QAbstractAxis"; isPointer: true } + Property { name: "seriesChildren"; type: "QObject"; isList: true; isReadonly: true } + Signal { + name: "axisXChanged" + revision: 1 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisYChanged" + revision: 1 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisXTopChanged" + revision: 2 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Signal { + name: "axisYRightChanged" + revision: 2 + Parameter { name: "axis"; type: "QAbstractAxis"; isPointer: true } + } + Method { + name: "appendSeriesChildren" + Parameter { name: "list"; type: "QObject"; isList: true; isPointer: true } + Parameter { name: "element"; type: "QObject"; isPointer: true } + } + Method { + name: "at" + type: "DeclarativeBarSet*" + Parameter { name: "index"; type: "int" } + } + Method { + name: "append" + type: "DeclarativeBarSet*" + Parameter { name: "label"; type: "string" } + Parameter { name: "values"; type: "QVariantList" } + } + Method { + name: "insert" + type: "DeclarativeBarSet*" + Parameter { name: "index"; type: "int" } + Parameter { name: "label"; type: "string" } + Parameter { name: "values"; type: "QVariantList" } + } + Method { + name: "remove" + type: "bool" + Parameter { name: "barset"; type: "QBarSet"; isPointer: true } + } + Method { name: "clear" } + } + Component { + name: "QtCharts::DeclarativeXYPoint" + prototype: "QObject" + exports: ["QtCharts/XYPoint 1.0", "QtCharts/XYPoint 2.0"] + exportMetaObjectRevisions: [0, 0] + Property { name: "x"; type: "double" } + Property { name: "y"; type: "double" } + } + Component { + name: "QtCharts::LegendScroller" + defaultProperty: "children" + prototype: "QtCharts::QLegend" + } + Component { + name: "QtCharts::QAbstractAxis" + prototype: "QObject" + exports: ["QtCharts/AbstractAxis 1.0", "QtCharts/AbstractAxis 2.0"] + isCreatable: false + exportMetaObjectRevisions: [0, 0] + Property { name: "visible"; type: "bool" } + Property { name: "lineVisible"; type: "bool" } + Property { name: "linePen"; type: "QPen" } + Property { name: "color"; type: "QColor" } + Property { name: "labelsVisible"; type: "bool" } + Property { name: "labelsPen"; type: "QPen" } + Property { name: "labelsBrush"; type: "QBrush" } + Property { name: "labelsAngle"; type: "int" } + Property { name: "labelsFont"; type: "QFont" } + Property { name: "labelsColor"; type: "QColor" } + Property { name: "gridVisible"; type: "bool" } + Property { name: "gridLinePen"; type: "QPen" } + Property { name: "shadesVisible"; type: "bool" } + Property { name: "shadesColor"; type: "QColor" } + Property { name: "shadesBorderColor"; type: "QColor" } + Property { name: "shadesPen"; type: "QPen" } + Property { name: "shadesBrush"; type: "QBrush" } + Property { name: "titleText"; type: "string" } + Property { name: "titlePen"; type: "QPen" } + Property { name: "titleBrush"; type: "QBrush" } + Property { name: "titleVisible"; type: "bool" } + Property { name: "titleFont"; type: "QFont" } + Property { name: "orientation"; type: "Qt::Orientation"; isReadonly: true } + Property { name: "alignment"; type: "Qt::Alignment"; isReadonly: true } + Signal { + name: "visibleChanged" + Parameter { name: "visible"; type: "bool" } + } + Signal { + name: "linePenChanged" + Parameter { name: "pen"; type: "QPen" } + } + Signal { + name: "lineVisibleChanged" + Parameter { name: "visible"; type: "bool" } + } + Signal { + name: "labelsVisibleChanged" + Parameter { name: "visible"; type: "bool" } + } + Signal { + name: "labelsPenChanged" + Parameter { name: "pen"; type: "QPen" } + } + Signal { + name: "labelsBrushChanged" + Parameter { name: "brush"; type: "QBrush" } + } + Signal { + name: "labelsFontChanged" + Parameter { name: "pen"; type: "QFont" } + } + Signal { + name: "labelsAngleChanged" + Parameter { name: "angle"; type: "int" } + } + Signal { + name: "gridLinePenChanged" + Parameter { name: "pen"; type: "QPen" } + } + Signal { + name: "gridVisibleChanged" + Parameter { name: "visible"; type: "bool" } + } + Signal { + name: "colorChanged" + Parameter { name: "color"; type: "QColor" } + } + Signal { + name: "labelsColorChanged" + Parameter { name: "color"; type: "QColor" } + } + Signal { + name: "titleTextChanged" + Parameter { name: "title"; type: "string" } + } + Signal { + name: "titlePenChanged" + Parameter { name: "pen"; type: "QPen" } + } + Signal { + name: "titleBrushChanged" + Parameter { name: "brush"; type: "QBrush" } + } + Signal { + name: "titleVisibleChanged" + Parameter { name: "visible"; type: "bool" } + } + Signal { + name: "titleFontChanged" + Parameter { name: "font"; type: "QFont" } + } + Signal { + name: "shadesVisibleChanged" + Parameter { name: "visible"; type: "bool" } + } + Signal { + name: "shadesColorChanged" + Parameter { name: "color"; type: "QColor" } + } + Signal { + name: "shadesBorderColorChanged" + Parameter { name: "color"; type: "QColor" } + } + Signal { + name: "shadesPenChanged" + Parameter { name: "pen"; type: "QPen" } + } + Signal { + name: "shadesBrushChanged" + Parameter { name: "brush"; type: "QBrush" } + } + } + Component { + name: "QtCharts::QAbstractBarSeries" + prototype: "QtCharts::QAbstractSeries" + exports: [ + "QtCharts/AbstractBarSeries 1.0", + "QtCharts/AbstractBarSeries 2.0" + ] + isCreatable: false + exportMetaObjectRevisions: [0, 0] + Enum { + name: "LabelsPosition" + values: { + "LabelsCenter": 0, + "LabelsInsideEnd": 1, + "LabelsInsideBase": 2, + "LabelsOutsideEnd": 3 + } + } + Property { name: "barWidth"; type: "double" } + Property { name: "count"; type: "int"; isReadonly: true } + Property { name: "labelsVisible"; type: "bool" } + Property { name: "labelsFormat"; type: "string" } + Property { name: "labelsPosition"; type: "LabelsPosition" } + Signal { + name: "clicked" + Parameter { name: "index"; type: "int" } + Parameter { name: "barset"; type: "QBarSet"; isPointer: true } + } + Signal { + name: "hovered" + Parameter { name: "status"; type: "bool" } + Parameter { name: "barset"; type: "QBarSet"; isPointer: true } + } + Signal { + name: "hovered" + Parameter { name: "status"; type: "bool" } + Parameter { name: "index"; type: "int" } + Parameter { name: "barset"; type: "QBarSet"; isPointer: true } + } + Signal { + name: "labelsFormatChanged" + Parameter { name: "format"; type: "string" } + } + Signal { + name: "labelsPositionChanged" + Parameter { name: "position"; type: "QAbstractBarSeries::LabelsPosition" } + } + Signal { + name: "barsetsAdded" + Parameter { name: "sets"; type: "QList<QBarSet*>" } + } + Signal { + name: "barsetsRemoved" + Parameter { name: "sets"; type: "QList<QBarSet*>" } + } + } + Component { + name: "QtCharts::QAbstractSeries" + prototype: "QObject" + exports: [ + "QtCharts/AbstractSeries 1.0", + "QtCharts/AbstractSeries 2.0" + ] + isCreatable: false + exportMetaObjectRevisions: [0, 0] + Enum { + name: "SeriesType" + values: { + "SeriesTypeLine": 0, + "SeriesTypeArea": 1, + "SeriesTypeBar": 2, + "SeriesTypeStackedBar": 3, + "SeriesTypePercentBar": 4, + "SeriesTypePie": 5, + "SeriesTypeScatter": 6, + "SeriesTypeSpline": 7, + "SeriesTypeHorizontalBar": 8, + "SeriesTypeHorizontalStackedBar": 9, + "SeriesTypeHorizontalPercentBar": 10, + "SeriesTypeBoxPlot": 11 + } + } + Property { name: "name"; type: "string" } + Property { name: "visible"; type: "bool" } + Property { name: "opacity"; type: "double" } + Property { name: "type"; type: "SeriesType"; isReadonly: true } + } + Component { + name: "QtCharts::QAreaSeries" + prototype: "QtCharts::QAbstractSeries" + Property { name: "upperSeries"; type: "QLineSeries"; isReadonly: true; isPointer: true } + Property { name: "lowerSeries"; type: "QLineSeries"; isReadonly: true; isPointer: true } + Property { name: "color"; type: "QColor" } + Property { name: "borderColor"; type: "QColor" } + Property { name: "pointLabelsFormat"; type: "string" } + Property { name: "pointLabelsVisible"; type: "bool" } + Property { name: "pointLabelsFont"; type: "QFont" } + Property { name: "pointLabelsColor"; type: "QColor" } + Signal { + name: "clicked" + Parameter { name: "point"; type: "QPointF" } + } + Signal { + name: "hovered" + Parameter { name: "point"; type: "QPointF" } + Parameter { name: "state"; type: "bool" } + } + Signal { name: "selected" } + Signal { + name: "colorChanged" + Parameter { name: "color"; type: "QColor" } + } + Signal { + name: "borderColorChanged" + Parameter { name: "color"; type: "QColor" } + } + Signal { + name: "pointLabelsFormatChanged" + Parameter { name: "format"; type: "string" } + } + Signal { + name: "pointLabelsVisibilityChanged" + Parameter { name: "visible"; type: "bool" } + } + Signal { + name: "pointLabelsFontChanged" + Parameter { name: "font"; type: "QFont" } + } + Signal { + name: "pointLabelsColorChanged" + Parameter { name: "color"; type: "QColor" } + } + } + Component { + name: "QtCharts::QBarCategoryAxis" + prototype: "QtCharts::QAbstractAxis" + exports: [ + "QtCharts/BarCategoriesAxis 1.0", + "QtCharts/BarCategoryAxis 1.1", + "QtCharts/BarCategoryAxis 2.0" + ] + exportMetaObjectRevisions: [0, 0, 0] + Property { name: "categories"; type: "QStringList" } + Property { name: "min"; type: "string" } + Property { name: "max"; type: "string" } + Property { name: "count"; type: "int"; isReadonly: true } + Signal { + name: "minChanged" + Parameter { name: "min"; type: "string" } + } + Signal { + name: "maxChanged" + Parameter { name: "max"; type: "string" } + } + Signal { + name: "rangeChanged" + Parameter { name: "min"; type: "string" } + Parameter { name: "max"; type: "string" } + } + Method { name: "clear" } + } + Component { + name: "QtCharts::QBarModelMapper" + prototype: "QObject" + exports: [ + "QtCharts/BarModelMapper 1.0", + "QtCharts/BarModelMapper 2.0" + ] + isCreatable: false + exportMetaObjectRevisions: [0, 0] + } + Component { name: "QtCharts::QBarSeries"; prototype: "QtCharts::QAbstractBarSeries" } + Component { + name: "QtCharts::QBarSet" + prototype: "QObject" + exports: ["QtCharts/BarSetBase 1.0", "QtCharts/BarSetBase 2.0"] + isCreatable: false + exportMetaObjectRevisions: [0, 0] + Property { name: "label"; type: "string" } + Property { name: "pen"; type: "QPen" } + Property { name: "brush"; type: "QBrush" } + Property { name: "labelBrush"; type: "QBrush" } + Property { name: "labelFont"; type: "QFont" } + Property { name: "color"; type: "QColor" } + Property { name: "borderColor"; type: "QColor" } + Property { name: "labelColor"; type: "QColor" } + Signal { + name: "clicked" + Parameter { name: "index"; type: "int" } + } + Signal { + name: "hovered" + Parameter { name: "status"; type: "bool" } + } + Signal { + name: "hovered" + Parameter { name: "status"; type: "bool" } + Parameter { name: "index"; type: "int" } + } + Signal { + name: "colorChanged" + Parameter { name: "color"; type: "QColor" } + } + Signal { + name: "borderColorChanged" + Parameter { name: "color"; type: "QColor" } + } + Signal { + name: "labelColorChanged" + Parameter { name: "color"; type: "QColor" } + } + Signal { + name: "valuesAdded" + Parameter { name: "index"; type: "int" } + Parameter { name: "count"; type: "int" } + } + Signal { + name: "valuesRemoved" + Parameter { name: "index"; type: "int" } + Parameter { name: "count"; type: "int" } + } + Signal { + name: "valueChanged" + Parameter { name: "index"; type: "int" } + } + } + Component { + name: "QtCharts::QBoxPlotModelMapper" + prototype: "QObject" + exports: ["QtCharts/BoxPlotModelMapper 2.0"] + isCreatable: false + exportMetaObjectRevisions: [0] + } + Component { + name: "QtCharts::QBoxPlotSeries" + prototype: "QtCharts::QAbstractSeries" + Property { name: "boxOutlineVisible"; type: "bool" } + Property { name: "boxWidth"; type: "double" } + Property { name: "pen"; type: "QPen" } + Property { name: "brush"; type: "QBrush" } + Property { name: "count"; revision: 1; type: "int"; isReadonly: true } + Signal { + name: "clicked" + Parameter { name: "boxset"; type: "QBoxSet"; isPointer: true } + } + Signal { + name: "hovered" + Parameter { name: "status"; type: "bool" } + Parameter { name: "boxset"; type: "QBoxSet"; isPointer: true } + } + Signal { name: "boxOutlineVisibilityChanged" } + Signal { + name: "boxsetsAdded" + Parameter { name: "sets"; type: "QList<QBoxSet*>" } + } + Signal { + name: "boxsetsRemoved" + Parameter { name: "sets"; type: "QList<QBoxSet*>" } + } + } + Component { + name: "QtCharts::QBoxSet" + prototype: "QObject" + Property { name: "pen"; type: "QPen" } + Property { name: "brush"; type: "QBrush" } + Signal { name: "clicked" } + Signal { + name: "hovered" + Parameter { name: "status"; type: "bool" } + } + Signal { name: "valuesChanged" } + Signal { + name: "valueChanged" + Parameter { name: "index"; type: "int" } + } + Signal { name: "cleared" } + } + Component { + name: "QtCharts::QCategoryAxis" + prototype: "QtCharts::QValueAxis" + Property { name: "startValue"; type: "double" } + Property { name: "count"; type: "int"; isReadonly: true } + Property { name: "categoriesLabels"; type: "QStringList"; isReadonly: true } + Signal { name: "categoriesChanged" } + } + Component { + name: "QtCharts::QDateTimeAxis" + prototype: "QtCharts::QAbstractAxis" + exports: ["QtCharts/DateTimeAxis 1.1", "QtCharts/DateTimeAxis 2.0"] + exportMetaObjectRevisions: [0, 0] + Property { name: "tickCount"; type: "int" } + Property { name: "min"; type: "QDateTime" } + Property { name: "max"; type: "QDateTime" } + Property { name: "format"; type: "string" } + Signal { + name: "minChanged" + Parameter { name: "min"; type: "QDateTime" } + } + Signal { + name: "maxChanged" + Parameter { name: "max"; type: "QDateTime" } + } + Signal { + name: "rangeChanged" + Parameter { name: "min"; type: "QDateTime" } + Parameter { name: "max"; type: "QDateTime" } + } + Signal { + name: "formatChanged" + Parameter { name: "format"; type: "string" } + } + Signal { + name: "tickCountChanged" + Parameter { name: "tick"; type: "int" } + } + } + Component { + name: "QtCharts::QHBarModelMapper" + prototype: "QtCharts::QBarModelMapper" + exports: [ + "QtCharts/HBarModelMapper 1.0", + "QtCharts/HBarModelMapper 2.0" + ] + exportMetaObjectRevisions: [0, 0] + Property { name: "series"; type: "QAbstractBarSeries"; isPointer: true } + Property { name: "model"; type: "QAbstractItemModel"; isPointer: true } + Property { name: "firstBarSetRow"; type: "int" } + Property { name: "lastBarSetRow"; type: "int" } + Property { name: "firstColumn"; type: "int" } + Property { name: "columnCount"; type: "int" } + Signal { name: "seriesReplaced" } + Signal { name: "modelReplaced" } + } + Component { + name: "QtCharts::QHPieModelMapper" + prototype: "QtCharts::QPieModelMapper" + exports: [ + "QtCharts/HPieModelMapper 1.0", + "QtCharts/HPieModelMapper 2.0" + ] + exportMetaObjectRevisions: [0, 0] + Property { name: "series"; type: "QPieSeries"; isPointer: true } + Property { name: "model"; type: "QAbstractItemModel"; isPointer: true } + Property { name: "valuesRow"; type: "int" } + Property { name: "labelsRow"; type: "int" } + Property { name: "firstColumn"; type: "int" } + Property { name: "columnCount"; type: "int" } + Signal { name: "seriesReplaced" } + Signal { name: "modelReplaced" } + } + Component { + name: "QtCharts::QHXYModelMapper" + prototype: "QtCharts::QXYModelMapper" + exports: [ + "QtCharts/HXYModelMapper 1.0", + "QtCharts/HXYModelMapper 2.0" + ] + exportMetaObjectRevisions: [0, 0] + Property { name: "series"; type: "QXYSeries"; isPointer: true } + Property { name: "model"; type: "QAbstractItemModel"; isPointer: true } + Property { name: "xRow"; type: "int" } + Property { name: "yRow"; type: "int" } + Property { name: "firstColumn"; type: "int" } + Property { name: "columnCount"; type: "int" } + Signal { name: "seriesReplaced" } + Signal { name: "modelReplaced" } + } + Component { name: "QtCharts::QHorizontalBarSeries"; prototype: "QtCharts::QAbstractBarSeries" } + Component { + name: "QtCharts::QHorizontalPercentBarSeries" + prototype: "QtCharts::QAbstractBarSeries" + } + Component { + name: "QtCharts::QHorizontalStackedBarSeries" + prototype: "QtCharts::QAbstractBarSeries" + } + Component { + name: "QtCharts::QLegend" + defaultProperty: "children" + prototype: "QGraphicsWidget" + exports: ["QtCharts/Legend 1.0", "QtCharts/Legend 2.0"] + isCreatable: false + exportMetaObjectRevisions: [0, 0] + Property { name: "alignment"; type: "Qt::Alignment" } + Property { name: "backgroundVisible"; type: "bool" } + Property { name: "color"; type: "QColor" } + Property { name: "borderColor"; type: "QColor" } + Property { name: "font"; type: "QFont" } + Property { name: "labelColor"; type: "QColor" } + Property { name: "reverseMarkers"; type: "bool" } + Signal { + name: "backgroundVisibleChanged" + Parameter { name: "visible"; type: "bool" } + } + Signal { + name: "colorChanged" + Parameter { name: "color"; type: "QColor" } + } + Signal { + name: "borderColorChanged" + Parameter { name: "color"; type: "QColor" } + } + Signal { + name: "fontChanged" + Parameter { name: "font"; type: "QFont" } + } + Signal { + name: "labelColorChanged" + Parameter { name: "color"; type: "QColor" } + } + Signal { + name: "reverseMarkersChanged" + Parameter { name: "reverseMarkers"; type: "bool" } + } + } + Component { name: "QtCharts::QLineSeries"; prototype: "QtCharts::QXYSeries" } + Component { + name: "QtCharts::QLogValueAxis" + prototype: "QtCharts::QAbstractAxis" + exports: ["QtCharts/LogValueAxis 1.3", "QtCharts/LogValueAxis 2.0"] + exportMetaObjectRevisions: [0, 1] + Property { name: "min"; type: "double" } + Property { name: "max"; type: "double" } + Property { name: "labelFormat"; type: "string" } + Property { name: "base"; type: "double" } + Signal { + name: "minChanged" + Parameter { name: "min"; type: "double" } + } + Signal { + name: "maxChanged" + Parameter { name: "max"; type: "double" } + } + Signal { + name: "rangeChanged" + Parameter { name: "min"; type: "double" } + Parameter { name: "max"; type: "double" } + } + Signal { + name: "labelFormatChanged" + Parameter { name: "format"; type: "string" } + } + Signal { + name: "baseChanged" + Parameter { name: "base"; type: "double" } + } + } + Component { name: "QtCharts::QPercentBarSeries"; prototype: "QtCharts::QAbstractBarSeries" } + Component { + name: "QtCharts::QPieModelMapper" + prototype: "QObject" + exports: [ + "QtCharts/PieModelMapper 1.0", + "QtCharts/PieModelMapper 2.0" + ] + isCreatable: false + exportMetaObjectRevisions: [0, 0] + } + Component { + name: "QtCharts::QPieSeries" + prototype: "QtCharts::QAbstractSeries" + exports: ["QtCharts/QPieSeries 1.0", "QtCharts/QPieSeries 2.0"] + isCreatable: false + exportMetaObjectRevisions: [0, 0] + Property { name: "horizontalPosition"; type: "double" } + Property { name: "verticalPosition"; type: "double" } + Property { name: "size"; type: "double" } + Property { name: "startAngle"; type: "double" } + Property { name: "endAngle"; type: "double" } + Property { name: "count"; type: "int"; isReadonly: true } + Property { name: "sum"; type: "double"; isReadonly: true } + Property { name: "holeSize"; type: "double" } + Signal { + name: "added" + Parameter { name: "slices"; type: "QList<QPieSlice*>" } + } + Signal { + name: "removed" + Parameter { name: "slices"; type: "QList<QPieSlice*>" } + } + Signal { + name: "clicked" + Parameter { name: "slice"; type: "QPieSlice"; isPointer: true } + } + Signal { + name: "hovered" + Parameter { name: "slice"; type: "QPieSlice"; isPointer: true } + Parameter { name: "state"; type: "bool" } + } + } + Component { + name: "QtCharts::QPieSlice" + prototype: "QObject" + exports: ["QtCharts/PieSlice 1.0", "QtCharts/PieSlice 2.0"] + exportMetaObjectRevisions: [0, 0] + Enum { + name: "LabelPosition" + values: { + "LabelOutside": 0, + "LabelInsideHorizontal": 1, + "LabelInsideTangential": 2, + "LabelInsideNormal": 3 + } + } + Property { name: "label"; type: "string" } + Property { name: "value"; type: "double" } + Property { name: "labelVisible"; type: "bool" } + Property { name: "labelPosition"; type: "LabelPosition" } + Property { name: "exploded"; type: "bool" } + Property { name: "pen"; type: "QPen" } + Property { name: "borderColor"; type: "QColor" } + Property { name: "borderWidth"; type: "int" } + Property { name: "brush"; type: "QBrush" } + Property { name: "color"; type: "QColor" } + Property { name: "labelBrush"; type: "QBrush" } + Property { name: "labelColor"; type: "QColor" } + Property { name: "labelFont"; type: "QFont" } + Property { name: "labelArmLengthFactor"; type: "double" } + Property { name: "explodeDistanceFactor"; type: "double" } + Property { name: "percentage"; type: "double"; isReadonly: true } + Property { name: "startAngle"; type: "double"; isReadonly: true } + Property { name: "angleSpan"; type: "double"; isReadonly: true } + Signal { name: "clicked" } + Signal { + name: "hovered" + Parameter { name: "state"; type: "bool" } + } + } + Component { + name: "QtCharts::QScatterSeries" + prototype: "QtCharts::QXYSeries" + Enum { + name: "MarkerShape" + values: { + "MarkerShapeCircle": 0, + "MarkerShapeRectangle": 1 + } + } + Property { name: "color"; type: "QColor" } + Property { name: "borderColor"; type: "QColor" } + Property { name: "markerShape"; type: "MarkerShape" } + Property { name: "markerSize"; type: "double" } + Property { name: "brush"; type: "QBrush" } + Signal { + name: "colorChanged" + Parameter { name: "color"; type: "QColor" } + } + Signal { + name: "borderColorChanged" + Parameter { name: "color"; type: "QColor" } + } + } + Component { name: "QtCharts::QSplineSeries"; prototype: "QtCharts::QLineSeries" } + Component { name: "QtCharts::QStackedBarSeries"; prototype: "QtCharts::QAbstractBarSeries" } + Component { + name: "QtCharts::QVBarModelMapper" + prototype: "QtCharts::QBarModelMapper" + exports: [ + "QtCharts/VBarModelMapper 1.0", + "QtCharts/VBarModelMapper 2.0" + ] + exportMetaObjectRevisions: [0, 0] + Property { name: "series"; type: "QAbstractBarSeries"; isPointer: true } + Property { name: "model"; type: "QAbstractItemModel"; isPointer: true } + Property { name: "firstBarSetColumn"; type: "int" } + Property { name: "lastBarSetColumn"; type: "int" } + Property { name: "firstRow"; type: "int" } + Property { name: "rowCount"; type: "int" } + Signal { name: "seriesReplaced" } + Signal { name: "modelReplaced" } + } + Component { + name: "QtCharts::QVBoxPlotModelMapper" + prototype: "QtCharts::QBoxPlotModelMapper" + exports: ["QtCharts/VBoxPlotModelMapper 2.0"] + exportMetaObjectRevisions: [0] + Property { name: "series"; type: "QBoxPlotSeries"; isPointer: true } + Property { name: "model"; type: "QAbstractItemModel"; isPointer: true } + Property { name: "firstBoxSetColumn"; type: "int" } + Property { name: "lastBoxSetColumn"; type: "int" } + Property { name: "firstRow"; type: "int" } + Property { name: "rowCount"; type: "int" } + Signal { name: "seriesReplaced" } + Signal { name: "modelReplaced" } + } + Component { + name: "QtCharts::QVPieModelMapper" + prototype: "QtCharts::QPieModelMapper" + exports: [ + "QtCharts/VPieModelMapper 1.0", + "QtCharts/VPieModelMapper 2.0" + ] + exportMetaObjectRevisions: [0, 0] + Property { name: "series"; type: "QPieSeries"; isPointer: true } + Property { name: "model"; type: "QAbstractItemModel"; isPointer: true } + Property { name: "valuesColumn"; type: "int" } + Property { name: "labelsColumn"; type: "int" } + Property { name: "firstRow"; type: "int" } + Property { name: "rowCount"; type: "int" } + Signal { name: "seriesReplaced" } + Signal { name: "modelReplaced" } + } + Component { + name: "QtCharts::QVXYModelMapper" + prototype: "QtCharts::QXYModelMapper" + exports: [ + "QtCharts/VXYModelMapper 1.0", + "QtCharts/VXYModelMapper 2.0" + ] + exportMetaObjectRevisions: [0, 0] + Property { name: "series"; type: "QXYSeries"; isPointer: true } + Property { name: "model"; type: "QAbstractItemModel"; isPointer: true } + Property { name: "xColumn"; type: "int" } + Property { name: "yColumn"; type: "int" } + Property { name: "firstRow"; type: "int" } + Property { name: "rowCount"; type: "int" } + Signal { name: "seriesReplaced" } + Signal { name: "modelReplaced" } + } + Component { + name: "QtCharts::QValueAxis" + prototype: "QtCharts::QAbstractAxis" + exports: [ + "QtCharts/ValueAxis 1.1", + "QtCharts/ValueAxis 2.0", + "QtCharts/ValuesAxis 1.0" + ] + exportMetaObjectRevisions: [0, 0, 0] + Property { name: "tickCount"; type: "int" } + Property { name: "niceNumbersEnabled"; type: "bool" } + Property { name: "min"; type: "double" } + Property { name: "max"; type: "double" } + Property { name: "labelFormat"; type: "string" } + Signal { + name: "minChanged" + Parameter { name: "min"; type: "double" } + } + Signal { + name: "maxChanged" + Parameter { name: "max"; type: "double" } + } + Signal { + name: "rangeChanged" + Parameter { name: "min"; type: "double" } + Parameter { name: "max"; type: "double" } + } + Signal { + name: "tickCountChanged" + Parameter { name: "tickCount"; type: "int" } + } + Signal { + name: "labelFormatChanged" + Parameter { name: "format"; type: "string" } + } + Method { name: "applyNiceNumbers" } + } + Component { + name: "QtCharts::QXYModelMapper" + prototype: "QObject" + exports: ["QtCharts/XYModelMapper 1.0", "QtCharts/XYModelMapper 2.0"] + isCreatable: false + exportMetaObjectRevisions: [0, 0] + } + Component { + name: "QtCharts::QXYSeries" + prototype: "QtCharts::QAbstractSeries" + exports: ["QtCharts/XYSeries 1.0", "QtCharts/XYSeries 2.0"] + isCreatable: false + exportMetaObjectRevisions: [0, 0] + Property { name: "pointsVisible"; type: "bool" } + Property { name: "color"; type: "QColor" } + Property { name: "pointLabelsFormat"; type: "string" } + Property { name: "pointLabelsVisible"; type: "bool" } + Property { name: "pointLabelsFont"; type: "QFont" } + Property { name: "pointLabelsColor"; type: "QColor" } + Signal { + name: "clicked" + Parameter { name: "point"; type: "QPointF" } + } + Signal { + name: "hovered" + Parameter { name: "point"; type: "QPointF" } + Parameter { name: "state"; type: "bool" } + } + Signal { + name: "pointReplaced" + Parameter { name: "index"; type: "int" } + } + Signal { + name: "pointRemoved" + Parameter { name: "index"; type: "int" } + } + Signal { + name: "pointAdded" + Parameter { name: "index"; type: "int" } + } + Signal { + name: "colorChanged" + Parameter { name: "color"; type: "QColor" } + } + Signal { name: "pointsReplaced" } + Signal { + name: "pointLabelsFormatChanged" + Parameter { name: "format"; type: "string" } + } + Signal { + name: "pointLabelsVisibilityChanged" + Parameter { name: "visible"; type: "bool" } + } + Signal { + name: "pointLabelsFontChanged" + Parameter { name: "font"; type: "QFont" } + } + Signal { + name: "pointLabelsColorChanged" + Parameter { name: "color"; type: "QColor" } + } + } +} diff --git a/src/chartsqml2/qmldir b/src/chartsqml2/qmldir new file mode 100644 index 00000000..10f4c598 --- /dev/null +++ b/src/chartsqml2/qmldir @@ -0,0 +1,4 @@ +module QtCharts +plugin qtchartsqml2 +classname QtChartsQml2Plugin + |