plugin.cpp
227 lines
| 10.7 KiB
| text/x-c
|
CppLexer
Jani Honkonen
|
r830 | /**************************************************************************** | ||
** | ||||
Miikka Heikkinen
|
r2433 | ** Copyright (C) 2013 Digia Plc | ||
Jani Honkonen
|
r830 | ** All rights reserved. | ||
** For any questions to Digia, please use contact form at http://qt.digia.com | ||||
** | ||||
** This file is part of the Qt Commercial Charts Add-on. | ||||
** | ||||
** $QT_BEGIN_LICENSE$ | ||||
** Licensees holding valid Qt Commercial licenses may use this file in | ||||
** accordance with the Qt Commercial License Agreement provided with the | ||||
** Software or, alternatively, in accordance with the terms contained in | ||||
** a written agreement between you and Digia. | ||||
** | ||||
** If you have questions regarding the use of this file, please use | ||||
** contact form at http://qt.digia.com | ||||
** $QT_END_LICENSE$ | ||||
** | ||||
****************************************************************************/ | ||||
Tero Ahola
|
r836 | #include "qchart.h" | ||
Michal Klocek
|
r1541 | #include "qabstractaxis.h" | ||
Marek Rosa
|
r1805 | #include "qvalueaxis.h" | ||
Tero Ahola
|
r1870 | #include "declarativecategoryaxis.h" | ||
Marek Rosa
|
r1810 | #include "qbarcategoryaxis.h" | ||
Jani Honkonen
|
r1 | #include "declarativechart.h" | ||
Tero Ahola
|
r722 | #include "declarativexypoint.h" | ||
Tero Ahola
|
r215 | #include "declarativelineseries.h" | ||
Tero Ahola
|
r732 | #include "declarativesplineseries.h" | ||
Tero Ahola
|
r847 | #include "declarativeareaseries.h" | ||
Tero Ahola
|
r732 | #include "declarativescatterseries.h" | ||
Tero Ahola
|
r646 | #include "declarativebarseries.h" | ||
Tero Ahola
|
r215 | #include "declarativepieseries.h" | ||
Tero Ahola
|
r2296 | #include "declarativeaxes.h" | ||
Marek Rosa
|
r1669 | #include "qvxymodelmapper.h" | ||
#include "qhxymodelmapper.h" | ||||
#include "qhpiemodelmapper.h" | ||||
#include "qvpiemodelmapper.h" | ||||
#include "qhbarmodelmapper.h" | ||||
#include "qvbarmodelmapper.h" | ||||
Tero Ahola
|
r1928 | #include "declarativemargins.h" | ||
Jani Honkonen
|
r2257 | #include "qarealegendmarker.h" | ||
#include "qbarlegendmarker.h" | ||||
#include "qpielegendmarker.h" | ||||
#include "qxylegendmarker.h" | ||||
Marek Rosa
|
r1942 | #ifndef QT_ON_ARM | ||
Jani Honkonen
|
r2247 | #include "qdatetimeaxis.h" | ||
Marek Rosa
|
r1942 | #endif | ||
Jani Honkonen
|
r2247 | #include <QAbstractItemModel> | ||
#include <QtDeclarative/qdeclarativeextensionplugin.h> | ||||
#include <QtDeclarative/qdeclarative.h> | ||||
Marek Rosa
|
r1942 | |||
Tero Ahola
|
r2117 | QTCOMMERCIALCHART_USE_NAMESPACE | ||
Tero Ahola
|
r2116 | Q_DECLARE_METATYPE(QList<QPieSlice *>) | ||
Q_DECLARE_METATYPE(QList<QBarSet *>) | ||||
Tero Ahola
|
r2296 | Q_DECLARE_METATYPE(QList<QAbstractAxis *>) | ||
Jani Honkonen
|
r2257 | |||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) | ||||
// NOTE: Hackish fixes for Qt5 (beta2). | ||||
// These should not be needed or at least they are not needed in Qt4. | ||||
Tero Ahola
|
r2389 | Q_DECLARE_METATYPE(DeclarativeChart *) | ||
Jani Honkonen
|
r2257 | Q_DECLARE_METATYPE(DeclarativeMargins *) | ||
Q_DECLARE_METATYPE(DeclarativeAreaSeries *) | ||||
Q_DECLARE_METATYPE(DeclarativeBarSeries *) | ||||
Q_DECLARE_METATYPE(DeclarativeLineSeries *) | ||||
Q_DECLARE_METATYPE(DeclarativePieSeries *) | ||||
Q_DECLARE_METATYPE(DeclarativeScatterSeries *) | ||||
Q_DECLARE_METATYPE(DeclarativeSplineSeries *) | ||||
Q_DECLARE_METATYPE(QAbstractAxis *) | ||||
Q_DECLARE_METATYPE(QValueAxis *) | ||||
Q_DECLARE_METATYPE(QBarCategoryAxis *) | ||||
Q_DECLARE_METATYPE(QCategoryAxis *) | ||||
Q_DECLARE_METATYPE(QDateTimeAxis *) | ||||
Q_DECLARE_METATYPE(QLegend *) | ||||
Q_DECLARE_METATYPE(QLegendMarker *) | ||||
Q_DECLARE_METATYPE(QAreaLegendMarker *) | ||||
Q_DECLARE_METATYPE(QBarLegendMarker *) | ||||
Q_DECLARE_METATYPE(QPieLegendMarker *) | ||||
Q_DECLARE_METATYPE(QHPieModelMapper *) | ||||
Q_DECLARE_METATYPE(QHXYModelMapper *) | ||||
Q_DECLARE_METATYPE(QPieModelMapper *) | ||||
Q_DECLARE_METATYPE(QHBarModelMapper *) | ||||
Q_DECLARE_METATYPE(QBarModelMapper *) | ||||
Q_DECLARE_METATYPE(QVBarModelMapper *) | ||||
Q_DECLARE_METATYPE(QVPieModelMapper *) | ||||
Q_DECLARE_METATYPE(QVXYModelMapper *) | ||||
Q_DECLARE_METATYPE(QXYLegendMarker *) | ||||
Q_DECLARE_METATYPE(QXYModelMapper *) | ||||
Jani Honkonen
|
r2250 | Q_DECLARE_METATYPE(QAbstractSeries *) | ||
Jani Honkonen
|
r2257 | Q_DECLARE_METATYPE(QXYSeries *) | ||
Q_DECLARE_METATYPE(QAbstractBarSeries *) | ||||
Q_DECLARE_METATYPE(QBarSeries *) | ||||
Q_DECLARE_METATYPE(QBarSet *) | ||||
Q_DECLARE_METATYPE(QAreaSeries *) | ||||
Q_DECLARE_METATYPE(QHorizontalBarSeries *) | ||||
Q_DECLARE_METATYPE(QHorizontalPercentBarSeries *) | ||||
Q_DECLARE_METATYPE(QHorizontalStackedBarSeries *) | ||||
Q_DECLARE_METATYPE(QLineSeries *) | ||||
Q_DECLARE_METATYPE(QPercentBarSeries *) | ||||
Q_DECLARE_METATYPE(QPieSeries *) | ||||
Q_DECLARE_METATYPE(QPieSlice *) | ||||
Q_DECLARE_METATYPE(QScatterSeries *) | ||||
Q_DECLARE_METATYPE(QSplineSeries *) | ||||
Q_DECLARE_METATYPE(QStackedBarSeries *) | ||||
#endif | ||||
Jani Honkonen
|
r1 | |||
Tero Ahola
|
r2117 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||
Tero Ahola
|
r120 | class ChartQmlPlugin : public QDeclarativeExtensionPlugin | ||
Jani Honkonen
|
r1 | { | ||
Q_OBJECT | ||||
Marek Rosa
|
r2052 | |||
Jani Honkonen
|
r2247 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) | ||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface") | ||||
Marek Rosa
|
r2052 | #endif | ||
Jani Honkonen
|
r2101 | public: | ||
Jani Honkonen
|
r1 | virtual void registerTypes(const char *uri) | ||
{ | ||||
Tero Ahola
|
r120 | Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart")); | ||
Tero Ahola
|
r215 | |||
Tero Ahola
|
r2116 | qRegisterMetaType<QList<QPieSlice *> >(); | ||
qRegisterMetaType<QList<QBarSet *> >(); | ||||
Tero Ahola
|
r2296 | qRegisterMetaType<QList<QAbstractAxis *> >(); | ||
Tero Ahola
|
r2116 | |||
Tero Ahola
|
r1857 | // QtCommercial.Chart 1.0 | ||
Tero Ahola
|
r1130 | qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView"); | ||
Tero Ahola
|
r1532 | qmlRegisterType<DeclarativeXYPoint>(uri, 1, 0, "XYPoint"); | ||
Tero Ahola
|
r196 | qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); | ||
Tero Ahola
|
r215 | qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries"); | ||
Tero Ahola
|
r732 | qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries"); | ||
Tero Ahola
|
r847 | qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries"); | ||
sauimone
|
r1594 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); | ||
Tero Ahola
|
r1318 | qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries"); | ||
qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries"); | ||||
Tero Ahola
|
r215 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); | ||
Tero Ahola
|
r1329 | qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice"); | ||
Tero Ahola
|
r1240 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); | ||
Tero Ahola
|
r1278 | qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper"); | ||
qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper"); | ||||
qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper"); | ||||
qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper"); | ||||
Tero Ahola
|
r1313 | qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper"); | ||
qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper"); | ||||
Tero Ahola
|
r1857 | qmlRegisterType<QValueAxis>(uri, 1, 0, "ValuesAxis"); | ||
Marek Rosa
|
r1808 | qmlRegisterType<QBarCategoryAxis>(uri, 1, 0, "BarCategoriesAxis"); | ||
Tero Ahola
|
r1357 | qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend", | ||
Marek Rosa
|
r1942 | QLatin1String("Trying to create uncreatable: Legend.")); | ||
Tero Ahola
|
r1491 | qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries", | ||
Marek Rosa
|
r1942 | QLatin1String("Trying to create uncreatable: XYSeries.")); | ||
Tero Ahola
|
r1249 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", | ||
Marek Rosa
|
r1942 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); | ||
Tero Ahola
|
r1278 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", | ||
Marek Rosa
|
r1942 | QLatin1String("Trying to create uncreatable: XYModelMapper.")); | ||
Tero Ahola
|
r1249 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", | ||
Marek Rosa
|
r1942 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); | ||
Tero Ahola
|
r1313 | qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper", | ||
Marek Rosa
|
r1942 | QLatin1String("Trying to create uncreatable: BarModelMapper.")); | ||
Tero Ahola
|
r1240 | qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries", | ||
Marek Rosa
|
r1942 | QLatin1String("Trying to create uncreatable: AbstractSeries.")); | ||
Michal Klocek
|
r1604 | qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 0, "AbstractBarSeries", | ||
Marek Rosa
|
r1942 | QLatin1String("Trying to create uncreatable: AbstractBarSeries.")); | ||
Tero Ahola
|
r1550 | qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis", | ||
Marek Rosa
|
r1942 | QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead.")); | ||
Tero Ahola
|
r1908 | qmlRegisterUncreatableType<QBarSet>(uri, 1, 0, "BarSetBase", | ||
Marek Rosa
|
r1942 | QLatin1String("Trying to create uncreatable: BarsetBase.")); | ||
Tero Ahola
|
r1926 | qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries", | ||
Marek Rosa
|
r1942 | QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead.")); | ||
Tero Ahola
|
r2296 | qmlRegisterUncreatableType<DeclarativeAxes>(uri, 1, 0, "DeclarativeAxes", | ||
QLatin1String("Trying to create uncreatable: DeclarativeAxes.")); | ||||
Tero Ahola
|
r1857 | |||
// QtCommercial.Chart 1.1 | ||||
Tero Ahola
|
r1928 | qmlRegisterType<DeclarativeChart, 1>(uri, 1, 1, "ChartView"); | ||
Tero Ahola
|
r1857 | 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"); | ||||
Tero Ahola
|
r2249 | qmlRegisterType<QValueAxis>(uri, 1, 1, "ValueAxis"); | ||
Marek Rosa
|
r1942 | #ifndef QT_ON_ARM | ||
Tero Ahola
|
r1870 | qmlRegisterType<QDateTimeAxis>(uri, 1, 1, "DateTimeAxis"); | ||
Marek Rosa
|
r1942 | #endif | ||
Tero Ahola
|
r1870 | qmlRegisterType<DeclarativeCategoryAxis>(uri, 1, 1, "CategoryAxis"); | ||
qmlRegisterType<DeclarativeCategoryRange>(uri, 1, 1, "CategoryRange"); | ||||
Tero Ahola
|
r1857 | qmlRegisterType<QBarCategoryAxis>(uri, 1, 1, "BarCategoryAxis"); | ||
Tero Ahola
|
r1928 | qmlRegisterUncreatableType<DeclarativeMargins>(uri, 1, 1, "Margins", | ||
Marek Rosa
|
r1942 | QLatin1String("Trying to create uncreatable: Margins.")); | ||
Michal Klocek
|
r2090 | |||
// QtCommercial.Chart 1.2 | ||||
qmlRegisterType<DeclarativeChart, 2>(uri, 1, 2, "ChartView"); | ||||
Tero Ahola
|
r2296 | 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"); | ||||
Jani Honkonen
|
r1 | } | ||
}; | ||||
#include "plugin.moc" | ||||
Tero Ahola
|
r120 | QTCOMMERCIALCHART_END_NAMESPACE | ||
QTCOMMERCIALCHART_USE_NAMESPACE | ||||
Jani Honkonen
|
r2247 | #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) | ||
Marek Rosa
|
r2052 | Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin)) | ||
#endif | ||||