summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTero Ahola <tero.ahola@digia.com>2012-09-06 12:35:48 +0300
committerTero Ahola <tero.ahola@digia.com>2012-09-06 14:44:00 +0300
commitdf31e46fa48c59c23918696ef05d39e8e7b17257 (patch)
treeecc0d612e5178304574ef62622933981de70c9d9
parent4e1c0d187ea1c715e15a8db9160e7f090043f70f (diff)
Property for QDateTimeAxis::format and a QML demo for axes
-rw-r--r--demos/demos.pro3
-rw-r--r--demos/qmlaxes/main.cpp36
-rw-r--r--demos/qmlaxes/qml/qmlaxes/View1.qml67
-rw-r--r--demos/qmlaxes/qml/qmlaxes/View2.qml59
-rw-r--r--demos/qmlaxes/qml/qmlaxes/View3.qml67
-rw-r--r--demos/qmlaxes/qml/qmlaxes/loader.qml37
-rw-r--r--demos/qmlaxes/qml/qmlaxes/main.qml90
-rw-r--r--demos/qmlaxes/qmlapplicationviewer/qmlapplicationviewer.cpp200
-rw-r--r--demos/qmlaxes/qmlapplicationviewer/qmlapplicationviewer.h47
-rw-r--r--demos/qmlaxes/qmlapplicationviewer/qmlapplicationviewer.pri13
-rw-r--r--demos/qmlaxes/qmlaxes.pro8
-rw-r--r--demos/qmlaxes/resources.qrc9
-rw-r--r--doc/src/demos.qdoc1
-rw-r--r--src/axis/datetimeaxis/qdatetimeaxis.cpp38
-rw-r--r--src/axis/datetimeaxis/qdatetimeaxis.h2
15 files changed, 664 insertions, 13 deletions
diff --git a/demos/demos.pro b/demos/demos.pro
index 9cea903e..4c663072 100644
--- a/demos/demos.pro
+++ b/demos/demos.pro
@@ -12,7 +12,8 @@ SUBDIRS += piechartcustomization \
qmlf1legends \
qmlcustomizations \
qmlcustommodel \
- chartinteractions
+ chartinteractions \
+ qmlaxes
contains(QT_CONFIG, opengl) {
SUBDIRS += chartthemes \
diff --git a/demos/qmlaxes/main.cpp b/demos/qmlaxes/main.cpp
new file mode 100644
index 00000000..e30437dd
--- /dev/null
+++ b/demos/qmlaxes/main.cpp
@@ -0,0 +1,36 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 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 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$
+**
+****************************************************************************/
+
+#include <QtGui/QApplication>
+#include <QDeclarativeEngine>
+#include "qmlapplicationviewer.h"
+
+Q_DECL_EXPORT int main(int argc, char *argv[])
+{
+ QScopedPointer<QApplication> app(createApplication(argc, argv));
+ QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create());
+
+ viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
+ viewer->setSource(QUrl("qrc:/qml/qmlaxes/loader.qml"));
+ viewer->setRenderHint(QPainter::Antialiasing, true);
+ viewer->showExpanded();
+
+ return app->exec();
+}
diff --git a/demos/qmlaxes/qml/qmlaxes/View1.qml b/demos/qmlaxes/qml/qmlaxes/View1.qml
new file mode 100644
index 00000000..64feaa14
--- /dev/null
+++ b/demos/qmlaxes/qml/qmlaxes/View1.qml
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 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 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$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+import QtCommercial.Chart 1.1
+
+Rectangle {
+ anchors.fill: parent
+
+ //![1]
+ ChartView {
+ title: "Two Series, Common Axes"
+ anchors.fill: parent
+ legend.visible: false
+
+ ValueAxis {
+ id: axisX
+ min: 0
+ max: 10
+ tickCount: 5
+ }
+
+ ValueAxis {
+ id: axisY
+ min: -0.5
+ max: 1.5
+ }
+
+ LineSeries {
+ id: series1
+ axisX: axisX
+ axisY: axisY
+ }
+
+ ScatterSeries {
+ id: series2
+ axisX: axisX
+ axisY: axisY
+ }
+ }
+
+ // Add data dynamically to the series
+ Component.onCompleted: {
+ for (var i = 0; i <= 10; i++) {
+ series1.append(i, Math.random());
+ series2.append(i, Math.random());
+ }
+ }
+ //![1]
+}
diff --git a/demos/qmlaxes/qml/qmlaxes/View2.qml b/demos/qmlaxes/qml/qmlaxes/View2.qml
new file mode 100644
index 00000000..8cf48b73
--- /dev/null
+++ b/demos/qmlaxes/qml/qmlaxes/View2.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 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 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$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+import QtCommercial.Chart 1.1
+
+Rectangle {
+ anchors.fill: parent
+
+ //![1]
+ ChartView {
+ title: "Accurate Historical Data"
+ anchors.fill: parent
+ legend.visible: false
+
+ LineSeries {
+ axisX: DateTimeAxis {
+ format: "yyyy MMM"
+ tickCount: 5
+ }
+ axisY: ValueAxis {
+ min: 0
+ max: 150
+ }
+
+ // Please note that month in JavaScript months are zero based, so 2 means March
+ XYPoint { x: toMsecsSinceEpoch(new Date(1950, 2, 15)); y: 5 }
+ XYPoint { x: toMsecsSinceEpoch(new Date(1970, 0, 1)); y: 50 }
+ XYPoint { x: toMsecsSinceEpoch(new Date(1987, 12, 31)); y: 102 }
+ XYPoint { x: toMsecsSinceEpoch(new Date(1998, 7, 1)); y: 100 }
+ XYPoint { x: toMsecsSinceEpoch(new Date(2012, 8, 2)); y: 110 }
+ }
+ }
+
+ // DateTimeAxis is based on QDateTimes so we must convert our JavaScript dates to
+ // milliseconds since epoch to make them match the DateTimeAxis values
+ function toMsecsSinceEpoch(date) {
+ var msecs = date.getTime();
+ return msecs;
+ }
+ //![1]
+}
diff --git a/demos/qmlaxes/qml/qmlaxes/View3.qml b/demos/qmlaxes/qml/qmlaxes/View3.qml
new file mode 100644
index 00000000..dedf0b9a
--- /dev/null
+++ b/demos/qmlaxes/qml/qmlaxes/View3.qml
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 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 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$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+import QtCommercial.Chart 1.1
+
+Rectangle {
+ anchors.fill: parent
+
+ //![1]
+ ChartView {
+ title: "Numerical Data for Dummies"
+ anchors.fill: parent
+ legend.visible: false
+
+ LineSeries {
+ axisY: CategoryAxis {
+ min: 0
+ max: 30
+ CategoryRange {
+ label: "critical"
+ endValue: 2
+ }
+ CategoryRange {
+ label: "low"
+ endValue: 4
+ }
+ CategoryRange {
+ label: "normal"
+ endValue: 7
+ }
+ CategoryRange {
+ label: "high"
+ endValue: 15
+ }
+ CategoryRange {
+ label: "extremely high"
+ endValue: 30
+ }
+ }
+
+ XYPoint { x: 0; y: 4.3 }
+ XYPoint { x: 1; y: 4.1 }
+ XYPoint { x: 2; y: 4.7 }
+ XYPoint { x: 3; y: 3.9 }
+ XYPoint { x: 4; y: 5.2 }
+ }
+ }
+ //![1]
+}
diff --git a/demos/qmlaxes/qml/qmlaxes/loader.qml b/demos/qmlaxes/qml/qmlaxes/loader.qml
new file mode 100644
index 00000000..7668f0c6
--- /dev/null
+++ b/demos/qmlaxes/qml/qmlaxes/loader.qml
@@ -0,0 +1,37 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 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 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$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+
+Item {
+ id: container
+ width: 400
+ height: 300
+ Component.onCompleted: {
+ var co = Qt.createComponent("main.qml")
+ if (co.status == Component.Ready) {
+ var o = co.createObject(container)
+ } else {
+ console.log(co.errorString())
+ console.log("QtCommercial.Chart 1.1 not available")
+ console.log("Please use correct QML_IMPORT_PATH export")
+ }
+ }
+}
diff --git a/demos/qmlaxes/qml/qmlaxes/main.qml b/demos/qmlaxes/qml/qmlaxes/main.qml
new file mode 100644
index 00000000..1cc96ca0
--- /dev/null
+++ b/demos/qmlaxes/qml/qmlaxes/main.qml
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 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 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$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+
+Rectangle {
+ width: parent.width
+ height: parent.height
+ property int viewNumber: 1
+ property int viewCount: 3
+
+ Loader {
+ id: loader
+ anchors.fill: parent
+ source: "View" + viewNumber + ".qml";
+ }
+
+ Rectangle {
+ id: infoText
+ anchors.centerIn: parent
+ width: parent.width
+ height: 40
+ color: "black"
+ Text {
+ color: "white"
+ anchors.centerIn: parent
+ text: "Use left and right arrow keys to navigate"
+ }
+
+ Behavior on opacity {
+ NumberAnimation { duration: 400 }
+ }
+ }
+
+ MouseArea {
+ focus: true
+ anchors.fill: parent
+ onClicked: {
+ if (infoText.opacity > 0) {
+ infoText.opacity = 0.0;
+ } else {
+ nextView();
+ }
+ }
+ Keys.onPressed: {
+ if (infoText.opacity > 0) {
+ infoText.opacity = 0.0;
+ } else {
+ if (event.key == Qt.Key_Left) {
+ previousView();
+ } else {
+ nextView();
+ }
+ }
+ }
+ }
+
+ function nextView() {
+ var i = viewNumber + 1;
+ if (i > viewCount)
+ viewNumber = 1;
+ else
+ viewNumber = i;
+ }
+
+ function previousView() {
+ var i = viewNumber - 1;
+ if (i <= 0)
+ viewNumber = viewCount;
+ else
+ viewNumber = i;
+ }
+}
diff --git a/demos/qmlaxes/qmlapplicationviewer/qmlapplicationviewer.cpp b/demos/qmlaxes/qmlapplicationviewer/qmlapplicationviewer.cpp
new file mode 100644
index 00000000..8ba6e886
--- /dev/null
+++ b/demos/qmlaxes/qmlapplicationviewer/qmlapplicationviewer.cpp
@@ -0,0 +1,200 @@
+// checksum 0x78c version 0x60010
+/*
+ This file was generated by the Qt Quick Application wizard of Qt Creator.
+ QmlApplicationViewer is a convenience class containing mobile device specific
+ code such as screen orientation handling. Also QML paths and debugging are
+ handled here.
+ It is recommended not to modify this file, since newer versions of Qt Creator
+ may offer an updated version of it.
+*/
+
+#include "qmlapplicationviewer.h"
+
+#include <QtCore/QDir>
+#include <QtCore/QFileInfo>
+#include <QtDeclarative/QDeclarativeComponent>
+#include <QtDeclarative/QDeclarativeEngine>
+#include <QtDeclarative/QDeclarativeContext>
+#include <QtGui/QApplication>
+
+#include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN
+
+#ifdef HARMATTAN_BOOSTER
+#include <MDeclarativeCache>
+#endif
+
+#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
+
+#include <qt_private/qdeclarativedebughelper_p.h>
+
+#if !defined(NO_JSDEBUGGER)
+#include <jsdebuggeragent.h>
+#endif
+#if !defined(NO_QMLOBSERVER)
+#include <qdeclarativeviewobserver.h>
+#endif
+
+// Enable debugging before any QDeclarativeEngine is created
+struct QmlJsDebuggingEnabler
+{
+ QmlJsDebuggingEnabler()
+ {
+ QDeclarativeDebugHelper::enableDebugging();
+ }
+};
+
+// Execute code in constructor before first QDeclarativeEngine is instantiated
+static QmlJsDebuggingEnabler enableDebuggingHelper;
+
+#endif // QMLJSDEBUGGER
+
+class QmlApplicationViewerPrivate
+{
+ QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {}
+
+ QString mainQmlFile;
+ QDeclarativeView *view;
+ friend class QmlApplicationViewer;
+ QString adjustPath(const QString &path);
+};
+
+QString QmlApplicationViewerPrivate::adjustPath(const QString &path)
+{
+#ifdef Q_OS_UNIX
+#ifdef Q_OS_MAC
+ if (!QDir::isAbsolutePath(path))
+ return QCoreApplication::applicationDirPath()
+ + QLatin1String("/../Resources/") + path;
+#else
+ QString pathInInstallDir;
+ const QString applicationDirPath = QCoreApplication::applicationDirPath();
+ pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path);
+
+ if (QFileInfo(pathInInstallDir).exists())
+ return pathInInstallDir;
+#endif
+#endif
+ return path;
+}
+
+QmlApplicationViewer::QmlApplicationViewer(QWidget *parent)
+ : QDeclarativeView(parent)
+ , d(new QmlApplicationViewerPrivate(this))
+{
+ connect(engine(), SIGNAL(quit()), SLOT(close()));
+ setResizeMode(QDeclarativeView::SizeRootObjectToView);
+ // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in
+#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
+#if !defined(NO_JSDEBUGGER)
+ new QmlJSDebugger::JSDebuggerAgent(d->view->engine());
+#endif
+#if !defined(NO_QMLOBSERVER)
+ new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view);
+#endif
+#endif
+}
+
+QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent)
+ : QDeclarativeView(parent)
+ , d(new QmlApplicationViewerPrivate(view))
+{
+ connect(view->engine(), SIGNAL(quit()), view, SLOT(close()));
+ view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+ // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in
+#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
+#if !defined(NO_JSDEBUGGER)
+ new QmlJSDebugger::JSDebuggerAgent(d->view->engine());
+#endif
+#if !defined(NO_QMLOBSERVER)
+ new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view);
+#endif
+#endif
+}
+
+QmlApplicationViewer::~QmlApplicationViewer()
+{
+ delete d;
+}
+
+QmlApplicationViewer *QmlApplicationViewer::create()
+{
+#ifdef HARMATTAN_BOOSTER
+ return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0);
+#else
+ return new QmlApplicationViewer();
+#endif
+}
+
+void QmlApplicationViewer::setMainQmlFile(const QString &file)
+{
+ d->mainQmlFile = d->adjustPath(file);
+ d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile));
+}
+
+void QmlApplicationViewer::addImportPath(const QString &path)
+{
+ d->view->engine()->addImportPath(d->adjustPath(path));
+}
+
+void QmlApplicationViewer::setOrientation(ScreenOrientation orientation)
+{
+#if defined(Q_OS_SYMBIAN)
+ // If the version of Qt on the device is < 4.7.2, that attribute won't work
+ if (orientation != ScreenOrientationAuto) {
+ const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.'));
+ if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) {
+ qWarning("Screen orientation locking only supported with Qt 4.7.2 and above");
+ return;
+ }
+ }
+#endif // Q_OS_SYMBIAN
+
+ Qt::WidgetAttribute attribute;
+ switch (orientation) {
+#if QT_VERSION < 0x040702
+ // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
+ case ScreenOrientationLockPortrait:
+ attribute = static_cast<Qt::WidgetAttribute>(128);
+ break;
+ case ScreenOrientationLockLandscape:
+ attribute = static_cast<Qt::WidgetAttribute>(129);
+ break;
+ default:
+ case ScreenOrientationAuto:
+ attribute = static_cast<Qt::WidgetAttribute>(130);
+ break;
+#else // QT_VERSION < 0x040702
+ case ScreenOrientationLockPortrait:
+ attribute = Qt::WA_LockPortraitOrientation;
+ break;
+ case ScreenOrientationLockLandscape:
+ attribute = Qt::WA_LockLandscapeOrientation;
+ break;
+ default:
+ case ScreenOrientationAuto:
+ attribute = Qt::WA_AutoOrientation;
+ break;
+#endif // QT_VERSION < 0x040702
+ };
+ setAttribute(attribute, true);
+}
+
+void QmlApplicationViewer::showExpanded()
+{
+#if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR)
+ d->view->showFullScreen();
+#elif defined(Q_WS_MAEMO_5)
+ d->view->showMaximized();
+#else
+ d->view->show();
+#endif
+}
+
+QApplication *createApplication(int &argc, char **argv)
+{
+#ifdef HARMATTAN_BOOSTER
+ return MDeclarativeCache::qApplication(argc, argv);
+#else
+ return new QApplication(argc, argv);
+#endif
+}
diff --git a/demos/qmlaxes/qmlapplicationviewer/qmlapplicationviewer.h b/demos/qmlaxes/qmlapplicationviewer/qmlapplicationviewer.h
new file mode 100644
index 00000000..f8008f5c
--- /dev/null
+++ b/demos/qmlaxes/qmlapplicationviewer/qmlapplicationviewer.h
@@ -0,0 +1,47 @@
+// checksum 0x82ed version 0x60010
+/*
+ This file was generated by the Qt Quick Application wizard of Qt Creator.
+ QmlApplicationViewer is a convenience class containing mobile device specific
+ code such as screen orientation handling. Also QML paths and debugging are
+ handled here.
+ It is recommended not to modify this file, since newer versions of Qt Creator
+ may offer an updated version of it.
+*/
+
+#ifndef QMLAPPLICATIONVIEWER_H
+#define QMLAPPLICATIONVIEWER_H
+
+#include <QtDeclarative/QDeclarativeView>
+
+class QmlApplicationViewer : public QDeclarativeView
+{
+ Q_OBJECT
+
+public:
+ enum ScreenOrientation {
+ ScreenOrientationLockPortrait,
+ ScreenOrientationLockLandscape,
+ ScreenOrientationAuto
+ };
+
+ explicit QmlApplicationViewer(QWidget *parent = 0);
+ virtual ~QmlApplicationViewer();
+
+ static QmlApplicationViewer *create();
+
+ void setMainQmlFile(const QString &file);
+ void addImportPath(const QString &path);
+
+ // Note that this will only have an effect on Symbian and Fremantle.
+ void setOrientation(ScreenOrientation orientation);
+
+ void showExpanded();
+
+private:
+ explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent);
+ class QmlApplicationViewerPrivate *d;
+};
+
+QApplication *createApplication(int &argc, char **argv);
+
+#endif // QMLAPPLICATIONVIEWER_H
diff --git a/demos/qmlaxes/qmlapplicationviewer/qmlapplicationviewer.pri b/demos/qmlaxes/qmlapplicationviewer/qmlapplicationviewer.pri
new file mode 100644
index 00000000..567c6dc6
--- /dev/null
+++ b/demos/qmlaxes/qmlapplicationviewer/qmlapplicationviewer.pri
@@ -0,0 +1,13 @@
+QT += declarative
+
+SOURCES += $$PWD/qmlapplicationviewer.cpp
+HEADERS += $$PWD/qmlapplicationviewer.h
+INCLUDEPATH += $$PWD
+
+# Include JS debugger library if QMLJSDEBUGGER_PATH is set
+!isEmpty(QMLJSDEBUGGER_PATH) {
+ include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri)
+} else {
+ DEFINES -= QMLJSDEBUGGER
+}
+
diff --git a/demos/qmlaxes/qmlaxes.pro b/demos/qmlaxes/qmlaxes.pro
new file mode 100644
index 00000000..82294279
--- /dev/null
+++ b/demos/qmlaxes/qmlaxes.pro
@@ -0,0 +1,8 @@
+!include( ../demos.pri ) {
+ error( "Couldn't find the demos.pri file!" )
+}
+
+RESOURCES += resources.qrc
+SOURCES += main.cpp
+
+include(qmlapplicationviewer/qmlapplicationviewer.pri)
diff --git a/demos/qmlaxes/resources.qrc b/demos/qmlaxes/resources.qrc
new file mode 100644
index 00000000..29e173d4
--- /dev/null
+++ b/demos/qmlaxes/resources.qrc
@@ -0,0 +1,9 @@
+<RCC>
+ <qresource prefix="/">
+ <file>qml/qmlaxes/loader.qml</file>
+ <file>qml/qmlaxes/main.qml</file>
+ <file>qml/qmlaxes/View1.qml</file>
+ <file>qml/qmlaxes/View2.qml</file>
+ <file>qml/qmlaxes/View3.qml</file>
+ </qresource>
+</RCC>
diff --git a/doc/src/demos.qdoc b/doc/src/demos.qdoc
index 4f7a0999..6584f92e 100644
--- a/doc/src/demos.qdoc
+++ b/doc/src/demos.qdoc
@@ -18,6 +18,7 @@
<li><a href="demos-nesteddonuts.html">Nested donuts chart</a></li>
<li><a href="demos-piechartcustomization.html">Pie chart customization</a></li>
<li><a href="demos-qmlchart.html">Qml Basic Charts</a></li>
+ <li><a href="demos-qmlaxes.html">Qml Axes</a></li>
<li><a href="demos-qmlcustomizations.html">Qml Customizations</a></li>
<li><a href="demos-qmlcustommodel.html">Qml Custom Model</a></li>
<li><a href="demos-qmlf1legends.html">Qml F1 Legends</a></li>
diff --git a/src/axis/datetimeaxis/qdatetimeaxis.cpp b/src/axis/datetimeaxis/qdatetimeaxis.cpp
index 60f96b54..78ad8b0d 100644
--- a/src/axis/datetimeaxis/qdatetimeaxis.cpp
+++ b/src/axis/datetimeaxis/qdatetimeaxis.cpp
@@ -72,6 +72,7 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE
/*!
\qmlclass DateTimeAxis QDateTimeAxis
\brief The DateTimeAxis element is used for manipulating chart's axes
+ \inherits AbstractAxis
The labels can be configured by setting an appropriate DateTime format.
Note that any date before 4714 BCE or after about 1.4 million CE may not be accurately stored.
@@ -129,11 +130,31 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE
*/
/*!
- \qmlproperty int ValuesAxis::tickCount
+ \qmlproperty int DateTimeAxis::tickCount
The number of tick marks for the axis.
*/
/*!
+ \property QDateTimeAxis::format
+ The format string that is used when creating label for the axis out of a QDateTime object.
+ Check QDateTime documentation for information on how the string should be defined.
+*/
+/*!
+ \qmlproperty string DateTimeAxis::format
+ The format string that is used when creating label for the axis out of a QDateTime object.
+ Check QDateTime documentation for information on how the string should be defined.
+*/
+
+/*!
+ \fn void QDateTimeAxis::formatChanged(QString format)
+ Axis emits signal when \a format of the axis has changed.
+*/
+/*!
+ \qmlsignal DateTimeAxis::onFormatChanged(string format)
+ Axis emits signal when \a format of the axis has changed.
+*/
+
+/*!
Constructs an axis object which is a child of \a parent.
*/
QDateTimeAxis::QDateTimeAxis(QObject *parent) :
@@ -213,22 +234,15 @@ void QDateTimeAxis::setRange(QDateTime min, QDateTime max)
}
}
-/*!
- Sets \a format string that is used when creating label for the axis out of the QDateTime object.
- Check QDateTime documentation for information on how the string should be defined.
- \sa format()
-*/
void QDateTimeAxis::setFormat(QString format)
{
Q_D(QDateTimeAxis);
- d->m_format = format;
+ if (d->m_format != format) {
+ d->m_format = format;
+ emit formatChanged(format);
+ }
}
-/*!
- Returns the format string that is used when creating label for the axis out of the QDateTime object.
- Check QDateTime documentation for information on how the string should be defined.
- \sa setFormat()
-*/
QString QDateTimeAxis::format() const
{
Q_D(const QDateTimeAxis);
diff --git a/src/axis/datetimeaxis/qdatetimeaxis.h b/src/axis/datetimeaxis/qdatetimeaxis.h
index 5b47f080..fbf45579 100644
--- a/src/axis/datetimeaxis/qdatetimeaxis.h
+++ b/src/axis/datetimeaxis/qdatetimeaxis.h
@@ -35,6 +35,7 @@ class QTCOMMERCIALCHART_EXPORT QDateTimeAxis : public QAbstractAxis
Q_PROPERTY(int tickCount READ tickCount WRITE setTickCount)
Q_PROPERTY(QDateTime min READ min WRITE setMin NOTIFY minChanged)
Q_PROPERTY(QDateTime max READ max WRITE setMax NOTIFY maxChanged)
+ Q_PROPERTY(QString format READ format WRITE setFormat NOTIFY formatChanged)
public:
explicit QDateTimeAxis(QObject *parent = 0);
@@ -64,6 +65,7 @@ Q_SIGNALS:
void minChanged(QDateTime min);
void maxChanged(QDateTime max);
void rangeChanged(QDateTime min, QDateTime max);
+ void formatChanged(QString format);
private:
Q_DECLARE_PRIVATE(QDateTimeAxis)