Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / runtime / kurifilter-plugins / ikws / kurisearchfilter.cpp
blobfc007122dd0ab77cd83b51fba75e38f86fe4096f
1 /* This file is part of the KDE project
2 Copyright (C) 1999 Simon Hausmann <hausmann@kde.org>
3 Copyright (C) 2000 Yves Arrouye <yves@realnames.com>
4 Copyright (C) 2002, 2003 Dawit Alemayehu <adawit@kde.org>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #include <unistd.h>
24 #include <kdebug.h>
25 #include <klocale.h>
26 #include <kcomponentdata.h>
27 #include <kglobal.h>
29 #include "ikwsopts.h"
30 #include "kuriikwsfiltereng.h"
31 #include "kurisearchfilter.h"
33 #include <QtDBus/QtDBus>
35 /**
36 * IMPORTANT: If you change anything here, please run the regression test
37 * ../tests/kurifiltertest
40 K_PLUGIN_FACTORY(KUriSearchFilterFactory, registerPlugin<KUriSearchFilter>();)
41 K_EXPORT_PLUGIN(KUriSearchFilterFactory("kcmkurifilt"))
43 KUriSearchFilter::KUriSearchFilter(QObject *parent,
44 const QVariantList &)
45 :KUriFilterPlugin( "kurisearchfilter", parent )
47 KGlobal::locale()->insertCatalog("kurifilter");
48 QDBusConnection::sessionBus().connect(QString(), QString(), "org.kde.KUriFilterPlugin",
49 "configure", this, SLOT(configure()));
52 KUriSearchFilter::~KUriSearchFilter()
56 void KUriSearchFilter::configure()
58 if ( KURISearchFilterEngine::self()->verbose() )
59 kDebug() << "KUriSearchFilter::configure: Config reload request...";
61 KURISearchFilterEngine::self()->loadConfig();
64 bool KUriSearchFilter::filterUri( KUriFilterData &data ) const
66 if ( KURISearchFilterEngine::self()->verbose() )
67 kDebug() << "KUriSearchFilter::filterUri: '" << data.typedString() << "'";
69 QString result = KURISearchFilterEngine::self()->webShortcutQuery( data.typedString() );
71 if ( !result.isEmpty() )
73 if ( KURISearchFilterEngine::self()->verbose() )
74 kDebug() << "Filtered URL: " << result;
76 setFilteredUri( data, KUrl( result ) );
77 setUriType( data, KUriFilterData::NetProtocol );
78 return true;
81 return false;
84 KCModule *KUriSearchFilter::configModule(QWidget *parent, const char *) const
86 return new FilterOptions( KUriSearchFilterFactory::componentData(), parent);
89 QString KUriSearchFilter::configName() const
91 return i18n("Search F&ilters");
94 #include "kurisearchfilter.moc"