Use QML WorkerScript for loading and updating models
This commit is contained in:
parent
376b3225f6
commit
d8fd1ff3dd
6 changed files with 126 additions and 33 deletions
|
@ -18,31 +18,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
function updateModelFrom(model, data) {
|
||||
for (var i=0; i<data.length; i++) {
|
||||
if (model.count < i) {
|
||||
model.append(data[i]);
|
||||
} else {
|
||||
model.set(i, data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
while (model.count > data.length) {
|
||||
model.remove(model.count-1);
|
||||
}
|
||||
}
|
||||
|
||||
function updateModelWith(model, key, value, update) {
|
||||
for (var row=0; row<model.count; row++) {
|
||||
var current = model.get(row);
|
||||
if (current[key] == value) {
|
||||
for (var key in update) {
|
||||
model.setProperty(row, key, update[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function formatDuration(duration) {
|
||||
if (duration !== 0 && !duration) {
|
||||
return ''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue