Solid
deviceinterface.cpp
Go to the documentation of this file.
00001 /* 00002 Copyright 2006-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 #include "deviceinterface.h" 00022 #include "deviceinterface_p.h" 00023 00024 #include <solid/ifaces/deviceinterface.h> 00025 00026 #include <QtCore/QMetaEnum> 00027 00028 00029 Solid::DeviceInterface::DeviceInterface(DeviceInterfacePrivate &dd, QObject *backendObject) 00030 : d_ptr(&dd) 00031 { 00032 Q_D(DeviceInterface); 00033 00034 d->setBackendObject(backendObject); 00035 } 00036 00037 00038 Solid::DeviceInterface::~DeviceInterface() 00039 { 00040 delete d_ptr; 00041 d_ptr = 0; 00042 } 00043 00044 bool Solid::DeviceInterface::isValid() const 00045 { 00046 Q_D(const DeviceInterface); 00047 return d->backendObject()!=0; 00048 } 00049 00050 QString Solid::DeviceInterface::typeToString(Type type) 00051 { 00052 int index = staticMetaObject.indexOfEnumerator("Type"); 00053 QMetaEnum metaEnum = staticMetaObject.enumerator(index); 00054 return QString(metaEnum.valueToKey((int)type)); 00055 } 00056 00057 Solid::DeviceInterface::Type Solid::DeviceInterface::stringToType(const QString &type) 00058 { 00059 int index = staticMetaObject.indexOfEnumerator("Type"); 00060 QMetaEnum metaEnum = staticMetaObject.enumerator(index); 00061 return (Type)metaEnum.keyToValue(type.toUtf8()); 00062 } 00063 00064 QString Solid::DeviceInterface::typeDescription(Type type) 00065 { 00066 switch (type) 00067 { 00068 case Unknown: 00069 return QObject::tr("Unknown", "Unknown device type"); 00070 case GenericInterface: 00071 return QObject::tr("Generic Interface", "Generic Interface device type"); 00072 case Processor: 00073 return QObject::tr("Processor", "Processor device type"); 00074 case Block: 00075 return QObject::tr("Block", "Block device type"); 00076 case StorageAccess: 00077 return QObject::tr("Storage Access", "Storage Access device type"); 00078 case StorageDrive: 00079 return QObject::tr("Storage Drive", "Storage Drive device type"); 00080 case OpticalDrive: 00081 return QObject::tr("Optical Drive", "Optical Drive device type"); 00082 case StorageVolume: 00083 return QObject::tr("Storage Volume", "Storage Volume device type"); 00084 case OpticalDisc: 00085 return QObject::tr("Optical Disc", "Optical Disc device type"); 00086 case Camera: 00087 return QObject::tr("Camera", "Camera device type"); 00088 case PortableMediaPlayer: 00089 return QObject::tr("Portable Media Player", "Portable Media Player device type"); 00090 case NetworkInterface: 00091 return QObject::tr("Network Interface", "Network Interface device type"); 00092 case AcAdapter: 00093 return QObject::tr("Ac Adapter", "Ac Adapter device type"); 00094 case Battery: 00095 return QObject::tr("Battery", "Battery device type"); 00096 case Button: 00097 return QObject::tr("Button", "Button device type"); 00098 case AudioInterface: 00099 return QObject::tr("Audio Interface", "Audio Interface device type"); 00100 case DvbInterface: 00101 return QObject::tr("Dvb Interface", "Dvb Interface device type"); 00102 case Video: 00103 return QObject::tr("Video", "Video device type"); 00104 case SerialInterface: 00105 return QObject::tr("Serial Interface", "Serial Interface device type"); 00106 case SmartCardReader: 00107 return QObject::tr("Smart Card Reader", "Smart Card Reader device type"); 00108 case InternetGateway: 00109 return QObject::tr("Internet Gateway Device", "Internet Gateway device type"); 00110 case Last: 00111 return QString(); 00112 } 00113 return QString(); 00114 } 00115 00116 Solid::DeviceInterfacePrivate::DeviceInterfacePrivate() 00117 : m_devicePrivate(0) 00118 { 00119 00120 } 00121 00122 Solid::DeviceInterfacePrivate::~DeviceInterfacePrivate() 00123 { 00124 00125 } 00126 00127 QObject *Solid::DeviceInterfacePrivate::backendObject() const 00128 { 00129 return m_backendObject.data(); 00130 } 00131 00132 void Solid::DeviceInterfacePrivate::setBackendObject(QObject *object) 00133 { 00134 m_backendObject = object; 00135 } 00136 00137 Solid::DevicePrivate* Solid::DeviceInterfacePrivate::devicePrivate() const 00138 { 00139 return m_devicePrivate; 00140 } 00141 00142 void Solid::DeviceInterfacePrivate::setDevicePrivate(DevicePrivate *devicePrivate) 00143 { 00144 m_devicePrivate = devicePrivate; 00145 } 00146 00147 #include "deviceinterface.moc"
KDE 4.6 API Reference