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 ListModel stockQuotesListModel
20 property string lastUpdatedTimeStamp
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()
82 target: stockQuotesComponent
84 stockQuotesView.currentIndex = 0;
96 anchors.bottom: toolBar.top
100 text: stockQuotesComponent.lastUpdatedTimeStamp
101 horizontalAlignment: Text.AlignRight; verticalAlignment: Text.AlignVCenter
102 width: parent.width; font.pixelSize: 12; elide: Text.ElideRight;
104 style: Text.Raised; styleColor: "black"
107 target: stockQuotesComponent
109 timeStamp.text = stockQuotesComponent.lastUpdatedTimeStamp;
117 width: parent.width; height: 40
118 anchors.bottom: parent.bottom
120 onReloadButtonClicked: reloadQuotes();
121 onDownButtonClicked: if (!stockQuotesView.moving && stockQuotesView.interactive) stockQuotesView.currentIndex = stockQuotesView.currentIndex + 1
122 onUpButtonClicked: if (!stockQuotesView.moving && stockQuotesView.interactive) stockQuotesView.currentIndex = stockQuotesView.currentIndex - 1
123 onNewsButtonClicked: Qt.openUrlExternally("http://finance.yahoo.com");
125 target: stockQuotesComponent
127 if (!toolBar.updatePending) toolBar.updatePending = true;
130 toolBar.updatePending = false;
131 console.log(stockQuotesComponent.lastUpdatedTimeStamp);