add more spacing
[personal-kdebase.git] / runtime / kurifilter-plugins / ikws / searchprovider.cpp
blobd3e31c01f938343e5fcd74c5f9a34c6bff247a36
1 /*
2 * Copyright (c) 2000 Malte Starostik <malte@kde.org>
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.
19 #include "searchprovider.h"
21 #include <kservicetypetrader.h>
23 SearchProvider::SearchProvider(const KService::Ptr service)
24 : m_dirty(false)
26 m_desktopEntryName = service->desktopEntryName();
27 m_name = service->name();
28 m_query = service->property("Query").toString();
29 m_keys = service->property("Keys").toStringList();
30 m_charset = service->property("Charset").toString();
33 void SearchProvider::setName(const QString &name)
35 if (m_name == name)
36 return;
37 m_name = name;
38 m_dirty = true;
41 void SearchProvider::setQuery(const QString &query)
43 if (m_query == query)
44 return;
45 m_query = query;
46 m_dirty = true;
49 void SearchProvider::setKeys(const QStringList &keys)
51 if (m_keys == keys)
52 return;
53 m_keys = keys;
54 m_dirty = true;
57 void SearchProvider::setCharset(const QString &charset)
59 if (m_charset == charset)
60 return;
61 m_charset = charset;
62 m_dirty = true;
65 SearchProvider *SearchProvider::findByDesktopName(const QString &name)
67 KService::Ptr service =
68 KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(name));
69 return service ? new SearchProvider(service) : 0;
72 SearchProvider *SearchProvider::findByKey(const QString &key)
74 KService::List providers =
75 KServiceTypeTrader::self()->query("SearchProvider", QString("'%1' in Keys").arg(key));
76 return providers.count() ? new SearchProvider(providers[0]) : 0;