KDirLister Class Reference
The dir lister deals with the kiojob used to list and update a directory and has signals for the user of this class (e.g. Helper class for the kiojob used to list and update a directory. More...
#include <kdirlister.h>
Inheritance diagram for KDirLister:

Public Types | |
enum | WhichItems { AllItems = 0, FilteredItems = 1 } |
Used by items() and itemsForDir() to specify whether you want all items for a directory or just the filtered ones. More... | |
Signals | |
void | started (const KURL &_url) |
Tell the view that we started to list _url . | |
void | completed () |
Tell the view that listing is finished. | |
void | completed (const KURL &_url) |
Tell the view that the listing of the directory _url is finished. | |
void | canceled () |
Tell the view that the user canceled the listing. | |
void | canceled (const KURL &_url) |
Tell the view that the listing of the directory _url was canceled. | |
void | redirection (const KURL &_url) |
Signal a redirection. | |
void | redirection (const KURL &oldUrl, const KURL &newUrl) |
Signal a redirection. | |
void | clear () |
Signal to clear all items. | |
void | clear (const KURL &_url) |
Signal to empty the directory _url . | |
void | newItems (const KFileItemList &items) |
Signal new items. | |
void | itemsFilteredByMime (const KFileItemList &items) |
Send a list of items filtered-out by mime-type. | |
void | deleteItem (KFileItem *_fileItem) |
Signal an item to remove. | |
void | refreshItems (const KFileItemList &items) |
Signal an item to refresh (its mimetype/icon/name has changed). | |
void | infoMessage (const QString &msg) |
Emitted to display information about running jobs. | |
void | percent (int percent) |
Progress signal showing the overall progress of the KDirLister. | |
void | totalSize (KIO::filesize_t size) |
Emitted when we know the size of the jobs. | |
void | processedSize (KIO::filesize_t size) |
Regularly emitted to show the progress of this KDirLister. | |
void | speed (int bytes_per_second) |
Emitted to display information about the speed of the jobs. | |
Public Member Functions | |
KDirLister (bool _delayedMimeTypes=false) | |
Create a directory lister. | |
virtual | ~KDirLister () |
Destroy the directory lister. | |
virtual bool | openURL (const KURL &_url, bool _keep=false, bool _reload=false) |
Run the directory lister on the given url. | |
virtual void | stop () |
Stop listing all directories currently being listed. | |
virtual void | stop (const KURL &_url) |
Stop listing the given directory. | |
bool | autoUpdate () const |
Checks whether KDirWatch will automatically update directories. | |
virtual void | setAutoUpdate (bool enable) |
Enable/disable automatic directory updating, when a directory changes (using KDirWatch). | |
bool | autoErrorHandlingEnabled () const |
Check whether auto error handling is enabled. | |
void | setAutoErrorHandlingEnabled (bool enable, QWidget *parent) |
Enable or disable auto error handling is enabled. | |
bool | showingDotFiles () const |
Checks whether hidden files (files beginning with a dot) will be shown. | |
virtual void | setShowingDotFiles (bool _showDotFiles) |
Changes the "is viewing dot files" setting. | |
bool | dirOnlyMode () const |
Checks whether the KDirLister only lists directories or all files. | |
virtual void | setDirOnlyMode (bool dirsOnly) |
Call this to list only directories. | |
const KURL & | url () const |
Returns the URL that is listed by this KDirLister. | |
virtual void | emitChanges () |
Actually emit the changes made with setShowingDotFiles, setDirOnlyMode, setNameFilter and setMimeFilter. | |
virtual void | updateDirectory (const KURL &_dir) |
Update the directory _dir . | |
bool | isFinished () const |
Returns true if no io operation is currently in progress. | |
KFileItem * | rootItem () const |
Returns the file item of the URL. | |
virtual KFileItem * | findByURL (const KURL &_url) const |
Find an item by its URL. | |
KFileItem * | find (const KURL &_url) const |
virtual KFileItem * | findByName (const QString &name) const |
Find an item by its name. | |
virtual void | setNameFilter (const QString &filter) |
Set a name filter to only list items matching this name, e.g. | |
const QString & | nameFilter () const |
Returns the current name filter, as set via setNameFilter(). | |
virtual void | setMimeFilter (const QStringList &mimeList) |
Set mime-based filter to only list items matching the given mimetypes. | |
void | setMimeExcludeFilter (const QStringList &mimeList) |
Filtering should be done with KFileFilter. | |
virtual void | clearMimeFilter () |
Clears the mime based filter. | |
const QStringList & | mimeFilters () const |
Returns the list of mime based filters, as set via setMimeFilter(). | |
bool | matchesFilter (const QString &name) const |
Checks whether name matches a filter in the list of name filters. | |
bool | matchesMimeFilter (const QString &mime) const |
Checks whether mime matches a filter in the list of mime types. | |
void | setMainWindow (QWidget *window) |
Pass the main window this object is associated with this is used for caching authentication data. | |
QWidget * | mainWindow () |
Returns the main window associated with this object. | |
KFileItemList | items (WhichItems which=FilteredItems) const |
Returns the items listed for the current url(). | |
KFileItemList | itemsForDir (const KURL &dir, WhichItems which=FilteredItems) const |
Returns the items listed for the given dir . | |
Protected Types | |
enum | Changes { NONE = 0, NAME_FILTER = 1, MIME_FILTER = 2, DOT_FILES = 4, DIR_ONLY_MODE = 8 } |
Protected Member Functions | |
virtual bool | matchesFilter (const KFileItem *) const |
Called for every new item before emitting newItems(). | |
virtual bool | matchesMimeFilter (const KFileItem *) const |
Called for every new item before emitting newItems(). | |
virtual bool | doNameFilter (const QString &name, const QPtrList< QRegExp > &filters) const |
Called by the public matchesFilter() to do the actual filtering. | |
virtual bool | doMimeFilter (const QString &mime, const QStringList &filters) const |
Called by the public matchesMimeFilter() to do the actual filtering. | |
bool | doMimeExcludeFilter (const QString &mimeExclude, const QStringList &filters) const |
virtual bool | validURL (const KURL &) const |
Checks if an url is malformed or not and displays an error message if it is and autoErrorHandling is set to true. | |
virtual void | handleError (KIO::Job *) |
Reimplement to customize error handling. | |
virtual void | virtual_hook (int id, void *data) |
Friends | |
class | KDirListerPrivate |
class | KDirListerCache |
Detailed Description
The dir lister deals with the kiojob used to list and update a directory and has signals for the user of this class (e.g. Helper class for the kiojob used to list and update a directory.konqueror view or kdesktop) to create/destroy its items when asked.
This class is independent from the graphical representation of the dir (icon container, tree view, ...) and it stores the items (as KFileItems).
Typical usage :
- Create an instance.
- Connect to at least update, clear, newItem, and deleteItem.
- Call openURL - the signals will be called.
- Reuse the instance when opening a new url (openURL).
- Destroy the instance when not needed anymore (usually destructor).
Definition at line 54 of file kdirlister.h.
Member Enumeration Documentation
|
Used by items() and itemsForDir() to specify whether you want all items for a directory or just the filtered ones.
Definition at line 350 of file kdirlister.h. |
Constructor & Destructor Documentation
|
Create a directory lister.
Definition at line 1512 of file kdirlister.cpp. References setAutoErrorHandlingEnabled(), setAutoUpdate(), setDirOnlyMode(), and setShowingDotFiles(). |
|
Destroy the directory lister.
Definition at line 1526 of file kdirlister.cpp. References stop(). |
Member Function Documentation
|
Run the directory lister on the given url.
This method causes KDirLister to emit _all_ the items of The newItems() signal may be emitted more than once to supply you with KFileItems, up until the signal completed() is emitted (and isFinished() returns true).
Definition at line 1535 of file kdirlister.cpp. References emitChanges(), KURL::prettyURL(), and validURL(). Referenced by KFileTreeBranch::populate(), KDirOperator::rereadDir(), and KDirOperator::setURL(). |
|
Stop listing all directories currently being listed. Emits canceled() if there was at least one job running. Emits canceled( const KURL& ) for each stopped job if there are at least two dirctories being watched by KDirLister. Definition at line 1554 of file kdirlister.cpp. Referenced by KDirOperator::close(), and ~KDirLister(). |
|
Stop listing the given directory.
Emits canceled() if the killed job was the last running one. Emits canceled( const KURL& ) for the killed job if there are at least two directories being watched by KDirLister. No signal is emitted if there was no job running for
Definition at line 1560 of file kdirlister.cpp. References KURL::prettyURL(). |
|
Checks whether KDirWatch will automatically update directories. This is enabled by default.
Definition at line 1566 of file kdirlister.cpp. |
|
Enable/disable automatic directory updating, when a directory changes (using KDirWatch).
Definition at line 1571 of file kdirlister.cpp. Referenced by KDirLister(), and KDirOperator::setDirLister(). |
|
Check whether auto error handling is enabled. If enabled, it will show an error dialog to the user when an error occurs. It is turned on by default.
Definition at line 1608 of file kdirlister.cpp. |
|
Enable or disable auto error handling is enabled. If enabled, it will show an error dialog to the user when an error occurs. It is turned on by default.
Definition at line 1613 of file kdirlister.cpp. Referenced by KDirLister(). |
|
Checks whether hidden files (files beginning with a dot) will be shown. By default this option is disabled (hidden files will be not shown).
Definition at line 1580 of file kdirlister.cpp. |
|
Changes the "is viewing dot files" setting. Calls updateDirectory() if setting changed. By default this option is disabled (hidden files will not be shown).
Definition at line 1585 of file kdirlister.cpp. Referenced by KDirLister(), KFileTreeBranch::KFileTreeBranch(), and KDirOperator::readConfig(). |
|
Checks whether the KDirLister only lists directories or all files. By default this option is disabled (all files will be shown).
Definition at line 1594 of file kdirlister.cpp. |
|
Call this to list only directories. By default this option is disabled (all files will be shown).
Definition at line 1599 of file kdirlister.cpp. Referenced by KDirLister(), KFileTreeView::setDirOnlyMode(), and KDirOperator::setMode(). |
|
Returns the URL that is listed by this KDirLister.
It might be different from the one given with openURL(). if there was a redirection. If you called openURL() with
Definition at line 1619 of file kdirlister.cpp. Referenced by items(). |
|
Actually emit the changes made with setShowingDotFiles, setDirOnlyMode, setNameFilter and setMimeFilter.
Definition at line 1624 of file kdirlister.cpp. References QPtrListIterator::current(), deleteItem(), doMimeFilter(), doNameFilter(), QValueList< KURL >::Iterator(), and KGlobal::staticQString(). Referenced by openURL(), and KDirOperator::updateDir(). |
|
Update the directory
This method causes KDirLister to _only_ emit the items of The current implementation calls updateDirectory automatically for local files, using KDirWatch (if autoUpdate() is true), but it might be useful to force an update manually.
Definition at line 1713 of file kdirlister.cpp. |
|
Returns true if no io operation is currently in progress.
Definition at line 1718 of file kdirlister.cpp. |
|
Returns the file item of the URL.
Definition at line 1723 of file kdirlister.cpp. |
|
Find an item by its URL.
Definition at line 1728 of file kdirlister.cpp. Referenced by KFileTreeBranch::findTVIByURL(). |
|
Find an item by its name.
Definition at line 1733 of file kdirlister.cpp. Referenced by KDirOperator::setCurrentItem(). |
|
Set a name filter to only list items matching this name, e.g. "*.cpp". You can set more than one filter by separating them with whitespace, e.g "*.cpp *.h". Note: the direcory is not automatically reloaded.
Definition at line 1748 of file kdirlister.cpp. References QStringList::split(). Referenced by KDirOperator::clearFilter(), and KDirOperator::setNameFilter(). |
|
Returns the current name filter, as set via setNameFilter().
Definition at line 1769 of file kdirlister.cpp. Referenced by KDirOperator::nameFilter(). |
|
Set mime-based filter to only list items matching the given mimetypes. NOTE: setting the filter does not automatically reload direcory. Also calling this function will not affect any named filter already set.
Definition at line 1774 of file kdirlister.cpp. Referenced by KDirOperator::setMimeFilter(). |
|
Filtering should be done with KFileFilter. This will be implemented in a later revision of KDirLister. This method may be removed then. Set mime-based exclude filter to only list items not matching the given mimetypes NOTE: setting the filter does not automatically reload direcory. Also calling this function will not affect any named filter already set.
Definition at line 1788 of file kdirlister.cpp. |
|
Clears the mime based filter.
Definition at line 1798 of file kdirlister.cpp. Referenced by KDirOperator::clearFilter(). |
|
Returns the list of mime based filters, as set via setMimeFilter().
Definition at line 1810 of file kdirlister.cpp. Referenced by KDirOperator::mimeFilter(). |
|
Checks whether
Definition at line 1815 of file kdirlister.cpp. References doNameFilter(), and KStdAccel::name(). Referenced by itemsForDir(), and matchesFilter(). |
|
Checks whether
Definition at line 1820 of file kdirlister.cpp. References doMimeFilter(). Referenced by itemsForDir(), and matchesMimeFilter(). |
|
Pass the main window this object is associated with this is used for caching authentication data.
Definition at line 2094 of file kdirlister.cpp. |
|
Returns the main window associated with this object.
Definition at line 2099 of file kdirlister.cpp. |
|
Returns the items listed for the current url(). This method will NOT start listing a directory, you should only call this when receiving the finished() signal. The items in the KFileItemList are references to the items used by KDirLister, so e.g. an item gets destroyed when the deleteItem() signal is emitted.
Definition at line 2104 of file kdirlister.cpp. References itemsForDir(), and url(). |
|
Returns the items listed for the given
This method will NOT start listing The items in the KFileItemList are references to the items used by KDirLister, so e.g. an item gets destroyed when the deleteItem() signal is emitted.
Definition at line 2109 of file kdirlister.cpp. References QPtrList::append(), QPtrListIterator::current(), KFileItem::isDir(), matchesFilter(), and matchesMimeFilter(). Referenced by items(). |
|
Tell the view that we started to list NOTE: this does _not_ imply that there is really a job running! I.e. KDirLister::jobs() may return an empty list. In this case the items are taken from the cache. The view knows that openURL should start it, so it might seem useless, but the view also needs to know when an automatic update happens.
Referenced by KFileTreeBranch::KFileTreeBranch(). |
|
Tell the view that listing is finished. There are no jobs running anymore. Referenced by KFileTreeBranch::KFileTreeBranch(). |
|
Tell the view that the listing of the directory There might be other running jobs left. This signal is only emitted if KDirLister is watching more than one directory.
|
|
Tell the view that the user canceled the listing. No running jobs are left. Referenced by KFileTreeBranch::KFileTreeBranch(). |
|
Tell the view that the listing of the directory There might be other running jobs left. This signal is only emitted if KDirLister is watching more than one directory.
|
|
Signal a redirection. Only emitted if there's just one directory to list, i.e. most probably openURL() has been called with == false.
Referenced by KFileTreeBranch::KFileTreeBranch(). |
|
Signal a redirection.
|
|
Signal to clear all items. It must always be connected to this signal to avoid doubled items! Referenced by KFileTreeBranch::KFileTreeBranch(). |
|
Signal to empty the directory It is only emitted if the lister is holding more than one directory.
|
|
Signal new items.
Referenced by KFileTreeBranch::KFileTreeBranch(). |
|
Send a list of items filtered-out by mime-type.
|
|
Signal an item to remove.
ATTENTION: if
Referenced by emitChanges(), and KFileTreeBranch::KFileTreeBranch(). |
|
Signal an item to refresh (its mimetype/icon/name has changed). Note: KFileItem::refresh has already been called on those items.
|
|
Emitted to display information about running jobs. Examples of message are "Resolving host", "Connecting to host...", etc.
|
|
Progress signal showing the overall progress of the KDirLister. This allows using a progress bar very easily. (see KProgress)
|
|
Emitted when we know the size of the jobs.
|
|
Regularly emitted to show the progress of this KDirLister.
|
|
Emitted to display information about the speed of the jobs.
|
|
Called for every new item before emitting newItems(). You may reimplement this method in a subclass to implement your own filtering. The default implementation filters out ".." and everything not matching the name filter(s)
Definition at line 1827 of file kdirlister.cpp. References KFileItem::isDir(), matchesFilter(), KGlobal::staticQString(), and KFileItem::text(). |
|
Called for every new item before emitting newItems(). You may reimplement this method in a subclass to implement your own filtering. The default implementation filters out ".." and everything not matching the name filter(s)
Definition at line 1844 of file kdirlister.cpp. References matchesMimeFilter(), and KFileItem::mimetype(). |
|
Called by the public matchesFilter() to do the actual filtering. Those methods may be reimplemented to customize filtering.
Definition at line 1850 of file kdirlister.cpp. References QPtrListIterator::current(), and KStdAccel::name(). Referenced by emitChanges(), and matchesFilter(). |
|
Called by the public matchesMimeFilter() to do the actual filtering. Those methods may be reimplemented to customize filtering.
Definition at line 1859 of file kdirlister.cpp. Referenced by emitChanges(), and matchesMimeFilter(). |
|
Checks if an url is malformed or not and displays an error message if it is and autoErrorHandling is set to true.
Definition at line 1886 of file kdirlister.cpp. References KMessageBox::error(), KURL::isMalformed(), and KURL::prettyURL(). Referenced by openURL(). |
|
Reimplement to customize error handling.
Definition at line 1903 of file kdirlister.cpp. References KIO::Job::showErrorDialog(). |
The documentation for this class was generated from the following files: