aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/demos/stocqt/content/StockModel.qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/quick/demos/stocqt/content/StockModel.qml')
-rw-r--r--examples/quick/demos/stocqt/content/StockModel.qml11
1 files changed, 7 insertions, 4 deletions
diff --git a/examples/quick/demos/stocqt/content/StockModel.qml b/examples/quick/demos/stocqt/content/StockModel.qml
index d127afc5c5..f9ed9c87d4 100644
--- a/examples/quick/demos/stocqt/content/StockModel.qml
+++ b/examples/quick/demos/stocqt/content/StockModel.qml
@@ -122,11 +122,14 @@ ListModel {
}
function updateStock() {
- var xhr = new XMLHttpRequest;
-
var req = requestUrl();
- xhr.open("GET", req);
+ if (!req)
+ return;
+
+ var xhr = new XMLHttpRequest;
+
+ xhr.open("GET", req, true);
model.ready = false;
model.clear();
@@ -145,7 +148,7 @@ ListModel {
if (model.count > 0) {
model.ready = true;
model.stockPrice = model.get(0).adjusted;
- model.stockPriceChanged = Math.round((model.stockPrice - model.get(2).adjusted) * 100) / 100;
+ model.stockPriceChanged = model.count > 1 ? (Math.round((model.stockPrice - model.get(1).close) * 100) / 100) : 0;
model.dataReady(); //emit signal
}
}