1
2/*
3 * kcmtreeitem.h
4 *
5 * Copyright (C) 2010 David Hubner <hubnerd@ntlworld.com>
6 *
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.
11 *
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.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 *
21 */
22
23#ifndef KCMTREEITEM
24#define KCMTREEITEM
25
26//KDE
27#include <KCModuleInfo>
28#include <KIcon>
29
30//QT
31#include <QList>
32#include <QString>
33
34class KcmTreeItem
35{
36 public:
37
38 /**
39 * KCM Tree Item for InfoKcmModel. Holds information about a KCM
40 *
41 * @param module pointer to KCM module
42 * @param parent objects parent
43 */
44 explicit KcmTreeItem(const KService::Ptr module, KcmTreeItem *parent=0);
45
46 /**
47 * KCM Tree Item for InfoKcmModel. Holds information about a KCM
48 *
49 * @note Used for root folder objects
50 *
51 */
52 KcmTreeItem();
53
54 /**
55 * Enumeration of the possible tree item types
56 *
57 */
58 enum itemType { KCM=0, CATEGORY };
59
60 /**
61 * Destory KcmTreeItem
62 */
63 virtual ~KcmTreeItem();
64
65 /**
66 * Add child tree item to parent
67 */
68 void addChild(KcmTreeItem *);
69
70 /**
71 * Get child tree item
72 *
73 * @param row row where child is located
74 */
75 KcmTreeItem *child(const int row);
76
77 /**
78 * Get amount of children
79 */
80 int childCount();
81
82 /**
83 * Get parent of current tree item
84 */
85 KcmTreeItem *parent();
86
87 /**
88 * Get index of tree item
89 */
90 int indexOf(KcmTreeItem *);
91
92 /**
93 * Get amount of columns that tree item contains.
94 * Hardcoded to 1
95 */
96 int columnCount();
97
98 /**
99 * Get row of tree item
100 */
101 int row();
102
103 /**
104 * Get data of tree item
105 */
106 virtual QString data() const;
107
108 /**
109 * Get category of tree item.
110 * Set in X-KDE-KInfoCenter-Category
111 */
112 virtual QString category() const;
113
114 /**
115 * Gets the item type.
116 */
117 virtual itemType type() const;
118
119 /**
120 * Check if children of tree item contains a category.
121 * Used in search implementation
122 */
123 KcmTreeItem *containsCategory(const QString&);
124
125 /**
126 * Get tree item KCMs Data
127 */
128 virtual KCModuleInfo kcm() const;
129
130 /**
131 * Get tree items KCM's weight
132 */
133 virtual int weight();
134
135 /**
136 * Get icon tied to KCM
137 */
138 virtual KIcon icon() const;
139
140 /**
141 * Get whatsThis information from KCM
142 */
143 virtual QString whatsThis() const;
144
145 /**
146 * Check if there are any children tree items keywords that
147 * have a certain regexp pattern
148 */
149 bool childrenRegExp(const QRegExp& pattern);
150
151 /**
152 * Get KCM tree item keywords
153 */
154 virtual QStringList keywords() const;
155
156 protected:
157
158 QList<KcmTreeItem *> m_children;
159 KcmTreeItem *m_parent;
160 const KService::Ptr m_module;
161
162 const KCModuleInfo *m_moduleInfo;
163};
164
165#endif // KCMTREEITEM
166