Skip to content

Commit

Permalink
Merge pull request #12882 from ronso0/history-label-update
Browse files Browse the repository at this point in the history
(fix) Library sidebar: fix History label update
  • Loading branch information
daschuer authored Apr 14, 2024
2 parents 72742d9 + 99dbeca commit b6f1bb1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/library/trackset/baseplaylistfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,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);
}

Expand Down Expand Up @@ -741,6 +741,7 @@ void BasePlaylistFeature::updateChildModel(const QSet<int>& playlistIds) {
}
}
}
m_pSidebarModel->triggerRepaint();
}

/// Clears the child model dynamically, but the invisible root item remains
Expand Down
12 changes: 7 additions & 5 deletions src/library/trackset/playlistfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,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<std::unique_ptr<TreeItem>> childrenToAdd;
int selectedRow = -1;

Expand Down Expand Up @@ -254,7 +255,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
Expand Down Expand Up @@ -287,7 +288,7 @@ void PlaylistFeature::slotPlaylistTableChanged(int playlistId) {
}

void PlaylistFeature::slotPlaylistContentOrLockChanged(const QSet<int>& playlistIds) {
// qDebug() << "slotPlaylistContentOrLockChanged() playlistId:" << playlistId;
// qDebug() << "PlaylistFeature::slotPlaylistContentOrLockChanged() playlistId:" << playlistIds;
QSet<int> idsToBeUpdated;
for (const auto playlistId : std::as_const(playlistIds)) {
if (m_playlistDao.getHiddenType(playlistId) == PlaylistDAO::PLHT_NOT_HIDDEN) {
Expand All @@ -297,11 +298,12 @@ void PlaylistFeature::slotPlaylistContentOrLockChanged(const QSet<int>& 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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/library/trackset/setlogfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ void SetlogFeature::slotPlaylistTableChanged(int playlistId) {
}

void SetlogFeature::slotPlaylistContentOrLockChanged(const QSet<int>& playlistIds) {
// qDebug() << "slotPlaylistContentOrLockChanged() for"
// qDebug() << "SetlogFeature::slotPlaylistContentOrLockChanged() for"
// << playlistIds.count() << "playlist(s)";
QSet<int> idsToBeUpdated;
for (const auto playlistId : std::as_const(playlistIds)) {
Expand All @@ -738,7 +738,7 @@ void SetlogFeature::slotPlaylistContentOrLockChanged(const QSet<int>& 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<int>{playlistId});
}
Expand Down

0 comments on commit b6f1bb1

Please sign in to comment.