diff options
author | Daniel Schürmann <daschuer@mixxx.org> | 2018-03-25 10:49:41 +0200 |
---|---|---|
committer | Daniel Schürmann <daschuer@mixxx.org> | 2018-03-25 10:49:41 +0200 |
commit | b7215bcb09baa614ba32a2d5fb8a0f4ce801b25e (patch) | |
tree | ae25ccff3c6043c40e3685874db7164aec05a0f0 | |
parent | 0b0c98a4f01223202a21e265e4c20558e7f67d23 (diff) |
GoToItem now switches to the track table if the tree knot has a track table
-rw-r--r-- | src/library/autodj/autodjfeature.h | 4 | ||||
-rw-r--r-- | src/library/librarycontrol.cpp | 10 | ||||
-rw-r--r-- | src/library/libraryfeature.h | 4 | ||||
-rw-r--r-- | src/library/mixxxlibraryfeature.h | 4 | ||||
-rw-r--r-- | src/library/sidebarmodel.cpp | 8 | ||||
-rw-r--r-- | src/library/sidebarmodel.h | 1 | ||||
-rw-r--r-- | src/widget/wlibrarysidebar.cpp | 10 |
7 files changed, 34 insertions, 7 deletions
diff --git a/src/library/autodj/autodjfeature.h b/src/library/autodj/autodjfeature.h index 92bcda49fe..1d447fa642 100644 --- a/src/library/autodj/autodjfeature.h +++ b/src/library/autodj/autodjfeature.h @@ -48,6 +48,10 @@ class AutoDJFeature : public LibraryFeature { TreeItemModel* getChildModel(); + bool hasTrackTable() override { + return true; + } + public slots: void activate(); diff --git a/src/library/librarycontrol.cpp b/src/library/librarycontrol.cpp index 1750062f15..7a2038e64c 100644 --- a/src/library/librarycontrol.cpp +++ b/src/library/librarycontrol.cpp @@ -461,15 +461,15 @@ void LibraryControl::slotGoToItem(double v) { if (activeView && activeView->hasFocus()) { return slotLoadSelectedIntoFirstStopped(v); } - // Otherwise toggle the sidebar item expanded state (like a double-click) - slotToggleSelectedSidebarItem(v); // Focus the library if this is a leaf node in the tree if (m_pSidebarWidget && v > 0 - && m_pSidebarWidget->hasFocus() - && m_pSidebarWidget->isLeafNodeSelected()) - { + && m_pSidebarWidget->hasFocus() + && m_pSidebarWidget->isLeafNodeSelected()) { setLibraryFocus(); + } else { + // Otherwise toggle the sidebar item expanded state + slotToggleSelectedSidebarItem(v); } // TODO(xxx) instead of remote control the widgets individual, we should // translate this into Alt+Return and handle it at each library widget diff --git a/src/library/libraryfeature.h b/src/library/libraryfeature.h index 7a9b606354..138d96c1aa 100644 --- a/src/library/libraryfeature.h +++ b/src/library/libraryfeature.h @@ -65,6 +65,10 @@ class LibraryFeature : public QObject { KeyboardEventFilter* /* keyboard */) {} virtual TreeItemModel* getChildModel() = 0; + virtual bool hasTrackTable() { + return false; + } + protected: QStringList getPlaylistFiles() const { return getPlaylistFiles(QFileDialog::ExistingFiles); diff --git a/src/library/mixxxlibraryfeature.h b/src/library/mixxxlibraryfeature.h index db79b7eb26..e959aed37c 100644 --- a/src/library/mixxxlibraryfeature.h +++ b/src/library/mixxxlibraryfeature.h @@ -42,6 +42,10 @@ class MixxxLibraryFeature : public LibraryFeature { void bindWidget(WLibrary* pLibrary, KeyboardEventFilter* pKeyboard); + bool hasTrackTable() override { + return true; + } + public slots: void activate(); void activateChild(const QModelIndex& index); diff --git a/src/library/sidebarmodel.cpp b/src/library/sidebarmodel.cpp index db4def6a63..e0943bb40f 100644 --- a/src/library/sidebarmodel.cpp +++ b/src/library/sidebarmodel.cpp @@ -293,6 +293,14 @@ bool SidebarModel::dropAccept(const QModelIndex& index, QList<QUrl> urls, return result; } +bool SidebarModel::hasTrackTable(const QModelIndex& index) const { + if (index.internalPointer() == this) { + return m_sFeatures[index.row()]->hasTrackTable(); + } + return false; +} + + bool SidebarModel::dragMoveAccept(const QModelIndex& index, QUrl url) { //qDebug() << "SidebarModel::dragMoveAccept() index=" << index << url; bool result = false; diff --git a/src/library/sidebarmodel.h b/src/library/sidebarmodel.h index 78502260e7..0040d2119d 100644 --- a/src/library/sidebarmodel.h +++ b/src/library/sidebarmodel.h @@ -33,6 +33,7 @@ class SidebarModel : public QAbstractItemModel { bool dropAccept(const QModelIndex& index, QList<QUrl> urls, QObject* pSource); bool dragMoveAccept(const QModelIndex& index, QUrl url); virtual bool hasChildren(const QModelIndex& parent = QModelIndex()) const; + bool hasTrackTable(const QModelIndex& index) const; public slots: void clicked(const QModelIndex& index); diff --git a/src/widget/wlibrarysidebar.cpp b/src/widget/wlibrarysidebar.cpp index 700c444a85..23fc7396aa 100644 --- a/src/widget/wlibrarysidebar.cpp +++ b/src/widget/wlibrarysidebar.cpp @@ -82,7 +82,7 @@ void WLibrarySidebar::dragMoveEvent(QDragMoveEvent * event) { if (sidebarModel) { accepted = false; for (const QUrl& url : urls) { - QModelIndex destIndex = this->indexAt(event->pos()); + QModelIndex destIndex = indexAt(event->pos()); if (sidebarModel->dragMoveAccept(destIndex, url)) { // We only need one URL to be valid for us // to accept the whole drag... @@ -170,7 +170,13 @@ bool WLibrarySidebar::isLeafNodeSelected() { QModelIndexList selectedIndices = this->selectionModel()->selectedRows(); if (selectedIndices.size() > 0) { QModelIndex index = selectedIndices.at(0); - return !index.model()->hasChildren(index); + if(!index.model()->hasChildren(index)) { + return true; + } + const SidebarModel* sidebarModel = dynamic_cast<const SidebarModel*>(index.model()); + if (sidebarModel) { + return sidebarModel->hasTrackTable(index); + } } return false; } |