KURIFilter Class Reference
Manages the filtering of URIs.Filters a given URL into its proper format whenever possible. More...
#include <kurifilter.h>
Public Member Functions | |
~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< KURIFilterPlugin > | pluginsIterator () const |
QStringList | pluginNames () const |
Static Public Member Functions | |
static KURIFilter * | self () |
Protected Member Functions | |
KURIFilter () | |
void | loadPlugins () |
Detailed Description
Manages the filtering of URIs.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. 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.
Definition at line 528 of file kurifilter.h.
Constructor & Destructor Documentation
|
Destructor.
Definition at line 222 of file kurifilter.cpp. |
|
A protected constructor. This constructor creates a KURIFilter and initializes all plugins it can find by invoking loadPlugins. Definition at line 216 of file kurifilter.cpp. References loadPlugins(). |
Member Function Documentation
|
Returns an instance of KURIFilter.
Definition at line 209 of file kurifilter.cpp. References KStaticDeleter< type >::setObject(). |
|
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.
Definition at line 227 of file kurifilter.cpp. Referenced by filteredURI(), and filterURI(). |
|
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.
Definition at line 265 of file kurifilter.cpp. References filterURI(), and KURIFilterData::uri(). |
|
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.
Definition at line 273 of file kurifilter.cpp. References filterURI(), and KURIFilterData::uri(). |
|
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.
Definition at line 282 of file kurifilter.cpp. References filterURI(), and KURIFilterData::uri(). |
|
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.
Definition at line 289 of file kurifilter.cpp. References filterURI(), and KURIFilterData::uri(). |
|
Return an iterator to iterate over all loaded plugins.
Definition at line 296 of file kurifilter.cpp. Referenced by pluginNames(). |
|
Return a list of the names of all loaded plugins.
Definition at line 301 of file kurifilter.cpp. References pluginsIterator(). |
|
Loads all allowed plugins. This function loads all filters that have not been disbled. Definition at line 309 of file kurifilter.cpp. References KTrader::self(). Referenced by KURIFilter(). |
The documentation for this class was generated from the following files: