]>
cloud.milkyroute.net Git - dolphin.git/blob - src/panels/places/placesitem.cpp
1 /***************************************************************************
2 * Copyright (C) 2012 by Peter Penz <peter.penz19@gmail.com> *
4 * Based on KFilePlacesItem from kdelibs: *
5 * Copyright (C) 2007 Kevin Ottens <ervin@kde.org> *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the *
19 * Free Software Foundation, Inc., *
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
21 ***************************************************************************/
23 #include "placesitem.h"
28 #include <Solid/Block>
30 PlacesItem::PlacesItem(PlacesItem
* parent
) :
35 PlacesItem::PlacesItem(const KBookmark
& bookmark
, PlacesItem
* parent
) :
36 KStandardItem(parent
),
42 setHidden(bookmark
.metaDataItem("IsHidden") == QLatin1String("true"));
44 const QString udi
= bookmark
.metaDataItem("UDI");
46 setIcon(bookmark
.icon());
47 setText(bookmark
.text());
48 setUrl(bookmark
.url());
49 setDataValue("address", bookmark
.address());
50 setGroup(i18nc("@item", "Places"));
52 initializeDevice(udi
);
56 PlacesItem::PlacesItem(const QString
& udi
, PlacesItem
* parent
) :
57 KStandardItem(parent
),
63 initializeDevice(udi
);
66 PlacesItem::PlacesItem(const PlacesItem
& item
) :
75 PlacesItem::~PlacesItem()
79 void PlacesItem::setUrl(const KUrl
& url
)
81 setDataValue("url", url
);
84 KUrl
PlacesItem::url() const
86 return dataValue("url").value
<KUrl
>();
89 void PlacesItem::setHidden(bool hidden
)
91 setDataValue("isHidden", hidden
);
94 bool PlacesItem::isHidden() const
96 return dataValue("isHidden").toBool();
99 Solid::Device
PlacesItem::device() const
104 void PlacesItem::initializeDevice(const QString
& udi
)
106 m_device
= Solid::Device(udi
);
107 if (!m_device
.isValid()) {
111 m_access
= m_device
.as
<Solid::StorageAccess
>();
112 m_volume
= m_device
.as
<Solid::StorageVolume
>();
113 m_disc
= m_device
.as
<Solid::OpticalDisc
>();
115 setText(m_device
.description());
116 setIcon(m_device
.icon());
117 setIconOverlays(m_device
.emblems());
118 setDataValue("udi", udi
);
119 setGroup(i18nc("@item", "Devices"));
122 setUrl(m_access
->filePath());
123 } else if (m_disc
&& (m_disc
->availableContent() & Solid::OpticalDisc::Audio
) != 0) {
124 const QString device
= m_device
.as
<Solid::Block
>()->device();
125 setUrl(QString("audiocd:/?device=%1").arg(device
));