Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance improvements #140

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
[submodule "gpodder-core"]
path = gpodder-core
url = git://github.com/gpodder/gpodder-core.git
[submodule "gpodder-ui-qml"]
path = gpodder-ui-qml
url = git://github.com/gpodder/gpodder-ui-qml.git
[submodule "podcastparser"]
path = podcastparser
url = git://github.com/gpodder/podcastparser.git
Expand Down
1 change: 0 additions & 1 deletion gpodder-ui-qml
Submodule gpodder-ui-qml deleted from ed036a
45 changes: 45 additions & 0 deletions gpodder-ui-qml/common/GPodderAutoFire.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

/**
*
* gPodder QML UI Reference Implementation
* Copyright (c) 2015, Thomas Perl <[email protected]>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
*/

import QtQuick 2.0

Timer {
property int triggerCount: 0
property int initialInterval: 1500
property int autoFireInterval: 200

signal fired()

interval: triggerCount > 1 ? autoFireInterval : initialInterval

repeat: true
triggeredOnStart: true

onRunningChanged: {
if (!running) {
triggerCount = 0
}
}

onTriggered: {
triggerCount += 1
fired()
}
}
99 changes: 99 additions & 0 deletions gpodder-ui-qml/common/GPodderCore.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@

/**
*
* gPodder QML UI Reference Implementation
* Copyright (c) 2013, 2014, Thomas Perl <[email protected]>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
*/

import QtQuick 2.0
import io.thp.pyotherside 1.3


Python {
id: py

property string progname: 'gpodder'
property bool ready: false
property bool refreshing: false

property string coreversion
property string uiversion
property string parserversion

signal downloadProgress(int episode_id, real progress)
signal playbackProgress(int episode_id, real progress)
signal podcastListChanged()
signal updatingPodcast(int podcast_id)
signal updatedPodcast(var podcast)
signal episodeListChanged(int podcast_id)
signal updatedEpisode(var episode)
signal updateStats()
signal configChanged(string key, var value)
signal initialized()

Component.onCompleted: {
setHandler('hello', function (coreversion, uiversion, parserversion) {
py.coreversion = coreversion;
py.uiversion = uiversion;
py.parserversion = parserversion;

console.log('gPodder Core ' + py.coreversion);
console.log('gPodder QML UI ' + py.uiversion);
console.log('Podcastparser ' + py.parserversion);
console.log('PyOtherSide ' + py.pluginVersion());
console.log('Python ' + py.pythonVersion());
});

setHandler('download-progress', py.downloadProgress);
setHandler('playback-progress', py.playbackProgress);
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);
setHandler('update-stats', py.updateStats);
setHandler('config-changed', py.configChanged);

addImportPath(Qt.resolvedUrl('../..'));

// Load the Python side of things
importModule('main', function() {
py.call('main.initialize', [py.progname], function() {
py.ready = true;
initialized();
});
});
}

function setConfig(key, value) {
py.call('main.set_config_value', [key, value]);
}

function getConfig(key, callback) {
py.call('main.get_config_value', [key], function (result) {
callback(result);
});
}

onReceived: {
console.log('unhandled message: ' + data);
}

onError: {
console.log('Python failure: ' + traceback);
}
}
40 changes: 40 additions & 0 deletions gpodder-ui-qml/common/GPodderDirectorySearchModel.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

/**
*
* gPodder QML UI Reference Implementation
* Copyright (c) 2013, 2014, Thomas Perl <[email protected]>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
*/

import QtQuick 2.0

ListModel {
id: directorySearchModel
property string provider

function search(query, callback) {
clear();

py.call('main.get_directory_entries', [directorySearchModel.provider, query], function (result) {
for (var i=0; i<result.length; i++) {
directorySearchModel.append(result[i]);
}

if (callback !== undefined) {
callback();
}
});
}
}
145 changes: 145 additions & 0 deletions gpodder-ui-qml/common/GPodderEpisodeListModel.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@

