From 8b8c83d340db11843e1a331b9cbaff83d6349cf3 Mon Sep 17 00:00:00 2001 From: ronso0 Date: Tue, 27 Feb 2024 14:32:56 +0100 Subject: [PATCH 1/2] Playlist features: add/refine comments and debug output --- src/library/trackset/baseplaylistfeature.cpp | 4 ++-- src/library/trackset/playlistfeature.cpp | 12 +++++++----- src/library/trackset/setlogfeature.cpp | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/library/trackset/baseplaylistfeature.cpp b/src/library/trackset/baseplaylistfeature.cpp index 9cd8acf3556..7e9f8987c54 100644 --- a/src/library/trackset/baseplaylistfeature.cpp +++ b/src/library/trackset/baseplaylistfeature.cpp @@ -160,8 +160,8 @@ void BasePlaylistFeature::connectPlaylistDAO() { connect(&m_playlistDao, &PlaylistDAO::renamed, this, - // In "History") just the item is renamed, while in "Playlists" the - // entire sidebar model is rebuilt to resort items by name + // In "History" just the item is renamed, while in "Playlists" the + // entire sidebar model is rebuilt to re-sort items by name &BasePlaylistFeature::slotPlaylistTableRenamed); } diff --git a/src/library/trackset/playlistfeature.cpp b/src/library/trackset/playlistfeature.cpp index 38ff2575c67..f6de0f8c929 100644 --- a/src/library/trackset/playlistfeature.cpp +++ b/src/library/trackset/playlistfeature.cpp @@ -227,6 +227,7 @@ QString PlaylistFeature::fetchPlaylistLabel(int playlistId) { /// This method queries the database and does dynamic insertion /// @param selectedId entry which should be selected QModelIndex PlaylistFeature::constructChildModel(int selectedId) { + // qDebug() << "PlaylistFeature::constructChildModel() id:" << selectedId; std::vector> childrenToAdd; int selectedRow = -1; @@ -269,7 +270,7 @@ void PlaylistFeature::decorateChild(TreeItem* item, int playlistId) { } void PlaylistFeature::slotPlaylistTableChanged(int playlistId) { - //qDebug() << "slotPlaylistTableChanged() playlistId:" << playlistId; + // qDebug() << "PlaylistFeature::slotPlaylistTableChanged() playlistId:" << playlistId; enum PlaylistDAO::HiddenType type = m_playlistDao.getHiddenType(playlistId); if (type != PlaylistDAO::PLHT_NOT_HIDDEN && // not a regular playlist type != PlaylistDAO::PLHT_UNKNOWN) { // not a deleted playlist @@ -302,7 +303,7 @@ void PlaylistFeature::slotPlaylistTableChanged(int playlistId) { } void PlaylistFeature::slotPlaylistContentOrLockChanged(const QSet& playlistIds) { - // qDebug() << "slotPlaylistContentOrLockChanged() playlistId:" << playlistId; + // qDebug() << "PlaylistFeature::slotPlaylistContentOrLockChanged() playlistId:" << playlistIds; QSet idsToBeUpdated; for (const auto playlistId : std::as_const(playlistIds)) { if (m_playlistDao.getHiddenType(playlistId) == PlaylistDAO::PLHT_NOT_HIDDEN) { @@ -312,11 +313,12 @@ void PlaylistFeature::slotPlaylistContentOrLockChanged(const QSet& playlist updateChildModel(idsToBeUpdated); } -void PlaylistFeature::slotPlaylistTableRenamed( - int playlistId, const QString& newName) { +void PlaylistFeature::slotPlaylistTableRenamed(int playlistId, const QString& newName) { Q_UNUSED(newName); - // qDebug() << "slotPlaylistTableRenamed() playlistId:" << playlistId; + // qDebug() << "PlaylistFeature::slotPlaylistTableRenamed() playlistId:" << playlistId; if (m_playlistDao.getHiddenType(playlistId) == PlaylistDAO::PLHT_NOT_HIDDEN) { + // Maybe we need to re-sort the sidebar items, so call slotPlaylistTableChanged() + // in order to rebuild the model, not just updateChildModel() slotPlaylistTableChanged(playlistId); } } diff --git a/src/library/trackset/setlogfeature.cpp b/src/library/trackset/setlogfeature.cpp index 4273967e016..8d8e12c22b2 100644 --- a/src/library/trackset/setlogfeature.cpp +++ b/src/library/trackset/setlogfeature.cpp @@ -686,7 +686,7 @@ void SetlogFeature::slotPlaylistTableChanged(int playlistId) { } void SetlogFeature::slotPlaylistContentOrLockChanged(const QSet& playlistIds) { - // qDebug() << "slotPlaylistContentOrLockChanged() for" + // qDebug() << "SetlogFeature::slotPlaylistContentOrLockChanged() for" // << playlistIds.count() << "playlist(s)"; QSet idsToBeUpdated; for (const auto playlistId : std::as_const(playlistIds)) { @@ -699,7 +699,7 @@ void SetlogFeature::slotPlaylistContentOrLockChanged(const QSet& playlistId void SetlogFeature::slotPlaylistTableRenamed(int playlistId, const QString& newName) { Q_UNUSED(newName); - //qDebug() << "slotPlaylistTableRenamed() playlistId:" << playlistId; + // qDebug() << "SetlogFeature::slotPlaylistTableRenamed() Id:" << playlistId; if (m_playlistDao.getHiddenType(playlistId) == PlaylistDAO::PLHT_SET_LOG) { updateChildModel(QSet{playlistId}); } From 99dbeca2cd44599ae396d9ce088e55030502f2ac Mon Sep 17 00:00:00 2001 From: ronso0 Date: Tue, 27 Feb 2024 14:33:32 +0100 Subject: [PATCH 2/2] Lib sidebar: fix playlist label update (when renaming History items) --- src/library/trackset/baseplaylistfeature.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/library/trackset/baseplaylistfeature.cpp b/src/library/trackset/baseplaylistfeature.cpp index 7e9f8987c54..1fe43e315cd 100644 --- a/src/library/trackset/baseplaylistfeature.cpp +++ b/src/library/trackset/baseplaylistfeature.cpp @@ -738,6 +738,7 @@ void BasePlaylistFeature::updateChildModel(const QSet& playlistIds) { } } } + m_pSidebarModel->triggerRepaint(); } /// Clears the child model dynamically, but the invisible root item remains