Remove the SpecialPlaylistType class, it hasn't been used since Spotify and Grooveshark search results went into the sidebar tree.
This commit is contained in:
parent
b42e93d29b
commit
885d98b5f0
|
@ -224,7 +224,6 @@ set(SOURCES
|
|||
playlist/playlisttabbar.cpp
|
||||
playlist/playlistundocommands.cpp
|
||||
playlist/playlistview.cpp
|
||||
playlist/specialplaylisttype.cpp
|
||||
playlist/queue.cpp
|
||||
playlist/queuemanager.cpp
|
||||
playlist/songloaderinserter.cpp
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "blobversion.h"
|
||||
#include "config.h"
|
||||
#include "internetmodel.h"
|
||||
#include "searchboxwidget.h"
|
||||
#include "spotifyserver.h"
|
||||
#include "spotifyservice.h"
|
||||
#include "core/application.h"
|
||||
|
@ -16,8 +17,6 @@
|
|||
#include "playlist/playlist.h"
|
||||
#include "playlist/playlistcontainer.h"
|
||||
#include "playlist/playlistmanager.h"
|
||||
#include "searchboxwidget.h"
|
||||
#include "widgets/didyoumean.h"
|
||||
#include "ui/iconloader.h"
|
||||
#include "widgets/didyoumean.h"
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
class DidYouMean;
|
||||
class Playlist;
|
||||
class SearchBoxWidget;
|
||||
class SpotifyServer;
|
||||
|
|
|
@ -17,12 +17,10 @@
|
|||
|
||||
#include "playlistcontainer.h"
|
||||
#include "playlistmanager.h"
|
||||
#include "specialplaylisttype.h"
|
||||
#include "ui_playlistcontainer.h"
|
||||
#include "core/logging.h"
|
||||
#include "playlistparsers/playlistparser.h"
|
||||
#include "ui/iconloader.h"
|
||||
#include "widgets/didyoumean.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QInputDialog>
|
||||
|
@ -50,7 +48,6 @@ PlaylistContainer::PlaylistContainer(QWidget *parent)
|
|||
tab_bar_visible_(false),
|
||||
tab_bar_animation_(new QTimeLine(500, this)),
|
||||
no_matches_label_(NULL),
|
||||
did_you_mean_(NULL),
|
||||
filter_timer_(new QTimer(this))
|
||||
{
|
||||
ui_->setupUi(this);
|
||||
|
@ -96,9 +93,6 @@ PlaylistContainer::PlaylistContainer(QWidget *parent)
|
|||
connect(ui_->filter, SIGNAL(textChanged(QString)), SLOT(MaybeUpdateFilter()));
|
||||
connect(ui_->playlist, SIGNAL(FocusOnFilterSignal(QKeyEvent*)), SLOT(FocusOnFilter(QKeyEvent*)));
|
||||
ui_->filter->installEventFilter(this);
|
||||
|
||||
did_you_mean_ = new DidYouMean(ui_->filter, this);
|
||||
connect(did_you_mean_, SIGNAL(Accepted(QString)), SLOT(DidYouMeanAccepted(QString)));
|
||||
}
|
||||
|
||||
PlaylistContainer::~PlaylistContainer() {
|
||||
|
@ -215,11 +209,6 @@ void PlaylistContainer::SetViewModel(Playlist* playlist) {
|
|||
|
||||
emit UndoRedoActionsChanged(undo_, redo_);
|
||||
|
||||
did_you_mean()->hide();
|
||||
|
||||
// Implement special playlist behaviour
|
||||
const SpecialPlaylistType* type = manager_->GetPlaylistType(playlist->special_type());
|
||||
ui_->filter->setPlaceholderText(type->search_hint_text(playlist));
|
||||
}
|
||||
|
||||
void PlaylistContainer::ActivePlaying() {
|
||||
|
@ -237,12 +226,7 @@ void PlaylistContainer::ActiveStopped() {
|
|||
void PlaylistContainer::UpdateActiveIcon(const QIcon& icon) {
|
||||
// Unset all existing icons
|
||||
for (int i=0 ; i<ui_->tab_bar->count() ; ++i) {
|
||||
// Get the default icon for this tab
|
||||
const int id = ui_->tab_bar->tabData(i).toInt();
|
||||
Playlist* playlist = manager_->playlist(id);
|
||||
const SpecialPlaylistType* type = manager_->GetPlaylistType(playlist->special_type());
|
||||
|
||||
ui_->tab_bar->setTabIcon(i, type->icon(playlist));
|
||||
ui_->tab_bar->setTabIcon(i, QIcon());
|
||||
}
|
||||
|
||||
// Set our icon
|
||||
|
@ -251,12 +235,8 @@ void PlaylistContainer::UpdateActiveIcon(const QIcon& icon) {
|
|||
}
|
||||
|
||||
void PlaylistContainer::PlaylistAdded(int id, const QString &name) {
|
||||
Playlist* playlist = manager_->playlist(id);
|
||||
const SpecialPlaylistType* type = manager_->GetPlaylistType(playlist->special_type());
|
||||
|
||||
const int index = ui_->tab_bar->count();
|
||||
const QIcon icon = type->icon(playlist);
|
||||
ui_->tab_bar->InsertTab(id, index, name, icon);
|
||||
ui_->tab_bar->InsertTab(id, index, name);
|
||||
|
||||
// Are we startup up, should we select this tab?
|
||||
if (starting_up_ && settings_.value("current_playlist", 1).toInt() == id) {
|
||||
|
@ -395,33 +375,19 @@ void PlaylistContainer::MaybeUpdateFilter() {
|
|||
}
|
||||
|
||||
void PlaylistContainer::UpdateFilter() {
|
||||
Playlist* playlist = manager_->current();
|
||||
SpecialPlaylistType* type = manager_->GetPlaylistType(playlist->special_type());
|
||||
|
||||
did_you_mean()->hide();
|
||||
|
||||
if (type->has_special_search_behaviour(playlist)) {
|
||||
type->Search(ui_->filter->text(), playlist);
|
||||
} else {
|
||||
manager_->current()->proxy()->setFilterFixedString(ui_->filter->text());
|
||||
ui_->playlist->JumpToCurrentlyPlayingTrack();
|
||||
}
|
||||
manager_->current()->proxy()->setFilterFixedString(ui_->filter->text());
|
||||
ui_->playlist->JumpToCurrentlyPlayingTrack();
|
||||
|
||||
UpdateNoMatchesLabel();
|
||||
}
|
||||
|
||||
void PlaylistContainer::UpdateNoMatchesLabel() {
|
||||
Playlist* playlist = manager_->current();
|
||||
SpecialPlaylistType* type = manager_->GetPlaylistType(playlist->special_type());
|
||||
const QString empty_text = type->empty_playlist_text(playlist);
|
||||
|
||||
const bool has_rows = playlist->rowCount() != 0;
|
||||
const bool has_results = playlist->proxy()->rowCount() != 0;
|
||||
|
||||
QString text;
|
||||
if (!empty_text.isEmpty() && !has_results) {
|
||||
text = empty_text;
|
||||
} else if (has_rows && !has_results) {
|
||||
if (has_rows && !has_results) {
|
||||
text = tr("No matches found. Clear the search box to show the whole playlist again.");
|
||||
}
|
||||
|
||||
|
@ -491,11 +457,3 @@ bool PlaylistContainer::eventFilter(QObject *objectWatched, QEvent *event) {
|
|||
}
|
||||
return QWidget::eventFilter(objectWatched, event);
|
||||
}
|
||||
|
||||
void PlaylistContainer::DidYouMeanAccepted(const QString& text) {
|
||||
ui_->filter->setText(text);
|
||||
|
||||
Playlist* playlist = manager_->current();
|
||||
SpecialPlaylistType* type = manager_->GetPlaylistType(playlist->special_type());
|
||||
type->DidYouMeanClicked(text, playlist);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
class Ui_PlaylistContainer;
|
||||
|
||||
class DidYouMean;
|
||||
class LineEditInterface;
|
||||
class Playlist;
|
||||
class PlaylistManager;
|
||||
|
@ -47,7 +46,6 @@ public:
|
|||
previous_playlist);
|
||||
void SetManager(PlaylistManager* manager);
|
||||
|
||||
DidYouMean* did_you_mean() const { return did_you_mean_; }
|
||||
PlaylistView* view() const;
|
||||
|
||||
bool eventFilter(QObject *objectWatched, QEvent *event);
|
||||
|
@ -91,7 +89,6 @@ private slots:
|
|||
void UpdateFilter();
|
||||
void FocusOnFilter(QKeyEvent *event);
|
||||
|
||||
void DidYouMeanAccepted(const QString& text);
|
||||
void UpdateNoMatchesLabel();
|
||||
|
||||
private:
|
||||
|
@ -117,8 +114,6 @@ private:
|
|||
|
||||
QLabel* no_matches_label_;
|
||||
|
||||
DidYouMean* did_you_mean_;
|
||||
|
||||
QTimer* filter_timer_;
|
||||
};
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "playlistcontainer.h"
|
||||
#include "playlistmanager.h"
|
||||
#include "playlistview.h"
|
||||
#include "specialplaylisttype.h"
|
||||
#include "core/application.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/player.h"
|
||||
|
@ -43,7 +42,6 @@ PlaylistManager::PlaylistManager(Application* app, QObject *parent)
|
|||
library_backend_(NULL),
|
||||
sequence_(NULL),
|
||||
parser_(NULL),
|
||||
default_playlist_type_(new DefaultPlaylistType),
|
||||
current_(-1),
|
||||
active_(-1)
|
||||
{
|
||||
|
@ -56,9 +54,6 @@ PlaylistManager::~PlaylistManager() {
|
|||
foreach (const Data& data, playlists_.values()) {
|
||||
delete data.p;
|
||||
}
|
||||
|
||||
qDeleteAll(special_playlist_types_.values());
|
||||
delete default_playlist_type_;
|
||||
}
|
||||
|
||||
void PlaylistManager::Init(LibraryBackend* library_backend,
|
||||
|
@ -414,35 +409,3 @@ QString PlaylistManager::GetNameForNewPlaylist(const SongList& songs) {
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
void PlaylistManager::RegisterSpecialPlaylistType(SpecialPlaylistType* type) {
|
||||
const QString name = type->name();
|
||||
|
||||
if (special_playlist_types_.contains(name)) {
|
||||
qLog(Warning) << "Tried to register a special playlist type" << name
|
||||
<< "but one was already registered";
|
||||
return;
|
||||
}
|
||||
|
||||
qLog(Info) << "Registered special playlist type" << name;
|
||||
special_playlist_types_.insert(name, type);
|
||||
}
|
||||
|
||||
void PlaylistManager::UnregisterSpecialPlaylistType(SpecialPlaylistType* type) {
|
||||
const QString name = special_playlist_types_.key(type);
|
||||
if (name.isEmpty()) {
|
||||
qLog(Warning) << "Tried to unregister a special playlist type" << type->name()
|
||||
<< "that wasn't registered";
|
||||
return;
|
||||
}
|
||||
|
||||
qLog(Info) << "Unregistered special playlist type" << name;
|
||||
special_playlist_types_.remove(name);
|
||||
}
|
||||
|
||||
SpecialPlaylistType* PlaylistManager::GetPlaylistType(const QString& type) const {
|
||||
if (special_playlist_types_.contains(type)) {
|
||||
return special_playlist_types_[type];
|
||||
}
|
||||
return default_playlist_type_;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ class PlaylistBackend;
|
|||
class PlaylistContainer;
|
||||
class PlaylistParser;
|
||||
class PlaylistSequence;
|
||||
class SpecialPlaylistType;
|
||||
class TaskManager;
|
||||
|
||||
class QModelIndex;
|
||||
|
@ -72,10 +71,6 @@ public:
|
|||
virtual PlaylistParser* parser() const = 0;
|
||||
virtual PlaylistContainer* playlist_container() const = 0;
|
||||
|
||||
virtual void RegisterSpecialPlaylistType(SpecialPlaylistType* type) = 0;
|
||||
virtual void UnregisterSpecialPlaylistType(SpecialPlaylistType* type) = 0;
|
||||
virtual SpecialPlaylistType* GetPlaylistType(const QString& type) const = 0;
|
||||
|
||||
public slots:
|
||||
virtual void New(const QString& name, const SongList& songs = SongList(),
|
||||
const QString& special_type = QString()) = 0;
|
||||
|
@ -170,10 +165,6 @@ public:
|
|||
PlaylistParser* parser() const { return parser_; }
|
||||
PlaylistContainer* playlist_container() const { return playlist_container_; }
|
||||
|
||||
void RegisterSpecialPlaylistType(SpecialPlaylistType* type);
|
||||
void UnregisterSpecialPlaylistType(SpecialPlaylistType* type);
|
||||
SpecialPlaylistType* GetPlaylistType(const QString& type) const;
|
||||
|
||||
public slots:
|
||||
void New(const QString& name, const SongList& songs = SongList(),
|
||||
const QString& special_type = QString());
|
||||
|
@ -234,9 +225,6 @@ private:
|
|||
// key = id
|
||||
QMap<int, Data> playlists_;
|
||||
|
||||
QMap<QString, SpecialPlaylistType*> special_playlist_types_;
|
||||
SpecialPlaylistType* default_playlist_type_;
|
||||
|
||||
int current_;
|
||||
int active_;
|
||||
};
|
||||
|
|
|
@ -226,13 +226,11 @@ void PlaylistTabBar::CurrentIndexChanged(int index) {
|
|||
emit CurrentIdChanged(tabData(index).toInt());
|
||||
}
|
||||
|
||||
void PlaylistTabBar::InsertTab(int id, int index, const QString& text,
|
||||
const QIcon& icon) {
|
||||
void PlaylistTabBar::InsertTab(int id, int index, const QString& text) {
|
||||
suppress_current_changed_ = true;
|
||||
insertTab(index, text);
|
||||
setTabData(index, id);
|
||||
setTabToolTip(index, text);
|
||||
setTabIcon(index, icon);
|
||||
suppress_current_changed_ = false;
|
||||
|
||||
if (currentIndex() == index)
|
||||
|
|
|
@ -50,8 +50,7 @@ public:
|
|||
void set_text_by_id(int id, const QString& text);
|
||||
|
||||
void RemoveTab(int id);
|
||||
void InsertTab(int id, int index, const QString& text,
|
||||
const QIcon& icon = QIcon());
|
||||
void InsertTab(int id, int index, const QString& text);
|
||||
|
||||
signals:
|
||||
void CurrentIdChanged(int id);
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
/* This file is part of Clementine.
|
||||
Copyright 2010, 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 "specialplaylisttype.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
QString SpecialPlaylistType::search_hint_text(Playlist* playlist) const {
|
||||
return QObject::tr("Playlist search");
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
/* This file is part of Clementine.
|
||||
Copyright 2010, 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 SPECIALPLAYLISTTYPE_H
|
||||
#define SPECIALPLAYLISTTYPE_H
|
||||
|
||||
#include <QIcon>
|
||||
#include <QString>
|
||||
|
||||
class Playlist;
|
||||
|
||||
|
||||
class SpecialPlaylistType {
|
||||
public:
|
||||
virtual ~SpecialPlaylistType() {}
|
||||
|
||||
virtual QString name() const = 0;
|
||||
|
||||
virtual QIcon icon(Playlist* playlist) const { return QIcon(); }
|
||||
virtual QString search_hint_text(Playlist* playlist) const;
|
||||
virtual QString empty_playlist_text(Playlist* playlist) const { return QString(); }
|
||||
|
||||
virtual bool has_special_search_behaviour(Playlist* playlist) const { return false; }
|
||||
virtual void Search(const QString& text, Playlist* playlist) {}
|
||||
virtual void DidYouMeanClicked(const QString& text, Playlist* playlist) {}
|
||||
};
|
||||
|
||||
|
||||
class DefaultPlaylistType : public SpecialPlaylistType {
|
||||
public:
|
||||
virtual QString name() const { return QString(); }
|
||||
};
|
||||
|
||||
#endif // SPECIALPLAYLISTTYPE_H
|
Loading…
Reference in New Issue