KIO

kurifilter.h
1 /*
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 2000-2001, 2003, 2010 Dawit Alemayehu <adawit at kde.org>
4 
5  Original author
6  SPDX-FileCopyrightText: 2000 Yves Arrouye <[email protected]>
7 
8  SPDX-License-Identifier: LGPL-2.0-or-later
9 */
10 
11 #ifndef KURIFILTER_H
12 #define KURIFILTER_H
13 
14 #include "kiowidgets_export.h"
15 
16 #include <QObject>
17 #include <QHash>
18 #include <QPair>
19 #include <QStringList>
20 #include <QUrl>
21 
22 #ifdef Q_OS_WIN
23 #undef ERROR
24 #endif
25 
26 class KUriFilterPrivate;
27 class KUriFilterDataPrivate;
28 class KCModule;
29 class QHostInfo;
30 
38 class KIOWIDGETS_EXPORT KUriFilterSearchProvider
39 {
40 public:
45 
50 
54  virtual ~KUriFilterSearchProvider();
55 
62  QString desktopEntryName() const;
63 
70  QString name() const;
71 
75  virtual QString iconName() const;
76 
82  QStringList keys() const;
83 
92  QString defaultKey() const;
93 
98 
99 protected:
100  void setDesktopEntryName(const QString &);
101  void setIconName(const QString &);
102  void setKeys(const QStringList &);
103  void setName(const QString &);
104 
105 private:
106  friend class KUriFilterPlugin;
107  class KUriFilterSearchProviderPrivate;
108  KUriFilterSearchProviderPrivate *const d;
109 };
110 
152 class KIOWIDGETS_EXPORT KUriFilterData
153 {
154 public:
171  enum UriTypes { NetProtocol = 0, LocalFile, LocalDir, Executable, Help, Shell, Blocked, Error, Unknown };
172 
198  SearchFilterOptionNone = 0x0,
199  RetrieveSearchProvidersOnly = 0x01,
200  RetrievePreferredSearchProvidersOnly = 0x02,
201  RetrieveAvailableSearchProvidersOnly = (RetrievePreferredSearchProvidersOnly | RetrieveSearchProvidersOnly)
202  };
207 
208 
213  KUriFilterData();
214 
220  explicit KUriFilterData(const QUrl &url);
221 
227  explicit KUriFilterData(const QString &url);
228 
236  KUriFilterData(const KUriFilterData &other);
237 
241  ~KUriFilterData();
242 
251  QUrl uri() const;
252 
262  QString errorMsg() const;
263 
272  UriTypes uriType() const;
273 
281  QString absolutePath() const;
282 
290  bool hasAbsolutePath() const;
291 
298  QString argsAndOptions() const;
299 
306  bool hasArgsAndOptions() const;
307 
312  bool checkForExecutables() const;
313 
317  QString typedString() const;
318 
328  QString searchTerm() const;
329 
340  QChar searchTermSeparator() const;
341 
351  QString searchProvider() const;
352 
377  QStringList preferredSearchProviders() const;
378 
389  KUriFilterSearchProvider queryForSearchProvider(const QString &provider) const;
390 
404  QString queryForPreferredSearchProvider(const QString &provider) const;
405 
418  QStringList allQueriesForSearchProvider(const QString &provider) const;
419 
429  QString iconNameForPreferredSearchProvider(const QString &provider) const;
430 
443  QStringList alternateSearchProviders() const;
444 
455  QString alternateDefaultSearchProvider() const;
456 
465  QString defaultUrlScheme() const;
466 
475  SearchFilterOptions searchFilteringOptions() const;
476 
483  QString iconName();
484 
492  void setCheckForExecutables(bool check);
493 
502  void setData(const QUrl &url);
503 
513  void setData(const QString &url);
514 
529  bool setAbsolutePath(const QString &abs_path);
530 
544  void setAlternateSearchProviders(const QStringList &providers);
545 
558  void setAlternateDefaultSearchProvider(const QString &provider);
559 
574  void setDefaultUrlScheme(const QString &);
575 
591  void setSearchFilteringOptions(SearchFilterOptions options);
592 
601  KUriFilterData &operator=(const QUrl &url);
602 
611  KUriFilterData &operator=(const QString &url);
612 
613 private:
614  friend class KUriFilterPlugin;
615  KUriFilterDataPrivate *const d;
616 };
617 
632 class KIOWIDGETS_EXPORT KUriFilterPlugin : public QObject
633 {
634  Q_OBJECT
635 
636 public:
637 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(4, 6)
638 
645  KIOWIDGETS_DEPRECATED_VERSION(4, 6, "Use KUriFilterSearchProvider")
646  typedef QHash<QString, QPair<QString, QString> > ProviderInfoList;
647 #endif
648 
655  explicit KUriFilterPlugin(const QString &name, QObject *parent = nullptr);
656 
657  // KF6 TODO ~KUriFilterPlugin();
658 
665  virtual bool filterUri(KUriFilterData &data) const = 0;
666 
675  virtual KCModule *configModule(QWidget *, const char *) const;
676 
682  virtual QString configName() const;
683 
684 protected:
688  void setFilteredUri(KUriFilterData &data, const QUrl &uri) const;
689 
693  void setErrorMsg(KUriFilterData &data, const QString &errmsg) const;
694 
698  void setUriType(KUriFilterData &data, KUriFilterData::UriTypes type) const;
699 
704  void setArguments(KUriFilterData &data, const QString &args) const;
705 
712  void setSearchProvider(KUriFilterData &data, const QString &provider,
713  const QString &term, const QChar &separator) const;
714 
720  void setSearchProviders(KUriFilterData &data, const QList<KUriFilterSearchProvider *> &providers) const;
721 
727  QString iconNameFor(const QUrl &url, KUriFilterData::UriTypes type) const;
728 
745  QHostInfo resolveName(const QString &hostname, unsigned long timeout) const;
746 
747 private:
748  class KUriFilterPluginPrivate *const d;
749 };
750 
853 class KIOWIDGETS_EXPORT KUriFilter
854 {
855 public:
865  NormalTextFilter = 0x01,
866  WebShortcutFilter = 0x02
867  };
872 
873 
876  ~KUriFilter();
877 
881  static KUriFilter *self();
882 
894  bool filterUri(KUriFilterData &data, const QStringList &filters = QStringList());
895 
907  bool filterUri(QUrl &uri, const QStringList &filters = QStringList());
908 
920  bool filterUri(QString &uri, const QStringList &filters = QStringList());
921 
933  QUrl filteredUri(const QUrl &uri, const QStringList &filters = QStringList());
934 
946  QString filteredUri(const QString &uri, const QStringList &filters = QStringList());
947 
948 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(4, 6)
949 
955  KIOWIDGETS_DEPRECATED_VERSION(4, 6, "Use KUriFilter::filterSearchUri(KUriFilterData &, SearchFilterTypes)")
956  bool filterSearchUri(KUriFilterData &data);
957 #endif
958 
975  bool filterSearchUri(KUriFilterData &data, SearchFilterTypes types);
976 
982  QStringList pluginNames() const;
983 
984 protected:
985 
992  KUriFilter();
993 
999  void loadPlugins();
1000 
1001 private:
1002  KUriFilterPrivate *const d;
1003  friend class KUriFilterSingleton;
1004 };
1005 
1006 Q_DECLARE_OPERATORS_FOR_FLAGS(KUriFilterData::SearchFilterOptions)
1007 Q_DECLARE_OPERATORS_FOR_FLAGS(KUriFilter::SearchFilterTypes)
1008 
1009 #endif
Base class for URI filter plugins.
Definition: kurifilter.h:632
SearchFilterOption
This enum describes the search filtering options to be used.
Definition: kurifilter.h:197
Class that holds information about a search provider.
Definition: kurifilter.h:38
UriTypes
Describes the type of the URI that was filtered.
Definition: kurifilter.h:171
KUriFilter applies a number of filters to a URI and returns a filtered version if any filter matches...
Definition: kurifilter.h:853
This class is a basic messaging class used to exchange filtering information between the filter plugi...
Definition: kurifilter.h:152
SearchFilterType
This enum describes the types of search plugin filters available.
Definition: kurifilter.h:864
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Nov 30 2020 23:01:46 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.