diff options
-rw-r--r-- | src/widget/wtrackmenu.cpp | 63 | ||||
-rw-r--r-- | src/widget/wtrackmenu.h | 4 |
2 files changed, 26 insertions, 41 deletions
diff --git a/src/widget/wtrackmenu.cpp b/src/widget/wtrackmenu.cpp index 9fb3fee4aa..4fccccbc70 100644 --- a/src/widget/wtrackmenu.cpp +++ b/src/widget/wtrackmenu.cpp @@ -80,7 +80,7 @@ int WTrackMenu::getTrackCount() const { if (m_pTrackModel) { return m_trackIndexList.size(); } else { - return m_trackPointerList.size(); + return m_pTrack ? 1 : 0; } } @@ -508,10 +508,8 @@ bool WTrackMenu::isAnyTrackBpmLocked() const { } } } else { - for (const auto& pTrack : m_trackPointerList) { - if (pTrack->isBpmLocked()) { - return true; - } + if (m_pTrack && m_pTrack->isBpmLocked()) { + return true; } } return false; @@ -536,13 +534,10 @@ std::optional<std::optional<mixxx::RgbColor>> WTrackMenu::getCommonTrackColor() } } } else { - commonColor = m_trackPointerList.first()->getColor(); - for (const auto& pTrack : m_trackPointerList) { - if (commonColor != pTrack->getColor()) { - // Multiple, different colors - return std::nullopt; - } + if (!m_pTrack) { + return std::nullopt; } + commonColor = m_pTrack->getColor(); } return make_optional(commonColor); } @@ -605,7 +600,7 @@ CoverInfo WTrackMenu::getCoverInfoOfLastTrack() const { .toString(); return coverInfo; } else { - return m_trackPointerList.last()->getCoverInfoWithLocation(); + return m_pTrack->getCoverInfoWithLocation(); } } @@ -755,7 +750,7 @@ void WTrackMenu::loadTrack( if (!pTrack) { return; } - m_trackPointerList = TrackPointerList{pTrack}; + m_pTrack = pTrack; updateMenus(); } @@ -788,9 +783,8 @@ TrackIdList WTrackMenu::getTrackIds() const { trackIds.push_back(trackId); } } else { - trackIds.reserve(m_trackPointerList.size()); - for (const auto& pTrack : m_trackPointerList) { - const auto trackId = pTrack->getId(); + if (m_pTrack) { + const auto trackId = m_pTrack->getId(); DEBUG_ASSERT(trackId.isValid()); trackIds.push_back(trackId); } @@ -812,15 +806,11 @@ QList<TrackRef> WTrackMenu::getTrackRefs() const { } trackRefs.push_back(std::move(trackRef)); } - } else { - trackRefs.reserve(m_trackPointerList.size()); - for (const auto& pTrack : m_trackPointerList) { - DEBUG_ASSERT(pTrack); - auto trackRef = TrackRef::fromFileInfo( - pTrack->getFileInfo(), - pTrack->getId()); - trackRefs.push_back(std::move(trackRef)); - } + } else if (m_pTrack) { + auto trackRef = TrackRef::fromFileInfo( + m_pTrack->getFileInfo(), + m_pTrack->getId()); + trackRefs.push_back(std::move(trackRef)); } return trackRefs; } @@ -835,13 +825,10 @@ TrackPointer WTrackMenu::getFirstTrackPointer() const { // Skip unavailable tracks } return TrackPointer(); - } else { - if (m_trackPointerList.isEmpty()) { - return TrackPointer(); - } - DEBUG_ASSERT(m_trackPointerList.first()); - return m_trackPointerList.first(); + } else if (m_pTrack) { + return m_pTrack; } + return TrackPointer(); } std::unique_ptr<mixxx::TrackPointerIterator> WTrackMenu::newTrackPointerIterator() const { @@ -854,13 +841,11 @@ std::unique_ptr<mixxx::TrackPointerIterator> WTrackMenu::newTrackPointerIterator return std::make_unique<mixxx::TrackPointerModelIterator>( m_pTrackModel, m_trackIndexList); - } else { - if (m_trackPointerList.isEmpty()) { - return nullptr; - } + } else if (m_pTrack) { return std::make_unique<mixxx::TrackPointerListIterator>( - m_trackPointerList); + TrackPointerList{m_pTrack}); } + return nullptr; } int WTrackMenu::applyTrackPointerOperation( @@ -1597,7 +1582,7 @@ void WTrackMenu::slotShowDlgTrackInfo() { if (m_pTrackModel) { m_pDlgTrackInfo->loadTrack(m_trackIndexList.at(0)); } else { - m_pDlgTrackInfo->loadTrack(m_trackPointerList.at(0)); + m_pDlgTrackInfo->loadTrack(m_pTrack); } m_pDlgTrackInfo->show(); } @@ -1621,7 +1606,7 @@ void WTrackMenu::slotShowDlgTagFetcher() { if (m_pTrackModel) { m_pDlgTagFetcher->loadTrack(m_trackIndexList.at(0)); } else { - m_pDlgTagFetcher->loadTrack(m_trackPointerList.at(0)); + m_pDlgTagFetcher->loadTrack(m_pTrack); } m_pDlgTagFetcher->show(); } @@ -1737,7 +1722,7 @@ void WTrackMenu::slotPurge() { } void WTrackMenu::clearTrackSelection() { - m_trackPointerList.clear(); + m_pTrack = nullptr; m_trackIndexList.clear(); } diff --git a/src/widget/wtrackmenu.h b/src/widget/wtrackmenu.h index ced9c06554..54c8fb465b 100644 --- a/src/widget/wtrackmenu.h +++ b/src/widget/wtrackmenu.h @@ -186,8 +186,8 @@ class WTrackMenu : public QMenu { TrackModel* const m_pTrackModel; QModelIndexList m_trackIndexList; - // Source of track list when TrackModel is not set. - TrackPointerList m_trackPointerList; + /// Track being referenced when TrackModel is not set. + TrackPointer m_pTrack; const ControlProxy* m_pNumSamplers{}; const ControlProxy* m_pNumDecks{}; |