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(options: 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(key: provider->name(), value: provider);
48 } else {
49 data.d->searchProviderMap.remove(key: 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(asize: data.d->searchProviderList.size() + providers.size());
59 for (KUriFilterSearchProvider *searchProvider : providers) {
60 data.d->searchProviderList << searchProvider->name();
61 data.d->searchProviderMap.insert(key: searchProvider->name(), value: 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: hostname, timeout);
73}
74
75#include "moc_kurifilterplugin_p.cpp"
76

source code of kio/src/gui/kurifilterplugin.cpp