From f93cec031b93d418394fc0fcf18c744f983b3883 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 17 Nov 2020 00:25:48 +0100 Subject: [PATCH] [plasmalnf] Introduce an index-lookup function - for signalling model changes, also need to know indexes / row --- src/modules/plasmalnf/ThemeInfo.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/modules/plasmalnf/ThemeInfo.h b/src/modules/plasmalnf/ThemeInfo.h index a75c3c2bc..34c26dc6f 100644 --- a/src/modules/plasmalnf/ThemeInfo.h +++ b/src/modules/plasmalnf/ThemeInfo.h @@ -52,6 +52,20 @@ struct ThemeInfo class ThemeInfoList : public QList< ThemeInfo > { public: + std::pair< int, ThemeInfo* > indexById( const QString& id ) + { + int index = 0; + for ( ThemeInfo& i : *this ) + { + if ( i.id == id ) + { + return { index, &i }; + } + } + return { -1, nullptr }; + } + + /** @brief Looks for a given @p id in the list of themes, returns nullptr if not found. */ ThemeInfo* findById( const QString& id ) {