aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/demos/stocqt
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@digia.com>2012-11-29 16:02:34 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-12-10 18:16:48 +0100
commita6065d60f158ffad7a94877883af69731da94295 (patch)
tree5657fd490fd8a3f9794a8c9bcc9f85cf24a095c1 /examples/quick/demos/stocqt
parentc18e04b2e61f174a4883f6884cf9a0712c5725e3 (diff)
centralize and fixup example sources install targets
follow respective change in qtbase Change-Id: I27502eb7ebea973e19ec5f7c3ec0e2338556f6e0 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com>
Diffstat (limited to 'examples/quick/demos/stocqt')
-rw-r--r--examples/quick/demos/stocqt/content/Button.qml59
-rw-r--r--examples/quick/demos/stocqt/content/DatePicker.qml122
-rw-r--r--examples/quick/demos/stocqt/content/StockChart.qml324
-rw-r--r--examples/quick/demos/stocqt/content/StockListModel.qml147
-rw-r--r--examples/quick/demos/stocqt/content/StockListView.qml87
-rw-r--r--examples/quick/demos/stocqt/content/StockModel.qml160
-rw-r--r--examples/quick/demos/stocqt/content/StockSettings.qml317
-rw-r--r--examples/quick/demos/stocqt/content/StockView.qml129
-rw-r--r--examples/quick/demos/stocqt/content/images/icon-calendar-anim.pngbin0 -> 1088 bytes
-rw-r--r--examples/quick/demos/stocqt/content/images/icon-calendar.pngbin0 -> 884 bytes
-rw-r--r--examples/quick/demos/stocqt/content/images/icon-items.pngbin0 -> 887 bytes
-rw-r--r--examples/quick/demos/stocqt/content/images/icon-settings.pngbin0 -> 1066 bytes
-rw-r--r--examples/quick/demos/stocqt/content/images/logo.pngbin0 -> 4266 bytes
-rw-r--r--examples/quick/demos/stocqt/content/images/stock-selected.pngbin0 -> 6480 bytes
-rw-r--r--examples/quick/demos/stocqt/content/images/wheel-touch.pngbin0 -> 4767 bytes
-rw-r--r--examples/quick/demos/stocqt/content/images/wheel.pngbin0 -> 36223 bytes
-rw-r--r--examples/quick/demos/stocqt/main.cpp41
-rw-r--r--examples/quick/demos/stocqt/stocqt.pro9
-rw-r--r--examples/quick/demos/stocqt/stocqt.qml101
-rw-r--r--examples/quick/demos/stocqt/stocqt.qmlproject16
20 files changed, 1512 insertions, 0 deletions
diff --git a/examples/quick/demos/stocqt/content/Button.qml b/examples/quick/demos/stocqt/content/Button.qml
new file mode 100644
index 0000000000..0e99c52c51
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/Button.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id:button
+ property bool buttonEnabled:true
+ radius:5
+ width:25
+ height:25
+ color:buttonEnabled ? "steelblue" : "gray"
+ MouseArea {
+ anchors.fill:parent
+ onClicked: {
+ if (buttonEnabled)
+ buttonEnabled = false;
+ else
+ buttonEnabled = true;
+ }
+ }
+}
diff --git a/examples/quick/demos/stocqt/content/DatePicker.qml b/examples/quick/demos/stocqt/content/DatePicker.qml
new file mode 100644
index 0000000000..82d8788bd9
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/DatePicker.qml
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id:root
+ color:"transparent"
+ width:300
+ height:45
+ property var _monthNames : [ "JAN", "FEB", "MAR", "APR", "MAY", "JUN","JUL", "AUG", "SEP", "OCT", "NOV", "DEC" ];
+ property var date:new Date()
+
+ onDateChanged: {
+ month.text = root._monthNames[root.date.getMonth()]
+ day.text = date.getDate();
+ year.text = date.getFullYear();
+ }
+ Row {
+ spacing:20
+ anchors.fill:parent
+
+ Rectangle {
+ height:root.height
+ width:root.width/3 - 20
+ color:"#272822"
+ radius:5
+
+ TextInput {
+ id:month
+ anchors.centerIn:parent
+ color:"#ecc089"
+ font.pointSize:25
+ font.bold:true
+ text:root._monthNames[root.date.getMonth()]
+ onAccepted : {
+ for (var i = 0; i < 12; i++) {
+ if (text === root._monthNames[i]) {
+ root.date.setMonth(i);
+ root.date = root.date;
+ return;
+ }
+ }
+ root.date = root.date;
+ }
+ }
+ }
+
+ Rectangle {
+ height:root.height
+ width:root.width/3 - 20
+ color:"#272822"
+ radius:5
+
+ TextInput {
+ id:day
+ anchors.centerIn:parent
+ color:"#ecc089"
+ font.pointSize:25
+ font.bold:true
+ text:root.date.getDate()
+ validator:IntValidator {bottom:1; top:31}
+ onAccepted: { root.date.setDate(text); root.date = root.date;}
+ }
+ }
+
+ Rectangle {
+ height:root.height
+ width:root.width/3 - 20
+ color:"#272822"
+ radius:5
+
+ TextInput {
+ id:year
+ anchors.centerIn:parent
+ color:"#ecc089"
+ font.pointSize:25
+ font.bold:true
+ text:root.date.getFullYear()
+ validator:IntValidator {bottom:1995; top:(new Date()).getFullYear()}
+ onAccepted:{ root.date.setFullYear(text); root.date = root.date;}
+ }
+ }
+ }
+}
diff --git a/examples/quick/demos/stocqt/content/StockChart.qml b/examples/quick/demos/stocqt/content/StockChart.qml
new file mode 100644
index 0000000000..c7411679bb
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/StockChart.qml
@@ -0,0 +1,324 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+Rectangle {
+ id:chart
+ width:320
+ height:320
+ color:"transparent"
+ property var _months : [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]
+ property var stockModel:null
+ property var startDate
+ property var endDate
+ property var settings
+
+ function update() {
+ if (settings.chartType === "year")
+ chart.startDate = new Date(chart.endDate.getFullYear() - 1, chart.endDate.getMonth(), chart.endDate.getDate());
+ else if (settings.chartType === "month")
+ chart.startDate = new Date(chart.endDate.getFullYear() , chart.endDate.getMonth() -1, chart.endDate.getDate())
+ else if (settings.chartType === "week")
+ chart.startDate = new Date(chart.endDate.getFullYear() , chart.endDate.getMonth(), chart.endDate.getDate() - 7)
+ else
+ chart.startDate = new Date(1995, 3, 25)
+
+ canvas.requestPaint();
+ }
+
+
+ Text {
+ id:fromDate
+ color:"#6a5b44"
+ width:50
+ font.pointSize: 10
+ wrapMode: Text.WordWrap
+ anchors.left: parent.left
+ anchors.leftMargin: 20
+ anchors.top:parent.top
+ text:_months[startDate.getMonth()] + "\n" + startDate.getFullYear()
+ }
+
+ Text {
+ id:toDate
+ color:"#6a5b44"
+ font.pointSize: 10
+ width:50
+ wrapMode: Text.WordWrap
+ anchors.right: parent.right
+ anchors.leftMargin: 20
+ anchors.top:parent.top
+ text:_months[endDate.getMonth()] + "\n" + endDate.getFullYear()
+ }
+
+ Canvas {
+ id:canvas
+ anchors.top : toDate.bottom
+ width:parent.width
+ anchors.bottom: parent.bottom
+
+ renderTarget: Canvas.FramebufferObject
+ property int frames:first
+ property int mouseX:0;
+ property int mouseY:0;
+ property int mousePressedX:0;
+ property int mousePressedY:0;
+ property int movedY:0
+ property real scaleX:1.0;
+ property real scaleY:1.0;
+ property int first:0;
+ property int last:0;
+
+// MouseArea {
+// anchors.fill: parent
+
+// onPositionChanged: {
+// if (mouse.modifiers & Qt.ControlModifier) {
+// if (canvas.mouseX == 0 && canvas.mouseY == 0) {
+// canvas.mouseX = mouse.x;
+// canvas.mouseY = mouse.y;
+// }
+// } else{
+// var w = (view.width/view.count)*canvas.scaleX;
+
+// //canvas.movedY += Math.round((canvas.mousePressedY - mouse.y)/2);
+
+// var movedX = Math.round((canvas.mousePressedX - mouse.x)/w);
+// if (movedX != 0 || canvas.movedY != 0) {
+// if (canvas.first + movedX >= 0 && canvas.last + movedX < view.count) {
+// canvas.first += movedX;
+// canvas.last += movedX;
+// }
+// canvas.requestPaint();
+// }
+// }
+// }
+
+// onPressed: {
+// canvas.mousePressedX = mouse.x;
+// canvas.mousePressedY = mouse.y;
+// }
+
+// onReleased : {
+// if (mouse.modifiers & Qt.ControlModifier) {
+// var sx = mouse.x - canvas.mouseX;
+// var sy = canvas.mouseY - mouse.y;
+
+// if (Math.abs(sx) < 50) sx = 0;
+// if (Math.abs(sy) < 50) sy = 0;
+
+// if (sx > 0)
+// canvas.scaleX *= sx/100 +1;
+// else
+// canvas.scaleX *= 1/(-sx/100 + 1);
+
+// if (sy > 0)
+// canvas.scaleY *= sy/100 +1;
+// else
+// canvas.scaleY *= 1/(-sy/100 + 1);
+
+// if (canvas.scaleX < 1)
+// canvas.scaleX = 1;
+
+// //console.log("scaleX:" + canvas.scaleX + ", scaleY:" + canvas.scaleY);
+
+// canvas.first = Math.round(view.currentIndex - view.currentIndex / canvas.scaleX);
+// canvas.last = Math.round(view.currentIndex + (view.count - view.currentIndex) / canvas.scaleX);
+
+// canvas.mouseX = 0;
+// canvas.mouseY = 0;
+// canvas.mousePressedX = 0;
+// canvas.mousePressedY = 0;
+// canvas.requestPaint();
+// }
+// }
+// }
+
+ function drawBackground(ctx) {
+ ctx.save();
+ ctx.fillStyle = "#272822"
+ ctx.fillRect(0, 0, canvas.width, canvas.height)
+ ctx.strokeStyle = "#423a2f"
+ ctx.beginPath();
+ for (var i = 0; i < 10; i++) {
+ ctx.moveTo(0, i * (canvas.height/10.0));
+ ctx.lineTo(canvas.width, i * (canvas.height/10.0));
+ }
+
+ for (i = 0; i < 12; i++) {
+ ctx.moveTo(i * (canvas.width/12.0), 0);
+ ctx.lineTo(i * (canvas.width/12.0), canvas.height);
+ }
+ ctx.stroke();
+
+ ctx.strokeStyle = "#5c7a37"
+ ctx.beginPath();
+ ctx.moveTo(8 * (canvas.width/12.0), 0);
+ ctx.lineTo(8 * (canvas.width/12.0), canvas.height);
+ ctx.stroke();
+
+ ctx.restore();
+ }
+
+ function drawPrice(ctx, from, to, color, price, points, highest)
+ {
+ ctx.save();
+ ctx.globalAlpha = 0.7;
+ ctx.strokeStyle = color;
+ ctx.lineWidth = 1;
+ ctx.beginPath();
+
+ var w = canvas.width/points.length;
+ var end = points.length;
+ for (var i = 0; i < end; i++) {
+ var x = points[i].x;
+ var y = points[i][price];
+ y = canvas.height * y/highest;
+ if (i == 0) {
+ ctx.moveTo(x+w/2, y);
+ } else {
+ ctx.lineTo(x+w/2, y);
+ }
+ }
+ ctx.stroke();
+ ctx.restore();
+ }
+
+ function drawKLine(ctx, from, to, points, highest)
+ {
+ ctx.save();
+ ctx.globalAlpha = 0.4;
+ ctx.lineWidth = 2;
+ var end = points.length;
+ for (var i = 0; i < end; i++) {
+ var x = points[i].x;
+ var open = canvas.height * points[i].open/highest - canvas.movedY;
+ var close = canvas.height * points[i].close/highest - canvas.movedY;
+ var high = canvas.height * points[i].high/highest - canvas.movedY;
+ var low = canvas.height * points[i].low/highest - canvas.movedY;
+
+ var top, bottom;
+ if (close <= open) {
+ ctx.fillStyle = Qt.rgba(1, 0, 0, 1);
+ ctx.strokeStyle = Qt.rgba(1, 0, 0, 1);
+ top = close;
+ bottom = open;
+ } else {
+ ctx.fillStyle = Qt.rgba(0, 1, 0, 1);
+ ctx.strokeStyle = Qt.rgba(0, 1, 0, 1);
+ top = open;
+ bottom = close;
+ }
+
+ var w1, w2;
+ w1 = canvas.width/points.length;
+ w2 = w1 > 10 ? w1/2 : w1;
+
+ ctx.fillRect(x + (w1 - w2)/2, top, w2, bottom - top);
+ ctx.beginPath();
+ ctx.moveTo(x+w1/2, high);
+ ctx.lineTo(x+w1/2, low);
+ ctx.stroke();
+ }
+ ctx.restore();
+ }
+
+ function drawVolume(ctx, from, to, color, price, points, highest)
+ {
+ ctx.save();
+ ctx.fillStyle = color;
+ ctx.globalAlpha = 0.6;
+ ctx.strokeStyle = Qt.rgba(0.8, 0.8, 0.8, 1);
+ ctx.lineWidth = 1;
+
+ var end = points.length;
+ for (var i = 0; i < end; i++) {
+ var x = points[i].x;
+ var y = points[i][price];
+ y = canvas.height * (1 - y/highest);
+ ctx.fillRect(x, y, canvas.width/points.length, canvas.height - y);
+ }
+ ctx.restore();
+ }
+
+ onPaint: {
+ var ctx = canvas.getContext("2d");
+
+ ctx.globalCompositeOperation = "source-over";
+ ctx.lineWidth = 1;
+
+ drawBackground(ctx);
+ if (!stockModel.ready)
+ return;
+
+ last = stockModel.indexOf(chart.endDate)
+ first = last - (chart.endDate.getTime() - chart.startDate.getTime())/86400000;
+ console.log("painting... first:" + first + ", last:" + last);
+
+ var highestPrice = stockModel.highestPrice;
+ var highestVolume = stockModel.highestVolume;
+ console.log("highest price:" + highestPrice + ", highest volume:" + highestVolume)
+ var points = [];
+ for (var i = 0; i <= last - first; i++) {
+ var price = stockModel.get(i + first);
+ points.push({
+ x: i*canvas.width/(last-first+1),
+ open: price.open,
+ close: price.close,
+ high:price.high,
+ low:price.low,
+ volume:price.volume
+ });
+ }
+ if (settings.drawHighPrice)
+ drawPrice(ctx, first, last, settings.highColor,"high", points, highestPrice);
+ if (settings.drawLowPrice)
+ drawPrice(ctx, first, last, settings.lowColor,"low", points, highestPrice);
+ if (settings.drawOpenPrice)
+ drawPrice(ctx, first, last,settings.openColor,"open", points, highestPrice);
+ if (settings.drawClosePrice)
+ drawPrice(ctx, first, last, settings.closeColor,"close", points, highestPrice);
+ if (settings.drawVolume)
+ drawVolume(ctx, first, last, settings.volumeColor,"volume", points, highestVolume);
+ if (settings.drawKLine)
+ drawKLine(ctx, first, last, points, highestPrice);
+ }
+}
+}
diff --git a/examples/quick/demos/stocqt/content/StockListModel.qml b/examples/quick/demos/stocqt/content/StockListModel.qml
new file mode 100644
index 0000000000..b1e0706a3a
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/StockListModel.qml
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+ListModel {
+ id:stocks
+ //Data from : http://en.wikipedia.org/wiki/NASDAQ-100
+
+ ListElement {name:"Activision Blizzard"; stockId:"ATVI"}
+ ListElement {name:"Adobe Systems Incorporated"; stockId:"ADBE"}
+ ListElement {name:"Akamai Technologies, Inc"; stockId:"AKAM"}
+ ListElement {name:"Alexion Pharmaceuticals"; stockId:"ALXN"}
+ ListElement {name:"Altera Corporation"; stockId:"ALTR"}
+ ListElement {name:"Amazon.com, Inc."; stockId:"AMZN"}
+ ListElement {name:"Amgen Inc."; stockId:"AMGN"}
+ ListElement {name:"Apollo Group, Inc."; stockId:"APOL"}
+ ListElement {name:"Apple Inc."; stockId:"AAPL"}
+ ListElement {name:"Applied Materials, Inc."; stockId:"AMAT"}
+ ListElement {name:"Autodesk, Inc."; stockId:"ADSK"}
+ ListElement {name:"Automatic Data Processing, Inc."; stockId:"ADP"}
+ ListElement {name:"Baidu.com, Inc."; stockId:"BIDU"}
+ ListElement {name:"Bed Bath & Beyond Inc."; stockId:"BBBY"}
+ ListElement {name:"Biogen Idec, Inc"; stockId:"BIIB"}
+ ListElement {name:"BMC Software, Inc."; stockId:"BMC"}
+ ListElement {name:"Broadcom Corporation"; stockId:"BRCM"}
+ ListElement {name:"C. H. Robinson Worldwide, Inc."; stockId:"CHRW"}
+ ListElement {name:"CA, Inc."; stockId:"CA"}
+ ListElement {name:"Celgene Corporation"; stockId:"CELG"}
+ ListElement {name:"Cephalon, Inc."; stockId:"CEPH"}
+ ListElement {name:"Cerner Corporation"; stockId:"CERN"}
+ ListElement {name:"Check Point Software Technologies Ltd."; stockId:"CHKP"}
+ ListElement {name:"Cisco Systems, Inc."; stockId:"CSCO"}
+ ListElement {name:"Citrix Systems, Inc."; stockId:"CTXS"}
+ ListElement {name:"Cognizant Technology Solutions Corporation"; stockId:"CTSH"}
+ ListElement {name:"Comcast Corporation"; stockId:"CMCSA"}
+ ListElement {name:"Costco Wholesale Corporation"; stockId:"COST"}
+ ListElement {name:"Ctrip.com International, Ltd."; stockId:"CTRP"}
+ ListElement {name:"Dell Inc."; stockId:"DELL"}
+ ListElement {name:"DENTSPLY International Inc."; stockId:"XRAY"}
+ ListElement {name:"DirecTV"; stockId:"DTV"}
+ ListElement {name:"Dollar Tree, Inc."; stockId:"DLTR"}
+ ListElement {name:"eBay Inc."; stockId:"EBAY"}
+ ListElement {name:"Electronic Arts Inc."; stockId:"ERTS"}
+ ListElement {name:"Expedia, Inc."; stockId:"EXPE"}
+ ListElement {name:"Expeditors International of Washington, Inc."; stockId:"EXPD"}
+ ListElement {name:"Express Scripts, Inc."; stockId:"ESRX"}
+ ListElement {name:"F5 Networks, Inc."; stockId:"FFIV"}
+ ListElement {name:"Fastenal Company"; stockId:"FAST"}
+ ListElement {name:"First Solar, Inc."; stockId:"FSLR"}
+ ListElement {name:"Fiserv, Inc."; stockId:"FISV"}
+ ListElement {name:"Flextronics International Ltd."; stockId:"FLEX"}
+ ListElement {name:"FLIR Systems, Inc."; stockId:"FLIR"}
+ ListElement {name:"Garmin Ltd."; stockId:"GRMN"}
+ ListElement {name:"Gilead Sciences, Inc."; stockId:"GILD"}
+ ListElement {name:"Google Inc."; stockId:"GOOG"}
+ ListElement {name:"Green Mountain Coffee Roasters, Inc."; stockId:"GMCR"}
+ ListElement {name:"Henry Schein, Inc."; stockId:"HSIC"}
+ ListElement {name:"Illumina, Inc."; stockId:"ILMN"}
+ ListElement {name:"Infosys Technologies"; stockId:"INFY"}
+ ListElement {name:"Intel Corporation"; stockId:"INTC"}
+ ListElement {name:"Intuit, Inc."; stockId:"INTU"}
+ ListElement {name:"Intuitive Surgical Inc."; stockId:"ISRG"}
+ ListElement {name:"Joy Global Inc."; stockId:"JOYG"}
+ ListElement {name:"KLA Tencor Corporation"; stockId:"KLAC"}
+ ListElement {name:"Lam Research Corporation"; stockId:"LRCX"}
+ ListElement {name:"Liberty Media Corporation, Interactive Series A"; stockId:"LINTA"}
+ ListElement {name:"Life Technologies Corporation"; stockId:"LIFE"}
+ ListElement {name:"Linear Technology Corporation"; stockId:"LLTC"}
+ ListElement {name:"Marvell Technology Group, Ltd."; stockId:"MRVL"}
+ ListElement {name:"Mattel, Inc."; stockId:"MAT"}
+ ListElement {name:"Maxim Integrated Products"; stockId:"MXIM"}
+ ListElement {name:"Microchip Technology Incorporated"; stockId:"MCHP"}
+ ListElement {name:"Micron Technology, Inc."; stockId:"MU"}
+ ListElement {name:"Microsoft Corporation"; stockId:"MSFT"}
+ ListElement {name:"Mylan, Inc."; stockId:"MYL"}
+ ListElement {name:"NetApp, Inc."; stockId:"NTAP"}
+ ListElement {name:"Netflix, Inc."; stockId:"NFLX"}
+ ListElement {name:"News Corporation, Ltd."; stockId:"NWSA"}
+ ListElement {name:"NII Holdings, Inc."; stockId:"NIHD"}
+ ListElement {name:"NVIDIA Corporation"; stockId:"NVDA"}
+ ListElement {name:"O'Reilly Automotive, Inc."; stockId:"ORLY"}
+ ListElement {name:"Oracle Corporation"; stockId:"ORCL"}
+ ListElement {name:"PACCAR Inc."; stockId:"PCAR"}
+ ListElement {name:"Paychex, Inc."; stockId:"PAYX"}
+ ListElement {name:"Priceline.com, Incorporated"; stockId:"PCLN"}
+ ListElement {name:"Qiagen N.V."; stockId:"QGEN"}
+ ListElement {name:"QUALCOMM Incorporated"; stockId:"QCOM"}
+ ListElement {name:"Research in Motion Limited"; stockId:"RIMM"}
+ ListElement {name:"Ross Stores Inc."; stockId:"ROST"}
+ ListElement {name:"SanDisk Corporation"; stockId:"SNDK"}
+ ListElement {name:"Seagate Technology Holdings"; stockId:"STX"}
+ ListElement {name:"Sears Holdings Corporation"; stockId:"SHLD"}
+ ListElement {name:"Sigma-Aldrich Corporation"; stockId:"SIAL"}
+ ListElement {name:"Staples Inc."; stockId:"SPLS"}
+ ListElement {name:"Starbucks Corporation"; stockId:"SBUX"}
+ ListElement {name:"Stericycle, Inc"; stockId:"SRCL"}
+ ListElement {name:"Symantec Corporation"; stockId:"SYMC"}
+ ListElement {name:"Teva Pharmaceutical Industries Ltd."; stockId:"TEVA"}
+ ListElement {name:"Urban Outfitters, Inc."; stockId:"URBN"}
+ ListElement {name:"VeriSign, Inc."; stockId:"VRSN"}
+ ListElement {name:"Vertex Pharmaceuticals"; stockId:"VRTX"}
+ ListElement {name:"Virgin Media, Inc."; stockId:"VMED"}
+ ListElement {name:"Vodafone Group, plc."; stockId:"VOD"}
+ ListElement {name:"Warner Chilcott, Ltd."; stockId:"WCRX"}
+ ListElement {name:"Whole Foods Market, Inc."; stockId:"WFM"}
+ ListElement {name:"Wynn Resorts Ltd."; stockId:"WYNN"}
+ ListElement {name:"Xilinx, Inc."; stockId:"XLNX"}
+ ListElement {name:"Yahoo! Inc."; stockId:"YHOO"}
+}
diff --git a/examples/quick/demos/stocqt/content/StockListView.qml b/examples/quick/demos/stocqt/content/StockListView.qml
new file mode 100644
index 0000000000..c241efb54c
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/StockListView.qml
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id:root
+ width:320
+ height:480
+ color:"#423A2F"
+
+ property string currentStockId:""
+ property string currentStockName:""
+
+ ListView {
+ id:view
+ anchors.fill:parent
+ keyNavigationWraps:true
+ focus:true
+ snapMode: ListView.SnapToItem
+ model:StockListModel{}
+
+ onCurrentIndexChanged: {
+ root.currentStockId = model.get(currentIndex).stockId
+ root.currentStockName = model.get(currentIndex).name
+ console.log("current stock:" + root.currentStockId + " - " + root.currentStockName)
+ }
+
+ delegate:Rectangle {
+ height:30
+ width:parent.width
+ color:"transparent"
+ MouseArea {
+ anchors.fill: parent
+ onClicked:view.currentIndex = index
+ }
+
+ Text {
+ anchors.verticalCenter : parent.top
+ anchors.verticalCenterOffset : 15
+ color:index == view.currentIndex ? "#ECC089" : "#A58963"
+ font.pointSize:12
+ font.bold:true
+ text:" " + stockId + " - " + name
+ }
+ }
+
+ highlight:Image {height:30; width:parent.width; source:"images/stock-selected.png"}
+ }
+} \ No newline at end of file
diff --git a/examples/quick/demos/stocqt/content/StockModel.qml b/examples/quick/demos/stocqt/content/StockModel.qml
new file mode 100644
index 0000000000..b5a78548e4
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/StockModel.qml
@@ -0,0 +1,160 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+ListModel {
+ id:model
+ property string stockId:""
+ property string stockName:""
+ property var startDate
+ property var endDate
+ property string stockDataCycle:"d"
+ property bool ready:false
+ property real stockPrice:0.0
+ property real stockPriceChanged:0.0
+ property real highestPrice:0
+ property real highestVolume:0
+
+ signal dataReady
+
+ function indexOf(date) {
+ var end = new Date(model.get(0).date)
+ var start = new Date(model.get(model.count - 1).date)
+ if (end <= date)
+ return model.count -1;
+
+ if (start >= date)
+ return 0;
+
+ for (var i = 0; i < model.count; i++) {
+ var d = new Date(model.get(i).date)
+ if ( d === date)
+ return i;
+ }
+ return -1;
+ }
+
+ function requestUrl() {
+ if (stockId === "")
+ return;
+
+ if (startDate === undefined)
+ startDate = new Date(1995, 3, 25) //default: 25 April 1995
+
+ if (endDate === undefined)
+ endDate = new Date(); //today
+
+ if (stockDataCycle !== "d" && stockDataCycle !== "w" && stockDataCycle !== "m")
+ stockDataCycle = "d";
+
+ /*
+ Fetch stock data from yahoo finance:
+ url: http://ichart.finance.yahoo.com/table.csv?s=NOK&a=5&b=11&c=2010&d=7&e=23&f=2010&g=d&ignore=.csv
+ s:stock name/id, a:start day, b:start month, c:start year default: 25 April 1995, oldest c= 1962
+ d:end day, e:end month, f:end year, default:today (data only available 3 days before today)
+ g:data cycle(d daily, w weekly, m monthly, v Dividend)
+ */
+ var request = "http://ichart.finance.yahoo.com/table.csv?";
+ request += "s=" + stockId;
+ request += "&a=" + startDate.getDate();
+ request += "&b=" + startDate.getMonth();
+ request += "&c=" + startDate.getFullYear();
+ request += "&d=" + endDate.getDate();
+ request += "&e=" + endDate.getMonth();
+ request += "&f=" + endDate.getFullYear();
+ request += "&g=" + stockDataCycle;
+ request += "&ignore=.csv";
+ return request;
+ }
+
+ function createStockPrice(r) {
+ if (highestPrice < r[2])
+ highestPrice = r[2];
+ if (highestVolume < r[5])
+ highestVolume = r[5];
+ return {
+ "date": r[0],
+ "open":r[1],
+ "high":r[2],
+ "low":r[3],
+ "close":r[4],
+ "volume":r[5],
+ "adjusted":r[6]
+ };
+ }
+
+ function updateStock() {
+ var xhr = new XMLHttpRequest;
+
+ var req = requestUrl();
+ console.log("getting " + req + " .....");
+
+ xhr.open("GET", req);
+
+
+ model.ready = false;
+ model.clear();
+ var i = 1; //skip the first line
+ xhr.onreadystatechange = function() {
+ if (xhr.readyState === XMLHttpRequest.LOADING || xhr.readyState === XMLHttpRequest.DONE) {
+ var records = xhr.responseText.split('\n');
+ console.log("Updating:" + (records.length - i) + " records for " + model.stockId + " from:" + model.startDate + " to " + model.endDate)
+
+ for (;i < records.length; i++ ) {
+ var r = records[i].split(',');
+ if (r.length === 7)
+ model.append(createStockPrice(r));
+ }
+
+ if (xhr.readyState === XMLHttpRequest.DONE) {
+ if (model.count > 0) {
+ console.log("done, total:" + model.count);
+ model.ready = true;
+ model.stockPrice = model.get(0).adjusted
+ model.stockPriceChanged = Math.round((model.stockPrice - model.get(2).adjusted) * 100) / 100
+ model.dataReady(); //emit signal
+ }
+ }
+ }
+ }
+ xhr.send()
+ }
+}
diff --git a/examples/quick/demos/stocqt/content/StockSettings.qml b/examples/quick/demos/stocqt/content/StockSettings.qml
new file mode 100644
index 0000000000..600747b969
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/StockSettings.qml
@@ -0,0 +1,317 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id:root
+ width:320
+ height:480
+ color:"#423A2F"
+ property var startDate : startDatePicker.date;
+ property var endDate : endDatePicker.date;
+
+ property bool drawHighPrice:highButton.buttonEnabled
+ property bool drawLowPrice:lowButton.buttonEnabled
+ property bool drawOpenPrice:openButton.buttonEnabled
+ property bool drawClosePrice:closeButton.buttonEnabled
+ property bool drawVolume:volumeButton.buttonEnabled
+ property bool drawKLine:klineButton.buttonEnabled
+
+ property color highColor:Qt.rgba(1, 0, 0, 1)
+ property color lowColor:Qt.rgba(0, 1, 0, 1)
+ property color openColor:Qt.rgba(0, 0, 1, 1)
+ property color closeColor:"#ecc088"
+ property color volumeColor:Qt.rgba(0.3, 0.5, 0.7, 1)
+
+ property string chartType:"year"
+ Image {
+ id:logo
+ source:"images/logo.png"
+ anchors.horizontalCenter : parent.horizontalCenter
+ anchors.top:parent.top
+ anchors.topMargin:15
+ }
+
+ Text {
+ id:startDateText
+ text:"START DATE:"
+ color:"#76644A"
+ font.pointSize:15
+ anchors.left:parent.left
+ anchors.leftMargin:20
+ anchors.top:logo.bottom
+ anchors.topMargin:20
+ }
+
+ DatePicker {
+ id:startDatePicker
+ anchors.left:parent.left
+ anchors.leftMargin:30
+ anchors.top:startDateText.bottom
+ anchors.topMargin:15
+ date : new Date(1995, 3, 25)
+ }
+
+ Text {
+ id:endDateText
+ text:"END DATE:"
+ color:"#76644A"
+ font.pointSize:15
+ anchors.left:parent.left
+ anchors.leftMargin:20
+ anchors.top:startDatePicker.bottom
+ anchors.topMargin:20
+ }
+
+ DatePicker {
+ id:endDatePicker
+ anchors.left:parent.left
+ anchors.leftMargin:30
+ anchors.top:endDateText.bottom
+ anchors.topMargin:15
+ }
+
+ Text {
+ id:drawOptionsText
+ text:"DRAW OPTIONS:"
+ color:"#76644A"
+ font.pointSize:15
+ anchors.left:parent.left
+ anchors.leftMargin:20
+ anchors.top:endDatePicker.bottom
+ anchors.topMargin:20
+ }
+ Column {
+ id:drawOptions
+ anchors.top:drawOptionsText.bottom
+ anchors.topMargin: 20
+ anchors.left: parent.left
+ anchors.leftMargin: 30
+ spacing:2
+ Row{
+ spacing:10
+ Text {
+ text:"High "
+ color:"#76644A"
+ font.pointSize:15
+ }
+
+ Button {
+ id:highButton
+ buttonEnabled:false
+ }
+
+ Text {
+ text:"Low "
+ color:"#76644A"
+ font.pointSize:15
+ }
+
+ Button {
+ id:lowButton
+ buttonEnabled:false
+ }
+
+ Text {
+ text:"Open "
+ color:"#76644A"
+ font.pointSize:15
+ }
+ Button {
+ id:openButton
+ buttonEnabled:false
+ }
+ }
+ Row{
+ spacing:10
+ Text {
+ text:"Close "
+ color:"#76644A"
+ font.pointSize:15
+ }
+ Button {
+ id:closeButton
+ buttonEnabled:true
+ }
+ Text {
+ text:"Volume"
+ color:"#76644A"
+ font.pointSize:15
+ }
+ Button {
+ id:volumeButton
+ buttonEnabled:true
+ }
+ Text {
+ text:"K Line"
+ color:"#76644A"
+ font.pointSize:15
+ }
+ Button {
+ id:klineButton
+ buttonEnabled:false
+ }
+ }
+ }
+
+
+ Text {
+ id:chartTypeText
+ text:"CHART TYPE:"
+ color:"#76644A"
+ font.pointSize:15
+ anchors.left:parent.left
+ anchors.leftMargin:20
+ anchors.top:drawOptions.bottom
+ anchors.topMargin:20
+ }
+ Row {
+ anchors.left: parent.left
+ anchors.leftMargin: 20
+ anchors.top : chartTypeText.bottom
+ anchors.topMargin: 20
+ spacing:10
+ Rectangle {
+ id:yearView
+ width:70
+ height:30
+ radius:10
+ color:"steelblue"
+ Text {
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.fill: parent
+ font.pointSize: 15
+ text:"YEAR"
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (root.chartType != "year") {
+ root.chartType = "year";
+ yearView.color = "steelblue"
+ monthView.color = "gray"
+ weekView.color = "gray"
+ allView.color = "gray"
+ }
+ }
+ }
+ }
+ Rectangle {
+ id:monthView
+ width:70
+ radius:10
+ height:30
+ color:"gray"
+ Text {
+ anchors.fill: parent
+ anchors.horizontalCenter: parent.horizontalCenter
+ font.pointSize: 15
+ color:"#ecc089"
+ text:"MONTH"
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (root.chartType != "month") {
+ root.chartType = "month";
+ yearView.color = "gray"
+ monthView.color = "steelblue"
+ weekView.color = "gray"
+ allView.color = "gray"
+ }
+ }
+ }
+
+ }
+ Rectangle {
+ id:weekView
+ height:30
+ width:70
+ radius:10
+ color:"gray"
+ Text {
+ anchors.fill: parent
+ anchors.horizontalCenter: parent.horizontalCenter
+ font.pointSize: 15
+ color:"#ecc089"
+ text:"WEEK"
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (root.chartType != "week") {
+ root.chartType = "week";
+ yearView.color = "gray"
+ monthView.color = "gray"
+ weekView.color = "steelblue"
+ allView.color = "gray"
+ }
+ }
+ }
+ }
+ Rectangle {
+ id:allView
+ width:70
+ radius:10
+ height:30
+ color:"gray"
+ Text {
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.fill: parent
+ font.pointSize: 15
+ color:"#ecc089"
+ text:"ALL"
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (root.chartType != "all") {
+ root.chartType = "all";
+ yearView.color = "gray"
+ monthView.color = "gray"
+ weekView.color = "gray"
+ allView.color = "steelblue"
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/quick/demos/stocqt/content/StockView.qml b/examples/quick/demos/stocqt/content/StockView.qml
new file mode 100644
index 0000000000..49e6c98622
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/StockView.qml
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+Rectangle {
+ id:root
+ width:320
+ height:480
+ color:"#423A2F"
+ property var stock:null
+ property var stocklist:null
+ property var settings:null
+ signal listViewClicked
+ signal settingsClicked
+
+ function update() {
+ chart.endDate = settings.endDate
+ chart.update()
+ }
+
+ Rectangle {
+ color:"#272822"
+ anchors.fill:parent
+ radius:20
+
+ Image {
+ source:"images/icon-items.png"
+ anchors.left:parent.left
+ anchors.leftMargin:10
+ anchors.top:parent.top
+ anchors.topMargin:10
+ MouseArea {
+ anchors.fill:parent
+ onClicked:listViewClicked()
+ }
+ }
+ Image {
+ source:"images/icon-settings.png"
+ anchors.right:parent.right
+ anchors.rightMargin:10
+ anchors.top:parent.top
+ anchors.topMargin:10
+ MouseArea {
+ anchors.fill:parent
+ onClicked:settingsClicked()
+ }
+ }
+
+ Text {
+ id:desc
+ anchors.left:parent.left
+ anchors.leftMargin:20
+ anchors.top:parent.top
+ anchors.topMargin:40
+ color:"#564c3A"
+ font.pointSize:15
+ text:root.stock.stockId + " - " + root.stock.stockName
+ }
+
+ Text {
+ id:price
+ anchors.left:parent.left
+ anchors.leftMargin:20
+ anchors.top:desc.bottom
+ anchors.topMargin:5
+ color:"#ECC089"
+ font.pointSize:30
+ text:root.stock.stockPrice
+ }
+
+ Text {
+ id:priceChange
+ anchors.left:parent.left
+ anchors.leftMargin:20
+ anchors.top:price.bottom
+ anchors.topMargin:5
+ color: root.stock.stockPriceChanged < 0 ? "#A43D3D" : "#679B3A"
+ font.pointSize:25
+ text: root.stock.stockPriceChanged + " (" + Math.abs(Math.round(root.stock.stockPriceChanged/(root.stock.stockPrice - root.stock.stockPriceChanged) * 100))/100 +"%)"
+ }
+
+ StockChart {
+ id:chart
+ anchors.bottom: parent.bottom
+ anchors.top : priceChange.bottom
+ anchors.topMargin: 30
+ width:parent.width
+ stockModel:root.stock
+ settings:root.settings
+ }
+ }
+}
diff --git a/examples/quick/demos/stocqt/content/images/icon-calendar-anim.png b/examples/quick/demos/stocqt/content/images/icon-calendar-anim.png
new file mode 100644
index 0000000000..c5164d5183
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/images/icon-calendar-anim.png
Binary files differ
diff --git a/examples/quick/demos/stocqt/content/images/icon-calendar.png b/examples/quick/demos/stocqt/content/images/icon-calendar.png
new file mode 100644
index 0000000000..bd2857470b
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/images/icon-calendar.png
Binary files differ
diff --git a/examples/quick/demos/stocqt/content/images/icon-items.png b/examples/quick/demos/stocqt/content/images/icon-items.png
new file mode 100644
index 0000000000..f951aa5009
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/images/icon-items.png
Binary files differ
diff --git a/examples/quick/demos/stocqt/content/images/icon-settings.png b/examples/quick/demos/stocqt/content/images/icon-settings.png
new file mode 100644
index 0000000000..222d998289
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/images/icon-settings.png
Binary files differ
diff --git a/examples/quick/demos/stocqt/content/images/logo.png b/examples/quick/demos/stocqt/content/images/logo.png
new file mode 100644
index 0000000000..90c7c3ba3d
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/images/logo.png
Binary files differ
diff --git a/examples/quick/demos/stocqt/content/images/stock-selected.png b/examples/quick/demos/stocqt/content/images/stock-selected.png
new file mode 100644
index 0000000000..5629796b9c
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/images/stock-selected.png
Binary files differ
diff --git a/examples/quick/demos/stocqt/content/images/wheel-touch.png b/examples/quick/demos/stocqt/content/images/wheel-touch.png
new file mode 100644
index 0000000000..11c8120ada
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/images/wheel-touch.png
Binary files differ
diff --git a/examples/quick/demos/stocqt/content/images/wheel.png b/examples/quick/demos/stocqt/content/images/wheel.png
new file mode 100644
index 0000000000..470a675b35
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/images/wheel.png
Binary files differ
diff --git a/examples/quick/demos/stocqt/main.cpp b/examples/quick/demos/stocqt/main.cpp
new file mode 100644
index 0000000000..779d204a24
--- /dev/null
+++ b/examples/quick/demos/stocqt/main.cpp
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "../../shared/shared.h"
+DECLARATIVE_EXAMPLE_MAIN(stocqt)
diff --git a/examples/quick/demos/stocqt/stocqt.pro b/examples/quick/demos/stocqt/stocqt.pro
new file mode 100644
index 0000000000..f33c4aee01
--- /dev/null
+++ b/examples/quick/demos/stocqt/stocqt.pro
@@ -0,0 +1,9 @@
+TEMPLATE = app
+
+QT += qml quick
+SOURCES += main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/stocqt
+qml.files = stocqt.qml content
+qml.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/stocqt
+INSTALLS += target qml
diff --git a/examples/quick/demos/stocqt/stocqt.qml b/examples/quick/demos/stocqt/stocqt.qml
new file mode 100644
index 0000000000..3f8a84a810
--- /dev/null
+++ b/examples/quick/demos/stocqt/stocqt.qml
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "./content"
+
+ListView {
+ id:root
+ width:320
+ height:480
+ snapMode:ListView.SnapOneItem
+ focus:false
+ orientation : ListView.Horizontal
+ boundsBehavior : Flickable.StopAtBounds
+ currentIndex : 1
+
+ StockModel {
+ id:stock
+ stockId:listView.currentStockId
+ stockName: listView.currentStockName
+ startDate: settings.startDate
+ endDate:settings.endDate
+ onStockIdChanged: updateStock()
+ onStartDateChanged: updateStock()
+ onEndDateChanged: updateStock()
+ onDataReady: {
+ root.currentIndex = 1
+ stockView.update()
+ }
+ }
+
+ model: VisualItemModel {
+ StockListView {
+ id:listView
+ width:root.width
+ height:root.height
+ }
+
+ StockView {
+ id:stockView
+ width:root.width
+ height:root.height
+ stocklist : listView
+ settings : settings
+ stock: stock
+
+ onListViewClicked:root.currentIndex = 0
+ onSettingsClicked:root.currentIndex = 2
+ }
+
+ StockSettings {
+ id:settings
+ width:root.width
+ height:root.height
+ onDrawHighPriceChanged: stockView.update()
+ onDrawLowPriceChanged: stockView.update()
+ onDrawOpenPriceChanged: stockView.update()
+ onDrawClosePriceChanged: stockView.update()
+ onDrawVolumeChanged: stockView.update()
+ onDrawKLineChanged: stockView.update()
+ onChartTypeChanged: stockView.update()
+ }
+ }
+}
diff --git a/examples/quick/demos/stocqt/stocqt.qmlproject b/examples/quick/demos/stocqt/stocqt.qmlproject
new file mode 100644
index 0000000000..11ab78418a
--- /dev/null
+++ b/examples/quick/demos/stocqt/stocqt.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "stocqt.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}