Port away from deprecated QList::toSet and QSet::toList
This commit is contained in:
parent
624fadbe6e
commit
81fea21100
2 changed files with 22 additions and 9 deletions
|
@ -26,7 +26,7 @@
|
|||
#include "networkpacket.h"
|
||||
#include "pluginloader.h"
|
||||
|
||||
// In older Qt released, qAsConst isnt available
|
||||
// In older Qt released, qAsConst isn't available
|
||||
#include "qtcompat_p.h"
|
||||
|
||||
class Device::DevicePrivate
|
||||
|
@ -76,7 +76,7 @@ Device::Device(QObject *parent, const QString &id)
|
|||
QDBusConnection::sessionBus().registerObject(dbusPath(), this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors);
|
||||
|
||||
// Assume every plugin is supported until addLink is called and we can get the actual list
|
||||
d->m_allPlugins = PluginLoader::instance()->getPluginList().toSet();
|
||||
d->m_allPlugins = PluginLoader::instance()->getPluginSet();
|
||||
d->m_supportedPlugins = d->m_allPlugins;
|
||||
|
||||
connect(this, &Device::pairingError, this, &warn);
|
||||
|
@ -87,7 +87,7 @@ Device::Device(QObject *parent, const NetworkPacket &identityPacket, DeviceLink
|
|||
, d(new Device::DevicePrivate(identityPacket.get<QString>(QStringLiteral("deviceId"))))
|
||||
{
|
||||
d->m_deviceName = identityPacket.get<QString>(QStringLiteral("deviceName"));
|
||||
d->m_allPlugins = PluginLoader::instance()->getPluginList().toSet();
|
||||
d->m_allPlugins = PluginLoader::instance()->getPluginSet();
|
||||
|
||||
addLink(identityPacket, dl);
|
||||
|
||||
|
@ -132,7 +132,7 @@ int Device::protocolVersion()
|
|||
|
||||
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
|
||||
|
@ -158,8 +158,7 @@ void Device::reloadPlugins()
|
|||
const KPluginMetaData service = loader->getPluginInfo(pluginName);
|
||||
|
||||
const bool pluginEnabled = isPluginEnabled(pluginName);
|
||||
const QSet<QString> incomingCapabilities =
|
||||
KPluginMetaData::readStringList(service.rawData(), QStringLiteral("X-KdeConnect-SupportedPacketType")).toSet();
|
||||
const QStringList incomingCapabilities = service.rawData().value(QStringLiteral("X-KdeConnect-SupportedPacketType")).toVariant().toStringList();
|
||||
|
||||
if (pluginEnabled) {
|
||||
KdeConnectPlugin *plugin = d->m_plugins.take(pluginName);
|
||||
|
@ -291,14 +290,22 @@ void Device::addLink(const NetworkPacket &identityPacket, DeviceLink *link)
|
|||
std::sort(d->m_deviceLinks.begin(), d->m_deviceLinks.end(), lessThan);
|
||||
|
||||
const bool capabilitiesSupported = identityPacket.has(QStringLiteral("incomingCapabilities")) || identityPacket.has(QStringLiteral("outgoingCapabilities"));
|
||||
const auto toSet = [](const QStringList &l) {
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||
return l.toSet();
|
||||
#else
|
||||
return QSet(l.begin(), l.end());
|
||||
#endif
|
||||
};
|
||||
|
||||
if (capabilitiesSupported) {
|
||||
const QSet<QString> outgoingCapabilities = identityPacket.get<QStringList>(QStringLiteral("outgoingCapabilities")).toSet(),
|
||||
incomingCapabilities = identityPacket.get<QStringList>(QStringLiteral("incomingCapabilities")).toSet();
|
||||
const QSet<QString> outgoingCapabilities = toSet(identityPacket.get<QStringList>(QStringLiteral("outgoingCapabilities"))),
|
||||
incomingCapabilities = toSet(identityPacket.get<QStringList>(QStringLiteral("incomingCapabilities")));
|
||||
|
||||
d->m_supportedPlugins = PluginLoader::instance()->pluginsForCapabilities(incomingCapabilities, outgoingCapabilities);
|
||||
// qDebug() << "new plugins for" << m_deviceName << m_supportedPlugins << incomingCapabilities << outgoingCapabilities;
|
||||
} else {
|
||||
d->m_supportedPlugins = PluginLoader::instance()->getPluginList().toSet();
|
||||
d->m_supportedPlugins = PluginLoader::instance()->getPluginSet();
|
||||
}
|
||||
|
||||
reloadPlugins();
|
||||
|
|
|
@ -22,7 +22,13 @@ KdeConnectPlugin::KdeConnectPlugin(QObject *parent, const QVariantList &args)
|
|||
{
|
||||
d->m_device = qvariant_cast<Device *>(args.at(0));
|
||||
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();
|
||||
#endif
|
||||
d->m_config = nullptr;
|
||||
d->iconName = args.at(3).toString();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue