Port away from deprecated QList::toSet and QSet::toList

This commit is contained in:
Alexander Lohnau 2023-04-17 21:20:51 +02:00
parent 07187fc03a
commit 77f44ce943
3 changed files with 16 additions and 7 deletions

View file

@ -62,7 +62,8 @@ Device::Device(QObject *parent, const QString &id)
d = new Device::DevicePrivate(info); d = new Device::DevicePrivate(info);
d->m_pairingHandler = new PairingHandler(this, PairState::Paired); d->m_pairingHandler = new PairingHandler(this, PairState::Paired);
d->m_supportedPlugins = PluginLoader::instance()->getPluginList().toSet(); // Assume every plugin is supported until we get the capabilities const auto supported = PluginLoader::instance()->getPluginList();
d->m_supportedPlugins = QSet(supported.begin(), supported.end()); // Assume every plugin is supported until we get the capabilities
// Register in bus // Register in bus
QDBusConnection::sessionBus().registerObject(dbusPath(), this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors); QDBusConnection::sessionBus().registerObject(dbusPath(), this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors);
@ -79,7 +80,8 @@ Device::Device(QObject *parent, DeviceLink *dl)
d = new Device::DevicePrivate(dl->deviceInfo()); d = new Device::DevicePrivate(dl->deviceInfo());
d->m_pairingHandler = new PairingHandler(this, PairState::NotPaired); d->m_pairingHandler = new PairingHandler(this, PairState::NotPaired);
d->m_supportedPlugins = PluginLoader::instance()->getPluginList().toSet(); // Assume every plugin is supported until we get the capabilities const auto supported = PluginLoader::instance()->getPluginList();
d->m_supportedPlugins = QSet(supported.begin(), supported.end()); // Assume every plugin is supported until we get the capabilities
addLink(dl); addLink(dl);
@ -133,7 +135,7 @@ int Device::protocolVersion()
QStringList Device::supportedPlugins() const QStringList Device::supportedPlugins() const
{ {
return d->m_supportedPlugins.toList(); return QList(d->m_supportedPlugins.cbegin(), d->m_supportedPlugins.cend());
} }
bool Device::hasPlugin(const QString &name) const bool Device::hasPlugin(const QString &name) const
@ -161,8 +163,7 @@ void Device::reloadPlugins()
const KPluginMetaData service = loader->getPluginInfo(pluginName); const KPluginMetaData service = loader->getPluginInfo(pluginName);
const bool pluginEnabled = isPluginEnabled(pluginName); const bool pluginEnabled = isPluginEnabled(pluginName);
const QSet<QString> incomingCapabilities = const QStringList incomingCapabilities = service.rawData().value(QStringLiteral("X-KdeConnect-SupportedPacketType")).toVariant().toStringList();
KPluginMetaData::readStringList(service.rawData(), QStringLiteral("X-KdeConnect-SupportedPacketType")).toSet();
if (pluginEnabled) { if (pluginEnabled) {
KdeConnectPlugin *plugin = d->m_plugins.take(pluginName); KdeConnectPlugin *plugin = d->m_plugins.take(pluginName);

View file

@ -133,13 +133,15 @@ QSslCertificate KdeConnectConfig::certificate()
DeviceInfo KdeConnectConfig::deviceInfo() DeviceInfo KdeConnectConfig::deviceInfo()
{ {
const auto incoming = PluginLoader::instance()->incomingCapabilities();
const auto outgoing = PluginLoader::instance()->outgoingCapabilities();
return DeviceInfo(deviceId(), return DeviceInfo(deviceId(),
certificate(), certificate(),
name(), name(),
deviceType(), deviceType(),
NetworkPacket::s_protocolVersion, NetworkPacket::s_protocolVersion,
PluginLoader::instance()->incomingCapabilities().toSet(), QSet(incoming.begin(), incoming.end()),
PluginLoader::instance()->outgoingCapabilities().toSet()); QSet(outgoing.begin(), outgoing.end()));
} }
QDir KdeConnectConfig::baseConfigDir() QDir KdeConnectConfig::baseConfigDir()

View file

@ -22,7 +22,13 @@ KdeConnectPlugin::KdeConnectPlugin(QObject *parent, const QVariantList &args)
{ {
d->m_device = qvariant_cast<Device *>(args.at(0)); d->m_device = qvariant_cast<Device *>(args.at(0));
d->m_pluginName = args.at(1).toString(); d->m_pluginName = args.at(1).toString();
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
const QStringList cap = args.at(2).toStringList();
d->m_outgoingCapabilties = QSet(cap.begin(), cap.end());
#else
d->m_outgoingCapabilties = args.at(2).toStringList().toSet(); d->m_outgoingCapabilties = args.at(2).toStringList().toSet();
#endif
d->m_config = nullptr; d->m_config = nullptr;
d->iconName = args.at(3).toString(); d->iconName = args.at(3).toString();
} }