• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KUtils

  • kutils
kcmoduleinfo.cpp
Go to the documentation of this file.
1/*
2 Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
3 Copyright (c) 2000 Matthias Elter <elter@kde.org>
4 Copyright (c) 2003 Daniel Molkentin <molkentin@kde.org>
5 Copyright (c) 2003,2006 Matthias Kretz <kretz@kde.org>
6
7 This file is part of the KDE project
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public
11 License version 2, as published by the Free Software Foundation.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details.
17
18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA.
22*/
23
24#include "kcmoduleinfo.h"
25
26#include <QtCore/QVariant>
27
28#include <kdesktopfile.h>
29#include <kdebug.h>
30#include <kglobal.h>
31#include <kstandarddirs.h>
32#include <klocale.h>
33
34class KCModuleInfo::Private
35{
36 public:
37 Private();
38 Private( KService::Ptr );
39
40 QStringList keywords;
41 QString name, icon, lib, handle, fileName, doc, comment;
42 bool allLoaded;
43 int weight;
44
45 KService::Ptr service;
46
51 void loadAll();
52};
53
54KCModuleInfo::Private::Private()
55{
56}
57
58KCModuleInfo::Private::Private( KService::Ptr s )
59 : allLoaded( false )
60 , service( s )
61{
62 if ( !service )
63 {
64 kDebug(712) << "Could not find the service.";
65 return;
66 }
67
68 // set the modules simple attributes
69 name = service->name();
70 comment = service->comment();
71 icon = service->icon();
72 fileName = service->entryPath();
73 lib = service->library();
74 keywords = service->keywords();
75}
76
77KCModuleInfo::KCModuleInfo()
78{
79 d = new Private;
80}
81
82KCModuleInfo::KCModuleInfo(const QString& desktopFile)
83{
84 d = new Private( KService::serviceByStorageId(desktopFile) );
85}
86
87KCModuleInfo::KCModuleInfo( KService::Ptr moduleInfo )
88{
89 d = new Private( moduleInfo );
90}
91
92KCModuleInfo::KCModuleInfo( const KCModuleInfo &rhs )
93{
94 d = new Private;
95 ( *this ) = rhs;
96}
97
98KCModuleInfo &KCModuleInfo::operator=( const KCModuleInfo &rhs )
99{
100 *d = *(rhs.d);
101 return *this;
102}
103
104bool KCModuleInfo::operator==( const KCModuleInfo & rhs ) const
105{
106 return ( ( d->name == rhs.d->name ) && ( d->lib == rhs.d->lib ) && ( d->fileName == rhs.d->fileName ) );
107}
108
109bool KCModuleInfo::operator!=( const KCModuleInfo & rhs ) const
110{
111 return ! operator==( rhs );
112}
113
114KCModuleInfo::~KCModuleInfo()
115{
116 delete d;
117}
118
119void KCModuleInfo::Private::loadAll()
120{
121 allLoaded = true;
122
123 if( !service ) /* We have a bogus service. All get functions will return empty/zero values */
124 return;
125
126 // get the documentation path
127 doc = service->property( "X-DocPath", QVariant::String ).toString();
128 if (doc.isEmpty())
129 doc = service->property( "DocPath", QVariant::String ).toString();
130
131 // read weight
132 QVariant tmp = service->property( "X-KDE-Weight", QVariant::Int );
133 weight = tmp.isValid() ? tmp.toInt() : 100;
134
135 // factory handle
136 tmp = service->property("X-KDE-FactoryName", QVariant::String);
137 handle = tmp.isValid() ? tmp.toString() : lib;
138
139}
140
141QString KCModuleInfo::fileName() const
142{
143 return d->fileName;
144}
145
146QStringList KCModuleInfo::keywords() const
147{
148 return d->keywords;
149}
150
151QString KCModuleInfo::moduleName() const
152{
153 return d->name;
154}
155
156KService::Ptr KCModuleInfo::service() const
157{
158 return d->service;
159}
160
161QString KCModuleInfo::comment() const
162{
163 return d->comment;
164}
165
166QString KCModuleInfo::icon() const
167{
168 return d->icon;
169}
170
171QString KCModuleInfo::library() const
172{
173 return d->lib;
174}
175
176QString KCModuleInfo::docPath() const
177{
178 if (!d->allLoaded)
179 d->loadAll();
180
181 return d->doc;
182}
183
184QString KCModuleInfo::handle() const
185{
186 if (!d->allLoaded)
187 d->loadAll();
188
189 return d->handle;
190}
191
192int KCModuleInfo::weight() const
193{
194 if (!d->allLoaded)
195 d->loadAll();
196
197 return d->weight;
198}
199
200// vim: ts=2 sw=2 et
KCModuleInfo
A class that provides information about a KCModule.
Definition: kcmoduleinfo.h:48
KCModuleInfo::library
QString library() const
Definition: kcmoduleinfo.cpp:171
KCModuleInfo::fileName
QString fileName() const
Definition: kcmoduleinfo.cpp:141
KCModuleInfo::operator=
KCModuleInfo & operator=(const KCModuleInfo &rhs)
Assignment operator.
Definition: kcmoduleinfo.cpp:98
KCModuleInfo::service
KService::Ptr service() const
Definition: kcmoduleinfo.cpp:156
KCModuleInfo::comment
QString comment() const
Definition: kcmoduleinfo.cpp:161
KCModuleInfo::icon
QString icon() const
Definition: kcmoduleinfo.cpp:166
KCModuleInfo::~KCModuleInfo
~KCModuleInfo()
Default destructor.
Definition: kcmoduleinfo.cpp:114
KCModuleInfo::keywords
QStringList keywords() const
Definition: kcmoduleinfo.cpp:146
KCModuleInfo::weight
int weight() const
Definition: kcmoduleinfo.cpp:192
KCModuleInfo::operator==
bool operator==(const KCModuleInfo &rhs) const
Returns true if rhs describes the same KCModule as this object.
Definition: kcmoduleinfo.cpp:104
KCModuleInfo::KCModuleInfo
KCModuleInfo()
Same as above but creates an empty KCModuleInfo.
Definition: kcmoduleinfo.cpp:77
KCModuleInfo::docPath
QString docPath() const
Definition: kcmoduleinfo.cpp:176
KCModuleInfo::operator!=
bool operator!=(const KCModuleInfo &rhs) const
Definition: kcmoduleinfo.cpp:109
KCModuleInfo::moduleName
QString moduleName() const
Definition: kcmoduleinfo.cpp:151
KCModuleInfo::handle
QString handle() const
Definition: kcmoduleinfo.cpp:184
KService::serviceByStorageId
static Ptr serviceByStorageId(const QString &_storageId)
KSharedPtr< KService >
kDebug
#define kDebug
kcmoduleinfo.h
kdebug.h
kdesktopfile.h
kglobal.h
klocale.h
kstandarddirs.h
name
const char * name(StandardAction id)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KUtils

Skip menu "KUtils"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal