[RFC] Extending KCMultiDialog::addModule

Andreas Pakulat apaku at gmx.de
Mon Mar 26 12:53:56 BST 2007


Hi,

trying to work out KDevelop4's configuration stuff I hit a problem.
Currently it uses KCModule's to provide configuration widgets and
kconfigxt stuff, however we need to separate application-global
configuration from project-specific configuration. 

There are two problems when I look at KSettings::Dialog

a) it always loads all kcm's that have ParentApp=kdevelop set.
b) it creates kcm's without any arguments

Now a) could be worked around by setting ParentApp to some non-existant
appname (like kdevelop-project) and use ParentComponents with the same
thing. However b) can only be changed by changing API in kutils.

Now as the solution for a) is also rather hackish I think kdevelop will
use its own methods of discovering the "right" kcm's and createh
KCModuleInfo from that. This means we don't need KSettings::Dialog but
can use KCMultiDialog.

So the change I propose is adding a new argument to the
KCMultiDialog::addModule() methods that resembles the arguments a
KCModule is given during creation. The attached patch adds this and
doesn't need any porting of existing apps.

Any Comments welcome. 

Andreas

-- 
You will be a winner today.  Pick a fight with a four-year-old.
-------------- next part --------------
Index: kcmultidialog.cpp
===================================================================
--- kcmultidialog.cpp	(Revision 646402)
+++ kcmultidialog.cpp	(Arbeitskopie)
@@ -252,7 +252,7 @@ void KCMultiDialog::slotHelpClicked()
 }
 
 
-KPageWidgetItem* KCMultiDialog::addModule( const QString& path )
+KPageWidgetItem* KCMultiDialog::addModule( const QString& path, const QStringList& args )
 {
   QString complete = path;
 
@@ -261,11 +261,11 @@ KPageWidgetItem* KCMultiDialog::addModul
 
   KService::Ptr service = KService::serviceByStorageId( complete );
 
-  return addModule( KCModuleInfo( service ), 0 );
+  return addModule( KCModuleInfo( service ), 0, args );
 }
 
 KPageWidgetItem* KCMultiDialog::addModule( const KCModuleInfo& moduleInfo,
-                                           KPageWidgetItem *parentItem )
+                                           KPageWidgetItem *parentItem, const QStringList& args )
 {
   if ( !moduleInfo.service() )
     return 0;
@@ -286,7 +286,7 @@ KPageWidgetItem* KCMultiDialog::addModul
   else
     addPage( item );
 
-  KCModuleProxy *kcm = new KCModuleProxy( moduleInfo, widget );
+  KCModuleProxy *kcm = new KCModuleProxy( moduleInfo, widget, args );
 
   connect( kcm, SIGNAL( changed( bool ) ), this, SLOT( _k_clientChanged( bool ) ) );
 
Index: kcmultidialog.h
===================================================================
--- kcmultidialog.h	(Revision 646402)
+++ kcmultidialog.h	(Arbeitskopie)
@@ -56,9 +56,11 @@ class KUTILS_EXPORT KCMultiDialog : publ
      * @param module Specify the name of the module that is to be added
      *               to the list of modules the dialog will show.
      *
+     * @param args The arguments that should be given to the KCModule when its created
+     *
      * @returns The @see KPageWidgetItem associated with the new dialog page.
      **/
-    KPageWidgetItem* addModule( const QString& module );
+    KPageWidgetItem* addModule( const QString& module, const QStringList& args = QStringList() );
 
     /**
      * Add a module.
@@ -69,8 +71,10 @@ class KUTILS_EXPORT KCMultiDialog : publ
      *
      * @param parent The @see KPageWidgetItem that should appear as parents
      *               in the tree view or a 0 pointer if there is no parent.
+     *
+     * @param args The arguments that should be given to the KCModule when its created
      **/
-    KPageWidgetItem* addModule( const KCModuleInfo& moduleinfo, KPageWidgetItem *parent = 0 );
+    KPageWidgetItem* addModule( const KCModuleInfo& moduleinfo, KPageWidgetItem *parent = 0, const QStringList& args = QStringList() );
 
     /**
      * Removes all modules from the dialog.


More information about the kde-core-devel mailing list