KIO

kurifilterplugin.cpp
1/*
2 SPDX-FileCopyrightText: 2000-2001, 2003, 2010 Dawit Alemayehu <adawit at kde.org>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4*/
5
6#include "kurifilterplugin_p.h"
7
8#include "kurifilterdata_p.h"
9#include <QHostInfo>
10#include <hostinfo.h>
11
12KUriFilterPlugin::KUriFilterPlugin(QObject *parent, const KPluginMetaData &data)
13 : QObject(parent)
14 , d(nullptr)
15{
16 setObjectName(data.pluginId());
17}
18
19KUriFilterPlugin::~KUriFilterPlugin() = default;
20
21void KUriFilterPlugin::setFilteredUri(KUriFilterData &data, const QUrl &uri) const
22{
23 data.d->url = uri.adjusted(QUrl::NormalizePathSegments);
24 data.d->wasModified = true;
25 // qDebug() << "Got filtered to:" << uri;
26}
27
28void KUriFilterPlugin::setErrorMsg(KUriFilterData &data, const QString &errmsg) const
29{
30 data.d->errMsg = errmsg;
31}
32
33void KUriFilterPlugin::setUriType(KUriFilterData &data, KUriFilterData::UriTypes type) const
34{
35 data.d->uriType = type;
36 data.d->wasModified = true;
37}
38
39void KUriFilterPlugin::setArguments(KUriFilterData &data, const QString &args) const
40{
41 data.d->args = args;
42}
43
44void KUriFilterPlugin::setSearchProvider(KUriFilterData &data, KUriFilterSearchProvider *provider, const QString &term, const QChar &separator) const
45{
46 if (provider) {
47 data.d->searchProviderMap.insert(provider->name(), provider);
48 } else {
49 data.d->searchProviderMap.remove(data.d->searchProvider);
50 }
51 data.d->searchProvider = provider ? provider->name() : QString();
52 data.d->searchTerm = term;
53 data.d->searchTermSeparator = separator;
54}
55
56void KUriFilterPlugin::setSearchProviders(KUriFilterData &data, const QList<KUriFilterSearchProvider *> &providers) const
57{
58 data.d->searchProviderList.reserve(data.d->searchProviderList.size() + providers.size());
59 for (KUriFilterSearchProvider *searchProvider : providers) {
60 data.d->searchProviderList << searchProvider->name();
61 data.d->searchProviderMap.insert(searchProvider->name(), searchProvider);
62 }
63}
64
65QString KUriFilterPlugin::iconNameFor(const QUrl &url, KUriFilterData::UriTypes type) const
66{
67 return KUriFilterDataPrivate::lookupIconNameFor(url, type);
68}
69
70QHostInfo KUriFilterPlugin::resolveName(const QString &hostname, unsigned long timeout) const
71{
72 return KIO::HostInfo::lookupHost(hostname, timeout);
73}
74
75#include "moc_kurifilterplugin_p.cpp"
QString pluginId() const
This class is a basic messaging class used to exchange filtering information between the filter plugi...
Definition kurifilter.h:153
UriTypes
Describes the type of the URI that was filtered.
Definition kurifilter.h:158
Class that holds information about a search provider.
Definition kurifilter.h:39
QString name() const
Returns the descriptive name of the search provider, e.g. "Google News".
Type type(const QSqlDatabase &db)
void lookupHost(const QString &hostName, QObject *receiver, const char *member)
Definition hostinfo.cpp:237
QCA_EXPORT ProviderList providers()
qsizetype size() const const
NormalizePathSegments
QUrl adjusted(FormattingOptions options) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:28 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.