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

(opti/cleanup) make use of WLibrary::getCurrentTrackTableView() #13335

Merged
merged 1 commit into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions src/library/analysis/dlganalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,31 +116,6 @@ void DlgAnalysis::onSearch(const QString& text) {
m_pAnalysisLibraryTableModel->search(text);
}

void DlgAnalysis::activateSelectedTrack() {
m_pAnalysisLibraryTableView->activateSelectedTrack();
}

void DlgAnalysis::loadSelectedTrackToGroup(const QString& group, bool play) {
m_pAnalysisLibraryTableView->loadSelectedTrackToGroup(group, play);
}

void DlgAnalysis::slotAddToAutoDJBottom() {
// append to auto DJ
m_pAnalysisLibraryTableView->slotAddToAutoDJBottom();
}

void DlgAnalysis::slotAddToAutoDJTop() {
m_pAnalysisLibraryTableView->slotAddToAutoDJTop();
}

void DlgAnalysis::slotAddToAutoDJReplace() {
m_pAnalysisLibraryTableView->slotAddToAutoDJReplace();
}

void DlgAnalysis::moveSelection(int delta) {
m_pAnalysisLibraryTableView->moveSelection(delta);
}

void DlgAnalysis::tableSelectionChanged(const QItemSelection& selected,
const QItemSelection& deselected) {
Q_UNUSED(selected);
Expand Down
6 changes: 0 additions & 6 deletions src/library/analysis/dlganalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ class DlgAnalysis : public QWidget, public Ui::DlgAnalysis, public virtual Libra
void onShow() override;
bool hasFocus() const override;
void setFocus() override;
void activateSelectedTrack() override;
void loadSelectedTrackToGroup(const QString& group, bool play) override;
void slotAddToAutoDJBottom() override;
void slotAddToAutoDJTop() override;
void slotAddToAutoDJReplace() override;
void moveSelection(int delta) override;
inline const QString currentSearch() {
return m_pAnalysisLibraryTableModel->currentSearch();
}
Expand Down
12 changes: 0 additions & 12 deletions src/library/autodj/dlgautodj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,18 +248,6 @@ void DlgAutoDJ::onSearch(const QString& text) {
Q_UNUSED(text);
}

void DlgAutoDJ::activateSelectedTrack() {
m_pTrackTableView->activateSelectedTrack();
}

void DlgAutoDJ::loadSelectedTrackToGroup(const QString& group, bool play) {
m_pTrackTableView->loadSelectedTrackToGroup(group, play);
}

void DlgAutoDJ::moveSelection(int delta) {
m_pTrackTableView->moveSelection(delta);
}

void DlgAutoDJ::shufflePlaylistButton(bool) {
QModelIndexList indexList = m_pTrackTableView->selectionModel()->selectedRows();

Expand Down
3 changes: 0 additions & 3 deletions src/library/autodj/dlgautodj.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ class DlgAutoDJ : public QWidget, public Ui::DlgAutoDJ, public LibraryView {
void setFocus() override;
void pasteFromSidebar() override;
void onSearch(const QString& text) override;
void activateSelectedTrack() override;
void loadSelectedTrackToGroup(const QString& group, bool play) override;
void moveSelection(int delta) override;
void saveCurrentViewState() override;
bool restoreCurrentViewState() override;

Expand Down
96 changes: 41 additions & 55 deletions src/library/librarycontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "widget/wlibrary.h"
#include "widget/wlibrarysidebar.h"
#include "widget/wsearchlineedit.h"
#include "widget/wtracktableview.h"

namespace {
const QString kAppGroup = QStringLiteral("[App]");
Expand Down Expand Up @@ -577,64 +578,53 @@ void LibraryControl::slotLoadSelectedTrackToGroup(const QString& group, bool pla
return;
}

LibraryView* pActiveView = m_pLibraryWidget->getActiveView();
if (!pActiveView) {
return;
WTrackTableView* pTrackTableView = m_pLibraryWidget->getCurrentTrackTableView();
if (pTrackTableView) {
pTrackTableView->loadSelectedTrackToGroup(group, play);
}
pActiveView->loadSelectedTrackToGroup(group, play);
}

void LibraryControl::slotLoadSelectedIntoFirstStopped(double v) {
if (!m_pLibraryWidget) {
if (!m_pLibraryWidget || v <= 0) {
return;
}

if (v > 0) {
LibraryView* pActiveView = m_pLibraryWidget->getActiveView();
if (!pActiveView) {
return;
}
pActiveView->activateSelectedTrack();
WTrackTableView* pTrackTableView = m_pLibraryWidget->getCurrentTrackTableView();
if (pTrackTableView) {
pTrackTableView->activateSelectedTrack();
}
}

void LibraryControl::slotAutoDjAddTop(double v) {
if (!m_pLibraryWidget) {
if (!m_pLibraryWidget || v <= 0) {
return;
}

if (v > 0) {
LibraryView* pActiveView = m_pLibraryWidget->getActiveView();
if (!pActiveView) {
return;
}
pActiveView->slotAddToAutoDJTop();
WTrackTableView* pTrackTableView = m_pLibraryWidget->getCurrentTrackTableView();
if (pTrackTableView) {
pTrackTableView->addToAutoDJTop();
}
}

void LibraryControl::slotAutoDjAddBottom(double v) {
if (!m_pLibraryWidget) {
if (!m_pLibraryWidget || v <= 0) {
return;
}
if (v > 0) {
LibraryView* pActiveView = m_pLibraryWidget->getActiveView();
if (!pActiveView) {
return;
}
pActiveView->slotAddToAutoDJBottom();

WTrackTableView* pTrackTableView = m_pLibraryWidget->getCurrentTrackTableView();
if (pTrackTableView) {
pTrackTableView->addToAutoDJBottom();
}
}

void LibraryControl::slotAutoDjAddReplace(double v) {
if (!m_pLibraryWidget) {
if (!m_pLibraryWidget || v <= 0) {
return;
}
if (v > 0) {
LibraryView* pActiveView = m_pLibraryWidget->getActiveView();
if (!pActiveView) {
return;
}
pActiveView->slotAddToAutoDJReplace();

WTrackTableView* pTrackTableView = m_pLibraryWidget->getCurrentTrackTableView();
if (pTrackTableView) {
pTrackTableView->addToAutoDJReplace();
}
}

Expand All @@ -651,17 +641,15 @@ void LibraryControl::slotSelectPrevTrack(double v) {
}

void LibraryControl::slotSelectTrack(double v) {
if (!m_pLibraryWidget) {
if (!m_pLibraryWidget || v == 0) {
return;
}

LibraryView* pActiveView = m_pLibraryWidget->getActiveView();
if (!pActiveView) {
return;
WTrackTableView* pTrackTableView = m_pLibraryWidget->getCurrentTrackTableView();
if (pTrackTableView) {
int i = (int)v;
pTrackTableView->moveSelection(i);
}

int i = (int)v;
pActiveView->moveSelection(i);
}

void LibraryControl::slotMoveUp(double v) {
Expand Down Expand Up @@ -982,9 +970,13 @@ void LibraryControl::slotGoToItem(double v) {
m_pSidebarWidget->toggleSelectedItem();
}
return;
case FocusWidget::TracksTable:
m_pLibraryWidget->getActiveView()->activateSelectedTrack();
case FocusWidget::TracksTable: {
WTrackTableView* pTrackTableView = m_pLibraryWidget->getCurrentTrackTableView();
if (pTrackTableView) {
pTrackTableView->activateSelectedTrack();
}
return;
}
case FocusWidget::Dialog: {
// press & release Space (QAbstractButton::clicked() is emitted on release)
QKeyEvent pressSpace = QKeyEvent{QEvent::KeyPress, Qt::Key_Space, Qt::NoModifier};
Expand Down Expand Up @@ -1060,29 +1052,23 @@ void LibraryControl::slotDecrementFontSize(double v) {
}

void LibraryControl::slotTrackColorPrev(double v) {
if (!m_pLibraryWidget) {
if (!m_pLibraryWidget || v <= 0) {
return;
}

if (v > 0) {
LibraryView* pActiveView = m_pLibraryWidget->getActiveView();
if (!pActiveView) {
return;
}
pActiveView->assignPreviousTrackColor();
WTrackTableView* pTrackTableView = m_pLibraryWidget->getCurrentTrackTableView();
if (pTrackTableView) {
pTrackTableView->assignPreviousTrackColor();
}
}

void LibraryControl::slotTrackColorNext(double v) {
if (!m_pLibraryWidget) {
if (!m_pLibraryWidget || v <= 0) {
return;
}

if (v > 0) {
LibraryView* pActiveView = m_pLibraryWidget->getActiveView();
if (!pActiveView) {
return;
}
pActiveView->assignNextTrackColor();
WTrackTableView* pTrackTableView = m_pLibraryWidget->getCurrentTrackTableView();
if (pTrackTableView) {
pTrackTableView->assignNextTrackColor();
}
}
22 changes: 0 additions & 22 deletions src/library/libraryview.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,6 @@ class LibraryView {
virtual void pasteFromSidebar() {
}

/// If applicable, requests that the LibraryView load the selected
/// track. Does nothing otherwise.
virtual void activateSelectedTrack() {
}

virtual void slotAddToAutoDJBottom() {
}
virtual void slotAddToAutoDJTop() {
}
virtual void slotAddToAutoDJReplace() {
}
virtual void saveCurrentViewState() {
}
/// @brief restores current view state.
Expand All @@ -44,17 +33,6 @@ class LibraryView {
return false;
};

/// If applicable, requests that the LibraryView load the selected track to
/// the specified group. Does nothing otherwise.
virtual void loadSelectedTrackToGroup(const QString& group, bool play) {
Q_UNUSED(group); Q_UNUSED(play);
}

/// If a selection is applicable for this view, request that the selection be
/// increased or decreased by the provided delta. For example, for a value of
/// 1, the view should move to the next selection in the list.
virtual void moveSelection(int delta) {Q_UNUSED(delta);}

virtual TrackModel::SortColumnId getColumnIdFromCurrentIndex() {
return TrackModel::SortColumnId::Invalid;
}
Expand Down
24 changes: 0 additions & 24 deletions src/library/recording/dlgrecording.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,30 +124,6 @@ void DlgRecording::slotRestoreSearch() {
emit restoreSearch(currentSearch());
}

void DlgRecording::activateSelectedTrack() {
m_pTrackTableView->activateSelectedTrack();
}

void DlgRecording::slotAddToAutoDJBottom() {
m_pTrackTableView->slotAddToAutoDJBottom();
}

void DlgRecording::slotAddToAutoDJTop() {
m_pTrackTableView->slotAddToAutoDJTop();
}

void DlgRecording::slotAddToAutoDJReplace() {
m_pTrackTableView->slotAddToAutoDJReplace();
}

void DlgRecording::loadSelectedTrackToGroup(const QString& group, bool play) {
m_pTrackTableView->loadSelectedTrackToGroup(group, play);
}

void DlgRecording::moveSelection(int delta) {
m_pTrackTableView->moveSelection(delta);
}

void DlgRecording::slotRecButtonClicked(bool toggle) {
Q_UNUSED(toggle);
m_pRecordingManager->slotToggleRecording(1);
Expand Down
6 changes: 0 additions & 6 deletions src/library/recording/dlgrecording.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ class DlgRecording : public QWidget, public Ui::DlgRecording, public virtual Lib
void onShow() override{};
bool hasFocus() const override;
void setFocus() override;
void activateSelectedTrack() override;
void slotAddToAutoDJBottom() override;
void slotAddToAutoDJTop() override;
void slotAddToAutoDJReplace() override;
void loadSelectedTrackToGroup(const QString& group, bool play) override;
void moveSelection(int delta) override;
inline const QString currentSearch() { return m_proxyModel.currentSearch(); }
void saveCurrentViewState() override;
bool restoreCurrentViewState() override;
Expand Down
9 changes: 4 additions & 5 deletions src/widget/wlibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,11 @@ WTrackTableView* WLibrary::getCurrentTrackTableView() const {
QWidget* pCurrent = currentWidget();
WTrackTableView* pTracksView = qobject_cast<WTrackTableView*>(pCurrent);
if (!pTracksView) {
// This view is no tracks view, but maybe a special tracks view with a
// controls row (DlgAutoDJ, DlgRecording)?
// qDebug() << " view is no tracks view. look for tracks view child";
// This view is not a tracks view, but possibly a special library view
// with a controls row and a track view (DlgAutoDJ, DlgRecording etc.)?
pTracksView = pCurrent->findChild<WTrackTableView*>();
}
return pTracksView; // might be nullptr
return pTracksView; // might still be nullptr
}

bool WLibrary::isTrackInCurrentView(const TrackId& trackId) {
Expand All @@ -136,7 +135,7 @@ void WLibrary::slotSelectTrackInActiveTrackView(const TrackId& trackId) {
if (!pTracksView) {
return;
}
pTracksView->slotSelectTrack(trackId);
pTracksView->selectTrack(trackId);
}

void WLibrary::saveCurrentViewState() const {
Expand Down
Loading