mirror of
https://github.com/clementine-player/Clementine
synced 2025-02-06 22:24:04 +01:00
Add a gpodder.net search
This commit is contained in:
parent
884080684a
commit
bbb661b82c
@ -231,6 +231,7 @@ set(SOURCES
|
|||||||
podcasts/addpodcastbyurl.cpp
|
podcasts/addpodcastbyurl.cpp
|
||||||
podcasts/addpodcastdialog.cpp
|
podcasts/addpodcastdialog.cpp
|
||||||
podcasts/addpodcastpage.cpp
|
podcasts/addpodcastpage.cpp
|
||||||
|
podcasts/gpoddersearchpage.cpp
|
||||||
podcasts/gpoddertoptagsmodel.cpp
|
podcasts/gpoddertoptagsmodel.cpp
|
||||||
podcasts/gpoddertoptagspage.cpp
|
podcasts/gpoddertoptagspage.cpp
|
||||||
podcasts/podcast.cpp
|
podcasts/podcast.cpp
|
||||||
@ -481,6 +482,7 @@ set(HEADERS
|
|||||||
podcasts/addpodcastbyurl.h
|
podcasts/addpodcastbyurl.h
|
||||||
podcasts/addpodcastdialog.h
|
podcasts/addpodcastdialog.h
|
||||||
podcasts/addpodcastpage.h
|
podcasts/addpodcastpage.h
|
||||||
|
podcasts/gpoddersearchpage.h
|
||||||
podcasts/gpoddertoptagsmodel.h
|
podcasts/gpoddertoptagsmodel.h
|
||||||
podcasts/gpoddertoptagspage.h
|
podcasts/gpoddertoptagspage.h
|
||||||
podcasts/podcastbackend.h
|
podcasts/podcastbackend.h
|
||||||
@ -609,6 +611,7 @@ set(UI
|
|||||||
|
|
||||||
podcasts/addpodcastbyurl.ui
|
podcasts/addpodcastbyurl.ui
|
||||||
podcasts/addpodcastdialog.ui
|
podcasts/addpodcastdialog.ui
|
||||||
|
podcasts/gpoddersearchpage.ui
|
||||||
podcasts/podcastinfowidget.ui
|
podcasts/podcastinfowidget.ui
|
||||||
|
|
||||||
remote/remotesettingspage.ui
|
remote/remotesettingspage.ui
|
||||||
|
@ -40,8 +40,6 @@ AddPodcastByUrl::~AddPodcastByUrl() {
|
|||||||
void AddPodcastByUrl::GoClicked() {
|
void AddPodcastByUrl::GoClicked() {
|
||||||
emit Busy(true);
|
emit Busy(true);
|
||||||
model()->clear();
|
model()->clear();
|
||||||
ui_->go->setEnabled(false);
|
|
||||||
ui_->url->setEnabled(false);
|
|
||||||
|
|
||||||
PodcastUrlLoaderReply* reply = loader_->Load(ui_->url->text());
|
PodcastUrlLoaderReply* reply = loader_->Load(ui_->url->text());
|
||||||
ui_->url->setText(reply->url().toString());
|
ui_->url->setText(reply->url().toString());
|
||||||
@ -55,8 +53,6 @@ void AddPodcastByUrl::RequestFinished(PodcastUrlLoaderReply* reply) {
|
|||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
|
|
||||||
emit Busy(false);
|
emit Busy(false);
|
||||||
ui_->go->setEnabled(true);
|
|
||||||
ui_->url->setEnabled(true);
|
|
||||||
|
|
||||||
if (!reply->is_success()) {
|
if (!reply->is_success()) {
|
||||||
QMessageBox::warning(this, tr("Failed to load podcast"),
|
QMessageBox::warning(this, tr("Failed to load podcast"),
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "addpodcastdialog.h"
|
#include "addpodcastdialog.h"
|
||||||
#include "addpodcastbyurl.h"
|
#include "addpodcastbyurl.h"
|
||||||
|
#include "gpoddersearchpage.h"
|
||||||
#include "gpoddertoptagspage.h"
|
#include "gpoddertoptagspage.h"
|
||||||
#include "podcastbackend.h"
|
#include "podcastbackend.h"
|
||||||
#include "podcastdiscoverymodel.h"
|
#include "podcastdiscoverymodel.h"
|
||||||
@ -46,11 +47,12 @@ AddPodcastDialog::AddPodcastDialog(Application* app, QWidget* parent)
|
|||||||
add_button_ = new QPushButton(IconLoader::Load("list-add"), tr("Add Podcast"), this);
|
add_button_ = new QPushButton(IconLoader::Load("list-add"), tr("Add Podcast"), this);
|
||||||
add_button_->setEnabled(false);
|
add_button_->setEnabled(false);
|
||||||
connect(add_button_, SIGNAL(clicked()), SLOT(AddPodcast()));
|
connect(add_button_, SIGNAL(clicked()), SLOT(AddPodcast()));
|
||||||
ui_->button_box->addButton(add_button_, QDialogButtonBox::AcceptRole);
|
ui_->button_box->addButton(add_button_, QDialogButtonBox::ActionRole);
|
||||||
|
|
||||||
// Add providers
|
// Add providers
|
||||||
AddPage(new AddPodcastByUrl(app, this));
|
AddPage(new AddPodcastByUrl(app, this));
|
||||||
AddPage(new GPodderTopTagsPage(app, this));
|
AddPage(new GPodderTopTagsPage(app, this));
|
||||||
|
AddPage(new GPodderSearchPage(app, this));
|
||||||
|
|
||||||
ui_->provider_list->setCurrentRow(0);
|
ui_->provider_list->setCurrentRow(0);
|
||||||
}
|
}
|
||||||
@ -83,7 +85,7 @@ void AddPodcastDialog::ChangePage(int index) {
|
|||||||
connect(ui_->results->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
|
connect(ui_->results->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
|
||||||
SLOT(ChangePodcast(QModelIndex)));
|
SLOT(ChangePodcast(QModelIndex)));
|
||||||
ChangePodcast(QModelIndex());
|
ChangePodcast(QModelIndex());
|
||||||
PageBusyChanged(page_is_busy_[index]);
|
CurrentPageBusyChanged(page_is_busy_[index]);
|
||||||
|
|
||||||
page->Show();
|
page->Show();
|
||||||
}
|
}
|
||||||
@ -116,10 +118,15 @@ void AddPodcastDialog::PageBusyChanged(bool busy) {
|
|||||||
page_is_busy_[index] = busy;
|
page_is_busy_[index] = busy;
|
||||||
|
|
||||||
if (index == ui_->provider_list->currentRow()) {
|
if (index == ui_->provider_list->currentRow()) {
|
||||||
ui_->results_stack->setCurrentWidget(busy ? ui_->busy_page : ui_->results_page);
|
CurrentPageBusyChanged(busy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AddPodcastDialog::CurrentPageBusyChanged(bool busy) {
|
||||||
|
ui_->results_stack->setCurrentWidget(busy ? ui_->busy_page : ui_->results_page);
|
||||||
|
ui_->stack->setDisabled(busy);
|
||||||
|
}
|
||||||
|
|
||||||
void AddPodcastDialog::AddPodcast() {
|
void AddPodcastDialog::AddPodcast() {
|
||||||
app_->podcast_backend()->Subscribe(¤t_podcast_);
|
app_->podcast_backend()->Subscribe(¤t_podcast_);
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ private slots:
|
|||||||
void ChangePodcast(const QModelIndex& current);
|
void ChangePodcast(const QModelIndex& current);
|
||||||
|
|
||||||
void PageBusyChanged(bool busy);
|
void PageBusyChanged(bool busy);
|
||||||
|
void CurrentPageBusyChanged(bool busy);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void AddPage(AddPodcastPage* page);
|
void AddPage(AddPodcastPage* page);
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Dialog</string>
|
<string>Add podcast</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
|
89
src/podcasts/gpoddersearchpage.cpp
Normal file
89
src/podcasts/gpoddersearchpage.cpp
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
/* This file is part of Clementine.
|
||||||
|
Copyright 2012, David Sansome <me@davidsansome.com>
|
||||||
|
|
||||||
|
Clementine is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Clementine is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gpoddersearchpage.h"
|
||||||
|
#include "podcast.h"
|
||||||
|
#include "podcastdiscoverymodel.h"
|
||||||
|
#include "ui_gpoddersearchpage.h"
|
||||||
|
#include "core/closure.h"
|
||||||
|
#include "core/network.h"
|
||||||
|
|
||||||
|
#include <ApiRequest.h>
|
||||||
|
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
GPodderSearchPage::GPodderSearchPage(Application* app, QWidget* parent)
|
||||||
|
: AddPodcastPage(app, parent),
|
||||||
|
ui_(new Ui_GPodderSearchPage),
|
||||||
|
network_(new NetworkAccessManager(this)),
|
||||||
|
api_(new mygpo::ApiRequest(network_))
|
||||||
|
{
|
||||||
|
ui_->setupUi(this);
|
||||||
|
connect(ui_->search, SIGNAL(clicked()), SLOT(SearchClicked()));
|
||||||
|
}
|
||||||
|
|
||||||
|
GPodderSearchPage::~GPodderSearchPage() {
|
||||||
|
delete ui_;
|
||||||
|
delete api_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GPodderSearchPage::SearchClicked() {
|
||||||
|
emit Busy(true);
|
||||||
|
|
||||||
|
mygpo::PodcastList* list = api_->search(ui_->query->text());
|
||||||
|
NewClosure(list, SIGNAL(finished()),
|
||||||
|
this, SLOT(SearchFinished(mygpo::PodcastList*)),
|
||||||
|
list);
|
||||||
|
NewClosure(list, SIGNAL(parseError()),
|
||||||
|
this, SLOT(SearchFailed(mygpo::PodcastList*)),
|
||||||
|
list);
|
||||||
|
NewClosure(list, SIGNAL(requestError(QNetworkReply::NetworkError)),
|
||||||
|
this, SLOT(SearchFailed(mygpo::PodcastList*)),
|
||||||
|
list);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GPodderSearchPage::SearchFinished(mygpo::PodcastList* list) {
|
||||||
|
list->deleteLater();
|
||||||
|
emit Busy(false);
|
||||||
|
|
||||||
|
model()->clear();
|
||||||
|
|
||||||
|
foreach (mygpo::PodcastPtr gpo_podcast, list->list()) {
|
||||||
|
Podcast podcast;
|
||||||
|
podcast.InitFromGpo(gpo_podcast.data());
|
||||||
|
|
||||||
|
model()->appendRow(model()->CreatePodcastItem(podcast));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GPodderSearchPage::SearchFailed(mygpo::PodcastList* list) {
|
||||||
|
list->deleteLater();
|
||||||
|
emit Busy(false);
|
||||||
|
|
||||||
|
model()->clear();
|
||||||
|
|
||||||
|
if (QMessageBox::warning(
|
||||||
|
NULL, tr("Failed to fetch podcasts"),
|
||||||
|
tr("There was a problem communicating with gpodder.net"),
|
||||||
|
QMessageBox::Retry | QMessageBox::Close,
|
||||||
|
QMessageBox::Retry) != QMessageBox::Retry) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try doing the search again.
|
||||||
|
SearchClicked();
|
||||||
|
}
|
52
src/podcasts/gpoddersearchpage.h
Normal file
52
src/podcasts/gpoddersearchpage.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/* This file is part of Clementine.
|
||||||
|
Copyright 2012, David Sansome <me@davidsansome.com>
|
||||||
|
|
||||||
|
Clementine is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Clementine is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GPODDERSEARCHPAGE_H
|
||||||
|
#define GPODDERSEARCHPAGE_H
|
||||||
|
|
||||||
|
#include "addpodcastpage.h"
|
||||||
|
|
||||||
|
class QNetworkAccessManager;
|
||||||
|
|
||||||
|
class Ui_GPodderSearchPage;
|
||||||
|
|
||||||
|
namespace mygpo {
|
||||||
|
class ApiRequest;
|
||||||
|
class PodcastList;
|
||||||
|
}
|
||||||
|
|
||||||
|
class GPodderSearchPage : public AddPodcastPage {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
GPodderSearchPage(Application* app, QWidget* parent = 0);
|
||||||
|
~GPodderSearchPage();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void SearchClicked();
|
||||||
|
void SearchFinished(mygpo::PodcastList* list);
|
||||||
|
void SearchFailed(mygpo::PodcastList* list);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui_GPodderSearchPage* ui_;
|
||||||
|
|
||||||
|
QNetworkAccessManager* network_;
|
||||||
|
mygpo::ApiRequest* api_;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GPODDERSEARCHPAGE_H
|
68
src/podcasts/gpoddersearchpage.ui
Normal file
68
src/podcasts/gpoddersearchpage.ui
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>GPodderSearchPage</class>
|
||||||
|
<widget class="QWidget" name="GPodderSearchPage">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>538</width>
|
||||||
|
<height>69</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Search gpodder.net</string>
|
||||||
|
</property>
|
||||||
|
<property name="windowIcon">
|
||||||
|
<iconset resource="../../data/data.qrc">
|
||||||
|
<normaloff>:/providers/mygpo32.png</normaloff>:/providers/mygpo32.png</iconset>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Enter search terms below to find podcasts on gpodder.net</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="query"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="search">
|
||||||
|
<property name="text">
|
||||||
|
<string>Search</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources>
|
||||||
|
<include location="../../data/data.qrc"/>
|
||||||
|
</resources>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>query</sender>
|
||||||
|
<signal>returnPressed()</signal>
|
||||||
|
<receiver>search</receiver>
|
||||||
|
<slot>click()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>130</x>
|
||||||
|
<y>45</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>198</x>
|
||||||
|
<y>46</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
@ -31,7 +31,7 @@ GPodderTopTagsPage::GPodderTopTagsPage(Application* app, QWidget* parent)
|
|||||||
api_(new mygpo::ApiRequest(network_)),
|
api_(new mygpo::ApiRequest(network_)),
|
||||||
done_initial_load_(false)
|
done_initial_load_(false)
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("Browse gpodder.net"));
|
setWindowTitle(tr("gpodder.net directory"));
|
||||||
setWindowIcon(QIcon(":providers/mygpo32.png"));
|
setWindowIcon(QIcon(":providers/mygpo32.png"));
|
||||||
|
|
||||||
SetModel(new GPodderTopTagsModel(api_, app, this));
|
SetModel(new GPodderTopTagsModel(api_, app, this));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user