]> cloud.milkyroute.net Git - dolphin.git/blob - src/kitemviews/kstandarditem.cpp
Bring back basic bookmark support for the Places Panel
[dolphin.git] / src / kitemviews / kstandarditem.cpp
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 #include "kstandarditem.h"
21
22 #include <KDebug>
23
24 KStandardItem::KStandardItem(KStandardItem* parent) :
25 m_parent(parent),
26 m_children(),
27 m_model(0),
28 m_data()
29 {
30 }
31
32 KStandardItem::KStandardItem(const QString& text, KStandardItem* parent) :
33 m_parent(parent),
34 m_children(),
35 m_model(0),
36 m_data()
37 {
38 setText(text);
39 }
40
41 KStandardItem::KStandardItem(const QIcon& icon, const QString& text, KStandardItem* parent) :
42 m_parent(parent),
43 m_children(),
44 m_model(0),
45 m_data()
46 {
47 setIcon(icon);
48 setText(text);
49 }
50
51 KStandardItem::~KStandardItem()
52 {
53 }
54
55 void KStandardItem::setText(const QString& text)
56 {
57 m_data.insert("text", text);
58 }
59
60 QString KStandardItem::text() const
61 {
62 return m_data["text"].toString();
63 }
64
65 void KStandardItem::setIcon(const QIcon& icon)
66 {
67 m_data.insert("iconName", icon.name());
68 }
69
70 QIcon KStandardItem::icon() const
71 {
72 return QIcon(m_data["iconName"].toString());
73 }
74
75 void KStandardItem::setGroup(const QString& group)
76 {
77 m_data.insert("group", group);
78 }
79
80 QString KStandardItem::group() const
81 {
82 return m_data["group"].toString();
83 }
84
85 void KStandardItem::setDataValue(const QByteArray& role, const QVariant& value)
86 {
87 m_data.insert(role, value);
88 }
89
90 QVariant KStandardItem::dataValue(const QByteArray& role) const
91 {
92 return m_data[role];
93 }
94
95 void KStandardItem::setParent(KStandardItem* parent)
96 {
97 // TODO: not implemented yet
98 m_parent = parent;
99 }
100
101 KStandardItem* KStandardItem::parent() const
102 {
103 return m_parent;
104 }
105
106 QHash<QByteArray, QVariant> KStandardItem::data() const
107 {
108 return m_data;
109 }
110
111 QList<KStandardItem*> KStandardItem::children() const
112 {
113 return m_children;
114 }