Extending KSettings::Dialog to allow to specify excludes
Andreas Pakulat
apaku at gmx.de
Mon Jun 18 23:33:27 BST 2007
On 18.06.07 23:39:52, Andreas Pakulat wrote:
> Hi,
>
> for KDevelop's and other KDevPlatform-using Applications Configuration
> dialog (using KSettings::Dialog) its needed to be able to supply
> KSettings::Dialog with a list of component names that shouldn't be
> loaded even if the component has parentApp == current mainComponent in
> the application.
>
> For example currentl the KDevelop Config dialog tries to load the
> configuration pages for QMake, which should only be visible in the
> project configuration dialog. This actually asserts in the qmake kcm
> because its missing some arguments.
>
> So I'm proposing to change the constructors to:
> explicit Dialog( const QStringList & components, QWidget * parent = 0,
> const QStringList& arguments = QStringList(),
> const QStringList& blackListComponents = QStringList() );
> explicit Dialog( ContentInListView content = Static, QWidget * parent = 0,
> const QStringList& arguments = QStringList(),
> const QStringList& blackListComponents = QStringList() );
> Dialog( const QStringList & components, ContentInListView
> content, QWidget * parent = 0,
> const QStringList& arguments = QStringList(),
> const QStringList& blackListComponents = QStringList() );
>
> I can't provide a full patch atm, because Matthias wanted to do some
> cleanups in ksettings today or the next days. I will provide one as soon
> as thats done.
Hehe, just when I sent the mail Matthias finished its work and comitted.
So here's the patch that I'd like to commit next monday 25th. It allows
to give the KSettings::Dialog another QStringList which holds the
name of any component for which no kcm should be loaded.
Andreas
--
Write yourself a threatening letter and pen a defiant reply.
-------------- next part --------------
Index: dialog.cpp
===================================================================
--- dialog.cpp (Revision 677317)
+++ dialog.cpp (Arbeitskopie)
@@ -36,30 +36,36 @@
namespace KSettings
{
-Dialog::Dialog(ContentInListView content, QWidget *parent, const QStringList &arguments)
+Dialog::Dialog(ContentInListView content, QWidget *parent, const QStringList &arguments,
+ const QStringList &blacklistComponents)
: KCMultiDialog(parent), d_ptr(new DialogPrivate(this, parent, (content == Static), arguments))
{
Q_D(Dialog);
d->q_ptr = this;
d->services = d->instanceServices();
+ d->componentBlacklist = blacklistComponents;
d->removeDuplicateServices();
}
-Dialog::Dialog(const QStringList &components, QWidget *parent, const QStringList &arguments)
+Dialog::Dialog(const QStringList &components, QWidget *parent, const QStringList &arguments,
+ const QStringList &blacklistComponents)
: KCMultiDialog(parent), d_ptr(new DialogPrivate(this, parent, true, arguments))
{
Q_D(Dialog);
d->q_ptr = this;
d->services = d->instanceServices() + d->parentComponentsServices(components);
+ d->componentBlacklist = blacklistComponents;
d->removeDuplicateServices();
}
-Dialog::Dialog(const QStringList &components, ContentInListView content, QWidget *parent, const QStringList &arguments)
+Dialog::Dialog(const QStringList &components, ContentInListView content, QWidget *parent,
+ const QStringList &arguments, const QStringList &blacklistComponents)
: KCMultiDialog(parent), d_ptr(new DialogPrivate(this, parent, (content == Static), arguments))
{
Q_D(Dialog);
d->q_ptr = this;
d->services = d->instanceServices() + d->parentComponentsServices(components);
+ d->componentBlacklist = blacklistComponents;
d->removeDuplicateServices();
}
@@ -216,6 +222,18 @@ void DialogPrivate::createDialogFromServ
for (QList<KService::Ptr>::ConstIterator it = services.begin(); it != services.end(); ++it) {
// we create the KCModuleInfo
KCModuleInfo * info = new KCModuleInfo( *it );
+ kDebug() << k_funcinfo << "Checking wether " << info->moduleName() << " should be loaded" << endl;
+ bool blacklisted = false;
+ foreach( QString comp, (*it)->property( "X-KDE-ParentComponents" ).toStringList() )
+ {
+ kDebug() << k_funcinfo << "Checking if " << comp << " is in " << componentBlacklist << endl;
+ if( componentBlacklist.contains(comp) )
+ {
+ blacklisted = true;
+ }
+ }
+ if( blacklisted )
+ continue;
QString parentid;
QVariant tmp = info->service()->property( "X-KDE-CfgDlgHierarchy",
QVariant::String );
Index: dialog_p.h
===================================================================
--- dialog_p.h (Revision 677317)
+++ dialog_p.h (Arbeitskopie)
@@ -318,6 +318,7 @@ class DialogPrivate
PageNode pagetree;
QStringList registeredComponents;
+ QStringList componentBlacklist;
QList<KService::Ptr> services;
QMap<QString, KPluginInfo*> plugininfomap;
QStringList arguments;
Index: dialog.h
===================================================================
--- dialog.h (Revision 677317)
+++ dialog.h (Arbeitskopie)
@@ -106,7 +106,8 @@ class KUTILS_EXPORT Dialog : public KCMu
* KCModules when adding them to the dialog
*/
explicit Dialog( ContentInListView content = Static, QWidget * parent = 0,
- const QStringList& arguments = QStringList() );
+ const QStringList& arguments = QStringList(),
+ const QStringList& blacklistComponents = QStringList() );
/**
* Construct a new Preferences Dialog with the pages for the selected
@@ -123,7 +124,8 @@ class KUTILS_EXPORT Dialog : public KCMu
* KCModules when adding them to the dialog
*/
explicit Dialog( const QStringList & components, QWidget * parent = 0,
- const QStringList& arguments = QStringList() );
+ const QStringList& arguments = QStringList(),
+ const QStringList& blacklistComponents = QStringList() );
/**
* Construct a new Preferences Dialog with the pages for the selected
@@ -143,7 +145,8 @@ class KUTILS_EXPORT Dialog : public KCMu
*/
Dialog( const QStringList & components, ContentInListView
content, QWidget * parent = 0,
- const QStringList& arguments = QStringList() );
+ const QStringList& arguments = QStringList(),
+ const QStringList& blacklistComponents = QStringList() );
~Dialog();
More information about the kde-core-devel
mailing list