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:"YHOO"
35 property string selectedSymbol:sharedContext.getStockSymbol()
37 function reloadData(){
38 CoreLib.reloadQuotes();
42 function initialize(){
43 var componentToDisplay = sharedContext.getComponentToDisplay();
44 if (componentToDisplay === "StockQuoteDetails"){
45 uiLoader.sourceComponent = stockDetailsComponent;
46 titleBar.buttonType = "Close";
47 titleBar.displayMenu = false;
48 toolBar.displayIcons = false;
52 uiLoader.sourceComponent = stockQuotesUIComponent;
56 Component.onCompleted: {
62 interval: autoUpdateInterval
63 //running: (autoUpdateInterval == 0? false:true)
66 if (!updateWeekDaysOnly){
67 logUtility.logMessage("Allowed to update all days of the week");
69 //checkNetworkStatus();
71 else if (Common.isTodayAWeekDay()){
72 logUtility.logMessage("Today is a weekday");
74 //checkNetworkStatus();
77 logUtility.logMessage("Update not triggered: Today is not a weekday");
83 id: stockQuoteDataModel
97 id: stockQuotesDelegate
100 id: wrapper; width: componentWidth; height: itemHeight
102 Rectangle { color: "black"; opacity: index % 2 ? 0.2 : 0.4; height: wrapper.height - 2; width: wrapper.width; y: 1
108 anchors {right: parent.right; rightMargin: 10; verticalCenter: parent.verticalCenter}
110 source: "Library/images/information.png"
112 anchors.fill: parent;
114 //console.log("Image clicked");
115 screen.selectedSymbol = symbol;
116 uiLoader.sourceComponent = stockDetailsComponent;
117 titleBar.buttonType = "Back";
118 titleBar.displayMenu = false;
119 toolBar.displayIcons = false;
127 informationIcon.visible = true;
128 //console.log("Rectangle clicked");
135 width: componentWidth - 60;
138 Text { text: stockName; width: parent.width * 30/100; font.pixelSize: 18; font.bold: true; elide: Text.ElideRight; color: "white"; style: Text.Raised; styleColor: "black" }
139 Text { text: lastTradedPrice; width: parent.width * 15/100; font.pixelSize: 18; horizontalAlignment: Text.AlignLeft; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
140 Text { text: change !== ""? (change + " ("+changePercentage+")"):""; width: parent.width * 25/100; font.pixelSize: 18; horizontalAlignment: Text.AlignLeft; elide: Text.ElideRight
141 color: if(change >= 0){"green";} else {"red";}
142 style: Text.Raised; styleColor: "black" }
143 Text { text: volume; width: parent.width * 15/100; font.pixelSize: 18; horizontalAlignment: Text.AlignLeft; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
144 Text { text: marketCap; width: parent.width * 15/100; font.pixelSize: 18; horizontalAlignment: Text.AlignLeft; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
154 id: newsWrapper; width: componentWidth; height: itemHeight
157 Rectangle { color: "black"; opacity: index % 2 ? 0.2 : 0.4; height: newsWrapper.height - 2; width: newsWrapper.width; y: 1 }
159 anchors.verticalCenter: parent.verticalCenter
160 anchors.left: parent.left
161 anchors.leftMargin: 10
162 anchors.right: parent.right
163 text: title; font.pixelSize: 18
165 verticalAlignment: Text.AlignVCenter
166 horizontalAlignment: Text.AlignLeft
167 elide: Text.ElideRight;
174 onClicked: Qt.openUrlExternally(link);
182 width: parent.width; height: screen.titleBarHeight;
183 anchors.top: parent.top
184 title: "Markets Today";
186 z: 5 //required to keep Titlebar and Menu buttons on top of everything else
188 onCloseClicked: Qt.quit()
191 uiLoader.sourceComponent = configTickersComponent;
192 titleBar.buttonType = "Back";
193 titleBar.displayMenu = false;
194 toolBar.displayIcons = false;
198 uiLoader.sourceComponent = configParamsComponent;
199 titleBar.buttonType = "Back";
200 titleBar.displayMenu = false;
201 toolBar.displayIcons = false;
205 uiLoader.sourceComponent = stockQuotesUIComponent;
206 titleBar.buttonType = "Close";
207 titleBar.displayMenu = false;
208 toolBar.displayIcons = true;
216 anchors.top: titleBar.bottom
217 anchors.bottom: toolBar.top
222 width: parent.width; height: screen.toolBarHeight
223 anchors.bottom: parent.bottom
225 displayNavigation: false
226 onReloadButtonClicked: screen.reloadData();
228 onNewsButtonClicked: {
229 uiLoader.sourceComponent = newsComponent;
230 toolBar.displayIcons = true;
231 toolBar.targetContentType = "Stocks";
234 onStocksButtonClicked: {
235 uiLoader.sourceComponent = stockQuotesUIComponent;
236 toolBar.displayIcons = true;
237 toolBar.targetContentType = "News";
243 onQuoteRefreshStarted:{
244 if (!toolBar.updatePending) toolBar.updatePending = true;
246 onQuoteRefreshCompleted:{
247 toolBar.updatePending = false;
255 id: stockQuotesUIComponent
260 anchors.top: parent.top
261 anchors.bottom: footerText.top
267 flickDeceleration: 500
268 model: stockQuoteDataModel
269 delegate: stockQuotesDelegate
271 snapMode: ListView.SnapToItem
280 anchors.bottom: parent.bottom
284 text: screen.lastUpdatedTimeStamp
285 horizontalAlignment: Text.AlignRight; verticalAlignment: Text.AlignVCenter
286 width: parent.width; font.pixelSize: 12; elide: Text.ElideRight;
288 style: Text.Raised; styleColor: "black"
292 onQuoteRefreshCompleted:{
293 timeStamp.text = screen.lastUpdatedTimeStamp;
302 id: stockDetailsComponent
303 StockDetailsComponent {
304 symbol: selectedSymbol
305 onLogRequest: logUtility.logMessage(strMessage)
314 anchors.top: parent.top
315 anchors.bottom: parent.bottom
321 flickDeceleration: 500
323 delegate: newsDelegate
325 snapMode: ListView.SnapToItem
332 id: configTickersComponent
334 ConfigTickersComponent{
335 itemHeight: screen.itemHeight
336 componentWidth: screen.componentWidth
337 onLogRequest: logUtility.logMessage(strMessage)
342 id: configParamsComponent
343 ConfigParametersComponent{
344 onLogRequest: logUtility.logMessage(strMessage)