Changeset View
Changeset View
Standalone View
Standalone View
src/solid/devices/backends/udev/udevmanager.cpp
Show First 20 Lines • Show All 173 Lines • ▼ Show 20 Line(s) | |||||
174 | 174 | | |||
175 | QStringList UDevManager::devicesFromQuery(const QString &parentUdi, | 175 | QStringList UDevManager::devicesFromQuery(const QString &parentUdi, | ||
176 | Solid::DeviceInterface::Type type) | 176 | Solid::DeviceInterface::Type type) | ||
177 | { | 177 | { | ||
178 | QStringList result; | 178 | QStringList result; | ||
179 | 179 | | |||
180 | if (!parentUdi.isEmpty()) { | 180 | if (!parentUdi.isEmpty()) { | ||
181 | const UdevQt::DeviceList deviceList = d->m_client->allDevices(); | 181 | const UdevQt::DeviceList deviceList = d->m_client->allDevices(); | ||
182 | Q_FOREACH (const UdevQt::Device &dev, deviceList) { | 182 | for (const UdevQt::Device &dev : deviceList) { | ||
183 | UDevDevice device(dev); | 183 | UDevDevice device(dev); | ||
184 | if (device.queryDeviceInterface(type) && d->isOfInterest(udiPrefix() + dev.sysfsPath(), dev) && device.parentUdi() == parentUdi) { | 184 | if (device.queryDeviceInterface(type) && d->isOfInterest(udiPrefix() + dev.sysfsPath(), dev) && device.parentUdi() == parentUdi) { | ||
185 | result << udiPrefix() + dev.sysfsPath(); | 185 | result << udiPrefix() + dev.sysfsPath(); | ||
186 | } | 186 | } | ||
187 | } | 187 | } | ||
188 | return result; | 188 | return result; | ||
189 | } | ||||
190 | | ||||
191 | if (type == DeviceInterface::Unknown) { | ||||
192 | return allDevices(); | ||||
193 | } | ||||
194 | | ||||
195 | UdevQt::DeviceList deviceList; | ||||
196 | | ||||
197 | // Already limit the number of devices we query and have to create wrapper items for here | ||||
198 | if (type == Solid::DeviceInterface::Processor) { | ||||
199 | deviceList = d->m_client->devicesBySubsystem(QStringLiteral("processor")) | ||||
200 | + d->m_client->devicesBySubsystem(QStringLiteral("cpu")); | ||||
201 | } else if (type == Solid::DeviceInterface::PortableMediaPlayer) { | ||||
202 | deviceList = d->m_client->devicesBySubsystem(QStringLiteral("usb")); | ||||
189 | } else if (type != Solid::DeviceInterface::Unknown) { | 203 | } else if (type != Solid::DeviceInterface::Unknown) { | ||
190 | const UdevQt::DeviceList deviceList = d->m_client->allDevices(); | 204 | deviceList = d->m_client->allDevices(); | ||
191 | Q_FOREACH (const UdevQt::Device &dev, deviceList) { | 205 | } | ||
206 | | ||||
207 | for (const UdevQt::Device &dev : deviceList) { | ||||
192 | UDevDevice device(dev); | 208 | UDevDevice device(dev); | ||
193 | if (device.queryDeviceInterface(type) && d->isOfInterest(udiPrefix() + dev.sysfsPath(), dev)) { | 209 | if (device.queryDeviceInterface(type) && d->isOfInterest(udiPrefix() + dev.sysfsPath(), dev)) { | ||
194 | result << udiPrefix() + dev.sysfsPath(); | 210 | result << udiPrefix() + dev.sysfsPath(); | ||
195 | } | 211 | } | ||
196 | } | 212 | } | ||
213 | | ||||
197 | return result; | 214 | return result; | ||
198 | } else { | | |||
199 | return allDevices(); | | |||
200 | } | | |||
201 | } | 215 | } | ||
202 | 216 | | |||
203 | QObject *UDevManager::createDevice(const QString &udi_) | 217 | QObject *UDevManager::createDevice(const QString &udi_) | ||
204 | { | 218 | { | ||
205 | if (udi_ == udiPrefix()) { | 219 | if (udi_ == udiPrefix()) { | ||
206 | RootDevice *const device = new RootDevice(UDEV_UDI_PREFIX); | 220 | RootDevice *const device = new RootDevice(UDEV_UDI_PREFIX); | ||
207 | device->setProduct(tr("Devices")); | 221 | device->setProduct(tr("Devices")); | ||
208 | device->setDescription(tr("Devices declared in your system")); | 222 | device->setDescription(tr("Devices declared in your system")); | ||
Show All 29 Lines |