Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

KURIFilter Class Reference

Filters a given URL into its proper format whenever possible. More...

#include <kurifilter.h>

List of all members.

Public Methods

 ~KURIFilter ()
bool filterURI (KURIFilterData &data, const QStringList &filters=QStringList())
bool filterURI (KURL &uri, const QStringList &filters=QStringList())
bool filterURI (QString &uri, const QStringList &filters=QStringList())
KURL filteredURI (const KURL &uri, const QStringList &filters=QStringList())
QString filteredURI (const QString &uri, const QStringList &filters=QStringList())
QPtrListIterator< KURIFilterPluginpluginsIterator () const
QStringList pluginNames () const

Static Public Methods

KURIFilter * self ()

Protected Methods

 KURIFilter ()
void loadPlugins ()


Detailed Description

Filters a given URL into its proper format whenever possible.

Manages the filtering of a URI.

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.

@sect 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

KURIFilter::KURIFilter   [protected]
 

A protected constructor.

This constructor creates a KURIFilter and initializes all plugins it can find by invoking loadPlugins.


Member Function Documentation

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

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

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

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

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

void KURIFilter::loadPlugins   [protected]
 

Loads all allowed plugins.

This function loads all filters that have not been dis

QStringList KURIFilter::pluginNames  
 

Return a list of the names of all loaded plugins

Since:
3.1
Returns:
a QStringList of plugin names

QPtrListIterator<KURIFilterPlugin> KURIFilter::pluginsIterator  
 

Return an iterator to iterate over all loaded plugins.

Returns:
a plugin iterator.

KURIFilter* KURIFilter::self   [static]
 

Return a static instance of KURIFilter.


The documentation for this class was generated from the following file:
Generated on Wed Aug 13 23:30:27 2003 for kdelibs by doxygen1.2.18