# class KUriFilter

###

Table of contents
Modules
kio Classes
All Classes

Module | kio
Namespace | global
Class | KUriFilter
Inherits |

Manages the filtering of URIs.

The intention of this plugin class is to allow people to extend the functionality of KUrl without modifying it directly. This way KUrl will remain a generic parser capable of parsing any generic URL that adheres to specifications.

The KUriFilter class applies a number of filters to a URI and returns the filtered version whenever possible. The filters are implemented using plugins to provide easy extensibility of the filtering mechanism. New filters can be added in the future by simply inheriting from KUriFilterPlugin and implementing the KUriFilterPlugin.filterUri method.

Use of this plugin-manager class is straight forward. Since it is a singleton object, all you have to do is obtain an instance by doing KUriFilter.self() and use any of the public member functions to preform the filtering.

Example

To simply filter a given string:

    bool filtered = KUriFilter.self()->filterUri( "kde.org" );

You can alternatively use a KUrl:

    KUrl url = "kde.org";
    bool filtered = KUriFilter.self()->filterUri( url );

If you have a constant string or a constant URL, simply invoke the corresponding function to obtain the filtered string or URL instead of a boolean flag:

    QString u = KUriFilter.self()->filteredUri( "kde.org" );

You can also restrict the filter(s) to be used by supplying the name of the filter(s) to use. By defualt all available filters will be used. To use specific filters, add the names of the filters you want to use to a QStringList and invoke the appropriate filtering function. The examples below show the use of specific filters. The first one uses a single filter called kshorturifilter while the second example uses multiple filters:

    QString text = "kde.org";
    bool filtered = KUriFilter.self()->filterUri( text, "kshorturifilter" );

    QStringList list;
    list << "kshorturifilter" << "localdomainfilter";
    bool filtered = KUriFilter.self()->filterUri( text, list );

KUriFilter also allows richer data exchange through a simple meta-object called KUriFilterData. Using this meta-object you can find out more information about the URL you want to filter. See KUriFilterData for examples and details.

Filters a given URL into its proper format whenever possible.

### methods

- KUriFilter ()

  returns a KUriFilter object

  Destructor

- filterUri (data, filters)

  returns (bool)

  Argument | Type | Default
  --- | --- | ---
  data | KUriFilterData |
  filters | QStringList | QStringList ()

  Filters the URI given by the object UriFilterData.

  The given URL is filtered based on the specified list of filters. If the list is empty all available filters would be used.

  data - object that contains the URI to be filtered.

  filters - specify the list of filters to be used.

  Returns a boolean indicating whether the URI has been changed

- filterUri (uri, filters)

  returns (bool)

  Argument | Type | Default
  --- | --- | ---
  uri | KUrl |
  filters | QStringList | QStringList ()

  Filters the URI given by the URL.

  The given URL is filtered based on the specified list of filters. If the list is empty all available filters would be used.

  uri - the URI to filter.

  filters - specify the list of filters to be used.

  Returns a boolean indicating whether the URI has been changed

- filterUri (uri, filters)

  returns (bool)

  Argument | Type | Default
  --- | --- | ---
  uri | QString |
  filters | QStringList | QStringList ()

  Filters a string representing a URI.

  The given URL is filtered based on the specified list of filters. If the list is empty all available filters would be used.

  uri - The URI to filter.

  filters - specify the list of filters to be used.

  Returns a boolean indicating whether the URI has been changed

- filteredUri (uri, filters)

  returns (KUrl)

  Argument | Type | Default
  --- | --- | ---
  uri | KUrl |
  filters | QStringList | QStringList ()

  Returns the filtered URI.

  The given URL is filtered based on the specified list of filters. If the list is empty all available filters would be used.

  uri - The URI to filter.

  filters - specify the list of filters to be used.

  Returns the filtered URI or null if it cannot be filtered

- filteredUri (uri, filters)

  returns (QString)

  Argument | Type | Default
  --- | --- | ---
  uri | QString |
  filters | QStringList | QStringList ()

  Return a filtered string representation of a URI.

  The given URL is filtered based on the specified list of filters. If the list is empty all available filters would be used.

  uri - the URI to filter.

  filters - specify the list of filters to be used.

  Returns the filtered URI or null if it cannot be filtered

- loadPlugins ()

  returns nothing

  Loads all allowed plugins.

  This function loads all filters that have not been disbled.

- pluginNames ()

  returns (QStringList)

  Return a list of the names of all loaded plugins.

  Returns a QStringList of plugin names

- self ()

  returns (KUriFilter)
  static

  Returns an instance of KUriFilter.