##// END OF EJS Templates
Added test app for testing QML properties
Tero Ahola -
r1298:9b6f70236860
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/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>
@@ -37,7 +37,7 Rectangle {
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: [index, "Manufacturer", 1, 2] }
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] }
@@ -69,13 +69,12 void DeclarativeChart::componentComplete()
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)
@@ -68,6 +68,18 void DeclarativePieSlice::setBorderWidth(int 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 {
@@ -38,6 +38,7 class DeclarativePieSlice: public QPieSlice
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);
@@ -47,6 +48,8 public:
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
@@ -36,6 +36,7 class QXYModelMapper;
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);
@@ -8,4 +8,5 SUBDIRS += \
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