Baloo

storagedevices.h
1/*
2 This file is part of the KDE Baloo project.
3 SPDX-FileCopyrightText: 2011 Sebastian Trueg <trueg@kde.org>
4 SPDX-FileCopyrightText: 2014 Vishesh Handa <vhanda@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7*/
8
9#ifndef STORAGE_DEVICES_H
10#define STORAGE_DEVICES_H
11
12#include <QObject>
13#include <QHash>
14
15#include <Solid/Device>
16
17namespace Baloo
18{
19
20/**
21 * The removable media cache
22 * media that are supported by Baloo.
23 */
24class StorageDevices : public QObject
25{
27
28public:
29 explicit StorageDevices(QObject* parent = nullptr);
31
32 class Entry
33 {
34 public:
35 Entry();
36 explicit Entry(const Solid::Device& device);
37
38 Solid::Device device() const {
39 return m_device;
40 }
41
42 bool isMounted() const;
43 QString mountPath() const;
44
45 /**
46 * Returns true if Baloo should be indexing this
47 * Currently we only index permanently mounted media
48 */
49 bool isUsable() const;
50
51 QString udi() const {
52 return m_device.udi();
53 }
54 private:
55 Solid::Device m_device;
56 };
57
58 QList<Entry> allMedia() const;
59 bool isEmpty() const;
60
62 void deviceAdded(const Baloo::StorageDevices::Entry* entry);
63 void deviceRemoved(const Baloo::StorageDevices::Entry* entry);
64 void deviceAccessibilityChanged(const Baloo::StorageDevices::Entry* entry);
65
66private Q_SLOTS:
67 void slotSolidDeviceAdded(const QString& udi);
68 void slotSolidDeviceRemoved(const QString& udi);
69 void slotAccessibilityChanged(bool accessible, const QString& udi);
70
71private:
72 void initCacheEntries();
73
74 Entry* createCacheEntry(const Solid::Device& dev);
75
76 /// maps Solid UDI to Entry
77 QHash<QString, Entry> m_metadataCache;
78};
79
80} // namespace Baloo
81
82Q_DECLARE_TYPEINFO(Baloo::StorageDevices::Entry, Q_RELOCATABLE_TYPE);
83
84#endif // STORAGE_DEVICES_H
The removable media cache media that are supported by Baloo.
QString udi() const
Implements storage for docIds without any associated data Instantiated for:
Definition coding.cpp:11
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:56:58 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.