Extending KSettings::Dialog to allow to specify excludes
Andreas Pakulat
apaku at gmx.de
Wed Jun 20 16:58:15 BST 2007
On 18.06.07 21:16:46, Aaron J. Seigo wrote:
> On Monday 18 June 2007, Andreas Pakulat wrote:
> > However this setter will only work before the show() method of the
> > dialog is called the first time. Because afterwards
> > createDialogFromServices is not executed anymore. So the setter is not
> > really a setter, its more an initializer.
>
> true; but at least it helps keep the ctors cleaner and perhaps at some point
> we can actually make it generally useful (e.g. if it's already init'd, when
> the blacklist is set it could remove panels that match... just a thought, and
> certainly not necessary imho for 4.0.. in fact, i'd actually be surprised if
> anyone used it in that manner at all)
>
> > How about initializeComponentBlacklist( const QStringList&)?
>
> =)
Ok, here's the updated patch, as I said I also moved the argument-list
out of the constructor as its not needed there (wonder what drove me to
put it there). Also the new functions now have proper apidox.
Andreas
--
A tall, dark stranger will have more fun than you.
-------------- next part --------------
Index: dialog.cpp
===================================================================
--- dialog.cpp (Revision 677983)
+++ dialog.cpp (Arbeitskopie)
@@ -36,8 +36,8 @@
namespace KSettings
{
-Dialog::Dialog(ContentInListView content, QWidget *parent, const QStringList &arguments)
- : KCMultiDialog(parent), d_ptr(new DialogPrivate(this, parent, (content == Static), arguments))
+Dialog::Dialog(ContentInListView content, QWidget *parent)
+ : KCMultiDialog(parent), d_ptr(new DialogPrivate(this, parent, (content == Static)))
{
Q_D(Dialog);
d->q_ptr = this;
@@ -45,8 +45,8 @@ Dialog::Dialog(ContentInListView content
d->removeDuplicateServices();
}
-Dialog::Dialog(const QStringList &components, QWidget *parent, const QStringList &arguments)
- : KCMultiDialog(parent), d_ptr(new DialogPrivate(this, parent, true, arguments))
+Dialog::Dialog(const QStringList &components, QWidget *parent)
+ : KCMultiDialog(parent), d_ptr(new DialogPrivate(this, parent, true))
{
Q_D(Dialog);
d->q_ptr = this;
@@ -54,8 +54,8 @@ Dialog::Dialog(const QStringList &compon
d->removeDuplicateServices();
}
-Dialog::Dialog(const QStringList &components, ContentInListView content, QWidget *parent, const QStringList &arguments)
- : KCMultiDialog(parent), d_ptr(new DialogPrivate(this, parent, (content == Static), arguments))
+Dialog::Dialog(const QStringList &components, ContentInListView content, QWidget *parent)
+ : KCMultiDialog(parent), d_ptr(new DialogPrivate(this, parent, (content == Static)))
{
Q_D(Dialog);
d->q_ptr = this;
@@ -68,6 +68,19 @@ Dialog::~Dialog()
delete d_ptr;
}
+
+void Dialog::initializeKCMArguments( const QStringList& arguments )
+{
+ Q_D(Dialog);
+ d->arguments = arguments;
+}
+
+void Dialog::initializeComponentBlacklist( const QStringList& blacklist )
+{
+ Q_D(Dialog);
+ d->componentBlacklist = blacklist;
+}
+
void Dialog::addPluginInfos( const QList<KPluginInfo*> & plugininfos )
{
Q_D(Dialog);
@@ -90,8 +103,8 @@ void Dialog::show()
return d->dlg->show();
}
-DialogPrivate::DialogPrivate(Dialog *d, QWidget *p, bool s, const QStringList &a)
- : pagetree(d), arguments(a), dlg(0), parentwidget(p), staticlistview(s)
+DialogPrivate::DialogPrivate(Dialog *d, QWidget *p, bool s)
+ : pagetree(d), dlg(0), parentwidget(p), staticlistview(s)
{
}
@@ -216,6 +229,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 677983)
+++ dialog_p.h (Arbeitskopie)
@@ -313,11 +313,12 @@ class DialogPrivate
friend class PageNode;
Q_DECLARE_PUBLIC(Dialog)
protected:
- DialogPrivate(Dialog *d, QWidget *p, bool s, const QStringList &a);
+ DialogPrivate(Dialog *d, QWidget *p, bool s);
PageNode pagetree;
QStringList registeredComponents;
+ QStringList componentBlacklist;
QList<KService::Ptr> services;
QMap<QString, KPluginInfo*> plugininfomap;
QStringList arguments;
Index: dialog.h
===================================================================
--- dialog.h (Revision 677983)
+++ dialog.h (Arbeitskopie)
@@ -102,11 +102,8 @@ class KUTILS_EXPORT Dialog : public KCMu
* @param parent The parent is only used as the parent for the
* dialog - centering the dialog over the parent
* widget.
- * @param arguments A list of arguments that are passed to all
- * KCModules when adding them to the dialog
*/
- explicit Dialog( ContentInListView content = Static, QWidget * parent = 0,
- const QStringList& arguments = QStringList() );
+ explicit Dialog( ContentInListView content = Static, QWidget * parent = 0 );
/**
* Construct a new Preferences Dialog with the pages for the selected
@@ -119,11 +116,8 @@ class KUTILS_EXPORT Dialog : public KCMu
* @param parent The parent is only used as the parent for the
* dialog - centering the dialog over the parent
* widget.
- * @param arguments A list of arguments that are passed to all
- * KCModules when adding them to the dialog
*/
- explicit Dialog( const QStringList & components, QWidget * parent = 0,
- const QStringList& arguments = QStringList() );
+ explicit Dialog( const QStringList & components, QWidget * parent = 0 );
/**
* Construct a new Preferences Dialog with the pages for the selected
@@ -138,12 +132,9 @@ class KUTILS_EXPORT Dialog : public KCMu
* @param parent The parent is only used as the parent for the
* dialog - centering the dialog over the parent
* widget.
- * @param arguments A list of arguments that are passed to all
- * KCModules when adding them to the dialog
*/
Dialog( const QStringList & components, ContentInListView
- content, QWidget * parent = 0,
- const QStringList& arguments = QStringList() );
+ content, QWidget * parent = 0 );
~Dialog();
@@ -153,6 +144,30 @@ class KUTILS_EXPORT Dialog : public KCMu
*/
void addPluginInfos( const QList<KPluginInfo*> & plugininfos );
+ /**
+ * sets the argument list that is given to all the KControlModule's when
+ * they are created.
+ * Use this if you have KControlModule's that need special arguments to
+ * work
+ *
+ * Note that this function only works before showing the
+ * KSettings::Dialog for the first time.
+ * @param arguments The list of arguments passed to each KCM
+ */
+ void initializeKCMArguments( const QStringList& arguments );
+
+ /**
+ * Initializes the blacklisted component list. Any KCM that lists one
+ * of the components in the given blacklist is not loaded even if it
+ * would fit otherwise. This is a way to explicitly prevent loading of
+ * certain KControlModules.
+ *
+ * Note that this function only works before showing the
+ * KSettings::Dialog for the first time.
+ * @param blacklist the list of components that prevent a KCM from being
+ * loaded
+ */
+ void initializeComponentBlacklist( const QStringList& blacklist );
public Q_SLOTS:
/**
* Show the config dialog. The slot immediately returns since the dialog
More information about the kde-core-devel
mailing list