/**
*
* gPodder QML UI Reference Implementation
* Copyright (c) 2013, 2014, Thomas Perl <[email protected]>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
*/

import QtQuick 2.0

import 'util.js' as Util
import 'constants.js' as Constants

ListModel {
id: episodeListModel

property int podcast_id: -1

property bool changeConfig: false

property var queries: ({
All: '',
Fresh: 'new or downloading',
Downloaded: 'downloaded or downloading',
UnplayedDownloads: 'downloaded and not played',
FinishedDownloads: 'downloaded and finished',
HideDeleted: 'not deleted',
Deleted: 'deleted',
ShortDownloads: 'downloaded and min > 0 and min < 10',
TextSearch: '/.*%s.*/i'
})

property var filters: ([
{ label: qsTr("All"), query: episodeListModel.queries.All, hasParameters:false },
{ label: qsTr("Fresh"), query: episodeListModel.queries.Fresh, hasParameters:false },
{ label: qsTr("Downloaded"), query: episodeListModel.queries.Downloaded, hasParameters:false },
{ label: qsTr("Unplayed downloads"), query: episodeListModel.queries.UnplayedDownloads, hasParameters:false },
{ label: qsTr("Finished downloads"), query: episodeListModel.queries.FinishedDownloads, hasParameters:false },
{ label: qsTr("Hide deleted"), query: episodeListModel.queries.HideDeleted, hasParameters:false },
{ label: qsTr("Deleted episodes"), query: episodeListModel.queries.Deleted, hasParameters:false },
{ label: qsTr("Short downloads (< 10 min)"), query: episodeListModel.queries.ShortDownloads, hasParameters:false },
{ label: qsTr("Includes Text: %s"), query: episodeListModel.queries.TextSearch, hasParameters:true, searchTerm: ""}
])

property bool ready: false
property int currentFilterIndex: 0
property string currentCustomQuery: queries.All


function getFormattedLabel(i){
if(i === undefined){
i = currentFilterIndex
}
console.assert(i>=0&&i<filters.length, "invalid filter label request")
if(filters[i].hasParameters){
return filters[i].label.replace("%s",filters[i].searchTerm);
}else{
return filters[i].label;
}
}

function forEachEpisode(callback) {
// Go from bottom up (= chronological order)
for (var i=count-1; i>=0; i--) {
callback(get(i));
}
}

function setQueryFromIndex(index) {
setQueryEx(filters[index].query,true);
}

function setQueryFromConfigUpdate(query) {
setQueryEx(query, false);
}

function setQuery(query) {
setQueryEx(query, true);
}

function setQueryEx(query, update) {
console.info(podcast_id,"changing query from '",currentCustomQuery,"' to '",query,"',")
if(ready && query === currentCustomQuery && !filters[currentFilterIndex].hasParameters){
console.debug(podcast_id, "filter already selected, skipping...");
return;
}
for (var i=0; i<filters.length; i++) {
if (filters[i].query === query) {
currentCustomQuery = query;
if (update && changeConfig) {
updateConfig();
}
currentFilterIndex = i;
reload();
return;
}
}
console.error("could not find query: ",query);
}

function updateConfig(){
console.info("saving selected filter: '",currentCustomQuery,"'.")
py.call('main.set_config_value', ['ui.qml.episode_list.filter_eql', currentCustomQuery]);
}

function loadAllEpisodes(callback) {
episodeListModel.podcast_id = -1;
reload(callback);
}

function loadEpisodes(podcast_id, callback) {
episodeListModel.podcast_id = podcast_id;
reload(callback);
}

function reload(callback) {
var query = filters[currentFilterIndex].query;
if(filters[currentFilterIndex].hasParameters){//text search
query = query.replace("%s",filters[currentFilterIndex].searchTerm)
}

console.info(podcast_id, "reloading with query: '",query,"'.")

ready = false;
py.call('main.load_episodes', [podcast_id, query], function (episodes) {
Util.updateModelFrom(episodeListModel, episodes);
episodeListModel.ready = true;
if (callback !== undefined) {
callback();
}
});
}
}
Loading