Solid

frontend/storagedrive.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 "storagedrive.h"
8#include "storagedrive_p.h"
9
10#include "device.h"
11#include "device_p.h"
12#include "predicate.h"
13#include "soliddefs_p.h"
14#include "storageaccess.h"
15#include <solid/devices/ifaces/storagedrive.h>
16
17Solid::StorageDrive::StorageDrive(QObject *backendObject)
18 : DeviceInterface(*new StorageDrivePrivate(), backendObject)
19{
20}
21
22Solid::StorageDrive::StorageDrive(StorageDrivePrivate &dd, QObject *backendObject)
23 : DeviceInterface(dd, backendObject)
24{
25}
26
30
31Solid::StorageDrive::Bus Solid::StorageDrive::bus() const
32{
33 Q_D(const StorageDrive);
34 return_SOLID_CALL(Ifaces::StorageDrive *, d->backendObject(), Platform, bus());
35}
36
37Solid::StorageDrive::DriveType Solid::StorageDrive::driveType() const
38{
39 Q_D(const StorageDrive);
40 return_SOLID_CALL(Ifaces::StorageDrive *, d->backendObject(), HardDisk, driveType());
41}
42
44{
45 Q_D(const StorageDrive);
46 return_SOLID_CALL(Ifaces::StorageDrive *, d->backendObject(), false, isRemovable());
47}
48
50{
51 Q_D(const StorageDrive);
52 return_SOLID_CALL(Ifaces::StorageDrive *, d->backendObject(), false, isHotpluggable());
53}
54
55qulonglong Solid::StorageDrive::size() const
56{
57 Q_D(const StorageDrive);
58 return_SOLID_CALL(Ifaces::StorageDrive *, d->backendObject(), false, size());
59}
60
62{
63 Q_D(const StorageDrive);
64 Predicate p(DeviceInterface::StorageAccess);
65 const QList<Device> devices = Device::listFromQuery(p, d->devicePrivate()->udi());
66
67 bool inUse = false;
68 for (const Device &dev : devices) {
69 if (dev.is<Solid::StorageAccess>()) {
70 const Solid::StorageAccess *access = dev.as<Solid::StorageAccess>();
71 inUse |= (access->isAccessible());
72 }
73 }
74 return inUse;
75}
76
77QDateTime Solid::StorageDrive::timeDetected() const
78{
79 Q_D(const StorageDrive);
80 return_SOLID_CALL(Ifaces::StorageDrive *, d->backendObject(), QDateTime(), timeDetected());
81}
82
83QDateTime Solid::StorageDrive::timeMediaDetected() const
84{
85 Q_D(const StorageDrive);
86 return_SOLID_CALL(Ifaces::StorageDrive *, d->backendObject(), QDateTime(), timeMediaDetected());
87}
88
89#include "moc_storagedrive.cpp"
Base class of all the device interfaces.
This class allows applications to deal with devices available in the underlying system.
static QList< Device > listFromQuery(const Predicate &predicate, const QString &parentUdi=QString())
Retrieves a list of devices of the system given matching the given constraints (parent and predicate)
This device interface is available on storage devices.
This class implements predicates for devices.
This device interface is available on volume devices to access them (i.e.
bool isAccessible() const
Indicates if this volume is mounted.
This device interface is available on storage devices.
bool isInUse() const
Indicates if the storage device is currently in use i.e.
~StorageDrive() override
Destroys a StorageDrive object.
bool isHotpluggable() const
Indicates if this storage device can be plugged or unplugged while the computer is running.
DriveType
This enum type defines the type of drive a storage device can be.
bool isRemovable() const
Indicates if the media contained by this drive can be removed.
Bus
This enum type defines the type of bus a storage device is attached to.
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:14:22 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.