From aad767acf498a0c03794a9f8b135c5f09a203d09 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 11 Sep 2024 09:22:50 +0200 Subject: [PATCH] FileListPage: move another function into the class --- src/FileListPage.cxx | 20 ++++++++++---------- src/FileListPage.hxx | 1 + 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/FileListPage.cxx b/src/FileListPage.cxx index 48f1d12f..587d3581 100644 --- a/src/FileListPage.cxx +++ b/src/FileListPage.cxx @@ -116,34 +116,34 @@ FileListPage::LoadPlaylist(struct mpdclient &c, return true; } -static bool -enqueue_and_play(struct mpdclient *c, FileListEntry *entry) +inline bool +FileListPage::EnqueueAndPlay(struct mpdclient &c, FileListEntry &entry) noexcept { - auto *connection = c->GetConnection(); + auto *connection = c.GetConnection(); if (connection == nullptr) return false; - const auto *song = mpd_entity_get_song(entry->entity); + const auto *song = mpd_entity_get_song(entry.entity); assert(song != nullptr); int id; #ifndef NCMPC_MINI - if (!(entry->flags & HIGHLIGHT)) + if (!(entry.flags & HIGHLIGHT)) id = -1; else #endif - id = c->playlist.FindIdByUri(mpd_song_get_uri(song)); + id = c.playlist.FindIdByUri(mpd_song_get_uri(song)); if (id < 0) { id = mpd_run_add_id(connection, mpd_song_get_uri(song)); if (id < 0) { - c->HandleError(); + c.HandleError(); return false; } #ifndef NCMPC_MINI - entry->flags |= HIGHLIGHT; + entry.flags |= HIGHLIGHT; #endif char buf[BUFSIZE]; @@ -152,7 +152,7 @@ enqueue_and_play(struct mpdclient *c, FileListEntry *entry) } if (!mpd_run_play_id(connection, id)) { - c->HandleError(); + c.HandleError(); return false; } @@ -217,7 +217,7 @@ FileListPage::HandleEnter(struct mpdclient &c) if (mpd_entity_get_type(entity) == MPD_ENTITY_TYPE_PLAYLIST) return LoadPlaylist(c, *mpd_entity_get_playlist(entity)); else if (mpd_entity_get_type(entity) == MPD_ENTITY_TYPE_SONG) - return enqueue_and_play(&c, entry); + return EnqueueAndPlay(c, *entry); return false; } diff --git a/src/FileListPage.hxx b/src/FileListPage.hxx index 6fd9f7e8..b903645f 100644 --- a/src/FileListPage.hxx +++ b/src/FileListPage.hxx @@ -44,6 +44,7 @@ protected: virtual bool HandleEnter(struct mpdclient &c); private: + bool EnqueueAndPlay(struct mpdclient &c, FileListEntry &entry) noexcept; bool LoadPlaylist(struct mpdclient &c, const struct mpd_playlist &playlist) noexcept; bool HandleSelectEntry(struct mpdclient &c, FileListEntry &entry,