From a14c1dd3bc266489c7a78af36a4f1d4557eeecd4 Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Tue, 10 Dec 2019 12:44:03 +0100 Subject: [PATCH 1/6] Fix function signatures --- src/library/dao/playlistdao.cpp | 8 ++++---- src/library/dao/playlistdao.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/library/dao/playlistdao.cpp b/src/library/dao/playlistdao.cpp index e05a5244202..04a8be7ad43 100644 --- a/src/library/dao/playlistdao.cpp +++ b/src/library/dao/playlistdao.cpp @@ -243,7 +243,7 @@ bool PlaylistDAO::isPlaylistLocked(const int playlistId) const { return false; } -bool PlaylistDAO::removeTracksFromPlaylist(const int playlistId, const int startIndex) { +bool PlaylistDAO::removeTracksFromPlaylist(int playlistId, int startIndex) { // Retain the first track if it is loaded in a deck ScopedTransaction transaction(m_database); QSqlQuery query(m_database); @@ -415,7 +415,7 @@ void PlaylistDAO::removeHiddenTracks(const int playlistId) { } -void PlaylistDAO::removeTrackFromPlaylist(const int playlistId, const TrackId& trackId) { +void PlaylistDAO::removeTrackFromPlaylist(int playlistId, TrackId trackId) { ScopedTransaction transaction(m_database); QSqlQuery query(m_database); @@ -441,7 +441,7 @@ void PlaylistDAO::removeTrackFromPlaylist(const int playlistId, const TrackId& t } -void PlaylistDAO::removeTrackFromPlaylist(const int playlistId, const int position) { +void PlaylistDAO::removeTrackFromPlaylist(int playlistId, int position) { // qDebug() << "PlaylistDAO::removeTrackFromPlaylist" // << QThread::currentThread() << m_database.connectionName(); ScopedTransaction transaction(m_database); @@ -450,7 +450,7 @@ void PlaylistDAO::removeTrackFromPlaylist(const int playlistId, const int positi emit(changed(playlistId)); } -void PlaylistDAO::removeTracksFromPlaylist(const int playlistId, QList& positions) { +void PlaylistDAO::removeTracksFromPlaylist(int playlistId, QList positions) { // get positions in reversed order qSort(positions.begin(), positions.end(), qGreater()); diff --git a/src/library/dao/playlistdao.h b/src/library/dao/playlistdao.h index 5f9af679a7d..eb478050dfc 100644 --- a/src/library/dao/playlistdao.h +++ b/src/library/dao/playlistdao.h @@ -91,9 +91,9 @@ class PlaylistDAO : public QObject, public virtual DAO { // removes all hidden and purged Tracks from the playlist void removeHiddenTracks(const int playlistId); // Remove a track from a playlist - void removeTrackFromPlaylist(const int playlistId, const TrackId& trackId); - void removeTrackFromPlaylist(const int playlistId, const int position); - void removeTracksFromPlaylist(const int playlistId, QList& positions); + void removeTrackFromPlaylist(int playlistId, TrackId trackId); + void removeTrackFromPlaylist(int playlistId, int position); + void removeTracksFromPlaylist(int playlistId, QList positions); // Insert a track into a specific position in a playlist bool insertTrackIntoPlaylist(TrackId trackId, int playlistId, int position); // Inserts a list of tracks into playlist @@ -131,7 +131,7 @@ class PlaylistDAO : public QObject, public virtual DAO { void lockChanged(int playlistId); private: - bool removeTracksFromPlaylist(const int playlistId, const int startIndex); + bool removeTracksFromPlaylist(int playlistId, int startIndex); void removeTracksFromPlaylistInner(int playlistId, int position); void searchForDuplicateTrack(const int fromPosition, const int toPosition, From f8e9811da9cdc0b6ccf7ea280c844617d76dc960 Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Tue, 10 Dec 2019 13:24:25 +0100 Subject: [PATCH 2/6] Rename function/signal/slot parameter --- src/library/baseplaylistfeature.h | 2 +- src/library/dao/playlistdao.h | 2 +- src/library/playlistfeature.cpp | 8 ++++---- src/library/playlistfeature.h | 6 +++--- src/library/setlogfeature.cpp | 6 ++++-- src/library/setlogfeature.h | 6 +++--- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/library/baseplaylistfeature.h b/src/library/baseplaylistfeature.h index 90d585f3afc..b78538c8a24 100644 --- a/src/library/baseplaylistfeature.h +++ b/src/library/baseplaylistfeature.h @@ -48,7 +48,7 @@ class BasePlaylistFeature : public LibraryFeature { virtual void slotPlaylistTableChanged(int playlistId) = 0; virtual void slotPlaylistContentChanged(int playlistId) = 0; - virtual void slotPlaylistTableRenamed(int playlistId, QString a_strName) = 0; + virtual void slotPlaylistTableRenamed(int playlistId, QString newName) = 0; void slotCreatePlaylist(); protected slots: diff --git a/src/library/dao/playlistdao.h b/src/library/dao/playlistdao.h index eb478050dfc..aae654eec94 100644 --- a/src/library/dao/playlistdao.h +++ b/src/library/dao/playlistdao.h @@ -124,10 +124,10 @@ class PlaylistDAO : public QObject, public virtual DAO { signals: void added(int playlistId); void deleted(int playlistId); + void renamed(int playlistId, QString newName); void changed(int playlistId); void trackAdded(int playlistId, TrackId trackId, int position); void trackRemoved(int playlistId, TrackId trackId, int position); - void renamed(int playlistId, QString a_strName); void lockChanged(int playlistId); private: diff --git a/src/library/playlistfeature.cpp b/src/library/playlistfeature.cpp index e8253266dad..269f5a0fabf 100644 --- a/src/library/playlistfeature.cpp +++ b/src/library/playlistfeature.cpp @@ -245,10 +245,10 @@ void PlaylistFeature::slotPlaylistContentChanged(int playlistId) { } } - - -void PlaylistFeature::slotPlaylistTableRenamed(int playlistId, - QString /* a_strName */) { +void PlaylistFeature::slotPlaylistTableRenamed( + int playlistId, + QString newName) { + Q_UNUSED(newName); if (!m_pPlaylistTableModel) { return; } diff --git a/src/library/playlistfeature.h b/src/library/playlistfeature.h index ce6a1183aba..9900c9b5287 100644 --- a/src/library/playlistfeature.h +++ b/src/library/playlistfeature.h @@ -35,9 +35,9 @@ class PlaylistFeature : public BasePlaylistFeature { void onRightClickChild(const QPoint& globalPos, QModelIndex index); private slots: - void slotPlaylistTableChanged(int playlistId); - void slotPlaylistContentChanged(int playlistId); - void slotPlaylistTableRenamed(int playlistId, QString a_strName); + void slotPlaylistTableChanged(int playlistId) override; + void slotPlaylistContentChanged(int playlistId) override; + void slotPlaylistTableRenamed(int playlistId, QString newName) override; protected: QList createPlaylistLabels() override; diff --git a/src/library/setlogfeature.cpp b/src/library/setlogfeature.cpp index 3e4794b49cf..aced064c683 100644 --- a/src/library/setlogfeature.cpp +++ b/src/library/setlogfeature.cpp @@ -345,8 +345,10 @@ void SetlogFeature::slotPlaylistContentChanged(int playlistId) { } } -void SetlogFeature::slotPlaylistTableRenamed(int playlistId, - QString /* a_strName */) { +void SetlogFeature::slotPlaylistTableRenamed( + int playlistId, + QString newName) { + Q_UNUSED(newName); if (!m_pPlaylistTableModel) { return; } diff --git a/src/library/setlogfeature.h b/src/library/setlogfeature.h index fb460e52246..ba2869e85c0 100644 --- a/src/library/setlogfeature.h +++ b/src/library/setlogfeature.h @@ -39,9 +39,9 @@ class SetlogFeature : public BasePlaylistFeature { private slots: void slotPlayingTrackChanged(TrackPointer currentPlayingTrack); - void slotPlaylistTableChanged(int playlistId); - void slotPlaylistContentChanged(int playlistId); - void slotPlaylistTableRenamed(int playlistId, QString a_strName); + void slotPlaylistTableChanged(int playlistId) override; + void slotPlaylistContentChanged(int playlistId) override; + void slotPlaylistTableRenamed(int playlistId, QString newName) override; private: QString getRootViewHtml() const; From 9fa7fd8a676fd66869d473a5ede11e8fceb5dd55 Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Tue, 10 Dec 2019 13:25:40 +0100 Subject: [PATCH 3/6] Fix indentation/whitespaces --- src/library/dao/playlistdao.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/library/dao/playlistdao.cpp b/src/library/dao/playlistdao.cpp index 04a8be7ad43..4cd1bcc9387 100644 --- a/src/library/dao/playlistdao.cpp +++ b/src/library/dao/playlistdao.cpp @@ -406,8 +406,8 @@ void PlaylistDAO::removeHiddenTracks(const int playlistId) { } while (query.next()) { - int position = query.value(query.record().indexOf("position")).toInt(); - removeTracksFromPlaylistInner(playlistId, position); + int position = query.value(query.record().indexOf("position")).toInt(); + removeTracksFromPlaylistInner(playlistId, position); } transaction.commit(); @@ -431,7 +431,7 @@ void PlaylistDAO::removeTrackFromPlaylist(int playlistId, TrackId trackId) { } while (query.next()) { - int position = query.value(query.record().indexOf("position")).toInt(); + int position = query.value(query.record().indexOf("position")).toInt(); removeTracksFromPlaylistInner(playlistId, position); } @@ -457,9 +457,8 @@ void PlaylistDAO::removeTracksFromPlaylist(int playlistId, QList positions) //qDebug() << "PlaylistDAO::removeTrackFromPlaylist" // << QThread::currentThread() << m_database.connectionName(); ScopedTransaction transaction(m_database); - QSqlQuery query(m_database); - foreach (int position , positions) { - removeTracksFromPlaylistInner(playlistId, position); + for (const auto position : positions) { + removeTracksFromPlaylistInner(playlistId, position); } transaction.commit(); emit(changed(playlistId)); From 79a93f6fb6b5115faadfa1150a0b4d980bb0957d Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Tue, 10 Dec 2019 13:26:08 +0100 Subject: [PATCH 4/6] Send a single signal after modifying multiple playlists --- src/library/baseplaylistfeature.cpp | 58 ++++++++++++++++++----------- src/library/baseplaylistfeature.h | 2 +- src/library/dao/playlistdao.cpp | 43 ++++++++++++--------- src/library/dao/playlistdao.h | 7 ++-- src/library/playlistfeature.cpp | 13 ++++--- src/library/playlistfeature.h | 2 +- src/library/playlisttablemodel.cpp | 10 +++-- src/library/playlisttablemodel.h | 2 +- src/library/setlogfeature.cpp | 13 ++++--- src/library/setlogfeature.h | 2 +- 10 files changed, 91 insertions(+), 61 deletions(-) diff --git a/src/library/baseplaylistfeature.cpp b/src/library/baseplaylistfeature.cpp index c5e64c61767..62dcb61794f 100644 --- a/src/library/baseplaylistfeature.cpp +++ b/src/library/baseplaylistfeature.cpp @@ -74,29 +74,45 @@ BasePlaylistFeature::BasePlaylistFeature(QObject* parent, this, SLOT(slotExportTrackFiles())); m_pAnalyzePlaylistAction = new QAction(tr("Analyze entire Playlist"), this); - connect(m_pAnalyzePlaylistAction, SIGNAL(triggered()), - this, SLOT(slotAnalyzePlaylist())); - - connect(&m_playlistDao, SIGNAL(added(int)), - this, SLOT(slotPlaylistTableChanged(int))); - - connect(&m_playlistDao, SIGNAL(deleted(int)), - this, SLOT(slotPlaylistTableChanged(int))); - - connect(&m_playlistDao, SIGNAL(renamed(int,QString)), - this, SLOT(slotPlaylistTableRenamed(int,QString))); - - connect(&m_playlistDao, SIGNAL(changed(int)), - this, SLOT(slotPlaylistContentChanged(int))); - - connect(&m_playlistDao, SIGNAL(lockChanged(int)), - this, SLOT(slotPlaylistTableChanged(int))); + connect(m_pAnalyzePlaylistAction, + &QAction::triggered, + this, + &BasePlaylistFeature::slotAnalyzePlaylist); + + connect(&m_playlistDao, + &PlaylistDAO::added, + this, + &BasePlaylistFeature::slotPlaylistTableChanged); + + connect(&m_playlistDao, + &PlaylistDAO::deleted, + this, + &BasePlaylistFeature::slotPlaylistTableChanged); + + connect(&m_playlistDao, + &PlaylistDAO::renamed, + this, + &BasePlaylistFeature::slotPlaylistTableRenamed); + + connect(&m_playlistDao, + &PlaylistDAO::tracksChanged, + this, + &BasePlaylistFeature::slotPlaylistContentChanged); + + connect(&m_playlistDao, + &PlaylistDAO::lockChanged, + this, + &BasePlaylistFeature::slotPlaylistTableChanged); Library* pLibrary = static_cast(parent); - connect(pLibrary, SIGNAL(trackSelected(TrackPointer)), - this, SLOT(slotTrackSelected(TrackPointer))); - connect(pLibrary, SIGNAL(switchToView(const QString&)), - this, SLOT(slotResetSelectedTrack())); + connect(pLibrary, + &Library::trackSelected, + this, + &BasePlaylistFeature::slotTrackSelected); + connect(pLibrary, + &Library::switchToView, + this, + &BasePlaylistFeature::slotResetSelectedTrack); } BasePlaylistFeature::~BasePlaylistFeature() { diff --git a/src/library/baseplaylistfeature.h b/src/library/baseplaylistfeature.h index b78538c8a24..88e6d3c525c 100644 --- a/src/library/baseplaylistfeature.h +++ b/src/library/baseplaylistfeature.h @@ -47,7 +47,7 @@ class BasePlaylistFeature : public LibraryFeature { virtual void htmlLinkClicked(const QUrl& link); virtual void slotPlaylistTableChanged(int playlistId) = 0; - virtual void slotPlaylistContentChanged(int playlistId) = 0; + virtual void slotPlaylistContentChanged(QSet playlistIds) = 0; virtual void slotPlaylistTableRenamed(int playlistId, QString newName) = 0; void slotCreatePlaylist(); diff --git a/src/library/dao/playlistdao.cpp b/src/library/dao/playlistdao.cpp index 4cd1bcc9387..2734cc82b65 100644 --- a/src/library/dao/playlistdao.cpp +++ b/src/library/dao/playlistdao.cpp @@ -256,7 +256,7 @@ bool PlaylistDAO::removeTracksFromPlaylist(int playlistId, int startIndex) { return false; } transaction.commit(); - emit(changed(playlistId)); + emit tracksChanged(QSet{playlistId}); return true; } @@ -298,7 +298,7 @@ bool PlaylistDAO::appendTracksToPlaylist(const QList& trackIds, const i // TODO(XXX) don't emit if the track didn't add successfully. emit(trackAdded(playlistId, trackId, insertPosition++)); } - emit(changed(playlistId)); + emit tracksChanged(QSet{playlistId}); return true; } @@ -411,13 +411,18 @@ void PlaylistDAO::removeHiddenTracks(const int playlistId) { } transaction.commit(); - emit(changed(playlistId)); + emit tracksChanged(QSet{playlistId}); } -void PlaylistDAO::removeTrackFromPlaylist(int playlistId, TrackId trackId) { +void PlaylistDAO::removeTracksFromPlaylistById(int playlistId, TrackId trackId) { ScopedTransaction transaction(m_database); + removeTracksFromPlaylistByIdInner(playlistId, trackId); + transaction.commit(); + emit tracksChanged(QSet{playlistId}); +} +void PlaylistDAO::removeTracksFromPlaylistByIdInner(int playlistId, TrackId trackId) { QSqlQuery query(m_database); query.prepare("SELECT position FROM PlaylistTracks WHERE playlist_id=:id " "AND track_id=:track_id"); @@ -433,11 +438,7 @@ void PlaylistDAO::removeTrackFromPlaylist(int playlistId, TrackId trackId) { while (query.next()) { int position = query.value(query.record().indexOf("position")).toInt(); removeTracksFromPlaylistInner(playlistId, position); - } - - transaction.commit(); - emit(changed(playlistId)); } @@ -447,7 +448,7 @@ void PlaylistDAO::removeTrackFromPlaylist(int playlistId, int position) { ScopedTransaction transaction(m_database); removeTracksFromPlaylistInner(playlistId, position); transaction.commit(); - emit(changed(playlistId)); + emit tracksChanged(QSet{playlistId}); } void PlaylistDAO::removeTracksFromPlaylist(int playlistId, QList positions) { @@ -461,7 +462,7 @@ void PlaylistDAO::removeTracksFromPlaylist(int playlistId, QList positions) removeTracksFromPlaylistInner(playlistId, position); } transaction.commit(); - emit(changed(playlistId)); + emit tracksChanged(QSet{playlistId}); } void PlaylistDAO::removeTracksFromPlaylistInner(int playlistId, int position) { @@ -549,7 +550,7 @@ bool PlaylistDAO::insertTrackIntoPlaylist(TrackId trackId, const int playlistId, m_playlistsTrackIsIn.insert(trackId, playlistId); emit(trackAdded(playlistId, trackId, position)); - emit(changed(playlistId)); + emit tracksChanged(QSet{playlistId}); return true; } @@ -610,7 +611,7 @@ int PlaylistDAO::insertTracksIntoPlaylist(const QList& trackIds, // TODO(XXX) The position is wrong if any track failed to insert. emit(trackAdded(playlistId, trackId, insertPositon++)); } - emit(changed(playlistId)); + emit tracksChanged(QSet{playlistId}); return tracksAdded; } @@ -723,7 +724,7 @@ bool PlaylistDAO::copyPlaylistTracks(const int sourcePlaylistID, const int targe m_playlistsTrackIsIn.insert(copiedTrackId, targetPlaylistID); emit(trackAdded(targetPlaylistID, copiedTrackId, copiedPosition)); } - emit(changed(targetPlaylistID)); + emit tracksChanged(QSet{targetPlaylistID}); return true; } @@ -749,14 +750,22 @@ int PlaylistDAO::getMaxPosition(const int playlistId) const { void PlaylistDAO::removeTracksFromPlaylists(const QList& trackIds) { // copy the hash, because there is no guarantee that "it" is valid after remove QMultiHash playlistsTrackIsInCopy = m_playlistsTrackIsIn; - for (const auto& trackId: trackIds) { + QSet playlistIds; + + ScopedTransaction transaction(m_database); + for (const auto& trackId : trackIds) { for (auto it = playlistsTrackIsInCopy.constBegin(); it != playlistsTrackIsInCopy.constEnd(); ++it) { if (it.key() == trackId) { - removeTrackFromPlaylist(it.value(), trackId); + const auto playlistId = it.value(); + removeTracksFromPlaylistByIdInner(playlistId, trackId); + playlistIds.insert(playlistId); } } } + transaction.commit(); + + emit tracksChanged(playlistIds); } int PlaylistDAO::tracksInPlaylist(const int playlistId) const { @@ -829,7 +838,7 @@ void PlaylistDAO::moveTrack(const int playlistId, const int oldPosition, const i qDebug() << query.lastError(); } - emit(changed(playlistId)); + emit tracksChanged(QSet{playlistId}); } void PlaylistDAO::searchForDuplicateTrack(const int fromPosition, @@ -993,7 +1002,7 @@ void PlaylistDAO::shuffleTracks(const int playlistId, const QList& position } transaction.commit(); - emit(changed(playlistId)); + emit tracksChanged(QSet{playlistId}); } bool PlaylistDAO::isTrackInPlaylist(TrackId trackId, const int playlistId) const { diff --git a/src/library/dao/playlistdao.h b/src/library/dao/playlistdao.h index aae654eec94..941525a440a 100644 --- a/src/library/dao/playlistdao.h +++ b/src/library/dao/playlistdao.h @@ -91,9 +91,9 @@ class PlaylistDAO : public QObject, public virtual DAO { // removes all hidden and purged Tracks from the playlist void removeHiddenTracks(const int playlistId); // Remove a track from a playlist - void removeTrackFromPlaylist(int playlistId, TrackId trackId); void removeTrackFromPlaylist(int playlistId, int position); void removeTracksFromPlaylist(int playlistId, QList positions); + void removeTracksFromPlaylistById(int playlistId, TrackId trackId); // Insert a track into a specific position in a playlist bool insertTrackIntoPlaylist(TrackId trackId, int playlistId, int position); // Inserts a list of tracks into playlist @@ -125,14 +125,15 @@ class PlaylistDAO : public QObject, public virtual DAO { void added(int playlistId); void deleted(int playlistId); void renamed(int playlistId, QString newName); - void changed(int playlistId); + void lockChanged(int playlistId); void trackAdded(int playlistId, TrackId trackId, int position); void trackRemoved(int playlistId, TrackId trackId, int position); - void lockChanged(int playlistId); + void tracksChanged(QSet playlistIds); // added/removed/reordered private: bool removeTracksFromPlaylist(int playlistId, int startIndex); void removeTracksFromPlaylistInner(int playlistId, int position); + void removeTracksFromPlaylistByIdInner(int playlistId, TrackId trackId); void searchForDuplicateTrack(const int fromPosition, const int toPosition, TrackId trackID, diff --git a/src/library/playlistfeature.cpp b/src/library/playlistfeature.cpp index 269f5a0fabf..c199cd670b4 100644 --- a/src/library/playlistfeature.cpp +++ b/src/library/playlistfeature.cpp @@ -232,16 +232,17 @@ void PlaylistFeature::slotPlaylistTableChanged(int playlistId) { } } -void PlaylistFeature::slotPlaylistContentChanged(int playlistId) { +void PlaylistFeature::slotPlaylistContentChanged(QSet playlistIds) { if (!m_pPlaylistTableModel) { return; } - //qDebug() << "slotPlaylistContentChanged() playlistId:" << playlistId; - enum PlaylistDAO::HiddenType type = m_playlistDao.getHiddenType(playlistId); - if (type == PlaylistDAO::PLHT_NOT_HIDDEN || - type == PlaylistDAO::PLHT_UNKNOWN) { // In case of a deleted Playlist - updateChildModel(playlistId); + for (const auto playlistId : playlistIds) { + enum PlaylistDAO::HiddenType type = m_playlistDao.getHiddenType(playlistId); + if (type == PlaylistDAO::PLHT_NOT_HIDDEN || + type == PlaylistDAO::PLHT_UNKNOWN) { // In case of a deleted Playlist + updateChildModel(playlistId); + } } } diff --git a/src/library/playlistfeature.h b/src/library/playlistfeature.h index 9900c9b5287..545f4907ddd 100644 --- a/src/library/playlistfeature.h +++ b/src/library/playlistfeature.h @@ -36,7 +36,7 @@ class PlaylistFeature : public BasePlaylistFeature { private slots: void slotPlaylistTableChanged(int playlistId) override; - void slotPlaylistContentChanged(int playlistId) override; + void slotPlaylistContentChanged(QSet playlistIds) override; void slotPlaylistTableRenamed(int playlistId, QString newName) override; protected: diff --git a/src/library/playlisttablemodel.cpp b/src/library/playlisttablemodel.cpp index d6ac44e729d..fc71087da51 100644 --- a/src/library/playlisttablemodel.cpp +++ b/src/library/playlisttablemodel.cpp @@ -68,8 +68,10 @@ void PlaylistTableModel::setTableModel(int playlistId) { setDefaultSort(fieldIndex(ColumnCache::COLUMN_PLAYLISTTRACKSTABLE_POSITION), Qt::AscendingOrder); setSort(defaultSortColumn(), defaultSortOrder()); - connect(&m_pTrackCollection->getPlaylistDAO(), SIGNAL(changed(int)), - this, SLOT(playlistChanged(int))); + connect(&m_pTrackCollection->getPlaylistDAO(), + &PlaylistDAO::tracksChanged, + this, + &PlaylistTableModel::playlistsChanged); } int PlaylistTableModel::addTracks(const QModelIndex& index, @@ -259,8 +261,8 @@ TrackModel::CapabilitiesFlags PlaylistTableModel::getCapabilities() const { return caps; } -void PlaylistTableModel::playlistChanged(int playlistId) { - if (playlistId == m_iPlaylistId) { +void PlaylistTableModel::playlistsChanged(QSet playlistIds) { + if (playlistIds.contains(m_iPlaylistId)) { select(); // Repopulate the data model. } } diff --git a/src/library/playlisttablemodel.h b/src/library/playlisttablemodel.h index 070a187f269..e282612059c 100644 --- a/src/library/playlisttablemodel.h +++ b/src/library/playlisttablemodel.h @@ -33,7 +33,7 @@ class PlaylistTableModel : public BaseSqlTableModel { CapabilitiesFlags getCapabilities() const final; private slots: - void playlistChanged(int playlistId); + void playlistsChanged(QSet playlistIds); private: int m_iPlaylistId; diff --git a/src/library/setlogfeature.cpp b/src/library/setlogfeature.cpp index aced064c683..5ccddcca3d1 100644 --- a/src/library/setlogfeature.cpp +++ b/src/library/setlogfeature.cpp @@ -332,16 +332,17 @@ void SetlogFeature::slotPlaylistTableChanged(int playlistId) { } } -void SetlogFeature::slotPlaylistContentChanged(int playlistId) { +void SetlogFeature::slotPlaylistContentChanged(QSet playlistIds) { if (!m_pPlaylistTableModel) { return; } - //qDebug() << "slotPlaylistContentChanged() playlistId:" << playlistId; - enum PlaylistDAO::HiddenType type = m_playlistDao.getHiddenType(playlistId); - if (type == PlaylistDAO::PLHT_SET_LOG || - type == PlaylistDAO::PLHT_UNKNOWN) { // In case of a deleted Playlist - updateChildModel(playlistId); + for (const auto playlistId : playlistIds) { + enum PlaylistDAO::HiddenType type = m_playlistDao.getHiddenType(playlistId); + if (type == PlaylistDAO::PLHT_SET_LOG || + type == PlaylistDAO::PLHT_UNKNOWN) { // In case of a deleted Playlist + updateChildModel(playlistId); + } } } diff --git a/src/library/setlogfeature.h b/src/library/setlogfeature.h index ba2869e85c0..c7a3b2a56d8 100644 --- a/src/library/setlogfeature.h +++ b/src/library/setlogfeature.h @@ -40,7 +40,7 @@ class SetlogFeature : public BasePlaylistFeature { private slots: void slotPlayingTrackChanged(TrackPointer currentPlayingTrack); void slotPlaylistTableChanged(int playlistId) override; - void slotPlaylistContentChanged(int playlistId) override; + void slotPlaylistContentChanged(QSet playlistIds) override; void slotPlaylistTableRenamed(int playlistId, QString newName) override; private: From 98ce67d871c4ba1551ef2f65a6555811d16709ad Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Wed, 11 Dec 2019 09:14:06 +0100 Subject: [PATCH 5/6] Fix Travis CI build for macOS --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index fee31289277..bed9ac30014 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,6 +52,7 @@ before_install: # Virtual X, needed for analyzer waveform tests - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export DISPLAY=:99.0 ; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sh -e /etc/init.d/xvfb start ; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install scons portaudio libsndfile libogg libvorbis portmidi taglib libshout protobuf flac ffmpeg qt chromaprint rubberband libmodplug libid3tag libmad mp4v2 faad2 wavpack opusfile lilv; fi install: From d1e0d1e97b02ee77b924f60d8c439d3ead5c18d8 Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Thu, 12 Dec 2019 00:05:44 +0100 Subject: [PATCH 6/6] Prevent temporary copies of QList --- src/library/dao/playlistdao.cpp | 2 +- src/library/playlistfeature.cpp | 2 +- src/library/playlisttablemodel.cpp | 4 +++- src/library/setlogfeature.cpp | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/library/dao/playlistdao.cpp b/src/library/dao/playlistdao.cpp index 2734cc82b65..c81a702ffa2 100644 --- a/src/library/dao/playlistdao.cpp +++ b/src/library/dao/playlistdao.cpp @@ -458,7 +458,7 @@ void PlaylistDAO::removeTracksFromPlaylist(int playlistId, QList positions) //qDebug() << "PlaylistDAO::removeTrackFromPlaylist" // << QThread::currentThread() << m_database.connectionName(); ScopedTransaction transaction(m_database); - for (const auto position : positions) { + for (const auto position : qAsConst(positions)) { removeTracksFromPlaylistInner(playlistId, position); } transaction.commit(); diff --git a/src/library/playlistfeature.cpp b/src/library/playlistfeature.cpp index c199cd670b4..f87e42e797d 100644 --- a/src/library/playlistfeature.cpp +++ b/src/library/playlistfeature.cpp @@ -237,7 +237,7 @@ void PlaylistFeature::slotPlaylistContentChanged(QSet playlistIds) { return; } - for (const auto playlistId : playlistIds) { + for (const auto playlistId : qAsConst(playlistIds)) { enum PlaylistDAO::HiddenType type = m_playlistDao.getHiddenType(playlistId); if (type == PlaylistDAO::PLHT_NOT_HIDDEN || type == PlaylistDAO::PLHT_UNKNOWN) { // In case of a deleted Playlist diff --git a/src/library/playlisttablemodel.cpp b/src/library/playlisttablemodel.cpp index fc71087da51..06a77138932 100644 --- a/src/library/playlisttablemodel.cpp +++ b/src/library/playlisttablemodel.cpp @@ -132,7 +132,9 @@ void PlaylistTableModel::removeTracks(const QModelIndexList& indices) { trackPositions.append(trackPosition); } - m_pTrackCollection->getPlaylistDAO().removeTracksFromPlaylist(m_iPlaylistId, trackPositions); + m_pTrackCollection->getPlaylistDAO().removeTracksFromPlaylist( + m_iPlaylistId, + std::move(trackPositions)); } void PlaylistTableModel::moveTrack(const QModelIndex& sourceIndex, diff --git a/src/library/setlogfeature.cpp b/src/library/setlogfeature.cpp index 5ccddcca3d1..c6bc6c98c40 100644 --- a/src/library/setlogfeature.cpp +++ b/src/library/setlogfeature.cpp @@ -337,7 +337,7 @@ void SetlogFeature::slotPlaylistContentChanged(QSet playlistIds) { return; } - for (const auto playlistId : playlistIds) { + for (const auto playlistId : qAsConst(playlistIds)) { enum PlaylistDAO::HiddenType type = m_playlistDao.getHiddenType(playlistId); if (type == PlaylistDAO::PLHT_SET_LOG || type == PlaylistDAO::PLHT_UNKNOWN) { // In case of a deleted Playlist