2012-03-05 19:15:45 +01:00
|
|
|
/* 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 PODCASTSERVICE_H
|
|
|
|
#define PODCASTSERVICE_H
|
|
|
|
|
2012-03-06 19:37:46 +01:00
|
|
|
#include "internet/internetmodel.h"
|
2012-03-05 19:15:45 +01:00
|
|
|
#include "internet/internetservice.h"
|
|
|
|
|
|
|
|
#include <QScopedPointer>
|
|
|
|
|
|
|
|
class AddPodcastDialog;
|
2012-03-07 12:04:47 +01:00
|
|
|
class Podcast;
|
2012-03-06 19:37:46 +01:00
|
|
|
class PodcastBackend;
|
2012-03-09 13:15:24 +01:00
|
|
|
class PodcastEpisode;
|
2012-03-06 22:24:41 +01:00
|
|
|
class StandardItemIconLoader;
|
2012-03-05 19:15:45 +01:00
|
|
|
|
2012-03-07 12:04:47 +01:00
|
|
|
class QSortFilterProxyModel;
|
|
|
|
|
2012-03-05 19:15:45 +01:00
|
|
|
class PodcastService : public InternetService {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
PodcastService(Application* app, InternetModel* parent);
|
|
|
|
~PodcastService();
|
|
|
|
|
|
|
|
static const char* kServiceName;
|
|
|
|
static const char* kSettingsGroup;
|
|
|
|
|
2012-03-06 19:37:46 +01:00
|
|
|
enum Type {
|
|
|
|
Type_AddPodcast = InternetModel::TypeCount,
|
|
|
|
Type_Podcast,
|
|
|
|
Type_Episode
|
|
|
|
};
|
|
|
|
|
2012-03-07 12:22:43 +01:00
|
|
|
enum Role {
|
2012-03-09 13:15:24 +01:00
|
|
|
Role_Podcast = InternetModel::RoleCount,
|
|
|
|
Role_Episode
|
2012-03-07 12:22:43 +01:00
|
|
|
};
|
|
|
|
|
2012-03-05 19:15:45 +01:00
|
|
|
QStandardItem* CreateRootItem();
|
|
|
|
void LazyPopulate(QStandardItem* parent);
|
|
|
|
|
|
|
|
void ShowContextMenu(const QModelIndex& index, const QPoint& global_pos);
|
2012-03-06 22:24:41 +01:00
|
|
|
void ReloadSettings();
|
2012-03-05 19:15:45 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
QModelIndex GetCurrentIndex();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void AddPodcast();
|
2012-03-09 13:15:24 +01:00
|
|
|
void UpdateSelectedPodcast();
|
|
|
|
|
2012-03-07 12:04:47 +01:00
|
|
|
void SubscriptionAdded(const Podcast& podcast);
|
|
|
|
void SubscriptionRemoved(const Podcast& podcast);
|
2012-03-09 13:15:24 +01:00
|
|
|
void EpisodesAdded(const QList<PodcastEpisode>& episodes);
|
2012-03-05 19:15:45 +01:00
|
|
|
|
2012-03-06 19:37:46 +01:00
|
|
|
private:
|
|
|
|
void PopulatePodcastList(QStandardItem* parent);
|
2012-03-09 13:15:24 +01:00
|
|
|
void UpdatePodcastText(QStandardItem* item, int unlistened_count) const;
|
|
|
|
|
2012-03-07 12:04:47 +01:00
|
|
|
QStandardItem* CreatePodcastItem(const Podcast& podcast);
|
2012-03-09 13:15:24 +01:00
|
|
|
QStandardItem* CreatePodcastEpisodeItem(const PodcastEpisode& episode);
|
2012-03-06 19:37:46 +01:00
|
|
|
|
2012-03-05 19:15:45 +01:00
|
|
|
private:
|
2012-03-06 22:24:41 +01:00
|
|
|
bool use_pretty_covers_;
|
|
|
|
QIcon default_icon_;
|
|
|
|
StandardItemIconLoader* icon_loader_;
|
|
|
|
|
2012-03-07 12:04:47 +01:00
|
|
|
PodcastBackend* backend_;
|
|
|
|
QStandardItemModel* model_;
|
|
|
|
QSortFilterProxyModel* proxy_;
|
|
|
|
|
2012-03-05 19:15:45 +01:00
|
|
|
QMenu* context_menu_;
|
2012-03-09 13:15:24 +01:00
|
|
|
QAction* update_selected_action_;
|
2012-03-05 19:15:45 +01:00
|
|
|
QStandardItem* root_;
|
|
|
|
|
2012-03-09 13:15:24 +01:00
|
|
|
QModelIndex current_index_;
|
|
|
|
QModelIndex current_podcast_index_;
|
|
|
|
|
|
|
|
QMap<int, QStandardItem*> podcasts_by_database_id_;
|
|
|
|
|
2012-03-05 19:15:45 +01:00
|
|
|
QScopedPointer<AddPodcastDialog> add_podcast_dialog_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PODCASTSERVICE_H
|