summaryrefslogtreecommitdiffstats
path: root/src/widget/wtracktableview.cpp
diff options
context:
space:
mode:
authorHarshit Maurya <hmaurya999@gmail.com>2020-04-09 22:12:51 +0530
committerHarshit Maurya <hmaurya999@gmail.com>2020-04-09 22:12:51 +0530
commit27347c0e770136925ddfa4f0d8ba862a4ed17bef (patch)
tree2222e5311b480835aa5a450e4bf2afcda9d26f45 /src/widget/wtracktableview.cpp
parent89577b6cb6a56e52412dd7fcdeefa9d7ca7d9401 (diff)
WTrackMenu: optimize menu updation
Diffstat (limited to 'src/widget/wtracktableview.cpp')
-rw-r--r--src/widget/wtracktableview.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/widget/wtracktableview.cpp b/src/widget/wtracktableview.cpp
index 0b4b609b14..8f55a9c50a 100644
--- a/src/widget/wtracktableview.cpp
+++ b/src/widget/wtracktableview.cpp
@@ -57,9 +57,6 @@ WTrackTableView::WTrackTableView(QWidget * parent,
QKeySequence(tr("ESC", "Focus")), this);
connect(setFocusShortcut, &QShortcut::activated,
this, qOverload<>(&WTrackTableView::setFocus));
-
- m_pMenu = new WTrackMenu(this, pConfig, m_pTrackCollectionManager);
- connect(m_pMenu, &WTrackMenu::loadTrackToPlayer, this, &WTrackTableView::loadTrackToPlayer);
}
WTrackTableView::~WTrackTableView() {
@@ -302,8 +299,9 @@ void WTrackTableView::loadTrackModel(QAbstractItemModel *model) {
// restoring scrollBar position using model pointer as key
// scrollbar positions with respect to different models are backed by map
- // Set the track model in context menu widget.
- m_pMenu->setTrackModel(getTrackModel());
+ // Initialize m_pMenu only after track model has been loaded.
+ m_pMenu = new WTrackMenu(this, m_pConfig, m_pTrackCollectionManager, WTrackMenu::Filter::None, trackModel);
+ connect(m_pMenu, &WTrackMenu::loadTrackToPlayer, this, &WTrackTableView::loadTrackToPlayer);
}
// slot
@@ -380,6 +378,9 @@ void WTrackTableView::slotUnhide() {
}
void WTrackTableView::contextMenuEvent(QContextMenuEvent* event) {
+ if (!m_pMenu) {
+ return;
+ }
// Update track indices in context menu
QModelIndexList indices = selectionModel()->selectedRows();
m_pMenu->loadTracks(indices);