@@ -0,0 +1,35 | |||||
|
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/qmlcustomizations/loader.qml")); | |||
|
32 | viewer->showExpanded(); | |||
|
33 | ||||
|
34 | return app->exec(); | |||
|
35 | } |
@@ -0,0 +1,44 | |||||
|
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.0 | |||
|
23 | ||||
|
24 | Rectangle { | |||
|
25 | anchors.fill: parent | |||
|
26 | ||||
|
27 | ChartView { | |||
|
28 | id: chart | |||
|
29 | title: "Top-5 car brand shares in Finland" | |||
|
30 | anchors.fill: parent | |||
|
31 | theme: ChartView.ChartThemeLight | |||
|
32 | legend: ChartView.LegendBottom | |||
|
33 | animationOptions: ChartView.SeriesAnimations | |||
|
34 | ||||
|
35 | PieSeries { | |||
|
36 | id: pieSeries | |||
|
37 | PieSlice { label: "Volkswagen"; value: 13.5 } | |||
|
38 | PieSlice { label: "Toyota"; value: 10.9 } | |||
|
39 | PieSlice { label: "Ford"; value: 8.6 } | |||
|
40 | PieSlice { label: "Skoda"; value: 8.2 } | |||
|
41 | PieSlice { label: "Volvo"; value: 6.8 } | |||
|
42 | } | |||
|
43 | } | |||
|
44 | } |
@@ -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,98 | |||||
|
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.0 | |||
|
23 | ||||
|
24 | Rectangle { | |||
|
25 | width: parent.width | |||
|
26 | height: parent.height | |||
|
27 | property int __activeIndex: 1 | |||
|
28 | property real __intervalCoefficient: 0 | |||
|
29 | ||||
|
30 | ||||
|
31 | ChartView { | |||
|
32 | id: chartView | |||
|
33 | anchors.fill: parent | |||
|
34 | title: "Wheel of fortune" | |||
|
35 | legend: ChartView.LegendDisabled | |||
|
36 | ||||
|
37 | PieSeries { | |||
|
38 | id: wheelOfFortune | |||
|
39 | } | |||
|
40 | ||||
|
41 | SplineSeries { | |||
|
42 | id: splineSeries | |||
|
43 | } | |||
|
44 | ||||
|
45 | ScatterSeries { | |||
|
46 | id: scatterSeries | |||
|
47 | } | |||
|
48 | } | |||
|
49 | ||||
|
50 | ||||
|
51 | Component.onCompleted: { | |||
|
52 | __intervalCoefficient = Math.random() + 0.1; | |||
|
53 | console.log("__intervalCoefficient: " + __intervalCoefficient); | |||
|
54 | ||||
|
55 | for (var i = 0; i < 20; i++) | |||
|
56 | wheelOfFortune.append("", 1); | |||
|
57 | ||||
|
58 | var interval = 1; | |||
|
59 | for (var j = 0; interval < 800; j++) { | |||
|
60 | interval = __intervalCoefficient * j * j; | |||
|
61 | splineSeries.append(j, interval); | |||
|
62 | } | |||
|
63 | chartView.axisX.max = j; | |||
|
64 | chartView.axisY.max = 1000; | |||
|
65 | } | |||
|
66 | ||||
|
67 | Timer { | |||
|
68 | triggeredOnStart: true | |||
|
69 | running: true | |||
|
70 | repeat: true | |||
|
71 | interval: 100 | |||
|
72 | onTriggered: { | |||
|
73 | // console.log("interval: " + interval); | |||
|
74 | var index = __activeIndex % wheelOfFortune.count; | |||
|
75 | if (interval < 700) { | |||
|
76 | scatterSeries.clear(); | |||
|
77 | wheelOfFortune.at(index).exploded = false; | |||
|
78 | __activeIndex++; | |||
|
79 | index = __activeIndex % wheelOfFortune.count; | |||
|
80 | wheelOfFortune.at(index).exploded = true; | |||
|
81 | interval = splineSeries.at(__activeIndex).y; | |||
|
82 | scatterSeries.append(__activeIndex, interval); | |||
|
83 | } else { | |||
|
84 | // Switch the colors of the slice and the border | |||
|
85 | wheelOfFortune.at(index).borderWidth = 2; | |||
|
86 | var borderColor = wheelOfFortune.at(index).borderColor; | |||
|
87 | wheelOfFortune.at(index).borderColor = wheelOfFortune.at(index).color; | |||
|
88 | wheelOfFortune.at(index).color = borderColor; | |||
|
89 | } | |||
|
90 | } | |||
|
91 | } | |||
|
92 | ||||
|
93 | // Loader { | |||
|
94 | // id: loader | |||
|
95 | // anchors.fill: parent | |||
|
96 | // source: "View" + (__viewNumber % 5 + 1) + ".qml"; | |||
|
97 | // } | |||
|
98 | } |
@@ -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,10 | |||||
|
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) | |||
|
9 | ||||
|
10 | !system_build:mac: QMAKE_POST_LINK += "$$MAC_POST_LINK_PREFIX $$MAC_DEMOS_BIN_DIR" |
@@ -0,0 +1,7 | |||||
|
1 | <RCC> | |||
|
2 | <qresource prefix="/"> | |||
|
3 | <file>qml/qmlcustomizations/loader.qml</file> | |||
|
4 | <file>qml/qmlcustomizations/main.qml</file> | |||
|
5 | <file>qml/qmlcustomizations/View1.qml</file> | |||
|
6 | </qresource> | |||
|
7 | </RCC> |
@@ -10,4 +10,5 SUBDIRS += chartthemes \ | |||||
10 | qmlchart \ |
|
10 | qmlchart \ | |
11 | qmlweather \ |
|
11 | qmlweather \ | |
12 | qmlf1legends \ |
|
12 | qmlf1legends \ | |
|
13 | qmlcustomizations \ | |||
13 | qmlcustommodel |
|
14 | qmlcustommodel |
@@ -71,25 +71,6 QDeclarativeListProperty<DeclarativeBarSet> DeclarativeBarSeries::initialBarSets | |||||
71 | return QDeclarativeListProperty<DeclarativeBarSet>(this, 0, &DeclarativeBarSeries::appendInitialBarSets); |
|
71 | return QDeclarativeListProperty<DeclarativeBarSet>(this, 0, &DeclarativeBarSeries::appendInitialBarSets); | |
72 | } |
|
72 | } | |
73 |
|
73 | |||
74 | bool DeclarativeBarSeries::setDeclarativeModel(DeclarativeTableModel *model) |
|
|||
75 | { |
|
|||
76 | QAbstractItemModel *m = qobject_cast<QAbstractItemModel *>(model); |
|
|||
77 | bool value(false); |
|
|||
78 | if (m) { |
|
|||
79 | // setModel(m); |
|
|||
80 | //setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical); |
|
|||
81 | // setModelMapping(0, 1, 1, Qt::Vertical); |
|
|||
82 | } else { |
|
|||
83 | qWarning("DeclarativeBarSeries: Illegal model"); |
|
|||
84 | } |
|
|||
85 | return value; |
|
|||
86 | } |
|
|||
87 |
|
||||
88 | DeclarativeTableModel *DeclarativeBarSeries::declarativeModel() |
|
|||
89 | { |
|
|||
90 | return 0;//qobject_cast<DeclarativeTableModel *>(model()); |
|
|||
91 | } |
|
|||
92 |
|
||||
93 | void DeclarativeBarSeries::setBarCategories(QStringList categories) |
|
74 | void DeclarativeBarSeries::setBarCategories(QStringList categories) | |
94 | { |
|
75 | { | |
95 | setCategories(categories); |
|
76 | setCategories(categories); | |
@@ -123,25 +104,6 QDeclarativeListProperty<DeclarativeBarSet> DeclarativeGroupedBarSeries::initial | |||||
123 | return QDeclarativeListProperty<DeclarativeBarSet>(this, 0, &DeclarativeGroupedBarSeries::appendInitialBarSets); |
|
104 | return QDeclarativeListProperty<DeclarativeBarSet>(this, 0, &DeclarativeGroupedBarSeries::appendInitialBarSets); | |
124 | } |
|
105 | } | |
125 |
|
106 | |||
126 | bool DeclarativeGroupedBarSeries::setDeclarativeModel(DeclarativeTableModel *model) |
|
|||
127 | { |
|
|||
128 | QAbstractItemModel *m = qobject_cast<QAbstractItemModel *>(model); |
|
|||
129 | bool value(false); |
|
|||
130 | if (m) { |
|
|||
131 | // setModel(m); |
|
|||
132 | //setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical); |
|
|||
133 | // setModelMapping(0, 1, 1, Qt::Vertical); |
|
|||
134 | } else { |
|
|||
135 | qWarning("DeclarativeGroupedBarSeries: Illegal model"); |
|
|||
136 | } |
|
|||
137 | return value; |
|
|||
138 | } |
|
|||
139 |
|
||||
140 | DeclarativeTableModel *DeclarativeGroupedBarSeries::declarativeModel() |
|
|||
141 | { |
|
|||
142 | return 0; //qobject_cast<DeclarativeTableModel *>(model()); |
|
|||
143 | } |
|
|||
144 |
|
||||
145 | void DeclarativeGroupedBarSeries::setBarCategories(QStringList categories) |
|
107 | void DeclarativeGroupedBarSeries::setBarCategories(QStringList categories) | |
146 | { |
|
108 | { | |
147 | setCategories(categories); |
|
109 | setCategories(categories); |
@@ -51,7 +51,6 class DeclarativeBarSeries : public QBarSeries, public QDeclarativeParserStatus | |||||
51 | { |
|
51 | { | |
52 | Q_OBJECT |
|
52 | Q_OBJECT | |
53 | Q_INTERFACES(QDeclarativeParserStatus) |
|
53 | Q_INTERFACES(QDeclarativeParserStatus) | |
54 | Q_PROPERTY(DeclarativeTableModel *model READ declarativeModel WRITE setDeclarativeModel) |
|
|||
55 | Q_PROPERTY(QStringList barCategories READ barCategories WRITE setBarCategories) |
|
54 | Q_PROPERTY(QStringList barCategories READ barCategories WRITE setBarCategories) | |
56 | Q_PROPERTY(QDeclarativeListProperty<DeclarativeBarSet> initialBarSets READ initialBarSets) |
|
55 | Q_PROPERTY(QDeclarativeListProperty<DeclarativeBarSet> initialBarSets READ initialBarSets) | |
57 | Q_CLASSINFO("DefaultProperty", "initialBarSets") |
|
56 | Q_CLASSINFO("DefaultProperty", "initialBarSets") | |
@@ -67,10 +66,6 public: // from QDeclarativeParserStatus | |||||
67 | void classBegin(); |
|
66 | void classBegin(); | |
68 | void componentComplete(); |
|
67 | void componentComplete(); | |
69 |
|
68 | |||
70 | public: |
|
|||
71 | bool setDeclarativeModel(DeclarativeTableModel *model); |
|
|||
72 | DeclarativeTableModel *declarativeModel(); |
|
|||
73 |
|
||||
74 | public Q_SLOTS: |
|
69 | public Q_SLOTS: | |
75 | static void appendInitialBarSets(QDeclarativeListProperty<DeclarativeBarSet> * /*list*/, DeclarativeBarSet * /*element*/) {} |
|
70 | static void appendInitialBarSets(QDeclarativeListProperty<DeclarativeBarSet> * /*list*/, DeclarativeBarSet * /*element*/) {} | |
76 | }; |
|
71 | }; | |
@@ -79,7 +74,6 class DeclarativeGroupedBarSeries : public QGroupedBarSeries, public QDeclarativ | |||||
79 | { |
|
74 | { | |
80 | Q_OBJECT |
|
75 | Q_OBJECT | |
81 | Q_INTERFACES(QDeclarativeParserStatus) |
|
76 | Q_INTERFACES(QDeclarativeParserStatus) | |
82 | Q_PROPERTY(DeclarativeTableModel *model READ declarativeModel WRITE setDeclarativeModel) |
|
|||
83 | Q_PROPERTY(QStringList barCategories READ barCategories WRITE setBarCategories) |
|
77 | Q_PROPERTY(QStringList barCategories READ barCategories WRITE setBarCategories) | |
84 | Q_PROPERTY(QDeclarativeListProperty<DeclarativeBarSet> initialBarSets READ initialBarSets) |
|
78 | Q_PROPERTY(QDeclarativeListProperty<DeclarativeBarSet> initialBarSets READ initialBarSets) | |
85 | Q_CLASSINFO("DefaultProperty", "initialBarSets") |
|
79 | Q_CLASSINFO("DefaultProperty", "initialBarSets") | |
@@ -95,8 +89,6 public: // from QDeclarativeParserStatus | |||||
95 | public: |
|
89 | public: | |
96 | void setBarCategories(QStringList categories); |
|
90 | void setBarCategories(QStringList categories); | |
97 | QStringList barCategories(); |
|
91 | QStringList barCategories(); | |
98 | bool setDeclarativeModel(DeclarativeTableModel *model); |
|
|||
99 | DeclarativeTableModel *declarativeModel(); |
|
|||
100 |
|
92 | |||
101 | public Q_SLOTS: |
|
93 | public Q_SLOTS: | |
102 | static void appendInitialBarSets(QDeclarativeListProperty<DeclarativeBarSet> * /*list*/, DeclarativeBarSet * /*element*/) {} |
|
94 | static void appendInitialBarSets(QDeclarativeListProperty<DeclarativeBarSet> * /*list*/, DeclarativeBarSet * /*element*/) {} |
@@ -57,6 +57,7 void DeclarativeChart::componentComplete() | |||||
57 | // qDebug() << "DeclarativeChart::componentComplete(), maxX: " << axisX()->max(); |
|
57 | // qDebug() << "DeclarativeChart::componentComplete(), maxX: " << axisX()->max(); | |
58 | foreach(QObject *child, children()) { |
|
58 | foreach(QObject *child, children()) { | |
59 | if (qobject_cast<QAbstractSeries *>(child)) { |
|
59 | if (qobject_cast<QAbstractSeries *>(child)) { | |
|
60 | // qDebug() << "DeclarativeChart::componentComplete(), add: " << child; | |||
60 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(child)); |
|
61 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(child)); | |
61 | } |
|
62 | } | |
62 | } |
|
63 | } |
@@ -32,7 +32,6 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
32 | class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries |
|
32 | class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries | |
33 | { |
|
33 | { | |
34 | Q_OBJECT |
|
34 | Q_OBJECT | |
35 | Q_PROPERTY(DeclarativeTableModel *model READ declarativeModel WRITE setDeclarativeModel) |
|
|||
36 | Q_PROPERTY(QColor color READ color WRITE setColor) |
|
35 | Q_PROPERTY(QColor color READ color WRITE setColor) | |
37 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) |
|
36 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) | |
38 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") |
|
37 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") | |
@@ -45,6 +44,7 public: // from QLineSeries | |||||
45 | Q_INVOKABLE void append(qreal x, qreal y) { QLineSeries::append(x, y); } |
|
44 | Q_INVOKABLE void append(qreal x, qreal y) { QLineSeries::append(x, y); } | |
46 | Q_INVOKABLE void remove(qreal x, qreal y) { QLineSeries::remove(x, y); } |
|
45 | Q_INVOKABLE void remove(qreal x, qreal y) { QLineSeries::remove(x, y); } | |
47 | Q_INVOKABLE void clear() { QLineSeries::removeAll(); } |
|
46 | Q_INVOKABLE void clear() { QLineSeries::removeAll(); } | |
|
47 | Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); } | |||
48 |
|
48 | |||
49 | public Q_SLOTS: |
|
49 | public Q_SLOTS: | |
50 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
50 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
@@ -27,6 +27,47 | |||||
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
29 |
|
29 | |||
|
30 | DeclarativePieSlice::DeclarativePieSlice(QObject *parent) : | |||
|
31 | QPieSlice(parent) | |||
|
32 | { | |||
|
33 | } | |||
|
34 | ||||
|
35 | QColor DeclarativePieSlice::color() | |||
|
36 | { | |||
|
37 | return brush().color(); | |||
|
38 | } | |||
|
39 | ||||
|
40 | void DeclarativePieSlice::setColor(QColor color) | |||
|
41 | { | |||
|
42 | QBrush b = brush(); | |||
|
43 | b.setColor(color); | |||
|
44 | setBrush(b); | |||
|
45 | } | |||
|
46 | ||||
|
47 | QColor DeclarativePieSlice::borderColor() | |||
|
48 | { | |||
|
49 | return pen().color(); | |||
|
50 | } | |||
|
51 | ||||
|
52 | void DeclarativePieSlice::setBorderColor(QColor color) | |||
|
53 | { | |||
|
54 | QPen p = pen(); | |||
|
55 | p.setColor(color); | |||
|
56 | setPen(p); | |||
|
57 | } | |||
|
58 | ||||
|
59 | int DeclarativePieSlice::borderWidth() | |||
|
60 | { | |||
|
61 | return pen().width(); | |||
|
62 | } | |||
|
63 | ||||
|
64 | void DeclarativePieSlice::setBorderWidth(int width) | |||
|
65 | { | |||
|
66 | QPen p = pen(); | |||
|
67 | p.setWidth(width); | |||
|
68 | setPen(p); | |||
|
69 | } | |||
|
70 | ||||
30 | DeclarativePieSeries::DeclarativePieSeries(QObject *parent) : |
|
71 | DeclarativePieSeries::DeclarativePieSeries(QObject *parent) : | |
31 | QPieSeries(parent) |
|
72 | QPieSeries(parent) | |
32 | { |
|
73 | { | |
@@ -39,8 +80,8 void DeclarativePieSeries::classBegin() | |||||
39 | void DeclarativePieSeries::componentComplete() |
|
80 | void DeclarativePieSeries::componentComplete() | |
40 | { |
|
81 | { | |
41 | foreach(QObject *child, children()) { |
|
82 | foreach(QObject *child, children()) { | |
42 |
if (qobject_cast< |
|
83 | if (qobject_cast<DeclarativePieSlice *>(child)) { | |
43 |
QPieSeries::append(qobject_cast< |
|
84 | QPieSeries::append(qobject_cast<DeclarativePieSlice *>(child)); | |
44 | } else if(qobject_cast<QVPieModelMapper *>(child)) { |
|
85 | } else if(qobject_cast<QVPieModelMapper *>(child)) { | |
45 | QVPieModelMapper *mapper = qobject_cast<QVPieModelMapper *>(child); |
|
86 | QVPieModelMapper *mapper = qobject_cast<QVPieModelMapper *>(child); | |
46 | mapper->setSeries(this); |
|
87 | mapper->setSeries(this); | |
@@ -63,43 +104,32 void DeclarativePieSeries::appendSeriesChildren(QDeclarativeListProperty<QObject | |||||
63 | Q_UNUSED(element); |
|
104 | Q_UNUSED(element); | |
64 | } |
|
105 | } | |
65 |
|
106 | |||
66 |
|
|
107 | DeclarativePieSlice *DeclarativePieSeries::at(int index) | |
67 | { |
|
108 | { | |
68 | QList<QPieSlice*> sliceList = slices(); |
|
109 | QList<QPieSlice*> sliceList = slices(); | |
69 | if (index < sliceList.count()) |
|
110 | if (index < sliceList.count()) | |
70 | return sliceList[index]; |
|
111 | return qobject_cast<DeclarativePieSlice *>(sliceList[index]); | |
71 |
|
112 | |||
72 | return 0; |
|
113 | return 0; | |
73 | } |
|
114 | } | |
74 |
|
115 | |||
75 |
|
|
116 | DeclarativePieSlice* DeclarativePieSeries::find(QString label) | |
76 | { |
|
117 | { | |
77 | foreach (QPieSlice *slice, slices()) { |
|
118 | foreach (QPieSlice *slice, slices()) { | |
78 | if (slice->label() == label) |
|
119 | if (slice->label() == label) | |
79 | return slice; |
|
120 | return qobject_cast<DeclarativePieSlice *>(slice); | |
80 | } |
|
121 | } | |
81 | return 0; |
|
122 | return 0; | |
82 | } |
|
123 | } | |
83 |
|
124 | |||
84 |
|
|
125 | DeclarativePieSlice* DeclarativePieSeries::append(QString label, qreal value) | |
85 | { |
|
126 | { | |
86 | // TODO: parameter order is wrong, switch it: |
|
127 | // TODO: parameter order is wrong, switch it: | |
87 | return QPieSeries::append(name, value); |
|
128 | DeclarativePieSlice *slice = new DeclarativePieSlice(this); | |
88 | } |
|
129 | slice->setLabel(label); | |
89 |
|
130 | slice->setValue(value); | ||
90 | void DeclarativePieSeries::setPieModel(DeclarativeTableModel *model) |
|
131 | QPieSeries::append(slice); | |
91 | { |
|
132 | return slice; | |
92 | QAbstractItemModel *m = qobject_cast<QAbstractItemModel *>(model); |
|
|||
93 | if (m) { |
|
|||
94 | // QPieSeries::setModel(m); |
|
|||
95 | } else { |
|
|||
96 | qWarning("DeclarativePieSeries: Illegal model"); |
|
|||
97 | } |
|
|||
98 | } |
|
|||
99 |
|
||||
100 | DeclarativeTableModel *DeclarativePieSeries::pieModel() |
|
|||
101 | { |
|
|||
102 | return 0;//qobject_cast<DeclarativeTableModel *>(model()); |
|
|||
103 | } |
|
133 | } | |
104 |
|
134 | |||
105 | #include "moc_declarativepieseries.cpp" |
|
135 | #include "moc_declarativepieseries.cpp" |
@@ -33,22 +33,36 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
33 |
|
33 | |||
34 | class QChart; |
|
34 | class QChart; | |
35 |
|
35 | |||
|
36 | class DeclarativePieSlice: public QPieSlice | |||
|
37 | { | |||
|
38 | Q_OBJECT | |||
|
39 | Q_PROPERTY(QColor color READ color WRITE setColor) | |||
|
40 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor) | |||
|
41 | Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth) | |||
|
42 | ||||
|
43 | public: | |||
|
44 | explicit DeclarativePieSlice(QObject *parent = 0); | |||
|
45 | QColor color(); | |||
|
46 | void setColor(QColor color); | |||
|
47 | QColor borderColor(); | |||
|
48 | void setBorderColor(QColor color); | |||
|
49 | int borderWidth(); | |||
|
50 | void setBorderWidth(int width); | |||
|
51 | }; | |||
|
52 | ||||
36 | class DeclarativePieSeries : public QPieSeries, public QDeclarativeParserStatus |
|
53 | class DeclarativePieSeries : public QPieSeries, public QDeclarativeParserStatus | |
37 | { |
|
54 | { | |
38 | Q_OBJECT |
|
55 | Q_OBJECT | |
39 | Q_INTERFACES(QDeclarativeParserStatus) |
|
56 | Q_INTERFACES(QDeclarativeParserStatus) | |
40 | Q_PROPERTY(DeclarativeTableModel *model READ pieModel WRITE setPieModel) |
|
|||
41 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
57 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
42 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
58 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
43 |
|
59 | |||
44 | public: |
|
60 | public: | |
45 | explicit DeclarativePieSeries(QObject *parent = 0); |
|
61 | explicit DeclarativePieSeries(QObject *parent = 0); | |
46 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
62 | QDeclarativeListProperty<QObject> seriesChildren(); | |
47 | DeclarativeTableModel *pieModel(); |
|
63 | Q_INVOKABLE DeclarativePieSlice *at(int index); | |
48 | void setPieModel(DeclarativeTableModel *model); |
|
64 | Q_INVOKABLE DeclarativePieSlice* find(QString label); | |
49 | Q_INVOKABLE QPieSlice *at(int index); |
|
65 | Q_INVOKABLE DeclarativePieSlice* append(QString label, qreal value); | |
50 | Q_INVOKABLE QPieSlice* find(QString label); |
|
|||
51 | Q_INVOKABLE QPieSlice* append(QString label, qreal value); |
|
|||
52 |
|
66 | |||
53 | public: |
|
67 | public: | |
54 | void classBegin(); |
|
68 | void classBegin(); |
@@ -30,7 +30,6 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
30 | class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeries |
|
30 | class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeries | |
31 | { |
|
31 | { | |
32 | Q_OBJECT |
|
32 | Q_OBJECT | |
33 | Q_PROPERTY(DeclarativeTableModel *model READ declarativeModel WRITE setDeclarativeModel) |
|
|||
34 | Q_PROPERTY(QColor color READ color WRITE setColor) |
|
33 | Q_PROPERTY(QColor color READ color WRITE setColor) | |
35 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) |
|
34 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) | |
36 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") |
|
35 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") | |
@@ -43,6 +42,7 public: // from QScatterSeries | |||||
43 | Q_INVOKABLE void append(qreal x, qreal y) { QScatterSeries::append(x, y); } |
|
42 | Q_INVOKABLE void append(qreal x, qreal y) { QScatterSeries::append(x, y); } | |
44 | Q_INVOKABLE void remove(qreal x, qreal y) { QScatterSeries::remove(x, y); } |
|
43 | Q_INVOKABLE void remove(qreal x, qreal y) { QScatterSeries::remove(x, y); } | |
45 | Q_INVOKABLE void clear() { QScatterSeries::removeAll(); } |
|
44 | Q_INVOKABLE void clear() { QScatterSeries::removeAll(); } | |
|
45 | Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); } | |||
46 |
|
46 | |||
47 | public Q_SLOTS: |
|
47 | public Q_SLOTS: | |
48 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
48 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
@@ -21,6 +21,7 | |||||
21 | #include "declarativesplineseries.h" |
|
21 | #include "declarativesplineseries.h" | |
22 | #include "declarativechart.h" |
|
22 | #include "declarativechart.h" | |
23 | #include <QChart> |
|
23 | #include <QChart> | |
|
24 | #include "declarativexypoint.h" | |||
24 |
|
25 | |||
25 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
26 |
|
27 |
@@ -31,7 +31,6 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
31 | class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries |
|
31 | class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries | |
32 | { |
|
32 | { | |
33 | Q_OBJECT |
|
33 | Q_OBJECT | |
34 | Q_PROPERTY(DeclarativeTableModel *model READ declarativeModel WRITE setDeclarativeModel) |
|
|||
35 | Q_PROPERTY(QColor color READ color WRITE setColor) |
|
34 | Q_PROPERTY(QColor color READ color WRITE setColor) | |
36 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) |
|
35 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) | |
37 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") |
|
36 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") | |
@@ -44,6 +43,7 public: // from QSplineSeries | |||||
44 | Q_INVOKABLE void append(qreal x, qreal y) { QSplineSeries::append(x, y); } |
|
43 | Q_INVOKABLE void append(qreal x, qreal y) { QSplineSeries::append(x, y); } | |
45 | Q_INVOKABLE void remove(qreal x, qreal y) { QSplineSeries::remove(x, y); } |
|
44 | Q_INVOKABLE void remove(qreal x, qreal y) { QSplineSeries::remove(x, y); } | |
46 | Q_INVOKABLE void clear() { QSplineSeries::removeAll(); } |
|
45 | Q_INVOKABLE void clear() { QSplineSeries::removeAll(); } | |
|
46 | Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); } | |||
47 |
|
47 | |||
48 | public Q_SLOTS: |
|
48 | public Q_SLOTS: | |
49 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
49 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
@@ -31,6 +31,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
31 | class DeclarativeXyPoint : public QObject, public QPointF |
|
31 | class DeclarativeXyPoint : public QObject, public QPointF | |
32 | { |
|
32 | { | |
33 | Q_OBJECT |
|
33 | Q_OBJECT | |
|
34 | // TODO: make the setters change the value, if parented by a series | |||
34 | Q_PROPERTY(qreal x READ x WRITE setX /*NOTIFY dataXChanged*/) |
|
35 | Q_PROPERTY(qreal x READ x WRITE setX /*NOTIFY dataXChanged*/) | |
35 | Q_PROPERTY(qreal y READ y WRITE setY /*NOTIFY dataYChanged*/) |
|
36 | Q_PROPERTY(qreal y READ y WRITE setY /*NOTIFY dataYChanged*/) | |
36 |
|
37 |
@@ -29,45 +29,12 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
29 |
|
29 | |||
30 | DeclarativeXySeries::DeclarativeXySeries() |
|
30 | DeclarativeXySeries::DeclarativeXySeries() | |
31 | { |
|
31 | { | |
32 | // TODO: XYModelMapper implementation has changed, this code has to be updated |
|
|||
33 |
|
||||
34 | // All the inherited objects must be of type QXYSeries, so it is safe to cast |
|
|||
35 | // QXYSeries *series = reinterpret_cast<QXYSeries *>(this); |
|
|||
36 | // // TODO: mapper should be available on the series by default |
|
|||
37 | // QXYModelMapper *mapper = new QXYModelMapper(series); |
|
|||
38 | // mapper->setMapX(0); |
|
|||
39 | // mapper->setMapY(1); |
|
|||
40 | // mapper->setFirst(0); |
|
|||
41 | // mapper->setCount(-1); |
|
|||
42 | // mapper->setOrientation(Qt::Vertical); |
|
|||
43 | // series->setModelMapper(mapper); |
|
|||
44 | } |
|
32 | } | |
45 |
|
33 | |||
46 | DeclarativeXySeries::~DeclarativeXySeries() |
|
34 | DeclarativeXySeries::~DeclarativeXySeries() | |
47 | { |
|
35 | { | |
48 | } |
|
36 | } | |
49 |
|
37 | |||
50 | bool DeclarativeXySeries::setDeclarativeModel(DeclarativeTableModel *model) |
|
|||
51 | { |
|
|||
52 | QAbstractItemModel *m = qobject_cast<QAbstractItemModel *>(model); |
|
|||
53 | bool value(false); |
|
|||
54 | if (m) { |
|
|||
55 | // All the inherited objects must be of type QXYSeries, so it is safe to cast |
|
|||
56 | // QXYSeries *series = reinterpret_cast<QXYSeries *>(this); |
|
|||
57 | // series->setModel(m); |
|
|||
58 | } else { |
|
|||
59 | qWarning("DeclarativeXySeries: Illegal model"); |
|
|||
60 | } |
|
|||
61 | return value; |
|
|||
62 | } |
|
|||
63 |
|
||||
64 | DeclarativeTableModel *DeclarativeXySeries::declarativeModel() |
|
|||
65 | { |
|
|||
66 | // All the inherited objects must be of type QXYSeries, so it is safe to cast |
|
|||
67 | // QXYSeries *series = reinterpret_cast<QXYSeries *>(this); |
|
|||
68 | return 0; //qobject_cast<DeclarativeTableModel *>(series->model()); |
|
|||
69 | } |
|
|||
70 |
|
||||
71 | QColor DeclarativeXySeries::color() |
|
38 | QColor DeclarativeXySeries::color() | |
72 | { |
|
39 | { | |
73 | // All the inherited objects must be of type QXYSeries, so it is safe to cast |
|
40 | // All the inherited objects must be of type QXYSeries, so it is safe to cast | |
@@ -83,5 +50,18 void DeclarativeXySeries::setColor(QColor color) | |||||
83 | series->setPen(pen); |
|
50 | series->setPen(pen); | |
84 | } |
|
51 | } | |
85 |
|
52 | |||
|
53 | DeclarativeXyPoint *DeclarativeXySeries::at(int index) | |||
|
54 | { | |||
|
55 | QXYSeries *series = reinterpret_cast<QXYSeries *>(this); | |||
|
56 | if (index < series->count()) { | |||
|
57 | QPointF point = series->points().at(index); | |||
|
58 | DeclarativeXyPoint *xyPoint = new DeclarativeXyPoint(series); | |||
|
59 | xyPoint->setX(point.x()); | |||
|
60 | xyPoint->setY(point.y()); | |||
|
61 | return xyPoint; | |||
|
62 | } | |||
|
63 | return 0; | |||
|
64 | } | |||
|
65 | ||||
86 |
|
66 | |||
87 | QTCOMMERCIALCHART_END_NAMESPACE |
|
67 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -37,10 +37,9 public: | |||||
37 | ~DeclarativeXySeries(); |
|
37 | ~DeclarativeXySeries(); | |
38 |
|
38 | |||
39 | public: |
|
39 | public: | |
40 | bool setDeclarativeModel(DeclarativeTableModel *model); |
|
|||
41 | DeclarativeTableModel *declarativeModel(); |
|
|||
42 | QColor color(); |
|
40 | QColor color(); | |
43 | void setColor(QColor color); |
|
41 | void setColor(QColor color); | |
|
42 | DeclarativeXyPoint *at(int index); | |||
44 | }; |
|
43 | }; | |
45 |
|
44 | |||
46 | QTCOMMERCIALCHART_END_NAMESPACE |
|
45 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -54,7 +54,7 public: | |||||
54 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); |
|
54 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); | |
55 | qmlRegisterType<DeclarativeGroupedBarSeries>(uri, 1, 0, "GroupedBarSeries"); |
|
55 | qmlRegisterType<DeclarativeGroupedBarSeries>(uri, 1, 0, "GroupedBarSeries"); | |
56 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); |
|
56 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); | |
57 |
qmlRegisterType< |
|
57 | qmlRegisterType<DeclarativePieSlice>(uri, 1, 0, "PieSlice"); | |
58 | qmlRegisterType<DeclarativeTableModel>(uri, 1, 0, "ChartModel"); |
|
58 | qmlRegisterType<DeclarativeTableModel>(uri, 1, 0, "ChartModel"); | |
59 | qmlRegisterType<DeclarativeTableModelElement>(uri, 1, 0, "ChartModelElement"); |
|
59 | qmlRegisterType<DeclarativeTableModelElement>(uri, 1, 0, "ChartModelElement"); | |
60 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); |
|
60 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); |
General Comments 0
You need to be logged in to leave comments.
Login now