Solid::Device Class
class Solid::DeviceHeader: | #include <Device> |
CMake: | find_package(KF6 REQUIRED COMPONENTS Solid) target_link_libraries(mytarget PRIVATE KF6::Solid) |
Public Functions
Device(const QString &udi = QString()) | |
Device(const Solid::Device &device) | |
~Device() | |
DevIface * | as() |
const DevIface * | as() const |
Solid::DeviceInterface * | asDeviceInterface(const Solid::DeviceInterface::Type &type) |
const Solid::DeviceInterface * | asDeviceInterface(const Solid::DeviceInterface::Type &type) const |
QString | description() const |
QString | displayName() const |
QStringList | emblems() const |
QString | icon() const |
bool | is() const |
bool | isDeviceInterface(const Solid::DeviceInterface::Type &type) const |
bool | isValid() const |
Solid::Device | parent() const |
QString | parentUdi() const |
QString | product() const |
QString | udi() const |
QString | vendor() const |
Solid::Device & | operator=(const Solid::Device &device) |
Static Public Members
QList<Solid::Device> | allDevices() |
QList<Solid::Device> | listFromQuery(const QString &predicate, const QString &parentUdi = QString()) |
QList<Solid::Device> | listFromQuery(const Solid::Predicate &predicate, const QString &parentUdi = QString()) |
QList<Solid::Device> | listFromType(const Solid::DeviceInterface::Type &type, const QString &parentUdi = QString()) |
Solid::Device | storageAccessFromPath(const QString &path) |
Detailed Description
@class Solid::Device device.h <Solid/Device>
This class allows applications to deal with devices available in the underlying system.
Device stores a reference to device data provided by the backend. Device objects are designed to be used by value. Copying these objects is quite cheap, so using pointers to the me is generally not needed.
@author Kevin Ottens <ervin@kde.org>
Member Function Documentation
[explicit]
Device::Device(const QString &udi = QString())
Constructs a device for a given Universal Device Identifier (UDI).
@param udi the udi of the device to create
Device::Device(const Solid::Device &device)
Constructs a copy of a device.
@param device the device to copy
[noexcept]
Device::~Device()
Destroys the device.
[static]
QList<Solid::Device> Device::allDevices()
Retrieves all the devices available in the underlying system.
@return the list of the devices available
template <typename DevIface> DevIface *Device::as()
Retrieves a specialized interface to interact with the device corresponding to a given device interface.
@returns a pointer to the device interface if it exists, 0 otherwise
template <typename DevIface> const DevIface *Device::as() const
Retrieves a specialized interface to interact with the device corresponding to a given device interface.
@returns a pointer to the device interface if it exists, 0 otherwise
Solid::DeviceInterface *Device::asDeviceInterface(const Solid::DeviceInterface::Type &type)
Retrieves a specialized interface to interact with the device corresponding to a particular device interface.
@param type the device interface type @returns a pointer to the device interface interface if it exists, 0 otherwise
const Solid::DeviceInterface *Device::asDeviceInterface(const Solid::DeviceInterface::Type &type) const
Retrieves a specialized interface to interact with the device corresponding to a particular device interface.
@param type the device interface type @returns a pointer to the device interface interface if it exists, 0 otherwise
QString Device::description() const
Retrieves the description of device.
@return the description @since 4.4
QString Device::displayName() const
Retrieves the display Name to use for this device. Same as description when not defined.
@return the display Name @since 5.71
QStringList Device::emblems() const
Retrieves the names of the emblems representing the state of this device. The naming follows the freedesktop.org specification.
@return the emblem names @since 4.4
QString Device::icon() const
Retrieves the name of the icon representing this device. The naming follows the freedesktop.org specification.
@return the icon name
template <typename DevIface> bool Device::is() const
Tests if a device provides a given device interface.
@returns true if the interface is available, false otherwise
bool Device::isDeviceInterface(const Solid::DeviceInterface::Type &type) const
Tests if a device interface is available from the device.
@param type the device interface type to query @return true if the device interface is available, false otherwise
bool Device::isValid() const
Indicates if this device is valid. A device is considered valid if it's available in the system.
@return true if this device is available, false otherwise
[static]
QList<Solid::Device> Device::listFromQuery(const QString &predicate, const QString &parentUdi = QString())
Convenience function see above.
@param predicate @param parentUdi @return the list of devices
[static]
QList<Solid::Device> Device::listFromQuery(const Solid::Predicate &predicate, const QString &parentUdi = QString())
Retrieves a list of devices of the system given matching the given constraints (parent and predicate)
@param predicate Predicate that the devices we're searching for must verify @param parentUdi UDI of the parent of the devices we're searching for, or QString() if there's no constraint on the parent @return the list of devices corresponding to the given constraints @see Solid::Predicate
[static]
QList<Solid::Device> Device::listFromType(const Solid::DeviceInterface::Type &type, const QString &parentUdi = QString())
Retrieves a list of devices of the system given matching the given constraints (parent and device interface type)
@param type device interface type available on the devices we're looking for, or DeviceInterface::Unknown if there's no constraint on the device interfaces @param parentUdi UDI of the parent of the devices we're searching for, or QString() if there's no constraint on the parent @return the list of devices corresponding to the given constraints @see Solid::Predicate
Solid::Device Device::parent() const
Retrieves the parent of the Device.
@return the device's parent @see parentUdi()
QString Device::parentUdi() const
Retrieves the Universal Device Identifier (UDI) of the Device's parent.
@return the udi of the device's parent
QString Device::product() const
Retrieves the name of the product corresponding to this device.
@return the product name
[static]
Solid::Device Device::storageAccessFromPath(const QString &path)
Returns the Device containing the filesystem for the given path
@param canonical path to a filesystem entry, e.g. a file or directory @return @p Device containing the given @p path. For Devices implementing the StorageVolume interface only ones matching UsageType::FileSystem are returned, i.e. no backing encrypted volumes. @since 5.73 @see QFileInfo::canonicalFilePath
QString Device::udi() const
Retrieves the Universal Device Identifier (UDI).
Warning: Don't use the UDI for anything except communication with Solid. Also don't store UDIs as there's no guarantee that the UDI stays the same when the hardware setup changed. The UDI is a unique identifier that is local to the computer in question and for the current boot session. The UDIs may change after a reboot. Similar hardware in other computers may have different values; different hardware could have the same UDI.
@return the udi of the device
QString Device::vendor() const
Retrieves the name of the device vendor.
@return the vendor name
Solid::Device &Device::operator=(const Solid::Device &device)
Assigns a device to this device and returns a reference to it.
@param device the device to assign @return a reference to the device