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

List:       kde-commits
Subject:    playground/sysadmin/kextprocess/lib
From:       Martijn Klingens <klingens () kde ! org>
Date:       2005-07-31 18:40:08
Message-ID: 1122835208.938724.20266.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 441717 by mklingens:

List all stored profiles as a first step towards implementing the
loading of profiles.

I'm not exactly happy with the messing I'm doing with KStandardDirs to
be independent of the name of the application. Perhaps I should indeed
use my own KStandardDirs instance and add "data/kextprocess" as an
official resource. For now it works, perhaps I should talk to coolo or
antonio at aKademy about it...



 M  +17 -1     profile.cpp  
 M  +8 -0      profile.h  
 M  +6 -0      profilepropertieswidget.cpp  


--- trunk/playground/sysadmin/kextprocess/lib/profile.cpp #441716:441717
@@ -122,6 +122,22 @@
     emit stepMoved( step, index, index + 1 );
 }
 
+QStringList Profile::profileList()
+{
+    // Return relative paths, so they can be displayed in a GUI
+    KStandardDirs *dirs = KGlobal::dirs();
+    QStringList absPaths = dirs->findAllResources( "data", "kextprocess/*" );
+    QStringList relPaths;
+    for ( QStringList::Iterator it = absPaths.begin(); it != absPaths.end(); ++it )
+    {
+        QString rel = dirs->relativeLocation( "data", *it ).replace(
+            "kextprocess/", QString::null );
+        relPaths.append( rel );
+    }
+
+    return relPaths;
+}
+
 void Profile::save( const QString &filename )
 {
     QString baseName = QFileInfo( filename ).baseName();
@@ -131,7 +147,7 @@
             "' contains a directory portion! Truncated to '" << baseName << "'." << endl;
     }
 
-    QString fileName = KStandardDirs().saveLocation( "data", "kextprocess/", true ) + baseName;
+    QString fileName = KGlobal::dirs()->saveLocation( "data", "kextprocess/", true ) + baseName;
 
     // Make sure we don't have an existing file. Since the file might not
     // exist yet, don't assume 'false' is an error and don't check for it.
--- trunk/playground/sysadmin/kextprocess/lib/profile.h #441716:441717
@@ -118,6 +118,14 @@
      */
     void save( const QString &filename );
 
+    /**
+     * Return a list of all available profiles
+     *
+     * @return The list of profiles, containing only the filename portion,
+     * without path.
+     */
+    static QStringList profileList();
+
 signals:
     /**
      * Emitted AFTER a profile step is moved. You can use the passed
--- trunk/playground/sysadmin/kextprocess/lib/profilepropertieswidget.cpp #441716:441717
@@ -14,6 +14,7 @@
 
 #include "profilepropertieswidget.h"
 
+#include <qcombobox.h>
 #include <qlabel.h>
 #include <qlayout.h>
 #include <qlineedit.h>
@@ -108,6 +109,11 @@
     slotDefault();
 
     enableButtons();
+
+    // Load the list of available profiles
+    QStringList profiles = Profile::profileList();
+    for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it )
+        d->mainWidget->m_profileList->insertItem( *it );
 }
 
 void ProfilePropertiesWidget::slotDefault()
[prev in list] [next in list] [prev in thread] [next in thread] 

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