]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/places/placesitem.h
Merge branch 'Applications/17.12'
[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 <KBookmark>
24 #include <kitemviews/kstandarditem.h>
25 #include <QUrl>
26 #include <QPointer>
27 #include <Solid/Device>
28 #include <Solid/OpticalDisc>
29 #include <Solid/StorageAccess>
30 #include <Solid/StorageVolume>
31 #include <Solid/PortableMediaPlayer>
32
33 class KDirLister;
34 class PlacesItemSignalHandler;
35
36 /**
37 * @brief Extends KStandardItem by places-specific properties.
38 */
39 class PlacesItem : public KStandardItem
40 {
41
42 public:
43 explicit PlacesItem(const KBookmark& bookmark, PlacesItem* parent = nullptr);
44 ~PlacesItem() override;
45
46 void setUrl(const QUrl& url);
47 QUrl url() const;
48
49 void setUdi(const QString& udi);
50 QString udi() const;
51
52 void setHidden(bool hidden);
53 bool isHidden() const;
54
55 void setGroupHidden(bool hidden);
56 bool isGroupHidden() const;
57
58 void setSystemItem(bool isSystemItem);
59 bool isSystemItem() const;
60
61 Solid::Device device() const;
62
63 void setBookmark(const KBookmark& bookmark);
64 KBookmark bookmark() const;
65
66 bool storageSetupNeeded() const;
67
68 bool isSearchOrTimelineUrl() const;
69
70 PlacesItemSignalHandler* signalHandler() const;
71
72 protected:
73 void onDataValueChanged(const QByteArray& role,
74 const QVariant& current,
75 const QVariant& previous) override;
76
77 void onDataChanged(const QHash<QByteArray, QVariant>& current,
78 const QHash<QByteArray, QVariant>& previous) override;
79
80 private:
81 PlacesItem(const PlacesItem& item);
82
83 void initializeDevice(const QString& udi);
84
85 /**
86 * Is invoked if the accessibility of the storage access
87 * m_access has been changed and updates the emblem.
88 */
89 void onAccessibilityChanged();
90
91 /**
92 * Is invoked if the listing of the trash has been completed.
93 * Updates the state of the trash-icon to be empty or full.
94 */
95 void onTrashDirListerCompleted();
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 QPointer<KDirLister> m_trashDirLister;
112 KBookmark m_bookmark;
113
114 friend class PlacesItemSignalHandler; // Calls onAccessibilityChanged()
115 };
116
117 #endif
118
119