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>
7 This file is part of the KDE project
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.
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.
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.
24 #include "kcmoduleinfo.h"
26 #include <QtCore/QVariant>
28 #include <kdesktopfile.h>
31 #include <kstandarddirs.h>
34 class KCModuleInfo::Private
38 Private( KService::Ptr
);
41 QString name
, icon
, lib
, handle
, fileName
, doc
, comment
;
45 KService::Ptr service
;
48 * Reads the service entries specific for KCModule from the desktop file.
49 * The usual desktop entries are read in the Private ctor.
54 KCModuleInfo::Private::Private()
58 KCModuleInfo::Private::Private( KService::Ptr s
)
64 kDebug(712) << "Could not find the service.";
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();
77 KCModuleInfo::KCModuleInfo()
82 KCModuleInfo::KCModuleInfo(const QString
& desktopFile
)
84 d
= new Private( KService::serviceByStorageId(desktopFile
) );
87 KCModuleInfo::KCModuleInfo( KService::Ptr moduleInfo
)
89 d
= new Private( moduleInfo
);
92 KCModuleInfo::KCModuleInfo( const KCModuleInfo
&rhs
)
98 KCModuleInfo
&KCModuleInfo::operator=( const KCModuleInfo
&rhs
)
104 bool KCModuleInfo::operator==( const KCModuleInfo
& rhs
) const
106 return ( ( d
->name
== rhs
.d
->name
) && ( d
->lib
== rhs
.d
->lib
) && ( d
->fileName
== rhs
.d
->fileName
) );
109 bool KCModuleInfo::operator!=( const KCModuleInfo
& rhs
) const
111 return ! operator==( rhs
);
114 KCModuleInfo::~KCModuleInfo()
119 void KCModuleInfo::Private::loadAll()
123 if( !service
) /* We have a bogus service. All get functions will return empty/zero values */
126 // get the documentation path
127 doc
= service
->property( "X-DocPath", QVariant::String
).toString();
129 doc
= service
->property( "DocPath", QVariant::String
).toString();
132 QVariant tmp
= service
->property( "X-KDE-Weight", QVariant::Int
);
133 weight
= tmp
.isValid() ? tmp
.toInt() : 100;
136 tmp
= service
->property("X-KDE-FactoryName", QVariant::String
);
137 handle
= tmp
.isValid() ? tmp
.toString() : lib
;
141 QString
KCModuleInfo::fileName() const
146 QStringList
KCModuleInfo::keywords() const
151 QString
KCModuleInfo::moduleName() const
156 KService::Ptr
KCModuleInfo::service() const
161 QString
KCModuleInfo::comment() const
166 QString
KCModuleInfo::icon() const
171 QString
KCModuleInfo::library() const
176 QString
KCModuleInfo::docPath() const
184 QString
KCModuleInfo::handle() const
192 int KCModuleInfo::weight() const