Clean up the StockQt demo
authorJens Bache-Wiig <jens.bache-wiig@digia.com>
Thu, 13 Dec 2012 18:16:13 +0000 (19:16 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Thu, 13 Dec 2012 19:43:59 +0000 (20:43 +0100)
I cleaned up the whitespace, property declarations and removed
some console output. No changes to the functionality or design.

Change-Id: I499f6d061e43bf2e187eebc026858b3abd21a9b0
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Reviewed-by: Alan Alpert <aalpert@rim.com>

examples/quick/demos/stocqt/content/Button.qml
examples/quick/demos/stocqt/content/CheckBox.qml
examples/quick/demos/stocqt/content/DatePicker.qml
examples/quick/demos/stocqt/content/StockChart.qml
examples/quick/demos/stocqt/content/StockListModel.qml
examples/quick/demos/stocqt/content/StockListView.qml
examples/quick/demos/stocqt/content/StockModel.qml
examples/quick/demos/stocqt/content/StockSettings.qml
examples/quick/demos/stocqt/content/StockView.qml
examples/quick/demos/stocqt/stocqt.qml

index 2cdd187..0051d81 100644 (file)
 import QtQuick 2.0
 
 Rectangle {
-  id:button
-  signal clicked
-  property alias text: txt.text
-  property bool buttonEnabled:false
-  radius:5
-  width: Math.max(64,txt.width+16);
-  height: 32
-  color: buttonEnabled ? "steelblue" : "gray"
-  MouseArea {
-    anchors.fill:parent
-    onClicked: button.clicked();
-  }
-  Text {
-    anchors.centerIn: parent
-    font.pixelSize: 18
-    color:"#ecc089"
-    id: txt
-  }
+    id: button
+    signal clicked
+    property alias text: txt.text
+    property bool buttonEnabled: false
+    radius: 5
+    width: Math.max(64, txt.width + 16)
+    height: 32
+    color: buttonEnabled ? "steelblue" : "gray"
+    MouseArea {
+        anchors.fill: parent
+        onClicked: button.clicked()
+    }
+    Text {
+        anchors.centerIn: parent
+        font.pixelSize: 18
+        color: "#ecc089"
+        id: txt
+    }
 }
index fb09390..1f21cc2 100644 (file)
 import QtQuick 2.0
 
 Row {
-  id:button
-  property alias text: txt.text
-  property bool buttonEnabled:true
-  width: txt.width + 30
-  height:25
-  spacing: 5
-  x: 5
-  Text {
-    id: txt
-    text:"Close "
-    color:"#76644A"
-    font.pixelSize:18
-  }
-  Rectangle {
-    width: 25
+    id: button
+    property alias text: txt.text
+    property bool buttonEnabled: true
+    width: txt.width + 30
     height: 25
-    radius:5
-    color:buttonEnabled ? "steelblue" : "gray"
-    MouseArea {
-        anchors.fill:parent
-        onClicked: {
-          if (buttonEnabled)
-           buttonEnabled = false;
-          else
-           buttonEnabled = true;
+    spacing: 5
+    x: 5
+    Text {
+        id: txt
+        text: "Close "
+        color: "#76644A"
+        font.pixelSize: 18
+    }
+    Rectangle {
+        width: 25
+        height: 25
+        radius: 5
+        color: buttonEnabled ? "steelblue" : "gray"
+        MouseArea {
+            anchors.fill: parent
+            onClicked: {
+                if (buttonEnabled)
+                    buttonEnabled = false;
+                else
+                    buttonEnabled = true;
+            }
         }
     }
-  }
 }
index 82d8788..d045d12 100644 (file)
 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()
+    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
+    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
+        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;
+            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
+        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;}
-      }
-    }
+            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
+        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;}
-      }
+            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;}
+            }
+        }
     }
-  }
 }
index c741167..97f6b47 100644 (file)
 ****************************************************************************/
 
 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
+    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
@@ -54,271 +56,204 @@ Rectangle {
         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())
+            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)
+            chart.startDate = new Date(chart.endDate.getFullYear() , chart.endDate.getMonth(), chart.endDate.getDate() - 7);
         else
-             chart.startDate = new Date(1995, 3, 25)
+            chart.startDate = new Date(1995, 3, 25);
 
         canvas.requestPaint();
     }
 
-
     Text {
-        id:fromDate
-        color:"#6a5b44"
-        width:50
+        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()
+        anchors.top: parent.top
+        text: _months[startDate.getMonth()] + "\n" + startDate.getFullYear()
     }
 
     Text {
-        id:toDate
-        color:"#6a5b44"
+        id: toDate
+        color: "#6a5b44"
         font.pointSize: 10
-        width:50
+        width: 50
         wrapMode: Text.WordWrap
         anchors.right: parent.right
         anchors.leftMargin: 20
-        anchors.top:parent.top
-        text:_months[endDate.getMonth()] + "\n" + endDate.getFullYear()
+        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);
+        id: canvas
+        width: parent.width
+        anchors.top: toDate.bottom
+        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
+
+        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));
+            }
 
-//                canvas.mouseX = 0;
-//                canvas.mouseY = 0;
-//                canvas.mousePressedX = 0;
-//                canvas.mousePressedY = 0;
-//                canvas.requestPaint();
-//            }
-//        }
-//    }
+            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();
 
-    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));
-        }
+            ctx.strokeStyle = "#5c7a37";
+            ctx.beginPath();
+            ctx.moveTo(8 * (canvas.width/12.0), 0);
+            ctx.lineTo(8 * (canvas.width/12.0), canvas.height);
+            ctx.stroke();
 
-        for (i = 0; i < 12; i++) {
-            ctx.moveTo(i * (canvas.width/12.0), 0);
-            ctx.lineTo(i * (canvas.width/12.0), canvas.height);
+            ctx.restore();
         }
-        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();
+        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);
+            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();
         }
-        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;
+        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();
             }
-
-            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();
         }
-        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);
+        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();
         }
-        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
-                        });
+        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);
         }
-        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);
     }
 }
-}
index b1e0706..86a28f3 100644 (file)
 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"}
+    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"}
 }
index c241efb..f4ac6cb 100644 (file)
 import QtQuick 2.0
 
 Rectangle {
-  id:root
-  width:320
-  height:480
-  color:"#423A2F"
+    id: root
+    width: 320
+    height: 480
+    color: "#423A2F"
 
-  property string currentStockId:""
-  property string currentStockName:""
+    property string currentStockId: ""
+    property string currentStockName: ""
 
-  ListView {
-    id:view
-    anchors.fill:parent
-    keyNavigationWraps:true
-    focus:true
-    snapMode: ListView.SnapToItem
-    model:StockListModel{}
+    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)
-    }
+        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
-       }
+        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
+            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
+        highlight: Image {
+            height:30
+            width:parent.width
+            source:"images/stock-selected.png"
+        }
+    }
+}
index b5a7854..e9d6757 100644 (file)
 import QtQuick 2.0
 
 ListModel {
-    id:model
-    property string stockId:""
-    property string stockName:""
+    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
+    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)
+        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;
 
@@ -65,7 +65,7 @@ ListModel {
             return 0;
 
         for (var i = 0; i < model.count; i++) {
-            var d = new Date(model.get(i).date)
+            var d = new Date(model.get(i).date);
             if ( d === date)
                 return i;
         }
@@ -77,7 +77,7 @@ ListModel {
             return;
 
         if (startDate === undefined)
-            startDate = new Date(1995, 3, 25) //default: 25 April 1995
+            startDate = new Date(1995, 3, 25); //default: 25 April 1995
 
         if (endDate === undefined)
             endDate = new Date(); //today
@@ -125,18 +125,15 @@ ListModel {
        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(',');
@@ -146,10 +143,9 @@ ListModel {
 
                 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.stockPrice = model.get(0).adjusted;
+                        model.stockPriceChanged = Math.round((model.stockPrice - model.get(2).adjusted) * 100) / 100;
                         model.dataReady(); //emit signal
                     }
                 }
index 3bb4de8..ec7c20e 100644 (file)
 import QtQuick 2.0
 
 Rectangle {
-  id:root
-  width:320
-  height:480
-  color:"#423A2F"
-  property var startDate : startDatePicker.date;
-  property var endDate : endDatePicker.date;
+    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 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 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 volumeColor: Qt.rgba(0.3, 0.5, 0.7, 1)
+    property color closeColor: "#ecc088"
 
-  property string chartType:"year"
-  Image {
-    id:logo
-    source:"images/logo.png"
-    anchors.horizontalCenter : parent.horizontalCenter
-    anchors.top:parent.top
-    anchors.topMargin:15
-  }
+    property string chartType: "year"
 
-  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
-  }
+    Image {
+        id: logo
+        source: "images/logo.png"
+        anchors.horizontalCenter : parent.horizontalCenter
+        anchors.top: parent.top
+        anchors.topMargin: 15
+    }
 
-  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: startDateText
+        text: "START DATE:"
+        color: "#76644A"
+        font.pointSize: 15
+        anchors.left: parent.left
+        anchors.leftMargin: 20
+        anchors.top: logo.bottom
+        anchors.topMargin: 20
+    }
 
-  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: startDatePicker
+        anchors.left: parent.left
+        anchors.leftMargin: 30
+        anchors.top: startDateText.bottom
+        anchors.topMargin: 15
+        date: new Date(1995, 3, 25)
+    }
 
