diff options
author | Harshit Maurya <hmaurya999@gmail.com> | 2020-04-14 01:54:24 +0530 |
---|---|---|
committer | Harshit Maurya <hmaurya999@gmail.com> | 2020-04-14 01:54:24 +0530 |
commit | 134591271270d20f8e034664d9f572faea363205 (patch) | |
tree | bc395e36b986576d9e9fd3c6dfd1ffbec73352fa /src/widget/wtracktableview.cpp | |
parent | ba7fdfa7c3518a5b1bceb885b0348c7aca725883 (diff) |
WTrackTableView: use unique_ptr to store m_pMenu
Diffstat (limited to 'src/widget/wtracktableview.cpp')
-rw-r--r-- | src/widget/wtracktableview.cpp | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/src/widget/wtracktableview.cpp b/src/widget/wtracktableview.cpp index 275879b3da..a2c0ff047b 100644 --- a/src/widget/wtracktableview.cpp +++ b/src/widget/wtracktableview.cpp @@ -19,7 +19,6 @@ #include "track/trackref.h" #include "util/assert.h" #include "util/dnd.h" -#include "util/parented_ptr.h" #include "util/time.h" #include "widget/wtracktableviewheader.h" @@ -302,18 +301,26 @@ void WTrackTableView::loadTrackModel(QAbstractItemModel *model) { // restoring scrollBar position using model pointer as key // scrollbar positions with respect to different models are backed by map - m_pMenu = make_parented<WTrackMenu>(this, m_pConfig, m_pTrackCollectionManager, WTrackMenu::Filter::All, trackModel); - connect(m_pMenu, &WTrackMenu::loadTrackToPlayer, this, &WTrackTableView::loadTrackToPlayer); + m_pMenu = std::make_unique<WTrackMenu>(this, + m_pConfig, + m_pTrackCollectionManager, + WTrackMenu::Filter::All, + trackModel); + connect(m_pMenu.get(), + &WTrackMenu::loadTrackToPlayer, + this, + &WTrackTableView::loadTrackToPlayer); } // slot -void WTrackTableView::slotMouseDoubleClicked(const QModelIndex &index) { +void WTrackTableView::slotMouseDoubleClicked(const QModelIndex& index) { // Read the current TrackLoadAction settings - int doubleClickActionConfigValue = m_pConfig->getValue( - ConfigKey("[Library]","TrackLoadAction"), - static_cast<int>(DlgPrefLibrary::LOAD_TO_DECK)); + int doubleClickActionConfigValue = + m_pConfig->getValue(ConfigKey("[Library]", "TrackLoadAction"), + static_cast<int>(DlgPrefLibrary::LOAD_TO_DECK)); DlgPrefLibrary::TrackDoubleClickAction doubleClickAction = - static_cast<DlgPrefLibrary::TrackDoubleClickAction>(doubleClickActionConfigValue); + static_cast<DlgPrefLibrary::TrackDoubleClickAction>( + doubleClickActionConfigValue); auto trackModel = getTrackModel(); if (doubleClickAction == DlgPrefLibrary::LOAD_TO_DECK && @@ -360,8 +367,16 @@ void WTrackTableView::slotUnhide() { } void WTrackTableView::contextMenuEvent(QContextMenuEvent* event) { - if (!m_pMenu) { - return; + VERIFY_OR_DEBUG_ASSERT(m_pMenu) { + m_pMenu = std::make_unique<WTrackMenu>(this, + m_pConfig, + m_pTrackCollectionManager, + WTrackMenu::Filter::All, + getTrackModel()); + connect(m_pMenu.get(), + &WTrackMenu::loadTrackToPlayer, + this, + &WTrackTableView::loadTrackToPlayer); } // Update track indices in context menu QModelIndexList indices = selectionModel()->selectedRows(); |