• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KUtils

kcmoduleinfo.cpp

Go to the documentation of this file.
00001 /*
00002   Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
00003   Copyright (c) 2000 Matthias Elter <elter@kde.org>
00004   Copyright (c) 2003 Daniel Molkentin <molkentin@kde.org>
00005   Copyright (c) 2003,2006 Matthias Kretz <kretz@kde.org>
00006 
00007   This file is part of the KDE project
00008 
00009   This library is free software; you can redistribute it and/or
00010   modify it under the terms of the GNU Library General Public
00011   License version 2, as published by the Free Software Foundation.
00012 
00013   This library is distributed in the hope that it will be useful,
00014   but WITHOUT ANY WARRANTY; without even the implied warranty of
00015   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016   Library General Public License for more details.
00017 
00018   You should have received a copy of the GNU Library General Public License
00019   along with this library; see the file COPYING.LIB.  If not, write to
00020   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00021   Boston, MA 02110-1301, USA.
00022 */
00023 
00024 #include "kcmoduleinfo.h"
00025 
00026 #include <QtCore/QVariant>
00027 
00028 #include <kdesktopfile.h>
00029 #include <kdebug.h>
00030 #include <kglobal.h>
00031 #include <kstandarddirs.h>
00032 #include <klocale.h>
00033 
00034 class KCModuleInfo::Private
00035 {
00036   public:
00037     Private();
00038     Private( KService::Ptr );
00039 
00040     QStringList keywords;
00041     QString     name, icon, lib, handle, fileName, doc, comment;
00042     bool        allLoaded;
00043     int         weight;
00044 
00045     KService::Ptr service;
00046 
00051     void loadAll();
00052 };
00053 
00054 KCModuleInfo::Private::Private()
00055 {
00056 }
00057 
00058 KCModuleInfo::Private::Private( KService::Ptr s )
00059   : allLoaded( false )
00060   , service( s )
00061 {
00062   if ( !service )
00063   {
00064     kDebug(712) << "Could not find the service.";
00065     return;
00066   }
00067 
00068   // set the modules simple attributes
00069   name = service->name();
00070   comment = service->comment();
00071   icon = service->icon();
00072   fileName = service->entryPath();
00073   lib = service->library();
00074   keywords = service->keywords();
00075 }
00076 
00077 KCModuleInfo::KCModuleInfo()
00078 {
00079   d = new Private;
00080 }
00081 
00082 KCModuleInfo::KCModuleInfo(const QString& desktopFile)
00083 {
00084   d = new Private( KService::serviceByStorageId(desktopFile) );
00085 }
00086 
00087 KCModuleInfo::KCModuleInfo( KService::Ptr moduleInfo )
00088 {
00089   d = new Private( moduleInfo );
00090 }
00091 
00092 KCModuleInfo::KCModuleInfo( const KCModuleInfo &rhs )
00093 {
00094     d = new Private;
00095     ( *this ) = rhs;
00096 }
00097 
00098 KCModuleInfo &KCModuleInfo::operator=( const KCModuleInfo &rhs )
00099 {
00100     *d = *(rhs.d);
00101     return *this;
00102 }
00103 
00104 bool KCModuleInfo::operator==( const KCModuleInfo & rhs ) const
00105 {
00106   return ( ( d->name == rhs.d->name ) && ( d->lib == rhs.d->lib ) && ( d->fileName == rhs.d->fileName ) );
00107 }
00108 
00109 bool KCModuleInfo::operator!=( const KCModuleInfo & rhs ) const
00110 {
00111   return ! operator==( rhs );
00112 }
00113 
00114 KCModuleInfo::~KCModuleInfo()
00115 {
00116   delete d;
00117 }
00118 
00119 void KCModuleInfo::Private::loadAll()
00120 {
00121   allLoaded = true;
00122 
00123   if( !service ) /* We have a bogus service. All get functions will return empty/zero values */
00124     return;
00125 
00126   // get the documentation path
00127   doc = service->property( "X-DocPath", QVariant::String ).toString();
00128   if (doc.isEmpty())
00129     doc = service->property( "DocPath", QVariant::String ).toString();
00130 
00131   // read weight
00132   QVariant tmp = service->property( "X-KDE-Weight", QVariant::Int );
00133   weight = tmp.isValid() ? tmp.toInt() : 100;
00134 
00135   // factory handle
00136   tmp = service->property("X-KDE-FactoryName", QVariant::String);
00137   handle = tmp.isValid() ? tmp.toString() : lib;
00138 
00139 }
00140 
00141 QString KCModuleInfo::fileName() const
00142 {
00143   return d->fileName;
00144 }
00145 
00146 QStringList KCModuleInfo::keywords() const
00147 {
00148   return d->keywords;
00149 }
00150 
00151 QString KCModuleInfo::moduleName() const
00152 {
00153   return d->name;
00154 }
00155 
00156 KService::Ptr KCModuleInfo::service() const
00157 {
00158   return d->service;
00159 }
00160 
00161 QString KCModuleInfo::comment() const
00162 {
00163   return d->comment;
00164 }
00165 
00166 QString KCModuleInfo::icon() const
00167 {
00168   return d->icon;
00169 }
00170 
00171 QString KCModuleInfo::library() const
00172 {
00173   return d->lib;
00174 }
00175 
00176 QString KCModuleInfo::docPath() const
00177 {
00178   if (!d->allLoaded)
00179     d->loadAll();
00180 
00181   return d->doc;
00182 }
00183 
00184 QString KCModuleInfo::handle() const
00185 {
00186   if (!d->allLoaded)
00187     d->loadAll();
00188 
00189   return d->handle;
00190 }
00191 
00192 int KCModuleInfo::weight() const
00193 {
00194   if (!d->allLoaded)
00195     d->loadAll();
00196 
00197   return d->weight;
00198 }
00199 
00200 // vim: ts=2 sw=2 et

KUtils

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal