Solid
device.h
Go to the documentation of this file.
00001 /* 00002 Copyright 2005-2007 Kevin Ottens <ervin@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Lesser General Public 00006 License as published by the Free Software Foundation; either 00007 version 2.1 of the License, or (at your option) version 3, or any 00008 later version accepted by the membership of KDE e.V. (or its 00009 successor approved by the membership of KDE e.V.), which shall 00010 act as a proxy defined in Section 6 of version 3 of the license. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public 00018 License along with this library. If not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 00021 #ifndef SOLID_DEVICE_H 00022 #define SOLID_DEVICE_H 00023 00024 #include <QtCore/QVariant> 00025 00026 #include <QtCore/QMap> 00027 #include <QtCore/QList> 00028 #include <QtCore/QSharedData> 00029 00030 #include <solid/solid_export.h> 00031 00032 #include <solid/deviceinterface.h> 00033 00034 namespace Solid 00035 { 00036 class DevicePrivate; 00037 00048 class SOLID_EXPORT Device 00049 { 00050 public: 00056 static QList<Device> allDevices(); 00057 00069 static QList<Device> listFromType(const DeviceInterface::Type &type, 00070 const QString &parentUdi = QString()); 00071 00082 static QList<Device> listFromQuery(const Predicate &predicate, 00083 const QString &parentUdi = QString()); 00084 00092 static QList<Device> listFromQuery(const QString &predicate, 00093 const QString &parentUdi = QString()); 00094 00095 00101 explicit Device(const QString &udi = QString()); 00102 00108 Device(const Device &device); 00109 00113 ~Device(); 00114 00115 00116 00123 Device &operator=(const Device &device); 00124 00131 bool isValid() const; 00132 00133 00146 QString udi() const; 00147 00154 QString parentUdi() const; 00155 00156 00163 Device parent() const; 00164 00165 00166 00172 QString vendor() const; 00173 00179 QString product() const; 00180 00187 QString icon() const; 00188 00196 QStringList emblems() const; 00197 00204 QString description() const; 00205 00212 bool isDeviceInterface(const DeviceInterface::Type &type) const; 00213 00221 DeviceInterface *asDeviceInterface(const DeviceInterface::Type &type); 00222 00230 const DeviceInterface *asDeviceInterface(const DeviceInterface::Type &type) const; 00231 00238 template <class DevIface> DevIface *as() 00239 { 00240 DeviceInterface::Type type = DevIface::deviceInterfaceType(); 00241 DeviceInterface *iface = asDeviceInterface(type); 00242 return qobject_cast<DevIface *>(iface); 00243 } 00244 00251 template <class DevIface> const DevIface *as() const 00252 { 00253 DeviceInterface::Type type = DevIface::deviceInterfaceType(); 00254 const DeviceInterface *iface = asDeviceInterface(type); 00255 return qobject_cast<const DevIface *>(iface); 00256 } 00257 00263 template <class DevIface> bool is() const 00264 { 00265 return isDeviceInterface(DevIface::deviceInterfaceType()); 00266 } 00267 00268 private: 00269 QExplicitlySharedDataPointer<DevicePrivate> d; 00270 friend class DeviceManagerPrivate; 00271 }; 00272 } 00273 00274 #endif
KDE 4.6 API Reference