Use QML WorkerScript for loading and updating models

This commit is contained in:
Thomas Perl 2015-01-18 14:22:05 +01:00
parent 376b3225f6
commit d8fd1ff3dd
6 changed files with 126 additions and 33 deletions

View file

@ -62,6 +62,10 @@ ListModel {
});
}
property var worker: ModelWorkerScript {
id: modelWorker
}
function forEachEpisode(callback) {
// Go from bottom up (= chronological order)
for (var i=count-1; i>=0; i--) {
@ -122,11 +126,12 @@ ListModel {
ready = false;
py.call('main.load_episodes', [podcast_id, query], function (episodes) {
Util.updateModelFrom(episodeListModel, episodes);
episodeListModel.ready = true;
if (callback !== undefined) {
callback();
}
modelWorker.updateModelFrom(episodeListModel, episodes, function () {
episodeListModel.ready = true;
if (callback !== undefined) {
callback();
}
});
});
}
}