Episode list model: Store and restore episode list filter
This commit is contained in:
parent
65b692b16d
commit
deaa5e8268
6 changed files with 41 additions and 8 deletions
|
@ -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('../..'));
|
||||
|
||||
|
|
|
@ -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<filters.length; i++) {
|
||||
if (filters[i].query === query) {
|
||||
py.call('main.set_config_value', ['ui.qml.episode_list.filter_eql', query]);
|
||||
currentFilterIndex = i;
|
||||
return;
|
||||
}
|
||||
|
@ -64,6 +78,8 @@ ListModel {
|
|||
|
||||
currentFilterIndex = -1;
|
||||
currentCustomQuery = query;
|
||||
|
||||
py.call('main.set_config_value', ['ui.qml.episode_list.filter_eql', query]);
|
||||
}
|
||||
|
||||
function loadAllEpisodes(callback) {
|
||||
|
@ -119,5 +135,12 @@ ListModel {
|
|||
episodeListModel.reload();
|
||||
}
|
||||
}
|
||||
|
||||
onConfigChanged: {
|
||||
if (key === 'ui.qml.episode_list.filter_eql') {
|
||||
setQuery(value);
|
||||
reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue