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("bus").toString();
24
25 if (bus == "ide") {
26 return Solid::StorageDrive::Ide;
27 } else if (bus == "usb") {
28 return Solid::StorageDrive::Usb;
29 } else if (bus == "ieee1394") {
30 return Solid::StorageDrive::Ieee1394;
31 } else if (bus == "scsi") {
32 return Solid::StorageDrive::Scsi;
33 } else if (bus == "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("major").toString();
43
44 if (type == "disk") {
45 return Solid::StorageDrive::HardDisk;
46 } else if (type == "cdrom") {
47 return Solid::StorageDrive::CdromDrive;
48 } else if (type == "floppy") {
49 return Solid::StorageDrive::Floppy;
50 } else if (type == "tape") {
51 return Solid::StorageDrive::Tape;
52 } else if (type == "compact_flash") {
53 return Solid::StorageDrive::CompactFlash;
54 } else if (type == "memory_stick") {
55 return Solid::StorageDrive::MemoryStick;
56 } else if (type == "smart_media") {
57 return Solid::StorageDrive::SmartMedia;
58 } else if (type == "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("isRemovable").toBool();
68}
69
70bool FakeStorage::isHotpluggable() const
71{
72 return fakeDevice()->property("isHotpluggable").toBool();
73}
74
75qulonglong FakeStorage::size() const
76{
77 return fakeDevice()->property("size").toULongLong();
78}
79
80QDateTime FakeStorage::timeDetected() const
81{
82 return fakeDevice()->property("timeDetected").toDateTime();
83}
84
85QDateTime FakeStorage::timeMediaDetected() const
86{
87 return fakeDevice()->property("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 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.