File: deviceinterface.cpp

package info (click to toggle)
cantata 3.4.0.ds1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 20,428 kB
  • sloc: cpp: 109,584; perl: 1,366; xml: 722; python: 139; lex: 110; sh: 105; yacc: 78; makefile: 8
file content (145 lines) | stat: -rw-r--r-- 4,675 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
    Copyright 2006-2007 Kevin Ottens <ervin@kde.org>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) version 3, or any
    later version accepted by the membership of KDE e.V. (or its
    successor approved by the membership of KDE e.V.), which shall
    act as a proxy defined in Section 6 of version 3 of the license.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/

#include "deviceinterface.h"
#include "deviceinterface_p.h"

#include <solid-lite/ifaces/deviceinterface.h>

#include <QMetaEnum>

Solid::DeviceInterface::DeviceInterface(DeviceInterfacePrivate& dd, QObject* backendObject)
	: d_ptr(&dd)
{
	Q_D(DeviceInterface);

	d->setBackendObject(backendObject);
}

Solid::DeviceInterface::~DeviceInterface()
{
	delete d_ptr;
	d_ptr = nullptr;
}

bool Solid::DeviceInterface::isValid() const
{
	Q_D(const DeviceInterface);
	return d->backendObject() != nullptr;
}

QString Solid::DeviceInterface::typeToString(Type type)
{
	int index = staticMetaObject.indexOfEnumerator("Type");
	QMetaEnum metaEnum = staticMetaObject.enumerator(index);
	return QString(metaEnum.valueToKey((int)type));
}

Solid::DeviceInterface::Type Solid::DeviceInterface::stringToType(const QString& type)
{
	int index = staticMetaObject.indexOfEnumerator("Type");
	QMetaEnum metaEnum = staticMetaObject.enumerator(index);
	return (Type)metaEnum.keyToValue(type.toUtf8());
}

QString Solid::DeviceInterface::typeDescription(Type type)
{
	switch (type) {
	case Unknown:
		return QObject::tr("Unknown", "Unknown device type");
	case GenericInterface:
		return QObject::tr("Generic Interface", "Generic Interface device type");
	//case Processor:
	//    return QObject::tr("Processor", "Processor device type");
	case Block:
		return QObject::tr("Block", "Block device type");
	case StorageAccess:
		return QObject::tr("Storage Access", "Storage Access device type");
	case StorageDrive:
		return QObject::tr("Storage Drive", "Storage Drive device type");
	case OpticalDrive:
		return QObject::tr("Optical Drive", "Optical Drive device type");
	case StorageVolume:
		return QObject::tr("Storage Volume", "Storage Volume device type");
	case OpticalDisc:
		return QObject::tr("Optical Disc", "Optical Disc device type");
	//case Camera:
	//    return QObject::tr("Camera", "Camera device type");
	case PortableMediaPlayer:
		return QObject::tr("Portable Media Player", "Portable Media Player device type");
	/*case NetworkInterface:
        return QObject::tr("Network Interface", "Network Interface device type");
    case AcAdapter:
        return QObject::tr("Ac Adapter", "Ac Adapter device type");
    case Battery:
        return QObject::tr("Battery", "Battery device type");
    case Button:
        return QObject::tr("Button", "Button device type");
    case AudioInterface:
        return QObject::tr("Audio Interface", "Audio Interface device type");
    case DvbInterface:
        return QObject::tr("Dvb Interface", "Dvb Interface device type");
    case Video:
        return QObject::tr("Video", "Video device type");
    case SerialInterface:
        return QObject::tr("Serial Interface", "Serial Interface device type");
    case SmartCardReader:
        return QObject::tr("Smart Card Reader", "Smart Card Reader device type");
    case InternetGateway:
        return QObject::tr("Internet Gateway Device", "Internet Gateway device type");
    case NetworkShare:
        return QObject::tr("Network Share", "Network Share device type");
    */
	case Last:
		return QString();
	}
	return QString();
}

Solid::DeviceInterfacePrivate::DeviceInterfacePrivate()
	: m_devicePrivate(nullptr)
{
}

Solid::DeviceInterfacePrivate::~DeviceInterfacePrivate()
{
}

QObject* Solid::DeviceInterfacePrivate::backendObject() const
{
	return m_backendObject.data();
}

void Solid::DeviceInterfacePrivate::setBackendObject(QObject* object)
{
	m_backendObject = object;
}

Solid::DevicePrivate* Solid::DeviceInterfacePrivate::devicePrivate() const
{
	return m_devicePrivate;
}

void Solid::DeviceInterfacePrivate::setDevicePrivate(DevicePrivate* devicePrivate)
{
	m_devicePrivate = devicePrivate;
}

#include "moc_deviceinterface.cpp"