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::fromLatin1(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().constData());
47}
48
50{
51 switch (type) {
52 case Unknown:
53 return tr("Unknown", "Unknown device type");
54 case GenericInterface:
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");
72 case PortableMediaPlayer:
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"
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)
int keyToValue(const char *key, bool *ok) const const
const char * valueToKey(int value) const const
QObject(QObject *parent)
QString tr(const char *sourceText, const char *disambiguation, int n)
QString fromLatin1(QByteArrayView str)
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:47:11 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.