Main Page Modules Namespace List Class Hierarchy Compound List File List Namespace Members Compound Members Related Pages
KDirOperator Class Reference
A widget for displaying files and browsing directories.
More...
#include <kdiroperator.h>
List of all members.
|
Public Types |
| enum | ActionTypes |
Public Slots |
| void | back () |
| void | forward () |
| void | home () |
| void | cdUp () |
| void | updateDir () |
| void | rereadDir () |
| void | mkdir () |
| void | deleteSelected () |
| void | updateSelectionDependentActions () |
| QString | makeCompletion (const QString &) |
| QString | makeDirCompletion (const QString &) |
Signals |
| void | viewChanged (KFileView *newView) |
| void | fileHighlighted (const KFileItem *item) |
Public Methods |
| | KDirOperator (const KURL &urlName=KURL(), QWidget *parent=0, const char *name=0) |
| virtual | ~KDirOperator () |
| void | setShowHiddenFiles (bool s) |
| bool | showHiddenFiles () const |
| void | close () |
| void | setNameFilter (const QString &filter) |
| const QString & | nameFilter () const |
| void | setMimeFilter (const QStringList &mimetypes) |
| QStringList | mimeFilter () const |
| void | clearFilter () |
| KURL | url () const |
| void | setURL (const KURL &url, bool clearforward) |
| void | setCurrentItem (const QString &filename) |
| void | setView (KFileView *view) |
| KFileView * | view () const |
| QWidget * | viewWidget () const |
| void | setView (KFile::FileView view) |
| void | setSorting (QDir::SortSpec) |
| QDir::SortSpec | sorting () const |
| bool | isRoot () const |
| KDirLister * | dirLister () const |
| KProgress * | progressBar () const |
| void | setMode (KFile::Mode m) |
| KFile::Mode | mode () const |
| void | setPreviewWidget (const QWidget *w) |
| const KFileItemList * | selectedItems () const |
| bool | isSelected (const KFileItem *item) const |
| int | numDirs () const |
| int | numFiles () const |
| KCompletion * | completionObject () const |
| KCompletion * | dirCompletionObject () const |
| KActionCollection * | actionCollection () const |
| void | setViewConfig (KConfig *config, const QString &group) |
| KConfig * | viewConfig () |
| QString | viewConfigGroup () const |
| virtual void | readConfig (KConfig *, const QString &group=QString::null) |
| virtual void | writeConfig (KConfig *, const QString &group=QString::null) |
| void | setOnlyDoubleClickSelectsFiles (bool enable) |
| bool | onlyDoubleClickSelectsFiles () const |
| bool | mkdir (const QString &directory, bool enterDirectory=true) |
| KIO::DeleteJob * | del (const KFileItemList &items, bool ask=true, bool showProgress=true) |
| KIO::DeleteJob * | del (const KFileItemList &items, QWidget *parent, bool ask=true, bool showProgress=true) |
| void | clearHistory () |
| void | setEnableDirHighlighting (bool enable) |
| bool | dirHighlighting () const |
| bool | dirOnlyMode () const |
| void | setupMenu (int whichActions) |
Protected Slots |
| void | resetCursor () |
| void | pathChanged () |
| void | insertNewFiles (const KFileItemList &newone) |
| void | itemDeleted (KFileItem *) |
| void | selectDir (const KFileItem *item) |
| void | selectFile (const KFileItem *item) |
| void | highlightFile (const KFileItem *i) |
| virtual void | activatedMenu (const KFileItem *, const QPoint &pos) |
| void | sortByName () |
| void | sortBySize () |
| void | sortByDate () |
| void | sortReversed () |
| void | toggleDirsFirst () |
| void | toggleIgnoreCase () |
| void | slotCompletionMatch (const QString &match) |
Protected Methods |
| virtual KFileView * | createView (QWidget *parent, KFile::FileView view) |
| void | setDirLister (KDirLister *lister) |
| void | resizeEvent (QResizeEvent *) |
| void | setupActions () |
| void | updateSortActions () |
| void | updateViewActions () |
| void | setupMenu () |
| void | prepareCompletionObjects () |
| bool | checkPreviewSupport () |
Detailed Description
A widget for displaying files and browsing directories.
This widget works as a network transparent filebrowser. You specify a URL to display and this url will be loaded via KDirLister. The user can browse through directories, highlight and select files, delete or rename files.
It supports different views, e.g. a detailed view (see KFileDetailView), a simple icon view (see KFileIconView), a combination of two views, separating directories and files (KCombiView).
Additionally, a preview view is available (see KFilePreview), which can show either a simple or detailed view and additionally a preview widget (see setPreviewWidget()). KImageFilePreview is one implementation of a preview widget, that displays previews for all supported filetypes utilizing KIO::PreviewJob.
Currently, those classes don't support Drag&Drop out of the box -- there you have to use your own view-classes. You can use some DnD-aware views from Björn Sahlström <bjorn@kbear.org> until they will be integrated into this library. See http://devel-home.kde.org/~pfeiffer/DnD-classes.tar.gz
This widget is the one used in the KFileDialog.
Basic usage is like this:
KDirOperator *op = new KDirOperator( KURL( "file:/home/gis" ), this );
// some signals you might be interested in
connect(op, SIGNAL(urlEntered(const KURL&)),
SLOT(urlEntered(const KURL&)));
connect(op, SIGNAL(fileHighlighted(const KFileItem *)),
SLOT(fileHighlighted(const KFileItem *)));
connect(op, SIGNAL(fileSelected(const KFileItem *)),
SLOT(fileSelected(const KFileItem *)));
connect(op, SIGNAL(finishedLoading()),
SLOT(slotLoadingFinished()));
op->readConfig( KGlobal::config(), "Your KDiroperator ConfigGroup" );
op->setView(KFile::Default);
This will create a childwidget of 'this' showing the directory contents of /home/gis in the default-view. The view is determined by the readConfig() call, which will read the KDirOperator settings, the user left your program with (and which you saved with op->writeConfig()).
- Author:
-
Stephan Kulow <coolo@kde.org>, Carsten Pfeiffer <pfeiffer@kde.org>
Definition at line 98 of file kdiroperator.h.
Member Enumeration Documentation
| enum KDirOperator::ActionTypes
|
|
|
|
The various action types. These values can be or'd together - Since:
-
3.1
Definition at line 107 of file kdiroperator.h. |
Constructor & Destructor Documentation
| KDirOperator::KDirOperator |
( |
const KURL & |
urlName = KURL(), |
|
|
QWidget * |
parent = 0, |
|
|
const char * |
name = 0 |
|
) |
|
|
|
|
Constructs the KDirOperator with no initial view. As the views are configurable, call readConfig() to load the user's configuration and then setView to explicitly set a view.
This constructor doesn't start loading the url, setView will do it. |
| virtual KDirOperator::~KDirOperator |
( |
|
) |
[virtual] |
|
|
|
Destroys the KDirOperator. |
Member Function Documentation
|
|
an accessor to a collection of all available Actions. The actions are static, they will be there all the time (no need to connect to the signals KActionCollection::inserted() or removed().
There are the following actions:
- popupMenu : an ActionMenu presenting a popupmenu with all actions
- up : changes to the parent directory
- back : goes back to the previous directory
- forward : goes forward in the history
- home : changes to the user's home directory
- reload : reloads the current directory
- separator : a separator
- mkdir : opens a dialog box to create a directory
- delete : deletes the selected files/directories
- sorting menu : an ActionMenu containing all sort-options
- by name : sorts by name
- by date : sorts by date
- by size : sorts by size
- reversed : reverses the sort order
- dirs first : sorts directories before files
- case insensitive : sorts case insensitively
- view menu : an ActionMenu containing all actions concerning the view
- short view : shows a simple fileview
- detailed view : shows a detailed fileview (dates, permissions ,...)
- show hidden : shows hidden files
- separate dirs : shows directories in a separate pane
- preview : shows a preview next to the fileview
- single : hides the separate view for directories or the preview
- properties : shows a KPropertiesDialog for the selected files
The short and detailed view are in an exclusive group. The sort-by actions are in an exclusive group as well. Also the "separate dirs", "preview" and "single" actions are in an exclusive group.
You can e.g. use actionCollection()->action( "up" )->plug( someToolBar ); to add a button into a toolbar, which makes the dirOperator change to its parent directory.
- Returns:
-
all available Actions
Definition at line 381 of file kdiroperator.h. |
| virtual void KDirOperator::activatedMenu |
( |
const KFileItem * |
, |
|
|
const QPoint & |
pos |
|
) |
[protected, virtual, slot] |
|
|
|
Called upon right-click to activate the popupmenu. |
| void KDirOperator::back |
( |
|
) |
[slot] |
|
|
|
Goes one step back in the history and opens that url. |
| void KDirOperator::cdUp |
( |
|
) |
[slot] |
|
|
|
Goes one directory up from the current url. |
| bool KDirOperator::checkPreviewSupport |
( |
|
) |
[protected] |
|
| void KDirOperator::clearFilter |
( |
|
) |
|
|
| void KDirOperator::clearHistory |
( |
|
) |
|
|
|
|
Clears the forward and backward history. |
| void KDirOperator::close |
( |
|
) |
|
|
|
|
Stops loading immediately. You don't need to call this, usually. |
| KCompletion* KDirOperator::completionObject |
( |
|
) |
const [inline] |
|
| virtual KFileView* KDirOperator::createView |
( |
QWidget * |
parent, |
|
|
KFile::FileView |
view |
|
) |
[protected, virtual] |
|
|
|
A view factory for creating predefined fileviews. Called internally by setView , but you can also call it directly. Reimplement this if you depend on self defined fileviews. - Parameters:
-
| parent |
is the QWidget to be set as parent |
| view |
is the predefined view to be set, note: this can be several ones OR:ed together. |
- Returns:
-
the created KFileView
- See also:
-
KFileView , KCombiView , KFileDetailView , KFileIconView , KFilePreview , KFile::FileView , setView
|
| KIO::DeleteJob* KDirOperator::del |
( |
const KFileItemList & |
items, |
|
|
QWidget * |
parent, |
|
|
bool |
ask = true, |
|
|
bool |
showProgress = true |
|
) |
|
|
|
|
Starts and returns a KIO::DeleteJob to delete the given items. - Parameters:
-
| parent |
the parent widget used for the confirmation dialog |
| ask |
specifies whether a confirmation dialog should be shown |
| showProgress |
passed to the DeleteJob to show a progress dialog |
- Since:
-
3.1
|
| KIO::DeleteJob* KDirOperator::del |
( |
const KFileItemList & |
items, |
|
|
bool |
ask = true, |
|
|
bool |
showProgress = true |
|
) |
|
|
|
|
Starts and returns a KIO::DeleteJob to delete the given items. - Parameters:
-
| ask |
specifies whether a confirmation dialog should be shown |
| showProgress |
passed to the DeleteJob to show a progress dialog |
|
| void KDirOperator::deleteSelected |
( |
|
) |
[slot] |
|
|
|
Deletes the currently selected files/directories. |
| KCompletion* KDirOperator::dirCompletionObject |
( |
|
) |
const [inline] |
|
| bool KDirOperator::dirHighlighting |
( |
|
) |
|
|
|
|
- Returns:
-
whether the last directory will be made the current item when going up in the directory hierarchy.
Default is false. |
| KDirLister* KDirOperator::dirLister |
( |
|
) |
const [inline] |
|
|
|
- Returns:
-
the object listing the directory
Definition at line 255 of file kdiroperator.h. |
| bool KDirOperator::dirOnlyMode |
( |
|
) |
const [inline] |
|
|
|
- Returns:
-
true if we are in directory-only mode, that is, no files are shown.
Definition at line 521 of file kdiroperator.h. |
| void KDirOperator::fileHighlighted |
( |
const KFileItem * |
item |
) |
[signal] |
|
|
|
Emitted when a file is highlighted or generally the selection changes in multiselection mode. In the latter case, item is 0L. You can access the selected items with selectedItems().
Referenced by highlightFile(). |
| void KDirOperator::forward |
( |
|
) |
[slot] |
|
|
|
Goes one step forward in the history and opens that url. |
| void KDirOperator::highlightFile |
( |
const KFileItem * |
i |
) |
[inline, protected, slot] |
|
| void KDirOperator::home |
( |
|
) |
[slot] |
|
|
|
Enters the home directory. |
| void KDirOperator::insertNewFiles |
( |
const KFileItemList & |
newone |
) |
[protected, slot] |
|
|
|
Adds a new list of KFileItems to the view (coming from KDirLister) |
| bool KDirOperator::isRoot |
( |
|
) |
const [inline] |
|
| bool KDirOperator::isSelected |
( |
const KFileItem * |
item |
) |
const [inline] |
|
| void KDirOperator::itemDeleted |
( |
KFileItem * |
|
) |
[protected, slot] |
|
| QString KDirOperator::makeCompletion |
( |
const QString & |
|
) |
[slot] |
|
|
|
Tries to complete the given string (only completes files). |
| QString KDirOperator::makeDirCompletion |
( |
const QString & |
|
) |
[slot] |
|
|
|
Tries to complete the given string (only completes directores). |
| QStringList KDirOperator::mimeFilter |
( |
|
) |
const [inline] |
|
| void KDirOperator::mkdir |
( |
|
) |
[slot] |
|
|
|
Opens a dialog to create a new directory. |
| bool KDirOperator::mkdir |
( |
const QString & |
directory, |
|
|
bool |
enterDirectory = true |
|
) |
|
|
|
|
Creates the given directory/url. If it is a relative path, it will be completed with the current directory. If enterDirectory is true, the directory will be entered after a successful operation. If unsuccessful, a messagebox will be presented to the user. - Returns:
-
true if the directory could be created.
|
|
|
- Returns:
-
the listing/selection mode.
|
| const QString& KDirOperator::nameFilter |
( |
|
) |
const [inline] |
|
| int KDirOperator::numDirs |
( |
|
) |
|
|
|
|
- Returns:
-
the number of directories in the currently listed url. Returns 0 if there is no view.
|
| int KDirOperator::numFiles |
( |
|
) |
|
|
|
|
- Returns:
-
the number of files in the currently listed url. Returns 0 if there is no view.
|
| bool KDirOperator::onlyDoubleClickSelectsFiles |
( |
|
) |
|
|
| void KDirOperator::pathChanged |
( |
|
) |
[protected, slot] |
|
|
|
Called after setURL() to load the directory, update the history, etc. |
| void KDirOperator::prepareCompletionObjects |
( |
|
) |
[protected] |
|
|
|
- Returns:
-
the progress widget, that is shown during directory listing. You can for example reparent() it to put it into a statusbar.
|
| virtual void KDirOperator::readConfig |
( |
KConfig * |
, |
|
|
const QString & |
group = QString::null |
|
) |
[virtual] |
|
|
|
Reads the default settings for a view, i.e. the default KFile::FileView. Also reads the sorting and whether hidden files should be shown. Note: the default view will not be set - you have to call
setView( KFile::Default )
to apply it.
- See also:
-
setView , setViewConfig , writeConfig
|
| void KDirOperator::rereadDir |
( |
|
) |
[slot] |
|
|
|
Re-reads the current url. |
| void KDirOperator::resetCursor |
( |
|
) |
[protected, slot] |
|
|
|
Restores the normal cursor after showing the busy-cursor. Also hides the progressbar. |
| void KDirOperator::resizeEvent |
( |
QResizeEvent * |
|
) |
[protected] |
|
| void KDirOperator::selectDir |
( |
const KFileItem * |
item |
) |
[protected, slot] |
|
|
|
Enters the directory specified by the given item. |
| const KFileItemList* KDirOperator::selectedItems |
( |
|
) |
const [inline] |
|
| void KDirOperator::selectFile |
( |
const KFileItem * |
item |
) |
[protected, slot] |
|
|
|
Emits fileSelected( item ) |
| void KDirOperator::setCurrentItem |
( |
const QString & |
filename |
) |
|
|
|
|
Clears the current selection and attempts to set filename the current file. filename is just the name, no path or url. |
| void KDirOperator::setDirLister |
( |
KDirLister * |
lister |
) |
[protected] |
|
|
|
Sets a custom KFileReader to list directories. |
| void KDirOperator::setEnableDirHighlighting |
( |
bool |
enable |
) |
|
|
|
|
When going up in the directory hierarchy, KDirOperator can highlight the directory that was just left.
I.e. when you go from /home/gis/src to /home/gis, the item "src" will be made the current item.
Default is off. |
| void KDirOperator::setMimeFilter |
( |
const QStringList & |
mimetypes |
) |
|
|
|
|
Sets a list of mimetypes as filter. Only files of those mimetypes will be shown.
Example:
QStringList filter;
filter << "text/html" << "image/png" << "inode/directory";
dirOperator->setMimefilter( filter );
Node: Without the mimetype inode/directory, only files would be shown. Call updateDir() to apply it.
- See also:
-
KDirLister::setMimeFilter , mimeFilter
|
|
|
Sets the listing/selection mode for the views, an OR'ed combination of
- File
- Directory
- Files
- ExistingOnly
- LocalOnly
You cannot mix File and Files of course, as the former means single-selection mode, the latter multi-selection. |
| void KDirOperator::setNameFilter |
( |
const QString & |
filter |
) |
|
|
| void KDirOperator::setOnlyDoubleClickSelectsFiles |
( |
bool |
enable |
) |
|
|
|
|
This is a KFileDialog specific hack: we want to select directories with single click, but not files. But as a generic class, we have to be able to select files on single click as well.
This gives us the opportunity to do both.
The default is false, set it to true if you don't want files selected with single click. |
| void KDirOperator::setPreviewWidget |
( |
const QWidget * |
w |
) |
|
|
|
|
Sets a preview-widget to be shown next to the file-view. The ownership of w is transferred to KDirOperator, so don't delete it yourself! |
| void KDirOperator::setShowHiddenFiles |
( |
bool |
s |
) |
[inline] |
|
| void KDirOperator::setSorting |
( |
QDir::SortSpec |
|
) |
|
|
|
|
Sets the way to sort files and directories. |
| void KDirOperator::setupActions |
( |
|
) |
[protected] |
|
|
|
Sets up all the actions. Called from the constructor, you usually better not call this. |
| void KDirOperator::setupMenu |
( |
|
) |
[protected] |
|
|
|
Sets up the context-menu with all the necessary actions. Called from the constructor, you usually don't need to call this. - Since:
-
3.1
|
| void KDirOperator::setupMenu |
( |
int |
whichActions |
) |
|
|
|
|
Sets up the action menu. - Parameters:
-
| actionTypes |
is an value of OR'd ActionTypes that controls which actions to show in the action menu |
|
| void KDirOperator::setURL |
( |
const KURL & |
url, |
|
|
bool |
clearforward |
|
) |
|
|
|
|
Sets a new url to list. - Parameters:
-
| clearforward |
specifies whether the "forward" history should be cleared. |
|
| void KDirOperator::setView |
( |
KFile::FileView |
view |
) |
|
|
|
|
Sets one of the predefined fileviews - See also:
-
KFile::FileView
|
| void KDirOperator::setView |
( |
KFileView * |
view |
) |
|
|
| void KDirOperator::setViewConfig |
( |
KConfig * |
config, |
|
|
const QString & |
group |
|
) |
|
|
|
|
Sets the config object and the to be used group in KDirOperator. This will be used to store the view's configuration via KFileView::writeConfig() (and for KFileView::readConfig()). If you don't set this, the views cannot save and restore their configuration.
Usually you call this right after KDirOperator creation so that the view instantiation can make use of it already.
Note that KDirOperator does NOT take ownership of that object (typically it's KGlobal::config() anyway.
- See also:
-
viewConfig , viewConfigGroup
- Since:
-
3.1
|
| bool KDirOperator::showHiddenFiles |
( |
|
) |
const [inline] |
|
| void KDirOperator::slotCompletionMatch |
( |
const QString & |
match |
) |
[protected, slot] |
|
|
|
Tries to make the given match as current item in the view and emits completion( match ) |
| void KDirOperator::sortByDate |
( |
|
) |
[inline, protected, slot] |
|
| void KDirOperator::sortByName |
( |
|
) |
[inline, protected, slot] |
|
| void KDirOperator::sortBySize |
( |
|
) |
[inline, protected, slot] |
|
| QDir::SortSpec KDirOperator::sorting |
( |
|
) |
const [inline] |
|
|
|
- Returns:
-
the current way of sorting files and directories
Definition at line 245 of file kdiroperator.h. |
| void KDirOperator::sortReversed |
( |
|
) |
[inline, protected, slot] |
|
| void KDirOperator::toggleDirsFirst |
( |
|
) |
[inline, protected, slot] |
|
| void KDirOperator::toggleIgnoreCase |
( |
|
) |
[inline, protected, slot] |
|
| void KDirOperator::updateDir |
( |
|
) |
[slot] |
|
|
|
to update the view after changing the settings |
| void KDirOperator::updateSelectionDependentActions |
( |
|
) |
[slot] |
|
|
|
Enables/disables actions that are selection dependent. Call this e.g. when you are about to show a popup menu using some of KDirOperators actions. |
| void KDirOperator::updateSortActions |
( |
|
) |
[protected] |
|
|
|
Updates the sorting-related actions to comply with the current sorting - See also:
-
sorting
|
| void KDirOperator::updateViewActions |
( |
|
) |
[protected] |
|
|
|
Updates the view-related actions to comply with the current KFile::FileView |
| KURL KDirOperator::url |
( |
|
) |
|
|
|
|
- Returns:
-
the current url
Referenced by isRoot(). |
| KFileView* KDirOperator::view |
( |
|
) |
const [inline] |
|
| void KDirOperator::viewChanged |
( |
KFileView * |
newView |
) |
[signal] |
|
|
|
Emitted whenever the current fileview is changed, either by an explicit call to setView() or by the user selecting a different view thru the GUI. |
| KConfig* KDirOperator::viewConfig |
( |
|
) |
|
|
|
|
Returns the KConfig object used for saving and restoring view's configuration. - Returns:
-
the KConfig object used for saving and restoring view's configuration.
- Since:
-
3.1
|
| QString KDirOperator::viewConfigGroup |
( |
|
) |
|
|
|
|
Returns the group name used for saving and restoring view's configuration. - Returns:
-
the group name used for saving and restoring view's configuration.
- Since:
-
3.1
|
| QWidget* KDirOperator::viewWidget |
( |
|
) |
const [inline] |
|
| virtual void KDirOperator::writeConfig |
( |
KConfig * |
, |
|
|
const QString & |
group = QString::null |
|
) |
[virtual] |
|
The documentation for this class was generated from the following file:
Generated on Wed Aug 13 23:30:10 2003 for kdelibs by
1.2.18