# class KDirOperator

###

Module | kio
Namespace |
Class | KDirOperator
Inherits | QWidget

### enums

- ActionType { SortActions, ViewActions, NavActions, FileActions, AllActions }

enum details

### methods

- KDirOperator (urlName, parent)

  returns ctor
  KDE 4.1.0 and later only

  Argument | Type | Default
  --- | --- | ---
  urlName | KUrl | KUrl()
  parent | QWidget | 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.

- KDirOperator (a0, a1)

  returns ctor
  before KDE 4.1.0 only

  Argument | Type | Default
  --- | --- | ---
  a0 | KUrl | KUrl()
  a1 | QWidget | 0

- actionCollection ( )

  returns KActionCollection

  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
- 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 size : sorts by size
- by date : sorts by date
- by type : sorts by type
- descending : reverses the sort order
- 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
- preview : shows a preview next to the fileview
- 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

- activatedMenu (item, pos)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  item | KFileItem |
  pos | QPoint |

  Called upon right-click to activate the popupmenu.

- back ( )

  returns Nothing

  Goes one step back in the history and opens that url.

- cdUp ( )

  returns Nothing

  Goes one directory up from the current url.

- changeEvent (event)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  event | QEvent |

- checkPreviewSupport ( )

  returns bool

  Checks if there support from KIO.PreviewJob for the currently shown files, taking mimeFilter() and nameFilter() into account Enables/disables the preview-action accordingly.

- clearFilter ( )

  returns Nothing

  Clears both the namefilter and mimetype filter, so that all files and directories will be shown. Call updateDir() to apply it.

  See also setMimeFilter

  See also setNameFilter

- clearHistory ( )

  returns Nothing

  Clears the forward and backward history.

- close ( )

  returns Nothing

  Stops loading immediately. You don't need to call this, usually.

- completion (a0)

  returns Nothing
  SIGNAL ("completion (const QString&)")

  Argument | Type | Default
  --- | --- | ---
  a0 | QString |

- completionObject ( )

  returns KCompletion

  Returns a KCompletion object, containing all filenames and directories of the current directory/URL. You can use it to insert it into a KLineEdit or KComboBox Note: it will only contain files, after prepareCompletionObjects() has been called. It will be implicitly called from makeCompletion() or makeDirCompletion()

- createView (parent, viewKind)

  returns QAbstractItemView

  Argument | Type | Default
  --- | --- | ---
  parent | QWidget |
  viewKind | KFile.FileView |

  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.

  parent - is the QWidget to be set as parent

  viewKind - is the predefined view to be set, note: this can be several ones OR:ed together Returns the created view

  See also KFile.FileView

  See also setView

- del (items, parent, ask, showProgress)

  returns KIO.DeleteJob

  Argument | Type | Default
  --- | --- | ---
  items | KFileItemList |
  parent | QWidget | 0
  ask | bool | 1
  showProgress | bool | 1

  Starts and returns a KIO.DeleteJob to delete the given items.

  items - the list of items to be deleted

  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

- deleteSelected ( )

  returns Nothing

  Deletes the currently selected files/directories.

- dirActivated (item)

  returns Nothing
  SIGNAL ("dirActivated (const KFileItem&)")

  Argument | Type | Default
  --- | --- | ---
  item | KFileItem |

- dirCompletionObject ( )

  returns KCompletion

  Returns a KCompletion object, containing only all directories of the current directory/URL. You can use it to insert it into a KLineEdit or KComboBox Note: it will only contain directories, after prepareCompletionObjects() has been called. It will be implicitly called from makeCompletion() or makeDirCompletion()

- dirHighlighting ( )

  returns bool

  Returns whether the last directory will be made the current item when going up in the directory hierarchy.

  Default is false.

- dirLister ( )

  returns KDirLister

  Returns the object listing the directory

- dirOnlyMode ( )

  returns bool

  Returns true if we are in directory-only mode, that is, no files are shown.

- dirOnlyMode (mode)

  returns bool
  static

  Argument | Type | Default
  --- | --- | ---
  mode | uint |

- dropped (item, event, urls)

  returns Nothing
  SIGNAL ("dropped (const KFileItem&, QDropEvent*, const List&)")

  Argument | Type | Default
  --- | --- | ---
  item | KFileItem |
  event | QDropEvent |
  urls | KUrl.List |

  Emitted when files are dropped. Dropping files is disabled by default. You need to enable it with setAcceptDrops()

  item - the item on which the drop occurred or 0.

  event - the drop event itself.

  urls - the urls that where dropped.

- eventFilter (watched, event)

  returns bool
  KDE 4.1.0 and later only

  Argument | Type | Default
  --- | --- | ---
  watched | QObject |
  event | QEvent |

- fileHighlighted (item)

  returns Nothing
  SIGNAL ("fileHighlighted (const KFileItem&)")

  Argument | Type | Default
  --- | --- | ---
  item | KFileItem |

  Emitted when a file is highlighted or generally the selection changes in multiselection mode. In the latter case, item is 0. You can access the selected items with selectedItems().

- fileSelected (item)

  returns Nothing
  SIGNAL ("fileSelected (const KFileItem&)")

  Argument | Type | Default
  --- | --- | ---
  item | KFileItem |

- finishedLoading ( )

  returns Nothing
  SIGNAL ("finishedLoading ()")

- forward ( )

  returns Nothing

  Goes one step forward in the history and opens that url.

- highlightFile (item)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  item | KFileItem |

  Emits fileHighlighted(item)

- home ( )

  returns Nothing

  Enters the home directory.

- isRoot ( )

  returns bool

  Returns true if we are displaying the root directory of the current url

- isSelected (item)

  returns bool

  Argument | Type | Default
  --- | --- | ---
  item | KFileItem |

  Returns true if item is currently selected, or false otherwise.

- makeCompletion (a0)

  returns QString

  Argument | Type | Default
  --- | --- | ---
  a0 | QString |

  Tries to complete the given string (only completes files).

- makeDirCompletion (a0)

  returns QString

  Argument | Type | Default
  --- | --- | ---
  a0 | QString |

  Tries to complete the given string (only completes directores).

- mimeFilter ( )

  returns QStringList

  Returns the current mime filter.

- mkdir (directory, enterDirectory)

  returns bool

  Argument | Type | Default
  --- | --- | ---
  directory | QString |
  enterDirectory | bool | 1

  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.

- mkdir ( )

  returns Nothing

  Opens a dialog to create a new directory.

- mode ( )

  returns KFile.Modes

  Returns the listing/selection mode.

- nameFilter ( )

  returns QString

  Returns the current namefilter.

  See also setNameFilter

- numDirs ( )

  returns int

  Returns the number of directories in the currently listed url. Returns 0 if there is no view.

- numFiles ( )

  returns int

  Returns the number of files in the currently listed url. Returns 0 if there is no view.

- onlyDoubleClickSelectsFiles ( )

  returns bool

  Returns whether files (not directories) should only be select()ed by double-clicks.

  See also setOnlyDoubleClickSelectsFiles

- pathChanged ( )

  returns Nothing

  Called after setUrl() to load the directory, update the history, etc.

- prepareCompletionObjects ( )

  returns Nothing

  Synchronizes the completion objects with the entries of the currently listed url.

  Automatically called from makeCompletion() and makeDirCompletion()

- progressBar ( )

  returns QProgressBar

  Returns the progress widget, that is shown during directory listing. You can for example reparent() it to put it into a statusbar.

- readConfig (configGroup)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  configGroup | KConfigGroup |

  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

  See also setViewConfig

  See also writeConfig

- rereadDir ( )

  returns Nothing

  Re-reads the current url.

- resetCursor ( )

  returns Nothing

  Restores the normal cursor after showing the busy-cursor. Also hides the progressbar.

- resizeEvent (event)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  event | QResizeEvent |

- selectDir (item)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  item | KFileItem |

  Enters the directory specified by the given item.

- selectFile (item)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  item | KFileItem |

  Emits fileSelected( item )

- selectedItems ( )

  returns KFileItemList

  Returns a list of all currently selected items. If there is no view, or there are no selected items, an empty list is returned.

- setAcceptDrops (b)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  b | bool |

  Reimplemented - allow dropping of files if b is true

  b - true if the widget should allow dropping of files

- setCurrentItem (filename)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  filename | QString |

  Clears the current selection and attempts to set filename the current file. filename is just the name, no path or url.

- setCurrentItem (item)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  item | KFileItem |

  Clears the current selection and attempts to set item as the the current item.

- setDirLister (lister)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  lister | KDirLister |

  Sets a custom KDirLister to list directories. The KDirOperator takes ownership of the given KDirLister.

- setDropOptions (options)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  options | int |

  Sets the options for dropping files. CURRENTLY NOT IMPLEMENTED

- setEnableDirHighlighting (enable)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  enable | bool |

  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.

- setMimeFilter (mimetypes)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  mimetypes | QStringList |

  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

  See also mimeFilter

- setMode (m)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  m | KFile.Modes |

  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.

- setNameFilter (filter)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  filter | QString |

  Sets a filter like "*.cpp *.h *.o". Only files matching that filter will be shown.

  See also KDirLister.setNameFilter

  See also nameFilter

- setOnlyDoubleClickSelectsFiles (enable)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  enable | bool |

  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.

- setPreviewWidget (w)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  w | KPreviewWidgetBase |

  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!

- setShowHiddenFiles (s)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  s | bool |

  Enables/disables showing hidden files.

