##// END OF EJS Templates
Separated series model stuff from data api in QML examples
Tero Ahola -
r1202:d898436e4875
parent child
Show More
@@ -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/qmlcustommodel/loader.qml"));
32 viewer->showExpanded();
33
34 return app->exec();
35 }
@@ -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,105
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
28 ChartView {
29 id: chart
30 title: "Top-5 car brand shares in Finland"
31 anchors.fill: parent
32 theme: ChartView.ChartThemeLight
33
34 // For dynamic data you can use the ChartModel API.
35 ChartModel {
36 id: chartModel
37 ChartModelElement { values: [0, "Volkswagen", 13.5] }
38 ChartModelElement { values: [0, "Toyota", 10.9] }
39 ChartModelElement { values: [0, "Ford", 8.6] }
40 ChartModelElement { values: [0, "Skoda", 8.2] }
41 ChartModelElement { values: [0, "Volvo", 6.8] }
42 }
43
44 LineSeries {
45 name: "line"
46 model: chartModel
47 modelMapper.mapX: 2
48 modelMapper.mapY: 2
49 }
50
51 PieSeries {
52 id: pieSeries
53 model: chartModel
54 size: 0.4
55 horizontalPosition: 0.2
56 verticalPosition: 0.3
57 // Define how your data maps to pie slices with the ModelMapper API of the pie series
58 modelMapper.mapLabels: 1
59 modelMapper.mapValues: 2
60 modelMapper.first: 0
61 modelMapper.count: -1 // "Undefined" = -1 by default
62 modelMapper.orientation: PieModelMapper.Vertical
63 }
64
65 AreaSeries {
66 name: "area"
67 upperSeries: LineSeries {
68 model: chartModel
69 modelMapper.mapX: 2
70 modelMapper.mapY: 2
71 }
72 lowerSeries: LineSeries {
73 model: chartModel
74 modelMapper.mapX: 2
75 modelMapper.mapY: 0
76 }
77 }
78
79 // TODO: BarSeries with ChartModel base model API
80 // BarSeries {
81 // model: chartModel
82 // modelMapper.first: 0
83 // }
84 }
85
86
87 // TODO: you could also implement appending to your model, for example:
88 // pieSeries.model.append(["Others", 52.0]);
89
90 // TODO: show how to use data from a list model in a chart view
91 // i.e. copy the data into a chart model
92 // ListModel {
93 // id: listModel
94 // ListElement {
95 // label: "Volkswagen"
96 // value: 13.5
97 // }
98 // ListElement {
99 // label: "Toyota"
100 // value: 10.9
101 // }
102 // // and so on...
103 // }
104
105 }
@@ -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,93
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <svg
3 xmlns:dc="http://purl.org/dc/elements/1.1/"
4 xmlns:cc="http://creativecommons.org/ns#"
5 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
6 xmlns:svg="http://www.w3.org/2000/svg"
7 xmlns="http://www.w3.org/2000/svg"
8 xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
9 xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
10 height="44px"
11 version="1.1"
12 viewBox="0 0 44 44"
13 width="44px"
14 x="0px"
15 y="0px"
16 id="svg2"
17 inkscape:version="0.47 r22583"
18 sodipodi:docname="qt.svg">
19 <metadata
20 id="metadata18">
21 <rdf:RDF>
22 <cc:Work
23 rdf:about="">
24 <dc:format>image/svg+xml</dc:format>
25 <dc:type
26 rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
27 </cc:Work>
28 </rdf:RDF>
29 </metadata>
30 <defs
31 id="defs16">
32 <inkscape:perspective
33 sodipodi:type="inkscape:persp3d"
34 inkscape:vp_x="0 : 22 : 1"
35 inkscape:vp_y="0 : 1000 : 0"
36 inkscape:vp_z="44 : 22 : 1"
37 inkscape:persp3d-origin="22 : 14.666667 : 1"
38 id="perspective2836" />
39 </defs>
40 <sodipodi:namedview
41 pagecolor="#ffffff"
42 bordercolor="#666666"
43 borderopacity="1"
44 objecttolerance="10"
45 gridtolerance="10"
46 guidetolerance="10"
47 inkscape:pageopacity="0"
48 inkscape:pageshadow="2"
49 inkscape:window-width="1920"
50 inkscape:window-height="1020"
51 id="namedview14"
52 showgrid="false"
53 inkscape:zoom="21.454545"
54 inkscape:cx="49.412871"
55 inkscape:cy="21.894358"
56 inkscape:window-x="-4"
57 inkscape:window-y="-4"
58 inkscape:window-maximized="1"
59 inkscape:current-layer="g3" />
60 <g
61 transform="matrix(0.18308778,0,0,0.18308778,6.6100946,3.2385199)"
62 id="g3">
63 <path
64 d="M 43.09,0.3586 C 40.94,0.0036 38.84,-0.0824 36.81,0.0776 31.968136,0.39505671 27.122677,0.73638425 22.28,1.0696 9.62,2.0816 0,12.4996 0,26.8896 l 0,169.7 14.19,13.2 28.87,-209.42 0.03,-0.011 z"
65 style="fill:#006225"
66 id="path5"
67 sodipodi:nodetypes="cccccccc" />
68 <path
69 d="m 174.4,160 c 0,12.5 -7.75,24.07 -17.57,25.77 L 14.23,209.73 V 25.93 C 14.23,9.21 27.57,-2.27 43.12,0.3 l 131.3,21.52 v 138.2 z"
70 style="fill:#80c342"
71 id="path7" />
72 <path
73 d="m 154.9,80.96 -12.96,-0.598 0,0.278 6.945,0.32 6.016,0 z"
74 style="fill:#006225"
75 id="path11" />
76 <path
77 d="m 144.6,135.6 c 0.66,0.328 1.43,0.476 2.351,0.476 0.161,0 0.329,-0.004 0.497,-0.016 2.55,-0.148 5.32,-0.933 8.343,-2.308 h -6.015 c -1.821,0.832 -3.532,1.457 -5.176,1.848 z"
78 style="fill:#006225"
79 id="path13" />
80 <path
81 id="path17"
82 style="fill:#ffffff"
83 d="m 91.15,132.4 c 2.351,-6.051 3.511,-17.91 3.511,-35.62 0,-15.89 -1.148,-26.82 -3.484,-32.81 -2.336,-6.027 -5.832,-9.281 -10.52,-9.691 -0.359,-0.031 -0.714,-0.051 -1.058,-0.051 -4.34,0 -7.68,2.535 -10.01,7.625 -2.52,5.543 -3.793,17.04 -3.793,34.44 0,16.82 1.238,28.75 3.734,35.75 2.356,6.672 5.879,9.976 10.5,9.976 0.207,0 0.41,-0.008 0.621,-0.019 4.633,-0.293 8.121,-3.496 10.49,-9.602 m 17.98,3.75 c -4.117,9.707 -10.39,16.06 -18.99,19 0.867,4.449 2.176,7.441 3.922,9.019 1.351,1.211 3.433,1.821 6.222,1.821 0.805,0 1.668,-0.055 2.59,-0.157 v 13.12 l -5.961,0.782 c -1.758,0.23 -3.426,0.343 -5.004,0.343 -5.218,0 -9.445,-1.265 -12.62,-3.824 -4.207,-3.379 -7.308,-9.894 -9.297,-19.54 -9.136,-1.945 -16.26,-7.754 -21.19,-17.5 -5.004,-9.902 -7.551,-24.39 -7.551,-43.34 0,-20.43 3.484,-35.51 10.34,-45.07 5.789,-8.07 13.86,-12.04 24.02,-12.04 1.629,0 3.309,0.102 5.043,0.305 11.95,1.375 20.62,7.016 26.26,16.79 5.535,9.562 8.254,23.27 8.254,41.26 0,16.48 -2,29.45 -6.043,39.02 z M 130.4,45.91 l 11.52,1.238 0,20.21 12.96,0.914 0,12.68 -12.96,-0.598 0,46.33 c 0,4.032 0.445,6.625 1.34,7.789 0.8,1.067 2.046,1.594 3.71,1.594 0.161,0 0.329,-0.004 0.497,-0.016 2.55,-0.148 5.32,-0.933 8.343,-2.308 v 11.65 c -5.136,2.258 -10.18,3.598 -15.12,4.02 -0.718,0.055 -1.41,0.086 -2.078,0.086 -4.48,0 -7.906,-1.301 -10.25,-3.934 -2.73,-3.051 -4.09,-7.949 -4.09,-14.67 V 79.535 L 118.046,79.25 V 65.66 l 7.586,0.547 4.773,-20.3 z" />
84 <path
85 d="m 100.3,166 c 0.809,0 1.672,-0.055 2.59,-0.157 H 98.054 C 98.73,165.949 99.507,166 100.3,166 z"
86 style="fill:#006225"
87 id="path19" />
88 <path
89 id="path21"
90 style="fill:#006225"
91 d="m 84.85,63.98 c 2.336,5.997 3.484,16.92 3.484,32.81 0,17.7 -1.16,29.57 -3.512,35.62 -1.894,4.879 -4.527,7.902 -7.863,9.07 0.965,0.368 1.992,0.551 3.078,0.551 0.207,0 0.41,-0.008 0.621,-0.019 4.633,-0.293 8.121,-3.496 10.49,-9.602 2.351,-6.051 3.511,-17.91 3.511,-35.62 0,-15.89 -1.148,-26.82 -3.484,-32.81 -2.336,-6.027 -5.832,-9.281 -10.52,-9.691 -0.359,-0.031 -0.714,-0.051 -1.058,-0.051 -1.09,0 -2.117,0.16 -3.082,0.481 h -0.004 c 3.601,1.121 6.379,4.215 8.336,9.261 z m -2.344,114.3 c -0.113,-0.05 -0.227,-0.105 -0.336,-0.16 -0.012,-0.004 -0.023,-0.012 -0.035,-0.015 -0.102,-0.051 -0.207,-0.106 -0.309,-0.157 -0.019,-0.011 -0.039,-0.019 -0.058,-0.031 -0.09,-0.051 -0.184,-0.098 -0.278,-0.148 -0.027,-0.016 -0.054,-0.036 -0.086,-0.051 -0.082,-0.043 -0.164,-0.09 -0.242,-0.137 -0.039,-0.023 -0.078,-0.047 -0.113,-0.07 -0.07,-0.039 -0.145,-0.082 -0.215,-0.125 -0.047,-0.031 -0.094,-0.059 -0.14,-0.09 -0.059,-0.039 -0.118,-0.074 -0.176,-0.113 -0.059,-0.039 -0.114,-0.075 -0.168,-0.114 -0.051,-0.031 -0.102,-0.066 -0.149,-0.097 -0.066,-0.047 -0.132,-0.094 -0.195,-0.137 -0.039,-0.027 -0.078,-0.055 -0.113,-0.082 -0.078,-0.055 -0.153,-0.113 -0.231,-0.172 -0.023,-0.016 -0.05,-0.035 -0.078,-0.055 -0.098,-0.078 -0.199,-0.156 -0.297,-0.234 -4.207,-3.379 -7.308,-9.894 -9.297,-19.54 -9.136,-1.945 -16.26,-7.754 -21.19,-17.5 -5.004,-9.902 -7.551,-24.39 -7.551,-43.34 0,-20.43 3.484,-35.51 10.34,-45.07 5.789,-8.07 13.86,-12.04 24.02,-12.04 h -6.351 c -10.15,0.008 -18.22,3.977 -24,12.04 -6.855,9.563 -10.34,24.64 -10.34,45.07 0,18.95 2.547,33.44 7.551,43.34 4.934,9.75 12.05,15.56 21.19,17.5 1.989,9.641 5.09,16.16 9.297,19.54 3.176,2.559 7.403,3.824 12.62,3.824 0.098,0 0.199,0 0.297,-0.004 h 5.539 c -3.406,-0.05 -6.383,-0.66 -8.906,-1.828 L 82.498,178.28 z M 128.4,145.6 c -2.73,-3.051 -4.09,-7.949 -4.09,-14.67 V 79.57 l -6.226,-0.285 v -13.59 h -6.016 v 3.035 c 0.871,3.273 1.555,6.82 2.063,10.64 l 4.164,0.192 v 51.36 c 0,6.723 1.367,11.62 4.09,14.67 2.343,2.633 5.765,3.934 10.25,3.934 h 6.015 c -4.48,0 -7.906,-1.301 -10.25,-3.934 z m 2.043,-99.66 -6.016,0 -4.668,19.88 5.911,0.422 4.773,-20.3 z" />
92 </g>
93 </svg>
@@ -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,6
1 <RCC>
2 <qresource prefix="/">
3 <file>qml/qmlcustommodel/loader.qml</file>
4 <file>qml/qmlcustommodel/main.qml</file>
5 </qresource>
6 </RCC>
@@ -8,4 +8,5 SUBDIRS += chartthemes \
8 8 piechartcustomization \
9 9 dynamicspline \
10 10 qmlchart \
11 qmlweather
11 qmlweather \
12 qmlcustommodel
@@ -45,30 +45,6 Rectangle {
45 45 PieSlice { label: "Skoda"; value: 8.2 }
46 46 PieSlice { label: "Volvo"; value: 6.8 }
47 47 }
48
49 // TODO: move ChartModel API into a demo application instead of making it a public API
50 // // For dynamic data you can use the ChartModel API.
51 // ChartModel {
52 // id: chartModel
53 // ChartModelElement { values: ["Volkswagen", 13.5] }
54 // ChartModelElement { values: ["Toyota", 10.9] }
55 // ChartModelElement { values: ["Ford", 8.6] }
56 // ChartModelElement { values: ["Skoda", 8.2] }
57 // ChartModelElement { values: ["Volvo", 6.8] }
58 // }
59 // // In this case you need to define how the data maps to pie slices with the ModelMapper API of the pie series.
60 // PieSeries {
61 // id: pieSeries
62 // model: chartModel
63 // modelMapper.mapLabels: 0
64 // modelMapper.mapValues: 1
65 // modelMapper.first: 0
66 // modelMapper.count: -1 // "Undefined" = -1 by default
67 // modelMapper.orientation: PieModelMapper.Vertical
68 // }
69
70 // TODO: you could also append to your model, for example:
71 // pieSeries.model.append(["Others", 52.0]);
72 48 }
73 49
74 50 Component.onCompleted: {
@@ -90,9 +66,9 Rectangle {
90 66 __explodedIndex = (__explodedIndex + 1) % pieSeries.count;
91 67 pieSeries.at(__explodedIndex).exploded = true;
92 68
69 pieSeries.find("Volkswagen").exploded = true;
93 70 // TODO: implement for convenience
94 // pieSeries.find("Ford").exploded = true;
95 // pieSeries.removeAll("Ford")
71 // pieSeries.removeAll("Ford");
96 72 }
97 73 }
98 74
@@ -123,20 +99,4 Rectangle {
123 99 }
124 100 }
125 101 }
126
127 // TODO: show how to use data from a list model in a chart view
128 // i.e. copy the data into a chart model
129 // ListModel {
130 // id: listModel
131 // ListElement {
132 // label: "Volkswagen"
133 // value: 13.5
134 // }
135 // ListElement {
136 // label: "Toyota"
137 // value: 10.9
138 // }
139 // // and so on...
140 // }
141
142 102 }
@@ -32,31 +32,24 Rectangle {
32 32
33 33 LineSeries {
34 34 name: "Line"
35 model: chartModel
36 modelMapper.mapX: 0
37 modelMapper.mapY: 1
38 modelMapper.first: 0
39 modelMapper.count: -1
40 modelMapper.orientation: XYModelMapper.Vertical
35 XyPoint { x: 0; y: 0 }
36 XyPoint { x: 1.1; y: 2.1 }
37 XyPoint { x: 1.9; y: 3.3 }
38 XyPoint { x: 2.1; y: 2.1 }
39 XyPoint { x: 2.9; y: 4.9 }
40 XyPoint { x: 3.4; y: 3.0 }
41 XyPoint { x: 4.1; y: 3.3 }
41 42 }
42 43
43 44 SplineSeries {
44 45 name: "Spline"
45 model: chartModel
46 modelMapper.mapX: 0
47 modelMapper.mapY: 2
46 XyPoint { x: 0; y: 0.3 }
47 XyPoint { x: 1.1; y: 3.2 }
48 XyPoint { x: 1.9; y: 2.4 }
49 XyPoint { x: 2.1; y: 2.1 }
50 XyPoint { x: 2.9; y: 2.6 }
51 XyPoint { x: 3.4; y: 2.3 }
52 XyPoint { x: 4.1; y: 3.1 }
48 53 }
49 54 }
50
51 ChartModel {
52 id: chartModel
53 ChartModelElement { values: [0.0, 0.0, 0.3] }
54 ChartModelElement { values: [1.1, 2.1, 3.2] }
55 ChartModelElement { values: [1.9, 3.3, 2.4] }
56 ChartModelElement { values: [2.1, 2.1, 2.1] }
57 ChartModelElement { values: [2.9, 4.9, 2.6] }
58 ChartModelElement { values: [3.4, 3.0, 2.3] }
59 ChartModelElement { values: [4.1, 3.3, 3.1] }
60 }
61
62 55 }
@@ -33,46 +33,98 Rectangle {
33 33
34 34 AreaSeries {
35 35 name: "Russian"
36 upperModel: chartModel
37 upperModelMapper.mapX: 0
38 upperModelMapper.mapY: 2
39 lowerModel: chartModel
40 lowerModelMapper.mapX: 0
41 lowerModelMapper.mapY: 1
36 upperSeries: LineSeries {
37 XyPoint { x: 0; y: 1 }
38 XyPoint { x: 1; y: 1 }
39 XyPoint { x: 2; y: 1 }
40 XyPoint { x: 3; y: 1 }
41 XyPoint { x: 4; y: 1 }
42 XyPoint { x: 5; y: 0 }
43 XyPoint { x: 6; y: 1 }
44 XyPoint { x: 7; y: 1 }
45 XyPoint { x: 8; y: 4 }
46 XyPoint { x: 9; y: 3 }
47 XyPoint { x: 10; y: 2 }
48 XyPoint { x: 11; y: 1 }
49 }
50 lowerSeries: LineSeries {
51 XyPoint { x: 0; y: 0 }
52 XyPoint { x: 1; y: 0 }
53 XyPoint { x: 2; y: 0 }
54 XyPoint { x: 3; y: 0 }
55 XyPoint { x: 4; y: 0 }
56 XyPoint { x: 5; y: 0 }
57 XyPoint { x: 6; y: 0 }
58 XyPoint { x: 7; y: 0 }
59 XyPoint { x: 8; y: 0 }
60 XyPoint { x: 9; y: 0 }
61 XyPoint { x: 10; y: 0 }
62 XyPoint { x: 11; y: 0 }
63 }
42 64 }
65
43 66 AreaSeries {
44 67 name: "Swedish"
45 upperModel: chartModel
46 upperModelMapper.mapX: 0
47 upperModelMapper.mapY: 3
48 lowerModel: chartModel
49 lowerModelMapper.mapX: 0
50 lowerModelMapper.mapY: 1
68 upperSeries: LineSeries {
69 XyPoint { x: 0; y: 1 }
70 XyPoint { x: 1; y: 1 }
71 XyPoint { x: 2; y: 3 }
72 XyPoint { x: 3; y: 3 }
73 XyPoint { x: 4; y: 2 }
74 XyPoint { x: 5; y: 0 }
75 XyPoint { x: 6; y: 2 }
76 XyPoint { x: 7; y: 1 }
77 XyPoint { x: 8; y: 2 }
78 XyPoint { x: 9; y: 1 }
79 XyPoint { x: 10; y: 3 }
80 XyPoint { x: 11; y: 3 }
81 }
82 lowerSeries: LineSeries {
83 XyPoint { x: 0; y: 0 }
84 XyPoint { x: 1; y: 0 }
85 XyPoint { x: 2; y: 0 }
86 XyPoint { x: 3; y: 0 }
87 XyPoint { x: 4; y: 0 }
88 XyPoint { x: 5; y: 0 }
89 XyPoint { x: 6; y: 0 }
90 XyPoint { x: 7; y: 0 }
91 XyPoint { x: 8; y: 0 }
92 XyPoint { x: 9; y: 0 }
93 XyPoint { x: 10; y: 0 }
94 XyPoint { x: 11; y: 0 }
95 }
51 96 }
97
52 98 AreaSeries {
53 name: "Finnish"
54 upperModel: chartModel
55 upperModelMapper.mapX: 0
56 upperModelMapper.mapY: 4
57 lowerModel: chartModel
58 lowerModelMapper.mapX: 0
59 lowerModelMapper.mapY: 1
99 name: "Swedish"
100 upperSeries: LineSeries {
101 XyPoint { x: 0; y: 0 }
102 XyPoint { x: 1; y: 0 }
103 XyPoint { x: 2; y: 0 }
104 XyPoint { x: 3; y: 0 }
105 XyPoint { x: 4; y: 0 }
106 XyPoint { x: 5; y: 0 }
107 XyPoint { x: 6; y: 1 }
108 XyPoint { x: 7; y: 0 }
109 XyPoint { x: 8; y: 0 }
110 XyPoint { x: 9; y: 0 }
111 XyPoint { x: 10; y: 0 }
112 XyPoint { x: 11; y: 1 }
113 }
114 lowerSeries: LineSeries {
115 XyPoint { x: 0; y: 0 }
116 XyPoint { x: 1; y: 0 }
117 XyPoint { x: 2; y: 0 }
118 XyPoint { x: 3; y: 0 }
119 XyPoint { x: 4; y: 0 }
120 XyPoint { x: 5; y: 0 }
121 XyPoint { x: 6; y: 0 }
122 XyPoint { x: 7; y: 0 }
123 XyPoint { x: 8; y: 0 }
124 XyPoint { x: 9; y: 0 }
125 XyPoint { x: 10; y: 0 }
126 XyPoint { x: 11; y: 0 }
127 }
60 128 }
61 129 }
62
63 ChartModel {
64 id: chartModel
65 ChartModelElement { values: [0, 0, 1, 1, 0] }
66 ChartModelElement { values: [1, 0, 1, 1, 0] }
67 ChartModelElement { values: [2, 0, 1, 3, 0] }
68 ChartModelElement { values: [3, 0, 1, 3, 0] }
69 ChartModelElement { values: [4, 0, 1, 2, 0] }
70 ChartModelElement { values: [5, 0, 0, 0, 0] }
71 ChartModelElement { values: [6, 0, 1, 2, 1] }
72 ChartModelElement { values: [7, 0, 1, 1, 0] }
73 ChartModelElement { values: [8, 0, 4, 2, 0] }
74 ChartModelElement { values: [9, 0, 3, 1, 0] }
75 ChartModelElement { values: [10, 0, 2, 3, 0] }
76 ChartModelElement { values: [11, 0, 1, 3, 1] }
77 }
78 130 }
@@ -40,6 +40,7 Rectangle {
40 40 XyPoint { x: 2.1; y: 1.3 }
41 41 XyPoint { x: 2.5; y: 2.1 }
42 42 }
43
43 44 ScatterSeries {
44 45 name: "Scatter2"
45 46 XyPoint { x: 2.0; y: 2.0 }
@@ -29,6 +29,7 Rectangle {
29 29 anchors.fill: parent
30 30 theme: ChartView.ChartThemeLight
31 31 legend: ChartView.LegendBottom
32 // TODO: labels defined by x-axis, not by bar series
32 33 // axisXLabels: ["0", "2008", "1", "2009", "2", "2010", "3", "2012"]
33 34 axisX.max: 10
34 35
@@ -38,21 +39,5 Rectangle {
38 39 BarSet { name: "Susan"; values: [5, 1, 2, 4, 1, 7] }
39 40 BarSet { name: "James"; values: [3, 5, 8, 13, 5, 8] }
40 41 }
41
42 // TODO: optional syntax with ChartModel base model API
43 // BarSeries {
44 // model: chartModel
45 // modelMapping: BarSeriesMapping {
46 // ?
47 // startIndex: 0 // defaults to 0
48 // count: BarSeriesMapping.Undefined // defaults to "Undefined"
49 // }
50 // }
51 // ChartModel {
52 // id: chartModel
53 // ChartModelElement { values: ["Bob", 2, 2, 3, 4, 5, 6] }
54 // ChartModelElement { values: ["Susan", 5, 1, 2, 4, 1, 7] }
55 // ChartModelElement { values: ["James", 3, 5, 8, 13, 5, 8] }
56 // }
57 42 }
58 43 }
@@ -26,67 +26,28
26 26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 27
28 28 DeclarativeAreaSeries::DeclarativeAreaSeries(QObject *parent) :
29 QAreaSeries(new QLineSeries(parent), new QLineSeries(parent))
29 QAreaSeries(parent)
30 30 {
31 QXYModelMapper *upperMapper = new QXYModelMapper(upperSeries());
32 upperMapper->setMapX(0);
33 upperMapper->setMapY(1);
34 upperMapper->setFirst(0);
35 upperMapper->setCount(-1);
36 upperMapper->setOrientation(Qt::Vertical);
37 upperSeries()->setModelMapper(upperMapper);
38
39 QXYModelMapper *lowerMapper = new QXYModelMapper(lowerSeries());
40 lowerMapper->setMapX(2);
41 lowerMapper->setMapY(3);
42 lowerMapper->setFirst(0);
43 lowerMapper->setCount(-1);
44 lowerMapper->setOrientation(Qt::Vertical);
45 lowerSeries()->setModelMapper(lowerMapper);
46 }
47
48 bool DeclarativeAreaSeries::setDeclarativeUpperModel(DeclarativeTableModel *model)
49 {
50 QAbstractItemModel *m = qobject_cast<QAbstractItemModel *>(model);
51 bool value(false);
52 if (m) {
53 upperSeries()->setModel(m);
54 } else {
55 qWarning("DeclarativeAreaSeries: Illegal model");
56 }
57 return value;
58 }
59
60 DeclarativeTableModel *DeclarativeAreaSeries::declarativeUpperModel()
61 {
62 return qobject_cast<DeclarativeTableModel *>(upperSeries()->model());
63 31 }
64 32
65 bool DeclarativeAreaSeries::setDeclarativeLowerModel(DeclarativeTableModel *model)
33 void DeclarativeAreaSeries::setUpperSeries(DeclarativeLineSeries* series)
66 34 {
67 QAbstractItemModel *m = qobject_cast<QAbstractItemModel *>(model);
68 bool value(false);
69 if (m) {
70 lowerSeries()->setModel(m);
71 } else {
72 qWarning("DeclarativeAreaSeries: Illegal model");
73 }
74 return value;
35 QAreaSeries::setUpperSeries(series);
75 36 }
76 37
77 DeclarativeTableModel *DeclarativeAreaSeries::declarativeLowerModel()
38 DeclarativeLineSeries* DeclarativeAreaSeries::upperSeries() const
78 39 {
79 return qobject_cast<DeclarativeTableModel *>(lowerSeries()->model());
40 return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::upperSeries());
80 41 }
81 42
82 QXYModelMapper* DeclarativeAreaSeries::upperModelMapper() const
43 void DeclarativeAreaSeries::setLowerSeries(DeclarativeLineSeries* series)
83 44 {
84 return upperSeries()->modelMapper();
45 QAreaSeries::setLowerSeries(series);
85 46 }
86 47
87 QXYModelMapper* DeclarativeAreaSeries::lowerModelMapper() const
48 DeclarativeLineSeries* DeclarativeAreaSeries::lowerSeries() const
88 49 {
89 return lowerSeries()->modelMapper();
50 return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::lowerSeries());
90 51 }
91 52
92 53 #include "moc_declarativeareaseries.cpp"
@@ -30,10 +30,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 30 class DeclarativeAreaSeries : public QAreaSeries
31 31 {
32 32 Q_OBJECT
33 Q_PROPERTY(DeclarativeTableModel *upperModel READ declarativeUpperModel WRITE setDeclarativeUpperModel)
34 Q_PROPERTY(DeclarativeTableModel *lowerModel READ declarativeLowerModel WRITE setDeclarativeLowerModel)
35 Q_PROPERTY(QXYModelMapper *upperModelMapper READ upperModelMapper)
36 Q_PROPERTY(QXYModelMapper *lowerModelMapper READ lowerModelMapper)
33 Q_PROPERTY(DeclarativeLineSeries *upperSeries READ upperSeries WRITE setUpperSeries)
34 Q_PROPERTY(DeclarativeLineSeries *lowerSeries READ lowerSeries WRITE setLowerSeries)
37 35
38 36 public:
39 37 explicit DeclarativeAreaSeries(QObject *parent = 0);
@@ -45,6 +43,11 public:
45 43 DeclarativeTableModel *declarativeLowerModel();
46 44 QXYModelMapper* upperModelMapper() const;
47 45 QXYModelMapper* lowerModelMapper() const;
46 public:
47 void setUpperSeries(DeclarativeLineSeries* series);
48 DeclarativeLineSeries* upperSeries() const;
49 void setLowerSeries(DeclarativeLineSeries* series);
50 DeclarativeLineSeries* lowerSeries() const;
48 51 };
49 52
50 53 QTCOMMERCIALCHART_END_NAMESPACE
@@ -61,7 +61,6 void DeclarativeBarSeries::componentComplete()
61 61 {
62 62 foreach(QObject *child, children()) {
63 63 if (qobject_cast<QBarSet *>(child)) {
64 qDebug() << "append bar set:" << child;
65 64 QBarSeries::append(qobject_cast<QBarSet *>(child));
66 65 }
67 66 }
@@ -30,6 +30,21 DeclarativeLineSeries::DeclarativeLineSeries(QObject *parent) :
30 30 {
31 31 }
32 32
33 QDeclarativeListProperty<QObject> DeclarativeLineSeries::declarativeChildren()
34 {
35 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
36 }
37
38 void DeclarativeLineSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
39 {
40 QXYSeries *series = qobject_cast<QXYSeries*>(list->object);
41 DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(element);
42 if (series && point) {
43 qDebug() << "DeclarativeScatterSeries::appendDeclarativeChildren:" << *point;
44 series->append(*point);
45 }
46 }
47
33 48 #include "moc_declarativelineseries.cpp"
34 49
35 50 QTCOMMERCIALCHART_END_NAMESPACE
@@ -32,9 +32,15 class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries
32 32 {
33 33 Q_OBJECT
34 34 Q_PROPERTY(DeclarativeTableModel *model READ declarativeModel WRITE setDeclarativeModel)
35 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
36 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
35 37
36 38 public:
37 39 explicit DeclarativeLineSeries(QObject *parent = 0);
40 QDeclarativeListProperty<QObject> declarativeChildren();
41
42 public Q_SLOTS:
43 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
38 44 };
39 45
40 46 QTCOMMERCIALCHART_END_NAMESPACE
@@ -69,6 +69,15 QPieSlice *DeclarativePieSeries::at(int index)
69 69 return 0;
70 70 }
71 71
72 QPieSlice* DeclarativePieSeries::find(QString label)
73 {
74 foreach (QPieSlice *slice, slices()) {
75 if (slice->label() == label)
76 return slice;
77 }
78 return 0;
79 }
80
72 81 QPieSlice* DeclarativePieSeries::append(QString name, qreal value)
73 82 {
74 83 // TODO: parameter order is wrong, switch it:
@@ -48,7 +48,8 public:
48 48 DeclarativeTableModel *pieModel();
49 49 void setPieModel(DeclarativeTableModel *model);
50 50 Q_INVOKABLE QPieSlice *at(int index);
51 Q_INVOKABLE QPieSlice* append(QString name, qreal value);
51 Q_INVOKABLE QPieSlice* find(QString label);
52 Q_INVOKABLE QPieSlice* append(QString label, qreal value);
52 53
53 54 public:
54 55 void classBegin();
@@ -37,9 +37,10 QDeclarativeListProperty<QObject> DeclarativeScatterSeries::declarativeChildren(
37 37
38 38 void DeclarativeScatterSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
39 39 {
40 DeclarativeScatterSeries *series = qobject_cast<DeclarativeScatterSeries *>(list->object);
41 if (series && qobject_cast<DeclarativeXyPoint *>(element))
42 series->declarativeModel()->appendPoint(series->modelMapper(), qobject_cast<DeclarativeXyPoint *>(element));
40 QXYSeries *series = qobject_cast<QXYSeries*>(list->object);
41 DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(element);
42 if (series && point)
43 series->append(*point);
43 44 }
44 45
45 46 #include "moc_declarativescatterseries.cpp"
@@ -29,6 +29,20 DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) :
29 29 {
30 30 }
31 31
32 QDeclarativeListProperty<QObject> DeclarativeSplineSeries::declarativeChildren()
33 {
34 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
35 }
36
37 void DeclarativeSplineSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
38 {
39 QXYSeries *series = qobject_cast<QXYSeries*>(list->object);
40 DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(element);
41 if (series && point) {
42 qDebug() << "DeclarativeScatterSeries::appendDeclarativeChildren:" << *point;
43 series->append(*point);
44 }
45 }
32 46 #include "moc_declarativesplineseries.cpp"
33 47
34 48 QTCOMMERCIALCHART_END_NAMESPACE
@@ -32,9 +32,15 class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries
32 32 {
33 33 Q_OBJECT
34 34 Q_PROPERTY(DeclarativeTableModel *model READ declarativeModel WRITE setDeclarativeModel)
35 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
36 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
35 37
36 38 public:
37 39 explicit DeclarativeSplineSeries(QObject *parent = 0);
40 QDeclarativeListProperty<QObject> declarativeChildren();
41
42 public Q_SLOTS:
43 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
38 44 };
39 45
40 46 QTCOMMERCIALCHART_END_NAMESPACE
@@ -31,8 +31,7 DeclarativeXySeries::DeclarativeXySeries()
31 31 {
32 32 // All the inherited objects must be of type QXYSeries, so it is safe to cast
33 33 QXYSeries *series = reinterpret_cast<QXYSeries *>(this);
34 // TODO: set default model on init?
35 series->setModel(new DeclarativeTableModel());
34 // TODO: mapper should be available on the series by default
36 35 QXYModelMapper *mapper = new QXYModelMapper(series);
37 36 mapper->setMapX(0);
38 37 mapper->setMapY(1);
@@ -109,6 +109,14 QAreaSeries::QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries)
109 109 }
110 110
111 111 /*!
112 Constructs area series object without upper or lower series.
113 */
114 QAreaSeries::QAreaSeries(QObject *parent)
115 : QAbstractSeries(*new QAreaSeriesPrivate(0, 0, this), parent)
116 {
117 }
118
119 /*!
112 120 Destroys the object. Series added to QChartView or QChart instances are owned by those,
113 121 and are deleted when mentioned object are destroyed.
114 122 */
@@ -122,12 +130,24 QAbstractSeries::SeriesType QAreaSeries::type() const
122 130 return QAbstractSeries::SeriesTypeArea;
123 131 }
124 132
133 void QAreaSeries::setUpperSeries(QLineSeries* series)
134 {
135 Q_D(QAreaSeries);
136 d->m_upperSeries = series;
137 }
138
125 139 QLineSeries* QAreaSeries::upperSeries() const
126 140 {
127 141 Q_D(const QAreaSeries);
128 142 return d->m_upperSeries;
129 143 }
130 144
145 void QAreaSeries::setLowerSeries(QLineSeries* series)
146 {
147 Q_D(QAreaSeries);
148 d->m_lowerSeries = series;
149 }
150
131 151 QLineSeries* QAreaSeries::lowerSeries() const
132 152 {
133 153 Q_D(const QAreaSeries);
@@ -34,13 +34,16 class QTCOMMERCIALCHART_EXPORT QAreaSeries : public QAbstractSeries
34 34 {
35 35 Q_OBJECT
36 36 public:
37 explicit QAreaSeries(QObject *parent = 0);
37 38 explicit QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries = 0);
38 39 ~QAreaSeries();
39 40
40 41 public:
41 42 QAbstractSeries::SeriesType type() const;
42 43
44 void setUpperSeries(QLineSeries* series);
43 45 QLineSeries* upperSeries() const;
46 void setLowerSeries(QLineSeries* series);
44 47 QLineSeries* lowerSeries() const;
45 48
46 49 void setPen(const QPen &pen);
General Comments 0
You need to be logged in to leave comments. Login now