From 9aac4c6fc46857f98e17b922099eadbf70f9a673 Mon Sep 17 00:00:00 2001 From: ronso0 Date: Tue, 3 May 2022 20:58:36 +0200 Subject: [PATCH] Library: emit showTrackmodel when activating feature root with tracks table This makes the track menu 'Select track in library' action work in feature root views that have a tracks table (AutoDJ, Analyze), though it's not working in Browse and Recording because the BrowseModel does currently not support getTrackRows(). Issue still unresolved: When triggering this section while a feature root view with no tracks table is active the track will be selected in the previously selected tracks table. --- src/library/analysisfeature.cpp | 1 + src/library/autodj/autodjfeature.cpp | 1 + src/library/dlganalysis.h | 3 +++ src/library/recording/dlgrecording.h | 3 +++ src/library/recording/recordingfeature.cpp | 30 ++++++++++++---------- src/library/recording/recordingfeature.h | 2 ++ 6 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/library/analysisfeature.cpp b/src/library/analysisfeature.cpp index ea3a470b2e5..9ee555ed0de 100644 --- a/src/library/analysisfeature.cpp +++ b/src/library/analysisfeature.cpp @@ -127,6 +127,7 @@ void AnalysisFeature::activate() { if (m_pAnalysisView) { emit restoreSearch(m_pAnalysisView->currentSearch()); } + emit showTrackModel(m_pAnalysisView->getTableModel()); emit enableCoverArtDisplay(true); } diff --git a/src/library/autodj/autodjfeature.cpp b/src/library/autodj/autodjfeature.cpp index 4a943289f32..d4eedb9530c 100644 --- a/src/library/autodj/autodjfeature.cpp +++ b/src/library/autodj/autodjfeature.cpp @@ -162,6 +162,7 @@ void AutoDJFeature::activate() { //qDebug() << "AutoDJFeature::activate()"; emit switchToView(kViewName); emit disableSearch(); + emit showTrackModel(m_pAutoDJProcessor->getTableModel()); emit enableCoverArtDisplay(true); } diff --git a/src/library/dlganalysis.h b/src/library/dlganalysis.h index db37c5afa4a..94009908507 100644 --- a/src/library/dlganalysis.h +++ b/src/library/dlganalysis.h @@ -32,6 +32,9 @@ class DlgAnalysis : public QWidget, public Ui::DlgAnalysis, public virtual Libra void slotAddToAutoDJTop() override; void slotAddToAutoDJReplace() override; void moveSelection(int delta) override; + AnalysisLibraryTableModel* getTableModel() const { + return m_pAnalysisLibraryTableModel; + } inline const QString currentSearch() { return m_pAnalysisLibraryTableModel->currentSearch(); } diff --git a/src/library/recording/dlgrecording.h b/src/library/recording/dlgrecording.h index 14c732a5287..b68ea2caa5e 100644 --- a/src/library/recording/dlgrecording.h +++ b/src/library/recording/dlgrecording.h @@ -33,6 +33,9 @@ class DlgRecording : public QWidget, public Ui::DlgRecording, public virtual Lib void slotAddToAutoDJReplace() override; void loadSelectedTrackToGroup(const QString& group, bool play) override; void moveSelection(int delta) override; + ProxyTrackModel* getTableModel() { + return &m_proxyModel; + } inline const QString currentSearch() { return m_proxyModel.currentSearch(); } void saveCurrentViewState() override; bool restoreCurrentViewState() override; diff --git a/src/library/recording/recordingfeature.cpp b/src/library/recording/recordingfeature.cpp index f01dc54d091..5b48ecb2916 100644 --- a/src/library/recording/recordingfeature.cpp +++ b/src/library/recording/recordingfeature.cpp @@ -20,7 +20,8 @@ RecordingFeature::RecordingFeature(Library* pLibrary, RecordingManager* pRecordingManager) : LibraryFeature(pLibrary, pConfig, QStringLiteral("recordings")), m_pRecordingManager(pRecordingManager), - m_pSidebarModel(new FolderTreeModel(this)) { + m_pSidebarModel(new FolderTreeModel(this)), + m_pRecordingView(nullptr) { } QVariant RecordingFeature::title() { @@ -34,35 +35,35 @@ TreeItemModel* RecordingFeature::sidebarModel() const { void RecordingFeature::bindLibraryWidget(WLibrary* pLibraryWidget, KeyboardEventFilter *keyboard) { //The view will be deleted by LibraryWidget - DlgRecording* pRecordingView = new DlgRecording(pLibraryWidget, - m_pConfig, - m_pLibrary, - m_pRecordingManager, - keyboard); + m_pRecordingView = new DlgRecording(pLibraryWidget, + m_pConfig, + m_pLibrary, + m_pRecordingManager, + keyboard); - pRecordingView->installEventFilter(keyboard); - pLibraryWidget->registerView(kViewName, pRecordingView); - connect(pRecordingView, + m_pRecordingView->installEventFilter(keyboard); + pLibraryWidget->registerView(kViewName, m_pRecordingView); + connect(m_pRecordingView, &DlgRecording::loadTrack, this, &RecordingFeature::loadTrack); - connect(pRecordingView, + connect(m_pRecordingView, &DlgRecording::loadTrackToPlayer, this, &RecordingFeature::loadTrackToPlayer); connect(this, &RecordingFeature::refreshBrowseModel, - pRecordingView, + m_pRecordingView, &DlgRecording::refreshBrowseModel); connect(this, &RecordingFeature::requestRestoreSearch, - pRecordingView, + m_pRecordingView, &DlgRecording::slotRestoreSearch); - connect(pRecordingView, + connect(m_pRecordingView, &DlgRecording::restoreSearch, this, &RecordingFeature::restoreSearch); - connect(pRecordingView, + connect(m_pRecordingView, &DlgRecording::restoreModelState, this, &RecordingFeature::restoreModelState); @@ -72,5 +73,6 @@ void RecordingFeature::activate() { emit refreshBrowseModel(); emit switchToView(kViewName); emit disableSearch(); + emit showTrackModel(m_pRecordingView->getTableModel()); emit enableCoverArtDisplay(false); } diff --git a/src/library/recording/recordingfeature.h b/src/library/recording/recordingfeature.h index daae72076b8..2197c720cdb 100644 --- a/src/library/recording/recordingfeature.h +++ b/src/library/recording/recordingfeature.h @@ -10,6 +10,7 @@ #include "library/proxytrackmodel.h" class RecordingManager; +class DlgRecording; class RecordingFeature final : public LibraryFeature { Q_OBJECT @@ -38,4 +39,5 @@ class RecordingFeature final : public LibraryFeature { RecordingManager* const m_pRecordingManager; FolderTreeModel* m_pSidebarModel; + DlgRecording* m_pRecordingView; };