Add a BBC Podcasts page
This commit is contained in:
parent
d48177d630
commit
80b95a357d
@ -342,5 +342,6 @@
|
|||||||
<file>providers/podcast32.png</file>
|
<file>providers/podcast32.png</file>
|
||||||
<file>providers/mygpo32.png</file>
|
<file>providers/mygpo32.png</file>
|
||||||
<file>providers/itunes.png</file>
|
<file>providers/itunes.png</file>
|
||||||
|
<file>providers/bbc.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
BIN
data/providers/bbc.png
Normal file
BIN
data/providers/bbc.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 664 B |
@ -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/fixedopmlpage.cpp
|
||||||
podcasts/gpoddersearchpage.cpp
|
podcasts/gpoddersearchpage.cpp
|
||||||
podcasts/gpoddertoptagsmodel.cpp
|
podcasts/gpoddertoptagsmodel.cpp
|
||||||
podcasts/gpoddertoptagspage.cpp
|
podcasts/gpoddertoptagspage.cpp
|
||||||
@ -483,6 +484,7 @@ set(HEADERS
|
|||||||
podcasts/addpodcastbyurl.h
|
podcasts/addpodcastbyurl.h
|
||||||
podcasts/addpodcastdialog.h
|
podcasts/addpodcastdialog.h
|
||||||
podcasts/addpodcastpage.h
|
podcasts/addpodcastpage.h
|
||||||
|
podcasts/fixedopmlpage.h
|
||||||
podcasts/gpoddersearchpage.h
|
podcasts/gpoddersearchpage.h
|
||||||
podcasts/gpoddertoptagsmodel.h
|
podcasts/gpoddertoptagsmodel.h
|
||||||
podcasts/gpoddertoptagspage.h
|
podcasts/gpoddertoptagspage.h
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "addpodcastdialog.h"
|
#include "addpodcastdialog.h"
|
||||||
#include "addpodcastbyurl.h"
|
#include "addpodcastbyurl.h"
|
||||||
|
#include "fixedopmlpage.h"
|
||||||
#include "gpoddersearchpage.h"
|
#include "gpoddersearchpage.h"
|
||||||
#include "gpoddertoptagspage.h"
|
#include "gpoddertoptagspage.h"
|
||||||
#include "itunessearchpage.h"
|
#include "itunessearchpage.h"
|
||||||
@ -29,6 +30,8 @@
|
|||||||
|
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
|
const char* AddPodcastDialog::kBbcOpmlUrl = "http://www.bbc.co.uk/podcasts.opml";
|
||||||
|
|
||||||
AddPodcastDialog::AddPodcastDialog(Application* app, QWidget* parent)
|
AddPodcastDialog::AddPodcastDialog(Application* app, QWidget* parent)
|
||||||
: QDialog(parent),
|
: QDialog(parent),
|
||||||
app_(app),
|
app_(app),
|
||||||
@ -57,6 +60,8 @@ AddPodcastDialog::AddPodcastDialog(Application* app, QWidget* parent)
|
|||||||
|
|
||||||
// Add providers
|
// Add providers
|
||||||
AddPage(new AddPodcastByUrl(app, this));
|
AddPage(new AddPodcastByUrl(app, this));
|
||||||
|
AddPage(new FixedOpmlPage(QUrl(kBbcOpmlUrl), tr("BBC Podcasts"),
|
||||||
|
QIcon(":providers/bbc.png"), app, this));
|
||||||
AddPage(new GPodderTopTagsPage(app, this));
|
AddPage(new GPodderTopTagsPage(app, this));
|
||||||
AddPage(new GPodderSearchPage(app, this));
|
AddPage(new GPodderSearchPage(app, this));
|
||||||
AddPage(new ITunesSearchPage(app, this));
|
AddPage(new ITunesSearchPage(app, this));
|
||||||
|
@ -36,6 +36,8 @@ public:
|
|||||||
AddPodcastDialog(Application* app, QWidget* parent = 0);
|
AddPodcastDialog(Application* app, QWidget* parent = 0);
|
||||||
~AddPodcastDialog();
|
~AddPodcastDialog();
|
||||||
|
|
||||||
|
static const char* kBbcOpmlUrl;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void AddPodcast();
|
void AddPodcast();
|
||||||
void RemovePodcast();
|
void RemovePodcast();
|
||||||
|
70
src/podcasts/fixedopmlpage.cpp
Normal file
70
src/podcasts/fixedopmlpage.cpp
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/* 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 "fixedopmlpage.h"
|
||||||
|
#include "podcastdiscoverymodel.h"
|
||||||
|
#include "podcasturlloader.h"
|
||||||
|
#include "core/closure.h"
|
||||||
|
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
FixedOpmlPage::FixedOpmlPage(const QUrl& opml_url, const QString& title,
|
||||||
|
const QIcon& icon, Application* app,
|
||||||
|
QWidget* parent)
|
||||||
|
: AddPodcastPage(app, parent),
|
||||||
|
loader_(new PodcastUrlLoader(this)),
|
||||||
|
opml_url_(opml_url),
|
||||||
|
done_initial_load_(false)
|
||||||
|
{
|
||||||
|
setWindowTitle(title);
|
||||||
|
setWindowIcon(icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FixedOpmlPage::Show() {
|
||||||
|
if (!done_initial_load_) {
|
||||||
|
emit Busy(true);
|
||||||
|
done_initial_load_ = true;
|
||||||
|
|
||||||
|
PodcastUrlLoaderReply* reply = loader_->Load(opml_url_);
|
||||||
|
NewClosure(reply, SIGNAL(Finished(bool)),
|
||||||
|
this, SLOT(LoadFinished(PodcastUrlLoaderReply*)),
|
||||||
|
reply);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FixedOpmlPage::LoadFinished(PodcastUrlLoaderReply* reply) {
|
||||||
|
reply->deleteLater();
|
||||||
|
emit Busy(false);
|
||||||
|
|
||||||
|
if (!reply->is_success()) {
|
||||||
|
QMessageBox::warning(this, tr("Failed to load podcast"),
|
||||||
|
reply->error_text(), QMessageBox::Close);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (reply->result_type()) {
|
||||||
|
case PodcastUrlLoaderReply::Type_Podcast:
|
||||||
|
foreach (const Podcast& podcast, reply->podcast_results()) {
|
||||||
|
model()->appendRow(model()->CreatePodcastItem(podcast));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PodcastUrlLoaderReply::Type_Opml:
|
||||||
|
model()->CreateOpmlContainerItems(reply->opml_results(), model()->invisibleRootItem());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
48
src/podcasts/fixedopmlpage.h
Normal file
48
src/podcasts/fixedopmlpage.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/* 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 FIXEDOPMLPAGE_H
|
||||||
|
#define FIXEDOPMLPAGE_H
|
||||||
|
|
||||||
|
#include "addpodcastpage.h"
|
||||||
|
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
|
class PodcastUrlLoader;
|
||||||
|
class PodcastUrlLoaderReply;
|
||||||
|
|
||||||
|
class FixedOpmlPage : public AddPodcastPage {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
FixedOpmlPage(const QUrl& opml_url, const QString& title, const QIcon& icon,
|
||||||
|
Application* app, QWidget* parent = 0);
|
||||||
|
|
||||||
|
bool has_visible_widget() const { return false; }
|
||||||
|
void Show();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void LoadFinished(PodcastUrlLoaderReply* reply);
|
||||||
|
|
||||||
|
private:
|
||||||
|
PodcastUrlLoader* loader_;
|
||||||
|
QUrl opml_url_;
|
||||||
|
|
||||||
|
bool done_initial_load_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FIXEDOPMLPAGE_H
|
@ -79,8 +79,10 @@ QUrl PodcastUrlLoader::FixPodcastUrl(const QString& url_text) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PodcastUrlLoaderReply* PodcastUrlLoader::Load(const QString& url_text) {
|
PodcastUrlLoaderReply* PodcastUrlLoader::Load(const QString& url_text) {
|
||||||
QUrl url(FixPodcastUrl(url_text));
|
return Load(FixPodcastUrl(url_text));
|
||||||
|
}
|
||||||
|
|
||||||
|
PodcastUrlLoaderReply* PodcastUrlLoader::Load(const QUrl& url) {
|
||||||
// Create a reply
|
// Create a reply
|
||||||
PodcastUrlLoaderReply* reply = new PodcastUrlLoaderReply(url, this);
|
PodcastUrlLoaderReply* reply = new PodcastUrlLoaderReply(url, this);
|
||||||
|
|
||||||
|
@ -77,6 +77,7 @@ public:
|
|||||||
static const int kMaxRedirects;
|
static const int kMaxRedirects;
|
||||||
|
|
||||||
PodcastUrlLoaderReply* Load(const QString& url_text);
|
PodcastUrlLoaderReply* Load(const QString& url_text);
|
||||||
|
PodcastUrlLoaderReply* Load(const QUrl& url);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct RequestState {
|
struct RequestState {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user