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 showStockDetails(string strSymbol)
20 signal quoteRefreshStarted
21 signal quoteRefreshCompleted
22 signal quoteRefreshFailed(string strMessage)
23 signal checkNetworkStatus
25 property int itemHeight: 50
26 property int titleBarHeight: 60
27 property int toolBarHeight: 40
28 property int componentWidth: screen.width
29 property int autoUpdateInterval: 300000
30 property bool updateWeekDaysOnly: false
31 property bool updateOnSavedNetworksOnly: false
32 property string rssURL: "http://finance.yahoo.com/rss/topstories"
33 property string lastUpdatedTimeStamp
34 property bool isDesktopWidget
35 property string selectedSymbol:""
37 function reloadData(){
38 CoreLib.reloadQuotes();
42 function initialize(){
46 Component.onCompleted: {
52 interval: autoUpdateInterval
53 //running: (autoUpdateInterval == 0? false:true)
56 if (!updateWeekDaysOnly){
57 logUtility.logMessage("Allowed to update all days of the week");
59 //checkNetworkStatus();
61 else if (Common.isTodayAWeekDay()){
62 logUtility.logMessage("Today is a weekday");
64 //checkNetworkStatus();
67 logUtility.logMessage("Update not triggered: Today is not a weekday");
73 id: stockQuoteDataModel
86 Component.onCompleted: {
87 console.log("Rectangle Height = "+background.height);
91 id: stockQuotesDelegate
94 id: wrapper; width: parent.width; height: itemHeight
97 Rectangle { color: "black"; opacity: index % 2 ? 0.2 : 0.4; height: wrapper.height - 2; width: wrapper.width; y: 1
103 anchors {right: parent.right; rightMargin: 10; verticalCenter: parent.verticalCenter}
105 source: "Library/images/information.png"
107 anchors.fill: parent;
109 //console.log("Image clicked");
110 showStockDetails(symbol);
118 informationIcon.visible = true;
119 //console.log("Rectangle clicked");
125 anchors {left: parent.left;leftMargin: 10;right: parent.right;rightMargin: 10}
126 //width: componentWidth;
127 height: parent.height
130 Text { text: symbol; width: parent.width * 25/100; font.pixelSize: 18; font.bold: true; verticalAlignment:Text.AlignVCenter; elide: Text.ElideRight; color: "white"; style: Text.Raised; styleColor: "black" }
131 Text { text: lastTradedPrice; width: parent.width * 25/100; font.pixelSize: 18; verticalAlignment:Text.AlignVCenter; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
134 width: parent.width * 20/100; height: parent.height
136 Text { text: change; font.pixelSize: 16; elide: Text.ElideRight
137 color: if(change >= 0){"green";} else {"red";}
138 style: Text.Raised; styleColor: "black" }
139 Text { text: changePercentage; font.pixelSize: 16; elide: Text.ElideRight;
140 color: if(change >= 0){"green";} else {"red";}
141 style: Text.Raised; styleColor: "black" }
143 Text { text: volume; width: parent.width * 30/100; font.pixelSize: 18; verticalAlignment:Text.AlignVCenter; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
153 id: newsWrapper; width: componentWidth; height: itemHeight
156 Rectangle { color: "black"; opacity: index % 2 ? 0.2 : 0.4; height: newsWrapper.height - 2; width: newsWrapper.width; y: 1 }
158 anchors.verticalCenter: parent.verticalCenter
159 anchors.left: parent.left
160 anchors.leftMargin: 10
161 anchors.right: parent.right
162 text: title; font.pixelSize: 14
164 verticalAlignment: Text.AlignVCenter
165 horizontalAlignment: Text.AlignLeft
166 elide: Text.ElideRight;
173 onClicked: Qt.openUrlExternally(link);
181 width: parent.width; height: screen.titleBarHeight
182 anchors.top: parent.top
183 title: "Markets Today"
185 displayMenuIcon: false
188 uiLoader.sourceComponent = stockQuotesUIComponent;
189 titleBar.buttonType = "";
190 titleBar.displayMenu = false;
191 toolBar.displayIcons = true;
198 anchors.top: titleBar.bottom
199 anchors.bottom: toolBar.top
200 sourceComponent: stockQuotesUIComponent
205 width: parent.width; height: screen.toolBarHeight
206 anchors.bottom: parent.bottom
208 displayNavigation: true
209 onReloadButtonClicked: screen.reloadData();
210 onNewsButtonClicked: {
211 uiLoader.sourceComponent = newsComponent;
212 toolBar.displayIcons = true;
213 toolBar.targetContentType = "Stocks";
216 onStocksButtonClicked: {
217 uiLoader.sourceComponent = stockQuotesUIComponent;
218 toolBar.displayIcons = true;
219 toolBar.targetContentType = "News";
225 onQuoteRefreshStarted:{
226 if (!toolBar.updatePending) toolBar.updatePending = true;
228 onQuoteRefreshCompleted:{
229 toolBar.updatePending = false;
235 id: stockQuotesUIComponent
240 anchors.top: parent.top
241 anchors.bottom: footerText.top
247 flickDeceleration: 500
248 //preferredHighlightBegin: 1/stockQuotesView.count
249 //preferredHighlightEnd: 1/stockQuotesView.count
250 //pathItemCount: count
253 model: stockQuoteDataModel
254 delegate: stockQuotesDelegate
260 y: stockQuotesView.count * itemHeight + itemHeight/2
263 Keys.onDownPressed: if (!moving && interactive) incrementCurrentIndex()
264 Keys.onUpPressed: if (!moving && interactive) decrementCurrentIndex()
268 onQuoteRefreshCompleted:{
269 stockQuotesView.currentIndex = 0;
275 onDownButtonClicked: {
276 if (!stockQuotesView.moving && stockQuotesView.interactive)
277 stockQuotesView.currentIndex = stockQuotesView.currentIndex + 1
280 if (!stockQuotesView.moving && stockQuotesView.interactive)
281 stockQuotesView.currentIndex = stockQuotesView.currentIndex - 1
292 anchors.bottom: parent.bottom
296 text: screen.lastUpdatedTimeStamp
297 horizontalAlignment: Text.AlignRight; verticalAlignment: Text.AlignVCenter
298 width: parent.width; font.pixelSize: 12; elide: Text.ElideRight;
300 style: Text.Raised; styleColor: "black"
304 onQuoteRefreshCompleted:{
305 timeStamp.text = screen.lastUpdatedTimeStamp;
318 anchors.top: parent.top
319 anchors.bottom: parent.bottom
325 flickDeceleration: 500
329 delegate: newsDelegate
335 y: newsView.count * itemHeight + itemHeight/2
338 Keys.onDownPressed: if (!moving && interactive) incrementCurrentIndex()
339 Keys.onUpPressed: if (!moving && interactive) decrementCurrentIndex()
343 onQuoteRefreshCompleted:{
344 newsView.currentIndex = 0;
350 onDownButtonClicked: {
351 if (!newsView.moving && newsView.interactive)
352 newsView.currentIndex = newsView.currentIndex + 1
355 if (!newsView.moving && newsView.interactive)
356 newsView.currentIndex = newsView.currentIndex - 1