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" }
103 width: parent.width; height: 60;
104 anchors.top: parent.top
105 title: "Markets Today";
109 console.log("Closing..");
110 console.log(stockQuoteDataModel.count);
115 uiLoader.sourceComponent = configTickersComponent;
116 titleBar.buttonType = "Back";
117 titleBar.displayMenu = false;
118 toolBar.displayIcons = false;
122 uiLoader.sourceComponent = configParamsComponent;
123 titleBar.buttonType = "Back";
124 titleBar.displayMenu = false;
125 toolBar.displayIcons = false;
129 uiLoader.sourceComponent = stockQuotesUIComponent;
130 titleBar.buttonType = "Close";
131 titleBar.displayMenu = false;
132 toolBar.displayIcons = true;
139 anchors.top: titleBar.bottom
140 anchors.bottom: toolBar.top
141 sourceComponent: stockQuotesUIComponent
146 width: parent.width; height: 40
147 anchors.bottom: parent.bottom
149 displayNavigation: false
150 onReloadButtonClicked: screen.reloadQuotes();
151 onNewsButtonClicked: Qt.openUrlExternally("http://finance.yahoo.com");
155 onQuoteRefreshStarted:{
156 if (!toolBar.updatePending) toolBar.updatePending = true;
158 onQuoteRefreshCompleted:{
159 toolBar.updatePending = false;
160 console.log(screen.lastUpdatedTimeStamp);
168 id: stockQuotesUIComponent
173 anchors.top: parent.top
174 anchors.bottom: footerText.top
180 flickDeceleration: 500
181 model: stockQuoteDataModel
182 delegate: stockQuotesDelegate
192 anchors.bottom: parent.bottom
196 text: screen.lastUpdatedTimeStamp
197 horizontalAlignment: Text.AlignRight; verticalAlignment: Text.AlignVCenter
198 width: parent.width; font.pixelSize: 12; elide: Text.ElideRight;
200 style: Text.Raised; styleColor: "black"
204 onQuoteRefreshCompleted:{
205 timeStamp.text = screen.lastUpdatedTimeStamp;
214 id: configTickersComponent
216 ConfigTickersComponent{
217 itemHeight: screen.itemHeight
218 componentWidth: screen.componentWidth
219 onLogRequest: logUtility.logMessage(strMessage)
224 id: configParamsComponent
225 ConfigParametersComponent{
226 onLogRequest: logUtility.logMessage(strMessage)