Cleanup episode events, mark episodes as old, fresh episodes fix
This commit is contained in:
parent
8eebb09707
commit
0ff355737c
11 changed files with 126 additions and 93 deletions
|
@ -28,16 +28,13 @@ Python {
|
|||
property string progname: 'gpodder'
|
||||
property bool ready: false
|
||||
property bool refreshing: false
|
||||
signal downloading(int episode_id)
|
||||
signal downloadProgress(int episode_id, real progress)
|
||||
signal playbackProgress(int episode_id, real progress)
|
||||
signal downloaded(int episode_id)
|
||||
signal deleted(int episode_id)
|
||||
signal isNewChanged(int episode_id, bool is_new)
|
||||
signal stateChanged(int episode_id, int state)
|
||||
signal podcastListChanged()
|
||||
signal updatingPodcast(int podcast_id)
|
||||
signal updatedPodcast(var podcast)
|
||||
signal episodeListChanged(int podcast_id)
|
||||
signal updatedEpisode(var episode)
|
||||
|
||||
Component.onCompleted: {
|
||||
setHandler('hello', function (coreversion, uiversion) {
|
||||
|
@ -47,17 +44,14 @@ Python {
|
|||
console.log('Python ' + py.pythonVersion());
|
||||
});
|
||||
|
||||
setHandler('downloading', py.downloading);
|
||||
setHandler('download-progress', py.downloadProgress);
|
||||
setHandler('playback-progress', py.playbackProgress);
|
||||
setHandler('downloaded', py.downloaded);
|
||||
setHandler('deleted', py.deleted);
|
||||
setHandler('is-new-changed', py.isNewChanged);
|
||||
setHandler('state-changed', py.stateChanged);
|
||||
setHandler('podcast-list-changed', py.podcastListChanged);
|
||||
setHandler('updating-podcast', py.updatingPodcast);
|
||||
setHandler('updated-podcast', py.updatedPodcast);
|
||||
setHandler('refreshing', function(v) { py.refreshing = v; });
|
||||
setHandler('episode-list-changed', py.episodeListChanged);
|
||||
setHandler('updated-episode', py.updatedEpisode);
|
||||
|
||||
addImportPath(Qt.resolvedUrl('../..'));
|
||||
|
||||
|
|
|
@ -26,7 +26,22 @@ import 'constants.js' as Constants
|
|||
ListModel {
|
||||
id: episodeListModel
|
||||
|
||||
property var podcast_id
|
||||
|
||||
function loadEpisodes(podcast_id) {
|
||||
episodeListModel.podcast_id = podcast_id;
|
||||
reload();
|
||||
}
|
||||
|
||||
function loadFreshEpisodes(callback) {
|
||||
episodeListModel.podcast_id = -1;
|
||||
py.call('main.get_fresh_episodes', [], function (episodes) {
|
||||
Util.updateModelFrom(episodeListModel, episodes);
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
function reload() {
|
||||
py.call('main.load_episodes', [podcast_id], function (episodes) {
|
||||
Util.updateModelFrom(episodeListModel, episodes);
|
||||
});
|
||||
|
@ -43,21 +58,18 @@ ListModel {
|
|||
Util.updateModelWith(episodeListModel, 'id', episode_id,
|
||||
{'playbackProgress': progress});
|
||||
}
|
||||
onDownloaded: {
|
||||
Util.updateModelWith(episodeListModel, 'id', episode_id,
|
||||
{'progress': 0, 'downloadState': Constants.state.downloaded});
|
||||
onUpdatedEpisode: {
|
||||
for (var i=0; i<episodeListModel.count; i++) {
|
||||
if (episodeListModel.get(i).id == episode.id) {
|
||||
episodeListModel.set(i, episode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
onDeleted: {
|
||||
Util.updateModelWith(episodeListModel, 'id', episode_id,
|
||||
{'downloadState': Constants.state.deleted, 'isNew': false});
|
||||
}
|
||||
onIsNewChanged: {
|
||||
Util.updateModelWith(episodeListModel, 'id', episode_id,
|
||||
{'isNew': is_new});
|
||||
}
|
||||
onStateChanged: {
|
||||
Util.updateModelWith(episodeListModel, 'id', episode_id,
|
||||
{'downloadState': state});
|
||||
onEpisodeListChanged: {
|
||||
if (episodeListModel.podcast_id == podcast_id) {
|
||||
episodeListModel.reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue