1 | |
2 | /* |
3 | * kcmcategoryitem.cpp |
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 | #include "kcmcategoryitem.h" |
24 | |
25 | KcmCategoryItem::KcmCategoryItem(const KService::Ptr module, KcmTreeItem *parent) : |
26 | KcmTreeItem(module, parent) |
27 | { |
28 | } |
29 | |
30 | KcmCategoryItem::KcmCategoryItem(const QString& categoryName) : |
31 | KcmTreeItem(), |
32 | m_category(categoryName) |
33 | { |
34 | } |
35 | |
36 | QString KcmCategoryItem::data() const |
37 | { |
38 | if(m_category.isEmpty()) |
39 | { |
40 | return m_moduleInfo->moduleName(); |
41 | } |
42 | else |
43 | { |
44 | return category(); |
45 | } |
46 | } |
47 | |
48 | KcmTreeItem::itemType KcmCategoryItem::type() const |
49 | { |
50 | return CATEGORY; |
51 | } |
52 | |
53 | QString KcmCategoryItem::category() const |
54 | { |
55 | if(m_category.isEmpty()) |
56 | { |
57 | return m_module->property("X-KDE-KInfoCenter-Category" ).toString().trimmed(); |
58 | } |
59 | else |
60 | { |
61 | return m_category; |
62 | } |
63 | } |
64 | |
65 | KCModuleInfo KcmCategoryItem::kcm() const |
66 | { |
67 | return KCModuleInfo(); |
68 | } |
69 | |
70 | int KcmCategoryItem::weight() |
71 | { |
72 | return (category().count() + 1000); |
73 | } |
74 | |
75 | KIcon KcmCategoryItem::icon() const |
76 | { |
77 | if(m_category.isEmpty()) |
78 | { |
79 | return KIcon(m_moduleInfo->icon()); |
80 | } |
81 | else |
82 | { |
83 | return KIcon("" ); |
84 | } |
85 | } |
86 | |
87 | QString KcmCategoryItem::whatsThis() const |
88 | { |
89 | return QString(); |
90 | } |
91 | |
92 | QStringList KcmCategoryItem::keywords() const |
93 | { |
94 | return QStringList(); |
95 | } |
96 | |