##// END OF EJS Templates
Added QChart::locale property...
Miikka Heikkinen -
r2708:b421e87aa00a
parent child
Show More
@@ -180,7 +180,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
180 When \c{true}, all generated numbers appearing in various series and axis labels will be
180 When \c{true}, all generated numbers appearing in various series and axis labels will be
181 localized using the default QLocale of the application, which defaults to the system locale.
181 localized using the default QLocale of the application, which defaults to the system locale.
182 When \c{false}, the "C" locale is always used.
182 When \c{false}, the "C" locale is always used.
183 Defaults to \c{false}.
183 Defaults to \c{true}.
184 */
184 */
185
185
186 /*!
186 /*!
@@ -200,7 +200,7 Q_SIGNALS:
200 void seriesRemoved(QAbstractSeries *series);
200 void seriesRemoved(QAbstractSeries *series);
201 Q_REVISION(3) void plotAreaColorChanged();
201 Q_REVISION(3) void plotAreaColorChanged();
202 Q_REVISION(3) void backgroundRoundnessChanged(qreal diameter);
202 Q_REVISION(3) void backgroundRoundnessChanged(qreal diameter);
203 Q_REVISION(4) bool localizeNumbersChanged();
203 Q_REVISION(4) void localizeNumbersChanged();
204
204
205 private Q_SLOTS:
205 private Q_SLOTS:
206 void changeMinimumMargins(int top, int bottom, int left, int right);
206 void changeMinimumMargins(int top, int bottom, int left, int right);
@@ -385,7 +385,7 QStringList ChartAxisElement::createDateTimeLabels(qreal min, qreal max,int tick
385 n++;
385 n++;
386 for (int i = 0; i < ticks; i++) {
386 for (int i = 0; i < ticks; i++) {
387 qreal value = min + (i * (max - min) / (ticks - 1));
387 qreal value = min + (i * (max - min) / (ticks - 1));
388 labels << QDateTime::fromMSecsSinceEpoch(value).toString(format);
388 labels << presenter()->locale().toString(QDateTime::fromMSecsSinceEpoch(value), format);
389 }
389 }
390 return labels;
390 return labels;
391 }
391 }
@@ -149,6 +149,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
149 \property QDateTimeAxis::format
149 \property QDateTimeAxis::format
150 The format string that is used when creating label for the axis out of a QDateTime object.
150 The format string that is used when creating label for the axis out of a QDateTime object.
151 Check QDateTime documentation for information on how the string should be defined.
151 Check QDateTime documentation for information on how the string should be defined.
152
153 \sa QChart::locale
152 */
154 */
153 /*!
155 /*!
154 \qmlproperty string DateTimeAxis::format
156 \qmlproperty string DateTimeAxis::format
@@ -45,7 +45,7 ChartPresenter::ChartPresenter(QChart *chart, QChart::ChartType type)
45 m_background(0),
45 m_background(0),
46 m_plotAreaBackground(0),
46 m_plotAreaBackground(0),
47 m_title(0),
47 m_title(0),
48 m_localizeNumbers(false)
48 m_localizeNumbers(true)
49 {
49 {
50 if (type == QChart::ChartTypeCartesian)
50 if (type == QChart::ChartTypeCartesian)
51 m_layout = new CartesianChartLayout(this);
51 m_layout = new CartesianChartLayout(this);
@@ -352,12 +352,12 void ChartPresenter::setLocalizeNumbers(bool localize)
352 m_layout->invalidate();
352 m_layout->invalidate();
353 }
353 }
354
354
355 bool ChartPresenter::localizeNumbers() const
355 void ChartPresenter::setLocale(const QLocale &locale)
356 {
356 {
357 return m_localizeNumbers;
357 m_locale = locale;
358 m_layout->invalidate();
358 }
359 }
359
360
360
361 AbstractChartLayout *ChartPresenter::layout()
361 AbstractChartLayout *ChartPresenter::layout()
362 {
362 {
363 return m_layout;
363 return m_layout;
@@ -131,7 +131,9 public:
131 bool isBackgroundDropShadowEnabled() const;
131 bool isBackgroundDropShadowEnabled() const;
132
132
133 void setLocalizeNumbers(bool localize);
133 void setLocalizeNumbers(bool localize);
134 bool localizeNumbers() const;
134 inline bool localizeNumbers() const { return m_localizeNumbers; }
135 void setLocale(const QLocale &locale);
136 inline const QLocale &locale() const { return m_locale; }
135
137
136 void setVisible(bool visible);
138 void setVisible(bool visible);
137
139
@@ -154,7 +156,6 public:
154 inline static qreal textMargin() { return qreal(0.5); }
156 inline static qreal textMargin() { return qreal(0.5); }
155
157
156 QString numberToString(double value, char f = 'g', int prec = 6);
158 QString numberToString(double value, char f = 'g', int prec = 6);
157 inline const QLocale &locale() const { return m_locale; }
158
159
159 private:
160 private:
160 void createBackgroundItem();
161 void createBackgroundItem();
@@ -148,9 +148,24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
148 \property QChart::localizeNumbers
148 \property QChart::localizeNumbers
149 \since QtCharts 2.0
149 \since QtCharts 2.0
150 When \c{true}, all generated numbers appearing in various series and axis labels will be
150 When \c{true}, all generated numbers appearing in various series and axis labels will be
151 localized using the default QLocale of the application, which defaults to the system locale.
151 localized using the QLocale set with the locale property.
152 When \c{false}, the "C" locale is always used.
152 When \c{false}, the "C" locale is always used.
153 Defaults to \c{false}.
153 Defaults to \c{true}.
154 \note This property doesn't affect QDateTimeAxis labels, which always use the QLocale set with
155 the locale property.
156
157 \sa locale
158 */
159
160 /*!
161 \property QChart::locale
162 \since QtCharts 2.0
163 Sets the locale used to format various chart labels when localizeNumbers is \c{true}.
164 This also determines the locale used to format QDateTimeAxis labels regardless of
165 localizeNumbers property.
166 Defaults to application default locale at the time the chart is constructed.
167
168 \sa localizeNumbers
154 */
169 */
155
170
156 /*!
171 /*!
@@ -580,6 +595,16 bool QChart::localizeNumbers() const
580 return d_ptr->m_presenter->localizeNumbers();
595 return d_ptr->m_presenter->localizeNumbers();
581 }
596 }
582
597
598 void QChart::setLocale(const QLocale &locale)
599 {
600 d_ptr->m_presenter->setLocale(locale);
601 }
602
603 QLocale QChart::locale() const
604 {
605 return d_ptr->m_presenter->locale();
606 }
607
583 void QChart::setAnimationOptions(AnimationOptions options)
608 void QChart::setAnimationOptions(AnimationOptions options)
584 {
609 {
585 d_ptr->m_presenter->setAnimationOptions(options);
610 d_ptr->m_presenter->setAnimationOptions(options);
@@ -50,6 +50,7 class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsWidget
50 Q_PROPERTY(QChart::ChartType chartType READ chartType)
50 Q_PROPERTY(QChart::ChartType chartType READ chartType)
51 Q_PROPERTY(bool plotAreaBackgroundVisible READ isPlotAreaBackgroundVisible WRITE setPlotAreaBackgroundVisible)
51 Q_PROPERTY(bool plotAreaBackgroundVisible READ isPlotAreaBackgroundVisible WRITE setPlotAreaBackgroundVisible)
52 Q_PROPERTY(bool localizeNumbers READ localizeNumbers WRITE setLocalizeNumbers)
52 Q_PROPERTY(bool localizeNumbers READ localizeNumbers WRITE setLocalizeNumbers)
53 Q_PROPERTY(QLocale locale READ locale WRITE setLocale)
53 Q_ENUMS(ChartTheme)
54 Q_ENUMS(ChartTheme)
54 Q_ENUMS(AnimationOption)
55 Q_ENUMS(AnimationOption)
55 Q_ENUMS(ChartType)
56 Q_ENUMS(ChartType)
@@ -154,6 +155,8 public:
154 bool isPlotAreaBackgroundVisible() const;
155 bool isPlotAreaBackgroundVisible() const;
155 void setLocalizeNumbers(bool localize);
156 void setLocalizeNumbers(bool localize);
156 bool localizeNumbers() const;
157 bool localizeNumbers() const;
158 void setLocale(const QLocale &locale);
159 QLocale locale() const;
157
160
158 QPointF mapToValue(const QPointF &position, QAbstractSeries *series = 0);
161 QPointF mapToValue(const QPointF &position, QAbstractSeries *series = 0);
159 QPointF mapToPosition(const QPointF &value, QAbstractSeries *series = 0);
162 QPointF mapToPosition(const QPointF &value, QAbstractSeries *series = 0);
General Comments 0
You need to be logged in to leave comments. Login now