2 * Copyright (c) 2000 Yves Arrouye <yves@realnames.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 #include <QtGui/QTabWidget>
24 #include <QtGui/QBoxLayout>
27 #include <kurifilter.h>
30 #include <kservicetypetrader.h>
31 #include <KPluginFactory>
34 K_PLUGIN_FACTORY(KURIFactory
,
35 registerPlugin
<KURIFilterModule
>();
37 K_EXPORT_PLUGIN(KURIFactory("kcmkurifilt"))
39 KURIFilterModule::KURIFilterModule(QWidget
*parent
, const QVariantList
&)
40 : KCModule(KURIFactory::componentData(), parent
),
44 filter
= KUriFilter::self();
46 setQuickHelp( i18n("<h1>Enhanced Browsing</h1> In this module you can configure some enhanced browsing"
47 " features of KDE. <h2>Internet Keywords</h2>Internet Keywords let you"
48 " type in the name of a brand, a project, a celebrity, etc... and go to the"
49 " relevant location. For example you can just type"
50 " \"KDE\" or \"K Desktop Environment\" in Konqueror to go to KDE's homepage."
51 "<h2>Web Shortcuts</h2>Web Shortcuts are a quick way of using Web search engines. For example, type \"altavista:frobozz\""
52 " or \"av:frobozz\" and Konqueror will do a search on AltaVista for \"frobozz\"."
53 " Even easier: just press Alt+F2 (if you have not"
54 " changed this shortcut) and enter the shortcut in the KDE Run Command dialog."));
56 QVBoxLayout
*layout
= new QVBoxLayout(this);
58 QMap
<QString
,KCModule
*> helper
;
59 // Load the plugins. This saves a public method in KUriFilter just for this.
60 const KService::List offers
= KServiceTypeTrader::self()->query( "KUriFilter/Plugin" );
61 KService::List::ConstIterator it
= offers
.begin();
62 const KService::List::ConstIterator end
= offers
.end();
63 for (; it
!= end
; ++it
)
65 KUriFilterPlugin
*plugin
= ( *it
)->createInstance
<KUriFilterPlugin
>( this );
67 KCModule
*module
= plugin
->configModule(this, 0);
69 modules
.append(module
);
70 helper
.insert(plugin
->configName(), module
);
71 connect(module
, SIGNAL(changed(bool)), SIGNAL(changed(bool)));
76 if (modules
.count() > 1)
78 QTabWidget
*tab
= new QTabWidget(this);
80 QMap
<QString
,KCModule
*>::iterator it2
;
81 for (it2
= helper
.begin(); it2
!= helper
.end(); ++it2
)
82 tab
->addTab(it2
.value(), it2
.key());
84 tab
->setCurrentIndex(tab
->indexOf(modules
.first()));
87 else if (modules
.count() == 1)
89 m_widget
= modules
.first();
90 if (m_widget
->layout())
91 m_widget
->layout()->setMargin(0);
95 layout
->addWidget(m_widget
);
99 void KURIFilterModule::load()
101 // seems not to be necessary, since modules automatically call load() on show (uwolfer)
102 // foreach( KCModule* module, modules )
108 void KURIFilterModule::save()
110 foreach( KCModule
* module
, modules
)
116 void KURIFilterModule::defaults()
118 foreach( KCModule
* module
, modules
)
124 KURIFilterModule::~KURIFilterModule()
126 qDeleteAll( modules
);