]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/places/placesitem.h
eccd297fa4bc6e2fbe5595471291e747a3cca215
[dolphin.git] / src / panels / places / placesitem.h
1 /***************************************************************************
2 * Copyright (C) 2012 by Peter Penz <peter.penz19@gmail.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20 #ifndef PLACESITEM_H
21 #define PLACESITEM_H
22
23 #include "kitemviews/kstandarditem.h"
24
25 #include <KBookmark>
26 #include <Solid/Device>
27 #include <Solid/OpticalDisc>
28 #include <Solid/PortableMediaPlayer>
29 #include <Solid/StorageAccess>
30 #include <Solid/StorageVolume>
31
32 #include <QPointer>
33 #include <QUrl>
34
35
36 class KDirLister;
37 class PlacesItemSignalHandler;
38
39 /**
40 * @brief Extends KStandardItem by places-specific properties.
41 */
42 class PlacesItem : public KStandardItem
43 {
44
45 public:
46 explicit PlacesItem(const KBookmark& bookmark, PlacesItem* parent = nullptr);
47 ~PlacesItem() override;
48
49 void setUrl(const QUrl& url);
50 QUrl url() const;
51
52 void setUdi(const QString& udi);
53 QString udi() const;
54
55 void setApplicationName(const QString& applicationName);
56 QString applicationName() const;
57
58 void setHidden(bool hidden);
59 bool isHidden() const;
60
61 void setGroupHidden(bool hidden);
62 bool isGroupHidden() const;
63
64 void setSystemItem(bool isSystemItem);
65 bool isSystemItem() const;
66
67 Solid::Device device() const;
68
69 void setBookmark(const KBookmark& bookmark);
70 KBookmark bookmark() const;
71
72 bool storageSetupNeeded() const;
73
74 bool isSearchOrTimelineUrl() const;
75
76 PlacesItemSignalHandler* signalHandler() const;
77
78 protected:
79 void onDataValueChanged(const QByteArray& role,
80 const QVariant& current,
81 const QVariant& previous) override;
82
83 void onDataChanged(const QHash<QByteArray, QVariant>& current,
84 const QHash<QByteArray, QVariant>& previous) override;
85
86 private:
87 PlacesItem(const PlacesItem& item);
88
89 void initializeDevice(const QString& udi);
90
91 /**
92 * Is invoked if the accessibility of the storage access
93 * m_access has been changed and updates the emblem.
94 */
95 void onAccessibilityChanged();
96
97 /**
98 * Applies the data-value from the role to m_bookmark.
99 */
100 void updateBookmarkForRole(const QByteArray& role);
101
102 static QString generateNewId();
103
104 private:
105 Solid::Device m_device;
106 QPointer<Solid::StorageAccess> m_access;
107 QPointer<Solid::StorageVolume> m_volume;
108 QPointer<Solid::OpticalDisc> m_disc;
109 QPointer<Solid::PortableMediaPlayer> m_mtp;
110 QPointer<PlacesItemSignalHandler> m_signalHandler;
111 KBookmark m_bookmark;
112
113 friend class PlacesItemSignalHandler; // Calls onAccessibilityChanged()
114 };
115
116 #endif
117
118