]> cloud.milkyroute.net Git - dolphin.git/blob - src/kitemviews/kstandarditem.cpp
Places Panel: Allow hiding of items
[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(const KStandardItem& item) :
52 m_parent(item.m_parent),
53 m_children(item.m_children),
54 m_model(item.m_model),
55 m_data(item.m_data)
56 {
57 }
58
59 KStandardItem::~KStandardItem()
60 {
61 }
62
63 void KStandardItem::setText(const QString& text)
64 {
65 m_data.insert("text", text);
66 }
67
68 QString KStandardItem::text() const
69 {
70 return m_data["text"].toString();
71 }
72
73 void KStandardItem::setIcon(const QIcon& icon)
74 {
75 m_data.insert("iconName", icon.name());
76 }
77
78 QIcon KStandardItem::icon() const
79 {
80 return QIcon(m_data["iconName"].toString());
81 }
82
83 void KStandardItem::setGroup(const QString& group)
84 {
85 m_data.insert("group", group);
86 }
87
88 QString KStandardItem::group() const
89 {
90 return m_data["group"].toString();
91 }
92
93 void KStandardItem::setDataValue(const QByteArray& role, const QVariant& value)
94 {
95 m_data.insert(role, value);
96 }
97
98 QVariant KStandardItem::dataValue(const QByteArray& role) const
99 {
100 return m_data[role];
101 }
102
103 void KStandardItem::setParent(KStandardItem* parent)
104 {
105 // TODO: not implemented yet
106 m_parent = parent;
107 }
108
109 KStandardItem* KStandardItem::parent() const
110 {
111 return m_parent;
112 }
113
114 void KStandardItem::setData(const QHash<QByteArray, QVariant>& values)
115 {
116 m_data = values;
117 }
118
119 QHash<QByteArray, QVariant> KStandardItem::data() const
120 {
121 return m_data;
122 }
123
124 QList<KStandardItem*> KStandardItem::children() const
125 {
126 return m_children;
127 }