Skip to content

Commit 0b913a9

Browse files
committed
Avoid deprecated audqt::TreeView::activate()
1 parent 4d24228 commit 0b913a9

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

src/playlist-manager-qt/playlist-manager-qt.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,6 @@ class PlaylistsView : public audqt::TreeView
134134
void update (Playlist::UpdateLevel level);
135135
void update_sel ();
136136

137-
void activate (const QModelIndex & index) override
138-
{
139-
if (index.isValid ())
140-
Playlist::by_index (index.row ()).start_playback ();
141-
}
142-
143137
const HookReceiver<PlaylistsView, Playlist::UpdateLevel>
144138
update_hook {"playlist update", this, & PlaylistsView::update};
145139
const HookReceiver<PlaylistsView>
@@ -268,6 +262,11 @@ PlaylistsView::PlaylistsView ()
268262
setDragDropMode (InternalMove);
269263
setFrameShape (QFrame::NoFrame);
270264
setIndentation (0);
265+
266+
connect (this, & QTreeView::activated, [] (const QModelIndex & index) {
267+
if (index.isValid ())
268+
Playlist::by_index (index.row ()).start_playback ();
269+
});
271270
}
272271

273272
void PlaylistsView::currentChanged (const QModelIndex & current, const QModelIndex & previous)

src/qtui/playlist-qt.cc

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,21 @@ PlaylistWidget::PlaylistWidget(QWidget * parent, Playlist playlist)
6161
setDragDropMode(DragDrop);
6262
setMouseTracking(true);
6363

64-
connect(this, &QTreeView::activated, this, &PlaylistWidget::activate);
65-
6664
updateSettings();
6765
header->updateColumns();
6866

6967
/* get initial selection and focus from core */
7068
inUpdate = true;
7169
updateSelection(0, 0);
7270
inUpdate = false;
71+
72+
connect(this, &QTreeView::activated, [this](const QModelIndex & index) {
73+
if (index.isValid())
74+
{
75+
m_playlist.set_position(indexToRow(index));
76+
m_playlist.start_playback();
77+
}
78+
});
7379
}
7480

7581
PlaylistWidget::~PlaylistWidget()
@@ -119,15 +125,6 @@ QModelIndex PlaylistWidget::visibleIndexNear(int row)
119125
return index;
120126
}
121127

122-
void PlaylistWidget::activate(const QModelIndex & index)
123-
{
124-
if (index.isValid())
125-
{
126-
m_playlist.set_position(indexToRow(index));
127-
m_playlist.start_playback();
128-
}
129-
}
130-
131128
void PlaylistWidget::changeEvent(QEvent * event)
132129
{
133130
if (event->type() == QEvent::FontChange)

src/qtui/playlist-qt.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ class PlaylistWidget : public audqt::TreeView
6969
QItemSelection & deselected);
7070
void updateSelection(int rowsBefore, int rowsAfter);
7171

72-
void activate(const QModelIndex & index);
7372
void changeEvent(QEvent * event);
7473
void contextMenuEvent(QContextMenuEvent * event);
7574
void keyPressEvent(QKeyEvent * event);

0 commit comments

Comments
 (0)