Use new directory provider support

This commit is contained in:
Thomas Perl 2014-10-27 11:36:54 +01:00
parent 54178ae4b9
commit 75f555f16f
9 changed files with 125 additions and 63 deletions

@ -1 +1 @@
Subproject commit 3f75aaf9ceda24dfede262a218168d28a163cba1 Subproject commit dc92d3c1154ded37e76d7e57024950a5c23e5088

@ -1 +1 @@
Subproject commit 77bac09899d07aa51579759dc42499e485edf424 Subproject commit 4680751494b5fcbc2fd29f179d6b09751a27801d

@ -1 +1 @@
Subproject commit 378327cc793223326cb87bb8f8f1a9819225fa95 Subproject commit f98acd22b14bc8459f7f695cf5fd6fad50324b8f

View file

@ -26,9 +26,18 @@ import 'common'
Page { Page {
id: directory id: directory
property string provider
property string query: '-'
property var callback property var callback
function start(query, callback) { Component.onCompleted: {
if (directory.query !== '-') {
directory.start(directory.provider, directory.query, directory.callback);
}
}
function start(provider, query, callback) {
directory.provider = provider;
directory.callback = callback; directory.callback = callback;
directorySearchModel.search(query, function() { directorySearchModel.search(query, function() {
busyIndicator.visible = false; busyIndicator.visible = false;
@ -39,12 +48,12 @@ Page {
anchors.fill: parent anchors.fill: parent
header: PageHeader { header: PageHeader {
title: 'Search results' title: directory.provider
} }
VerticalScrollDecorator { } VerticalScrollDecorator { }
model: GPodderDirectorySearchModel { id: directorySearchModel } model: GPodderDirectorySearchModel { id: directorySearchModel; provider: directory.provider }
delegate: DirectoryItem { delegate: DirectoryItem {
onClicked: { onClicked: {

View file

@ -23,23 +23,24 @@ import Sailfish.Silica 1.0
Dialog { Dialog {
id: directory id: directory
property string provider
property var callback
canAccept: input.text != '' canAccept: input.text != ''
acceptDestination: Component { Directory { } } acceptDestination: Component { Directory { } }
acceptDestinationAction: PageStackAction.Replace acceptDestinationAction: PageStackAction.Replace
onAccepted: { onAccepted: {
var ctx = { py: py }; acceptDestinationInstance.start(directory.provider, input.text, directory.callback);
acceptDestinationInstance.start(input.text, function (url) {
ctx.py.call('main.subscribe', [url]);
});
} }
Column { Column {
anchors.fill: parent anchors.fill: parent
DialogHeader { DialogHeader {
title: 'Search gpodder.net' title: directory.provider
acceptText: 'Search' acceptText: 'Search'
} }

View file

@ -34,7 +34,7 @@ ListItem {
Image { Image {
id: cover id: cover
opacity: scaled_logo_url && status == Image.Ready opacity: image && status == Image.Ready
Behavior on opacity { FadeAnimation { } } Behavior on opacity { FadeAnimation { } }
anchors { anchors {
@ -49,7 +49,7 @@ ListItem {
width: Theme.iconSizeMedium width: Theme.iconSizeMedium
height: Theme.iconSizeMedium height: Theme.iconSizeMedium
source: scaled_logo_url source: image
} }
Rectangle { Rectangle {
@ -73,12 +73,24 @@ ListItem {
anchors { anchors {
left: cover.right left: cover.right
leftMargin: Theme.paddingSmall leftMargin: Theme.paddingSmall
rightMargin: Theme.paddingSmall rightMargin: subs.text ? Theme.paddingSmall : 0
right: parent.right right: subs.left
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
} }
truncationMode: TruncationMode.Fade truncationMode: TruncationMode.Fade
text: title text: title
} }
Label {
id: subs
anchors {
right: parent.right
rightMargin: Theme.paddingSmall
verticalCenter: parent.verticalCenter
}
text: (subscribers > 0) ? subscribers : ''
}
} }

View file

@ -0,0 +1,86 @@
/**
*
* gPodder QML UI Reference Implementation
* Copyright (c) 2014, Thomas Perl <m@thp.io>
*
* 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 Sailfish.Silica 1.0
Page {
id: directorySelectionDialog
property var model
property int selectedIndex: -1
Component.onCompleted: {
py.call('main.get_directory_providers', [], function (result) {
directorySelectionDialog.model = result;
});
}
SilicaListView {
anchors.fill: parent
header: PageHeader {
title: 'Select provider'
}
model: directorySelectionDialog.model
delegate: ListItem {
id: listItem
highlighted: down || (index == directorySelectionDialog.selectedIndex)
onClicked: {
directorySelectionDialog.selectedIndex = index;
var callback = (function (py) {
return (function (url) {
py.call('main.subscribe', [url]);
});
})(py);
if (!modelData.can_search) {
pgst.loadPage('Directory.qml', {
provider: modelData.label,
query: '',
callback: callback,
}, true);
} else {
pgst.loadPage('DirectoryDialog.qml', {
provider: modelData.label,
callback: callback,
}, true);
}
}
Label {
anchors {
left: parent.left
verticalCenter: parent.verticalCenter
margins: Theme.paddingMedium
}
color: listItem.highlighted ? Theme.highlightColor : Theme.primaryColor
text: modelData.label
}
}
VerticalScrollDecorator { }
}
}

View file

@ -1,46 +0,0 @@
/**
*
* gPodder QML UI Reference Implementation
* Copyright (c) 2014, Thomas Perl <m@thp.io>
*
* 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
Item {
id: episodeQueryControl
property var model
property string title
function showSelectionDialog() {
pgst.loadPage('SelectionDialog.qml', {
title: episodeQueryControl.title,
callback: function (index, result) {
episodeQueryControl.model.currentFilterIndex = index;
episodeQueryControl.model.reload();
},
items: function () {
var labels = [];
for (var i in episodeQueryControl.model.filters) {
labels.push(episodeQueryControl.model.filters[i].label);
}
return labels;
}(),
selectedIndex: episodeQueryControl.model.currentFilterIndex,
});
}
}

View file

@ -60,8 +60,8 @@ Page {
} }
MenuItem { MenuItem {
text: 'Search gpodder.net' text: 'Discover new podcasts'
onClicked: pgst.loadPage('DirectoryDialog.qml'); onClicked: pgst.loadPage('DirectorySelectionDialog.qml');
} }
} }