]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/places/placesitem.h
Fix several bookmark synchronization issues
[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 <KUrl>
26 #include <QPointer>
27 #include <Solid/Device>
28 #include <Solid/OpticalDisc>
29 #include <Solid/StorageAccess>
30 #include <Solid/StorageVolume>
31
32 class PlacesItemStorageAccessListener;
33
34 /**
35 * @brief Extends KStandardItem by places-specific properties.
36 */
37 class PlacesItem : public KStandardItem
38 {
39
40 public:
41 explicit PlacesItem(const KBookmark& bookmark, PlacesItem* parent = 0);
42 explicit PlacesItem(const PlacesItem& item);
43 virtual ~PlacesItem();
44
45 void setUrl(const KUrl& url);
46 KUrl url() const;
47
48 void setUdi(const QString& udi);
49 QString udi() const;
50
51 void setHidden(bool hidden);
52 bool isHidden() const;
53
54 void setSystemItem(bool isSystemItem);
55 bool isSystemItem() const;
56
57 Solid::Device device() const;
58
59 void setBookmark(const KBookmark& bookmark);
60 KBookmark bookmark() const;
61
62 static KBookmark createBookmark(KBookmarkManager* manager,
63 const QString& text,
64 const KUrl& url,
65 const QString& iconName);
66 static KBookmark createDeviceBookmark(KBookmarkManager* manager,
67 const QString& udi);
68
69 protected:
70 virtual void onDataValueChanged(const QByteArray& role,
71 const QVariant& current,
72 const QVariant& previous);
73
74 virtual void onDataChanged(const QHash<QByteArray, QVariant>& current,
75 const QHash<QByteArray, QVariant>& previous);
76
77 private:
78 void initializeDevice(const QString& udi);
79
80 /**
81 * Is invoked by m_accessListener if the accessibility
82 * of the storage access m_access has been changed.
83 */
84 void onAccessibilityChanged();
85
86 /**
87 * Applies the data-value from the role to m_bookmark.
88 */
89 void updateBookmarkForRole(const QByteArray& role);
90
91 static QString generateNewId();
92
93 private:
94 Solid::Device m_device;
95 QPointer<Solid::StorageAccess> m_access;
96 QPointer<Solid::StorageVolume> m_volume;
97 QPointer<Solid::OpticalDisc> m_disc;
98 QPointer<PlacesItemStorageAccessListener> m_accessListener;
99 KBookmark m_bookmark;
100
101 friend class PlacesItemStorageAccessListener; // Calls onAccessibilityChanged()
102 };
103
104 #endif
105
106