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 checkNetworkStatus
24 property int itemHeight: 50
25 property int titleBarHeight: 60
26 property int toolBarHeight: 40
27 property int componentWidth: screen.width
28 property int autoUpdateInterval: 300000
29 property bool updateWeekDaysOnly: false
30 property bool updateOnSavedNetworksOnly: false
31 property string rssURL: "http://finance.yahoo.com/rss/topstories"
32 property string lastUpdatedTimeStamp
33 property bool isDesktopWidget
34 property string selectedSymbol:""
36 function reloadData(){
37 CoreLib.reloadQuotes();
41 function initialize(){
45 Component.onCompleted: {
51 interval: autoUpdateInterval
52 //running: (autoUpdateInterval == 0? false:true)
55 if (!updateWeekDaysOnly){
56 logUtility.logMessage("Allowed to update all days of the week");
58 //checkNetworkStatus();
60 else if (Common.isTodayAWeekDay()){
61 logUtility.logMessage("Today is a weekday");
63 //checkNetworkStatus();
66 logUtility.logMessage("Update not triggered: Today is not a weekday");
72 id: stockQuoteDataModel
85 Component.onCompleted: {
86 console.log("Rectangle Height = "+background.height);
90 id: stockQuotesDelegate
93 id: wrapper; width: parent.width; height: itemHeight
96 Rectangle { color: "black"; opacity: index % 2 ? 0.2 : 0.4; height: wrapper.height - 2; width: wrapper.width; y: 1
102 anchors {right: parent.right; rightMargin: 10; verticalCenter: parent.verticalCenter}
104 source: "Library/images/information.png"
106 anchors.fill: parent;
108 //console.log("Image clicked");
109 showStockDetails(symbol);
117 informationIcon.visible = true;
118 //console.log("Rectangle clicked");
124 anchors {left: parent.left;leftMargin: 10;right: parent.right;rightMargin: 10}
125 //width: componentWidth;
126 height: parent.height
129 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" }
130 Text { text: lastTradedPrice; width: parent.width * 25/100; font.pixelSize: 18; verticalAlignment:Text.AlignVCenter; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
133 width: parent.width * 20/100; height: parent.height
135 Text { text: change; font.pixelSize: 16; elide: Text.ElideRight
136 color: if(change >= 0){"green";} else {"red";}
137 style: Text.Raised; styleColor: "black" }
138 Text { text: changePercentage; font.pixelSize: 16; elide: Text.ElideRight;
139 color: if(change >= 0){"green";} else {"red";}
140 style: Text.Raised; styleColor: "black" }
142 Text { text: volume; width: parent.width * 30/100; font.pixelSize: 18; verticalAlignment:Text.AlignVCenter; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
152 id: newsWrapper; width: componentWidth; height: itemHeight
155 Rectangle { color: "black"; opacity: index % 2 ? 0.2 : 0.4; height: newsWrapper.height - 2; width: newsWrapper.width; y: 1 }
157 anchors.verticalCenter: parent.verticalCenter
158 anchors.left: parent.left
159 anchors.leftMargin: 10
160 anchors.right: parent.right
161 text: title; font.pixelSize: 14
163 verticalAlignment: Text.AlignVCenter
164 horizontalAlignment: Text.AlignLeft
165 elide: Text.ElideRight;
172 onClicked: Qt.openUrlExternally(link);
180 width: parent.width; height: screen.titleBarHeight
181 anchors.top: parent.top
182 title: "Markets Today"
184 displayMenuIcon: false
187 uiLoader.sourceComponent = stockQuotesUIComponent;
188 titleBar.buttonType = "";
189 titleBar.displayMenu = false;
190 toolBar.displayIcons = true;
197 anchors.top: titleBar.bottom
198 anchors.bottom: toolBar.top
199 sourceComponent: stockQuotesUIComponent
204 width: parent.width; height: screen.toolBarHeight
205 anchors.bottom: parent.bottom
207 displayNavigation: true
208 onReloadButtonClicked: screen.reloadData();
209 onNewsButtonClicked: {
210 uiLoader.sourceComponent = newsComponent;
211 toolBar.displayIcons = true;
212 toolBar.targetContentType = "Stocks";
215 onStocksButtonClicked: {
216 uiLoader.sourceComponent = stockQuotesUIComponent;
217 toolBar.displayIcons = true;
218 toolBar.targetContentType = "News";
224 onQuoteRefreshStarted:{
225 if (!toolBar.updatePending) toolBar.updatePending = true;
227 onQuoteRefreshCompleted:{
228 toolBar.updatePending = false;
234 id: stockQuotesUIComponent
239 anchors.top: parent.top
240 anchors.bottom: footerText.top
246 flickDeceleration: 500
247 //preferredHighlightBegin: 1/stockQuotesView.count
248 //preferredHighlightEnd: 1/stockQuotesView.count
249 //pathItemCount: count
252 model: stockQuoteDataModel
253 delegate: stockQuotesDelegate
259 y: stockQuotesView.count * itemHeight + itemHeight/2
262 Keys.onDownPressed: if (!moving && interactive) incrementCurrentIndex()
263 Keys.onUpPressed: if (!moving && interactive) decrementCurrentIndex()
267 onQuoteRefreshCompleted:{
268 stockQuotesView.currentIndex = 0;
274 onDownButtonClicked: {
275 if (!stockQuotesView.moving && stockQuotesView.interactive)
276 stockQuotesView.currentIndex = stockQuotesView.currentIndex + 1
279 if (!stockQuotesView.moving && stockQuotesView.interactive)
280 stockQuotesView.currentIndex = stockQuotesView.currentIndex - 1
291 anchors.bottom: parent.bottom
295 text: screen.lastUpdatedTimeStamp
296 horizontalAlignment: Text.AlignRight; verticalAlignment: Text.AlignVCenter
297 width: parent.width; font.pixelSize: 12; elide: Text.ElideRight;
299 style: Text.Raised; styleColor: "black"
303 onQuoteRefreshCompleted:{
304 timeStamp.text = screen.lastUpdatedTimeStamp;
317 anchors.top: parent.top
318 anchors.bottom: parent.bottom
324 flickDeceleration: 500
328 delegate: newsDelegate
334 y: newsView.count * itemHeight + itemHeight/2
337 Keys.onDownPressed: if (!moving && interactive) incrementCurrentIndex()
338 Keys.onUpPressed: if (!moving && interactive) decrementCurrentIndex()
342 onQuoteRefreshCompleted:{
343 newsView.currentIndex = 0;
349 onDownButtonClicked: {
350 if (!newsView.moving && newsView.interactive)
351 newsView.currentIndex = newsView.currentIndex + 1
354 if (!newsView.moving && newsView.interactive)
355 newsView.currentIndex = newsView.currentIndex - 1