@@ -0,0 +1,36 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | #include <QtGui/QApplication> | |
|
22 | #include <QDeclarativeEngine> | |
|
23 | #include "qmlapplicationviewer.h" | |
|
24 | ||
|
25 | Q_DECL_EXPORT int main(int argc, char *argv[]) | |
|
26 | { | |
|
27 | QScopedPointer<QApplication> app(createApplication(argc, argv)); | |
|
28 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); | |
|
29 | ||
|
30 | viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); | |
|
31 | viewer->setSource(QUrl("qrc:/qml/qmlaxes/loader.qml")); | |
|
32 | viewer->setRenderHint(QPainter::Antialiasing, true); | |
|
33 | viewer->showExpanded(); | |
|
34 | ||
|
35 | return app->exec(); | |
|
36 | } |
@@ -0,0 +1,67 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | import QtQuick 1.0 | |
|
22 | import QtCommercial.Chart 1.1 | |
|
23 | ||
|
24 | Rectangle { | |
|
25 | anchors.fill: parent | |
|
26 | ||
|
27 | //![1] | |
|
28 | ChartView { | |
|
29 | title: "Two Series, Common Axes" | |
|
30 | anchors.fill: parent | |
|
31 | legend.visible: false | |
|
32 | ||
|
33 | ValueAxis { | |
|
34 | id: axisX | |
|
35 | min: 0 | |
|
36 | max: 10 | |
|
37 | tickCount: 5 | |
|
38 | } | |
|
39 | ||
|
40 | ValueAxis { | |
|
41 | id: axisY | |
|
42 | min: -0.5 | |
|
43 | max: 1.5 | |
|
44 | } | |
|
45 | ||
|
46 | LineSeries { | |
|
47 | id: series1 | |
|
48 | axisX: axisX | |
|
49 | axisY: axisY | |
|
50 | } | |
|
51 | ||
|
52 | ScatterSeries { | |
|
53 | id: series2 | |
|
54 | axisX: axisX | |
|
55 | axisY: axisY | |
|
56 | } | |
|
57 | } | |
|
58 | ||
|
59 | // Add data dynamically to the series | |
|
60 | Component.onCompleted: { | |
|
61 | for (var i = 0; i <= 10; i++) { | |
|
62 | series1.append(i, Math.random()); | |
|
63 | series2.append(i, Math.random()); | |
|
64 | } | |
|
65 | } | |
|
66 | //![1] | |
|
67 | } |
@@ -0,0 +1,59 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | import QtQuick 1.0 | |
|
22 | import QtCommercial.Chart 1.1 | |
|
23 | ||
|
24 | Rectangle { | |
|
25 | anchors.fill: parent | |
|
26 | ||
|
27 | //![1] | |
|
28 | ChartView { | |
|
29 | title: "Accurate Historical Data" | |
|
30 | anchors.fill: parent | |
|
31 | legend.visible: false | |
|
32 | ||
|
33 | LineSeries { | |
|
34 | axisX: DateTimeAxis { | |
|
35 | format: "yyyy MMM" | |
|
36 | tickCount: 5 | |
|
37 | } | |
|
38 | axisY: ValueAxis { | |
|
39 | min: 0 | |
|
40 | max: 150 | |
|
41 | } | |
|
42 | ||
|
43 | // Please note that month in JavaScript months are zero based, so 2 means March | |
|
44 | XYPoint { x: toMsecsSinceEpoch(new Date(1950, 2, 15)); y: 5 } | |
|
45 | XYPoint { x: toMsecsSinceEpoch(new Date(1970, 0, 1)); y: 50 } | |
|
46 | XYPoint { x: toMsecsSinceEpoch(new Date(1987, 12, 31)); y: 102 } | |
|
47 | XYPoint { x: toMsecsSinceEpoch(new Date(1998, 7, 1)); y: 100 } | |
|
48 | XYPoint { x: toMsecsSinceEpoch(new Date(2012, 8, 2)); y: 110 } | |
|
49 | } | |
|
50 | } | |
|
51 | ||
|
52 | // DateTimeAxis is based on QDateTimes so we must convert our JavaScript dates to | |
|
53 | // milliseconds since epoch to make them match the DateTimeAxis values | |
|
54 | function toMsecsSinceEpoch(date) { | |
|
55 | var msecs = date.getTime(); | |
|
56 | return msecs; | |
|
57 | } | |
|
58 | //![1] | |
|
59 | } |
@@ -0,0 +1,67 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | import QtQuick 1.0 | |
|
22 | import QtCommercial.Chart 1.1 | |
|
23 | ||
|
24 | Rectangle { | |
|
25 | anchors.fill: parent | |
|
26 | ||
|
27 | //![1] | |
|
28 | ChartView { | |
|
29 | title: "Numerical Data for Dummies" | |
|
30 | anchors.fill: parent | |
|
31 | legend.visible: false | |
|
32 | ||
|
33 | LineSeries { | |
|
34 | axisY: CategoryAxis { | |
|
35 | min: 0 | |
|
36 | max: 30 | |
|
37 | CategoryRange { | |
|
38 | label: "critical" | |
|
39 | endValue: 2 | |
|
40 | } | |
|
41 | CategoryRange { | |
|
42 | label: "low" | |
|
43 | endValue: 4 | |
|
44 | } | |
|
45 | CategoryRange { | |
|
46 | label: "normal" | |
|
47 | endValue: 7 | |
|
48 | } | |
|
49 | CategoryRange { | |
|
50 | label: "high" | |
|
51 | endValue: 15 | |
|
52 | } | |
|
53 | CategoryRange { | |
|
54 | label: "extremely high" | |
|
55 | endValue: 30 | |
|
56 | } | |
|
57 | } | |
|
58 | ||
|
59 | XYPoint { x: 0; y: 4.3 } | |
|
60 | XYPoint { x: 1; y: 4.1 } | |
|
61 | XYPoint { x: 2; y: 4.7 } | |
|
62 | XYPoint { x: 3; y: 3.9 } | |
|
63 | XYPoint { x: 4; y: 5.2 } | |
|
64 | } | |
|
65 | } | |
|
66 | //![1] | |
|
67 | } |
@@ -0,0 +1,37 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | import QtQuick 1.0 | |
|
22 | ||
|
23 | Item { | |
|
24 | id: container | |
|
25 | width: 400 | |
|
26 | height: 300 | |
|
27 | Component.onCompleted: { | |
|
28 | var co = Qt.createComponent("main.qml") | |
|
29 | if (co.status == Component.Ready) { | |
|
30 | var o = co.createObject(container) | |
|
31 | } else { | |
|
32 | console.log(co.errorString()) | |
|
33 | console.log("QtCommercial.Chart 1.1 not available") | |
|
34 | console.log("Please use correct QML_IMPORT_PATH export") | |
|
35 | } | |
|
36 | } | |
|
37 | } |
@@ -0,0 +1,90 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | import QtQuick 1.0 | |
|
22 | ||
|
23 | Rectangle { | |
|
24 | width: parent.width | |
|
25 | height: parent.height | |
|
26 | property int viewNumber: 1 | |
|
27 | property int viewCount: 3 | |
|
28 | ||
|
29 | Loader { | |
|
30 | id: loader | |
|
31 | anchors.fill: parent | |
|
32 | source: "View" + viewNumber + ".qml"; | |
|
33 | } | |
|
34 | ||
|
35 | Rectangle { | |
|
36 | id: infoText | |
|
37 | anchors.centerIn: parent | |
|
38 | width: parent.width | |
|
39 | height: 40 | |
|
40 | color: "black" | |
|
41 | Text { | |
|
42 | color: "white" | |
|
43 | anchors.centerIn: parent | |
|
44 | text: "Use left and right arrow keys to navigate" | |
|
45 | } | |
|
46 | ||
|
47 | Behavior on opacity { | |
|
48 | NumberAnimation { duration: 400 } | |
|
49 | } | |
|
50 | } | |
|
51 | ||
|
52 | MouseArea { | |
|
53 | focus: true | |
|
54 | anchors.fill: parent | |
|
55 | onClicked: { | |
|
56 | if (infoText.opacity > 0) { | |
|
57 | infoText.opacity = 0.0; | |
|
58 | } else { | |
|
59 | nextView(); | |
|
60 | } | |
|
61 | } | |
|
62 | Keys.onPressed: { | |
|
63 | if (infoText.opacity > 0) { | |
|
64 | infoText.opacity = 0.0; | |
|
65 | } else { | |
|
66 | if (event.key == Qt.Key_Left) { | |
|
67 | previousView(); | |
|
68 | } else { | |
|
69 | nextView(); | |
|
70 | } | |
|
71 | } | |
|
72 | } | |
|
73 | } | |
|
74 | ||
|
75 | function nextView() { | |
|
76 | var i = viewNumber + 1; | |
|
77 | if (i > viewCount) | |
|
78 | viewNumber = 1; | |
|
79 | else | |
|
80 | viewNumber = i; | |
|
81 | } | |
|
82 | ||
|
83 | function previousView() { | |
|
84 | var i = viewNumber - 1; | |
|
85 | if (i <= 0) | |
|
86 | viewNumber = viewCount; | |
|
87 | else | |
|
88 | viewNumber = i; | |
|
89 | } | |
|
90 | } |
@@ -0,0 +1,200 | |||
|
1 | // checksum 0x78c version 0x60010 | |
|
2 | /* | |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
|
6 | handled here. | |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
|
8 | may offer an updated version of it. | |
|
9 | */ | |
|
10 | ||
|
11 | #include "qmlapplicationviewer.h" | |
|
12 | ||
|
13 | #include <QtCore/QDir> | |
|
14 | #include <QtCore/QFileInfo> | |
|
15 | #include <QtDeclarative/QDeclarativeComponent> | |
|
16 | #include <QtDeclarative/QDeclarativeEngine> | |
|
17 | #include <QtDeclarative/QDeclarativeContext> | |
|
18 | #include <QtGui/QApplication> | |
|
19 | ||
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |
|
21 | ||
|
22 | #ifdef HARMATTAN_BOOSTER | |
|
23 | #include <MDeclarativeCache> | |
|
24 | #endif | |
|
25 | ||
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
|
27 | ||
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |
|
29 | ||
|
30 | #if !defined(NO_JSDEBUGGER) | |
|
31 | #include <jsdebuggeragent.h> | |
|
32 | #endif | |
|
33 | #if !defined(NO_QMLOBSERVER) | |
|
34 | #include <qdeclarativeviewobserver.h> | |
|
35 | #endif | |
|
36 | ||
|
37 | // Enable debugging before any QDeclarativeEngine is created | |
|
38 | struct QmlJsDebuggingEnabler | |
|
39 | { | |
|
40 | QmlJsDebuggingEnabler() | |
|
41 | { | |
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |
|
43 | } | |
|
44 | }; | |
|
45 | ||
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |
|
48 | ||
|
49 | #endif // QMLJSDEBUGGER | |
|
50 | ||
|
51 | class QmlApplicationViewerPrivate | |
|
52 | { | |
|
53 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} | |
|
54 | ||
|
55 | QString mainQmlFile; | |
|
56 | QDeclarativeView *view; | |
|
57 | friend class QmlApplicationViewer; | |
|
58 | QString adjustPath(const QString &path); | |
|
59 | }; | |
|
60 | ||
|
61 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |
|
62 | { | |
|
63 | #ifdef Q_OS_UNIX | |
|
64 | #ifdef Q_OS_MAC | |
|
65 | if (!QDir::isAbsolutePath(path)) | |
|
66 | return QCoreApplication::applicationDirPath() | |
|
67 | + QLatin1String("/../Resources/") + path; | |
|
68 | #else | |
|
69 | QString pathInInstallDir; | |
|
70 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); | |
|
71 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); | |
|
72 | ||
|
73 | if (QFileInfo(pathInInstallDir).exists()) | |
|
74 | return pathInInstallDir; | |
|
75 | #endif | |
|
76 | #endif | |
|
77 | return path; | |
|
78 | } | |
|
79 | ||
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |
|
81 | : QDeclarativeView(parent) | |
|
82 | , d(new QmlApplicationViewerPrivate(this)) | |
|
83 | { | |
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
|
86 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
|
87 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
|
88 | #if !defined(NO_JSDEBUGGER) | |
|
89 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
|
90 | #endif | |
|
91 | #if !defined(NO_QMLOBSERVER) | |
|
92 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
|
93 | #endif | |
|
94 | #endif | |
|
95 | } | |
|
96 | ||
|
97 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) | |
|
98 | : QDeclarativeView(parent) | |
|
99 | , d(new QmlApplicationViewerPrivate(view)) | |
|
100 | { | |
|
101 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); | |
|
102 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
|
103 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
|
104 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
|
105 | #if !defined(NO_JSDEBUGGER) | |
|
106 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
|
107 | #endif | |
|
108 | #if !defined(NO_QMLOBSERVER) | |
|
109 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
|
110 | #endif | |
|
111 | #endif | |
|
112 | } | |
|
113 | ||
|
114 | QmlApplicationViewer::~QmlApplicationViewer() | |
|
115 | { | |
|
116 | delete d; | |
|
117 | } | |
|
118 | ||
|
119 | QmlApplicationViewer *QmlApplicationViewer::create() | |
|
120 | { | |
|
121 | #ifdef HARMATTAN_BOOSTER | |
|
122 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); | |
|
123 | #else | |
|
124 | return new QmlApplicationViewer(); | |
|
125 | #endif | |
|
126 | } | |
|
127 | ||
|
128 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
|
129 | { | |
|
130 | d->mainQmlFile = d->adjustPath(file); | |
|
131 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
|
132 | } | |
|
133 | ||
|
134 | void QmlApplicationViewer::addImportPath(const QString &path) | |
|
135 | { | |
|
136 | d->view->engine()->addImportPath(d->adjustPath(path)); | |
|
137 | } | |
|
138 | ||
|
139 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
|
140 | { | |
|
141 | #if defined(Q_OS_SYMBIAN) | |
|
142 | // If the version of Qt on the device is < 4.7.2, that attribute won't work | |
|
143 | if (orientation != ScreenOrientationAuto) { | |
|
144 | const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); | |
|
145 | if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { | |
|
146 | qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); | |
|
147 | return; | |
|
148 | } | |
|
149 | } | |
|
150 | #endif // Q_OS_SYMBIAN | |
|
151 | ||
|
152 | Qt::WidgetAttribute attribute; | |
|
153 | switch (orientation) { | |
|
154 | #if QT_VERSION < 0x040702 | |
|
155 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
|
156 | case ScreenOrientationLockPortrait: | |
|
157 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
|
158 | break; | |
|
159 | case ScreenOrientationLockLandscape: | |
|
160 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
|
161 | break; | |
|
162 | default: | |
|
163 | case ScreenOrientationAuto: | |
|
164 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
|
165 | break; | |
|
166 | #else // QT_VERSION < 0x040702 | |
|
167 | case ScreenOrientationLockPortrait: | |
|
168 | attribute = Qt::WA_LockPortraitOrientation; | |
|
169 | break; | |
|
170 | case ScreenOrientationLockLandscape: | |
|
171 | attribute = Qt::WA_LockLandscapeOrientation; | |
|
172 | break; | |
|
173 | default: | |
|
174 | case ScreenOrientationAuto: | |
|
175 | attribute = Qt::WA_AutoOrientation; | |
|
176 | break; | |
|
177 | #endif // QT_VERSION < 0x040702 | |
|
178 | }; | |
|
179 | setAttribute(attribute, true); | |
|
180 | } | |
|
181 | ||
|
182 | void QmlApplicationViewer::showExpanded() | |
|
183 | { | |
|
184 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
|
185 | d->view->showFullScreen(); | |
|
186 | #elif defined(Q_WS_MAEMO_5) | |
|
187 | d->view->showMaximized(); | |
|
188 | #else | |
|
189 | d->view->show(); | |
|
190 | #endif | |
|
191 | } | |
|
192 | ||
|
193 | QApplication *createApplication(int &argc, char **argv) | |
|
194 | { | |
|
195 | #ifdef HARMATTAN_BOOSTER | |
|
196 | return MDeclarativeCache::qApplication(argc, argv); | |
|
197 | #else | |
|
198 | return new QApplication(argc, argv); | |
|
199 | #endif | |
|
200 | } |
@@ -0,0 +1,47 | |||
|
1 | // checksum 0x82ed version 0x60010 | |
|
2 | /* | |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
|
6 | handled here. | |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
|
8 | may offer an updated version of it. | |
|
9 | */ | |
|
10 | ||
|
11 | #ifndef QMLAPPLICATIONVIEWER_H | |
|
12 | #define QMLAPPLICATIONVIEWER_H | |
|
13 | ||
|
14 | #include <QtDeclarative/QDeclarativeView> | |
|
15 | ||
|
16 | class QmlApplicationViewer : public QDeclarativeView | |
|
17 | { | |
|
18 | Q_OBJECT | |
|
19 | ||
|
20 | public: | |
|
21 | enum ScreenOrientation { | |
|
22 | ScreenOrientationLockPortrait, | |
|
23 | ScreenOrientationLockLandscape, | |
|
24 | ScreenOrientationAuto | |
|
25 | }; | |
|
26 | ||
|
27 | explicit QmlApplicationViewer(QWidget *parent = 0); | |
|
28 | virtual ~QmlApplicationViewer(); | |
|
29 | ||
|
30 | static QmlApplicationViewer *create(); | |
|
31 | ||
|
32 | void setMainQmlFile(const QString &file); | |
|
33 | void addImportPath(const QString &path); | |
|
34 | ||
|
35 | // Note that this will only have an effect on Symbian and Fremantle. | |
|
36 | void setOrientation(ScreenOrientation orientation); | |
|
37 | ||
|
38 | void showExpanded(); | |
|
39 | ||
|
40 | private: | |
|
41 | explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); | |
|
42 | class QmlApplicationViewerPrivate *d; | |
|
43 | }; | |
|
44 | ||
|
45 | QApplication *createApplication(int &argc, char **argv); | |
|
46 | ||
|
47 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -0,0 +1,13 | |||
|
1 | QT += declarative | |
|
2 | ||
|
3 | SOURCES += $$PWD/qmlapplicationviewer.cpp | |
|
4 | HEADERS += $$PWD/qmlapplicationviewer.h | |
|
5 | INCLUDEPATH += $$PWD | |
|
6 | ||
|
7 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set | |
|
8 | !isEmpty(QMLJSDEBUGGER_PATH) { | |
|
9 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) | |
|
10 | } else { | |
|
11 | DEFINES -= QMLJSDEBUGGER | |
|
12 | } | |
|
13 |
@@ -0,0 +1,8 | |||
|
1 | !include( ../demos.pri ) { | |
|
2 | error( "Couldn't find the demos.pri file!" ) | |
|
3 | } | |
|
4 | ||
|
5 | RESOURCES += resources.qrc | |
|
6 | SOURCES += main.cpp | |
|
7 | ||
|
8 | include(qmlapplicationviewer/qmlapplicationviewer.pri) |
@@ -0,0 +1,9 | |||
|
1 | <RCC> | |
|
2 | <qresource prefix="/"> | |
|
3 | <file>qml/qmlaxes/loader.qml</file> | |
|
4 | <file>qml/qmlaxes/main.qml</file> | |
|
5 | <file>qml/qmlaxes/View1.qml</file> | |
|
6 | <file>qml/qmlaxes/View2.qml</file> | |
|
7 | <file>qml/qmlaxes/View3.qml</file> | |
|
8 | </qresource> | |
|
9 | </RCC> |
@@ -1,23 +1,24 | |||
|
1 | 1 | CURRENTLY_BUILDING_COMPONENTS = "demos" |
|
2 | 2 | !include( ../config.pri ) { |
|
3 | 3 | error( "Couldn't find the config.pri file!" ) |
|
4 | 4 | } |
|
5 | 5 | |
|
6 | 6 | TEMPLATE = subdirs |
|
7 | 7 | SUBDIRS += piechartcustomization \ |
|
8 | 8 | dynamicspline \ |
|
9 | 9 | nesteddonuts \ |
|
10 | 10 | qmlchart \ |
|
11 | 11 | qmlweather \ |
|
12 | 12 | qmlf1legends \ |
|
13 | 13 | qmlcustomizations \ |
|
14 | 14 | qmlcustommodel \ |
|
15 | chartinteractions | |
|
15 | chartinteractions \ | |
|
16 | qmlaxes | |
|
16 | 17 | |
|
17 | 18 | contains(QT_CONFIG, opengl) { |
|
18 | 19 | SUBDIRS += chartthemes \ |
|
19 | 20 | qmloscilloscope \ |
|
20 | 21 | chartviewer |
|
21 | 22 | } else { |
|
22 | 23 | message("OpenGL not available. Some demos are disabled") |
|
23 | 24 | } |
@@ -1,31 +1,32 | |||
|
1 | 1 | /*! |
|
2 | 2 | \page demos.html |
|
3 | 3 | \title Demos |
|
4 | 4 | \keyword Demos |
|
5 | 5 | |
|
6 | 6 | \raw HTML |
|
7 | 7 | <table cellpadding="2" cellspacing="1" border="0" width="100%" class="indextable"> |
|
8 | 8 | <tr> |
|
9 | 9 | <th class="titleheader" width="33%"> |
|
10 | 10 | List of demos |
|
11 | 11 | </th> |
|
12 | 12 | </tr> |
|
13 | 13 | <tr> |
|
14 | 14 | <td valign="top"> |
|
15 | 15 | <ul> |
|
16 | 16 | <li><a href="demos-chartthemes.html">Chart themes</a></li> |
|
17 | 17 | <li><a href="demos-dynamicspline.html">Dynamic spline chart</a></li> |
|
18 | 18 | <li><a href="demos-nesteddonuts.html">Nested donuts chart</a></li> |
|
19 | 19 | <li><a href="demos-piechartcustomization.html">Pie chart customization</a></li> |
|
20 | 20 | <li><a href="demos-qmlchart.html">Qml Basic Charts</a></li> |
|
21 | <li><a href="demos-qmlaxes.html">Qml Axes</a></li> | |
|
21 | 22 | <li><a href="demos-qmlcustomizations.html">Qml Customizations</a></li> |
|
22 | 23 | <li><a href="demos-qmlcustommodel.html">Qml Custom Model</a></li> |
|
23 | 24 | <li><a href="demos-qmlf1legends.html">Qml F1 Legends</a></li> |
|
24 | 25 | <li><a href="demos-qmloscilloscope.html">Qml Oscilloscope</a></li> |
|
25 | 26 | <li><a href="demos-qmlweather.html">Qml Weather</a></li> |
|
26 | 27 | </ul> |
|
27 | 28 | </td> |
|
28 | 29 | </tr> |
|
29 | 30 | </table> |
|
30 | 31 | \endraw |
|
31 | 32 | */ |
@@ -1,352 +1,366 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "qdatetimeaxis.h" |
|
22 | 22 | #include "qdatetimeaxis_p.h" |
|
23 | 23 | #include "chartdatetimeaxisx_p.h" |
|
24 | 24 | #include "chartdatetimeaxisy_p.h" |
|
25 | 25 | #include "domain_p.h" |
|
26 | 26 | #include <cmath> |
|
27 | 27 | |
|
28 | 28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | 29 | /*! |
|
30 | 30 | \class QDateTimeAxis |
|
31 | 31 | \brief The QDateTimeAxis class is used for manipulating chart's axis. |
|
32 | 32 | \mainclass |
|
33 | 33 | |
|
34 | 34 | The labels can be configured by setting an appropriate DateTime format. |
|
35 | 35 | QDateTimeAxis works correctly with dates from 4714 BCE to 287396 CE |
|
36 | 36 | There are also other limitiation related to QDateTime . Please refer to QDateTime documentation. |
|
37 | 37 | QDateTimeAxis can be setup to show axis line with tick marks, grid lines and shades. |
|
38 | 38 | |
|
39 | 39 | NOTE: QDateTimeAxis is disabled on ARM platform at the present time. |
|
40 | 40 | |
|
41 | 41 | \image api_datatime_axis.png |
|
42 | 42 | |
|
43 | 43 | QDateTimeAxis can be used with QLineSeries, QSplineSeries or QScatterSeries. |
|
44 | 44 | To add a data point to the series QDateTime::toMSecsSinceEpoch() is used. |
|
45 | 45 | \code |
|
46 | 46 | QLineSeries *series = new QLineSeries; |
|
47 | 47 | |
|
48 | 48 | QDateTime xValue; |
|
49 | 49 | xValue.setDate(QDate(2012, 1 , 18)); |
|
50 | 50 | xValue.setTime(QTime(9, 34)); |
|
51 | 51 | qreal yValue = 12; |
|
52 | 52 | series->append(xValue.toMSecsSinceEpoch(), yValue); |
|
53 | 53 | |
|
54 | 54 | xValue.setDate(QDate(2013, 5 , 11)); |
|
55 | 55 | xValue.setTime(QTime(11, 14)); |
|
56 | 56 | qreal yValue = 22; |
|
57 | 57 | series->append(xValue.toMSecsSinceEpoch(), yValue); |
|
58 | 58 | \endcode |
|
59 | 59 | |
|
60 | 60 | Adding the series to the chart and setting up the QDateTimeAxis. |
|
61 | 61 | \code |
|
62 | 62 | QChartView *chartView = new QChartView; |
|
63 | 63 | chartView->chart()->addSeries(series); |
|
64 | 64 | |
|
65 | 65 | // ... |
|
66 | 66 | QDateTimeAxis *axisX = new QDateTimeAxis; |
|
67 | 67 | axisX->setFormat("dd-MM-yyyy h:mm"); |
|
68 | 68 | chartView->chart()->setAxisX(series, axisX); |
|
69 | 69 | \endcode |
|
70 | 70 | */ |
|
71 | 71 | |
|
72 | 72 | /*! |
|
73 | 73 | \qmlclass DateTimeAxis QDateTimeAxis |
|
74 | 74 | \brief The DateTimeAxis element is used for manipulating chart's axes |
|
75 | \inherits AbstractAxis | |
|
75 | 76 | |
|
76 | 77 | The labels can be configured by setting an appropriate DateTime format. |
|
77 | 78 | Note that any date before 4714 BCE or after about 1.4 million CE may not be accurately stored. |
|
78 | 79 | DateTimeAxis can be setup to show axis line with tick marks, grid lines and shades. |
|
79 | 80 | */ |
|
80 | 81 | |
|
81 | 82 | /*! |
|
82 | 83 | \property QDateTimeAxis::min |
|
83 | 84 | Defines the minimum value on the axis. |
|
84 | 85 | When setting this property the max is adjusted if necessary, to ensure that the range remains valid. |
|
85 | 86 | */ |
|
86 | 87 | /*! |
|
87 | 88 | \qmlproperty real ValuesAxis::min |
|
88 | 89 | Defines the minimum value on the axis. |
|
89 | 90 | When setting this property the max is adjusted if necessary, to ensure that the range remains valid. |
|
90 | 91 | */ |
|
91 | 92 | |
|
92 | 93 | /*! |
|
93 | 94 | \property QDateTimeAxis::max |
|
94 | 95 | Defines the maximum value on the axis. |
|
95 | 96 | When setting this property the min is adjusted if necessary, to ensure that the range remains valid. |
|
96 | 97 | */ |
|
97 | 98 | /*! |
|
98 | 99 | \qmlproperty real ValuesAxis::max |
|
99 | 100 | Defines the maximum value on the axis. |
|
100 | 101 | When setting this property the min is adjusted if necessary, to ensure that the range remains valid. |
|
101 | 102 | */ |
|
102 | 103 | |
|
103 | 104 | /*! |
|
104 | 105 | \fn void QDateTimeAxis::minChanged(QDateTime min) |
|
105 | 106 | Axis emits signal when \a min of axis has changed. |
|
106 | 107 | */ |
|
107 | 108 | /*! |
|
108 | 109 | \qmlsignal ValuesAxis::onMinChanged(QDateTime min) |
|
109 | 110 | Axis emits signal when \a min of axis has changed. |
|
110 | 111 | */ |
|
111 | 112 | |
|
112 | 113 | /*! |
|
113 | 114 | \fn void QDateTimeAxis::maxChanged(QDateTime max) |
|
114 | 115 | Axis emits signal when \a max of axis has changed. |
|
115 | 116 | */ |
|
116 | 117 | /*! |
|
117 | 118 | \qmlsignal ValuesAxis::onMaxChanged(QDateTime max) |
|
118 | 119 | Axis emits signal when \a max of axis has changed. |
|
119 | 120 | */ |
|
120 | 121 | |
|
121 | 122 | /*! |
|
122 | 123 | \fn void QDateTimeAxis::rangeChanged(QDateTime min, QDateTime max) |
|
123 | 124 | Axis emits signal when \a min or \a max of axis has changed. |
|
124 | 125 | */ |
|
125 | 126 | |
|
126 | 127 | /*! |
|
127 | 128 | \property QDateTimeAxis::tickCount |
|
128 | 129 | The number of tick marks for the axis. |
|
129 | 130 | */ |
|
130 | 131 | |
|
131 | 132 | /*! |
|
132 |
\qmlproperty int |
|
|
133 | \qmlproperty int DateTimeAxis::tickCount | |
|
133 | 134 | The number of tick marks for the axis. |
|
134 | 135 | */ |
|
135 | 136 | |
|
136 | 137 | /*! |
|
138 | \property QDateTimeAxis::format | |
|
139 | The format string that is used when creating label for the axis out of a QDateTime object. | |
|
140 | Check QDateTime documentation for information on how the string should be defined. | |
|
141 | */ | |
|
142 | /*! | |
|
143 | \qmlproperty string DateTimeAxis::format | |
|
144 | The format string that is used when creating label for the axis out of a QDateTime object. | |
|
145 | Check QDateTime documentation for information on how the string should be defined. | |
|
146 | */ | |
|
147 | ||
|
148 | /*! | |
|
149 | \fn void QDateTimeAxis::formatChanged(QString format) | |
|
150 | Axis emits signal when \a format of the axis has changed. | |
|
151 | */ | |
|
152 | /*! | |
|
153 | \qmlsignal DateTimeAxis::onFormatChanged(string format) | |
|
154 | Axis emits signal when \a format of the axis has changed. | |
|
155 | */ | |
|
156 | ||
|
157 | /*! | |
|
137 | 158 | Constructs an axis object which is a child of \a parent. |
|
138 | 159 | */ |
|
139 | 160 | QDateTimeAxis::QDateTimeAxis(QObject *parent) : |
|
140 | 161 | QAbstractAxis(*new QDateTimeAxisPrivate(this),parent) |
|
141 | 162 | { |
|
142 | 163 | |
|
143 | 164 | } |
|
144 | 165 | |
|
145 | 166 | /*! |
|
146 | 167 | \internal |
|
147 | 168 | */ |
|
148 | 169 | QDateTimeAxis::QDateTimeAxis(QDateTimeAxisPrivate &d,QObject *parent) : QAbstractAxis(d,parent) |
|
149 | 170 | { |
|
150 | 171 | |
|
151 | 172 | } |
|
152 | 173 | |
|
153 | 174 | /*! |
|
154 | 175 | Destroys the object |
|
155 | 176 | */ |
|
156 | 177 | QDateTimeAxis::~QDateTimeAxis() |
|
157 | 178 | { |
|
158 | 179 | |
|
159 | 180 | } |
|
160 | 181 | |
|
161 | 182 | void QDateTimeAxis::setMin(QDateTime min) |
|
162 | 183 | { |
|
163 | 184 | Q_D(QDateTimeAxis); |
|
164 | 185 | if (min.isValid()) |
|
165 | 186 | setRange(min, qMax(d->m_max, min)); |
|
166 | 187 | } |
|
167 | 188 | |
|
168 | 189 | QDateTime QDateTimeAxis::min() const |
|
169 | 190 | { |
|
170 | 191 | Q_D(const QDateTimeAxis); |
|
171 | 192 | return d->m_min; |
|
172 | 193 | } |
|
173 | 194 | |
|
174 | 195 | void QDateTimeAxis::setMax(QDateTime max) |
|
175 | 196 | { |
|
176 | 197 | Q_D(QDateTimeAxis); |
|
177 | 198 | if (max.isValid()) |
|
178 | 199 | setRange(qMin(d->m_min, max), max); |
|
179 | 200 | } |
|
180 | 201 | |
|
181 | 202 | QDateTime QDateTimeAxis::max() const |
|
182 | 203 | { |
|
183 | 204 | Q_D(const QDateTimeAxis); |
|
184 | 205 | return d->m_max; |
|
185 | 206 | } |
|
186 | 207 | |
|
187 | 208 | /*! |
|
188 | 209 | Sets range from \a min to \a max on the axis. |
|
189 | 210 | If min is greater than max then this function returns without making any changes. |
|
190 | 211 | */ |
|
191 | 212 | void QDateTimeAxis::setRange(QDateTime min, QDateTime max) |
|
192 | 213 | { |
|
193 | 214 | Q_D(QDateTimeAxis); |
|
194 | 215 | if (!min.isValid() || !max.isValid() || min > max) |
|
195 | 216 | return; |
|
196 | 217 | |
|
197 | 218 | bool changed = false; |
|
198 | 219 | if (d->m_min != min) { |
|
199 | 220 | d->m_min = min; |
|
200 | 221 | changed = true; |
|
201 | 222 | emit minChanged(min); |
|
202 | 223 | } |
|
203 | 224 | |
|
204 | 225 | if (d->m_max != max) { |
|
205 | 226 | d->m_max = max; |
|
206 | 227 | changed = true; |
|
207 | 228 | emit maxChanged(max); |
|
208 | 229 | } |
|
209 | 230 | |
|
210 | 231 | if (changed) { |
|
211 | 232 | emit rangeChanged(d->m_min,d->m_max); |
|
212 | 233 | d->emitUpdated(); |
|
213 | 234 | } |
|
214 | 235 | } |
|
215 | 236 | |
|
216 | /*! | |
|
217 | Sets \a format string that is used when creating label for the axis out of the QDateTime object. | |
|
218 | Check QDateTime documentation for information on how the string should be defined. | |
|
219 | \sa format() | |
|
220 | */ | |
|
221 | 237 | void QDateTimeAxis::setFormat(QString format) |
|
222 | 238 | { |
|
223 | 239 | Q_D(QDateTimeAxis); |
|
224 |
d->m_format = format |
|
|
240 | if (d->m_format != format) { | |
|
241 | d->m_format = format; | |
|
242 | emit formatChanged(format); | |
|
243 | } | |
|
225 | 244 | } |
|
226 | 245 | |
|
227 | /*! | |
|
228 | Returns the format string that is used when creating label for the axis out of the QDateTime object. | |
|
229 | Check QDateTime documentation for information on how the string should be defined. | |
|
230 | \sa setFormat() | |
|
231 | */ | |
|
232 | 246 | QString QDateTimeAxis::format() const |
|
233 | 247 | { |
|
234 | 248 | Q_D(const QDateTimeAxis); |
|
235 | 249 | return d->m_format; |
|
236 | 250 | } |
|
237 | 251 | |
|
238 | 252 | /*! |
|
239 | 253 | Sets \a count for ticks on the axis. |
|
240 | 254 | */ |
|
241 | 255 | void QDateTimeAxis::setTickCount(int count) |
|
242 | 256 | { |
|
243 | 257 | Q_D(QDateTimeAxis); |
|
244 | 258 | if (d->m_tickCount != count && count >=2) { |
|
245 | 259 | d->m_tickCount = count; |
|
246 | 260 | d->emitUpdated(); |
|
247 | 261 | } |
|
248 | 262 | } |
|
249 | 263 | |
|
250 | 264 | /*! |
|
251 | 265 | \fn int QDateTimeAxis::tickCount() const |
|
252 | 266 | Return number of ticks on the axis |
|
253 | 267 | */ |
|
254 | 268 | int QDateTimeAxis::tickCount() const |
|
255 | 269 | { |
|
256 | 270 | Q_D(const QDateTimeAxis); |
|
257 | 271 | return d->m_tickCount; |
|
258 | 272 | } |
|
259 | 273 | |
|
260 | 274 | /*! |
|
261 | 275 | Returns the type of the axis |
|
262 | 276 | */ |
|
263 | 277 | QAbstractAxis::AxisType QDateTimeAxis::type() const |
|
264 | 278 | { |
|
265 | 279 | return AxisTypeDateTime; |
|
266 | 280 | } |
|
267 | 281 | |
|
268 | 282 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
269 | 283 | |
|
270 | 284 | QDateTimeAxisPrivate::QDateTimeAxisPrivate(QDateTimeAxis* q): |
|
271 | 285 | QAbstractAxisPrivate(q), |
|
272 | 286 | m_min(QDateTime::fromMSecsSinceEpoch(0)), |
|
273 | 287 | m_max(QDateTime::fromMSecsSinceEpoch(0)), |
|
274 | 288 | m_tickCount(5) |
|
275 | 289 | { |
|
276 | 290 | m_format = "dd-MM-yyyy\nh:mm"; |
|
277 | 291 | } |
|
278 | 292 | |
|
279 | 293 | QDateTimeAxisPrivate::~QDateTimeAxisPrivate() |
|
280 | 294 | { |
|
281 | 295 | |
|
282 | 296 | } |
|
283 | 297 | |
|
284 | 298 | void QDateTimeAxisPrivate::handleDomainUpdated() |
|
285 | 299 | { |
|
286 | 300 | Q_Q(QDateTimeAxis); |
|
287 | 301 | Domain* domain = qobject_cast<Domain*>(sender()); |
|
288 | 302 | Q_ASSERT(domain); |
|
289 | 303 | |
|
290 | 304 | if(orientation()==Qt::Horizontal){ |
|
291 | 305 | q->setRange(QDateTime::fromMSecsSinceEpoch(domain->minX()), QDateTime::fromMSecsSinceEpoch(domain->maxX())); |
|
292 | 306 | }else if(orientation()==Qt::Vertical){ |
|
293 | 307 | q->setRange(QDateTime::fromMSecsSinceEpoch(domain->minY()), QDateTime::fromMSecsSinceEpoch(domain->maxY())); |
|
294 | 308 | } |
|
295 | 309 | } |
|
296 | 310 | |
|
297 | 311 | |
|
298 | 312 | void QDateTimeAxisPrivate::setMin(const QVariant &min) |
|
299 | 313 | { |
|
300 | 314 | Q_Q(QDateTimeAxis); |
|
301 | 315 | if (min.canConvert(QVariant::DateTime)) |
|
302 | 316 | q->setMin(min.toDateTime()); |
|
303 | 317 | } |
|
304 | 318 | |
|
305 | 319 | void QDateTimeAxisPrivate::setMax(const QVariant &max) |
|
306 | 320 | { |
|
307 | 321 | |
|
308 | 322 | Q_Q(QDateTimeAxis); |
|
309 | 323 | if (max.canConvert(QVariant::DateTime)) |
|
310 | 324 | q->setMax(max.toDateTime()); |
|
311 | 325 | } |
|
312 | 326 | |
|
313 | 327 | void QDateTimeAxisPrivate::setRange(const QVariant &min, const QVariant &max) |
|
314 | 328 | { |
|
315 | 329 | Q_Q(QDateTimeAxis); |
|
316 | 330 | if (min.canConvert(QVariant::DateTime) && max.canConvert(QVariant::DateTime)) |
|
317 | 331 | q->setRange(min.toDateTime(), max.toDateTime()); |
|
318 | 332 | } |
|
319 | 333 | |
|
320 | 334 | ChartAxis* QDateTimeAxisPrivate::createGraphics(ChartPresenter* presenter) |
|
321 | 335 | { |
|
322 | 336 | Q_Q(QDateTimeAxis); |
|
323 | 337 | if(m_orientation == Qt::Vertical){ |
|
324 | 338 | return new ChartDateTimeAxisY(q,presenter); |
|
325 | 339 | }else{ |
|
326 | 340 | return new ChartDateTimeAxisX(q,presenter); |
|
327 | 341 | } |
|
328 | 342 | |
|
329 | 343 | } |
|
330 | 344 | |
|
331 | 345 | void QDateTimeAxisPrivate::intializeDomain(Domain* domain) |
|
332 | 346 | { |
|
333 | 347 | Q_Q(QDateTimeAxis); |
|
334 | 348 | if(m_max == m_min) { |
|
335 | 349 | if(m_orientation==Qt::Vertical){ |
|
336 | 350 | q->setRange(QDateTime::fromMSecsSinceEpoch(domain->minY()), QDateTime::fromMSecsSinceEpoch(domain->maxY())); |
|
337 | 351 | }else{ |
|
338 | 352 | q->setRange(QDateTime::fromMSecsSinceEpoch(domain->minX()), QDateTime::fromMSecsSinceEpoch(domain->maxX())); |
|
339 | 353 | } |
|
340 | 354 | } else { |
|
341 | 355 | if(m_orientation==Qt::Vertical){ |
|
342 | 356 | domain->setRangeY(m_min.toMSecsSinceEpoch(), m_max.toMSecsSinceEpoch()); |
|
343 | 357 | }else{ |
|
344 | 358 | domain->setRangeX(m_min.toMSecsSinceEpoch(), m_max.toMSecsSinceEpoch()); |
|
345 | 359 | } |
|
346 | 360 | } |
|
347 | 361 | } |
|
348 | 362 | |
|
349 | 363 | #include "moc_qdatetimeaxis.cpp" |
|
350 | 364 | #include "moc_qdatetimeaxis_p.cpp" |
|
351 | 365 | |
|
352 | 366 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,75 +1,77 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #ifndef QDATETIMEAXIS_H |
|
22 | 22 | #define QDATETIMEAXIS_H |
|
23 | 23 | |
|
24 | 24 | #include "qabstractaxis.h" |
|
25 | 25 | |
|
26 | 26 | class QDateTime; |
|
27 | 27 | |
|
28 | 28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | 29 | |
|
30 | 30 | class QDateTimeAxisPrivate; |
|
31 | 31 | |
|
32 | 32 | class QTCOMMERCIALCHART_EXPORT QDateTimeAxis : public QAbstractAxis |
|
33 | 33 | { |
|
34 | 34 | Q_OBJECT |
|
35 | 35 | Q_PROPERTY(int tickCount READ tickCount WRITE setTickCount) |
|
36 | 36 | Q_PROPERTY(QDateTime min READ min WRITE setMin NOTIFY minChanged) |
|
37 | 37 | Q_PROPERTY(QDateTime max READ max WRITE setMax NOTIFY maxChanged) |
|
38 | Q_PROPERTY(QString format READ format WRITE setFormat NOTIFY formatChanged) | |
|
38 | 39 | |
|
39 | 40 | public: |
|
40 | 41 | explicit QDateTimeAxis(QObject *parent = 0); |
|
41 | 42 | ~QDateTimeAxis(); |
|
42 | 43 | |
|
43 | 44 | protected: |
|
44 | 45 | QDateTimeAxis(QDateTimeAxisPrivate &d,QObject *parent = 0); |
|
45 | 46 | |
|
46 | 47 | public: |
|
47 | 48 | AxisType type() const; |
|
48 | 49 | |
|
49 | 50 | //range handling |
|
50 | 51 | void setMin(QDateTime min); |
|
51 | 52 | QDateTime min() const; |
|
52 | 53 | void setMax(QDateTime max); |
|
53 | 54 | QDateTime max() const; |
|
54 | 55 | void setRange(QDateTime min, QDateTime max); |
|
55 | 56 | |
|
56 | 57 | void setFormat(QString format); |
|
57 | 58 | QString format() const; |
|
58 | 59 | |
|
59 | 60 | //ticks handling |
|
60 | 61 | void setTickCount(int count); |
|
61 | 62 | int tickCount() const; |
|
62 | 63 | |
|
63 | 64 | Q_SIGNALS: |
|
64 | 65 | void minChanged(QDateTime min); |
|
65 | 66 | void maxChanged(QDateTime max); |
|
66 | 67 | void rangeChanged(QDateTime min, QDateTime max); |
|
68 | void formatChanged(QString format); | |
|
67 | 69 | |
|
68 | 70 | private: |
|
69 | 71 | Q_DECLARE_PRIVATE(QDateTimeAxis) |
|
70 | 72 | Q_DISABLE_COPY(QDateTimeAxis) |
|
71 | 73 | }; |
|
72 | 74 | |
|
73 | 75 | QTCOMMERCIALCHART_END_NAMESPACE |
|
74 | 76 | |
|
75 | 77 | #endif // QDATETIMEAXIS_H |
General Comments 0
You need to be logged in to leave comments.
Login now