Baloo

storagedevices.h
1 /*
2  This file is part of the KDE Baloo project.
3  SPDX-FileCopyrightText: 2011 Sebastian Trueg <[email protected]>
4  SPDX-FileCopyrightText: 2014 Vishesh Handa <[email protected]>
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 
17 namespace Baloo
18 {
19 
20 /**
21  * The removable media cache
22  * media that are supported by Baloo.
23  */
24 class StorageDevices : public QObject
25 {
26  Q_OBJECT
27 
28 public:
29  explicit StorageDevices(QObject* parent = nullptr);
30  ~StorageDevices();
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 
61 Q_SIGNALS:
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 
66 private Q_SLOTS:
67  void slotSolidDeviceAdded(const QString& udi);
68  void slotSolidDeviceRemoved(const QString& udi);
69  void slotAccessibilityChanged(bool accessible, const QString& udi);
70 
71 private:
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 
82 #endif // STORAGE_DEVICES_H
Q_OBJECTQ_OBJECT
Q_SLOTSQ_SLOTS
Implements storage for docIds without any associated data Instantiated for:
Definition: coding.cpp:11
Q_SIGNALSQ_SIGNALS
The removable media cache media that are supported by Baloo.
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Nov 29 2023 03:56:26 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.