diff options
author | Topi Reinio <topi.reinio@theqtcompany.com> | 2016-02-23 13:55:59 +0100 |
---|---|---|
committer | Topi Reiniƶ <topi.reinio@theqtcompany.com> | 2016-02-24 11:12:30 +0000 |
commit | 90e9b622f01465666f4ae3f88d1710a36bb2ed1f (patch) | |
tree | 924a7c09b5442a2954de8d6b494341af0db7c8dc /examples/quick/demos/stocqt/content/StockModel.qml | |
parent | d3f8a608e8e00915df38a2a43496127a93b5bcaf (diff) |
StocQt demo: Bugfixes and improvements
- Update the list of NASDAQ-100 companies
- Add code for handling invalid entries (stock IDs)
- Simplify top-level navigation logic. The app now
opens in list view with no stock pre-selected.
- Fix math for calculating change percentages
Change-Id: I6aaab45f5a391f9636123c0ddca73656fab79916
Task-number: QTBUG-50651
Reviewed-by: Mika Salmela <mika.salmela@theqtcompany.com>
Reviewed-by: Venugopal Shivashankar <venugopal.shivashankar@digia.com>
Diffstat (limited to 'examples/quick/demos/stocqt/content/StockModel.qml')
-rw-r--r-- | examples/quick/demos/stocqt/content/StockModel.qml | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/examples/quick/demos/stocqt/content/StockModel.qml b/examples/quick/demos/stocqt/content/StockModel.qml index c1484d318e..035d9454d0 100644 --- a/examples/quick/demos/stocqt/content/StockModel.qml +++ b/examples/quick/demos/stocqt/content/StockModel.qml @@ -52,6 +52,9 @@ ListModel { signal dataReady function indexOf(date) { + if (model.count == 0) + return -1; + var newest = new Date(model.get(0).date); var oldest = new Date(model.get(model.count - 1).date); if (newest <= date) @@ -148,8 +151,11 @@ ListModel { model.ready = true; model.stockPrice = model.get(0).adjusted; model.stockPriceChanged = model.count > 1 ? (Math.round((model.stockPrice - model.get(1).close) * 100) / 100) : 0; - model.dataReady(); //emit signal + } else { + model.stockPrice = 0; + model.stockPriceChanged = 0; } + model.dataReady(); // emit signal - model.ready indicates whether the data is valid } } } |