Refactor podcast list handling into GPodderPodcastListModel
This commit is contained in:
parent
c88b0f6046
commit
bc38f75985
2 changed files with 4 additions and 38 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit 9d5fa936439a335c037116eff90517e66da03c93
|
Subproject commit fa9586bbdb62f13c583dfc2f8da784d13a809144
|
|
@ -21,47 +21,13 @@
|
||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
import Sailfish.Silica 1.0
|
import Sailfish.Silica 1.0
|
||||||
|
|
||||||
|
import 'common'
|
||||||
import 'common/util.js' as Util
|
import 'common/util.js' as Util
|
||||||
|
|
||||||
Page {
|
Page {
|
||||||
id: podcastsPage
|
id: podcastsPage
|
||||||
|
|
||||||
function reload() {
|
Component.onCompleted: podcastListModel.reload();
|
||||||
py.call('main.load_podcasts', [], function (podcasts) {
|
|
||||||
Util.updateModelFrom(podcastListModel, podcasts);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
reload();
|
|
||||||
|
|
||||||
py.setHandler('podcast-list-changed', podcastsPage.reload);
|
|
||||||
|
|
||||||
py.setHandler('updating-podcast', function (podcast_id) {
|
|
||||||
for (var i=0; i<podcastListModel.count; i++) {
|
|
||||||
var podcast = podcastListModel.get(i);
|
|
||||||
if (podcast.id == podcast_id) {
|
|
||||||
podcastListModel.setProperty(i, 'updating', true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
py.setHandler('updated-podcast', function (podcast) {
|
|
||||||
for (var i=0; i<podcastListModel.count; i++) {
|
|
||||||
if (podcastListModel.get(i).id == podcast.id) {
|
|
||||||
podcastListModel.set(i, podcast);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Component.onDestruction: {
|
|
||||||
py.setHandler('podcast-list-changed', undefined);
|
|
||||||
py.setHandler('updating-podcast', undefined);
|
|
||||||
py.setHandler('updated-podcast', undefined);
|
|
||||||
}
|
|
||||||
|
|
||||||
SilicaListView {
|
SilicaListView {
|
||||||
id: podcastList
|
id: podcastList
|
||||||
|
@ -93,7 +59,7 @@ Page {
|
||||||
section.property: 'section'
|
section.property: 'section'
|
||||||
section.delegate: SectionHeader { text: section }
|
section.delegate: SectionHeader { text: section }
|
||||||
|
|
||||||
model: ListModel { id: podcastListModel }
|
model: GPodderPodcastListModel { id: podcastListModel }
|
||||||
|
|
||||||
delegate: PodcastItem {
|
delegate: PodcastItem {
|
||||||
onClicked: pgst.loadPage('EpisodesPage.qml', {'podcast_id': id, 'title': title});
|
onClicked: pgst.loadPage('EpisodesPage.qml', {'podcast_id': id, 'title': title});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue