|
|
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. 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).
Advanced usage : call openURL with _keep = true to list directories without forgetting the ones previously read (e.g. for a tree view)
KDirLister ( bool _delayedMimeTypes = false )
| KDirLister |
Create a directory lister.
~KDirLister ()
| ~KDirLister |
[virtual]
Destroy the directory lister.
void openURL ( const KURL& _url, bool _showDotFiles, bool _keep = false )
| openURL |
[virtual]
Run the directory lister on the given url. If _url
is already in the cache
(i.e. openURL() was already called with _url
) and _keep == true this is
equivalent to updateDirectory
( _url ).
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).
Parameters:
_url | the directory URL. |
_showDotFiles | whether to return the "hidden" files |
_keep | if true the previous directories aren't forgotten (they are still watched by kdirwatch and their items are kept in m_lstFileItems). This is useful for e.g. a treeview. |
void stop ()
| stop |
[virtual]
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.
void stop ( const KURL& _url )
| stop |
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 _url
.
Parameters:
_url | the directory URL |
const KURL & url ()
| url |
[const virtual]
Returns: the url used by this instance to list the files, with _keep == true, this is the first url opened (in e.g. a treeview this is the root). It might be different from the one given with openURL() or setURL() if there was a redirection.
bool setURL ( const KURL& url )
| setURL |
[virtual]
Sets url
as the current url, forgetting any previous ones and stopping
any pending job. If url
is malformed, the previous url will be kept
and false will be returned.
Does _not_ start loading that url,
void updateDirectory ( const KURL& _dir )
| updateDirectory |
[virtual]
Update _dir
.
The current implementation calls it automatically for
local files, using KDirWatch (if autoUpdate() is true), but it might be
useful to force an update manually.
Parameters:
_dir | the directory URL |
void listDirectory ()
| listDirectory |
Convenience method. Starts loading the current directory, e.g. set via setURL(), if the URL is "dirty" -- otherwise the cached entries are reused. The url is dirty when a new URL was set via setURL or the nameFilter was changed.
See also: setURLDirty
void setURLDirty ( bool dirty )
| setURLDirty |
Sets the current URL "dirty", so it will be reloaded upon the next listDirectory() call.
void setAutoUpdate ( bool enable )
| setAutoUpdate |
Enable/disable automatic directory updating, when a directory changes (using KDirWatch).
bool autoUpdate ()
| autoUpdate |
[const]
Returns: whether KDirWatch is used to automatically update directories. This is enabled by default.
void setShowingDotFiles ( bool _showDotFiles )
| setShowingDotFiles |
[virtual]
Changes the "is viewing dot files" setting. Calls updateDirectory() if setting changed
bool showingDotFiles ()
| showingDotFiles |
[const virtual]
Returns: whether dotfiles are shown
KFileItem* find ( const KURL& _url )
| find |
[const]
Find an item by its URL
Parameters:
_url | the item URL |
Returns: the pointer to the KFileItem
Reimplemented from DCOPObject.
KFileItem* findByName ( const QString& name )
| findByName |
[const]
Find an item by its name
Parameters:
name | the item name |
Returns: the pointer to the KFileItem
QList<KFileItem> & items ()
| items |
Returns: the list of file items. The list may be incomplete if isFinished() is false, i.e. it is still loading items.
KFileItem * rootItem ()
| rootItem |
[const]
Returns: the file item for url() itself (".")
KIO::ListJob * job ()
| job |
[const]
## problem, if there are more jobs running (merge?)
void setDirOnlyMode ( bool dirsOnly )
| setDirOnlyMode |
Call this with dirsOnly
== true to list only directories
bool dirOnlyMode ()
| dirOnlyMode |
[const]
Returns: true if setDirOnlyMode(true) was called
void setNameFilter ( const QString& )
| setNameFilter |
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". Call setNameFilter( QString::null ) to disable filtering. Note: the direcory is not automatically reloaded.
See also: matchesFilter
void setMimeFilter ( const QStringList& )
| setMimeFilter |
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.
Parameters:
a | list of mime-types. |
See also: clearMimeFilter, matchesMimeFilter
void clearMimeFilter ()
| clearMimeFilter |
Clears the mime based filter.
See also: setMimeFilter
void setMimeFilter ( const QString& )
| setMimeFilter |
Sets mime filters separated with space. ## remove for 3.0
const QString& nameFilter ()
| nameFilter |
[const]
Returns: the current name filter, as set via setNameFilter()
QStringList mimeFilters ()
| mimeFilters |
[const]
Returns: the list of mime based filters, as set via setMimeFilter(). Empty, when no mime filter is set.
const QString& mimeFilter ()
| mimeFilter |
[const]
Returns: the current mime filter as set via setMimeFilter()
bool matchesFilter ( const QString& name )
| matchesFilter |
[const]
Returns: true if name
matches a filter in the list,
otherwise false.
See also: setNameFilter
bool matchesMimeFilter ( const QString& mime )
| matchesMimeFilter |
[const]
Parameters:
mime | the mimetype to find in the filter list. |
Returns: true if name
matches a filter in the list,
otherwise false.
See also: setNameFilter.
void FilesAdded ( const KURL & directory )
| FilesAdded |
[virtual]
Notify that files have been added in directory
The receiver will list that directory again to find
the new items (since it needs more than just the names anyway).
Reimplemented from KDirNotify.
Reimplemented from KDirNotify.
void FilesRemoved ( const KURL::List & fileList )
| FilesRemoved |
[virtual]
Notify that files have been deleted. This call passes the exact urls of the deleted files so that any view showing them can simply remove them or be closed (if its current dir was deleted) Reimplemented from KDirNotify.
Reimplemented from KDirNotify.
void FilesChanged ( const KURL::List & fileList )
| FilesChanged |
[virtual]
Notify that files have been changed. At the moment, this is only used for new icon, but it could be used for size etc. as well. Note: this is ASYNC so that it can be used with a broadcast
Reimplemented from KDirNotify.
void FileRenamed ( const KURL &src, const KURL &dst )
| FileRenamed |
[virtual]
Reimplemented from KDirNotify.
bool isFinished ()
| isFinished |
[const]
Returns true if no io operation is currently in progress.
void started ( const QString& _url )
| started |
[signal]
Tell the view that we started to list _url. 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.
## KDE 3.0: change to const KURL&
void completed ()
| completed |
[signal]
Tell the view that listing is finished. There are no jobs running anymore.
void completed ( const KURL& _url )
| completed |
[signal]
Tell the view that the listing of the directory _url
is finished.
There might be other running jobs left.
This signal is only emitted if KDirLister is watching more than one directory.
Parameters:
_url | the directory URL |
void canceled ()
| canceled |
[signal]
Tell the view that the user canceled the listing. No running jobs are left.
void canceled ( const KURL& _url )
| canceled |
[signal]
Tell the view that the listing of the directory _url
was canceled.
There might be other running jobs left.
This signal is only emitted if KDirLister is watching more than one directory.
Parameters:
_url | the directory URL |
void redirection ( const KURL & url )
| redirection |
[signal]
Signal a redirection. Only emitted if _keep == false
void redirection ( const KURL & oldUrl, const KURL & newUrl )
| redirection |
[signal]
Signal a redirection. Only emitted if _keep == true, i.e. there are more than one dirs to list
void clear ()
| clear |
[signal]
void newItems ( const KFileItemList & items )
| newItems |
[signal]
Signal new items, complete
is true when the directory loading has
finished
void itemsFilteredByMime ( const KFileItemList & items )
| itemsFilteredByMime |
[signal]
void deleteItem ( KFileItem * _fileItem )
| deleteItem |
[signal]
Signal an item to remove. ## change to const KFileItem in 3.0
void refreshItems ( const KFileItemList & items )
| refreshItems |
[signal]
Signal an item to refresh (its mimetype/icon/name has changed) Note: KFileItem::refresh has already been called on those items.
void closeView ()
| closeView |
[signal]
Instruct the view to close itself, since the dir was just deleted.
void slotResult ( KIO::Job * )
| slotResult |
[protected slots slot]
void slotEntries ( KIO::Job*, const KIO::UDSEntryList& )
| slotEntries |
[protected slots slot]
void slotUpdateResult ( KIO::Job * )
| slotUpdateResult |
[protected slots slot]
void slotUpdateEntries ( KIO::Job*, const KIO::UDSEntryList& )
| slotUpdateEntries |
[protected slots slot]
void slotRedirection ( KIO::Job *, const KURL & url )
| slotRedirection |
[protected slots slot]
void slotDirectoryDirty ( const QString& _dir )
| slotDirectoryDirty |
[protected slots slot]
void slotFileDirty ( const QString& _file )
| slotFileDirty |
[protected slots slot]
void slotURLDirty ( const KURL& dir )
| slotURLDirty |
[protected slots slot]
KFileItem * createFileItem ( const KIO::UDSEntry&, const KURL&url,
bool determineMimeTypeOnDemand )
| createFileItem |
[protected virtual]
called to create a KFileItem - you may subclass and reimplement this method if you use "special KFileItems", i.e. a subclass like KonqFileItem Must return a valid KFileItem
Parameters:
url | the URL of the DIRECTORY where this item is. |
bool matchesFilter ( const KFileItem * )
| matchesFilter |
[protected const virtual]
Called for every item after createFileItem().
Returns: false if the item shall not be shown in a view, e.g. files not matching a pattern *.cpp (KFileItem::isHidden()) 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)
See also: matchesFilter, setNameFilter
bool matchesMimeFilter ( const KFileItem * )
| matchesMimeFilter |
[protected const]
void forgetDirs ()
| forgetDirs |
[protected]
Unregister dirs from kdirwatch and clear list of dirs
void deleteUnmarkedItems ()
| deleteUnmarkedItems |
[protected]
Delete unmarked items, as it says on the tin
bool validURL ( const KURL& )
| validURL |
[protected const]
Checks if a url is malformed or not and displays an error message if it is. Returns true if it is valid, otherwise false.
void processPendingUpdates ()
| processPendingUpdates |
[protected]
If an update was triggered while we were listing, we'll process it after the end of the listing. This processes the next update in the list of pending updates.
KURL m_url | m_url |
[protected]
KIO::ListJob * m_job | m_job |
[protected]
QList<KFileItem> m_lstFileItems | m_lstFileItems |
[protected]
KFileItem * m_rootFileItem | m_rootFileItem |
[protected]
KURL::List m_lstDirs | m_lstDirs |
[protected]
bool m_isShowingDotFiles | m_isShowingDotFiles |
[protected]
bool m_bComplete | m_bComplete |
[protected]
QValueList<KIO::UDSEntry> m_buffer | m_buffer |
[protected]
bool m_bDirOnlyMode | m_bDirOnlyMode |
[protected]
bool m_bDelayedMimeTypes | m_bDelayedMimeTypes |
[protected]
QList<QRegExp> m_lstFilters | m_lstFilters |
[protected]
KDirListerPrivate * d | d |
[protected]
Generated by: dfaure on kde.faure.org on Thu Jan 17 22:16:53 2002, using kdoc 2.0a53. |