diff options
author | Uwe Klotz <uklotz@mixxx.org> | 2020-08-22 15:47:46 +0200 |
---|---|---|
committer | Uwe Klotz <uklotz@mixxx.org> | 2020-08-23 12:09:06 +0200 |
commit | 6078973e169b8cb515104a61b1e1be681b2fe6d0 (patch) | |
tree | 7a70b6b6514447b0bccf90803be0161827d7187b /src | |
parent | a1ee9b6084ce59f691b3c5a0a99e8d03d9433f64 (diff) |
Use type-safe enum class Library::RemovalType
Diffstat (limited to 'src')
-rw-r--r-- | src/library/library.cpp | 26 | ||||
-rw-r--r-- | src/library/library.h | 4 | ||||
-rw-r--r-- | src/preferences/dialog/dlgpreflibrary.cpp | 55 |
3 files changed, 47 insertions, 38 deletions
diff --git a/src/library/library.cpp b/src/library/library.cpp index 136c92c4cb..e82533df1a 100644 --- a/src/library/library.cpp +++ b/src/library/library.cpp @@ -477,19 +477,19 @@ void Library::slotRequestAddDir(QString dir) { void Library::slotRequestRemoveDir(QString dir, RemovalType removalType) { switch (removalType) { - case Library::HideTracks: - // Mark all tracks in this directory as deleted but DON'T purge them - // in case the user re-adds them manually. - m_pTrackCollectionManager->hideAllTracks(dir); - break; - case Library::PurgeTracks: - // The user requested that we purge all metadata. - m_pTrackCollectionManager->purgeAllTracks(dir); - break; - case Library::LeaveTracksUnchanged: - default: - break; - + case RemovalType::KeepTracks: + break; + case RemovalType::HideTracks: + // Mark all tracks in this directory as deleted but DON'T purge them + // in case the user re-adds them manually. + m_pTrackCollectionManager->hideAllTracks(dir); + break; + case RemovalType::PurgeTracks: + // The user requested that we purge all metadata. + m_pTrackCollectionManager->purgeAllTracks(dir); + break; + default: + DEBUG_ASSERT(!"unreachable"); } // Remove the directory from the directory list. diff --git a/src/library/library.h b/src/library/library.h index 96ef783a23..23cdc4f43c 100644 --- a/src/library/library.h +++ b/src/library/library.h @@ -77,8 +77,8 @@ class Library: public QObject { //static Library* buildDefaultLibrary(); - enum RemovalType { - LeaveTracksUnchanged = 0, + enum class RemovalType { + KeepTracks, HideTracks, PurgeTracks }; diff --git a/src/preferences/dialog/dlgpreflibrary.cpp b/src/preferences/dialog/dlgpreflibrary.cpp index 17e7a1402f..5ec3482b91 100644 --- a/src/preferences/dialog/dlgpreflibrary.cpp +++ b/src/preferences/dialog/dlgpreflibrary.cpp @@ -30,18 +30,30 @@ DlgPrefLibrary::DlgPrefLibrary( m_iOriginalTrackTableRowHeight(Library::kDefaultRowHeightPx) { setupUi(this); - connect(this, SIGNAL(requestAddDir(QString)), - m_pLibrary, SLOT(slotRequestAddDir(QString))); - connect(this, SIGNAL(requestRemoveDir(QString, Library::RemovalType)), - m_pLibrary, SLOT(slotRequestRemoveDir(QString, Library::RemovalType))); - connect(this, SIGNAL(requestRelocateDir(QString,QString)), - m_pLibrary, SLOT(slotRequestRelocateDir(QString,QString))); - connect(PushButtonAddDir, SIGNAL(clicked()), - this, SLOT(slotAddDir())); - connect(PushButtonRemoveDir, SIGNAL(clicked()), - this, SLOT(slotRemoveDir())); - connect(PushButtonRelocateDir, SIGNAL(clicked()), - this, SLOT(slotRelocateDir())); + connect(this, + &DlgPrefLibrary::requestAddDir, + m_pLibrary, + &Library::slotRequestAddDir); + connect(this, + &DlgPrefLibrary::requestRemoveDir, + m_pLibrary, + &Library::slotRequestRemoveDir); + connect(this, + &DlgPrefLibrary::requestRelocateDir, + m_pLibrary, + &Library::slotRequestRelocateDir); + connect(PushButtonAddDir, + &QPushButton::clicked, + this, + &DlgPrefLibrary::slotAddDir); + connect(PushButtonRemoveDir, + &QPushButton::clicked, + this, + &DlgPrefLibrary::slotRemoveDir); + connect(PushButtonRelocateDir, + &QPushButton::clicked, + this, + &DlgPrefLibrary::slotRelocateDir); // Set default direction as stored in config file int rowHeight = m_pLibrary->getTrackTableRowHeight(); @@ -259,17 +271,14 @@ void DlgPrefLibrary::slotRemoveDir() { return; } - bool deleteAll = removeMsgBox.clickedButton() == deleteAllButton; - bool hideAll = removeMsgBox.clickedButton() == hideAllButton; - bool leaveUnchanged = removeMsgBox.clickedButton() == leaveUnchangedButton; - - Library::RemovalType removalType = Library::LeaveTracksUnchanged; - if (leaveUnchanged) { - removalType = Library::LeaveTracksUnchanged; - } else if (deleteAll) { - removalType = Library::PurgeTracks; - } else if (hideAll) { - removalType = Library::HideTracks; + Library::RemovalType removalType; + if (removeMsgBox.clickedButton() == hideAllButton) { + removalType = Library::RemovalType::HideTracks; + } else if (removeMsgBox.clickedButton() == deleteAllButton) { + removalType = Library::RemovalType::PurgeTracks; + } else { + DEBUG_ASSERT(removeMsgBox.clickedButton() == leaveUnchangedButton); + removalType = Library::RemovalType::KeepTracks; } emit requestRemoveDir(fd, removalType); |