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
)
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
)
41 void SearchProvider::setQuery(const QString
&query
)
49 void SearchProvider::setKeys(const QStringList
&keys
)
57 void SearchProvider::setCharset(const QString
&charset
)
59 if (m_charset
== charset
)
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;