3 @author: Sudheer K. <scifi1947 at gmail.com>
4 @license: GNU General Public License
8 import "Library" as Library
9 import "Library/js/ISODate.js" as DateLib
12 id: stockQuotesComponent
17 signal updateCompleted
19 property XmlListModel stockQuotesListModel
20 property XmlListModel lastUpdatedModel
21 property int componentWidth
22 property int componentHeight
23 property int itemHeight: 50
26 id: stockQuotesDelegate
29 id: wrapper; width: componentWidth; height: itemHeight
31 Rectangle { color: "black"; opacity: index % 2 ? 0.2 : 0.4; height: wrapper.height - 2; width: wrapper.width; y: 1 }
34 width: componentWidth - 40;
37 Text { text: if (width >= 250) {stockName;} else {symbol;} width: parent.width * 35/100; font.pixelSize: 18; font.bold: true; elide: Text.ElideRight; color: "white"; style: Text.Raised; styleColor: "black" }
38 Text { text: lastTradedPrice; width: parent.width * 25/100; font.pixelSize: 18; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
39 Text { text: change; width: parent.width * 20/100; font.pixelSize: 18; elide: Text.ElideRight
40 color: if(change >= 0){"green";} else {"red";}
41 style: Text.Raised; styleColor: "black" }
42 Text { text: changePercentage; width: parent.width * 20/100; font.pixelSize: 18; elide: Text.ElideRight;
43 color: if(change >= 0){"green";} else {"red";}
44 style: Text.Raised; styleColor: "black" }
53 anchors.top: parent.top
54 anchors.bottom: footerText.top
59 flickDeceleration: 500
60 //preferredHighlightBegin: 1/stockQuotesView.count
61 //preferredHighlightEnd: 1/stockQuotesView.count
62 //pathItemCount: count
65 model: stockQuotesListModel
66 delegate: stockQuotesDelegate
72 y: stockQuotesView.count * itemHeight + itemHeight/2
75 Keys.onDownPressed: if (!moving && interactive) {
76 console.log(stockQuotesView.height);
77 incrementCurrentIndex();
79 Keys.onUpPressed: if (!moving && interactive) decrementCurrentIndex()
88 anchors.bottom: toolBar.top
91 model: lastUpdatedModel
94 text: "Updated: "+DateLib.ISODate.format(timestamp)
95 horizontalAlignment: Text.AlignRight; verticalAlignment: Text.AlignVCenter
96 width: parent.width; font.pixelSize: 12; elide: Text.ElideRight;
98 style: Text.Raised; styleColor: "black"
105 width: parent.width; height: 40
106 anchors.bottom: parent.bottom
108 onReloadButtonClicked: reloadQuotes();
109 onDownButtonClicked: if (!stockQuotesView.moving && stockQuotesView.interactive) stockQuotesView.currentIndex = stockQuotesView.currentIndex + 1
110 onUpButtonClicked: if (!stockQuotesView.moving && stockQuotesView.interactive) stockQuotesView.currentIndex = stockQuotesView.currentIndex - 1
111 onNewsButtonClicked: Qt.openUrlExternally("http://finance.yahoo.com");
113 target: stockQuotesComponent
115 if (!toolBar.updatePending) toolBar.updatePending = true;
118 toolBar.updatePending = false;