diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2014-09-18 14:50:03 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2014-09-18 15:11:07 +0300 |
commit | e26d82d56bc95d0e2b06bf41813e885486a2ea6c (patch) | |
tree | b495952484a52b78a40f64b6e28e145e925348ff | |
parent | 682630e62d588dace079a717e6cd4e43275a2db4 (diff) |
Misc fixes
- Default value for localizeNumbers is now false, as it would look
weird if numbers were localized in otherwise unlocalized app.
- Added locale property to qml ChartView.
- Added registrations for latest revisions of all QML types for 2.0,
since apparently this is necessary to make them visible when
importing Charts 2.0
Change-Id: I46997b3af4458c6dbf6755a19e01115d5393013a
Reviewed-by: Titta Heikkala <titta.heikkala@digia.com>
-rw-r--r-- | plugins/declarative/declarativechart.cpp | 28 | ||||
-rw-r--r-- | plugins/declarative/declarativechart.h | 5 | ||||
-rw-r--r-- | plugins/declarative/plugin.cpp | 59 | ||||
-rw-r--r-- | src/axis/chartaxiselement.cpp | 2 | ||||
-rw-r--r-- | src/chartpresenter.cpp | 2 | ||||
-rw-r--r-- | src/qchart.cpp | 2 |
6 files changed, 94 insertions, 4 deletions
diff --git a/plugins/declarative/declarativechart.cpp b/plugins/declarative/declarativechart.cpp index b5b74c7c..fec441d5 100644 --- a/plugins/declarative/declarativechart.cpp +++ b/plugins/declarative/declarativechart.cpp @@ -180,7 +180,20 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE 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{true}. + 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 */ /*! @@ -732,6 +745,19 @@ bool DeclarativeChart::localizeNumbers() const return m_chart->localizeNumbers(); } +void QtCommercialChart::DeclarativeChart::setLocale(const QLocale &locale) +{ + if (m_chart->locale() != locale) { + m_chart->setLocale(locale); + emit localeChanged(); + } +} + +QLocale QtCommercialChart::DeclarativeChart::locale() const +{ + return m_chart->locale(); +} + int DeclarativeChart::count() { return m_chart->series().count(); diff --git a/plugins/declarative/declarativechart.h b/plugins/declarative/declarativechart.h index 600dbf5c..a1b40d80 100644 --- a/plugins/declarative/declarativechart.h +++ b/plugins/declarative/declarativechart.h @@ -34,6 +34,7 @@ #endif #include "qchart.h" +#include <QtCore/QLocale> QTCOMMERCIALCHART_BEGIN_NAMESPACE @@ -68,6 +69,7 @@ class DeclarativeChart : public QDECLARATIVE_PAINTED_ITEM Q_PROPERTY(QDeclarativeListProperty<QAbstractAxis> axes READ axes REVISION 2) #endif 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) @@ -145,6 +147,8 @@ public: 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); @@ -201,6 +205,7 @@ Q_SIGNALS: 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); diff --git a/plugins/declarative/plugin.cpp b/plugins/declarative/plugin.cpp index 6498456c..1dad0dc0 100644 --- a/plugins/declarative/plugin.cpp +++ b/plugins/declarative/plugin.cpp @@ -258,7 +258,66 @@ public: qmlRegisterType<QVBoxPlotModelMapper>(uri, 2, 0, "VBoxPlotModelMapper"); qmlRegisterUncreatableType<QBoxPlotModelMapper>(uri, 2, 0, "BoxPlotModelMapper", QLatin1String("Trying to create uncreatable: BoxPlotModelMapper.")); + + // Re-register latest revisions for 2.0 qmlRegisterType<DeclarativeChart, 4>(uri, 2, 0, "ChartView"); + qmlRegisterType<DeclarativeLineSeries, 3>(uri, 2, 0, "LineSeries"); + qmlRegisterType<DeclarativeScatterSeries, 4>(uri, 2, 0, "ScatterSeries"); + 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<DeclarativeHorizontalBarSeries, 2>(uri, 2, 0, "HorizontalBarSeries"); + qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 2>(uri, 2, 0, "HorizontalStackedBarSeries"); + qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 2>(uri, 2, 0, "HorizontalPercentBarSeries"); + qmlRegisterType<DeclarativeBarSet, 2>(uri, 2, 0, "BarSet"); + qmlRegisterType<DeclarativeBoxPlotSeries, 1>(uri, 2, 0, "BoxPlotSeries"); + qmlRegisterType<DeclarativeBoxSet, 1>(uri, 2, 0, "BoxSet"); + qmlRegisterType<DeclarativePieSlice>(uri, 2, 0, "PieSlice"); + qmlRegisterType<DeclarativePieSeries>(uri, 2, 0, "PieSeries"); + qmlRegisterType<DeclarativeXYPoint>(uri, 2, 0, "XYPoint"); + 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"); + 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.")); + qmlRegisterType<DeclarativePolarChart>(uri, 2, 0, "PolarChartView"); + qmlRegisterType<QLogValueAxis>(uri, 2, 0, "LogValueAxis"); } }; diff --git a/src/axis/chartaxiselement.cpp b/src/axis/chartaxiselement.cpp index 310555e7..c006b166 100644 --- a/src/axis/chartaxiselement.cpp +++ b/src/axis/chartaxiselement.cpp @@ -29,7 +29,7 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE static const char *labelFormatMatchString = "%[\\-\\+#\\s\\d\\.lhjztL]*([dicuoxfegXFEG])"; -static const char *labelFormatMatchLocalizedString = "^([^%]*)%\\.?(\\d)*([defgiEG])(.*)$"; +static const char *labelFormatMatchLocalizedString = "^([^%]*)%\\.(\\d+)([defgiEG])(.*)$"; static QRegExp *labelFormatMatcher = 0; static QRegExp *labelFormatMatcherLocalized = 0; class StaticLabelFormatMatcherDeleter diff --git a/src/chartpresenter.cpp b/src/chartpresenter.cpp index 619f400f..e83a7fbc 100644 --- a/src/chartpresenter.cpp +++ b/src/chartpresenter.cpp @@ -45,7 +45,7 @@ ChartPresenter::ChartPresenter(QChart *chart, QChart::ChartType type) m_background(0), m_plotAreaBackground(0), m_title(0), - m_localizeNumbers(true) + m_localizeNumbers(false) { if (type == QChart::ChartTypeCartesian) m_layout = new CartesianChartLayout(this); diff --git a/src/qchart.cpp b/src/qchart.cpp index b103ed9b..16391b9a 100644 --- a/src/qchart.cpp +++ b/src/qchart.cpp @@ -150,7 +150,7 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE When \c{true}, all generated numbers appearing in various series and axis labels will be localized using the QLocale set with the locale property. When \c{false}, the "C" locale is always used. - Defaults to \c{true}. + Defaults to \c{false}. \note This property doesn't affect QDateTimeAxis labels, which always use the QLocale set with the locale property. |