Connection syntax migration (#637)
This commit is contained in:
@@ -23,9 +23,10 @@ DynamicPlaylistControls::DynamicPlaylistControls(QWidget *parent)
|
||||
|
||||
ui_->setupUi(this);
|
||||
|
||||
connect(ui_->expand, SIGNAL(clicked()), SIGNAL(Expand()));
|
||||
connect(ui_->repopulate, SIGNAL(clicked()), SIGNAL(Repopulate()));
|
||||
connect(ui_->off, SIGNAL(clicked()), SIGNAL(TurnOff()));
|
||||
QObject::connect(ui_->expand, &QPushButton::clicked, this, &DynamicPlaylistControls::Expand);
|
||||
QObject::connect(ui_->repopulate, &QPushButton::clicked, this, &DynamicPlaylistControls::Repopulate);
|
||||
QObject::connect(ui_->off, &QPushButton::clicked, this, &DynamicPlaylistControls::TurnOff);
|
||||
|
||||
}
|
||||
|
||||
DynamicPlaylistControls::~DynamicPlaylistControls() { delete ui_; }
|
||||
|
||||
@@ -27,7 +27,7 @@ class DynamicPlaylistControls : public QWidget {
|
||||
|
||||
public:
|
||||
DynamicPlaylistControls(QWidget *parent = nullptr);
|
||||
~DynamicPlaylistControls();
|
||||
~DynamicPlaylistControls() override;
|
||||
|
||||
signals:
|
||||
void Expand();
|
||||
|
||||
@@ -142,20 +142,20 @@ Playlist::Playlist(PlaylistBackend *backend, TaskManager *task_manager, Collecti
|
||||
|
||||
undo_stack_->setUndoLimit(kUndoStackSize);
|
||||
|
||||
connect(this, SIGNAL(rowsInserted(QModelIndex, int, int)), SIGNAL(PlaylistChanged()));
|
||||
connect(this, SIGNAL(rowsRemoved(QModelIndex, int, int)), SIGNAL(PlaylistChanged()));
|
||||
QObject::connect(this, &Playlist::rowsInserted, this, &Playlist::PlaylistChanged);
|
||||
QObject::connect(this, &Playlist::rowsRemoved, this, &Playlist::PlaylistChanged);
|
||||
|
||||
Restore();
|
||||
|
||||
proxy_->setSourceModel(this);
|
||||
queue_->setSourceModel(this);
|
||||
|
||||
connect(queue_, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)), SLOT(TracksAboutToBeDequeued(QModelIndex, int, int)));
|
||||
connect(queue_, SIGNAL(rowsRemoved(QModelIndex,int,int)), SLOT(TracksDequeued()));
|
||||
QObject::connect(queue_, &Queue::rowsAboutToBeRemoved, this, &Playlist::TracksAboutToBeDequeued);
|
||||
QObject::connect(queue_, &Queue::rowsRemoved, this, &Playlist::TracksDequeued);
|
||||
|
||||
connect(queue_, SIGNAL(rowsInserted(QModelIndex, int, int)), SLOT(TracksEnqueued(QModelIndex, int, int)));
|
||||
QObject::connect(queue_, &Queue::rowsInserted, this, &Playlist::TracksEnqueued);
|
||||
|
||||
connect(queue_, SIGNAL(layoutChanged()), SLOT(QueueLayoutChanged()));
|
||||
QObject::connect(queue_, &Queue::layoutChanged, this, &Playlist::QueueLayoutChanged);
|
||||
|
||||
column_alignments_ = PlaylistView::DefaultColumnAlignment();
|
||||
|
||||
@@ -691,8 +691,8 @@ void Playlist::set_current_row(const int i, const AutoScroll autoscroll, const b
|
||||
void Playlist::InsertDynamicItems(const int count) {
|
||||
|
||||
PlaylistGeneratorInserter* inserter = new PlaylistGeneratorInserter(task_manager_, collection_, this);
|
||||
connect(inserter, SIGNAL(Error(QString)), SIGNAL(Error(QString)));
|
||||
connect(inserter, SIGNAL(PlayRequested(QModelIndex)), SIGNAL(PlayRequested(QModelIndex)));
|
||||
QObject::connect(inserter, &PlaylistGeneratorInserter::Error, this, &Playlist::Error);
|
||||
QObject::connect(inserter, &PlaylistGeneratorInserter::PlayRequested, this, &Playlist::PlayRequested);
|
||||
|
||||
inserter->Load(this, -1, false, false, false, dynamic_playlist_, count);
|
||||
|
||||
@@ -805,7 +805,7 @@ bool Playlist::dropMimeData(const QMimeData *data, Qt::DropAction action, int ro
|
||||
}
|
||||
else if (data->hasFormat(kCddaMimeType)) {
|
||||
SongLoaderInserter *inserter = new SongLoaderInserter(task_manager_, collection_, backend_->app()->player());
|
||||
connect(inserter, SIGNAL(Error(QString)), SIGNAL(Error(QString)));
|
||||
QObject::connect(inserter, &SongLoaderInserter::Error, this, &Playlist::Error);
|
||||
inserter->LoadAudioCD(this, row, play_now, enqueue_now, enqueue_next_now);
|
||||
}
|
||||
else if (data->hasUrls()) {
|
||||
@@ -820,7 +820,7 @@ bool Playlist::dropMimeData(const QMimeData *data, Qt::DropAction action, int ro
|
||||
void Playlist::InsertUrls(const QList<QUrl> &urls, const int pos, const bool play_now, const bool enqueue, const bool enqueue_next) {
|
||||
|
||||
SongLoaderInserter *inserter = new SongLoaderInserter(task_manager_, collection_, backend_->app()->player());
|
||||
connect(inserter, SIGNAL(Error(QString)), SIGNAL(Error(QString)));
|
||||
QObject::connect(inserter, &SongLoaderInserter::Error, this, &Playlist::Error);
|
||||
|
||||
inserter->Load(this, pos, play_now, enqueue, enqueue_next, urls);
|
||||
|
||||
@@ -834,7 +834,7 @@ void Playlist::InsertSmartPlaylist(PlaylistGeneratorPtr generator, const int pos
|
||||
}
|
||||
|
||||
PlaylistGeneratorInserter *inserter = new PlaylistGeneratorInserter(task_manager_, collection_, this);
|
||||
connect(inserter, SIGNAL(Error(QString)), SIGNAL(Error(QString)));
|
||||
QObject::connect(inserter, &PlaylistGeneratorInserter::Error, this, &Playlist::Error);
|
||||
|
||||
inserter->Load(this, pos, play_now, enqueue, enqueue_next, generator);
|
||||
|
||||
@@ -1759,11 +1759,11 @@ void Playlist::ReloadItems(const QList<int> &rows) {
|
||||
|
||||
void Playlist::AddSongInsertVetoListener(SongInsertVetoListener *listener) {
|
||||
veto_listeners_.append(listener);
|
||||
connect(listener, SIGNAL(destroyed()), this, SLOT(SongInsertVetoListenerDestroyed()));
|
||||
QObject::connect(listener, &SongInsertVetoListener::destroyed, this, &Playlist::SongInsertVetoListenerDestroyed);
|
||||
}
|
||||
|
||||
void Playlist::RemoveSongInsertVetoListener(SongInsertVetoListener *listener) {
|
||||
disconnect(listener, SIGNAL(destroyed()), this, SLOT(SongInsertVetoListenerDestroyed()));
|
||||
QObject::disconnect(listener, &SongInsertVetoListener::destroyed, this, &Playlist::SongInsertVetoListenerDestroyed);
|
||||
veto_listeners_.removeAll(listener);
|
||||
}
|
||||
|
||||
@@ -1885,7 +1885,7 @@ void Playlist::ReshuffleIndices() {
|
||||
void Playlist::set_sequence(PlaylistSequence *v) {
|
||||
|
||||
playlist_sequence_ = v;
|
||||
connect(v, SIGNAL(ShuffleModeChanged(PlaylistSequence::ShuffleMode)), SLOT(ShuffleModeChanged(PlaylistSequence::ShuffleMode)));
|
||||
QObject::connect(v, &PlaylistSequence::ShuffleModeChanged, this, &Playlist::ShuffleModeChanged);
|
||||
|
||||
ShuffleModeChanged(v->shuffle_mode());
|
||||
|
||||
|
||||
@@ -325,6 +325,8 @@ class Playlist : public QAbstractListModel {
|
||||
void RepopulateDynamicPlaylist();
|
||||
void TurnOffDynamicPlaylist();
|
||||
|
||||
void AlbumCoverLoaded(const Song &song, const AlbumCoverLoaderResult &result);
|
||||
|
||||
signals:
|
||||
void RestoreFinished();
|
||||
void PlaylistLoaded();
|
||||
@@ -373,11 +375,10 @@ class Playlist : public QAbstractListModel {
|
||||
void TracksDequeued();
|
||||
void TracksEnqueued(const QModelIndex&, const int begin, const int end);
|
||||
void QueueLayoutChanged();
|
||||
void SongSaveComplete(TagReaderReply *reply, const QPersistentModelIndex &index);
|
||||
void ItemReloadComplete(const QPersistentModelIndex &index);
|
||||
void SongSaveComplete(TagReaderReply *reply, const QPersistentModelIndex &idx);
|
||||
void ItemReloadComplete(const QPersistentModelIndex &idx);
|
||||
void ItemsLoaded(QFuture<PlaylistItemList> future);
|
||||
void SongInsertVetoListenerDestroyed();
|
||||
void AlbumCoverLoaded(const Song &song, const AlbumCoverLoaderResult &result);
|
||||
|
||||
private:
|
||||
bool is_loading_;
|
||||
|
||||
@@ -107,21 +107,21 @@ PlaylistContainer::PlaylistContainer(QWidget *parent)
|
||||
ui_->tab_bar->setExpanding(false);
|
||||
ui_->tab_bar->setMovable(true);
|
||||
|
||||
connect(tab_bar_animation_, SIGNAL(frameChanged(int)), SLOT(SetTabBarHeight(int)));
|
||||
QObject::connect(tab_bar_animation_, &QTimeLine::frameChanged, this, &PlaylistContainer::SetTabBarHeight);
|
||||
ui_->tab_bar->setMaximumHeight(0);
|
||||
|
||||
// Connections
|
||||
connect(ui_->tab_bar, SIGNAL(currentChanged(int)), SLOT(Save()));
|
||||
connect(ui_->tab_bar, SIGNAL(Save(int)), SLOT(SavePlaylist(int)));
|
||||
QObject::connect(ui_->tab_bar, &PlaylistTabBar::currentChanged, this, &PlaylistContainer::Save);
|
||||
QObject::connect(ui_->tab_bar, &PlaylistTabBar::Save, this, &PlaylistContainer::SaveCurrentPlaylist);
|
||||
|
||||
// set up timer for delayed filter updates
|
||||
filter_timer_->setSingleShot(true);
|
||||
filter_timer_->setInterval(kFilterDelayMs);
|
||||
connect(filter_timer_, SIGNAL(timeout()), this, SLOT(UpdateFilter()));
|
||||
QObject::connect(filter_timer_, &QTimer::timeout, this, &PlaylistContainer::UpdateFilter);
|
||||
|
||||
// Replace playlist search filter with native search box.
|
||||
connect(ui_->filter, SIGNAL(textChanged(QString)), SLOT(MaybeUpdateFilter()));
|
||||
connect(ui_->playlist, SIGNAL(FocusOnFilterSignal(QKeyEvent*)), SLOT(FocusOnFilter(QKeyEvent*)));
|
||||
QObject::connect(ui_->filter, &QSearchField::textChanged, this, &PlaylistContainer::MaybeUpdateFilter);
|
||||
QObject::connect(ui_->playlist, &PlaylistView::FocusOnFilterSignal, this, &PlaylistContainer::FocusOnFilter);
|
||||
ui_->filter->installEventFilter(this);
|
||||
|
||||
ReloadSettings();
|
||||
@@ -141,13 +141,13 @@ void PlaylistContainer::SetActions(QAction *new_playlist, QAction *load_playlist
|
||||
|
||||
ui_->tab_bar->SetActions(new_playlist, load_playlist);
|
||||
|
||||
connect(new_playlist, SIGNAL(triggered()), SLOT(NewPlaylist()));
|
||||
connect(save_playlist, SIGNAL(triggered()), SLOT(SavePlaylist()));
|
||||
connect(load_playlist, SIGNAL(triggered()), SLOT(LoadPlaylist()));
|
||||
connect(clear_playlist, SIGNAL(triggered()), SLOT(ClearPlaylist()));
|
||||
connect(next_playlist, SIGNAL(triggered()), SLOT(GoToNextPlaylistTab()));
|
||||
connect(previous_playlist, SIGNAL(triggered()), SLOT(GoToPreviousPlaylistTab()));
|
||||
connect(clear_playlist, SIGNAL(triggered()), SLOT(ClearPlaylist()));
|
||||
QObject::connect(new_playlist, &QAction::triggered, this, &PlaylistContainer::NewPlaylist);
|
||||
QObject::connect(save_playlist, &QAction::triggered, this, &PlaylistContainer::SavePlaylist);
|
||||
QObject::connect(load_playlist, &QAction::triggered, this, &PlaylistContainer::LoadPlaylist);
|
||||
QObject::connect(clear_playlist, &QAction::triggered, this, &PlaylistContainer::ClearPlaylist);
|
||||
QObject::connect(next_playlist, &QAction::triggered, this, &PlaylistContainer::GoToNextPlaylistTab);
|
||||
QObject::connect(previous_playlist, &QAction::triggered, this, &PlaylistContainer::GoToPreviousPlaylistTab);
|
||||
QObject::connect(clear_playlist, &QAction::triggered, this, &PlaylistContainer::ClearPlaylist);
|
||||
|
||||
}
|
||||
|
||||
@@ -156,35 +156,35 @@ void PlaylistContainer::SetManager(PlaylistManager *manager) {
|
||||
manager_ = manager;
|
||||
ui_->tab_bar->SetManager(manager);
|
||||
|
||||
connect(ui_->tab_bar, SIGNAL(CurrentIdChanged(int)), manager, SLOT(SetCurrentPlaylist(int)));
|
||||
connect(ui_->tab_bar, SIGNAL(Rename(int, QString)), manager, SLOT(Rename(int, QString)));
|
||||
connect(ui_->tab_bar, SIGNAL(Close(int)), manager, SLOT(Close(int)));
|
||||
connect(ui_->tab_bar, SIGNAL(PlaylistFavorited(int, bool)), manager, SLOT(Favorite(int, bool)));
|
||||
QObject::connect(ui_->tab_bar, &PlaylistTabBar::CurrentIdChanged, manager, &PlaylistManager::SetCurrentPlaylist);
|
||||
QObject::connect(ui_->tab_bar, &PlaylistTabBar::Rename, manager, &PlaylistManager::Rename);
|
||||
QObject::connect(ui_->tab_bar, &PlaylistTabBar::Close, manager, &PlaylistManager::Close);
|
||||
QObject::connect(ui_->tab_bar, &PlaylistTabBar::PlaylistFavorited, manager, &PlaylistManager::Favorite);
|
||||
|
||||
connect(ui_->tab_bar, SIGNAL(PlaylistOrderChanged(QList<int>)), manager, SLOT(ChangePlaylistOrder(QList<int>)));
|
||||
QObject::connect(ui_->tab_bar, &PlaylistTabBar::PlaylistOrderChanged, manager, &PlaylistManager::ChangePlaylistOrder);
|
||||
|
||||
connect(manager, SIGNAL(CurrentChanged(Playlist*, int)), SLOT(SetViewModel(Playlist*, int)));
|
||||
connect(manager, SIGNAL(PlaylistAdded(int, QString, bool)), SLOT(PlaylistAdded(int, QString, bool)));
|
||||
connect(manager, SIGNAL(PlaylistManagerInitialized()), SLOT(Started()));
|
||||
connect(manager, SIGNAL(PlaylistClosed(int)), SLOT(PlaylistClosed(int)));
|
||||
connect(manager, SIGNAL(PlaylistRenamed(int, QString)), SLOT(PlaylistRenamed(int, QString)));
|
||||
QObject::connect(manager, &PlaylistManager::CurrentChanged, this, &PlaylistContainer::SetViewModel);
|
||||
QObject::connect(manager, &PlaylistManager::PlaylistAdded, this, &PlaylistContainer::PlaylistAdded);
|
||||
QObject::connect(manager, &PlaylistManager::PlaylistManagerInitialized, this, &PlaylistContainer::Started);
|
||||
QObject::connect(manager, &PlaylistManager::PlaylistClosed, this, &PlaylistContainer::PlaylistClosed);
|
||||
QObject::connect(manager, &PlaylistManager::PlaylistRenamed, this, &PlaylistContainer::PlaylistRenamed);
|
||||
|
||||
}
|
||||
|
||||
void PlaylistContainer::SetViewModel(Playlist *playlist, const int scroll_position) {
|
||||
|
||||
if (view()->selectionModel()) {
|
||||
disconnect(view()->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(SelectionChanged()));
|
||||
QObject::disconnect(view()->selectionModel(), &QItemSelectionModel::selectionChanged, this, &PlaylistContainer::SelectionChanged);
|
||||
}
|
||||
if (playlist_ && playlist_->proxy()) {
|
||||
disconnect(playlist_->proxy(), SIGNAL(modelReset()), this, SLOT(UpdateNoMatchesLabel()));
|
||||
disconnect(playlist_->proxy(), SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(UpdateNoMatchesLabel()));
|
||||
disconnect(playlist_->proxy(), SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(UpdateNoMatchesLabel()));
|
||||
QObject::disconnect(playlist_->proxy(), &QSortFilterProxyModel::modelReset, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
||||
QObject::disconnect(playlist_->proxy(), &QSortFilterProxyModel::rowsInserted, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
||||
QObject::disconnect(playlist_->proxy(), &QSortFilterProxyModel::rowsRemoved, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
||||
}
|
||||
if (playlist_) {
|
||||
disconnect(playlist_, SIGNAL(modelReset()), this, SLOT(UpdateNoMatchesLabel()));
|
||||
disconnect(playlist_, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(UpdateNoMatchesLabel()));
|
||||
disconnect(playlist_, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(UpdateNoMatchesLabel()));
|
||||
QObject::disconnect(playlist_, &Playlist::modelReset, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
||||
QObject::disconnect(playlist_, &Playlist::rowsInserted, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
||||
QObject::disconnect(playlist_, &Playlist::rowsRemoved, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
||||
}
|
||||
|
||||
playlist_ = playlist;
|
||||
@@ -197,7 +197,7 @@ void PlaylistContainer::SetViewModel(Playlist *playlist, const int scroll_positi
|
||||
if (scroll_position != 0) view()->verticalScrollBar()->setValue(scroll_position);
|
||||
playlist->IgnoreSorting(false);
|
||||
|
||||
connect(view()->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(SelectionChanged()));
|
||||
QObject::connect(view()->selectionModel(), &QItemSelectionModel::selectionChanged, this, &PlaylistContainer::SelectionChanged);
|
||||
emit ViewSelectionModelChanged();
|
||||
|
||||
// Update filter
|
||||
@@ -208,12 +208,12 @@ void PlaylistContainer::SetViewModel(Playlist *playlist, const int scroll_positi
|
||||
#endif
|
||||
|
||||
// Update the no matches label
|
||||
connect(playlist_->proxy(), SIGNAL(modelReset()), SLOT(UpdateNoMatchesLabel()));
|
||||
connect(playlist_->proxy(), SIGNAL(rowsInserted(QModelIndex, int, int)), SLOT(UpdateNoMatchesLabel()));
|
||||
connect(playlist_->proxy(), SIGNAL(rowsRemoved(QModelIndex, int, int)), SLOT(UpdateNoMatchesLabel()));
|
||||
connect(playlist_, SIGNAL(modelReset()), SLOT(UpdateNoMatchesLabel()));
|
||||
connect(playlist_, SIGNAL(rowsInserted(QModelIndex, int, int)), SLOT(UpdateNoMatchesLabel()));
|
||||
connect(playlist_, SIGNAL(rowsRemoved(QModelIndex, int, int)), SLOT(UpdateNoMatchesLabel()));
|
||||
QObject::connect(playlist_->proxy(), &QSortFilterProxyModel::modelReset, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
||||
QObject::connect(playlist_->proxy(), &QSortFilterProxyModel::rowsInserted, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
||||
QObject::connect(playlist_->proxy(), &QSortFilterProxyModel::rowsRemoved, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
||||
QObject::connect(playlist_, &Playlist::modelReset, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
||||
QObject::connect(playlist_, &Playlist::rowsInserted, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
||||
QObject::connect(playlist_, &Playlist::rowsRemoved, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
||||
UpdateNoMatchesLabel();
|
||||
|
||||
// Ensure that tab is current
|
||||
@@ -284,7 +284,7 @@ void PlaylistContainer::UpdateActiveIcon(const QIcon &icon) {
|
||||
|
||||
}
|
||||
|
||||
void PlaylistContainer::PlaylistAdded(int id, const QString &name, bool favorite) {
|
||||
void PlaylistContainer::PlaylistAdded(const int id, const QString &name, const bool favorite) {
|
||||
|
||||
const int index = ui_->tab_bar->count();
|
||||
ui_->tab_bar->InsertTab(id, index, name, favorite);
|
||||
@@ -313,7 +313,7 @@ void PlaylistContainer::PlaylistAdded(int id, const QString &name, bool favorite
|
||||
|
||||
void PlaylistContainer::Started() { starting_up_ = false; }
|
||||
|
||||
void PlaylistContainer::PlaylistClosed(int id) {
|
||||
void PlaylistContainer::PlaylistClosed(const int id) {
|
||||
|
||||
ui_->tab_bar->RemoveTab(id);
|
||||
|
||||
@@ -321,7 +321,7 @@ void PlaylistContainer::PlaylistClosed(int id) {
|
||||
|
||||
}
|
||||
|
||||
void PlaylistContainer::PlaylistRenamed(int id, const QString &new_name) {
|
||||
void PlaylistContainer::PlaylistRenamed(const int id, const QString &new_name) {
|
||||
ui_->tab_bar->set_text_by_id(id, new_name);
|
||||
}
|
||||
|
||||
@@ -340,7 +340,7 @@ void PlaylistContainer::LoadPlaylist() {
|
||||
|
||||
}
|
||||
|
||||
void PlaylistContainer::SavePlaylist(int id = -1) {
|
||||
void PlaylistContainer::SavePlaylist(const int id = -1) {
|
||||
|
||||
// Use the tab name as the suggested name
|
||||
QString suggested_name = ui_->tab_bar->tabText(ui_->tab_bar->currentIndex());
|
||||
@@ -377,7 +377,7 @@ void PlaylistContainer::Save() {
|
||||
|
||||
}
|
||||
|
||||
void PlaylistContainer::SetTabBarVisible(bool visible) {
|
||||
void PlaylistContainer::SetTabBarVisible(const bool visible) {
|
||||
|
||||
if (tab_bar_visible_ == visible) return;
|
||||
tab_bar_visible_ = visible;
|
||||
@@ -387,7 +387,7 @@ void PlaylistContainer::SetTabBarVisible(bool visible) {
|
||||
|
||||
}
|
||||
|
||||
void PlaylistContainer::SetTabBarHeight(int height) {
|
||||
void PlaylistContainer::SetTabBarHeight(const int height) {
|
||||
ui_->tab_bar->setMaximumHeight(height);
|
||||
}
|
||||
|
||||
@@ -457,7 +457,7 @@ void PlaylistContainer::FocusOnFilter(QKeyEvent *event) {
|
||||
}
|
||||
}
|
||||
|
||||
void PlaylistContainer::RepositionNoMatchesLabel(bool force) {
|
||||
void PlaylistContainer::RepositionNoMatchesLabel(const bool force) {
|
||||
|
||||
if (!force && !no_matches_label_->isVisible()) return;
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ class PlaylistContainer : public QWidget {
|
||||
|
||||
signals:
|
||||
void TabChanged(int id);
|
||||
void Rename(int id, const QString &new_name);
|
||||
void Rename(int id, QString new_name);
|
||||
|
||||
void UndoRedoActionsChanged(QAction *undo, QAction *redo);
|
||||
void ViewSelectionModelChanged();
|
||||
@@ -75,27 +75,23 @@ class PlaylistContainer : public QWidget {
|
||||
private slots:
|
||||
void NewPlaylist();
|
||||
void LoadPlaylist();
|
||||
void SavePlaylist() { SavePlaylist(-1); }
|
||||
void SavePlaylist(int id);
|
||||
void SaveCurrentPlaylist() { SavePlaylist(-1); }
|
||||
void SavePlaylist(const int id);
|
||||
void ClearPlaylist();
|
||||
void GoToNextPlaylistTab();
|
||||
void GoToPreviousPlaylistTab();
|
||||
|
||||
void SetViewModel(Playlist *playlist, const int scroll_position);
|
||||
void PlaylistAdded(int id, const QString &name, bool favorite);
|
||||
void PlaylistClosed(int id);
|
||||
void PlaylistRenamed(int id, const QString &new_name);
|
||||
void PlaylistAdded(const int id, const QString &name, bool favorite);
|
||||
void PlaylistClosed(const int id);
|
||||
void PlaylistRenamed(const int id, const QString &new_name);
|
||||
|
||||
void Started();
|
||||
|
||||
void ActivePlaying();
|
||||
void ActivePaused();
|
||||
void ActiveStopped();
|
||||
|
||||
void Save();
|
||||
|
||||
void SetTabBarVisible(bool visible);
|
||||
void SetTabBarHeight(int height);
|
||||
void SetTabBarVisible(const bool visible);
|
||||
void SetTabBarHeight(const int height);
|
||||
|
||||
void SelectionChanged();
|
||||
void MaybeUpdateFilter();
|
||||
@@ -104,6 +100,11 @@ class PlaylistContainer : public QWidget {
|
||||
|
||||
void UpdateNoMatchesLabel();
|
||||
|
||||
public slots:
|
||||
void ActivePlaying();
|
||||
void ActivePaused();
|
||||
void ActiveStopped();
|
||||
|
||||
private:
|
||||
void UpdateActiveIcon(const QIcon &icon);
|
||||
void RepositionNoMatchesLabel(bool force = false);
|
||||
|
||||
@@ -90,13 +90,13 @@ const int PlaylistDelegateBase::kMinHeight = 19;
|
||||
QueuedItemDelegate::QueuedItemDelegate(QObject *parent, int indicator_column)
|
||||
: QStyledItemDelegate(parent), indicator_column_(indicator_column) {}
|
||||
|
||||
void QueuedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {
|
||||
void QueuedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const {
|
||||
|
||||
QStyledItemDelegate::paint(painter, option, index);
|
||||
QStyledItemDelegate::paint(painter, option, idx);
|
||||
|
||||
if (index.column() == indicator_column_) {
|
||||
if (idx.column() == indicator_column_) {
|
||||
bool ok = false;
|
||||
const int queue_pos = index.data(Playlist::Role_QueuePosition).toInt(&ok);
|
||||
const int queue_pos = idx.data(Playlist::Role_QueuePosition).toInt(&ok);
|
||||
if (ok && queue_pos != -1) {
|
||||
float opacity = kQueueOpacitySteps - qMin(kQueueOpacitySteps, queue_pos);
|
||||
opacity /= kQueueOpacitySteps;
|
||||
@@ -155,10 +155,10 @@ void QueuedItemDelegate::DrawBox(QPainter *painter, const QRect &line_rect, cons
|
||||
|
||||
}
|
||||
|
||||
int QueuedItemDelegate::queue_indicator_size(const QModelIndex &index) const {
|
||||
int QueuedItemDelegate::queue_indicator_size(const QModelIndex &idx) const {
|
||||
|
||||
if (index.column() == indicator_column_) {
|
||||
const int queue_pos = index.data(Playlist::Role_QueuePosition).toInt();
|
||||
if (idx.column() == indicator_column_) {
|
||||
const int queue_pos = idx.data(Playlist::Role_QueuePosition).toInt();
|
||||
if (queue_pos != -1) {
|
||||
return kQueueBoxLength + kQueueBoxBorder * 2;
|
||||
}
|
||||
@@ -205,23 +205,23 @@ QString PlaylistDelegateBase::displayText(const QVariant &value, const QLocale&)
|
||||
|
||||
}
|
||||
|
||||
QSize PlaylistDelegateBase::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const {
|
||||
QSize PlaylistDelegateBase::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &idx) const {
|
||||
|
||||
QSize size = QueuedItemDelegate::sizeHint(option, index);
|
||||
QSize size = QueuedItemDelegate::sizeHint(option, idx);
|
||||
if (size.height() < kMinHeight) size.setHeight(kMinHeight);
|
||||
return size;
|
||||
|
||||
}
|
||||
|
||||
void PlaylistDelegateBase::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {
|
||||
void PlaylistDelegateBase::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const {
|
||||
|
||||
QueuedItemDelegate::paint(painter, Adjusted(option, index), index);
|
||||
QueuedItemDelegate::paint(painter, Adjusted(option, idx), idx);
|
||||
|
||||
// Stop after indicator
|
||||
if (index.column() == Playlist::Column_Title) {
|
||||
if (index.data(Playlist::Role_StopAfter).toBool()) {
|
||||
if (idx.column() == Playlist::Column_Title) {
|
||||
if (idx.data(Playlist::Role_StopAfter).toBool()) {
|
||||
QRect rect(option.rect);
|
||||
rect.setRight(rect.right() - queue_indicator_size(index));
|
||||
rect.setRight(rect.right() - queue_indicator_size(idx));
|
||||
|
||||
DrawBox(painter, rect, option.font, tr("stop"));
|
||||
}
|
||||
@@ -229,18 +229,18 @@ void PlaylistDelegateBase::paint(QPainter *painter, const QStyleOptionViewItem &
|
||||
|
||||
}
|
||||
|
||||
QStyleOptionViewItem PlaylistDelegateBase::Adjusted(const QStyleOptionViewItem &option, const QModelIndex &index) const {
|
||||
QStyleOptionViewItem PlaylistDelegateBase::Adjusted(const QStyleOptionViewItem &option, const QModelIndex &idx) const {
|
||||
|
||||
if (!view_) return option;
|
||||
|
||||
QPoint top_left(-view_->horizontalScrollBar()->value(), -view_->verticalScrollBar()->value());
|
||||
|
||||
if (view_->header()->logicalIndexAt(top_left) != index.column())
|
||||
if (view_->header()->logicalIndexAt(top_left) != idx.column())
|
||||
return option;
|
||||
|
||||
QStyleOptionViewItem ret(option);
|
||||
|
||||
if (index.data(Playlist::Role_IsCurrent).toBool()) {
|
||||
if (idx.data(Playlist::Role_IsCurrent).toBool()) {
|
||||
// Move the text in a bit on the first column for the song that's currently playing
|
||||
ret.rect.setLeft(ret.rect.left() + 20);
|
||||
}
|
||||
@@ -249,7 +249,7 @@ QStyleOptionViewItem PlaylistDelegateBase::Adjusted(const QStyleOptionViewItem &
|
||||
|
||||
}
|
||||
|
||||
bool PlaylistDelegateBase::helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index) {
|
||||
bool PlaylistDelegateBase::helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &idx) {
|
||||
|
||||
// This function is copied from QAbstractItemDelegate, and changed to show displayText() in the tooltip, rather than the index's naked Qt::ToolTipRole text.
|
||||
|
||||
@@ -258,11 +258,11 @@ bool PlaylistDelegateBase::helpEvent(QHelpEvent *event, QAbstractItemView *view,
|
||||
if (!event || !view) return false;
|
||||
|
||||
QHelpEvent *he = static_cast<QHelpEvent*>(event);
|
||||
QString text = displayText(index.data(), QLocale::system());
|
||||
QString text = displayText(idx.data(), QLocale::system());
|
||||
|
||||
// Special case: we want newlines in the comment tooltip
|
||||
if (index.column() == Playlist::Column_Comment) {
|
||||
text = index.data(Qt::ToolTipRole).toString().toHtmlEscaped();
|
||||
if (idx.column() == Playlist::Column_Comment) {
|
||||
text = idx.data(Qt::ToolTipRole).toString().toHtmlEscaped();
|
||||
text.replace("\\r\\n", "<br />");
|
||||
text.replace("\\n", "<br />");
|
||||
text.replace("\r\n", "<br />");
|
||||
@@ -273,8 +273,8 @@ bool PlaylistDelegateBase::helpEvent(QHelpEvent *event, QAbstractItemView *view,
|
||||
|
||||
switch (event->type()) {
|
||||
case QEvent::ToolTip: {
|
||||
QSize real_text = sizeHint(option, index);
|
||||
QRect displayed_text = view->visualRect(index);
|
||||
QSize real_text = sizeHint(option, idx);
|
||||
QRect displayed_text = view->visualRect(idx);
|
||||
bool is_elided = displayed_text.width() < real_text.width();
|
||||
if (is_elided) {
|
||||
QToolTip::showText(he->globalPos(), text, view);
|
||||
|
||||
@@ -60,10 +60,10 @@ class QueuedItemDelegate : public QStyledItemDelegate {
|
||||
public:
|
||||
explicit QueuedItemDelegate(QObject *parent, int indicator_column = Playlist::Column_Title);
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
void DrawBox(QPainter *painter, const QRect &line_rect, const QFont &font, const QString &text, int width = -1) const;
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const override;
|
||||
void DrawBox(QPainter *painter, const QRect &line_rect, const QFont &font, const QString &idx, int width = -1) const;
|
||||
|
||||
int queue_indicator_size(const QModelIndex &index) const;
|
||||
int queue_indicator_size(const QModelIndex &idx) const;
|
||||
|
||||
private:
|
||||
static const int kQueueBoxBorder;
|
||||
@@ -83,16 +83,16 @@ class PlaylistDelegateBase : public QueuedItemDelegate {
|
||||
public:
|
||||
explicit PlaylistDelegateBase(QObject *parent, const QString &suffix = QString());
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const override;
|
||||
QString displayText(const QVariant &value, const QLocale &locale) const override;
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &idx) const override;
|
||||
|
||||
QStyleOptionViewItem Adjusted(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
QStyleOptionViewItem Adjusted(const QStyleOptionViewItem &option, const QModelIndex &idx) const;
|
||||
|
||||
static const int kMinHeight;
|
||||
|
||||
public slots:
|
||||
bool helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index) override;
|
||||
bool helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &idx) override;
|
||||
|
||||
protected:
|
||||
QTreeView *view_;
|
||||
@@ -161,7 +161,7 @@ class TagCompletionItemDelegate : public PlaylistDelegateBase {
|
||||
public:
|
||||
explicit TagCompletionItemDelegate(QObject *parent, CollectionBackend *backend, Playlist::Column column) : PlaylistDelegateBase(parent), backend_(backend), column_(column) {};
|
||||
|
||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &idx) const override;
|
||||
|
||||
private:
|
||||
CollectionBackend *backend_;
|
||||
@@ -211,4 +211,4 @@ class RatingItemDelegate : public PlaylistDelegateBase {
|
||||
QModelIndexList selected_indexes_;
|
||||
};
|
||||
|
||||
#endif // PLAYLISTDELEGATES_H
|
||||
#endif // PLAYLISTDELEGATES_H
|
||||
|
||||
@@ -53,10 +53,10 @@ PlaylistHeader::PlaylistHeader(Qt::Orientation orientation, PlaylistView *view,
|
||||
action_align_right_(nullptr)
|
||||
{
|
||||
|
||||
action_hide_ = menu_->addAction(tr("&Hide..."), this, SLOT(HideCurrent()));
|
||||
action_stretch_ = menu_->addAction(tr("&Stretch columns to fit window"), this, SLOT(ToggleStretchEnabled()));
|
||||
action_reset_ = menu_->addAction(tr("&Reset columns to default"), this, SLOT(ResetColumns()));
|
||||
action_rating_lock_ = menu_->addAction(tr("&Lock rating"), this, SLOT(ToggleRatingEditStatus()));
|
||||
action_hide_ = menu_->addAction(tr("&Hide..."), this, &PlaylistHeader::HideCurrent);
|
||||
action_stretch_ = menu_->addAction(tr("&Stretch columns to fit window"), this, &PlaylistHeader::ToggleStretchEnabled);
|
||||
action_reset_ = menu_->addAction(tr("&Reset columns to default"), this, &PlaylistHeader::ResetColumns);
|
||||
action_rating_lock_ = menu_->addAction(tr("&Lock rating"), this, &PlaylistHeader::ToggleRatingEditStatus);
|
||||
action_rating_lock_->setCheckable(true);
|
||||
menu_->addSeparator();
|
||||
|
||||
@@ -71,7 +71,7 @@ PlaylistHeader::PlaylistHeader(Qt::Orientation orientation, PlaylistView *view,
|
||||
action_align_right_->setCheckable(true);
|
||||
align_menu->addActions(align_group->actions());
|
||||
|
||||
connect(align_group, SIGNAL(triggered(QAction*)), SLOT(SetColumnAlignment(QAction*)));
|
||||
QObject::connect(align_group, &QActionGroup::triggered, this, &PlaylistHeader::SetColumnAlignment);
|
||||
|
||||
menu_->addMenu(align_menu);
|
||||
menu_->addSeparator();
|
||||
@@ -79,7 +79,7 @@ PlaylistHeader::PlaylistHeader(Qt::Orientation orientation, PlaylistView *view,
|
||||
action_stretch_->setCheckable(true);
|
||||
action_stretch_->setChecked(is_stretch_enabled());
|
||||
|
||||
connect(this, SIGNAL(StretchEnabledChanged(bool)), action_stretch_, SLOT(setChecked(bool)));
|
||||
QObject::connect(this, &PlaylistHeader::StretchEnabledChanged, action_stretch_, &QAction::setChecked);
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(PlaylistSettingsPage::kSettingsGroup);
|
||||
@@ -135,7 +135,7 @@ void PlaylistHeader::AddColumnAction(int index) {
|
||||
action->setChecked(!isSectionHidden(index));
|
||||
show_actions_ << action;
|
||||
|
||||
connect(action, &QAction::triggered, [this, index]() { ToggleVisible(index); } );
|
||||
QObject::connect(action, &QAction::triggered, [this, index]() { ToggleVisible(index); } );
|
||||
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ void PlaylistHeader::SetColumnAlignment(QAction *action) {
|
||||
|
||||
}
|
||||
|
||||
void PlaylistHeader::ToggleVisible(int section) {
|
||||
void PlaylistHeader::ToggleVisible(const int section) {
|
||||
SetSectionHidden(section, !isSectionHidden(section));
|
||||
emit SectionVisibilityChanged(section, !isSectionHidden(section));
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class PlaylistHeader : public StretchHeaderView {
|
||||
|
||||
private slots:
|
||||
void HideCurrent();
|
||||
void ToggleVisible(int section);
|
||||
void ToggleVisible(const int section);
|
||||
void ResetColumns();
|
||||
void SetColumnAlignment(QAction *action);
|
||||
void ToggleRatingEditStatus();
|
||||
@@ -84,4 +84,3 @@ class PlaylistHeader : public StretchHeaderView {
|
||||
};
|
||||
|
||||
#endif // PLAYLISTHEADER_H
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ class PlaylistItem : public std::enable_shared_from_this<PlaylistItem> {
|
||||
virtual QList<QAction*> actions() { return QList<QAction*>(); }
|
||||
|
||||
virtual bool InitFromQuery(const SqlRow &query) = 0;
|
||||
void BindToQuery(QSqlQuery* query) const;
|
||||
void BindToQuery(QSqlQuery *query) const;
|
||||
virtual void Reload() {}
|
||||
QFuture<void> BackgroundReload();
|
||||
|
||||
@@ -135,4 +135,3 @@ Q_DECLARE_METATYPE(QList<PlaylistItemPtr>)
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(PlaylistItem::Options)
|
||||
|
||||
#endif // PLAYLISTITEM_H
|
||||
|
||||
|
||||
@@ -109,21 +109,21 @@ PlaylistListContainer::PlaylistListContainer(QWidget *parent)
|
||||
ui_->remove->setDefaultAction(action_remove_);
|
||||
ui_->save_playlist->setDefaultAction(action_save_playlist_);
|
||||
|
||||
connect(action_new_folder_, SIGNAL(triggered()), SLOT(NewFolderClicked()));
|
||||
connect(action_remove_, SIGNAL(triggered()), SLOT(Delete()));
|
||||
connect(action_save_playlist_, SIGNAL(triggered()), SLOT(SavePlaylist()));
|
||||
QObject::connect(action_new_folder_, &QAction::triggered, this, &PlaylistListContainer::NewFolderClicked);
|
||||
QObject::connect(action_remove_, &QAction::triggered, this, &PlaylistListContainer::Delete);
|
||||
QObject::connect(action_save_playlist_, &QAction::triggered, this, &PlaylistListContainer::SavePlaylist);
|
||||
#ifndef Q_OS_WIN
|
||||
connect(action_copy_to_device_, SIGNAL(triggered()), SLOT(CopyToDevice()));
|
||||
QObject::connect(action_copy_to_device_, &QAction::triggered, this, &PlaylistListContainer::CopyToDevice);
|
||||
#endif
|
||||
connect(model_, SIGNAL(PlaylistPathChanged(int, QString)), SLOT(PlaylistPathChanged(int, QString)));
|
||||
QObject::connect(model_, &PlaylistListModel::PlaylistPathChanged, this, &PlaylistListContainer::PlaylistPathChanged);
|
||||
|
||||
proxy_->setSourceModel(model_);
|
||||
proxy_->setDynamicSortFilter(true);
|
||||
proxy_->sort(0);
|
||||
ui_->tree->setModel(proxy_);
|
||||
|
||||
connect(ui_->tree, SIGNAL(ItemsSelectedChanged(bool)), SLOT(ItemsSelectedChanged(bool)));
|
||||
connect(ui_->tree, SIGNAL(doubleClicked(QModelIndex)), SLOT(ItemDoubleClicked(QModelIndex)));
|
||||
QObject::connect(ui_->tree, &PlaylistListView::ItemsSelectedChanged, this, &PlaylistListContainer::ItemsSelectedChanged);
|
||||
QObject::connect(ui_->tree, &PlaylistListView::doubleClicked, this, &PlaylistListContainer::ItemDoubleClicked);
|
||||
|
||||
model_->invisibleRootItem()->setData(PlaylistListModel::Type_Folder, PlaylistListModel::Role_Type);
|
||||
|
||||
@@ -139,17 +139,17 @@ void PlaylistListContainer::SetApplication(Application *app) {
|
||||
PlaylistManager *manager = app_->playlist_manager();
|
||||
Player *player = app_->player();
|
||||
|
||||
connect(manager, SIGNAL(PlaylistAdded(int, QString, bool)), SLOT(AddPlaylist(int, QString, bool)));
|
||||
connect(manager, SIGNAL(PlaylistFavorited(int, bool)), SLOT(PlaylistFavoriteStateChanged(int, bool)));
|
||||
connect(manager, SIGNAL(PlaylistRenamed(int, QString)), SLOT(PlaylistRenamed(int, QString)));
|
||||
connect(manager, SIGNAL(CurrentChanged(Playlist*)), SLOT(CurrentChanged(Playlist*)));
|
||||
connect(manager, SIGNAL(ActiveChanged(Playlist*)), SLOT(ActiveChanged(Playlist*)));
|
||||
QObject::connect(manager, &PlaylistManager::PlaylistAdded, this, &PlaylistListContainer::AddPlaylist);
|
||||
QObject::connect(manager, &PlaylistManager::PlaylistFavorited, this, &PlaylistListContainer::PlaylistFavoriteStateChanged);
|
||||
QObject::connect(manager, &PlaylistManager::PlaylistRenamed, this, &PlaylistListContainer::PlaylistRenamed);
|
||||
QObject::connect(manager, &PlaylistManager::CurrentChanged, this, &PlaylistListContainer::CurrentChanged);
|
||||
QObject::connect(manager, &PlaylistManager::ActiveChanged, this, &PlaylistListContainer::ActiveChanged);
|
||||
|
||||
connect(model_, SIGNAL(PlaylistRenamed(int, QString)), manager, SLOT(Rename(int, QString)));
|
||||
QObject::connect(model_, &PlaylistListModel::PlaylistRenamed, manager, &PlaylistManager::Rename);
|
||||
|
||||
connect(player, SIGNAL(Paused()), SLOT(ActivePaused()));
|
||||
connect(player, SIGNAL(Playing()), SLOT(ActivePlaying()));
|
||||
connect(player, SIGNAL(Stopped()), SLOT(ActiveStopped()));
|
||||
QObject::connect(player, &Player::Paused, this, &PlaylistListContainer::ActivePaused);
|
||||
QObject::connect(player, &Player::Playing, this, &PlaylistListContainer::ActivePlaying);
|
||||
QObject::connect(player, &Player::Stopped, this, &PlaylistListContainer::ActiveStopped);
|
||||
|
||||
// Get all playlists, even ones that are hidden in the UI.
|
||||
for (const PlaylistBackend::Playlist &p : app->playlist_backend()->GetAllFavoritePlaylists()) {
|
||||
|
||||
@@ -35,9 +35,9 @@
|
||||
|
||||
PlaylistListModel::PlaylistListModel(QObject *parent) : QStandardItemModel(parent), dropping_rows_(false) {
|
||||
|
||||
connect(this, SIGNAL(dataChanged(QModelIndex, QModelIndex)), SLOT(RowsChanged(QModelIndex, QModelIndex)));
|
||||
connect(this, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)), SLOT(RowsAboutToBeRemoved(QModelIndex, int, int)));
|
||||
connect(this, SIGNAL(rowsInserted(QModelIndex, int, int)), SLOT(RowsInserted(QModelIndex, int, int)));
|
||||
QObject::connect(this,&PlaylistListModel::dataChanged, this, &PlaylistListModel::RowsChanged);
|
||||
QObject::connect(this,&PlaylistListModel::rowsAboutToBeRemoved, this, &PlaylistListModel::RowsAboutToBeRemoved);
|
||||
QObject::connect(this,&PlaylistListModel::rowsInserted, this, &PlaylistListModel::RowsInserted);
|
||||
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ bool PlaylistListModel::dropMimeData(const QMimeData *data, Qt::DropAction actio
|
||||
dropping_rows_ = false;
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
QString PlaylistListModel::ItemPath(const QStandardItem *item) const {
|
||||
@@ -75,7 +76,7 @@ void PlaylistListModel::RowsChanged(const QModelIndex &begin, const QModelIndex
|
||||
AddRowMappings(begin, end);
|
||||
}
|
||||
|
||||
void PlaylistListModel::RowsInserted(const QModelIndex &parent, int start, int end) {
|
||||
void PlaylistListModel::RowsInserted(const QModelIndex &parent, const int start, const int end) {
|
||||
|
||||
// RowsChanged will take care of these when dropping.
|
||||
if (!dropping_rows_) {
|
||||
@@ -120,7 +121,7 @@ void PlaylistListModel::AddRowItem(QStandardItem *item, const QString &parent_pa
|
||||
|
||||
}
|
||||
|
||||
void PlaylistListModel::RowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) {
|
||||
void PlaylistListModel::RowsAboutToBeRemoved(const QModelIndex &parent, const int start, const int end) {
|
||||
|
||||
for (int i = start; i <= end; ++i) {
|
||||
const QModelIndex idx = index(i, 0, parent);
|
||||
@@ -143,7 +144,7 @@ void PlaylistListModel::RowsAboutToBeRemoved(const QModelIndex &parent, int star
|
||||
|
||||
}
|
||||
|
||||
QStandardItem *PlaylistListModel::PlaylistById(int id) const {
|
||||
QStandardItem *PlaylistListModel::PlaylistById(const int id) const {
|
||||
return playlists_by_id_[id];
|
||||
}
|
||||
|
||||
@@ -200,7 +201,7 @@ QStandardItem *PlaylistListModel::NewFolder(const QString &name) const {
|
||||
|
||||
}
|
||||
|
||||
QStandardItem *PlaylistListModel::NewPlaylist(const QString &name, int id) const {
|
||||
QStandardItem *PlaylistListModel::NewPlaylist(const QString &name, const int id) const {
|
||||
|
||||
QStandardItem *ret = new QStandardItem;
|
||||
ret->setText(name);
|
||||
@@ -212,20 +213,20 @@ QStandardItem *PlaylistListModel::NewPlaylist(const QString &name, int id) const
|
||||
|
||||
}
|
||||
|
||||
bool PlaylistListModel::setData(const QModelIndex &index, const QVariant &value, int role) {
|
||||
bool PlaylistListModel::setData(const QModelIndex &idx, const QVariant &value, int role) {
|
||||
|
||||
if (!QStandardItemModel::setData(index, value, role)) {
|
||||
if (!QStandardItemModel::setData(idx, value, role)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (index.data(Role_Type).toInt()) {
|
||||
switch (idx.data(Role_Type).toInt()) {
|
||||
case Type_Playlist:
|
||||
emit PlaylistRenamed(index.data(Role_PlaylistId).toInt(), value.toString());
|
||||
emit PlaylistRenamed(idx.data(Role_PlaylistId).toInt(), value.toString());
|
||||
break;
|
||||
|
||||
case Type_Folder:
|
||||
// Walk all the children and modify their paths.
|
||||
UpdatePathsRecursive(index);
|
||||
UpdatePathsRecursive(idx);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -248,4 +249,3 @@ void PlaylistListModel::UpdatePathsRecursive(const QModelIndex &parent) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ class PlaylistListModel : public QStandardItemModel {
|
||||
QString ItemPath(const QStandardItem *item) const;
|
||||
|
||||
// Finds the playlist with the given ID, returns 0 if it doesn't exist.
|
||||
QStandardItem *PlaylistById(int id) const;
|
||||
QStandardItem *PlaylistById(const int id) const;
|
||||
|
||||
// Finds the folder with the given path, creating it (and its parents) if they
|
||||
// do not exist. Returns invisibleRootItem() if path is empty.
|
||||
@@ -75,19 +75,19 @@ class PlaylistListModel : public QStandardItemModel {
|
||||
|
||||
// Returns a new playlist item with the given name and ID. The item isn't
|
||||
// added to the model yet.
|
||||
QStandardItem *NewPlaylist(const QString &name, int id) const;
|
||||
QStandardItem *NewPlaylist(const QString &name, const int id) const;
|
||||
|
||||
// QStandardItemModel
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||
bool setData(const QModelIndex &idx, const QVariant &value, int role) override;
|
||||
|
||||
signals:
|
||||
void PlaylistPathChanged(int id, const QString &new_path);
|
||||
void PlaylistRenamed(int id, const QString &new_name);
|
||||
signals:
|
||||
void PlaylistPathChanged(int id, QString new_path);
|
||||
void PlaylistRenamed(int id, QString new_name);
|
||||
|
||||
private slots:
|
||||
void RowsChanged(const QModelIndex &begin, const QModelIndex &end);
|
||||
void RowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
|
||||
void RowsInserted(const QModelIndex &parent, int start, int end);
|
||||
void RowsAboutToBeRemoved(const QModelIndex &parent, const int start, const int end);
|
||||
void RowsInserted(const QModelIndex &parent, const int start, const int end);
|
||||
|
||||
private:
|
||||
void AddRowMappings(const QModelIndex &begin, const QModelIndex &end);
|
||||
|
||||
@@ -75,11 +75,12 @@ PlaylistManager::PlaylistManager(Application *app, QObject *parent)
|
||||
playlist_container_(nullptr),
|
||||
current_(-1),
|
||||
active_(-1),
|
||||
playlists_loading_(0)
|
||||
{
|
||||
connect(app_->player(), SIGNAL(Paused()), SLOT(SetActivePaused()));
|
||||
connect(app_->player(), SIGNAL(Playing()), SLOT(SetActivePlaying()));
|
||||
connect(app_->player(), SIGNAL(Stopped()), SLOT(SetActiveStopped()));
|
||||
playlists_loading_(0) {
|
||||
|
||||
QObject::connect(app_->player(), &Player::Paused, this, &PlaylistManager::SetActivePaused);
|
||||
QObject::connect(app_->player(), &Player::Playing, this, &PlaylistManager::SetActivePlaying);
|
||||
QObject::connect(app_->player(), &Player::Stopped, this, &PlaylistManager::SetActiveStopped);
|
||||
|
||||
}
|
||||
|
||||
PlaylistManager::~PlaylistManager() {
|
||||
@@ -96,14 +97,14 @@ void PlaylistManager::Init(CollectionBackend *collection_backend, PlaylistBacken
|
||||
parser_ = new PlaylistParser(collection_backend, this);
|
||||
playlist_container_ = playlist_container;
|
||||
|
||||
connect(collection_backend_, SIGNAL(SongsDiscovered(SongList)), SLOT(SongsDiscovered(SongList)));
|
||||
connect(collection_backend_, SIGNAL(SongsStatisticsChanged(SongList)), SLOT(SongsDiscovered(SongList)));
|
||||
connect(collection_backend_, SIGNAL(SongsRatingChanged(SongList)), SLOT(SongsDiscovered(SongList)));
|
||||
QObject::connect(collection_backend_, &CollectionBackend::SongsDiscovered, this, &PlaylistManager::SongsDiscovered);
|
||||
QObject::connect(collection_backend_, &CollectionBackend::SongsStatisticsChanged, this, &PlaylistManager::SongsDiscovered);
|
||||
QObject::connect(collection_backend_, &CollectionBackend::SongsRatingChanged, this, &PlaylistManager::SongsDiscovered);
|
||||
|
||||
for (const PlaylistBackend::Playlist &p : playlist_backend->GetAllOpenPlaylists()) {
|
||||
++playlists_loading_;
|
||||
Playlist *ret = AddPlaylist(p.id, p.name, p.special_type, p.ui_path, p.favorite);
|
||||
connect(ret, SIGNAL(PlaylistLoaded()), SLOT(PlaylistLoaded()));
|
||||
QObject::connect(ret, &Playlist::PlaylistLoaded, this, &PlaylistManager::PlaylistLoaded);
|
||||
}
|
||||
|
||||
// If no playlist exists then make a new one
|
||||
@@ -117,7 +118,7 @@ void PlaylistManager::PlaylistLoaded() {
|
||||
|
||||
Playlist *playlist = qobject_cast<Playlist*>(sender());
|
||||
if (!playlist) return;
|
||||
disconnect(playlist, SIGNAL(PlaylistLoaded()), this, SLOT(PlaylistLoaded()));
|
||||
QObject::disconnect(playlist, &Playlist::PlaylistLoaded, this, &PlaylistManager::PlaylistLoaded);
|
||||
--playlists_loading_;
|
||||
if (playlists_loading_ == 0) {
|
||||
emit AllPlaylistsLoaded();
|
||||
@@ -148,15 +149,15 @@ Playlist *PlaylistManager::AddPlaylist(const int id, const QString &name, const
|
||||
ret->set_sequence(sequence_);
|
||||
ret->set_ui_path(ui_path);
|
||||
|
||||
connect(ret, SIGNAL(CurrentSongChanged(Song)), SIGNAL(CurrentSongChanged(Song)));
|
||||
connect(ret, SIGNAL(SongMetadataChanged(Song)), SIGNAL(SongMetadataChanged(Song)));
|
||||
connect(ret, SIGNAL(PlaylistChanged()), SLOT(OneOfPlaylistsChanged()));
|
||||
connect(ret, SIGNAL(PlaylistChanged()), SLOT(UpdateSummaryText()));
|
||||
connect(ret, SIGNAL(EditingFinished(QModelIndex)), SIGNAL(EditingFinished(QModelIndex)));
|
||||
connect(ret, SIGNAL(Error(QString)), SIGNAL(Error(QString)));
|
||||
connect(ret, SIGNAL(PlayRequested(QModelIndex, Playlist::AutoScroll)), SIGNAL(PlayRequested(QModelIndex, Playlist::AutoScroll)));
|
||||
connect(playlist_container_->view(), SIGNAL(ColumnAlignmentChanged(ColumnAlignmentMap)), ret, SLOT(SetColumnAlignment(ColumnAlignmentMap)));
|
||||
connect(app_->current_albumcover_loader(), SIGNAL(AlbumCoverLoaded(Song, AlbumCoverLoaderResult)), ret, SLOT(AlbumCoverLoaded(Song, AlbumCoverLoaderResult)));
|
||||
QObject::connect(ret, &Playlist::CurrentSongChanged, this, &PlaylistManager::CurrentSongChanged);
|
||||
QObject::connect(ret, &Playlist::SongMetadataChanged, this, &PlaylistManager::SongMetadataChanged);
|
||||
QObject::connect(ret, &Playlist::PlaylistChanged, this, &PlaylistManager::OneOfPlaylistsChanged);
|
||||
QObject::connect(ret, &Playlist::PlaylistChanged, this, &PlaylistManager::UpdateSummaryText);
|
||||
QObject::connect(ret, &Playlist::EditingFinished, this, &PlaylistManager::EditingFinished);
|
||||
QObject::connect(ret, &Playlist::Error, this, &PlaylistManager::Error);
|
||||
QObject::connect(ret, &Playlist::PlayRequested, this, &PlaylistManager::PlayRequested);
|
||||
QObject::connect(playlist_container_->view(), &PlaylistView::ColumnAlignmentChanged, ret, &Playlist::SetColumnAlignment);
|
||||
QObject::connect(app_->current_albumcover_loader(), &CurrentAlbumCoverLoader::AlbumCoverLoaded, ret, &Playlist::AlbumCoverLoaded);
|
||||
|
||||
playlists_[id] = Data(ret, name);
|
||||
|
||||
|
||||
@@ -116,12 +116,12 @@ class PlaylistManagerInterface : public QObject {
|
||||
void PlaylistManagerInitialized();
|
||||
void AllPlaylistsLoaded();
|
||||
|
||||
void PlaylistAdded(const int id, QString name, const bool favorite);
|
||||
void PlaylistDeleted(const int id);
|
||||
void PlaylistClosed(const int id);
|
||||
void PlaylistRenamed(const int id, QString new_name);
|
||||
void PlaylistFavorited(const int id, const bool favorite);
|
||||
void CurrentChanged(Playlist *new_playlist, const int scroll_position = 0);
|
||||
void PlaylistAdded(int id, QString name, bool favorite);
|
||||
void PlaylistDeleted(int id);
|
||||
void PlaylistClosed(int id);
|
||||
void PlaylistRenamed(int id, QString new_name);
|
||||
void PlaylistFavorited(int id, bool favorite);
|
||||
void CurrentChanged(Playlist *new_playlist, int scroll_position = 0);
|
||||
void ActiveChanged(Playlist *new_playlist);
|
||||
|
||||
void Error(QString message);
|
||||
@@ -161,7 +161,7 @@ class PlaylistManager : public PlaylistManagerInterface {
|
||||
bool IsPlaylistOpen(const int id);
|
||||
|
||||
// Returns a pretty automatic name for playlist created from the given list of songs.
|
||||
static QString GetNameForNewPlaylist(const SongList& songs);
|
||||
static QString GetNameForNewPlaylist(const SongList &songs);
|
||||
|
||||
QItemSelection selection(const int id) const override;
|
||||
QItemSelection current_selection() const override { return selection(current_id()); }
|
||||
@@ -189,7 +189,7 @@ class PlaylistManager : public PlaylistManagerInterface {
|
||||
void Delete(const int id) override;
|
||||
bool Close(const int id) override;
|
||||
void Open(const int id) override;
|
||||
void ChangePlaylistOrder(const QList<int>& ids) override;
|
||||
void ChangePlaylistOrder(const QList<int> &ids) override;
|
||||
|
||||
void SetCurrentPlaylist(const int id) override;
|
||||
void SetActivePlaylist(const int id) override;
|
||||
@@ -208,8 +208,8 @@ class PlaylistManager : public PlaylistManagerInterface {
|
||||
|
||||
void SongChangeRequestProcessed(const QUrl& url, const bool valid) override;
|
||||
|
||||
void InsertUrls(const int id, const QList<QUrl>& urls, const int pos = -1, const bool play_now = false, const bool enqueue = false);
|
||||
void InsertSongs(const int id, const SongList& songs, const int pos = -1, const bool play_now = false, const bool enqueue = false);
|
||||
void InsertUrls(const int id, const QList<QUrl> &urls, const int pos = -1, const bool play_now = false, const bool enqueue = false);
|
||||
void InsertSongs(const int id, const SongList &songs, const int pos = -1, const bool play_now = false, const bool enqueue = false);
|
||||
// Removes items with given indices from the playlist. This operation is not undoable.
|
||||
void RemoveItemsWithoutUndo(const int id, const QList<int>& indices);
|
||||
// Remove the current playing song
|
||||
|
||||
@@ -81,8 +81,8 @@ PlaylistSequence::PlaylistSequence(QWidget *parent, SettingsProvider *settings)
|
||||
shuffle_menu_->addActions(shuffle_group->actions());
|
||||
ui_->shuffle->setMenu(shuffle_menu_);
|
||||
|
||||
connect(repeat_group, SIGNAL(triggered(QAction*)), SLOT(RepeatActionTriggered(QAction*)));
|
||||
connect(shuffle_group, SIGNAL(triggered(QAction*)), SLOT(ShuffleActionTriggered(QAction*)));
|
||||
QObject::connect(repeat_group, &QActionGroup::triggered, this, &PlaylistSequence::RepeatActionTriggered);
|
||||
QObject::connect(shuffle_group, &QActionGroup::triggered, this, &PlaylistSequence::ShuffleActionTriggered);
|
||||
|
||||
Load();
|
||||
|
||||
|
||||
@@ -76,8 +76,8 @@ class PlaylistSequence : public QWidget {
|
||||
void CycleRepeatMode();
|
||||
|
||||
signals:
|
||||
void RepeatModeChanged(const PlaylistSequence::RepeatMode mode);
|
||||
void ShuffleModeChanged(const PlaylistSequence::ShuffleMode mode);
|
||||
void RepeatModeChanged(PlaylistSequence::RepeatMode mode);
|
||||
void ShuffleModeChanged(PlaylistSequence::ShuffleMode mode);
|
||||
|
||||
private slots:
|
||||
void RepeatActionTriggered(QAction *);
|
||||
|
||||
@@ -70,19 +70,19 @@ PlaylistTabBar::PlaylistTabBar(QWidget *parent)
|
||||
setUsesScrollButtons(true);
|
||||
setTabsClosable(true);
|
||||
|
||||
close_ = menu_->addAction(IconLoader::Load("list-remove"), tr("Close playlist"), this, SLOT(Close()));
|
||||
rename_ = menu_->addAction(IconLoader::Load("edit-rename"), tr("Rename playlist..."), this, SLOT(Rename()));
|
||||
save_ = menu_->addAction(IconLoader::Load("document-save"), tr("Save playlist..."), this, SLOT(Save()));
|
||||
close_ = menu_->addAction(IconLoader::Load("list-remove"), tr("Close playlist"), this, &PlaylistTabBar::Close);
|
||||
rename_ = menu_->addAction(IconLoader::Load("edit-rename"), tr("Rename playlist..."), this, &PlaylistTabBar::RenameSlot);
|
||||
save_ = menu_->addAction(IconLoader::Load("document-save"), tr("Save playlist..."), this, &PlaylistTabBar::Save);
|
||||
menu_->addSeparator();
|
||||
|
||||
rename_editor_->setVisible(false);
|
||||
connect(rename_editor_, SIGNAL(editingFinished()), SLOT(RenameInline()));
|
||||
connect(rename_editor_, SIGNAL(EditingCanceled()), SLOT(HideEditor()));
|
||||
QObject::connect(rename_editor_, &RenameTabLineEdit::editingFinished, this, &PlaylistTabBar::RenameInline);
|
||||
QObject::connect(rename_editor_, &RenameTabLineEdit::EditingCanceled, this, &PlaylistTabBar::HideEditor);
|
||||
|
||||
connect(this, SIGNAL(currentChanged(int)), SLOT(CurrentIndexChanged(int)));
|
||||
connect(this, SIGNAL(tabMoved(int, int)), SLOT(TabMoved()));
|
||||
QObject::connect(this, &PlaylistTabBar::currentChanged, this, &PlaylistTabBar::CurrentIndexChanged);
|
||||
QObject::connect(this, &PlaylistTabBar::tabMoved, this, &PlaylistTabBar::TabMoved);
|
||||
// We can't just emit Close signal, we need to extract the playlist id first
|
||||
connect(this, SIGNAL(tabCloseRequested(int)), SLOT(CloseFromTabIndex(int)));
|
||||
QObject::connect(this, &PlaylistTabBar::tabCloseRequested, this, &PlaylistTabBar::CloseFromTabIndex);
|
||||
|
||||
}
|
||||
|
||||
@@ -98,8 +98,8 @@ void PlaylistTabBar::SetActions(QAction *new_playlist, QAction *load_playlist) {
|
||||
void PlaylistTabBar::SetManager(PlaylistManager *manager) {
|
||||
|
||||
manager_ = manager;
|
||||
connect(manager_, SIGNAL(PlaylistFavorited(int, bool)), SLOT(PlaylistFavoritedSlot(int, bool)));
|
||||
connect(manager_, SIGNAL(PlaylistManagerInitialized()), this, SLOT(PlaylistManagerInitialized()));
|
||||
QObject::connect(manager_, &PlaylistManager::PlaylistFavorited, this, &PlaylistTabBar::PlaylistFavoritedSlot);
|
||||
QObject::connect(manager_, &PlaylistManager::PlaylistManagerInitialized, this, &PlaylistTabBar::PlaylistManagerInitialized);
|
||||
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ void PlaylistTabBar::PlaylistManagerInitialized() {
|
||||
|
||||
// Signal that we are done loading and thus further changes should be committed to the db.
|
||||
initialized_ = true;
|
||||
disconnect(manager_, SIGNAL(PlaylistManagerInitialized()), this, SLOT(PlaylistManagerInitialized()));
|
||||
QObject::disconnect(manager_, &PlaylistManager::PlaylistManagerInitialized, this, &PlaylistTabBar::PlaylistManagerInitialized);
|
||||
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ void PlaylistTabBar::mouseReleaseEvent(QMouseEvent *e) {
|
||||
if (e->button() == Qt::MiddleButton) {
|
||||
// Update menu index
|
||||
menu_index_ = tabAt(e->pos());
|
||||
Close();
|
||||
CloseSlot();
|
||||
}
|
||||
|
||||
QTabBar::mouseReleaseEvent(e);
|
||||
@@ -165,7 +165,7 @@ void PlaylistTabBar::mouseDoubleClickEvent(QMouseEvent *e) {
|
||||
|
||||
}
|
||||
|
||||
void PlaylistTabBar::Rename() {
|
||||
void PlaylistTabBar::RenameSlot() {
|
||||
|
||||
if (menu_index_ == -1) return;
|
||||
|
||||
@@ -193,7 +193,7 @@ void PlaylistTabBar::HideEditor() {
|
||||
|
||||
}
|
||||
|
||||
void PlaylistTabBar::Close() {
|
||||
void PlaylistTabBar::CloseSlot() {
|
||||
|
||||
if (menu_index_ == -1) return;
|
||||
|
||||
@@ -260,15 +260,19 @@ void PlaylistTabBar::Close() {
|
||||
}
|
||||
|
||||
void PlaylistTabBar::CloseFromTabIndex(int index) {
|
||||
|
||||
// Update the global index
|
||||
menu_index_ = index;
|
||||
Close();
|
||||
CloseSlot();
|
||||
|
||||
}
|
||||
|
||||
void PlaylistTabBar::Save() {
|
||||
void PlaylistTabBar::SaveSlot() {
|
||||
|
||||
if (menu_index_ == -1) return;
|
||||
|
||||
emit Save(tabData(menu_index_).toInt());
|
||||
|
||||
}
|
||||
|
||||
int PlaylistTabBar::current_id() const {
|
||||
@@ -276,7 +280,7 @@ int PlaylistTabBar::current_id() const {
|
||||
return tabData(currentIndex()).toInt();
|
||||
}
|
||||
|
||||
int PlaylistTabBar::index_of(int id) const {
|
||||
int PlaylistTabBar::index_of(const int id) const {
|
||||
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
if (tabData(i).toInt() == id) {
|
||||
@@ -287,9 +291,9 @@ int PlaylistTabBar::index_of(int id) const {
|
||||
|
||||
}
|
||||
|
||||
void PlaylistTabBar::set_current_id(int id) { setCurrentIndex(index_of(id)); }
|
||||
void PlaylistTabBar::set_current_id(const int id) { setCurrentIndex(index_of(id)); }
|
||||
|
||||
int PlaylistTabBar::id_of(int index) const {
|
||||
int PlaylistTabBar::id_of(const int index) const {
|
||||
|
||||
if (index < 0 || index >= count()) {
|
||||
qLog(Warning) << "Playlist tab index requested is out of bounds!";
|
||||
@@ -299,34 +303,32 @@ int PlaylistTabBar::id_of(int index) const {
|
||||
|
||||
}
|
||||
|
||||
void PlaylistTabBar::set_icon_by_id(int id, const QIcon &icon) {
|
||||
void PlaylistTabBar::set_icon_by_id(const int id, const QIcon &icon) {
|
||||
setTabIcon(index_of(id), icon);
|
||||
}
|
||||
|
||||
void PlaylistTabBar::RemoveTab(int id) {
|
||||
void PlaylistTabBar::RemoveTab(const int id) {
|
||||
removeTab(index_of(id));
|
||||
}
|
||||
|
||||
void PlaylistTabBar::set_text_by_id(int id, const QString &text) {
|
||||
void PlaylistTabBar::set_text_by_id(const int id, const QString &text) {
|
||||
setTabText(index_of(id), text);
|
||||
setTabToolTip(index_of(id), text);
|
||||
}
|
||||
|
||||
void PlaylistTabBar::CurrentIndexChanged(int index) {
|
||||
void PlaylistTabBar::CurrentIndexChanged(const int index) {
|
||||
if (!suppress_current_changed_) emit CurrentIdChanged(tabData(index).toInt());
|
||||
}
|
||||
|
||||
void PlaylistTabBar::InsertTab(int id, int index, const QString &text, bool favorite) {
|
||||
void PlaylistTabBar::InsertTab(const int id, const int index, const QString &text, const bool favorite) {
|
||||
|
||||
suppress_current_changed_ = true;
|
||||
insertTab(index, text);
|
||||
setTabData(index, id);
|
||||
setTabToolTip(index, text);
|
||||
FavoriteWidget *widget = new FavoriteWidget(id, favorite);
|
||||
widget->setToolTip(
|
||||
tr("Click here to favorite this playlist so it will be saved and remain accessible"
|
||||
"through the \"Playlists\" panel on the left side bar"));
|
||||
connect(widget, SIGNAL(FavoriteStateChanged(int, bool)), SIGNAL(PlaylistFavorited(int, bool)));
|
||||
widget->setToolTip(tr("Click here to favorite this playlist so it will be saved and remain accessible through the \"Playlists\" panel on the left side bar"));
|
||||
QObject::connect(widget, &FavoriteWidget::FavoriteStateChanged, this, &PlaylistTabBar::PlaylistFavorited);
|
||||
setTabButton(index, QTabBar::LeftSide, widget);
|
||||
suppress_current_changed_ = false;
|
||||
|
||||
@@ -337,6 +339,7 @@ void PlaylistTabBar::InsertTab(int id, int index, const QString &text, bool favo
|
||||
// Update playlist tab order/visibility
|
||||
TabMoved();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void PlaylistTabBar::TabMoved() {
|
||||
@@ -434,7 +437,7 @@ bool PlaylistTabBar::event(QEvent *e) {
|
||||
|
||||
}
|
||||
|
||||
void PlaylistTabBar::PlaylistFavoritedSlot(int id, bool favorite) {
|
||||
void PlaylistTabBar::PlaylistFavoritedSlot(const int id, const bool favorite) {
|
||||
|
||||
const int index = index_of(id);
|
||||
FavoriteWidget *favorite_widget = qobject_cast<FavoriteWidget*>(tabButton(index, QTabBar::LeftSide));
|
||||
|
||||
@@ -58,24 +58,24 @@ class PlaylistTabBar : public QTabBar {
|
||||
void SetManager(PlaylistManager *manager);
|
||||
|
||||
// We use IDs to refer to tabs so the tabs can be moved around (and their indexes change).
|
||||
int index_of(int id) const;
|
||||
int index_of(const int id) const;
|
||||
int current_id() const;
|
||||
int id_of(int index) const;
|
||||
|
||||
// Utility functions that use IDs rather than indexes
|
||||
void set_current_id(int id);
|
||||
void set_icon_by_id(int id, const QIcon &icon);
|
||||
void set_text_by_id(int id, const QString &text);
|
||||
void set_current_id(const int id);
|
||||
void set_icon_by_id(const int id, const QIcon &icon);
|
||||
void set_text_by_id(const int id, const QString &text);
|
||||
|
||||
void RemoveTab(int id);
|
||||
void InsertTab(int id, int index, const QString &text, bool favorite);
|
||||
void RemoveTab(const int id);
|
||||
void InsertTab(const int id, const int index, const QString &text, const bool favorite);
|
||||
|
||||
signals:
|
||||
void CurrentIdChanged(int id);
|
||||
void Rename(int id, const QString &name);
|
||||
void Rename(int id, QString name);
|
||||
void Close(int id);
|
||||
void Save(int id);
|
||||
void PlaylistOrderChanged(const QList<int> &ids);
|
||||
void PlaylistOrderChanged(QList<int> ids);
|
||||
void PlaylistFavorited(int id, bool favorite);
|
||||
|
||||
protected:
|
||||
@@ -90,18 +90,18 @@ class PlaylistTabBar : public QTabBar {
|
||||
bool event(QEvent *e) override;
|
||||
|
||||
private slots:
|
||||
void CurrentIndexChanged(int index);
|
||||
void Rename();
|
||||
void CurrentIndexChanged(const int index);
|
||||
void RenameSlot();
|
||||
void RenameInline();
|
||||
void HideEditor();
|
||||
void Close();
|
||||
void CloseFromTabIndex(int index);
|
||||
void CloseSlot();
|
||||
void CloseFromTabIndex(const int index);
|
||||
// Used when playlist's favorite flag isn't changed from the favorite widget (e.g. from the playlistlistcontainer): will update the favorite widget
|
||||
void PlaylistFavoritedSlot(int id, bool favorite);
|
||||
void PlaylistFavoritedSlot(const int id, const bool favorite);
|
||||
// Used to signal that the playlist manager is done starting up
|
||||
void PlaylistManagerInitialized();
|
||||
void TabMoved();
|
||||
void Save();
|
||||
void SaveSlot();
|
||||
|
||||
private:
|
||||
PlaylistManager *manager_;
|
||||
|
||||
@@ -120,6 +120,7 @@ namespace PlaylistUndoCommands {
|
||||
public:
|
||||
explicit ShuffleItems(Playlist *playlist, const PlaylistItemList &new_items);
|
||||
};
|
||||
} //namespace
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // PLAYLISTUNDOCOMMANDS_H
|
||||
|
||||
@@ -192,22 +192,22 @@ PlaylistView::PlaylistView(QWidget *parent)
|
||||
setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
#endif
|
||||
|
||||
connect(header_, SIGNAL(sectionResized(int, int, int)), SLOT(SetHeaderState()));
|
||||
connect(header_, SIGNAL(sectionMoved(int, int, int)), SLOT(SetHeaderState()));
|
||||
connect(header_, SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), SLOT(SetHeaderState()));
|
||||
connect(header_, SIGNAL(SectionVisibilityChanged(int, bool)), SLOT(SetHeaderState()));
|
||||
QObject::connect(header_, &PlaylistHeader::sectionResized, this, &PlaylistView::SetHeaderState);
|
||||
QObject::connect(header_, &PlaylistHeader::sectionMoved, this, &PlaylistView::SetHeaderState);
|
||||
QObject::connect(header_, &PlaylistHeader::sortIndicatorChanged, this, &PlaylistView::SetHeaderState);
|
||||
QObject::connect(header_, &PlaylistHeader::SectionVisibilityChanged, this, &PlaylistView::SetHeaderState);
|
||||
|
||||
connect(header_, SIGNAL(sectionResized(int, int, int)), SLOT(InvalidateCachedCurrentPixmap()));
|
||||
connect(header_, SIGNAL(sectionMoved(int, int, int)), SLOT(InvalidateCachedCurrentPixmap()));
|
||||
connect(header_, SIGNAL(SectionVisibilityChanged(int, bool)), SLOT(InvalidateCachedCurrentPixmap()));
|
||||
connect(header_, SIGNAL(StretchEnabledChanged(bool)), SLOT(StretchChanged(bool)));
|
||||
QObject::connect(header_, &PlaylistHeader::sectionResized, this, &PlaylistView::InvalidateCachedCurrentPixmap);
|
||||
QObject::connect(header_, &PlaylistHeader::sectionMoved, this, &PlaylistView::InvalidateCachedCurrentPixmap);
|
||||
QObject::connect(header_, &PlaylistHeader::SectionVisibilityChanged, this, &PlaylistView::InvalidateCachedCurrentPixmap);
|
||||
QObject::connect(header_, &PlaylistHeader::StretchEnabledChanged, this, &PlaylistView::StretchChanged);
|
||||
|
||||
connect(header_, SIGNAL(SectionRatingLockStatusChanged(bool)), SLOT(SetRatingLockStatus(bool)));
|
||||
connect(header_, SIGNAL(MouseEntered()), SLOT(RatingHoverOut()));
|
||||
QObject::connect(header_, &PlaylistHeader::SectionRatingLockStatusChanged, this, &PlaylistView::SetRatingLockStatus);
|
||||
QObject::connect(header_, &PlaylistHeader::MouseEntered, this, &PlaylistView::RatingHoverOut);
|
||||
|
||||
inhibit_autoscroll_timer_->setInterval(kAutoscrollGraceTimeout * 1000);
|
||||
inhibit_autoscroll_timer_->setSingleShot(true);
|
||||
connect(inhibit_autoscroll_timer_, SIGNAL(timeout()), SLOT(InhibitAutoscrollTimeout()));
|
||||
QObject::connect(inhibit_autoscroll_timer_, &QTimer::timeout, this, &PlaylistView::InhibitAutoscrollTimeout);
|
||||
|
||||
horizontalScrollBar()->installEventFilter(this);
|
||||
verticalScrollBar()->installEventFilter(this);
|
||||
@@ -218,7 +218,7 @@ PlaylistView::PlaylistView(QWidget *parent)
|
||||
device_pixel_ratio_ = devicePixelRatioF();
|
||||
|
||||
// For fading
|
||||
connect(fade_animation_, SIGNAL(valueChanged(qreal)), SLOT(FadePreviousBackgroundImage(qreal)));
|
||||
QObject::connect(fade_animation_, &QTimeLine::valueChanged, this, &PlaylistView::FadePreviousBackgroundImage);
|
||||
fade_animation_->setDirection(QTimeLine::Backward); // 1.0 -> 0.0
|
||||
|
||||
}
|
||||
@@ -234,11 +234,11 @@ void PlaylistView::Init(Application *app) {
|
||||
|
||||
SetItemDelegates();
|
||||
|
||||
connect(app_->playlist_manager(), SIGNAL(CurrentSongChanged(Song)), this, SLOT(SongChanged(Song)));
|
||||
connect(app_->current_albumcover_loader(), SIGNAL(AlbumCoverLoaded(Song, AlbumCoverLoaderResult)), SLOT(AlbumCoverLoaded(Song, AlbumCoverLoaderResult)));
|
||||
connect(app_->player(), SIGNAL(Playing()), SLOT(StartGlowing()));
|
||||
connect(app_->player(), SIGNAL(Paused()), SLOT(StopGlowing()));
|
||||
connect(app_->player(), SIGNAL(Stopped()), SLOT(Stopped()));
|
||||
QObject::connect(app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, this, &PlaylistView::SongChanged);
|
||||
QObject::connect(app_->current_albumcover_loader(), &CurrentAlbumCoverLoader::AlbumCoverLoaded, this, &PlaylistView::AlbumCoverLoaded);
|
||||
QObject::connect(app_->player(), &Player::Playing, this, &PlaylistView::StartGlowing);
|
||||
QObject::connect(app_->player(), &Player::Paused, this, &PlaylistView::StopGlowing);
|
||||
QObject::connect(app_->player(), &Player::Stopped, this, &PlaylistView::Stopped);
|
||||
|
||||
}
|
||||
|
||||
@@ -281,8 +281,8 @@ void PlaylistView::SetItemDelegates() {
|
||||
void PlaylistView::setModel(QAbstractItemModel *m) {
|
||||
|
||||
if (model()) {
|
||||
disconnect(model(), SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(InvalidateCachedCurrentPixmap()));
|
||||
disconnect(model(), SIGNAL(layoutAboutToBeChanged()), this, SLOT(RatingHoverOut()));
|
||||
QObject::disconnect(model(), &QAbstractItemModel::dataChanged, this, &PlaylistView::InvalidateCachedCurrentPixmap);
|
||||
QObject::disconnect(model(), &QAbstractItemModel::layoutAboutToBeChanged, this, &PlaylistView::RatingHoverOut);
|
||||
|
||||
// When changing the model, always invalidate the current pixmap.
|
||||
// If a remote client uses "stop after", without invaliding the stop mark would not appear.
|
||||
@@ -291,22 +291,22 @@ void PlaylistView::setModel(QAbstractItemModel *m) {
|
||||
|
||||
QTreeView::setModel(m);
|
||||
|
||||
connect(model(), SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(InvalidateCachedCurrentPixmap()));
|
||||
connect(model(), SIGNAL(layoutAboutToBeChanged()), this, SLOT(RatingHoverOut()));
|
||||
QObject::connect(model(), &QAbstractItemModel::dataChanged, this, &PlaylistView::InvalidateCachedCurrentPixmap);
|
||||
QObject::connect(model(), &QAbstractItemModel::layoutAboutToBeChanged, this, &PlaylistView::RatingHoverOut);
|
||||
|
||||
}
|
||||
|
||||
void PlaylistView::SetPlaylist(Playlist *playlist) {
|
||||
|
||||
if (playlist_) {
|
||||
disconnect(playlist_, SIGNAL(MaybeAutoscroll(Playlist::AutoScroll)), this, SLOT(MaybeAutoscroll(Playlist::AutoScroll)));
|
||||
disconnect(playlist_, SIGNAL(destroyed()), this, SLOT(PlaylistDestroyed()));
|
||||
disconnect(playlist_, SIGNAL(QueueChanged()), this, SLOT(update()));
|
||||
QObject::disconnect(playlist_, &Playlist::MaybeAutoscroll, this, &PlaylistView::MaybeAutoscroll);
|
||||
QObject::disconnect(playlist_, &Playlist::destroyed, this, &PlaylistView::PlaylistDestroyed);
|
||||
QObject::disconnect(playlist_, &Playlist::QueueChanged, this, &PlaylistView::Update);
|
||||
|
||||
disconnect(playlist_, SIGNAL(DynamicModeChanged(bool)), this, SLOT(DynamicModeChanged(bool)));
|
||||
disconnect(dynamic_controls_, SIGNAL(Expand()), playlist_, SLOT(ExpandDynamicPlaylist()));
|
||||
disconnect(dynamic_controls_, SIGNAL(Repopulate()), playlist_, SLOT(RepopulateDynamicPlaylist()));
|
||||
disconnect(dynamic_controls_, SIGNAL(TurnOff()), playlist_, SLOT(TurnOffDynamicPlaylist()));
|
||||
QObject::disconnect(playlist_, &Playlist::DynamicModeChanged, this, &PlaylistView::DynamicModeChanged);
|
||||
QObject::disconnect(dynamic_controls_, &DynamicPlaylistControls::Expand, playlist_, &Playlist::ExpandDynamicPlaylist);
|
||||
QObject::disconnect(dynamic_controls_, &DynamicPlaylistControls::Repopulate, playlist_, &Playlist::RepopulateDynamicPlaylist);
|
||||
QObject::disconnect(dynamic_controls_, &DynamicPlaylistControls::TurnOff, playlist_, &Playlist::TurnOffDynamicPlaylist);
|
||||
}
|
||||
|
||||
playlist_ = playlist;
|
||||
@@ -316,15 +316,15 @@ void PlaylistView::SetPlaylist(Playlist *playlist) {
|
||||
JumpToLastPlayedTrack();
|
||||
playlist->set_auto_sort(auto_sort_);
|
||||
|
||||
connect(playlist_, SIGNAL(RestoreFinished()), SLOT(JumpToLastPlayedTrack()));
|
||||
connect(playlist_, SIGNAL(MaybeAutoscroll(Playlist::AutoScroll)), SLOT(MaybeAutoscroll(Playlist::AutoScroll)));
|
||||
connect(playlist_, SIGNAL(destroyed()), SLOT(PlaylistDestroyed()));
|
||||
connect(playlist_, SIGNAL(QueueChanged()), SLOT(update()));
|
||||
QObject::connect(playlist_, &Playlist::RestoreFinished, this, &PlaylistView::JumpToLastPlayedTrack);
|
||||
QObject::connect(playlist_, &Playlist::MaybeAutoscroll, this, &PlaylistView::MaybeAutoscroll);
|
||||
QObject::connect(playlist_, &Playlist::destroyed, this, &PlaylistView::PlaylistDestroyed);
|
||||
QObject::connect(playlist_, &Playlist::QueueChanged, this, &PlaylistView::Update);
|
||||
|
||||
connect(playlist_, SIGNAL(DynamicModeChanged(bool)), SLOT(DynamicModeChanged(bool)));
|
||||
connect(dynamic_controls_, SIGNAL(Expand()), playlist_, SLOT(ExpandDynamicPlaylist()));
|
||||
connect(dynamic_controls_, SIGNAL(Repopulate()), playlist_, SLOT(RepopulateDynamicPlaylist()));
|
||||
connect(dynamic_controls_, SIGNAL(TurnOff()), playlist_, SLOT(TurnOffDynamicPlaylist()));
|
||||
QObject::connect(playlist_, &Playlist::DynamicModeChanged, this, &PlaylistView::DynamicModeChanged);
|
||||
QObject::connect(dynamic_controls_, &DynamicPlaylistControls::Expand, playlist_, &Playlist::ExpandDynamicPlaylist);
|
||||
QObject::connect(dynamic_controls_, &DynamicPlaylistControls::Repopulate, playlist_, &Playlist::RepopulateDynamicPlaylist);
|
||||
QObject::connect(dynamic_controls_, &DynamicPlaylistControls::TurnOff, playlist_, &Playlist::TurnOffDynamicPlaylist);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -165,6 +165,7 @@ class PlaylistView : public QTreeView {
|
||||
void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint) override;
|
||||
|
||||
private slots:
|
||||
void Update() { update(); }
|
||||
void SetHeaderState();
|
||||
void InhibitAutoscrollTimeout();
|
||||
void MaybeAutoscroll(const Playlist::AutoScroll autoscroll);
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include <QList>
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/closure.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/songloader.h"
|
||||
#include "core/taskmanager.h"
|
||||
@@ -53,9 +52,9 @@ void SongLoaderInserter::Load(Playlist *destination, int row, bool play_now, boo
|
||||
enqueue_ = enqueue;
|
||||
enqueue_next_ = enqueue_next;
|
||||
|
||||
connect(destination, SIGNAL(destroyed()), SLOT(DestinationDestroyed()));
|
||||
connect(this, SIGNAL(PreloadFinished()), SLOT(InsertSongs()));
|
||||
connect(this, SIGNAL(EffectiveLoadFinished(SongList)), destination, SLOT(UpdateItems(SongList)));
|
||||
QObject::connect(destination, &Playlist::destroyed, this, &SongLoaderInserter::DestinationDestroyed);
|
||||
QObject::connect(this, &SongLoaderInserter::PreloadFinished, this, &SongLoaderInserter::InsertSongs);
|
||||
QObject::connect(this, &SongLoaderInserter::EffectiveLoadFinished, destination, &Playlist::UpdateItems);
|
||||
|
||||
for (const QUrl &url : urls) {
|
||||
SongLoader *loader = new SongLoader(collection_, player_, this);
|
||||
@@ -104,8 +103,8 @@ void SongLoaderInserter::LoadAudioCD(Playlist *destination, int row, bool play_n
|
||||
enqueue_next_ = enqueue_next;
|
||||
|
||||
SongLoader *loader = new SongLoader(collection_, player_, this);
|
||||
NewClosure(loader, SIGNAL(AudioCDTracksLoadFinished()), this, SLOT(AudioCDTracksLoadFinished(SongLoader*)), loader);
|
||||
connect(loader, SIGNAL(LoadAudioCDFinished(bool)), SLOT(AudioCDTagsLoaded(bool)));
|
||||
QObject::connect(loader, &SongLoader::AudioCDTracksLoadFinished, [this, loader]() { AudioCDTracksLoadFinished(loader); });
|
||||
QObject::connect(loader, &SongLoader::LoadAudioCDFinished, this, &SongLoaderInserter::AudioCDTagsLoaded);
|
||||
qLog(Info) << "Loading audio CD...";
|
||||
SongLoader::Result ret = loader->LoadAudioCD();
|
||||
if (ret == SongLoader::Error) {
|
||||
|
||||
@@ -47,9 +47,9 @@ class SongLoaderInserter : public QObject {
|
||||
void LoadAudioCD(Playlist *destination, int row, bool play_now, bool enqueue, bool enqueue_next);
|
||||
|
||||
signals:
|
||||
void Error(const QString &message);
|
||||
void Error(QString message);
|
||||
void PreloadFinished();
|
||||
void EffectiveLoadFinished(const SongList &songs);
|
||||
void EffectiveLoadFinished(SongList songs);
|
||||
|
||||
private slots:
|
||||
void DestinationDestroyed();
|
||||
|
||||
Reference in New Issue
Block a user