aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/demos/stocqt/content/StockModel.qml
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@digia.com>2013-10-08 14:35:55 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-04 11:45:57 +0100
commitb0dd9f3b314106bd3cd811ce02ff2cae5ee1eb50 (patch)
treecb9531623843944d4052a779355be3109066bbc4 /examples/quick/demos/stocqt/content/StockModel.qml
parenta79e400150e9d550cc4ddc0c0497778d8b78fe5d (diff)
Doc: Fix warnings in StocQt Qt Quick demo
Fix a number of warnings from QML engine by adding some boundary & sanity checks for properties. Also address UI update issues by having XMLHTTPRequest calls to trigger by a timer, instead of directly binding them to multiple change notifier signals. Task-number: QTBUG-33867 Change-Id: I48f573050b5dc3e3fe6e75bc423fe86ecc4a2469 Reviewed-by: Geir Vattekar <geir.vattekar@digia.com> Reviewed-by: Alan Alpert <aalpert@blackberry.com>
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
}
}