1 /***************************************************************************
2 * Copyright (C) 2012 by Peter Penz <peter.penz19@gmail.com> *
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. *
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. *
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 ***************************************************************************/
24 #include <kitemviews/kstandarditem.h>
27 #include <Solid/Device>
28 #include <Solid/OpticalDisc>
29 #include <Solid/StorageAccess>
30 #include <Solid/StorageVolume>
32 class PlacesItemStorageAccessListener
;
35 * @brief Extends KStandardItem by places-specific properties.
37 class PlacesItem
: public KStandardItem
41 explicit PlacesItem(const KBookmark
& bookmark
, PlacesItem
* parent
= 0);
42 explicit PlacesItem(const PlacesItem
& item
);
43 virtual ~PlacesItem();
45 void setUrl(const KUrl
& url
);
48 void setUdi(const QString
& udi
);
51 void setHidden(bool hidden
);
52 bool isHidden() const;
54 void setSystemItem(bool isSystemItem
);
55 bool isSystemItem() const;
57 Solid::Device
device() const;
59 void setBookmark(const KBookmark
& bookmark
);
60 KBookmark
bookmark() const;
62 static KBookmark
createBookmark(KBookmarkManager
* manager
,
65 const QString
& iconName
);
66 static KBookmark
createDeviceBookmark(KBookmarkManager
* manager
,
70 virtual void onDataValueChanged(const QByteArray
& role
,
71 const QVariant
& current
,
72 const QVariant
& previous
);
74 virtual void onDataChanged(const QHash
<QByteArray
, QVariant
>& current
,
75 const QHash
<QByteArray
, QVariant
>& previous
);
78 void initializeDevice(const QString
& udi
);
81 * Is invoked by m_accessListener if the accessibility
82 * of the storage access m_access has been changed.
84 void onAccessibilityChanged();
87 * Applies the data-value from the role to m_bookmark.
89 void updateBookmarkForRole(const QByteArray
& role
);
91 static QString
generateNewId();
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
;
101 friend class PlacesItemStorageAccessListener
; // Calls onAccessibilityChanged()