Touch UI: Use common podcast and episode list model
This commit is contained in:
parent
300643918a
commit
f58460b505
2 changed files with 7 additions and 53 deletions
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
*
|
||||
* 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
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -20,6 +20,7 @@
|
|||
|
||||
import QtQuick 2.0
|
||||
|
||||
import 'common'
|
||||
import 'common/util.js' as Util
|
||||
|
||||
SlidePage {
|
||||
|
@ -33,11 +34,7 @@ SlidePage {
|
|||
width: parent.width
|
||||
height: parent.height
|
||||
|
||||
Component.onCompleted: {
|
||||
py.call('main.load_episodes', [podcast_id], function (episodes) {
|
||||
Util.updateModelFrom(episodeListModel, episodes);
|
||||
});
|
||||
}
|
||||
Component.onCompleted: episodeListModel.loadEpisodes(podcast_id);
|
||||
|
||||
PullMenu {
|
||||
PullMenuItem {
|
||||
|
@ -60,7 +57,7 @@ SlidePage {
|
|||
PListView {
|
||||
id: episodeList
|
||||
title: episodesPage.title
|
||||
model: ListModel { id: episodeListModel }
|
||||
model: GPodderEpisodeListModel { id: episodeListModel }
|
||||
|
||||
delegate: EpisodeItem {
|
||||
onClicked: pgst.loadPage('EpisodeDetail.qml', {episode_id: id, title: title});
|
||||
|
|
|
@ -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});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue