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

@ -2,7 +2,7 @@
/** /**
* *
* gPodder QML UI Reference Implementation * gPodder QML UI Reference Implementation
* Copyright (c) 2013, Thomas Perl <m@thp.io> * Copyright (c) 2013, 2014, Thomas Perl <m@thp.io>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
@ -20,6 +20,7 @@
import QtQuick 2.0 import QtQuick 2.0
import 'common'
import 'common/util.js' as Util import 'common/util.js' as Util
SlidePage { SlidePage {
@ -33,11 +34,7 @@ SlidePage {
width: parent.width width: parent.width
height: parent.height height: parent.height
Component.onCompleted: { Component.onCompleted: episodeListModel.loadEpisodes(podcast_id);
py.call('main.load_episodes', [podcast_id], function (episodes) {
Util.updateModelFrom(episodeListModel, episodes);
});
}
PullMenu { PullMenu {
PullMenuItem { PullMenuItem {
@ -60,7 +57,7 @@ SlidePage {
PListView { PListView {
id: episodeList id: episodeList
title: episodesPage.title title: episodesPage.title
model: ListModel { id: episodeListModel } model: GPodderEpisodeListModel { id: episodeListModel }
delegate: EpisodeItem { delegate: EpisodeItem {
onClicked: pgst.loadPage('EpisodeDetail.qml', {episode_id: id, title: title}); onClicked: pgst.loadPage('EpisodeDetail.qml', {episode_id: id, title: title});

View file

@ -20,50 +20,14 @@
import QtQuick 2.0 import QtQuick 2.0
import 'common'
import 'common/util.js' as Util import 'common/util.js' as Util
SlidePage { SlidePage {
id: podcastsPage id: podcastsPage
hasPull: true hasPull: true
function reload() { Component.onCompleted: podcastListModel.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);
}
PullMenu { PullMenu {
PullMenuItem { PullMenuItem {
@ -91,12 +55,6 @@ SlidePage {
} }
} }
PLabel {
id: loading
anchors.centerIn: parent
text: 'Loading'
}
PListView { PListView {
id: podcastList id: podcastList
title: 'Subscriptions' title: 'Subscriptions'
@ -104,11 +62,10 @@ SlidePage {
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});
} }
} }
} }