From e97461937cc6a4d8c2c812b8b545405c1eb1f2b5 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Sat, 5 Oct 2024 17:17:08 +0100 Subject: [PATCH] Using string serialisation to workaround the weird build failure if I make the return type anything more complex --- core/daemon.cpp | 16 +++++----------- kcm/kcm.cpp | 41 ++++++++++++++++++----------------------- 2 files changed, 23 insertions(+), 34 deletions(-) diff --git a/core/daemon.cpp b/core/daemon.cpp index f195b96c5..e3d49bd6d 100644 --- a/core/daemon.cpp +++ b/core/daemon.cpp @@ -149,20 +149,14 @@ QSet Daemon::getLinkProviders() const QStringList Daemon::linkProviders() const { - /* - QString allStr = QStringLiteral("all"); - QString enabledStr = QStringLiteral("enabled"); - - QMap returnValue; + QStringList returnValue; for (LinkProvider *a : std::as_const(d->m_linkProviders)) { - returnValue[allStr] += a->name(); - - // TODO add filtering by enabled config - returnValue[enabledStr] += a->name(); + QString line = QString(a->name()); + line += QStringLiteral("|enabled"); + returnValue.append(line); } - return returnValue;*/ - return QStringList(); + return returnValue; } QStringList Daemon::devices(bool onlyReachable, bool onlyTrusted) const { diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp index 0a47f736f..5658a928e 100644 --- a/kcm/kcm.cpp +++ b/kcm/kcm.cpp @@ -93,32 +93,27 @@ KdeConnectKcm::KdeConnectKcm(QObject *parent, const KPluginMetaData &md, const Q } }, this); - /* - setWhenAvailable( - daemon->linkProviders(), - [this](bool error, const QStringList linkProviders) { - for (int i = 0; i < linkProviders[QStringLiteral("all")].size(); ++i) { - QString linkProvider = QString(linkProviders[QStringLiteral("all")].at(i).constData()); - QListWidgetItem linkProviderItem = new QListWidgetItem(linkProvider, kcmUi.linkProviders_list); - linkProviderItem->setCheckState(Qt::Unchecked); - if(linkProviders[QStringLiteral("enabled")].contains(linkProvider)){ - linkProviderItem->setCheckState(Qt::Checked); - } - kcmUi.linkProviders_list->addItem(linkProviderItem); - } - }, - this); - */ + setWhenAvailable( daemon->linkProviders(), - [this](bool error, const QStringList linkProviders) { /* - for (int i = 0; i < linkProviders[QStringLiteral("all")].size(); ++i) { - QString linkProvider = QString(linkProviders[QStringLiteral("all")].at(i).constData()); - QListWidgetItem *linkProviderItem = new QListWidgetItem(linkProvider, kcmUi.linkProviders_list); - linkProviderItem->setCheckState(Qt::Checked); - kcmUi.linkProviders_list->addItem(linkProviderItem); - }*/ + [this](bool error, const QStringList linkProviders) { + kcmUi.linkProviders_list->clear(); + for (int i = 0; i < linkProviders.size(); ++i) { + QStringList linkProvider = linkProviders.at(i).split(QStringLiteral("|")); + QString providerName = linkProvider.at(0); + QString providerStatus = linkProvider.at(1); + + QListWidgetItem *linkProviderItem = new QListWidgetItem(providerName, kcmUi.linkProviders_list); + + if (providerStatus.compare(QStringLiteral("enabled")) == 0) { + linkProviderItem->setCheckState(Qt::Checked); + } else { + linkProviderItem->setCheckState(Qt::Unchecked); + } + + kcmUi.linkProviders_list->addItem(linkProviderItem); + } }, this);