kio
KURIFilter Class Reference
Manages the filtering of URIs. More...
#include <kurifilter.h>
Public Member Functions | |
QString | filteredURI (const QString &uri, const QStringList &filters=QStringList()) |
KURL | filteredURI (const KURL &uri, const QStringList &filters=QStringList()) |
bool | filterURI (QString &uri, const QStringList &filters=QStringList()) |
bool | filterURI (KURL &uri, const QStringList &filters=QStringList()) |
bool | filterURI (KURIFilterData &data, const QStringList &filters=QStringList()) |
QStringList | pluginNames () const |
QPtrListIterator < KURIFilterPlugin > | pluginsIterator () const |
~KURIFilter () | |
Static Public Member Functions | |
static KURIFilter * | self () |
Protected Member Functions | |
KURIFilter () | |
void | loadPlugins () |
Detailed Description
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.
Definition at line 534 of file kurifilter.h.
Constructor & Destructor Documentation
KURIFilter::~KURIFilter | ( | ) |
KURIFilter::KURIFilter | ( | ) | [protected] |
A protected constructor.
This constructor creates a KURIFilter and initializes all plugins it can find by invoking loadPlugins.
Definition at line 228 of file kurifilter.cpp.
Member Function Documentation
QString KURIFilter::filteredURI | ( | const QString & | uri, | |
const QStringList & | filters = 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.
- Parameters:
-
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
Definition at line 300 of file kurifilter.cpp.
KURL KURIFilter::filteredURI | ( | const KURL & | uri, | |
const QStringList & | filters = 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.
- Parameters:
-
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
Definition at line 293 of file kurifilter.cpp.
bool KURIFilter::filterURI | ( | QString & | uri, | |
const QStringList & | filters = 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.
- 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 284 of file kurifilter.cpp.
bool KURIFilter::filterURI | ( | KURL & | uri, | |
const QStringList & | filters = 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.
- 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 276 of file kurifilter.cpp.
bool KURIFilter::filterURI | ( | KURIFilterData & | data, | |
const QStringList & | filters = 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.
- Parameters:
-
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
Definition at line 238 of file kurifilter.cpp.
void KURIFilter::loadPlugins | ( | ) | [protected] |
Loads all allowed plugins.
This function loads all filters that have not been disbled.
Definition at line 320 of file kurifilter.cpp.
QStringList KURIFilter::pluginNames | ( | ) | const |
Return a list of the names of all loaded plugins.
- Returns:
- a QStringList of plugin names
- Since:
- 3.1
Definition at line 312 of file kurifilter.cpp.
QPtrListIterator< KURIFilterPlugin > KURIFilter::pluginsIterator | ( | ) | const |
Return an iterator to iterate over all loaded plugins.
- Returns:
- a plugin iterator.
Definition at line 307 of file kurifilter.cpp.
KURIFilter * KURIFilter::self | ( | ) | [static] |
The documentation for this class was generated from the following files: