KURIFilter class Reference (kio Library)

| # kio Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# KURIFilter Class Reference

Manages the filtering of a URI. Filters a given URL into its proper format whenever possible. More...

`#include <kurifilter.h>`

Collaboration diagram for KURIFilter:

[legend]
List of all members.

## Public Member Functions
| ~KURIFilter ()
| Destructor.
bool | filterURI (KURIFilterData &data, const QStringList &filters=QStringList())
| Filters the URI given by the object URIFilterData.
bool | filterURI (KURL &uri, const QStringList &filters=QStringList())
| Filters the URI given by the URL.
bool | filterURI (QString &uri, const QStringList &filters=QStringList())
| Filters a string representing a URI.
KURL | filteredURI (const KURL &uri, const QStringList &filters=QStringList())
| Returns the filtered URI.
QString | filteredURI (const QString &uri, const QStringList &filters=QStringList())
| Return a filtered string representation of a URI.
QPtrListIterator< KURIFilterPlugin > | pluginsIterator () const
| Return an iterator to iterate over all loaded plugins.
QStringList | pluginNames () const
| Return a list of the names of all loaded plugins.
## Static Public Member Functions
KURIFilter * | self ()
| Return a static instance of KURIFilter.
## Protected Member Functions
| KURIFilter ()
| A protected constructor.
void | loadPlugins ()
| Loads all allowed plugins.

## Detailed Description

Manages the filtering of a URI. Filters a given URL into its proper format whenever possible.

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. That is, 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 specify only specific filter(s) to be applied by supplying the name(s) of the filter(s). By defualt all filters that are found are loaded when the KURIFilter object is created will be used. These names are taken from the enteries in the \".desktop\" files. Here are a couple of examples:

     QString text = "kde.org";
     bool filtered = KURIFilter::self()->filterURI( text, "KShortURIFilter" );

     QStringList list;
     list << "KShortURIFilter" << "MyFilter";
     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.

Definition at line 469 of file kurifilter.h.

## Constructor & Destructor Documentation

KURIFilter::~KURIFilter | ( |  | ) |

| Destructor. Definition at line 188 of file kurifilter.cpp.

KURIFilter::KURIFilter | ( |  | ) | `[protected]`

| A protected constructor. This constructor creates a KURIFilter and initializes all plugins it can find by invoking loadPlugins. Definition at line 182 of file kurifilter.cpp. References loadPlugins().

## Member Function Documentation

KURIFilter * KURIFilter::self | ( |  | ) | `[static]`

| Return a static instance of KURIFilter. Definition at line 175 of file kurifilter.cpp.

bool KURIFilter::filterURI | ( | KURIFilterData & | data,
|  | const QStringList & | filters = QStringList()
| ) |

  | Filters the URI given by the object URIFilterData. This filters the given data based on the specified filter list. If the list is empty all avaliable filter plugins would be used. If not, only those given in the list are used. Parameters:
  data | object that contains the URI to be filtered.
  filters | specify the list filters to be used
Returns: a boolean indicating whether the URI has been changed Definition at line 193 of file kurifilter.cpp. References QPtrListIterator::current(). Referenced by filteredURI(), and filterURI().

bool KURIFilter::filterURI | ( | KURL & | uri,
|  | const QStringList & | filters = QStringList()
| ) |

  | Filters the URI given by the URL. This filters the given URL based on the specified filter list. If the list is empty all avaliable filter plugins would be used. If not, only those given in the list are used. Parameters:
  uri | the URI to filter.
  filters | specify the list of filters to be used
Returns: a boolean indicating whether the URI has been changed Definition at line 232 of file kurifilter.cpp. References filterURI(), and KURIFilterData::uri().

bool KURIFilter::filterURI | ( | QString & | uri,
|  | const QStringList & | filters = QStringList()
| ) |

  | Filters a string representing a URI. This filters the given string based on the specified filter list. If the list is empty all avaliable filter plugins would be used. If not, only those given in the list are used. Parameters:
  uri | The URI to filter.
  filters | specify the list filters to be used
Returns: a boolean indicating whether the URI has been changed Definition at line 240 of file kurifilter.cpp. References filterURI(), KURIFilterData::uri(), and KURL::url().

KURL KURIFilter::filteredURI | ( | const KURL & | uri,
|  | const QStringList & | filters = QStringList()
| ) |

  | Returns the filtered URI. This filters the given URL based on the specified filter list. If the list is empty all avaliable filter plugins would be used. If not, only those given in the list are used. Parameters:
  uri | The URI to filter.
  filters | specify the list filters to be used
Returns: the filtered URI or null if it cannot be filtered Definition at line 249 of file kurifilter.cpp. References filterURI(), and KURIFilterData::uri().

QString KURIFilter::filteredURI | ( | const QString & | uri,
|  | const QStringList & | filters = QStringList()
| ) |

  | Return a filtered string representation of a URI. This filters the given URL based on the specified filter list. If the list is empty all avaliable filter plugins would be used. If not, only those given in the list are used. Parameters:
  uri | the URI to filter.
  filters | specify the list filters to be used
Returns: the filtered URI or null if it cannot be filtered Definition at line 256 of file kurifilter.cpp. References filterURI(), KURIFilterData::uri(), and KURL::url().

QPtrListIterator< KURIFilterPlugin > KURIFilter::pluginsIterator | ( |  | ) | const

| Return an iterator to iterate over all loaded plugins. Returns: a plugin iterator. Definition at line 263 of file kurifilter.cpp. Referenced by pluginNames().

QStringList KURIFilter::pluginNames | ( |  | ) | const

| Return a list of the names of all loaded plugins. Since: 3.1 Returns: a QStringList of plugin names Definition at line 268 of file kurifilter.cpp. References pluginsIterator().

void KURIFilter::loadPlugins | ( |  | ) | `[protected]`

| Loads all allowed plugins. This function loads all filters that have not been dis Definition at line 276 of file kurifilter.cpp. References QValueList::begin(), QValueList::end(), KStdAccel::end(), KTrader::OfferList, KTrader::query(), and KTrader::self(). Referenced by KURIFilter().

The documentation for this class was generated from the following files:

- kurifilter.h
- kurifilter.cpp

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:23:26 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001