-  DatePicker {
-    id:endDatePicker
-    anchors.left:parent.left
-    anchors.leftMargin:30
-    anchors.top:endDateText.bottom
-    anchors.topMargin:15
-  }
+    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
+    }
 
-  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
-           CheckBox {
-             id:highButton
-             text:"High   "
-             buttonEnabled:false
-           }
+    DatePicker {
+        id: endDatePicker
+        anchors.left: parent.left
+        anchors.leftMargin: 30
+        anchors.top: endDateText.bottom
+        anchors.topMargin: 15
+    }
 
-           CheckBox {
-             id:lowButton
-             text:"Low     "
-             buttonEnabled:false
-           }
-           CheckBox {
-             text:"Open "
-             id:openButton
-             buttonEnabled:false
-           }
-      }
-       Row{
-           spacing:10
-           CheckBox {
-             text:"Close "
-             id:closeButton
-             buttonEnabled:true
-           }
-           CheckBox {
-             id:volumeButton
-             text:"Volume"
-             buttonEnabled:true
-           }
-           CheckBox {
-             id:klineButton
-             text:"K Line"
-             buttonEnabled:false
-          }
-      }
-  }
+    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 {
-    id:chartTypeText
-    text:"SHOW PREVIOUS:"
-    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
-      Button {
-        id: yearView
-        text: "YEAR"
-        buttonEnabled: root.chartType == "year"
-        onClicked: root.chartType = "year"
-      }
-      Button {
-        id: monthView
-        text: "MONTH"
-        buttonEnabled: root.chartType == "month"
-        onClicked: root.chartType = "month"
-      }
-      Button {
-        id: weekView
-        text: "WEEK"
-        buttonEnabled: root.chartType == "week"
-        onClicked: root.chartType = "week"
-      }
-      Button {
-        id: allView
-        text: "ALL"
-        buttonEnabled: root.chartType == "all"
-        onClicked: root.chartType = "all"
-      }
-  }
+            CheckBox {
+                id: highButton
+                text: "High   "
+                buttonEnabled: false
+            }
+            CheckBox {
+                id: lowButton
+                text: "Low     "
+                buttonEnabled: false
+            }
+            CheckBox {
+                id: openButton
+                text: "Open "
+                buttonEnabled: false
+            }
+        }
+        Row {
+            spacing: 10
+            CheckBox {
+                text: "Close "
+                id: closeButton
+                buttonEnabled: true
+            }
+            CheckBox {
+                id: volumeButton
+                text: "Volume"
+                buttonEnabled: true
+            }
+            CheckBox {
+                id: klineButton
+                text: "K Line"
+                buttonEnabled: false
+            }
+        }
+    }
+
+    Text {
+        id: chartTypeText
+        text: "SHOW PREVIOUS:"
+        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
+        Button {
+            id: yearView
+            text: "YEAR"
+            buttonEnabled: root.chartType == "year"
+            onClicked: root.chartType = "year"
+        }
+        Button {
+            id: monthView
+            text: "MONTH"
+            buttonEnabled: root.chartType == "month"
+            onClicked: root.chartType = "month"
+        }
+        Button {
+            id: weekView
+            text: "WEEK"
+            buttonEnabled: root.chartType == "week"
+            onClicked: root.chartType = "week"
+        }
+        Button {
+            id: allView
+            text: "ALL"
+            buttonEnabled: root.chartType == "all"
+            onClicked: root.chartType = "all"
+        }
+    }
 }
index 49e6c98..308ecc0 100644 (file)
 ****************************************************************************/
 
 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 {
+    id: root
+    width: 320
+    height: 480
+    color: "#423A2F"
 
-  Rectangle {
-    color:"#272822"
-    anchors.fill:parent
-    radius:20
+    property var stock: null
+    property var stocklist: null
+    property var settings: null
+    signal listViewClicked
+    signal settingsClicked
 
-    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()
-      }
+    function update() {
+        chart.endDate = settings.endDate
+        chart.update()
     }
 
-    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
-    }
+    Rectangle {
+        color: "#272822"
+        anchors.fill: parent
+        radius: 20
 
-    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
-    }
+        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: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  +"%)"
-    }
+        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
+        StockChart {
+            id: chart
+            anchors.bottom: parent.bottom
+            anchors.top : priceChange.bottom
+            anchors.topMargin: 30
+            width: parent.width
+            stockModel: root.stock
+            settings: root.settings
+        }
     }
-  }
 }
index 3f8a84a..13c15d5 100644 (file)
@@ -42,60 +42,60 @@ 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
+    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()
+    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
-    }
+    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
+        StockView {
+            id: stockView
+            width: root.width
+            height: root.height
+            stocklist: listView
+            settings: settings
+            stock: stock
 
-      onListViewClicked:root.currentIndex = 0
-      onSettingsClicked:root.currentIndex = 2
-    }
+            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()
+        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()
+        }
     }
-  }
 }