diff --git a/common/GPodderCore.qml b/common/GPodderCore.qml index 3ddb328..0711013 100644 --- a/common/GPodderCore.qml +++ b/common/GPodderCore.qml @@ -40,6 +40,7 @@ Python { signal episodeListChanged(int podcast_id) signal updatedEpisode(var episode) signal updateStats() + signal configChanged(string key, var value) Component.onCompleted: { setHandler('hello', function (coreversion, uiversion) { @@ -61,6 +62,7 @@ Python { setHandler('episode-list-changed', py.episodeListChanged); setHandler('updated-episode', py.updatedEpisode); setHandler('update-stats', py.updateStats); + setHandler('config-changed', py.configChanged); addImportPath(Qt.resolvedUrl('../..')); diff --git a/common/GPodderEpisodeListModel.qml b/common/GPodderEpisodeListModel.qml index 2deaa1e..d7685e9 100644 --- a/common/GPodderEpisodeListModel.qml +++ b/common/GPodderEpisodeListModel.qml @@ -54,9 +54,23 @@ ListModel { property int currentFilterIndex: -1 property string currentCustomQuery: queries.All + Component.onCompleted: { + // Request filter, then load episodes + py.call('main.get_config_value', ['ui.qml.episode_list.filter_eql'], function (result) { + setQuery(result); + reload(); + }); + } + + function setQueryIndex(index) { + currentFilterIndex = index; + py.call('main.set_config_value', ['ui.qml.episode_list.filter_eql', filters[currentFilterIndex].query]); + } + function setQuery(query) { for (var i=0; i %s', name, old_value, new_value) + pyotherside.send('config-changed', name, new_value) + def _get_episode_by_id(self, episode_id): for podcast in self.core.model.get_podcasts(): for episode in podcast.episodes: @@ -361,6 +367,12 @@ class gPotherSide: if episode.total_time > 0: yield '%02d:%02d:%02d' % (episode.total_time / (60 * 60), (episode.total_time / 60) % 60, episode.total_time % 60) + def set_config_value(self, option, value): + self.core.config.update_field(option, value) + + def get_config_value(self, option): + return self.core.config.get_field(option) + gpotherside = gPotherSide() pyotherside.atexit(gpotherside.atexit) @@ -385,3 +397,5 @@ change_section = gpotherside.change_section report_playback_event = gpotherside.report_playback_event mark_episodes_as_old = gpotherside.mark_episodes_as_old save_playback_state = gpotherside.save_playback_state +set_config_value = gpotherside.set_config_value +get_config_value = gpotherside.get_config_value diff --git a/touch/EpisodeQueryControl.qml b/touch/EpisodeQueryControl.qml index 6392d7a..c9ece0e 100644 --- a/touch/EpisodeQueryControl.qml +++ b/touch/EpisodeQueryControl.qml @@ -31,7 +31,7 @@ Item { pgst.loadPage('SelectionDialog.qml', { title: episodeQueryControl.title, callback: function (index, result) { - episodeQueryControl.model.currentFilterIndex = index; + episodeQueryControl.model.setQueryIndex(index); episodeQueryControl.model.reload(); }, items: function () { diff --git a/touch/EpisodeQueryPage.qml b/touch/EpisodeQueryPage.qml index 70ae4b8..b3b9ac8 100644 --- a/touch/EpisodeQueryPage.qml +++ b/touch/EpisodeQueryPage.qml @@ -39,11 +39,6 @@ SlidePage { title: 'Select filter' } - Component.onCompleted: { - episodeList.model.setQuery(episodeList.model.queries.Fresh); - episodeList.model.reload(); - } - EpisodeListView { id: episodeList title: 'Episodes' diff --git a/touch/EpisodesPage.qml b/touch/EpisodesPage.qml index b2b7dac..72aaf13 100644 --- a/touch/EpisodesPage.qml +++ b/touch/EpisodesPage.qml @@ -63,8 +63,7 @@ SlidePage { Component.onCompleted: { episodeList.model.podcast_id = podcast_id; - episodeList.model.setQuery(episodeList.model.queries.All); - episodeList.model.reload(); + // List model will be loaded automatically on load } EpisodeQueryControl {