Touch UI: Use common podcast and episode list model

This commit is contained in:
Thomas Perl 2014-02-02 16:18:40 +01:00
parent 300643918a
commit f58460b505
2 changed files with 7 additions and 53 deletions

View file

@ -20,50 +20,14 @@
import QtQuick 2.0
import 'common'
import 'common/util.js' as Util
SlidePage {
id: podcastsPage
hasPull: true
function reload() {
loading.visible = true;
py.call('main.load_podcasts', [], function (podcasts) {
Util.updateModelFrom(podcastListModel, podcasts);
loading.visible = false;
});
}
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);
}
Component.onCompleted: podcastListModel.reload();
PullMenu {
PullMenuItem {
@ -91,12 +55,6 @@ SlidePage {
}
}
PLabel {
id: loading
anchors.centerIn: parent
text: 'Loading'
}
PListView {
id: podcastList
title: 'Subscriptions'
@ -104,11 +62,10 @@ SlidePage {
section.property: 'section'
section.delegate: SectionHeader { text: section }
model: ListModel { id: podcastListModel }
model: GPodderPodcastListModel { id: podcastListModel }
delegate: PodcastItem {
onClicked: pgst.loadPage('EpisodesPage.qml', {'podcast_id': id, 'title': title});
}
}
}