3 @author: Sudheer K. <scifi1947 at gmail.com>
4 @license: GNU General Public License
9 import "Library" as Library
10 import "Library/js/ISODate.js" as DateLib
11 import "Library/js/DBUtility.js" as DBUtility
12 import "Library/js/Common.js" as Common
13 import "Library/js/CoreLogic.js" as CoreLib
18 signal showConfigInNewWindow
19 signal quoteRefreshStarted
20 signal quoteRefreshCompleted
21 signal checkNetworkStatus
23 property int itemHeight: 50
24 property int componentWidth: screen.width
25 property int autoUpdateInterval: 300000
26 property bool updateWeekDaysOnly: false
27 property bool updateOnSavedNetworksOnly: false
28 property string lastUpdatedTimeStamp
29 property bool isDesktopWidget
31 function reloadQuotes(){
32 CoreLib.reloadQuotes();
35 function initialize(){
39 Component.onCompleted: {
45 interval: autoUpdateInterval
46 //running: (autoUpdateInterval == 0? false:true)
49 if (!updateWeekDaysOnly){
50 logUtility.logMessage("Allowed to update all days of the week");
54 else if (Common.isTodayAWeekDay()){
55 logUtility.logMessage("Today is a weekday");
60 logUtility.logMessage("Update not triggered: Today is not a weekday");
66 id: stockQuoteDataModel
76 id: stockQuotesDelegate
79 id: wrapper; width: componentWidth; height: itemHeight
81 Rectangle { color: "black"; opacity: index % 2 ? 0.2 : 0.4; height: wrapper.height - 2; width: wrapper.width; y: 1 }
84 width: componentWidth - 40;
87 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" }
88 Text { text: lastTradedPrice; width: parent.width * 25/100; font.pixelSize: 18; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
89 Text { text: change; width: parent.width * 20/100; font.pixelSize: 18; elide: Text.ElideRight
90 color: if(change >= 0){"green";} else {"red";}
91 style: Text.Raised; styleColor: "black" }
92 Text { text: changePercentage; width: parent.width * 20/100; font.pixelSize: 18; elide: Text.ElideRight;
93 color: if(change >= 0){"green";} else {"red";}
94 style: Text.Raised; styleColor: "black" }
102 width: parent.width; height: 60;
103 anchors.top: parent.top
104 title: "Markets Today";
111 anchors.top: titleBar.bottom
112 anchors.bottom: footerText.top
118 flickDeceleration: 500
119 //preferredHighlightBegin: 1/stockQuotesView.count
120 //preferredHighlightEnd: 1/stockQuotesView.count
121 //pathItemCount: count
124 model: stockQuoteDataModel
125 delegate: stockQuotesDelegate
131 y: stockQuotesView.count * itemHeight + itemHeight/2
134 Keys.onDownPressed: if (!moving && interactive) incrementCurrentIndex()
135 Keys.onUpPressed: if (!moving && interactive) decrementCurrentIndex()
139 onQuoteRefreshCompleted:{
140 stockQuotesView.currentIndex = 0;
146 onDownButtonClicked: {
147 if (!stockQuotesView.moving && stockQuotesView.interactive)
148 stockQuotesView.currentIndex = stockQuotesView.currentIndex + 1
151 if (!stockQuotesView.moving && stockQuotesView.interactive)
152 stockQuotesView.currentIndex = stockQuotesView.currentIndex - 1
163 anchors.bottom: toolBar.top
167 text: screen.lastUpdatedTimeStamp
168 horizontalAlignment: Text.AlignRight; verticalAlignment: Text.AlignVCenter
169 width: parent.width; font.pixelSize: 12; elide: Text.ElideRight;
171 style: Text.Raised; styleColor: "black"
175 onQuoteRefreshCompleted:{
176 timeStamp.text = screen.lastUpdatedTimeStamp;
184 width: parent.width; height: 40
185 anchors.bottom: parent.bottom
187 displayNavigation: true
188 onReloadButtonClicked: screen.reloadQuotes();
189 onNewsButtonClicked: Qt.openUrlExternally("http://finance.yahoo.com");
192 onQuoteRefreshStarted:{
193 if (!toolBar.updatePending) toolBar.updatePending = true;
195 onQuoteRefreshCompleted:{
196 toolBar.updatePending = false;
197 console.log(screen.lastUpdatedTimeStamp);