[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/work/komo/kdelibs/kutils
From:       Marc Mutz <mutz () kde ! org>
Date:       2010-12-06 16:54:44
Message-ID: 20101206165444.8E9B0AC8A4 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1204290 by mutz:

KCModuleInfo: allow to create one from a KDesktopFile; add noDisplay() to wrap more of KService

 M  +40 -3     kcmoduleinfo.cpp  
 M  +14 -0     kcmoduleinfo.h  


--- branches/work/komo/kdelibs/kutils/kcmoduleinfo.cpp #1204289:1204290
@@ -25,6 +25,7 @@
 
 #include <QtCore/QVariant>
 
+#include <kconfiggroup.h>
 #include <kdesktopfile.h>
 #include <kdebug.h>
 #include <kglobal.h>
@@ -36,10 +37,11 @@
   public:
     Private();
     Private( KService::Ptr );
+    explicit Private( const KDesktopFile & file );
 
     QStringList keywords;
     QString     name, icon, lib, handle, fileName, doc, comment;
-    bool        allLoaded;
+    bool        allLoaded, noDisplay;
     int         weight;
 
     KService::Ptr service;
@@ -52,12 +54,14 @@
 };
 
 KCModuleInfo::Private::Private()
+    : allLoaded( false ), noDisplay( true )
 {
 }
 
 KCModuleInfo::Private::Private( KService::Ptr s )
-  : allLoaded( false )
-  , service( s )
+  : allLoaded( false ),
+    noDisplay( true ),
+    service( s )
 {
   if ( !service )
   {
@@ -72,8 +76,27 @@
   fileName = service->entryPath();
   lib = service->library();
   keywords = service->keywords();
+  noDisplay = service->noDisplay();
 }
 
+KCModuleInfo::Private::Private( const KDesktopFile & file )
+  : keywords( /* below */ ),
+    name( file.readName() ),
+    icon( file.readIcon() ),
+    lib( /* below */ ),
+    handle( /* below */ ),
+    fileName( file.fileName() ),
+    doc( file.readDocPath() ),
+    comment( file.readComment() ),
+    allLoaded( true ),
+    noDisplay( false ) // ### should be like KService::noDisplay()
+{
+  const KConfigGroup desktop = file.desktopGroup();
+  keywords = desktop.readEntry( "X-KDE-Keywords",    QStringList() );
+  handle   = desktop.readEntry( "X-KDE-FactoryName", QString() );
+  weight   = desktop.readEntry( "X-KDE-Weight",      100 );
+}
+
 KCModuleInfo::KCModuleInfo()
 {
   d = new Private;
@@ -89,6 +112,12 @@
   d = new Private( moduleInfo );
 }
 
+KCModuleInfo::KCModuleInfo( const KDesktopFile & file )
+    : d( new Private( file ) )
+{
+
+}
+
 KCModuleInfo::KCModuleInfo( const KCModuleInfo &rhs )
 {
     d = new Private;
@@ -197,4 +226,12 @@
   return d->weight;
 }
 
+bool KCModuleInfo::noDisplay() const
+{
+  if (!d->allLoaded)
+    d->loadAll();
+
+  return d->noDisplay;
+}
+
 // vim: ts=2 sw=2 et
--- branches/work/komo/kdelibs/kutils/kcmoduleinfo.h #1204289:1204290
@@ -30,6 +30,8 @@
 class QString;
 class QStringList;
 
+class KDesktopFile;
+
 /**
  * A class that provides information about a KCModule
  *
@@ -67,7 +69,13 @@
    */
   KCModuleInfo( KService::Ptr moduleInfo );
 
+  /**
+     \overload
 
+     Takes a KDesktopFile as argument.
+  */
+  explicit KCModuleInfo( const KDesktopFile & desktopFile );
+
   /**
    * Same as above but takes a KCModuleInfo as argument.
    *
@@ -153,6 +161,12 @@
    */
   int weight() const;
 
+  /**
+   * @return whether the module is not to be shown.
+   * \sa KService::noDisplay()
+   */
+  bool noDisplay() const;
+
 private:
   class Private;
   Private * d;
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic