further refactoring of duplicated playlist-insertion related code in RadioServices
This commit is contained in:
parent
79159700fc
commit
c8aed5fd30
@ -64,15 +64,9 @@ class DigitallyImportedServiceBase(clementine.RadioService):
|
||||
def ShowContextMenu(self, index, global_pos):
|
||||
if not self.menu:
|
||||
self.menu = QMenu()
|
||||
self.menu.addAction(clementine.IconLoader.Load("media-playback-start"),
|
||||
self.tr("Append to current playlist"), self.AddToPlaylist)
|
||||
self.menu.addAction(clementine.IconLoader.Load("media-playback-start"),
|
||||
self.tr("Replace current playlist"), self.LoadToPlaylist)
|
||||
self.menu.addAction(clementine.IconLoader.Load("document-new"),
|
||||
self.tr("Open in new playlist"), self.OpenInNewPlaylist)
|
||||
|
||||
self.menu.addSeparator()
|
||||
|
||||
for action in self.GetPlaylistActions():
|
||||
self.menu.addAction(action)
|
||||
self.menu.addAction(clementine.IconLoader.Load("download"),
|
||||
self.tr("Open " + self.HOMEPAGE_NAME + " in browser"), self.Homepage)
|
||||
self.menu.addAction(clementine.IconLoader.Load("view-refresh"),
|
||||
@ -86,14 +80,8 @@ class DigitallyImportedServiceBase(clementine.RadioService):
|
||||
self.context_index = index
|
||||
self.menu.popup(global_pos)
|
||||
|
||||
def AddToPlaylist(self):
|
||||
self.AddItemToPlaylist(self.context_index, self.AddMode_Append)
|
||||
|
||||
def LoadToPlaylist(self):
|
||||
self.AddItemToPlaylist(self.context_index, self.AddMode_Replace)
|
||||
|
||||
def OpenInNewPlaylist(self):
|
||||
self.AddItemToPlaylist(self.context_index, self.AddMode_OpenInNew)
|
||||
def GetCurrentIndex(self):
|
||||
return self.context_index
|
||||
|
||||
def Homepage(self):
|
||||
QDesktopServices.openUrl(self.HOMEPAGE_URL)
|
||||
|
@ -271,9 +271,9 @@ void IcecastService::ShowContextMenu(const QModelIndex& index,
|
||||
const bool can_play = context_item_.isValid() &&
|
||||
model_->GetSong(context_item_).is_valid();
|
||||
|
||||
add_to_playlist_->setEnabled(can_play);
|
||||
load_to_playlist_->setEnabled(can_play);
|
||||
open_in_new_playlist_->setEnabled(can_play);
|
||||
GetAppendToPlaylistAction()->setEnabled(can_play);
|
||||
GetReplacePlaylistAction()->setEnabled(can_play);
|
||||
GetOpenInNewPlaylistAction()->setEnabled(can_play);
|
||||
context_menu_->popup(global_pos);
|
||||
}
|
||||
|
||||
@ -283,13 +283,7 @@ void IcecastService::EnsureMenuCreated() {
|
||||
|
||||
context_menu_ = new QMenu;
|
||||
|
||||
add_to_playlist_ = context_menu_->addAction(
|
||||
IconLoader::Load("media-playback-start"), tr("Append to current playlist"), this, SLOT(AddToPlaylist()));
|
||||
load_to_playlist_ = context_menu_->addAction(
|
||||
IconLoader::Load("media-playback-start"), tr("Replace current playlist"), this, SLOT(LoadToPlaylist()));
|
||||
open_in_new_playlist_ = context_menu_->addAction(
|
||||
IconLoader::Load("document-new"), tr("Open in new playlist"), this, SLOT(OpenInNewPlaylist()));
|
||||
context_menu_->addSeparator();
|
||||
context_menu_->addActions(GetPlaylistActions());
|
||||
context_menu_->addAction(IconLoader::Load("download"), tr("Open dir.xiph.org in browser"), this, SLOT(Homepage()));
|
||||
context_menu_->addAction(IconLoader::Load("view-refresh"), tr("Refresh station list"), this, SLOT(LoadDirectory()));
|
||||
}
|
||||
@ -298,14 +292,6 @@ void IcecastService::Homepage() {
|
||||
QDesktopServices::openUrl(QUrl(kHomepage));
|
||||
}
|
||||
|
||||
void IcecastService::AddToPlaylist() {
|
||||
AddItemToPlaylist(context_item_, AddMode_Append);
|
||||
}
|
||||
|
||||
void IcecastService::LoadToPlaylist() {
|
||||
AddItemToPlaylist(context_item_, AddMode_Replace);
|
||||
}
|
||||
|
||||
void IcecastService::OpenInNewPlaylist() {
|
||||
AddItemToPlaylist(context_item_, AddMode_OpenInNew);
|
||||
QModelIndex IcecastService::GetCurrentIndex() {
|
||||
return context_item_;
|
||||
}
|
||||
|
@ -52,12 +52,12 @@ class IcecastService : public RadioService {
|
||||
|
||||
QWidget* HeaderWidget() const;
|
||||
|
||||
protected:
|
||||
QModelIndex GetCurrentIndex();
|
||||
|
||||
private slots:
|
||||
void LoadDirectory();
|
||||
void Homepage();
|
||||
void AddToPlaylist();
|
||||
void LoadToPlaylist();
|
||||
void OpenInNewPlaylist();
|
||||
|
||||
private:
|
||||
void EnsureMenuCreated();
|
||||
@ -68,9 +68,6 @@ class IcecastService : public RadioService {
|
||||
NetworkAccessManager* network_;
|
||||
QMenu* context_menu_;
|
||||
QModelIndex context_item_;
|
||||
QAction* add_to_playlist_;
|
||||
QAction* load_to_playlist_;
|
||||
QAction* open_in_new_playlist_;
|
||||
|
||||
IcecastBackend* backend_;
|
||||
IcecastModel* model_;
|
||||
|
@ -378,13 +378,7 @@ void JamendoService::EnsureMenuCreated() {
|
||||
return;
|
||||
|
||||
context_menu_ = new QMenu;
|
||||
add_to_playlist_ = context_menu_->addAction(IconLoader::Load("media-playback-start"),
|
||||
tr("Append to current playlist"), this, SLOT(AddToPlaylist()));
|
||||
load_to_playlist_ = context_menu_->addAction(IconLoader::Load("media-playback-start"),
|
||||
tr("Replace current playlist"), this, SLOT(LoadToPlaylist()));
|
||||
open_in_new_playlist_ = context_menu_->addAction(IconLoader::Load("document-new"),
|
||||
tr("Open in new playlist"), this, SLOT(OpenInNewPlaylist()));
|
||||
context_menu_->addSeparator();
|
||||
context_menu_->addActions(GetPlaylistActions());
|
||||
album_info_ = context_menu_->addAction(IconLoader::Load("view-media-lyrics"),
|
||||
tr("Album info on jamendo.com..."), this, SLOT(AlbumInfo()));
|
||||
download_album_ = context_menu_->addAction(IconLoader::Load("download"),
|
||||
@ -409,9 +403,9 @@ void JamendoService::ShowContextMenu(const QModelIndex& index, const QPoint& glo
|
||||
context_item_ = QModelIndex();
|
||||
}
|
||||
|
||||
add_to_playlist_->setEnabled(context_item_.isValid());
|
||||
load_to_playlist_->setEnabled(context_item_.isValid());
|
||||
open_in_new_playlist_->setEnabled(context_item_.isValid());
|
||||
GetAppendToPlaylistAction()->setEnabled(context_item_.isValid());
|
||||
GetReplacePlaylistAction()->setEnabled(context_item_.isValid());
|
||||
GetOpenInNewPlaylistAction()->setEnabled(context_item_.isValid());
|
||||
album_info_->setEnabled(context_item_.isValid());
|
||||
download_album_->setEnabled(context_item_.isValid());
|
||||
context_menu_->popup(global_pos);
|
||||
@ -422,16 +416,8 @@ QWidget* JamendoService::HeaderWidget() const {
|
||||
return library_filter_;
|
||||
}
|
||||
|
||||
void JamendoService::AddToPlaylist() {
|
||||
AddItemToPlaylist(context_item_, AddMode_Append);
|
||||
}
|
||||
|
||||
void JamendoService::LoadToPlaylist() {
|
||||
AddItemToPlaylist(context_item_, AddMode_Replace);
|
||||
}
|
||||
|
||||
void JamendoService::OpenInNewPlaylist() {
|
||||
AddItemToPlaylist(context_item_, AddMode_OpenInNew);
|
||||
QModelIndex JamendoService::GetCurrentIndex() {
|
||||
return context_item_;
|
||||
}
|
||||
|
||||
void JamendoService::AlbumInfo() {
|
||||
|
@ -66,6 +66,9 @@ class JamendoService : public RadioService {
|
||||
static const int kBatchSize;
|
||||
static const int kApproxDatabaseSize;
|
||||
|
||||
protected:
|
||||
QModelIndex GetCurrentIndex();
|
||||
|
||||
private:
|
||||
void ParseDirectory(QIODevice* device) const;
|
||||
|
||||
@ -91,9 +94,6 @@ class JamendoService : public RadioService {
|
||||
void ParseDirectoryFinished();
|
||||
void UpdateTotalSongCount(int count);
|
||||
|
||||
void AddToPlaylist();
|
||||
void LoadToPlaylist();
|
||||
void OpenInNewPlaylist();
|
||||
void AlbumInfo();
|
||||
void DownloadAlbum();
|
||||
void Homepage();
|
||||
@ -104,9 +104,6 @@ class JamendoService : public RadioService {
|
||||
QMenu* context_menu_;
|
||||
QModelIndex context_item_;
|
||||
|
||||
QAction* add_to_playlist_;
|
||||
QAction* load_to_playlist_;
|
||||
QAction* open_in_new_playlist_;
|
||||
QAction* album_info_;
|
||||
QAction* download_album_;
|
||||
|
||||
|
@ -74,13 +74,7 @@ LastFMService::LastFMService(RadioModel* parent)
|
||||
{
|
||||
ReloadSettings();
|
||||
|
||||
play_action_ = context_menu_->addAction(
|
||||
IconLoader::Load("media-playback-start"), tr("Append to current playlist"), this, SLOT(AddToPlaylist()));
|
||||
load_action_ = context_menu_->addAction(
|
||||
IconLoader::Load("media-playback-start"), tr("Replace current playlist"), this, SLOT(LoadToPlaylist()));
|
||||
open_in_new_playlist_ = context_menu_->addAction(IconLoader::Load("document-new"),
|
||||
tr("Open in new playlist"), this, SLOT(OpenInNewPlaylist()));
|
||||
context_menu_->addSeparator();
|
||||
context_menu_->addActions(GetPlaylistActions());
|
||||
remove_action_ = context_menu_->addAction(
|
||||
IconLoader::Load("list-remove"), tr("Remove"), this, SLOT(Remove()));
|
||||
context_menu_->addSeparator();
|
||||
@ -470,9 +464,9 @@ void LastFMService::ShowContextMenu(const QModelIndex& index, const QPoint &glob
|
||||
}
|
||||
|
||||
const bool playable = model()->IsPlayable(index);
|
||||
play_action_->setEnabled(playable);
|
||||
load_action_->setEnabled(playable);
|
||||
open_in_new_playlist_->setEnabled(playable);
|
||||
GetAppendToPlaylistAction()->setEnabled(playable);
|
||||
GetReplacePlaylistAction()->setEnabled(playable);
|
||||
GetOpenInNewPlaylistAction()->setEnabled(playable);
|
||||
context_menu_->popup(global_pos);
|
||||
}
|
||||
|
||||
@ -558,16 +552,8 @@ void LastFMService::RefreshNeighboursFinished() {
|
||||
}
|
||||
}
|
||||
|
||||
void LastFMService::AddToPlaylist() {
|
||||
AddItemToPlaylist(context_item_->index(), AddMode_Append);
|
||||
}
|
||||
|
||||
void LastFMService::LoadToPlaylist() {
|
||||
AddItemToPlaylist(context_item_->index(), AddMode_Replace);
|
||||
}
|
||||
|
||||
void LastFMService::OpenInNewPlaylist() {
|
||||
AddItemToPlaylist(context_item_->index(), AddMode_OpenInNew);
|
||||
QModelIndex LastFMService::GetCurrentIndex() {
|
||||
return context_item_->index();
|
||||
}
|
||||
|
||||
void LastFMService::AddArtistRadio() {
|
||||
|
@ -116,6 +116,9 @@ class LastFMService : public RadioService {
|
||||
void ScrobblingEnabledChanged(bool value);
|
||||
void ButtonVisibilityChanged(bool value);
|
||||
|
||||
protected:
|
||||
QModelIndex GetCurrentIndex();
|
||||
|
||||
private slots:
|
||||
void AuthenticateReplyFinished();
|
||||
void RefreshFriendsFinished();
|
||||
@ -124,9 +127,6 @@ class LastFMService : public RadioService {
|
||||
void TunerTrackAvailable();
|
||||
void TunerError(lastfm::ws::Error error);
|
||||
|
||||
void AddToPlaylist();
|
||||
void LoadToPlaylist();
|
||||
void OpenInNewPlaylist();
|
||||
void AddArtistRadio();
|
||||
void AddTagRadio();
|
||||
void AddCustomRadio();
|
||||
@ -172,9 +172,6 @@ class LastFMService : public RadioService {
|
||||
boost::scoped_ptr<LastFMStationDialog> station_dialog_;
|
||||
|
||||
boost::scoped_ptr<QMenu> context_menu_;
|
||||
QAction* play_action_;
|
||||
QAction* load_action_;
|
||||
QAction* open_in_new_playlist_;
|
||||
QAction* remove_action_;
|
||||
QAction* add_artist_action_;
|
||||
QAction* add_tag_action_;
|
||||
|
@ -248,13 +248,7 @@ void MagnatuneService::EnsureMenuCreated() {
|
||||
|
||||
context_menu_ = new QMenu;
|
||||
|
||||
add_to_playlist_ = context_menu_->addAction(
|
||||
IconLoader::Load("media-playback-start"), tr("Append to current playlist"), this, SLOT(AddToPlaylist()));
|
||||
load_to_playlist_ = context_menu_->addAction(
|
||||
IconLoader::Load("media-playback-start"), tr("Replace current playlist"), this, SLOT(LoadToPlaylist()));
|
||||
open_in_new_playlist_ = context_menu_->addAction(IconLoader::Load("document-new"),
|
||||
tr("Open in new playlist"), this, SLOT(OpenInNewPlaylist()));
|
||||
context_menu_->addSeparator();
|
||||
context_menu_->addActions(GetPlaylistActions());
|
||||
download_ = context_menu_->addAction(
|
||||
IconLoader::Load("download"), tr("Download this album"), this, SLOT(Download()));
|
||||
context_menu_->addSeparator();
|
||||
@ -278,23 +272,15 @@ void MagnatuneService::ShowContextMenu(const QModelIndex& index, const QPoint& g
|
||||
else
|
||||
context_item_ = QModelIndex();
|
||||
|
||||
add_to_playlist_->setEnabled(context_item_.isValid());
|
||||
load_to_playlist_->setEnabled(context_item_.isValid());
|
||||
open_in_new_playlist_->setEnabled(context_item_.isValid());
|
||||
GetAppendToPlaylistAction()->setEnabled(context_item_.isValid());
|
||||
GetReplacePlaylistAction()->setEnabled(context_item_.isValid());
|
||||
GetOpenInNewPlaylistAction()->setEnabled(context_item_.isValid());
|
||||
download_->setEnabled(context_item_.isValid() && membership_ == Membership_Download);
|
||||
context_menu_->popup(global_pos);
|
||||
}
|
||||
|
||||
void MagnatuneService::AddToPlaylist() {
|
||||
AddItemToPlaylist(context_item_, AddMode_Append);
|
||||
}
|
||||
|
||||
void MagnatuneService::LoadToPlaylist() {
|
||||
AddItemToPlaylist(context_item_, AddMode_Replace);
|
||||
}
|
||||
|
||||
void MagnatuneService::OpenInNewPlaylist() {
|
||||
AddItemToPlaylist(context_item_, AddMode_OpenInNew);
|
||||
QModelIndex MagnatuneService::GetCurrentIndex() {
|
||||
return context_item_;
|
||||
}
|
||||
|
||||
void MagnatuneService::Homepage() {
|
||||
|
@ -88,14 +88,14 @@ class MagnatuneService : public RadioService {
|
||||
signals:
|
||||
void DownloadFinished(const QStringList& albums);
|
||||
|
||||
protected:
|
||||
QModelIndex GetCurrentIndex();
|
||||
|
||||
private slots:
|
||||
void UpdateTotalSongCount(int count);
|
||||
void ReloadDatabase();
|
||||
void ReloadDatabaseFinished();
|
||||
|
||||
void AddToPlaylist();
|
||||
void LoadToPlaylist();
|
||||
void OpenInNewPlaylist();
|
||||
void Download();
|
||||
void Homepage();
|
||||
void ShowConfig();
|
||||
@ -110,9 +110,6 @@ class MagnatuneService : public RadioService {
|
||||
QModelIndex context_item_;
|
||||
QStandardItem* root_;
|
||||
|
||||
QAction* add_to_playlist_;
|
||||
QAction* load_to_playlist_;
|
||||
QAction* open_in_new_playlist_;
|
||||
QAction* download_;
|
||||
|
||||
LibraryBackend* library_backend_;
|
||||
|
@ -19,14 +19,63 @@
|
||||
#include "radiomodel.h"
|
||||
#include "core/mergedproxymodel.h"
|
||||
#include "core/mimedata.h"
|
||||
#include "ui/iconloader.h"
|
||||
|
||||
#include <QMenu>
|
||||
|
||||
RadioService::RadioService(const QString& name, RadioModel* model)
|
||||
: QObject(model),
|
||||
model_(model),
|
||||
name_(name)
|
||||
name_(name),
|
||||
append_to_playlist_(NULL),
|
||||
replace_playlist_(NULL),
|
||||
open_in_new_playlist_(NULL),
|
||||
separator_(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
QList<QAction*> RadioService::GetPlaylistActions() {
|
||||
if(!separator_) {
|
||||
separator_ = new QAction(this);
|
||||
separator_->setSeparator(true);
|
||||
}
|
||||
|
||||
return QList<QAction*>() << GetAppendToPlaylistAction()
|
||||
<< GetReplacePlaylistAction()
|
||||
<< GetOpenInNewPlaylistAction()
|
||||
<< separator_;
|
||||
}
|
||||
|
||||
QAction* RadioService::GetAppendToPlaylistAction() {
|
||||
if(!append_to_playlist_) {
|
||||
append_to_playlist_ = new QAction(IconLoader::Load("media-playback-start"),
|
||||
tr("Append to current playlist"), this);
|
||||
connect(append_to_playlist_, SIGNAL(triggered()), this, SLOT(AppendToPlaylist()));
|
||||
}
|
||||
|
||||
return append_to_playlist_;
|
||||
}
|
||||
|
||||
QAction* RadioService::GetReplacePlaylistAction() {
|
||||
if(!replace_playlist_) {
|
||||
replace_playlist_ = new QAction(IconLoader::Load("media-playback-start"),
|
||||
tr("Replace current playlist"), this);
|
||||
connect(replace_playlist_, SIGNAL(triggered()), this, SLOT(ReplacePlaylist()));
|
||||
}
|
||||
|
||||
return replace_playlist_;
|
||||
}
|
||||
|
||||
QAction* RadioService::GetOpenInNewPlaylistAction() {
|
||||
if(!open_in_new_playlist_) {
|
||||
open_in_new_playlist_ = new QAction(IconLoader::Load("document-new"),
|
||||
tr("Open in new playlist"), this);
|
||||
connect(open_in_new_playlist_, SIGNAL(triggered()), this, SLOT(OpenInNewPlaylist()));
|
||||
}
|
||||
|
||||
return open_in_new_playlist_;
|
||||
}
|
||||
|
||||
PlaylistItem::SpecialLoadResult RadioService::StartLoading(const QUrl &url) {
|
||||
return PlaylistItem::SpecialLoadResult(
|
||||
PlaylistItem::SpecialLoadResult::TrackAvailable, url, url);
|
||||
@ -49,3 +98,15 @@ void RadioService::AddItemsToPlaylist(const QModelIndexList& indexes, AddMode ad
|
||||
}
|
||||
emit AddToPlaylistSignal(data);
|
||||
}
|
||||
|
||||
void RadioService::AppendToPlaylist() {
|
||||
AddItemToPlaylist(GetCurrentIndex(), AddMode_Append);
|
||||
}
|
||||
|
||||
void RadioService::ReplacePlaylist() {
|
||||
AddItemToPlaylist(GetCurrentIndex(), AddMode_Replace);
|
||||
}
|
||||
|
||||
void RadioService::OpenInNewPlaylist() {
|
||||
AddItemToPlaylist(GetCurrentIndex(), AddMode_OpenInNew);
|
||||
}
|
||||
|
@ -65,7 +65,26 @@ signals:
|
||||
|
||||
void AddToPlaylistSignal(QMimeData* data);
|
||||
|
||||
private slots:
|
||||
void AppendToPlaylist();
|
||||
void ReplacePlaylist();
|
||||
void OpenInNewPlaylist();
|
||||
|
||||
protected:
|
||||
// Subclass provides the currently selected QModelIndex on RadioService's
|
||||
// request.
|
||||
virtual QModelIndex GetCurrentIndex() = 0;
|
||||
|
||||
// Returns all the playlist insertion related QActions (see below).
|
||||
QList<QAction*> GetPlaylistActions();
|
||||
|
||||
// Returns the 'append to playlist' QAction.
|
||||
QAction* GetAppendToPlaylistAction();
|
||||
// Returns the 'replace playlist' QAction.
|
||||
QAction* GetReplacePlaylistAction();
|
||||
// Returns the 'open in new playlist' QAction.
|
||||
QAction* GetOpenInNewPlaylistAction();
|
||||
|
||||
// Describes how songs should be added to playlist.
|
||||
enum AddMode {
|
||||
// appends songs to the current playlist
|
||||
@ -84,6 +103,11 @@ protected:
|
||||
private:
|
||||
RadioModel* model_;
|
||||
QString name_;
|
||||
|
||||
QAction* append_to_playlist_;
|
||||
QAction* replace_playlist_;
|
||||
QAction* open_in_new_playlist_;
|
||||
QAction* separator_;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(RadioService*);
|
||||
|
@ -90,10 +90,7 @@ void SavedRadio::ShowContextMenu(const QModelIndex& index,
|
||||
const QPoint& global_pos) {
|
||||
if (!context_menu_) {
|
||||
context_menu_ = new QMenu;
|
||||
add_action_ = context_menu_->addAction(IconLoader::Load("media-playback-start"), tr("Append to current playlist"), this, SLOT(AddToPlaylist()));
|
||||
load_action_ = context_menu_->addAction(IconLoader::Load("media-playback-start"), tr("Replace current playlist"), this, SLOT(LoadToPlaylist()));
|
||||
open_in_new_playlist_ = context_menu_->addAction(IconLoader::Load("document-new"), tr("Open in new playlist"), this, SLOT(OpenInNewPlaylist()));
|
||||
context_menu_->addSeparator();
|
||||
context_menu_->addActions(GetPlaylistActions());
|
||||
remove_action_ = context_menu_->addAction(IconLoader::Load("list-remove"), tr("Remove"), this, SLOT(Remove()));
|
||||
edit_action_ = context_menu_->addAction(IconLoader::Load("edit-rename"), tr("Edit..."), this, SLOT(Edit()));
|
||||
context_menu_->addSeparator();
|
||||
@ -103,9 +100,9 @@ void SavedRadio::ShowContextMenu(const QModelIndex& index,
|
||||
context_item_ = model()->itemFromIndex(index);
|
||||
const bool is_root = index.data(RadioModel::Role_Type).toInt() == RadioModel::Type_Service;
|
||||
|
||||
add_action_->setEnabled(!is_root);
|
||||
load_action_->setEnabled(!is_root);
|
||||
open_in_new_playlist_->setEnabled(!is_root);
|
||||
GetAppendToPlaylistAction()->setEnabled(!is_root);
|
||||
GetReplacePlaylistAction()->setEnabled(!is_root);
|
||||
GetOpenInNewPlaylistAction()->setEnabled(!is_root);
|
||||
remove_action_->setEnabled(!is_root);
|
||||
edit_action_->setEnabled(!is_root);
|
||||
|
||||
@ -140,16 +137,8 @@ void SavedRadio::Edit() {
|
||||
SaveStreams();
|
||||
}
|
||||
|
||||
void SavedRadio::AddToPlaylist() {
|
||||
AddItemToPlaylist(context_item_->index(), AddMode_Append);
|
||||
}
|
||||
|
||||
void SavedRadio::LoadToPlaylist() {
|
||||
AddItemToPlaylist(context_item_->index(), AddMode_Replace);
|
||||
}
|
||||
|
||||
void SavedRadio::OpenInNewPlaylist() {
|
||||
AddItemToPlaylist(context_item_->index(), AddMode_OpenInNew);
|
||||
QModelIndex SavedRadio::GetCurrentIndex() {
|
||||
return context_item_->index();
|
||||
}
|
||||
|
||||
void SavedRadio::AddStreamToList(const Stream& stream, QStandardItem* parent) {
|
||||
|
@ -50,10 +50,10 @@ class SavedRadio : public RadioService {
|
||||
signals:
|
||||
void ShowAddStreamDialog();
|
||||
|
||||
protected:
|
||||
QModelIndex GetCurrentIndex();
|
||||
|
||||
private slots:
|
||||
void AddToPlaylist();
|
||||
void LoadToPlaylist();
|
||||
void OpenInNewPlaylist();
|
||||
void Remove();
|
||||
void Edit();
|
||||
|
||||
@ -78,9 +78,6 @@ class SavedRadio : public RadioService {
|
||||
QStandardItem* context_item_;
|
||||
QStandardItem* root_;
|
||||
|
||||
QAction* add_action_;
|
||||
QAction* load_action_;
|
||||
QAction* open_in_new_playlist_;
|
||||
QAction* remove_action_;
|
||||
QAction* edit_action_;
|
||||
|
||||
|
@ -69,10 +69,7 @@ void SomaFMService::LazyPopulate(QStandardItem* item) {
|
||||
void SomaFMService::ShowContextMenu(const QModelIndex& index, const QPoint& global_pos) {
|
||||
if (!context_menu_) {
|
||||
context_menu_ = new QMenu;
|
||||
context_menu_->addAction(IconLoader::Load("media-playback-start"), tr("Append to current playlist"), this, SLOT(AddToPlaylist()));
|
||||
context_menu_->addAction(IconLoader::Load("media-playback-start"), tr("Replace current playlist"), this, SLOT(LoadToPlaylist()));
|
||||
context_menu_->addAction(IconLoader::Load("document-new"), tr("Open in new playlist"), this, SLOT(OpenInNewPlaylist()));
|
||||
context_menu_->addSeparator();
|
||||
context_menu_->addActions(GetPlaylistActions());
|
||||
context_menu_->addAction(IconLoader::Load("download"), tr("Open somafm.com in browser"), this, SLOT(Homepage()));
|
||||
context_menu_->addAction(IconLoader::Load("view-refresh"), tr("Refresh channels"), this, SLOT(RefreshChannels()));
|
||||
}
|
||||
@ -213,16 +210,8 @@ void SomaFMService::Homepage() {
|
||||
QDesktopServices::openUrl(QUrl(kHomepage));
|
||||
}
|
||||
|
||||
void SomaFMService::AddToPlaylist() {
|
||||
AddItemToPlaylist(context_item_->index(), AddMode_Append);
|
||||
}
|
||||
|
||||
void SomaFMService::LoadToPlaylist() {
|
||||
AddItemToPlaylist(context_item_->index(), AddMode_Replace);
|
||||
}
|
||||
|
||||
void SomaFMService::OpenInNewPlaylist() {
|
||||
AddItemToPlaylist(context_item_->index(), AddMode_OpenInNew);
|
||||
QModelIndex SomaFMService::GetCurrentIndex() {
|
||||
return context_item_->index();
|
||||
}
|
||||
|
||||
PlaylistItem::Options SomaFMService::playlistitem_options() const {
|
||||
|
@ -48,14 +48,14 @@ class SomaFMService : public RadioService {
|
||||
PlaylistItem::Options playlistitem_options() const;
|
||||
PlaylistItem::SpecialLoadResult StartLoading(const QUrl& url);
|
||||
|
||||
protected:
|
||||
QModelIndex GetCurrentIndex();
|
||||
|
||||
private slots:
|
||||
void RefreshChannels();
|
||||
void RefreshChannelsFinished();
|
||||
void LoadPlaylistFinished();
|
||||
|
||||
void AddToPlaylist();
|
||||
void LoadToPlaylist();
|
||||
void OpenInNewPlaylist();
|
||||
void Homepage();
|
||||
|
||||
private:
|
||||
|
@ -35,6 +35,14 @@ signals:
|
||||
void AddToPlaylistSignal(QMimeData* data);
|
||||
|
||||
protected:
|
||||
virtual QModelIndex GetCurrentIndex() = 0;
|
||||
|
||||
QList<QAction*> GetPlaylistActions();
|
||||
|
||||
QAction* GetAppendToPlaylistAction();
|
||||
QAction* GetReplacePlaylistAction();
|
||||
QAction* GetOpenInNewPlaylistAction();
|
||||
|
||||
enum AddMode {
|
||||
AddMode_Append,
|
||||
AddMode_Replace,
|
||||
|
Loading…
x
Reference in New Issue
Block a user