Solid

fakestorage.cpp
1/*
2 SPDX-FileCopyrightText: 2006 Davide Bettio <davide.bettio@kdemail.net>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include "fakestorage.h"
8#include <QVariant>
9
10using namespace Solid::Backends::Fake;
11
12FakeStorage::FakeStorage(FakeDevice *device)
13 : FakeBlock(device)
14{
15}
16
17FakeStorage::~FakeStorage()
18{
19}
20
21Solid::StorageDrive::Bus FakeStorage::bus() const
22{
23 QString bus = fakeDevice()->property(QStringLiteral("bus")).toString();
24
25 if (bus == QLatin1String("ide")) {
26 return Solid::StorageDrive::Ide;
27 } else if (bus == QLatin1String("usb")) {
28 return Solid::StorageDrive::Usb;
29 } else if (bus == QLatin1String("ieee1394")) {
30 return Solid::StorageDrive::Ieee1394;
31 } else if (bus == QLatin1String("scsi")) {
32 return Solid::StorageDrive::Scsi;
33 } else if (bus == QLatin1String("sata")) {
34 return Solid::StorageDrive::Sata;
35 } else {
36 return Solid::StorageDrive::Platform;
37 }
38}
39
40Solid::StorageDrive::DriveType FakeStorage::driveType() const
41{
42 QString type = fakeDevice()->property(QStringLiteral("major")).toString();
43
44 if (type == QLatin1String("disk")) {
45 return Solid::StorageDrive::HardDisk;
46 } else if (type == QLatin1String("cdrom")) {
47 return Solid::StorageDrive::CdromDrive;
48 } else if (type == QLatin1String("floppy")) {
49 return Solid::StorageDrive::Floppy;
50 } else if (type == QLatin1String("tape")) {
51 return Solid::StorageDrive::Tape;
52 } else if (type == QLatin1String("compact_flash")) {
53 return Solid::StorageDrive::CompactFlash;
54 } else if (type == QLatin1String("memory_stick")) {
55 return Solid::StorageDrive::MemoryStick;
56 } else if (type == QLatin1String("smart_media")) {
57 return Solid::StorageDrive::SmartMedia;
58 } else if (type == QLatin1String("sd_mmc")) {
59 return Solid::StorageDrive::SdMmc;
60 } else {
61 return Solid::StorageDrive::HardDisk;
62 }
63}
64
65bool FakeStorage::isRemovable() const
66{
67 return fakeDevice()->property(QStringLiteral("isRemovable")).toBool();
68}
69
70bool FakeStorage::isHotpluggable() const
71{
72 return fakeDevice()->property(QStringLiteral("isHotpluggable")).toBool();
73}
74
75qulonglong FakeStorage::size() const
76{
77 return fakeDevice()->property(QStringLiteral("size")).toULongLong();
78}
79
80QDateTime FakeStorage::timeDetected() const
81{
82 return fakeDevice()->property(QStringLiteral("timeDetected")).toDateTime();
83}
84
85QDateTime FakeStorage::timeMediaDetected() const
86{
87 return fakeDevice()->property(QStringLiteral("timeMediaDetected")).toDateTime();
88}
89
90#include "moc_fakestorage.cpp"
DriveType
This enum type defines the type of drive a storage device can be.
Bus
This enum type defines the type of bus a storage device is attached to.
Type type(const QSqlDatabase &db)
bool toBool() const const
QDateTime toDateTime() const const
QString toString() const const
qulonglong toULongLong(bool *ok) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:03:23 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.