@@ -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/qmlchartproperties/loader.qml")); | |||
|
32 | viewer->showExpanded(); | |||
|
33 | ||||
|
34 | return app->exec(); | |||
|
35 | } |
@@ -0,0 +1,64 | |||||
|
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 | ChartView { | |||
|
25 | title: "area series" | |||
|
26 | anchors.fill: parent | |||
|
27 | axisXLabels: ["0", "2000", "1", "2001", "2", "2002", "3", "2003", "4", "2004", "5", "2005", | |||
|
28 | "6", "2006", "7", "2007", "8", "2008", "9", "2009", "10", "2010", "11", "2011"] | |||
|
29 | ||||
|
30 | property variant series: daSeries | |||
|
31 | ||||
|
32 | AreaSeries { | |||
|
33 | id: daSeries | |||
|
34 | name: "area 1" | |||
|
35 | upperSeries: LineSeries { | |||
|
36 | XyPoint { x: 0; y: 1 } | |||
|
37 | XyPoint { x: 1; y: 1 } | |||
|
38 | XyPoint { x: 2; y: 3 } | |||
|
39 | XyPoint { x: 3; y: 3 } | |||
|
40 | XyPoint { x: 4; y: 2 } | |||
|
41 | XyPoint { x: 5; y: 0 } | |||
|
42 | XyPoint { x: 6; y: 2 } | |||
|
43 | XyPoint { x: 7; y: 1 } | |||
|
44 | XyPoint { x: 8; y: 2 } | |||
|
45 | XyPoint { x: 9; y: 1 } | |||
|
46 | XyPoint { x: 10; y: 3 } | |||
|
47 | XyPoint { x: 11; y: 3 } | |||
|
48 | } | |||
|
49 | lowerSeries: LineSeries { | |||
|
50 | XyPoint { x: 0; y: 0 } | |||
|
51 | XyPoint { x: 1; y: 0 } | |||
|
52 | XyPoint { x: 2; y: 0 } | |||
|
53 | XyPoint { x: 3; y: 0 } | |||
|
54 | XyPoint { x: 4; y: 0 } | |||
|
55 | XyPoint { x: 5; y: 0 } | |||
|
56 | XyPoint { x: 6; y: 0 } | |||
|
57 | XyPoint { x: 7; y: 0 } | |||
|
58 | XyPoint { x: 8; y: 0 } | |||
|
59 | XyPoint { x: 9; y: 0 } | |||
|
60 | XyPoint { x: 10; y: 0 } | |||
|
61 | XyPoint { x: 11; y: 0 } | |||
|
62 | } | |||
|
63 | } | |||
|
64 | } |
@@ -0,0 +1,41 | |||||
|
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 | ChartView { | |||
|
25 | title: "Bar series" | |||
|
26 | anchors.fill: parent | |||
|
27 | theme: ChartView.ChartThemeLight | |||
|
28 | legend: ChartView.LegendBottom | |||
|
29 | // TODO: labels defined by x-axis, not by bar series | |||
|
30 | axisXLabels: ["0", "2008", "1", "2009", "2", "2010", "3", "2012"] | |||
|
31 | ||||
|
32 | property variant series: daSeries | |||
|
33 | ||||
|
34 | GroupedBarSeries { | |||
|
35 | id: daSeries | |||
|
36 | barCategories: [ "2008", "2009", "2010", "2011", "2012" ] | |||
|
37 | BarSet { name: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |||
|
38 | BarSet { name: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |||
|
39 | BarSet { name: "James"; values: [3, 5, 8, 13, 5, 8] } | |||
|
40 | } | |||
|
41 | } |
@@ -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 | import QtCommercial.Chart 1.0 | |||
|
23 | ||||
|
24 | Flow { | |||
|
25 | id: flow | |||
|
26 | spacing: 5 | |||
|
27 | property variant series | |||
|
28 | ||||
|
29 | Button { | |||
|
30 | text: "color" | |||
|
31 | onClicked: series.color = main.nextColor(); | |||
|
32 | } | |||
|
33 | Button { | |||
|
34 | text: "points visible" | |||
|
35 | onClicked: series.pointsVisible = !series.pointsVisible | |||
|
36 | } | |||
|
37 | } |
@@ -0,0 +1,69 | |||||
|
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 | id: button | |||
|
25 | height: 45 | |||
|
26 | width: 165 | |||
|
27 | color: "#afafaf" | |||
|
28 | radius: 5 | |||
|
29 | ||||
|
30 | property string text: "button" | |||
|
31 | signal clicked | |||
|
32 | ||||
|
33 | Text { | |||
|
34 | id: buttonText | |||
|
35 | anchors.centerIn: parent | |||
|
36 | text: button.text | |||
|
37 | } | |||
|
38 | ||||
|
39 | MouseArea { | |||
|
40 | anchors.fill: parent | |||
|
41 | onClicked: { | |||
|
42 | button.clicked(); | |||
|
43 | } | |||
|
44 | onPressedChanged: { | |||
|
45 | if (pressed) { | |||
|
46 | button.color = "#efefef"; | |||
|
47 | } else { | |||
|
48 | button.color = "#afafaf"; | |||
|
49 | } | |||
|
50 | } | |||
|
51 | onPressAndHold: { | |||
|
52 | repeatTimer.start(); | |||
|
53 | } | |||
|
54 | onReleased: { | |||
|
55 | repeatTimer.stop(); | |||
|
56 | } | |||
|
57 | } | |||
|
58 | ||||
|
59 | Timer { | |||
|
60 | id: repeatTimer | |||
|
61 | interval: 200 | |||
|
62 | repeat: true | |||
|
63 | triggeredOnStart: false | |||
|
64 | running: false | |||
|
65 | onTriggered: { | |||
|
66 | button.clicked(); | |||
|
67 | } | |||
|
68 | } | |||
|
69 | } |
@@ -0,0 +1,51 | |||||
|
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 | ChartView { | |||
|
25 | title: "line series" | |||
|
26 | anchors.fill: parent | |||
|
27 | ||||
|
28 | property variant series: daSeries | |||
|
29 | ||||
|
30 | LineSeries { | |||
|
31 | id: daSeries | |||
|
32 | name: "line 1" | |||
|
33 | XyPoint { x: 0; y: 0 } | |||
|
34 | XyPoint { x: 1.1; y: 2.1 } | |||
|
35 | XyPoint { x: 1.9; y: 3.3 } | |||
|
36 | XyPoint { x: 2.1; y: 2.1 } | |||
|
37 | XyPoint { x: 2.9; y: 4.9 } | |||
|
38 | XyPoint { x: 3.4; y: 3.0 } | |||
|
39 | XyPoint { x: 4.1; y: 3.3 } | |||
|
40 | } | |||
|
41 | ||||
|
42 | LineSeries { | |||
|
43 | name: "line 2" | |||
|
44 | XyPoint { x: 1.1; y: 1.1 } | |||
|
45 | XyPoint { x: 1.9; y: 2.3 } | |||
|
46 | XyPoint { x: 2.1; y: 1.1 } | |||
|
47 | XyPoint { x: 2.9; y: 3.9 } | |||
|
48 | XyPoint { x: 3.4; y: 2.0 } | |||
|
49 | XyPoint { x: 4.1; y: 2.3 } | |||
|
50 | } | |||
|
51 | } |
@@ -0,0 +1,38 | |||||
|
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 | ||||
|
25 | Flow { | |||
|
26 | id: flow | |||
|
27 | spacing: 5 | |||
|
28 | property variant series | |||
|
29 | ||||
|
30 | Button { | |||
|
31 | text: "color" | |||
|
32 | onClicked: series.color = main.nextColor(); | |||
|
33 | } | |||
|
34 | Button { | |||
|
35 | text: "points visible" | |||
|
36 | onClicked: series.pointsVisible = !series.pointsVisible | |||
|
37 | } | |||
|
38 | } |
@@ -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 | import QtCommercial.Chart 1.0 | |||
|
23 | ||||
|
24 | ChartView { | |||
|
25 | id: chart | |||
|
26 | title: "pie series" | |||
|
27 | animationOptions: ChartView.SeriesAnimations | |||
|
28 | ||||
|
29 | property variant series: pieSeries | |||
|
30 | ||||
|
31 | PieSeries { | |||
|
32 | id: pieSeries | |||
|
33 | PieSlice { id: daSlice; label: "slice1"; value: 11 } | |||
|
34 | PieSlice { label: "slice2"; value: 22 } | |||
|
35 | PieSlice { label: "slice3"; value: 33 } | |||
|
36 | } | |||
|
37 | } |
@@ -0,0 +1,57 | |||||
|
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 | Flow { | |||
|
25 | id: flow | |||
|
26 | spacing: 5 | |||
|
27 | property variant series | |||
|
28 | ||||
|
29 | Button { | |||
|
30 | text: "slice color" | |||
|
31 | onClicked: series.at(0).color = main.nextColor(); | |||
|
32 | } | |||
|
33 | Button { | |||
|
34 | text: "slice border color" | |||
|
35 | onClicked: series.at(0).borderColor = main.nextColor(); | |||
|
36 | } | |||
|
37 | Button { | |||
|
38 | text: "slice border width +" | |||
|
39 | onClicked: series.at(0).borderWidth++; | |||
|
40 | } | |||
|
41 | Button { | |||
|
42 | text: "slice border width -" | |||
|
43 | onClicked: series.at(0).borderWidth--; | |||
|
44 | } | |||
|
45 | Button { | |||
|
46 | text: "slice label visible" | |||
|
47 | onClicked: series.at(0).labelVisible = !series.at(0).labelVisible; | |||
|
48 | } | |||
|
49 | Button { | |||
|
50 | text: "slice label color" | |||
|
51 | onClicked: series.at(0).labelColor = main.nextColor(); | |||
|
52 | } | |||
|
53 | Button { | |||
|
54 | text: "slice exploded" | |||
|
55 | onClicked: series.at(0).exploded = !series.at(0).exploded; | |||
|
56 | } | |||
|
57 | } |
@@ -0,0 +1,51 | |||||
|
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 | ChartView { | |||
|
25 | title: "scatter series" | |||
|
26 | axisX.max: 4 | |||
|
27 | axisY.max: 4 | |||
|
28 | property variant series: daSeries | |||
|
29 | ||||
|
30 | ScatterSeries { | |||
|
31 | id: daSeries | |||
|
32 | name: "scatter 1" | |||
|
33 | XyPoint { x: 1.5; y: 1.5 } | |||
|
34 | XyPoint { x: 1.5; y: 1.6 } | |||
|
35 | XyPoint { x: 1.57; y: 1.55 } | |||
|
36 | XyPoint { x: 1.8; y: 1.8 } | |||
|
37 | XyPoint { x: 1.9; y: 1.6 } | |||
|
38 | XyPoint { x: 2.1; y: 1.3 } | |||
|
39 | XyPoint { x: 2.5; y: 2.1 } | |||
|
40 | } | |||
|
41 | ||||
|
42 | ScatterSeries { | |||
|
43 | name: "scatter2" | |||
|
44 | XyPoint { x: 2.0; y: 2.0 } | |||
|
45 | XyPoint { x: 2.0; y: 2.1 } | |||
|
46 | XyPoint { x: 2.07; y: 2.05 } | |||
|
47 | XyPoint { x: 2.2; y: 2.9 } | |||
|
48 | XyPoint { x: 2.4; y: 2.7 } | |||
|
49 | XyPoint { x: 2.67; y: 2.65 } | |||
|
50 | } | |||
|
51 | } |
@@ -0,0 +1,50 | |||||
|
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 | ChartView { | |||
|
25 | title: "spline series" | |||
|
26 | anchors.fill: parent | |||
|
27 | property variant series: daSeries | |||
|
28 | ||||
|
29 | SplineSeries { | |||
|
30 | id: daSeries | |||
|
31 | name: "spline 1" | |||
|
32 | XyPoint { x: 0; y: 0 } | |||
|
33 | XyPoint { x: 1.1; y: 2.1 } | |||
|
34 | XyPoint { x: 1.9; y: 3.3 } | |||
|
35 | XyPoint { x: 2.1; y: 2.1 } | |||
|
36 | XyPoint { x: 2.9; y: 4.9 } | |||
|
37 | XyPoint { x: 3.4; y: 3.0 } | |||
|
38 | XyPoint { x: 4.1; y: 3.3 } | |||
|
39 | } | |||
|
40 | ||||
|
41 | SplineSeries { | |||
|
42 | name: "spline 2" | |||
|
43 | XyPoint { x: 1.1; y: 1.1 } | |||
|
44 | XyPoint { x: 1.9; y: 2.3 } | |||
|
45 | XyPoint { x: 2.1; y: 1.1 } | |||
|
46 | XyPoint { x: 2.9; y: 3.9 } | |||
|
47 | XyPoint { x: 3.4; y: 2.0 } | |||
|
48 | XyPoint { x: 4.1; y: 2.3 } | |||
|
49 | } | |||
|
50 | } |
@@ -0,0 +1,53 | |||||
|
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 | title: "spline series" | |||
|
29 | anchors.fill: parent | |||
|
30 | ||||
|
31 | SplineSeries { | |||
|
32 | id: daSeries | |||
|
33 | name: "spline 1" | |||
|
34 | XyPoint { x: 0; y: 0 } | |||
|
35 | XyPoint { x: 1.1; y: 2.1 } | |||
|
36 | XyPoint { x: 1.9; y: 3.3 } | |||
|
37 | XyPoint { x: 2.1; y: 2.1 } | |||
|
38 | XyPoint { x: 2.9; y: 4.9 } | |||
|
39 | XyPoint { x: 3.4; y: 3.0 } | |||
|
40 | XyPoint { x: 4.1; y: 3.3 } | |||
|
41 | } | |||
|
42 | ||||
|
43 | SplineSeries { | |||
|
44 | name: "spline 2" | |||
|
45 | XyPoint { x: 1.1; y: 1.1 } | |||
|
46 | XyPoint { x: 1.9; y: 2.3 } | |||
|
47 | XyPoint { x: 2.1; y: 1.1 } | |||
|
48 | XyPoint { x: 2.9; y: 3.9 } | |||
|
49 | XyPoint { x: 3.4; y: 2.0 } | |||
|
50 | XyPoint { x: 4.1; y: 2.3 } | |||
|
51 | } | |||
|
52 | } | |||
|
53 | } |
@@ -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: 640 | |||
|
26 | height: 500 | |||
|
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,145 | |||||
|
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 | id: main | |||
|
26 | width: parent.width | |||
|
27 | height: parent.height | |||
|
28 | property int viewNumber: 0 | |||
|
29 | property int viewCount: 6 | |||
|
30 | property variant colors: ["#637D74", "#403D3A", "#8C3B3B", "#AB6937", "#D4A960"] | |||
|
31 | property int colorIndex: 0 | |||
|
32 | ||||
|
33 | function nextColor() { | |||
|
34 | colorIndex++; | |||
|
35 | console.log("color: " + colors[colorIndex % colors.length]); | |||
|
36 | return colors[colorIndex % colors.length]; | |||
|
37 | } | |||
|
38 | ||||
|
39 | onViewNumberChanged: { | |||
|
40 | if (viewNumber == 0) { | |||
|
41 | chartLoader.source = "PieChart.qml"; | |||
|
42 | editorLoader.source = "PieEditor.qml"; | |||
|
43 | } else if (viewNumber == 1) { | |||
|
44 | chartLoader.source = "LineChart.qml"; | |||
|
45 | editorLoader.source = "LineEditor.qml"; | |||
|
46 | } else if (viewNumber == 2) { | |||
|
47 | chartLoader.source = "SplineChart.qml"; | |||
|
48 | editorLoader.source = "LineEditor.qml"; | |||
|
49 | } else if (viewNumber == 3) { | |||
|
50 | chartLoader.source = "ScatterChart.qml"; | |||
|
51 | editorLoader.source = "LineEditor.qml"; // TODO: scatter specific properties | |||
|
52 | } else if (viewNumber == 4) { | |||
|
53 | chartLoader.source = "AreaChart.qml"; | |||
|
54 | editorLoader.source = "LineEditor.qml"; // TODO: area specific properties | |||
|
55 | } else if (viewNumber == 5) { | |||
|
56 | chartLoader.source = "BarChart.qml"; | |||
|
57 | editorLoader.source = "BarEditor.qml"; | |||
|
58 | } else { | |||
|
59 | console.log("Illegal view number"); | |||
|
60 | } | |||
|
61 | } | |||
|
62 | ||||
|
63 | Row { | |||
|
64 | anchors.top: parent.top | |||
|
65 | anchors.bottom: buttonRow.top | |||
|
66 | anchors.left: parent.left | |||
|
67 | anchors.right: parent.right | |||
|
68 | ||||
|
69 | Loader { | |||
|
70 | id: chartLoader | |||
|
71 | width: main.width - editorLoader.width | |||
|
72 | height: parent.height | |||
|
73 | source: "PieChart.qml" | |||
|
74 | onStatusChanged: { | |||
|
75 | console.log("chartLoader.status: " + status + " " + source); | |||
|
76 | if (status == Loader.Ready && editorLoader.status == Loader.Ready) | |||
|
77 | editorLoader.item.series = chartLoader.item.series; | |||
|
78 | } | |||
|
79 | } | |||
|
80 | ||||
|
81 | Loader { | |||
|
82 | id: editorLoader | |||
|
83 | width: 150 | |||
|
84 | height: parent.height | |||
|
85 | source: "PieEditor.qml" | |||
|
86 | onStatusChanged: { | |||
|
87 | console.log("editorLoader.status: " + status + " " + source); | |||
|
88 | if (status == Loader.Ready && chartLoader.status == Loader.Ready) | |||
|
89 | editorLoader.item.series = chartLoader.item.series; | |||
|
90 | } | |||
|
91 | } | |||
|
92 | } | |||
|
93 | ||||
|
94 | // Loader { | |||
|
95 | // id: loader | |||
|
96 | // anchors.top: parent.top | |||
|
97 | // anchors.bottom: buttonRow.top | |||
|
98 | // anchors.left: parent.left | |||
|
99 | // anchors.right: parent.right | |||
|
100 | // source: "View" + viewNumber + ".qml"; | |||
|
101 | // } | |||
|
102 | ||||
|
103 | Row { | |||
|
104 | id: buttonRow | |||
|
105 | height: 100 | |||
|
106 | anchors.bottom: parent.bottom | |||
|
107 | anchors.bottomMargin: 10 | |||
|
108 | anchors.horizontalCenter: parent.horizontalCenter | |||
|
109 | spacing: 10 | |||
|
110 | ||||
|
111 | Rectangle { | |||
|
112 | height: buttonRow.height | |||
|
113 | width: 100 | |||
|
114 | color: "#afafaf" | |||
|
115 | radius: 5 | |||
|
116 | Text { | |||
|
117 | anchors.centerIn: parent | |||
|
118 | text: "previous" | |||
|
119 | } | |||
|
120 | MouseArea { | |||
|
121 | anchors.fill: parent | |||
|
122 | onClicked: { | |||
|
123 | viewNumber = (viewNumber + viewCount - 1) % viewCount; | |||
|
124 | } | |||
|
125 | } | |||
|
126 | } | |||
|
127 | ||||
|
128 | Rectangle { | |||
|
129 | height: buttonRow.height | |||
|
130 | width: 100 | |||
|
131 | color: "#afafaf" | |||
|
132 | radius: 5 | |||
|
133 | Text { | |||
|
134 | anchors.centerIn: parent | |||
|
135 | text: "next" | |||
|
136 | } | |||
|
137 | MouseArea { | |||
|
138 | anchors.fill: parent | |||
|
139 | onClicked: { | |||
|
140 | viewNumber = (viewNumber + 1) % viewCount; | |||
|
141 | } | |||
|
142 | } | |||
|
143 | } | |||
|
144 | } | |||
|
145 | } |
@@ -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( ../tests.pri ) { | |||
|
2 | error( "Couldn't find the test.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,16 | |||||
|
1 | <RCC> | |||
|
2 | <qresource prefix="/"> | |||
|
3 | <file>qml/qmlchartproperties/loader.qml</file> | |||
|
4 | <file>qml/qmlchartproperties/main.qml</file> | |||
|
5 | <file>qml/qmlchartproperties/Button.qml</file> | |||
|
6 | <file>qml/qmlchartproperties/PieChart.qml</file> | |||
|
7 | <file>qml/qmlchartproperties/PieEditor.qml</file> | |||
|
8 | <file>qml/qmlchartproperties/LineChart.qml</file> | |||
|
9 | <file>qml/qmlchartproperties/LineEditor.qml</file> | |||
|
10 | <file>qml/qmlchartproperties/SplineChart.qml</file> | |||
|
11 | <file>qml/qmlchartproperties/ScatterChart.qml</file> | |||
|
12 | <file>qml/qmlchartproperties/AreaChart.qml</file> | |||
|
13 | <file>qml/qmlchartproperties/BarChart.qml</file> | |||
|
14 | <file>qml/qmlchartproperties/BarEditor.qml</file> | |||
|
15 | </qresource> | |||
|
16 | </RCC> |
@@ -1,120 +1,120 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | import QtQuick 1.0 |
|
21 | import QtQuick 1.0 | |
22 | import QtCommercial.Chart 1.0 |
|
22 | import QtCommercial.Chart 1.0 | |
23 | import QmlCustomModel 1.0 |
|
23 | import QmlCustomModel 1.0 | |
24 |
|
24 | |||
25 | Rectangle { |
|
25 | Rectangle { | |
26 | width: parent.width |
|
26 | width: parent.width | |
27 | height: parent.height |
|
27 | height: parent.height | |
28 |
|
28 | |||
29 | ChartView { |
|
29 | ChartView { | |
30 | id: chart |
|
30 | id: chart | |
31 | title: "Custom model example" |
|
31 | title: "Custom model example" | |
32 | anchors.fill: parent |
|
32 | anchors.fill: parent | |
33 | theme: ChartView.ChartThemeLight |
|
33 | theme: ChartView.ChartThemeLight | |
34 | axisX.max: 20 |
|
34 | axisX.max: 20 | |
35 | axisY.max: 20 |
|
35 | axisY.max: 20 | |
36 |
|
36 | |||
37 | // For dynamic data we use a custom data model derived from QAbstractiItemModel |
|
37 | // For dynamic data we use a custom data model derived from QAbstractiItemModel | |
38 | CustomModel { |
|
38 | CustomModel { | |
39 | id: customModel |
|
39 | id: customModel | |
40 |
CustomModelElement { values: [ |
|
40 | CustomModelElement { values: [0, "Manufacturer", 1, 2] } | |
41 | CustomModelElement { values: [1, "Volkswagen", 13.5, 12.5] } |
|
41 | CustomModelElement { values: [1, "Volkswagen", 13.5, 12.5] } | |
42 | CustomModelElement { values: [2, "Toyota", 10.9, 9.9] } |
|
42 | CustomModelElement { values: [2, "Toyota", 10.9, 9.9] } | |
43 | CustomModelElement { values: [3, "Ford", 8.6, 7.6] } |
|
43 | CustomModelElement { values: [3, "Ford", 8.6, 7.6] } | |
44 | CustomModelElement { values: [4, "Skoda", 8.2, 7.2] } |
|
44 | CustomModelElement { values: [4, "Skoda", 8.2, 7.2] } | |
45 | CustomModelElement { values: [5, "Volvo", 6.8, 5.8] } |
|
45 | CustomModelElement { values: [5, "Volvo", 6.8, 5.8] } | |
46 | } |
|
46 | } | |
47 |
|
47 | |||
48 | LineSeries { |
|
48 | LineSeries { | |
49 | name: "Volkswagen" |
|
49 | name: "Volkswagen" | |
50 | HXYModelMapper { |
|
50 | HXYModelMapper { | |
51 | model: customModel |
|
51 | model: customModel | |
52 | xRow: 0 |
|
52 | xRow: 0 | |
53 | yRow: 1 |
|
53 | yRow: 1 | |
54 | first: 2 |
|
54 | first: 2 | |
55 | } |
|
55 | } | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | LineSeries { |
|
58 | LineSeries { | |
59 | name: "Toyota" |
|
59 | name: "Toyota" | |
60 | HXYModelMapper { |
|
60 | HXYModelMapper { | |
61 | model: customModel |
|
61 | model: customModel | |
62 | xRow: 0 |
|
62 | xRow: 0 | |
63 | yRow: 2 |
|
63 | yRow: 2 | |
64 | first: 2 |
|
64 | first: 2 | |
65 | } |
|
65 | } | |
66 | } |
|
66 | } | |
67 |
|
67 | |||
68 | PieSeries { |
|
68 | PieSeries { | |
69 | id: pieSeries |
|
69 | id: pieSeries | |
70 | size: 0.4 |
|
70 | size: 0.4 | |
71 | horizontalPosition: 0.2 |
|
71 | horizontalPosition: 0.2 | |
72 | verticalPosition: 0.3 |
|
72 | verticalPosition: 0.3 | |
73 | } |
|
73 | } | |
74 |
|
74 | |||
75 | VPieModelMapper { |
|
75 | VPieModelMapper { | |
76 | series: pieSeries |
|
76 | series: pieSeries | |
77 | model: customModel |
|
77 | model: customModel | |
78 | labelsColumn: 1 |
|
78 | labelsColumn: 1 | |
79 | valuesColumn: 2 |
|
79 | valuesColumn: 2 | |
80 | first: 1 |
|
80 | first: 1 | |
81 | } |
|
81 | } | |
82 |
|
82 | |||
83 | AreaSeries { |
|
83 | AreaSeries { | |
84 | name: "Ford" |
|
84 | name: "Ford" | |
85 | upperSeries: LineSeries { |
|
85 | upperSeries: LineSeries { | |
86 | HXYModelMapper { |
|
86 | HXYModelMapper { | |
87 | model: customModel |
|
87 | model: customModel | |
88 | xRow: 0 |
|
88 | xRow: 0 | |
89 | yRow: 3 |
|
89 | yRow: 3 | |
90 | first: 2 |
|
90 | first: 2 | |
91 | } |
|
91 | } | |
92 | } |
|
92 | } | |
93 | } |
|
93 | } | |
94 |
|
94 | |||
95 | // BarSeries { |
|
95 | // BarSeries { | |
96 | // model: customModel |
|
96 | // model: customModel | |
97 | // modelMapper.first: 0 |
|
97 | // modelMapper.first: 0 | |
98 | // } |
|
98 | // } | |
99 | } |
|
99 | } | |
100 |
|
100 | |||
101 |
|
101 | |||
102 | // TODO: you could also implement appending to your model, for example: |
|
102 | // TODO: you could also implement appending to your model, for example: | |
103 | // pieSeries.model.append(["Others", 52.0]); |
|
103 | // pieSeries.model.append(["Others", 52.0]); | |
104 |
|
104 | |||
105 | // TODO: show how to use data from a list model in a chart view |
|
105 | // TODO: show how to use data from a list model in a chart view | |
106 | // i.e. copy the data into a custom model |
|
106 | // i.e. copy the data into a custom model | |
107 | // ListModel { |
|
107 | // ListModel { | |
108 | // id: listModel |
|
108 | // id: listModel | |
109 | // ListElement { |
|
109 | // ListElement { | |
110 | // label: "Volkswagen" |
|
110 | // label: "Volkswagen" | |
111 | // value: 13.5 |
|
111 | // value: 13.5 | |
112 | // } |
|
112 | // } | |
113 | // ListElement { |
|
113 | // ListElement { | |
114 | // label: "Toyota" |
|
114 | // label: "Toyota" | |
115 | // value: 10.9 |
|
115 | // value: 10.9 | |
116 | // } |
|
116 | // } | |
117 | // // and so on... |
|
117 | // // and so on... | |
118 | // } |
|
118 | // } | |
119 |
|
119 | |||
120 | } |
|
120 | } |
@@ -1,250 +1,249 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "declarativechart.h" |
|
21 | #include "declarativechart.h" | |
22 | #include <QPainter> |
|
22 | #include <QPainter> | |
23 | #include "declarativelineseries.h" |
|
23 | #include "declarativelineseries.h" | |
24 | #include "declarativeareaseries.h" |
|
24 | #include "declarativeareaseries.h" | |
25 | #include "declarativebarseries.h" |
|
25 | #include "declarativebarseries.h" | |
26 | #include "declarativepieseries.h" |
|
26 | #include "declarativepieseries.h" | |
27 | #include "declarativesplineseries.h" |
|
27 | #include "declarativesplineseries.h" | |
28 | #include "declarativescatterseries.h" |
|
28 | #include "declarativescatterseries.h" | |
29 |
|
29 | |||
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
31 |
|
31 | |||
32 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) |
|
32 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) | |
33 | : QDeclarativeItem(parent), |
|
33 | : QDeclarativeItem(parent), | |
34 | m_chart(new QChart(this)), |
|
34 | m_chart(new QChart(this)), | |
35 | m_legend(LegendTop) |
|
35 | m_legend(LegendTop) | |
36 | { |
|
36 | { | |
37 | setFlag(QGraphicsItem::ItemHasNoContents, false); |
|
37 | setFlag(QGraphicsItem::ItemHasNoContents, false); | |
38 | // m_chart->axisX()->setNiceNumbersEnabled(false); |
|
38 | // m_chart->axisX()->setNiceNumbersEnabled(false); | |
39 | } |
|
39 | } | |
40 |
|
40 | |||
41 | DeclarativeChart::~DeclarativeChart() |
|
41 | DeclarativeChart::~DeclarativeChart() | |
42 | { |
|
42 | { | |
43 | delete m_chart; |
|
43 | delete m_chart; | |
44 | } |
|
44 | } | |
45 |
|
45 | |||
46 | void DeclarativeChart::childEvent(QChildEvent *event) |
|
46 | void DeclarativeChart::childEvent(QChildEvent *event) | |
47 | { |
|
47 | { | |
48 | if (event->type() == QEvent::ChildAdded) { |
|
48 | if (event->type() == QEvent::ChildAdded) { | |
49 | if (qobject_cast<QAbstractSeries *>(event->child())) { |
|
49 | if (qobject_cast<QAbstractSeries *>(event->child())) { | |
50 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); |
|
50 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); | |
51 | } |
|
51 | } | |
52 | } |
|
52 | } | |
53 | } |
|
53 | } | |
54 |
|
54 | |||
55 | void DeclarativeChart::componentComplete() |
|
55 | void DeclarativeChart::componentComplete() | |
56 | { |
|
56 | { | |
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 | // qDebug() << "DeclarativeChart::componentComplete(), add: " << child; | |
61 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(child)); |
|
61 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(child)); | |
62 | } |
|
62 | } | |
63 | } |
|
63 | } | |
64 | // qDebug() << "DeclarativeChart::componentComplete(), maxX: " << axisX()->max(); |
|
64 | // qDebug() << "DeclarativeChart::componentComplete(), maxX: " << axisX()->max(); | |
65 |
|
65 | |||
66 | QDeclarativeItem::componentComplete(); |
|
66 | QDeclarativeItem::componentComplete(); | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) |
|
69 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) | |
70 | { |
|
70 | { | |
71 | // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height(); |
|
71 | // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height(); | |
72 | Q_UNUSED(oldGeometry) |
|
|||
73 |
|
||||
74 | if (newGeometry.isValid()) { |
|
72 | if (newGeometry.isValid()) { | |
75 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { |
|
73 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { | |
76 | m_chart->resize(newGeometry.width(), newGeometry.height()); |
|
74 | m_chart->resize(newGeometry.width(), newGeometry.height()); | |
77 | } |
|
75 | } | |
78 | } |
|
76 | } | |
|
77 | QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); | |||
79 | } |
|
78 | } | |
80 |
|
79 | |||
81 | void DeclarativeChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
80 | void DeclarativeChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | |
82 | { |
|
81 | { | |
83 | Q_UNUSED(option) |
|
82 | Q_UNUSED(option) | |
84 | Q_UNUSED(widget) |
|
83 | Q_UNUSED(widget) | |
85 |
|
84 | |||
86 | // TODO: optimized? |
|
85 | // TODO: optimized? | |
87 | painter->setRenderHint(QPainter::Antialiasing, true); |
|
86 | painter->setRenderHint(QPainter::Antialiasing, true); | |
88 | } |
|
87 | } | |
89 |
|
88 | |||
90 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) |
|
89 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) | |
91 | { |
|
90 | { | |
92 | m_chart->setTheme((QChart::ChartTheme) theme); |
|
91 | m_chart->setTheme((QChart::ChartTheme) theme); | |
93 | } |
|
92 | } | |
94 |
|
93 | |||
95 | DeclarativeChart::Theme DeclarativeChart::theme() |
|
94 | DeclarativeChart::Theme DeclarativeChart::theme() | |
96 | { |
|
95 | { | |
97 | return (DeclarativeChart::Theme) m_chart->theme(); |
|
96 | return (DeclarativeChart::Theme) m_chart->theme(); | |
98 | } |
|
97 | } | |
99 |
|
98 | |||
100 | void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) |
|
99 | void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) | |
101 | { |
|
100 | { | |
102 | m_chart->setAnimationOptions((QChart::AnimationOption) animations); |
|
101 | m_chart->setAnimationOptions((QChart::AnimationOption) animations); | |
103 | } |
|
102 | } | |
104 |
|
103 | |||
105 | DeclarativeChart::Animation DeclarativeChart::animationOptions() |
|
104 | DeclarativeChart::Animation DeclarativeChart::animationOptions() | |
106 | { |
|
105 | { | |
107 | if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) |
|
106 | if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) | |
108 | return DeclarativeChart::AllAnimations; |
|
107 | return DeclarativeChart::AllAnimations; | |
109 | else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) |
|
108 | else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) | |
110 | return DeclarativeChart::GridAxisAnimations; |
|
109 | return DeclarativeChart::GridAxisAnimations; | |
111 | else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) |
|
110 | else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) | |
112 | return DeclarativeChart::SeriesAnimations; |
|
111 | return DeclarativeChart::SeriesAnimations; | |
113 | else |
|
112 | else | |
114 | return DeclarativeChart::NoAnimation; |
|
113 | return DeclarativeChart::NoAnimation; | |
115 | } |
|
114 | } | |
116 |
|
115 | |||
117 | void DeclarativeChart::setLegend(DeclarativeChart::Legend legend) |
|
116 | void DeclarativeChart::setLegend(DeclarativeChart::Legend legend) | |
118 | { |
|
117 | { | |
119 | if (legend != m_legend) { |
|
118 | if (legend != m_legend) { | |
120 | m_legend = legend; |
|
119 | m_legend = legend; | |
121 | switch (m_legend) { |
|
120 | switch (m_legend) { | |
122 | case LegendDisabled: |
|
121 | case LegendDisabled: | |
123 | m_chart->legend()->setVisible(false); |
|
122 | m_chart->legend()->setVisible(false); | |
124 | break; |
|
123 | break; | |
125 | case LegendTop: |
|
124 | case LegendTop: | |
126 | m_chart->legend()->setVisible(true); |
|
125 | m_chart->legend()->setVisible(true); | |
127 | m_chart->legend()->setAlignment(QLegend::AlignmentTop); |
|
126 | m_chart->legend()->setAlignment(QLegend::AlignmentTop); | |
128 | break; |
|
127 | break; | |
129 | case LegendBottom: |
|
128 | case LegendBottom: | |
130 | m_chart->legend()->setVisible(true); |
|
129 | m_chart->legend()->setVisible(true); | |
131 | m_chart->legend()->setAlignment(QLegend::AlignmentBottom); |
|
130 | m_chart->legend()->setAlignment(QLegend::AlignmentBottom); | |
132 | break; |
|
131 | break; | |
133 | case LegendLeft: |
|
132 | case LegendLeft: | |
134 | m_chart->legend()->setVisible(true); |
|
133 | m_chart->legend()->setVisible(true); | |
135 | m_chart->legend()->setAlignment(QLegend::AlignmentLeft); |
|
134 | m_chart->legend()->setAlignment(QLegend::AlignmentLeft); | |
136 | break; |
|
135 | break; | |
137 | case LegendRight: |
|
136 | case LegendRight: | |
138 | m_chart->legend()->setVisible(true); |
|
137 | m_chart->legend()->setVisible(true); | |
139 | m_chart->legend()->setAlignment(QLegend::AlignmentRight); |
|
138 | m_chart->legend()->setAlignment(QLegend::AlignmentRight); | |
140 | break; |
|
139 | break; | |
141 | default: |
|
140 | default: | |
142 | m_chart->legend()->setVisible(false); |
|
141 | m_chart->legend()->setVisible(false); | |
143 | break; |
|
142 | break; | |
144 | } |
|
143 | } | |
145 | } |
|
144 | } | |
146 | } |
|
145 | } | |
147 |
|
146 | |||
148 | DeclarativeChart::Legend DeclarativeChart::legend() |
|
147 | DeclarativeChart::Legend DeclarativeChart::legend() | |
149 | { |
|
148 | { | |
150 | return m_legend; |
|
149 | return m_legend; | |
151 | } |
|
150 | } | |
152 |
|
151 | |||
153 | QAxis *DeclarativeChart::axisX() |
|
152 | QAxis *DeclarativeChart::axisX() | |
154 | { |
|
153 | { | |
155 | return m_chart->axisX(); |
|
154 | return m_chart->axisX(); | |
156 | } |
|
155 | } | |
157 |
|
156 | |||
158 | QAxis *DeclarativeChart::axisY() |
|
157 | QAxis *DeclarativeChart::axisY() | |
159 | { |
|
158 | { | |
160 | return m_chart->axisY(); |
|
159 | return m_chart->axisY(); | |
161 | } |
|
160 | } | |
162 |
|
161 | |||
163 | QVariantList DeclarativeChart::axisXLabels() |
|
162 | QVariantList DeclarativeChart::axisXLabels() | |
164 | { |
|
163 | { | |
165 | QVariantList labels; |
|
164 | QVariantList labels; | |
166 | foreach (qreal value, m_chart->axisX()->categories()->values()) { |
|
165 | foreach (qreal value, m_chart->axisX()->categories()->values()) { | |
167 | labels.append(value); |
|
166 | labels.append(value); | |
168 | labels.append(m_chart->axisX()->categories()->label(value)); |
|
167 | labels.append(m_chart->axisX()->categories()->label(value)); | |
169 | } |
|
168 | } | |
170 | return labels; |
|
169 | return labels; | |
171 | } |
|
170 | } | |
172 |
|
171 | |||
173 | void DeclarativeChart::setAxisXLabels(QVariantList list) |
|
172 | void DeclarativeChart::setAxisXLabels(QVariantList list) | |
174 | { |
|
173 | { | |
175 | QVariant value(QVariant::Invalid); |
|
174 | QVariant value(QVariant::Invalid); | |
176 | foreach (QVariant element, list) { |
|
175 | foreach (QVariant element, list) { | |
177 | if (value.isValid() && element.type() == QVariant::String) { |
|
176 | if (value.isValid() && element.type() == QVariant::String) { | |
178 | m_chart->axisX()->categories()->insert(value.toDouble(), element.toString()); |
|
177 | m_chart->axisX()->categories()->insert(value.toDouble(), element.toString()); | |
179 | value = QVariant(QVariant::Invalid); |
|
178 | value = QVariant(QVariant::Invalid); | |
180 | } else { |
|
179 | } else { | |
181 | if (element.canConvert(QVariant::Double)) |
|
180 | if (element.canConvert(QVariant::Double)) | |
182 | value = element; |
|
181 | value = element; | |
183 | } |
|
182 | } | |
184 | } |
|
183 | } | |
185 | } |
|
184 | } | |
186 |
|
185 | |||
187 | int DeclarativeChart::count() |
|
186 | int DeclarativeChart::count() | |
188 | { |
|
187 | { | |
189 | return m_chart->series().count(); |
|
188 | return m_chart->series().count(); | |
190 | } |
|
189 | } | |
191 |
|
190 | |||
192 | QAbstractSeries *DeclarativeChart::series(int index) |
|
191 | QAbstractSeries *DeclarativeChart::series(int index) | |
193 | { |
|
192 | { | |
194 | if (index < m_chart->series().count()) { |
|
193 | if (index < m_chart->series().count()) { | |
195 | return m_chart->series().at(index); |
|
194 | return m_chart->series().at(index); | |
196 | } |
|
195 | } | |
197 | return 0; |
|
196 | return 0; | |
198 | } |
|
197 | } | |
199 |
|
198 | |||
200 | QAbstractSeries *DeclarativeChart::series(QString seriesName) |
|
199 | QAbstractSeries *DeclarativeChart::series(QString seriesName) | |
201 | { |
|
200 | { | |
202 | foreach(QAbstractSeries *series, m_chart->series()) { |
|
201 | foreach(QAbstractSeries *series, m_chart->series()) { | |
203 | if (series->name() == seriesName) |
|
202 | if (series->name() == seriesName) | |
204 | return series; |
|
203 | return series; | |
205 | } |
|
204 | } | |
206 | return 0; |
|
205 | return 0; | |
207 | } |
|
206 | } | |
208 |
|
207 | |||
209 | QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name) |
|
208 | QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name) | |
210 | { |
|
209 | { | |
211 | QAbstractSeries *series = 0; |
|
210 | QAbstractSeries *series = 0; | |
212 | switch (type) { |
|
211 | switch (type) { | |
213 | case DeclarativeChart::SeriesTypeLine: |
|
212 | case DeclarativeChart::SeriesTypeLine: | |
214 | series = new DeclarativeLineSeries(); |
|
213 | series = new DeclarativeLineSeries(); | |
215 | break; |
|
214 | break; | |
216 | case DeclarativeChart::SeriesTypeArea: |
|
215 | case DeclarativeChart::SeriesTypeArea: | |
217 | series = new DeclarativeAreaSeries(); |
|
216 | series = new DeclarativeAreaSeries(); | |
218 | break; |
|
217 | break; | |
219 | case DeclarativeChart::SeriesTypeBar: |
|
218 | case DeclarativeChart::SeriesTypeBar: | |
220 | series = new DeclarativeBarSeries(); |
|
219 | series = new DeclarativeBarSeries(); | |
221 | break; |
|
220 | break; | |
222 | case DeclarativeChart::SeriesTypeStackedBar: |
|
221 | case DeclarativeChart::SeriesTypeStackedBar: | |
223 | // TODO |
|
222 | // TODO | |
224 | break; |
|
223 | break; | |
225 | case DeclarativeChart::SeriesTypePercentBar: |
|
224 | case DeclarativeChart::SeriesTypePercentBar: | |
226 | // TODO |
|
225 | // TODO | |
227 | break; |
|
226 | break; | |
228 | case DeclarativeChart::SeriesTypeGroupedBar: |
|
227 | case DeclarativeChart::SeriesTypeGroupedBar: | |
229 | series = new DeclarativeGroupedBarSeries(); |
|
228 | series = new DeclarativeGroupedBarSeries(); | |
230 | break; |
|
229 | break; | |
231 | case DeclarativeChart::SeriesTypePie: |
|
230 | case DeclarativeChart::SeriesTypePie: | |
232 | series = new DeclarativePieSeries(); |
|
231 | series = new DeclarativePieSeries(); | |
233 | break; |
|
232 | break; | |
234 | case DeclarativeChart::SeriesTypeScatter: |
|
233 | case DeclarativeChart::SeriesTypeScatter: | |
235 | series = new DeclarativeScatterSeries(); |
|
234 | series = new DeclarativeScatterSeries(); | |
236 | break; |
|
235 | break; | |
237 | case DeclarativeChart::SeriesTypeSpline: |
|
236 | case DeclarativeChart::SeriesTypeSpline: | |
238 | series = new DeclarativeSplineSeries(); |
|
237 | series = new DeclarativeSplineSeries(); | |
239 | break; |
|
238 | break; | |
240 | default: |
|
239 | default: | |
241 | qWarning() << "Illegal series type"; |
|
240 | qWarning() << "Illegal series type"; | |
242 | } |
|
241 | } | |
243 | series->setName(name); |
|
242 | series->setName(name); | |
244 | m_chart->addSeries(series); |
|
243 | m_chart->addSeries(series); | |
245 | return series; |
|
244 | return series; | |
246 | } |
|
245 | } | |
247 |
|
246 | |||
248 | #include "moc_declarativechart.cpp" |
|
247 | #include "moc_declarativechart.cpp" | |
249 |
|
248 | |||
250 | QTCOMMERCIALCHART_END_NAMESPACE |
|
249 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,137 +1,149 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "declarativepieseries.h" |
|
21 | #include "declarativepieseries.h" | |
22 | #include "declarativechart.h" |
|
22 | #include "declarativechart.h" | |
23 | #include "qchart.h" |
|
23 | #include "qchart.h" | |
24 | #include <qdeclarativelist.h> |
|
24 | #include <qdeclarativelist.h> | |
25 | #include <QVPieModelMapper> |
|
25 | #include <QVPieModelMapper> | |
26 | #include <QHPieModelMapper> |
|
26 | #include <QHPieModelMapper> | |
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
29 |
|
29 | |||
30 | DeclarativePieSlice::DeclarativePieSlice(QObject *parent) : |
|
30 | DeclarativePieSlice::DeclarativePieSlice(QObject *parent) : | |
31 | QPieSlice(parent) |
|
31 | QPieSlice(parent) | |
32 | { |
|
32 | { | |
33 | } |
|
33 | } | |
34 |
|
34 | |||
35 | QColor DeclarativePieSlice::color() |
|
35 | QColor DeclarativePieSlice::color() | |
36 | { |
|
36 | { | |
37 | return brush().color(); |
|
37 | return brush().color(); | |
38 | } |
|
38 | } | |
39 |
|
39 | |||
40 | void DeclarativePieSlice::setColor(QColor color) |
|
40 | void DeclarativePieSlice::setColor(QColor color) | |
41 | { |
|
41 | { | |
42 | QBrush b = brush(); |
|
42 | QBrush b = brush(); | |
43 | b.setColor(color); |
|
43 | b.setColor(color); | |
44 | setBrush(b); |
|
44 | setBrush(b); | |
45 | } |
|
45 | } | |
46 |
|
46 | |||
47 | QColor DeclarativePieSlice::borderColor() |
|
47 | QColor DeclarativePieSlice::borderColor() | |
48 | { |
|
48 | { | |
49 | return pen().color(); |
|
49 | return pen().color(); | |
50 | } |
|
50 | } | |
51 |
|
51 | |||
52 | void DeclarativePieSlice::setBorderColor(QColor color) |
|
52 | void DeclarativePieSlice::setBorderColor(QColor color) | |
53 | { |
|
53 | { | |
54 | QPen p = pen(); |
|
54 | QPen p = pen(); | |
55 | p.setColor(color); |
|
55 | p.setColor(color); | |
56 | setPen(p); |
|
56 | setPen(p); | |
57 | } |
|
57 | } | |
58 |
|
58 | |||
59 | int DeclarativePieSlice::borderWidth() |
|
59 | int DeclarativePieSlice::borderWidth() | |
60 | { |
|
60 | { | |
61 | return pen().width(); |
|
61 | return pen().width(); | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | void DeclarativePieSlice::setBorderWidth(int width) |
|
64 | void DeclarativePieSlice::setBorderWidth(int width) | |
65 | { |
|
65 | { | |
66 | QPen p = pen(); |
|
66 | QPen p = pen(); | |
67 | p.setWidth(width); |
|
67 | p.setWidth(width); | |
68 | setPen(p); |
|
68 | setPen(p); | |
69 | } |
|
69 | } | |
70 |
|
70 | |||
|
71 | QColor DeclarativePieSlice::labelColor() | |||
|
72 | { | |||
|
73 | return labelPen().color(); | |||
|
74 | } | |||
|
75 | ||||
|
76 | void DeclarativePieSlice::setLabelColor(QColor color) | |||
|
77 | { | |||
|
78 | QPen p = labelPen(); | |||
|
79 | p.setColor(color); | |||
|
80 | setLabelPen(p); | |||
|
81 | } | |||
|
82 | ||||
71 | DeclarativePieSeries::DeclarativePieSeries(QObject *parent) : |
|
83 | DeclarativePieSeries::DeclarativePieSeries(QObject *parent) : | |
72 | QPieSeries(parent) |
|
84 | QPieSeries(parent) | |
73 | { |
|
85 | { | |
74 | } |
|
86 | } | |
75 |
|
87 | |||
76 | void DeclarativePieSeries::classBegin() |
|
88 | void DeclarativePieSeries::classBegin() | |
77 | { |
|
89 | { | |
78 | } |
|
90 | } | |
79 |
|
91 | |||
80 | void DeclarativePieSeries::componentComplete() |
|
92 | void DeclarativePieSeries::componentComplete() | |
81 | { |
|
93 | { | |
82 | foreach(QObject *child, children()) { |
|
94 | foreach(QObject *child, children()) { | |
83 | if (qobject_cast<DeclarativePieSlice *>(child)) { |
|
95 | if (qobject_cast<DeclarativePieSlice *>(child)) { | |
84 | QPieSeries::append(qobject_cast<DeclarativePieSlice *>(child)); |
|
96 | QPieSeries::append(qobject_cast<DeclarativePieSlice *>(child)); | |
85 | } else if(qobject_cast<QVPieModelMapper *>(child)) { |
|
97 | } else if(qobject_cast<QVPieModelMapper *>(child)) { | |
86 | QVPieModelMapper *mapper = qobject_cast<QVPieModelMapper *>(child); |
|
98 | QVPieModelMapper *mapper = qobject_cast<QVPieModelMapper *>(child); | |
87 | mapper->setSeries(this); |
|
99 | mapper->setSeries(this); | |
88 | } else if(qobject_cast<QHPieModelMapper *>(child)) { |
|
100 | } else if(qobject_cast<QHPieModelMapper *>(child)) { | |
89 | QHPieModelMapper *mapper = qobject_cast<QHPieModelMapper *>(child); |
|
101 | QHPieModelMapper *mapper = qobject_cast<QHPieModelMapper *>(child); | |
90 | mapper->setSeries(this); |
|
102 | mapper->setSeries(this); | |
91 | } |
|
103 | } | |
92 | } |
|
104 | } | |
93 | } |
|
105 | } | |
94 |
|
106 | |||
95 | QDeclarativeListProperty<QObject> DeclarativePieSeries::seriesChildren() |
|
107 | QDeclarativeListProperty<QObject> DeclarativePieSeries::seriesChildren() | |
96 | { |
|
108 | { | |
97 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativePieSeries::appendSeriesChildren); |
|
109 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativePieSeries::appendSeriesChildren); | |
98 | } |
|
110 | } | |
99 |
|
111 | |||
100 | void DeclarativePieSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
112 | void DeclarativePieSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
101 | { |
|
113 | { | |
102 | // Empty implementation; the children are parsed in componentComplete instead |
|
114 | // Empty implementation; the children are parsed in componentComplete instead | |
103 | Q_UNUSED(list); |
|
115 | Q_UNUSED(list); | |
104 | Q_UNUSED(element); |
|
116 | Q_UNUSED(element); | |
105 | } |
|
117 | } | |
106 |
|
118 | |||
107 | DeclarativePieSlice *DeclarativePieSeries::at(int index) |
|
119 | DeclarativePieSlice *DeclarativePieSeries::at(int index) | |
108 | { |
|
120 | { | |
109 | QList<QPieSlice*> sliceList = slices(); |
|
121 | QList<QPieSlice*> sliceList = slices(); | |
110 | if (index < sliceList.count()) |
|
122 | if (index < sliceList.count()) | |
111 | return qobject_cast<DeclarativePieSlice *>(sliceList[index]); |
|
123 | return qobject_cast<DeclarativePieSlice *>(sliceList[index]); | |
112 |
|
124 | |||
113 | return 0; |
|
125 | return 0; | |
114 | } |
|
126 | } | |
115 |
|
127 | |||
116 | DeclarativePieSlice* DeclarativePieSeries::find(QString label) |
|
128 | DeclarativePieSlice* DeclarativePieSeries::find(QString label) | |
117 | { |
|
129 | { | |
118 | foreach (QPieSlice *slice, slices()) { |
|
130 | foreach (QPieSlice *slice, slices()) { | |
119 | if (slice->label() == label) |
|
131 | if (slice->label() == label) | |
120 | return qobject_cast<DeclarativePieSlice *>(slice); |
|
132 | return qobject_cast<DeclarativePieSlice *>(slice); | |
121 | } |
|
133 | } | |
122 | return 0; |
|
134 | return 0; | |
123 | } |
|
135 | } | |
124 |
|
136 | |||
125 | DeclarativePieSlice* DeclarativePieSeries::append(QString label, qreal value) |
|
137 | DeclarativePieSlice* DeclarativePieSeries::append(QString label, qreal value) | |
126 | { |
|
138 | { | |
127 | // TODO: parameter order is wrong, switch it: |
|
139 | // TODO: parameter order is wrong, switch it: | |
128 | DeclarativePieSlice *slice = new DeclarativePieSlice(this); |
|
140 | DeclarativePieSlice *slice = new DeclarativePieSlice(this); | |
129 | slice->setLabel(label); |
|
141 | slice->setLabel(label); | |
130 | slice->setValue(value); |
|
142 | slice->setValue(value); | |
131 | QPieSeries::append(slice); |
|
143 | QPieSeries::append(slice); | |
132 | return slice; |
|
144 | return slice; | |
133 | } |
|
145 | } | |
134 |
|
146 | |||
135 | #include "moc_declarativepieseries.cpp" |
|
147 | #include "moc_declarativepieseries.cpp" | |
136 |
|
148 | |||
137 | QTCOMMERCIALCHART_END_NAMESPACE |
|
149 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,76 +1,79 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVEPIESERIES_H |
|
21 | #ifndef DECLARATIVEPIESERIES_H | |
22 | #define DECLARATIVEPIESERIES_H |
|
22 | #define DECLARATIVEPIESERIES_H | |
23 |
|
23 | |||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #include <QPieSlice> |
|
25 | #include <QPieSlice> | |
26 | #include <QPieSeries> |
|
26 | #include <QPieSeries> | |
27 | #include <QDeclarativeParserStatus> |
|
27 | #include <QDeclarativeParserStatus> | |
28 | #include <QDeclarativeListProperty> |
|
28 | #include <QDeclarativeListProperty> | |
29 | #include <QAbstractItemModel> |
|
29 | #include <QAbstractItemModel> | |
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 | class QChart; |
|
33 | class QChart; | |
34 |
|
34 | |||
35 | class DeclarativePieSlice: public QPieSlice |
|
35 | class DeclarativePieSlice: public QPieSlice | |
36 | { |
|
36 | { | |
37 | Q_OBJECT |
|
37 | Q_OBJECT | |
38 | Q_PROPERTY(QColor color READ color WRITE setColor) |
|
38 | Q_PROPERTY(QColor color READ color WRITE setColor) | |
39 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor) |
|
39 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor) | |
40 | Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth) |
|
40 | Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth) | |
|
41 | Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor) | |||
41 |
|
42 | |||
42 | public: |
|
43 | public: | |
43 | explicit DeclarativePieSlice(QObject *parent = 0); |
|
44 | explicit DeclarativePieSlice(QObject *parent = 0); | |
44 | QColor color(); |
|
45 | QColor color(); | |
45 | void setColor(QColor color); |
|
46 | void setColor(QColor color); | |
46 | QColor borderColor(); |
|
47 | QColor borderColor(); | |
47 | void setBorderColor(QColor color); |
|
48 | void setBorderColor(QColor color); | |
48 | int borderWidth(); |
|
49 | int borderWidth(); | |
49 | void setBorderWidth(int width); |
|
50 | void setBorderWidth(int width); | |
|
51 | QColor labelColor(); | |||
|
52 | void setLabelColor(QColor color); | |||
50 | }; |
|
53 | }; | |
51 |
|
54 | |||
52 | class DeclarativePieSeries : public QPieSeries, public QDeclarativeParserStatus |
|
55 | class DeclarativePieSeries : public QPieSeries, public QDeclarativeParserStatus | |
53 | { |
|
56 | { | |
54 | Q_OBJECT |
|
57 | Q_OBJECT | |
55 | Q_INTERFACES(QDeclarativeParserStatus) |
|
58 | Q_INTERFACES(QDeclarativeParserStatus) | |
56 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
59 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
57 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
60 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
58 |
|
61 | |||
59 | public: |
|
62 | public: | |
60 | explicit DeclarativePieSeries(QObject *parent = 0); |
|
63 | explicit DeclarativePieSeries(QObject *parent = 0); | |
61 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
64 | QDeclarativeListProperty<QObject> seriesChildren(); | |
62 | Q_INVOKABLE DeclarativePieSlice *at(int index); |
|
65 | Q_INVOKABLE DeclarativePieSlice *at(int index); | |
63 | Q_INVOKABLE DeclarativePieSlice* find(QString label); |
|
66 | Q_INVOKABLE DeclarativePieSlice* find(QString label); | |
64 | Q_INVOKABLE DeclarativePieSlice* append(QString label, qreal value); |
|
67 | Q_INVOKABLE DeclarativePieSlice* append(QString label, qreal value); | |
65 |
|
68 | |||
66 | public: |
|
69 | public: | |
67 | void classBegin(); |
|
70 | void classBegin(); | |
68 | void componentComplete(); |
|
71 | void componentComplete(); | |
69 |
|
72 | |||
70 | public Q_SLOTS: |
|
73 | public Q_SLOTS: | |
71 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
74 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
72 | }; |
|
75 | }; | |
73 |
|
76 | |||
74 | QTCOMMERCIALCHART_END_NAMESPACE |
|
77 | QTCOMMERCIALCHART_END_NAMESPACE | |
75 |
|
78 | |||
76 | #endif // DECLARATIVEPIESERIES_H |
|
79 | #endif // DECLARATIVEPIESERIES_H |
@@ -1,86 +1,87 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QXYSERIES_H |
|
21 | #ifndef QXYSERIES_H | |
22 | #define QXYSERIES_H |
|
22 | #define QXYSERIES_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <qabstractseries.h> |
|
25 | #include <qabstractseries.h> | |
26 | #include <QPen> |
|
26 | #include <QPen> | |
27 | #include <QBrush> |
|
27 | #include <QBrush> | |
28 |
|
28 | |||
29 | class QModelIndex; |
|
29 | class QModelIndex; | |
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 | class QXYSeriesPrivate; |
|
33 | class QXYSeriesPrivate; | |
34 | class QXYModelMapper; |
|
34 | class QXYModelMapper; | |
35 |
|
35 | |||
36 | class QTCOMMERCIALCHART_EXPORT QXYSeries : public QAbstractSeries |
|
36 | class QTCOMMERCIALCHART_EXPORT QXYSeries : public QAbstractSeries | |
37 | { |
|
37 | { | |
38 | Q_OBJECT |
|
38 | Q_OBJECT | |
|
39 | Q_PROPERTY(bool pointsVisible READ pointsVisible WRITE setPointsVisible) | |||
39 |
|
40 | |||
40 | protected: |
|
41 | protected: | |
41 | explicit QXYSeries(QXYSeriesPrivate &d,QObject *parent = 0); |
|
42 | explicit QXYSeries(QXYSeriesPrivate &d,QObject *parent = 0); | |
42 |
|
43 | |||
43 | public: |
|
44 | public: | |
44 | ~QXYSeries(); |
|
45 | ~QXYSeries(); | |
45 | void append(qreal x, qreal y); |
|
46 | void append(qreal x, qreal y); | |
46 | void append(const QPointF &point); |
|
47 | void append(const QPointF &point); | |
47 | void append(const QList<QPointF> &points); |
|
48 | void append(const QList<QPointF> &points); | |
48 | void replace(qreal oldX,qreal oldY,qreal newX,qreal newY); |
|
49 | void replace(qreal oldX,qreal oldY,qreal newX,qreal newY); | |
49 | void replace(const QPointF &oldPoint,const QPointF &newPoint); |
|
50 | void replace(const QPointF &oldPoint,const QPointF &newPoint); | |
50 | void remove(qreal x, qreal y); |
|
51 | void remove(qreal x, qreal y); | |
51 | void remove(const QPointF &point); |
|
52 | void remove(const QPointF &point); | |
52 | void removeAll(); |
|
53 | void removeAll(); | |
53 | void insert(int index, const QPointF &point); |
|
54 | void insert(int index, const QPointF &point); | |
54 | void clear(); |
|
55 | void clear(); | |
55 |
|
56 | |||
56 | int count() const; |
|
57 | int count() const; | |
57 | QList<QPointF> points() const; |
|
58 | QList<QPointF> points() const; | |
58 |
|
59 | |||
59 | QXYSeries& operator << (const QPointF &point); |
|
60 | QXYSeries& operator << (const QPointF &point); | |
60 | QXYSeries& operator << (const QList<QPointF> &points); |
|
61 | QXYSeries& operator << (const QList<QPointF> &points); | |
61 |
|
62 | |||
62 | void setPen(const QPen &pen); |
|
63 | void setPen(const QPen &pen); | |
63 | QPen pen() const; |
|
64 | QPen pen() const; | |
64 |
|
65 | |||
65 | void setBrush(const QBrush &brush); |
|
66 | void setBrush(const QBrush &brush); | |
66 | QBrush brush() const; |
|
67 | QBrush brush() const; | |
67 |
|
68 | |||
68 | void setPointsVisible(bool visible = true); |
|
69 | void setPointsVisible(bool visible = true); | |
69 | bool pointsVisible() const; |
|
70 | bool pointsVisible() const; | |
70 |
|
71 | |||
71 | Q_SIGNALS: |
|
72 | Q_SIGNALS: | |
72 | void clicked(const QPointF &point); |
|
73 | void clicked(const QPointF &point); | |
73 | void pointReplaced(int index); |
|
74 | void pointReplaced(int index); | |
74 | void pointRemoved(int index); |
|
75 | void pointRemoved(int index); | |
75 | void pointAdded(int index); |
|
76 | void pointAdded(int index); | |
76 |
|
77 | |||
77 | private: |
|
78 | private: | |
78 | Q_DECLARE_PRIVATE(QXYSeries) |
|
79 | Q_DECLARE_PRIVATE(QXYSeries) | |
79 | Q_DISABLE_COPY(QXYSeries) |
|
80 | Q_DISABLE_COPY(QXYSeries) | |
80 | friend class XYLegendMarker; |
|
81 | friend class XYLegendMarker; | |
81 | friend class XYChart; |
|
82 | friend class XYChart; | |
82 | }; |
|
83 | }; | |
83 |
|
84 | |||
84 | QTCOMMERCIALCHART_END_NAMESPACE |
|
85 | QTCOMMERCIALCHART_END_NAMESPACE | |
85 |
|
86 | |||
86 | #endif |
|
87 | #endif |
@@ -1,11 +1,12 | |||||
1 | !include( ../config.pri ) { |
|
1 | !include( ../config.pri ) { | |
2 | error( "Couldn't find the config.pri file!" ) |
|
2 | error( "Couldn't find the config.pri file!" ) | |
3 | } |
|
3 | } | |
4 |
|
4 | |||
5 | TEMPLATE = subdirs |
|
5 | TEMPLATE = subdirs | |
6 | SUBDIRS += \ |
|
6 | SUBDIRS += \ | |
7 | auto \ |
|
7 | auto \ | |
8 | chartwidgettest \ |
|
8 | chartwidgettest \ | |
9 | wavechart \ |
|
9 | wavechart \ | |
10 | gdpbarchart \ |
|
10 | gdpbarchart \ | |
11 | tablemodelchart |
|
11 | tablemodelchart \ | |
|
12 | qmlchartproperties |
General Comments 0
You need to be logged in to leave comments.
Login now