Solid

frontend/deviceinterface.cpp
1/*
2 SPDX-FileCopyrightText: 2006-2007 Kevin Ottens <ervin@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include "deviceinterface.h"
8#include "deviceinterface_p.h"
9
10#include <solid/devices/ifaces/deviceinterface.h>
11
12#include <QMetaEnum>
13
14Solid::DeviceInterface::DeviceInterface(DeviceInterfacePrivate &dd, QObject *backendObject)
15 : d_ptr(&dd)
16{
18
19 d->setBackendObject(backendObject);
20}
21
23{
24 delete d_ptr->backendObject();
25 delete d_ptr;
26 d_ptr = nullptr;
27}
28
30{
31 Q_D(const DeviceInterface);
32 return d->backendObject() != nullptr;
33}
34
36{
37 int index = staticMetaObject.indexOfEnumerator("Type");
38 QMetaEnum metaEnum = staticMetaObject.enumerator(index);
39 return QString(metaEnum.valueToKey((int)type));
40}
41
43{
44 int index = staticMetaObject.indexOfEnumerator("Type");
45 QMetaEnum metaEnum = staticMetaObject.enumerator(index);
46 return (Type)metaEnum.keyToValue(type.toUtf8());
47}
48
50{
51 switch (type) {
52 case Unknown:
53 return tr("Unknown", "Unknown device type");
55 return tr("Generic Interface", "Generic Interface device type");
56 case Processor:
57 return tr("Processor", "Processor device type");
58 case Block:
59 return tr("Block", "Block device type");
60 case StorageAccess:
61 return tr("Storage Access", "Storage Access device type");
62 case StorageDrive:
63 return tr("Storage Drive", "Storage Drive device type");
64 case OpticalDrive:
65 return tr("Optical Drive", "Optical Drive device type");
66 case StorageVolume:
67 return tr("Storage Volume", "Storage Volume device type");
68 case OpticalDisc:
69 return tr("Optical Disc", "Optical Disc device type");
70 case Camera:
71 return tr("Camera", "Camera device type");
73 return tr("Portable Media Player", "Portable Media Player device type");
74 case Battery:
75 return tr("Battery", "Battery device type");
76 case NetworkShare:
77 return tr("Network Share", "Network Share device type");
78 case Last:
79 return QString();
80 }
81 return QString();
82}
83
84Solid::DeviceInterfacePrivate::DeviceInterfacePrivate()
85 : m_devicePrivate(nullptr)
86{
87}
88
89Solid::DeviceInterfacePrivate::~DeviceInterfacePrivate()
90{
91}
92
93QObject *Solid::DeviceInterfacePrivate::backendObject() const
94{
95 return m_backendObject.data();
96}
97
98void Solid::DeviceInterfacePrivate::setBackendObject(QObject *object)
99{
100 m_backendObject = object;
101}
102
103Solid::DevicePrivate *Solid::DeviceInterfacePrivate::devicePrivate() const
104{
105 return m_devicePrivate;
106}
107
108void Solid::DeviceInterfacePrivate::setDevicePrivate(DevicePrivate *devicePrivate)
109{
110 m_devicePrivate = devicePrivate;
111}
112
113#include "moc_deviceinterface.cpp"
This device interface is available on batteries.
This device interface is available on block devices.
This device interface is available on digital camera devices.
Base class of all the device interfaces.
static QString typeToString(Type type)
Type
This enum type defines the type of device interface that a Device can have.
bool isValid() const
Indicates if this device interface is valid.
~DeviceInterface() override
Destroys a DeviceInterface object.
static Type stringToType(const QString &type)
SOLID_NO_EXPORT DeviceInterface(DeviceInterfacePrivate &dd, QObject *backendObject)
static QString typeDescription(Type type)
Generic interface to deal with a device.
NetworkShare interface.
This device interface is available on optical discs.
This device interface is available on CD-R*,DVD*,Blu-Ray,HD-DVD drives.
This class implements Portable Media Player device interface and represents a portable media player a...
This device interface is available on processors.
This device interface is available on volume devices to access them (i.e.
This device interface is available on storage devices.
This device interface is available on volume devices.
int keyToValue(const char *key, bool *ok) const const
const char * valueToKey(int value) const const
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:17:12 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.