Implement support for the new directory search API

This commit is contained in:
Thomas Perl 2014-10-26 23:15:51 +01:00
parent 6b5864806d
commit 1e87a2a3fb
5 changed files with 68 additions and 23 deletions

View file

@ -24,6 +24,15 @@ import 'common'
SlidePage {
id: directory
property string provider
property bool can_search
Component.onCompleted: {
if (!directory.can_search) {
// Load static data
search('');
}
}
function search(text) {
loading.visible = true;
@ -40,7 +49,7 @@ SlidePage {
PScrollDecorator { flickable: listView }
model: GPodderDirectorySearchModel { id: directorySearchModel }
model: GPodderDirectorySearchModel { id: directorySearchModel; provider: directory.provider }
header: Column {
anchors {
@ -48,9 +57,11 @@ SlidePage {
right: parent.right
}
SlidePageHeader { title: 'Search gpodder.net' }
SlidePageHeader { title: directory.provider }
Column {
visible: directory.can_search
spacing: 0.5 * 30 * pgst.scalef
anchors {

View file

@ -46,7 +46,7 @@ ButtonArea {
width: 80 * pgst.scalef
height: 80 * pgst.scalef
source: scaled_logo_url
source: image
}
PLabel {
@ -70,6 +70,6 @@ ButtonArea {
verticalCenter: parent.verticalCenter
}
text: subscribers
text: (subscribers > 0) ? subscribers : ''
}
}

View file

@ -66,9 +66,25 @@ SlidePage {
},
},
{
label: 'Search gpodder.net',
label: 'Discover new podcasts',
callback: function () {
pgst.loadPage('Directory.qml');
py.call('main.get_directory_providers', [], function (result) {
var items = [];
for (var i=0; i<result.length; i++) {
(function (provider) {
items.push({
label: provider.label,
callback: function () {
pgst.loadPage('Directory.qml', {
provider: provider.label,
can_search: provider.can_search,
});
},
});
})(result[i]);
}
pgst.showSelection(items, 'Select provider');
});
},
},
]);