mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
solid: do not copy lists
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
8ee64ca77c
commit
85758c0a6d
2 changed files with 34 additions and 38 deletions
|
@ -176,8 +176,7 @@ QSet<Solid::DeviceInterface::Type> UDevManager::supportedInterfaces() const
|
||||||
QStringList UDevManager::allDevices()
|
QStringList UDevManager::allDevices()
|
||||||
{
|
{
|
||||||
QStringList res;
|
QStringList res;
|
||||||
const UdevQt::DeviceList deviceList = d->m_client->allDevices();
|
foreach (const UdevQt::Device &device, d->m_client->allDevices()) {
|
||||||
foreach (const UdevQt::Device &device, deviceList) {
|
|
||||||
if (d->isOfInterest(udiPrefix() + device.sysfsPath(), device)) {
|
if (d->isOfInterest(udiPrefix() + device.sysfsPath(), device)) {
|
||||||
res << udiPrefix() + device.sysfsPath();
|
res << udiPrefix() + device.sysfsPath();
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,7 @@ Solid::DeviceManagerPrivate::DeviceManagerPrivate()
|
||||||
{
|
{
|
||||||
loadBackends();
|
loadBackends();
|
||||||
|
|
||||||
QList<QObject*> backends = managerBackends();
|
foreach (QObject *backend, managerBackends()) {
|
||||||
foreach (QObject *backend, backends) {
|
|
||||||
connect(backend, SIGNAL(deviceAdded(QString)),
|
connect(backend, SIGNAL(deviceAdded(QString)),
|
||||||
this, SLOT(_k_deviceAdded(QString)));
|
this, SLOT(_k_deviceAdded(QString)));
|
||||||
connect(backend, SIGNAL(deviceRemoved(QString)),
|
connect(backend, SIGNAL(deviceRemoved(QString)),
|
||||||
|
@ -52,8 +51,7 @@ Solid::DeviceManagerPrivate::DeviceManagerPrivate()
|
||||||
|
|
||||||
Solid::DeviceManagerPrivate::~DeviceManagerPrivate()
|
Solid::DeviceManagerPrivate::~DeviceManagerPrivate()
|
||||||
{
|
{
|
||||||
QList<QObject*> backends = managerBackends();
|
foreach (QObject *backend, managerBackends()) {
|
||||||
foreach (QObject *backend, backends) {
|
|
||||||
disconnect(backend, 0, this, 0);
|
disconnect(backend, 0, this, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,16 +67,15 @@ Solid::DeviceManagerPrivate::~DeviceManagerPrivate()
|
||||||
QList<Solid::Device> Solid::Device::allDevices()
|
QList<Solid::Device> Solid::Device::allDevices()
|
||||||
{
|
{
|
||||||
QList<Device> list;
|
QList<Device> list;
|
||||||
QList<QObject*> backends = globalDeviceStorage()->managerBackends();
|
|
||||||
|
|
||||||
foreach (QObject *backendObj, backends) {
|
foreach (QObject *backendObj, globalDeviceStorage()->managerBackends()) {
|
||||||
Ifaces::DeviceManager *backend = qobject_cast<Ifaces::DeviceManager *>(backendObj);
|
Ifaces::DeviceManager *backend = qobject_cast<Ifaces::DeviceManager *>(backendObj);
|
||||||
|
|
||||||
if (backend == 0) continue;
|
if (backend == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
QStringList udis = backend->allDevices();
|
foreach (const QString &udi, backend->allDevices()) {
|
||||||
|
|
||||||
foreach (const QString &udi, udis) {
|
|
||||||
list.append(Device(udi));
|
list.append(Device(udi));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,17 +102,18 @@ QList<Solid::Device> Solid::Device::listFromType(const DeviceInterface::Type &ty
|
||||||
const QString &parentUdi)
|
const QString &parentUdi)
|
||||||
{
|
{
|
||||||
QList<Device> list;
|
QList<Device> list;
|
||||||
QList<QObject*> backends = globalDeviceStorage()->managerBackends();
|
|
||||||
|
|
||||||
foreach (QObject *backendObj, backends) {
|
foreach (QObject *backendObj, globalDeviceStorage()->managerBackends()) {
|
||||||
Ifaces::DeviceManager *backend = qobject_cast<Ifaces::DeviceManager *>(backendObj);
|
Ifaces::DeviceManager *backend = qobject_cast<Ifaces::DeviceManager *>(backendObj);
|
||||||
|
|
||||||
if (backend == 0) continue;
|
if (backend == 0) {
|
||||||
if (!backend->supportedInterfaces().contains(type)) continue;
|
continue;
|
||||||
|
}
|
||||||
|
if (!backend->supportedInterfaces().contains(type)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
QStringList udis = backend->devicesFromQuery(parentUdi, type);
|
foreach (const QString &udi, backend->devicesFromQuery(parentUdi, type)) {
|
||||||
|
|
||||||
foreach (const QString &udi, udis) {
|
|
||||||
list.append(Device(udi));
|
list.append(Device(udi));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,13 +125,14 @@ QList<Solid::Device> Solid::Device::listFromQuery(const Predicate &predicate,
|
||||||
const QString &parentUdi)
|
const QString &parentUdi)
|
||||||
{
|
{
|
||||||
QList<Device> list;
|
QList<Device> list;
|
||||||
QList<QObject*> backends = globalDeviceStorage()->managerBackends();
|
|
||||||
QSet<DeviceInterface::Type> usedTypes = predicate.usedTypes();
|
QSet<DeviceInterface::Type> usedTypes = predicate.usedTypes();
|
||||||
|
|
||||||
foreach (QObject *backendObj, backends) {
|
foreach (QObject *backendObj, globalDeviceStorage()->managerBackends()) {
|
||||||
Ifaces::DeviceManager *backend = qobject_cast<Ifaces::DeviceManager *>(backendObj);
|
Ifaces::DeviceManager *backend = qobject_cast<Ifaces::DeviceManager *>(backendObj);
|
||||||
|
|
||||||
if (backend == 0) continue;
|
if (backend == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
QSet<QString> udis;
|
QSet<QString> udis;
|
||||||
if (predicate.isValid()) {
|
if (predicate.isValid()) {
|
||||||
|
@ -143,26 +142,24 @@ QList<Solid::Device> Solid::Device::listFromQuery(const Predicate &predicate,
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (DeviceInterface::Type type, supportedTypes) {
|
foreach (DeviceInterface::Type type, supportedTypes) {
|
||||||
udis+= QSet<QString>::fromList(backend->devicesFromQuery(parentUdi, type));
|
udis += QSet<QString>::fromList(backend->devicesFromQuery(parentUdi, type));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
udis+= QSet<QString>::fromList(backend->allDevices());
|
udis += QSet<QString>::fromList(backend->allDevices());
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (const QString &udi, udis)
|
foreach (const QString &udi, udis) {
|
||||||
{
|
|
||||||
Device dev(udi);
|
Device dev(udi);
|
||||||
|
|
||||||
bool matches = false;
|
bool matches = false;
|
||||||
|
|
||||||
if(!predicate.isValid()) {
|
if (!predicate.isValid()) {
|
||||||
matches = true;
|
matches = true;
|
||||||
} else {
|
} else {
|
||||||
matches = predicate.matches(dev);
|
matches = predicate.matches(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matches)
|
if (matches) {
|
||||||
{
|
|
||||||
list.append(dev);
|
list.append(dev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -250,20 +247,20 @@ Solid::DevicePrivate *Solid::DeviceManagerPrivate::findRegisteredDevice(const QS
|
||||||
|
|
||||||
Solid::Ifaces::Device *Solid::DeviceManagerPrivate::createBackendObject(const QString &udi)
|
Solid::Ifaces::Device *Solid::DeviceManagerPrivate::createBackendObject(const QString &udi)
|
||||||
{
|
{
|
||||||
QList<QObject*> backends = globalDeviceStorage()->managerBackends();
|
foreach (QObject *backendObj, globalDeviceStorage()->managerBackends()) {
|
||||||
|
|
||||||
foreach (QObject *backendObj, backends) {
|
|
||||||
Ifaces::DeviceManager *backend = qobject_cast<Ifaces::DeviceManager *>(backendObj);
|
Ifaces::DeviceManager *backend = qobject_cast<Ifaces::DeviceManager *>(backendObj);
|
||||||
|
|
||||||
if (backend == 0) continue;
|
if (backend == 0) {
|
||||||
if (!udi.startsWith(backend->udiPrefix())) continue;
|
continue;
|
||||||
|
}
|
||||||
Ifaces::Device *iface = 0;
|
if (!udi.startsWith(backend->udiPrefix())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
QObject *object = backend->createDevice(udi);
|
QObject *object = backend->createDevice(udi);
|
||||||
iface = qobject_cast<Ifaces::Device *>(object);
|
Ifaces::Device *iface = qobject_cast<Ifaces::Device *>(object);
|
||||||
|
|
||||||
if (iface==0) {
|
if (iface == 0) {
|
||||||
delete object;
|
delete object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue