Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lib sidebar: right click selection fixes #11574

Merged
merged 11 commits into from
Jun 5, 2023
2 changes: 1 addition & 1 deletion src/library/autodj/autodjprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ AutoDJProcessor::AutoDJProcessor(
m_transitionTime(kTransitionPreferenceDefault) {
m_pAutoDJTableModel = new PlaylistTableModel(this, pTrackCollectionManager,
"mixxx.db.model.autodj");
m_pAutoDJTableModel->setTableModel(iAutoDJPlaylistId);
m_pAutoDJTableModel->selectPlaylist(iAutoDJPlaylistId);
m_pAutoDJTableModel->select();

m_pShufflePlaylist = new ControlPushButton(
Expand Down
6 changes: 3 additions & 3 deletions src/library/banshee/bansheefeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void BansheeFeature::activate() {
emit featureLoadingFinished(this);
}

m_pBansheePlaylistModel->setTableModel(0); // Gets the master playlist
m_pBansheePlaylistModel->selectPlaylist(0); // Loads the master playlist
emit showTrackModel(m_pBansheePlaylistModel);
emit enableCoverArtDisplay(false);
}
Expand All @@ -120,7 +120,7 @@ void BansheeFeature::activateChild(const QModelIndex& index) {
int playlistID = item->getData().toInt();
if (playlistID > 0) {
qDebug() << "Activating " << item->getLabel();
m_pBansheePlaylistModel->setTableModel(playlistID);
m_pBansheePlaylistModel->selectPlaylist(playlistID);
emit showTrackModel(m_pBansheePlaylistModel);
emit enableCoverArtDisplay(false);
}
Expand All @@ -141,7 +141,7 @@ void BansheeFeature::appendTrackIdsFromRightClickIndex(QList<TrackId>* trackIds,
new BansheePlaylistModel(this,
m_pLibrary->trackCollectionManager(),
&m_connection);
pPlaylistModelToAdd->setTableModel(playlistID);
pPlaylistModelToAdd->selectPlaylist(playlistID);
pPlaylistModelToAdd->select();

// Copy Tracks
Expand Down
4 changes: 2 additions & 2 deletions src/library/banshee/bansheeplaylistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ void BansheePlaylistModel::dropTempTable() {
}
}

void BansheePlaylistModel::setTableModel(int playlistId) {
//qDebug() << "BansheePlaylistModel::setTableModel" << this << playlistId;
void BansheePlaylistModel::selectPlaylist(int playlistId) {
// qDebug() << "BansheePlaylistModel::selectPlaylist" << this << playlistId;
if (m_playlistId == playlistId) {
qDebug() << "Already focused on playlist " << playlistId;
return;
Expand Down
2 changes: 1 addition & 1 deletion src/library/banshee/bansheeplaylistmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class BansheePlaylistModel final : public BaseSqlTableModel {
BansheePlaylistModel(QObject* pParent, TrackCollectionManager* pTrackCollectionManager, BansheeDbConnection* pConnection);
~BansheePlaylistModel() final;

void setTableModel(int playlistId);
void selectPlaylist(int playlistId);

TrackPointer getTrack(const QModelIndex& index) const final;
TrackId getTrackId(const QModelIndex& index) const final;
Expand Down
4 changes: 2 additions & 2 deletions src/library/playlisttablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ void PlaylistTableModel::initSortColumnMapping() {
}
}

void PlaylistTableModel::setTableModel(int playlistId) {
//qDebug() << "PlaylistTableModel::setTableModel" << playlistId;
void PlaylistTableModel::selectPlaylist(int playlistId) {
// qDebug() << "PlaylistTableModel::selectPlaylist" << playlistId;
if (m_iPlaylistId == playlistId) {
qDebug() << "Already focused on playlist " << playlistId;
return;
Expand Down
2 changes: 1 addition & 1 deletion src/library/playlisttablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class PlaylistTableModel final : public TrackSetTableModel {
PlaylistTableModel(QObject* parent, TrackCollectionManager* pTrackCollectionManager, const char* settingsNamespace, bool keepDeletedTracks = false);
~PlaylistTableModel() final = default;

void setTableModel(int playlistId = -1);
void selectPlaylist(int playlistId = -1 /* kInvalidPlaylistId */);
int getPlaylist() const {
return m_iPlaylistId;
}
Expand Down
21 changes: 10 additions & 11 deletions src/library/trackset/baseplaylistfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,32 +201,30 @@ void BasePlaylistFeature::activateChild(const QModelIndex& index) {
//qDebug() << "BasePlaylistFeature::activateChild()" << index;
int playlistId = playlistIdFromIndex(index);
if (playlistId == kInvalidPlaylistId) {
// This happens if user clicks on group nodes.
// Doesn't apply to YEAR nodes in the history feature, they are linked to
// a dummy playlist.
// may happen during initialization
return;
}
m_lastClickedIndex = index;
m_lastRightClickedIndex = QModelIndex();
emit saveModelState();
m_pPlaylistTableModel->setTableModel(playlistId);
m_pPlaylistTableModel->selectPlaylist(playlistId);
emit showTrackModel(m_pPlaylistTableModel);
emit enableCoverArtDisplay(true);
}

void BasePlaylistFeature::activatePlaylist(int playlistId) {
// qDebug() << "BasePlaylistFeature::activatePlaylist()" << playlistId << index;
VERIFY_OR_DEBUG_ASSERT(playlistId != kInvalidPlaylistId) {
return;
}
QModelIndex index = indexFromPlaylistId(playlistId);
//qDebug() << "BasePlaylistFeature::activatePlaylist()" << playlistId << index;
VERIFY_OR_DEBUG_ASSERT(index.isValid()) {
return;
}
m_lastClickedIndex = index;
m_lastRightClickedIndex = QModelIndex();
emit saveModelState();
m_pPlaylistTableModel->setTableModel(playlistId);
m_pPlaylistTableModel->selectPlaylist(playlistId);
emit showTrackModel(m_pPlaylistTableModel);
emit enableCoverArtDisplay(true);
// Update selection
Expand Down Expand Up @@ -470,13 +468,13 @@ void BasePlaylistFeature::slotImportPlaylistFile(const QString& playlistFile,

// Create a temporary PlaylistTableModel for the Playlist the entries shall be imported to.
// This is used as a proxy object to write to the database.
// We cannot use m_pPlaylistTableModel since it might have another playlist selected which
// We cannot use m_pPlaylistTableModel since it might have another playlist selected which
// is not the playlist that received the right-click.
QScopedPointer<PlaylistTableModel> pPlaylistTableModel(
new PlaylistTableModel(this,
m_pLibrary->trackCollectionManager(),
"mixxx.db.model.playlist_export"));
pPlaylistTableModel->setTableModel(playlistId);
pPlaylistTableModel->selectPlaylist(playlistId);
pPlaylistTableModel->setSort(
pPlaylistTableModel->fieldIndex(
ColumnCache::COLUMN_PLAYLISTTRACKSTABLE_POSITION),
Expand Down Expand Up @@ -585,7 +583,7 @@ void BasePlaylistFeature::slotExportPlaylist() {
"mixxx.db.model.playlist_export"));

emit saveModelState();
pPlaylistTableModel->setTableModel(playlistId);
pPlaylistTableModel->selectPlaylist(playlistId);
pPlaylistTableModel->setSort(
pPlaylistTableModel->fieldIndex(
ColumnCache::COLUMN_PLAYLISTTRACKSTABLE_POSITION),
Expand Down Expand Up @@ -631,7 +629,7 @@ void BasePlaylistFeature::slotExportTrackFiles() {
"mixxx.db.model.playlist_export"));

emit saveModelState();
pPlaylistTableModel->setTableModel(playlistId);
pPlaylistTableModel->selectPlaylist(playlistId);
pPlaylistTableModel->setSort(pPlaylistTableModel->fieldIndex(
ColumnCache::COLUMN_PLAYLISTTRACKSTABLE_POSITION),
Qt::AscendingOrder);
Expand Down Expand Up @@ -720,7 +718,8 @@ void BasePlaylistFeature::htmlLinkClicked(const QUrl& link) {
}

void BasePlaylistFeature::updateChildModel(const QSet<int>& playlistIds) {
// qDebug() << "BasePlaylistFeature::updateChildModel";
// qDebug() << "BasePlaylistFeature::updateChildModel() for"
// << playlistIds.count() << "playlist(s)";
if (playlistIds.isEmpty()) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/library/trackset/playlistfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ void PlaylistFeature::slotPlaylistTableChanged(int playlistId) {

clearChildModel();
QModelIndex newIndex = constructChildModel(selectedPlaylistId);
if (newIndex.isValid()) {
if (selectedPlaylistId != kInvalidPlaylistId && newIndex.isValid()) {
// If a child index was selected and we got a new valid index select that.
// Else (root item was selected or for some reason no index could be created)
// there's nothing to do: either no child was selected earlier, or the root
Expand Down
Loading