1/*
2 This file is part of the KDE project
3 SPDX-FileCopyrightText: 2002, 2003 Dawit Alemayehu <adawit@kde.org>
4 SPDX-FileCopyrightText: 1999 Simon Hausmann <hausmann@kde.org>
5 SPDX-FileCopyrightText: 1999 Yves Arrouye <yves@realnames.com>
6
7 Advanced web shortcuts
8 SPDX-FileCopyrightText: 2001 Andreas Hochsteger <e9625392@student.tuwien.ac.at>
9
10 SPDX-License-Identifier: GPL-2.0-or-later
11*/
12
13#ifndef KURIIKWSFILTERENG_H
14#define KURIIKWSFILTERENG_H
15
16#include "kuriikwsfiltereng_private_export.h"
17#include "searchproviderregistry_p.h"
18#include <QMap>
19#include <QObject>
20#include <QStringList>
21#include <QUrl>
22
23class QStringEncoder;
24class SearchProvider;
25
26namespace KIO
27{
28class KURIIKWSFILTERENG_PRIVATE_EXPORT KURISearchFilterEngine : public QObject
29{
30 Q_OBJECT
31public:
32 typedef QMap<QString, QString> SubstMap;
33
34 QByteArray name() const;
35 char keywordDelimiter() const;
36 QString defaultSearchEngine() const;
37 QStringList favoriteEngineList() const;
38 SearchProvider *webShortcutQuery(const QString &typedString, QString &searchTerm) const;
39 SearchProvider *autoWebSearchQuery(const QString &typedString, const QString &defaultShortcut = QString()) const;
40 QUrl formatResult(const QString &url, const QString &cset1, const QString &cset2, const QString &query, bool isMalformed) const;
41
42 SearchProviderRegistry *registry();
43
44 static KURISearchFilterEngine *self();
45 static QStringList defaultSearchProviders();
46
47protected:
48 QUrl formatResult(const QString &url, const QString &cset1, const QString &cset2, const QString &query, bool isMalformed, SubstMap &map) const;
49
50private:
51 KURISearchFilterEngine();
52 ~KURISearchFilterEngine();
53
54 Q_SLOT void configure();
55 Q_DISABLE_COPY_MOVE(KURISearchFilterEngine)
56
57 QStringList modifySubstitutionMap(SubstMap &map, const QString &query) const;
58 QString substituteQuery(const QString &url, SubstMap &map, const QString &userquery, QStringEncoder &codec) const;
59
60 SearchProviderRegistry m_registry;
61 QString m_defaultWebShortcut;
62 QStringList m_preferredWebShortcuts;
63 bool m_bWebShortcutsEnabled;
64 bool m_bUseOnlyPreferredWebShortcuts;
65 char m_cKeywordDelimiter;
66 bool m_reloadRegistry = false; // We would load it twice otherwise
67};
68}
69
70#endif // KURIIKWSFILTERENG_H
71

source code of kio/src/urifilters/ikws/kuriikwsfiltereng_p.h