]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/places/placesitem.h
Output of licensedigger + manual cleanup afterwards.
[dolphin.git] / src / panels / places / placesitem.h
1 /*
2 * SPDX-FileCopyrightText: 2012 Peter Penz <peter.penz19@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #ifndef PLACESITEM_H
8 #define PLACESITEM_H
9
10 #include "kitemviews/kstandarditem.h"
11
12 #include <KBookmark>
13 #include <Solid/Device>
14 #include <Solid/OpticalDisc>
15 #include <Solid/PortableMediaPlayer>
16 #include <Solid/StorageAccess>
17 #include <Solid/StorageVolume>
18
19 #include <QPointer>
20 #include <QUrl>
21
22
23 class KDirLister;
24 class PlacesItemSignalHandler;
25
26 /**
27 * @brief Extends KStandardItem by places-specific properties.
28 */
29 class PlacesItem : public KStandardItem
30 {
31
32 public:
33 explicit PlacesItem(const KBookmark& bookmark, PlacesItem* parent = nullptr);
34 ~PlacesItem() override;
35
36 void setUrl(const QUrl& url);
37 QUrl url() const;
38
39 void setUdi(const QString& udi);
40 QString udi() const;
41
42 void setApplicationName(const QString& applicationName);
43 QString applicationName() const;
44
45 void setHidden(bool hidden);
46 bool isHidden() const;
47
48 void setGroupHidden(bool hidden);
49 bool isGroupHidden() const;
50
51 void setSystemItem(bool isSystemItem);
52 bool isSystemItem() const;
53
54 Solid::Device device() const;
55
56 void setBookmark(const KBookmark& bookmark);
57 KBookmark bookmark() const;
58
59 bool storageSetupNeeded() const;
60
61 bool isSearchOrTimelineUrl() const;
62
63 PlacesItemSignalHandler* signalHandler() const;
64
65 protected:
66 void onDataValueChanged(const QByteArray& role,
67 const QVariant& current,
68 const QVariant& previous) override;
69
70 void onDataChanged(const QHash<QByteArray, QVariant>& current,
71 const QHash<QByteArray, QVariant>& previous) override;
72
73 private:
74 PlacesItem(const PlacesItem& item);
75
76 void initializeDevice(const QString& udi);
77
78 /**
79 * Is invoked if the accessibility of the storage access
80 * m_access has been changed and updates the emblem.
81 */
82 void onAccessibilityChanged();
83
84 /**
85 * Applies the data-value from the role to m_bookmark.
86 */
87 void updateBookmarkForRole(const QByteArray& role);
88
89 static QString generateNewId();
90
91 private:
92 Solid::Device m_device;
93 QPointer<Solid::StorageAccess> m_access;
94 QPointer<Solid::StorageVolume> m_volume;
95 QPointer<Solid::OpticalDisc> m_disc;
96 QPointer<Solid::PortableMediaPlayer> m_player;
97 QPointer<PlacesItemSignalHandler> m_signalHandler;
98 KBookmark m_bookmark;
99
100 friend class PlacesItemSignalHandler; // Calls onAccessibilityChanged()
101 };
102
103 #endif
104
105