]>
cloud.milkyroute.net Git - dolphin.git/blob - src/panels/places/placesitem.h
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>
31 #include <Solid/PortableMediaPlayer>
34 class PlacesItemSignalHandler
;
37 * @brief Extends KStandardItem by places-specific properties.
39 class PlacesItem
: public KStandardItem
51 explicit PlacesItem(const KBookmark
& bookmark
, PlacesItem
* parent
= nullptr);
52 ~PlacesItem() override
;
54 void setUrl(const QUrl
& url
);
57 void setUdi(const QString
& udi
);
60 void setHidden(bool hidden
);
61 bool isHidden() const;
63 void setSystemItem(bool isSystemItem
);
64 bool isSystemItem() const;
66 Solid::Device
device() const;
68 void setBookmark(const KBookmark
& bookmark
);
69 KBookmark
bookmark() const;
71 GroupType
groupType() const;
73 bool storageSetupNeeded() const;
75 static KBookmark
createBookmark(KBookmarkManager
* manager
,
78 const QString
& iconName
);
79 static KBookmark
createDeviceBookmark(KBookmarkManager
* manager
,
82 PlacesItemSignalHandler
* signalHandler() const;
85 void onDataValueChanged(const QByteArray
& role
,
86 const QVariant
& current
,
87 const QVariant
& previous
) override
;
89 void onDataChanged(const QHash
<QByteArray
, QVariant
>& current
,
90 const QHash
<QByteArray
, QVariant
>& previous
) override
;
93 PlacesItem(const PlacesItem
& item
);
95 void initializeDevice(const QString
& udi
);
98 * Is invoked if the accessibility of the storage access
99 * m_access has been changed and updates the emblem.
101 void onAccessibilityChanged();
104 * Is invoked if the listing of the trash has been completed.
105 * Updates the state of the trash-icon to be empty or full.
107 void onTrashDirListerCompleted();
110 * Applies the data-value from the role to m_bookmark.
112 void updateBookmarkForRole(const QByteArray
& role
);
114 static QString
generateNewId();
117 Solid::Device m_device
;
118 QPointer
<Solid::StorageAccess
> m_access
;
119 QPointer
<Solid::StorageVolume
> m_volume
;
120 QPointer
<Solid::OpticalDisc
> m_disc
;
121 QPointer
<Solid::PortableMediaPlayer
> m_mtp
;
122 QPointer
<PlacesItemSignalHandler
> m_signalHandler
;
123 QPointer
<KDirLister
> m_trashDirLister
;
124 KBookmark m_bookmark
;
126 friend class PlacesItemSignalHandler
; // Calls onAccessibilityChanged()