3 @author: Sudheer K. <scifi1947 at gmail.com>
4 @license: GNU General Public License
8 import com.nokia.meego 1.0
10 import "Library" as Library
11 import "Library/js/ISODate.js" as DateLib
12 import "Library/js/DBUtility.js" as DBUtility
13 import "Library/js/Common.js" as Common
14 import "Library/js/CoreLogic.js" as CoreLib
22 property int autoUpdateInterval: 300000
23 property bool updateWeekDaysOnly: false
24 property bool updateOnSavedNetworksOnly: false
25 property string rssURL: "http://finance.yahoo.com/rss/topfinstories"
26 property string lastUpdatedTimeStamp
27 property bool isDesktopWidget
28 //property string selectedSymbol:"YHOO"
29 property string selectedSymbol:sharedContext.getStockSymbol()
31 signal showConfigInNewWindow
32 signal showStockDetails(string strSymbol)
33 signal quoteRefreshStarted
34 signal quoteRefreshCompleted(bool success, string strMessage)
35 signal newsReloadCompleted(bool success, string strMessage)
36 signal checkNetworkStatus
38 function initialize(){
39 mainPage.initializePage();
45 property int itemHeight: 50
46 property int titleBarHeight: 60
47 property int toolBarHeight: 40
48 property int componentWidth: mainPage.width
50 function reloadData(){
51 CoreLib.reloadQuotes();
55 function initializePage(){
56 var componentToDisplay = sharedContext.getComponentToDisplay();
57 if (componentToDisplay === "StockQuoteDetails"){
58 uiLoader.sourceComponent = stockDetailsComponent;
59 titleBar.buttonType = "Close";
60 titleBar.displayMenu = false;
61 toolBar.displayIcons = false;
64 DBUtility.initialize();
65 uiLoader.sourceComponent = stockQuotesUIComponent;
70 Component.onCompleted: {
76 interval: autoUpdateInterval
77 //running: (autoUpdateInterval == 0? false:true)
80 if (!updateWeekDaysOnly){
81 logUtility.logMessage("Allowed to update all days of the week");
82 mainPage.reloadData();
83 //checkNetworkStatus();
85 else if (Common.isTodayAWeekDay()){
86 logUtility.logMessage("Today is a weekday");
87 mainPage.reloadData();
88 //checkNetworkStatus();
91 logUtility.logMessage("Update not triggered: Today is not a weekday");
97 id: stockQuoteDataModel
106 anchors.fill: parent;
111 id: stockQuotesDelegateLandscape
114 id: wrapper; width: mainPage.componentWidth; height: mainPage.itemHeight
116 Rectangle { color: "black"; opacity: index % 2 ? 0.2 : 0.4; height: wrapper.height - 2; width: wrapper.width; y: 1
120 appWindow.selectedSymbol = symbol;
121 uiLoader.sourceComponent = stockDetailsComponent;
122 titleBar.buttonType = "Back";
123 titleBar.displayMenu = false;
124 toolBar.displayIcons = false;
131 width: mainPage.componentWidth - 60;
134 Text { text: stockName; width: parent.width * 30/100; font.pixelSize: 18; font.bold: true; elide: Text.ElideRight; color: "white"; style: Text.Raised; styleColor: "black" }
135 Text { text: lastTradedPrice; width: parent.width * 15/100; font.pixelSize: 18; horizontalAlignment: Text.AlignLeft; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
136 Text { text: change !== ""? (change + " ("+changePercentage+")"):""; width: parent.width * 25/100; font.pixelSize: 18; horizontalAlignment: Text.AlignLeft; elide: Text.ElideRight
137 color: if(change >= 0){"green";} else {"red";}
138 style: Text.Raised; styleColor: "black" }
139 Text { text: volume; width: parent.width * 15/100; font.pixelSize: 18; horizontalAlignment: Text.AlignLeft; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
140 Text { text: marketCap; width: parent.width * 15/100; font.pixelSize: 18; horizontalAlignment: Text.AlignLeft; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
147 id: stockQuotesDelegatePortrait
150 id: wrapperItem; width: mainPage.componentWidth; height: mainPage.itemHeight
152 Rectangle { color: "black"; opacity: index % 2 ? 0.2 : 0.4; height: wrapperItem.height - 2; width: wrapperItem.width; y: 1
156 appWindow.selectedSymbol = symbol;
157 uiLoader.sourceComponent = stockDetailsComponent;
158 titleBar.buttonType = "Back";
159 titleBar.displayMenu = false;
160 toolBar.displayIcons = false;
167 width: mainPage.componentWidth - 5;
170 Text { text: stockName; width: parent.width * 42/100; font.pixelSize: 18; font.bold: true; elide: Text.ElideRight; color: "white"; style: Text.Raised; styleColor: "black" }
171 Text { text: lastTradedPrice; width: parent.width * 20/100; font.pixelSize: 18; horizontalAlignment: Text.AlignLeft; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
174 width: parent.width * 18/100; height: parent.height
176 Text { text: change; font.pixelSize: 16; horizontalAlignment: Text.AlignLeft; elide: Text.ElideRight
177 color: if(change >= 0){"green";} else {"red";}
178 style: Text.Raised; styleColor: "black" }
179 Text { text: changePercentage; font.pixelSize: 16; horizontalAlignment: Text.AlignLeft; elide: Text.ElideRight;
180 color: if(change >= 0){"green";} else {"red";}
181 style: Text.Raised; styleColor: "black" }
183 Text { text: volume; width: parent.width * 20/100; font.pixelSize: 18; horizontalAlignment: Text.AlignLeft; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
193 id: newsWrapper; width: mainPage.componentWidth; height: mainPage.itemHeight
196 Rectangle { color: "black"; opacity: index % 2 ? 0.2 : 0.4; height: newsWrapper.height - 2; width: newsWrapper.width; y: 1 }
198 anchors.verticalCenter: parent.verticalCenter
199 anchors.left: parent.left
200 anchors.leftMargin: 10
201 anchors.right: parent.right
202 text: title; font.pixelSize: 18
204 verticalAlignment: Text.AlignVCenter
205 horizontalAlignment: Text.AlignLeft
206 elide: Text.ElideRight;
213 onClicked: Qt.openUrlExternally(link);
221 width: parent.width; height: mainPage.titleBarHeight;
222 anchors.top: parent.top
223 title: "Markets Today";
225 z: 5 //required to keep Titlebar and Menu buttons on top of everything else
227 onCloseClicked: Qt.quit()
230 uiLoader.sourceComponent = configTickersComponent;
231 titleBar.buttonType = "Back";
232 titleBar.displayMenu = false;
233 toolBar.displayIcons = false;
237 uiLoader.sourceComponent = configParamsComponent;
238 titleBar.buttonType = "Back";
239 titleBar.displayMenu = false;
240 toolBar.displayIcons = false;
244 uiLoader.sourceComponent = stockQuotesUIComponent;
245 titleBar.buttonType = "Close";
246 titleBar.displayMenu = false;
247 toolBar.displayIcons = true;
248 mainPage.initializePage();
255 anchors.top: titleBar.bottom
256 anchors.bottom: toolBar.top
261 width: parent.width; height: mainPage.toolBarHeight
262 anchors.bottom: parent.bottom
264 displayNavigation: false
265 onReloadButtonClicked: mainPage.reloadData();
267 onNewsButtonClicked: {
268 uiLoader.sourceComponent = newsComponent;
269 toolBar.displayIcons = true;
270 toolBar.targetContentType = "Stocks";
273 onStocksButtonClicked: {
274 uiLoader.sourceComponent = stockQuotesUIComponent;
275 toolBar.displayIcons = true;
276 toolBar.targetContentType = "News";
282 onQuoteRefreshStarted:{
283 if (!toolBar.updatePending) toolBar.updatePending = true;
285 onQuoteRefreshCompleted:{
286 toolBar.updatePending = false;
294 id: stockQuotesUIComponent
299 anchors.top: parent.top
300 anchors.bottom: footerText.top
306 flickDeceleration: 500
307 model: stockQuoteDataModel
308 delegate: listViewWrapper.height > listViewWrapper.width ? stockQuotesDelegatePortrait : stockQuotesDelegateLandscape
310 snapMode: ListView.SnapToItem
315 id: stockStatusMsgArea
318 anchors {left: parent.left; leftMargin: 15; right: parent.right; rightMargin: 15;
319 verticalCenter: parent.verticalCenter}
325 text: "Loading quotes.."
326 horizontalAlignment: Text.AlignHCenter; verticalAlignment: Text.AlignVCenter
327 width: parent.width; font.pixelSize: 16; elide: Text.ElideNone;
329 wrapMode: Text.WrapAtWordBoundaryOrAnywhere
330 style: Text.Raised; styleColor: "black"
334 onQuoteRefreshCompleted: {
336 stockStatusMsgArea.visible = false;
339 stockStatusText.text = strMessage;
340 stockStatusMsgArea.visible = true;
352 anchors.bottom: parent.bottom
356 text: lastUpdatedTimeStamp
357 horizontalAlignment: Text.AlignRight; verticalAlignment: Text.AlignVCenter
358 width: parent.width; font.pixelSize: 12; elide: Text.ElideRight;
360 style: Text.Raised; styleColor: "black"
364 onQuoteRefreshCompleted:{
365 timeStamp.text = lastUpdatedTimeStamp;
374 id: stockDetailsComponent
375 StockDetailsComponent {
377 symbol: selectedSymbol
378 onLogRequest: logUtility.logMessage(strMessage)
379 orientation: (appWindow.inPortrait)? "Portrait":"Landscape"; //Initial Orientation
383 when: !appWindow.inPortrait
385 target: detailsComponent
386 orientation: "Landscape"
391 when: appWindow.inPortrait
393 target: detailsComponent
394 orientation: "Portrait"
399 Component.onCompleted: {
400 if (appWindow.inPortrait){
401 logUtility.logMessage("Initial orientation is Portrait");
405 logUtility.logMessage("Initial orientation is Landscape");
417 anchors.top: parent.top
418 anchors.bottom: parent.bottom
424 flickDeceleration: 500
426 delegate: newsDelegate
428 snapMode: ListView.SnapToItem
433 id: newsStatusMsgArea
436 anchors {left: parent.left; leftMargin: 15; right: parent.right; rightMargin: 15;
437 verticalCenter: parent.verticalCenter}
443 text: "Loading news.."
444 horizontalAlignment: Text.AlignHCenter; verticalAlignment: Text.AlignVCenter
445 width: parent.width; font.pixelSize: 16; elide: Text.ElideNone;
447 wrapMode: Text.WrapAtWordBoundaryOrAnywhere
448 style: Text.Raised; styleColor: "black"
452 onNewsReloadCompleted: {
454 newsStatusMsgArea.visible = false;
455 newsViewArea.visible = true;
458 newsStatusText.text = strMessage;
459 newsViewArea.visible = false;
460 newsStatusMsgArea.visible = true;
471 id: configTickersComponent
473 ConfigTickersComponent{
474 itemHeight: mainPage.itemHeight
475 componentWidth: mainPage.componentWidth
476 onLogRequest: logUtility.logMessage(strMessage)
481 id: configParamsComponent
482 ConfigParametersComponent{
483 onLogRequest: logUtility.logMessage(strMessage)