Solid
deviceinterface.cpp
Go to the documentation of this file.00001 /* This file is part of the KDE project 00002 Copyright (C) 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 Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 00017 00018 */ 00019 00020 #include "deviceinterface.h" 00021 #include "deviceinterface_p.h" 00022 00023 #include <solid/ifaces/deviceinterface.h> 00024 00025 #include <QtCore/QMetaEnum> 00026 00027 00028 Solid::DeviceInterface::DeviceInterface(DeviceInterfacePrivate &dd, QObject *backendObject) 00029 : d_ptr(&dd) 00030 { 00031 Q_D(DeviceInterface); 00032 00033 d->setBackendObject(backendObject); 00034 } 00035 00036 00037 Solid::DeviceInterface::~DeviceInterface() 00038 { 00039 delete d_ptr; 00040 d_ptr = 0; 00041 } 00042 00043 bool Solid::DeviceInterface::isValid() const 00044 { 00045 Q_D(const DeviceInterface); 00046 return d->backendObject()!=0; 00047 } 00048 00049 QString Solid::DeviceInterface::typeToString(Type type) 00050 { 00051 int index = staticMetaObject.indexOfEnumerator("Type"); 00052 QMetaEnum metaEnum = staticMetaObject.enumerator(index); 00053 return QString(metaEnum.valueToKey((int)type)); 00054 } 00055 00056 Solid::DeviceInterface::Type Solid::DeviceInterface::stringToType(const QString &type) 00057 { 00058 int index = staticMetaObject.indexOfEnumerator("Type"); 00059 QMetaEnum metaEnum = staticMetaObject.enumerator(index); 00060 return (Type)metaEnum.keyToValue(type.toUtf8()); 00061 } 00062 00063 Solid::DeviceInterfacePrivate::DeviceInterfacePrivate() 00064 { 00065 00066 } 00067 00068 Solid::DeviceInterfacePrivate::~DeviceInterfacePrivate() 00069 { 00070 00071 } 00072 00073 QObject *Solid::DeviceInterfacePrivate::backendObject() const 00074 { 00075 return m_backendObject; 00076 } 00077 00078 void Solid::DeviceInterfacePrivate::setBackendObject(QObject *object) 00079 { 00080 m_backendObject = object; 00081 } 00082 00083 #include "deviceinterface.moc"