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

List:       kfm-devel
Subject:    [patch] Re: KCModule: Enhanced browsing
From:       "Stefan Nikolaus" <stefan.nikolaus () stuco ! uni-oldenburg ! de>
Date:       2005-01-30 10:14:41
Message-ID: opsleuqrq8powx5f () stahl ! stuco ! uni-oldenburg ! de
[Download RAW message or body]

Hi,

I thought about something like this.

-- 
Stefan Nikolaus

"Time is the school in which we learn, time is the fire in which we burn."  
(Delmore Schwartz)
["kcm_ebrowsing.patch" (kcm_ebrowsing.patch)]

Index: main.cpp
===================================================================
RCS file: /home/kde/kdebase/kcontrol/ebrowsing/main.cpp,v
retrieving revision 1.29
diff -U3 -r1.29 main.cpp
--- main.cpp	22 Oct 2004 19:11:13 -0000	1.29
+++ main.cpp	29 Jan 2005 15:44:45 -0000
@@ -23,8 +23,12 @@
 
 #include <unistd.h>
 
+#include <qlayout.h>
+#include <qmap.h>
+#include <qtabwidget.h>
+
 #include <dcopclient.h>
 #include <kconfig.h>
 #include <kurifilter.h>
 #include <kgenericfactory.h>
 
@@ -53,8 +58,6 @@
       " changed this shortcut) and enter the shortcut in the KDE Run Command dialog."));
 
     QVBoxLayout *layout = new QVBoxLayout(this);
-    tab = new QTabWidget(this);
-    layout->addWidget(tab);
 
 #if 0
     opts = new FilterOptions(this);
@@ -64,21 +67,37 @@
 
     modules.setAutoDelete(true);
 
+    QMap<QString,KCModule*> helper;
     QPtrListIterator<KURIFilterPlugin> it = filter->pluginsIterator();
     for (; it.current(); ++it)
     {
-	  KCModule *module = it.current()->configModule(this, 0);
-      if (module)
-      {
-	    modules.append(module);
-	    tab->addTab(module, it.current()->configName());
-	    connect(module, SIGNAL(changed(bool)), SIGNAL(changed(bool)));
-	  }
+        KCModule *module = it.current()->configModule(this, 0);
+        if (module)
+        {
+            modules.append(module);
+            helper.insert(it.current()->configName(), module);
+            connect(module, SIGNAL(changed(bool)), SIGNAL(changed(bool)));
+        }
+    }
+
+    if (modules.count() > 1)
+    {
+        QTabWidget *tab = new QTabWidget(this);
+
+        QMapIterator<QString,KCModule*> it2;
+        for( it2 = helper.begin(); it2 != helper.end(); ++it2 )
+            tab->addTab(it2.data(), it2.key());
+
+        // Since there's nothing in the options tab yet, show the first plugin.
+        tab->showPage(modules.first());
+        widget = tab;
+    }
+    else if (modules.count() == 1)
+    {
+        widget = modules.first();
     }
 
-    // Since there's nothing in the options tab yet, show the first plugin.
-    KCModule *first = modules.first();
-    if (first) { tab->showPage(first); }
+    layout->addWidget(widget);
 
     // load();
 }
@@ -112,7 +131,7 @@
 
 void KURIFilterModule::resizeEvent(QResizeEvent *)
 {
-    tab->setGeometry(0,0,width(),height());
+    widget->setGeometry(0,0,width(),height());
 }
 
 #include "main.moc"
Index: main.h
===================================================================
RCS file: /home/kde/kdebase/kcontrol/ebrowsing/main.h,v
retrieving revision 1.11
diff -U3 -r1.11 main.h
--- main.h	22 Oct 2004 19:11:13 -0000	1.11
+++ main.h	29 Jan 2005 15:44:45 -0000
@@ -25,9 +25,6 @@
 #ifndef __MAIN_H__
 #define __MAIN_H__
 
-#include <qtabwidget.h>
-#include <qlayout.h>
-
 #include <kcmodule.h>
 
 class KURIFilter;
@@ -48,7 +45,7 @@
 private:
     KURIFilter *filter;
 
-    QTabWidget *tab;
+    QWidget *widget;
     FilterOptions *opts;
     QPtrList<KCModule> modules;
 };


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

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