- setSorting (a0)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  a0 | QDir.SortFlags |

  Sets the way to sort files and directories.

- setUrl (url, clearforward)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  url | KUrl |
  clearforward | bool |

  Sets a new url to list.

  clearforward - specifies whether the "forward" history should be cleared.

  url - the URL to set

- setView (view)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  view | QAbstractItemView |

  Sets a new view to be used for showing and browsing files. Note: this will read the current url() to fill the view.

  See also KFileTreeView

  See also view

- setView (viewKind)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  viewKind | KFile.FileView |

  Sets one of the predefined fileviews.

  See also KFile.FileView

- setViewConfig (configGroup)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  configGroup | KConfigGroup |

  Sets the config object and the to be used group in KDirOperator. This will be used to store the view's configuration. 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.

  You must not delete the KConfig or KConfigGroup object (and master config object) before either deleting the KDirOperator or calling setViewConfig(0); or something like that

  See also viewConfig

  See also viewConfigGroup

- setupActions ( )

  returns Nothing

  Sets up all the actions. Called from the constructor, you usually better not call this.

- setupMenu (whichActions)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  whichActions | int |

  Sets up the action menu.

  whichActions - is an value of OR'd ActionTypes that controls which actions to show in the action menu

- setupMenu ( )

  returns Nothing

  Sets up the context-menu with all the necessary actions. Called from the constructor, you usually don't need to call this.

- showHiddenFiles ( )

  returns bool

  Returns true when hidden files are shown or false otherwise.

- slotCompletionMatch (match)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  match | QString |

  Tries to make the given match as current item in the view and emits completion( match )

- sortByDate ( )

  returns Nothing

  Changes sorting to sort by date

- sortByName ( )

  returns Nothing

  Changes sorting to sort by name

- sortBySize ( )

  returns Nothing

  Changes sorting to sort by size

- sortByType ( )

  returns Nothing

  Changes sorting to sort by date

- sortReversed ( )

  returns Nothing

  Changes sorting to reverse sorting

- sorting ( )

  returns QDir.SortFlags

  Returns the current way of sorting files and directories

- toggleDirsFirst ( )

  returns Nothing

  Toggles showing directories first / having them sorted like files.

- toggleIgnoreCase ( )

  returns Nothing

  Toggles case sensitive / case insensitive sorting

- trash (items, parent, ask, showProgress)

  returns KIO.CopyJob

  Argument | Type | Default
  --- | --- | ---
  items | KFileItemList |
  parent | QWidget |
  ask | bool | 1
  showProgress | bool | 1

  Starts and returns a KIO.CopyJob to trash the given items.

  items - the list of items to be trashed

  parent - the parent widget used for the confirmation dialog

  ask - specifies whether a confirmation dialog should be shown

  showProgress - passed to the CopyJob to show a progress dialog

- trashSelected ( )

  returns Nothing

  Trashes the currently selected files/directories.

  This function used to take activation reason and keyboard modifiers, in order to call deleteSelected() if the user wanted to delete. Instead, call deleteSelected().

  FIXME KAction Port: link deleteSelected() up correctly

- updateDir ( )

  returns Nothing

  to update the view after changing the settings

- updateInformation (files, dirs)

  returns Nothing
  SIGNAL ("updateInformation (int, int)")

  Argument | Type | Default
  --- | --- | ---
  files | int |
  dirs | int |

- updateSelectionDependentActions ( )

  returns Nothing

  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.

- updateSortActions ( )

  returns Nothing

  Updates the sorting-related actions to comply with the current sorting

  See also sorting

- updateViewActions ( )

  returns Nothing

  Updates the view-related actions to comply with the current KFile.FileView

- url ( )

  returns KUrl

  Returns the current url

- urlEntered (a0)

  returns Nothing
  SIGNAL ("urlEntered (const KUrl&)")

  Argument | Type | Default
  --- | --- | ---
  a0 | KUrl |

- view ( )

  returns QAbstractItemView

  Returns the currently used view.

  See also setView

- viewChanged (newView)

  returns Nothing
  SIGNAL ("viewChanged (QAbstractItemView*)")

  Argument | Type | Default
  --- | --- | ---
  newView | QAbstractItemView |

  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.

- viewConfigGroup ( )

  returns KConfigGroup

- writeConfig (configGroup)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  configGroup | KConfigGroup |

  Saves the current settings like sorting, simple or detailed view.

  See also readConfig

  See also setViewConfig

### enums - detail

- ActionType { SortActions, ViewActions, NavActions, FileActions, AllActions }

  The various action types. These values can be or'd together

  | SortActions | - 1 | - |
  | ViewActions | - 2 | - |
  | NavActions | - 4 | - |
  | FileActions | - 8 | - |
  | AllActions | - 15 | - |