# class KFileView

### abstract class

Table of contents
Modules
kio Classes
All Classes

Module | kio
Namespace | global
Class | KFileView
Inherits |

This class defines an interface to all file views. Its intent is to allow to switch the view of the files in the selector very easily. It defines some pure virtual functions, that must be implemented to make a file view working.

Since this class is not a widget, but it's meant to be added to other widgets, its most important function is widget. This should return a pointer to the implemented widget.

A base class for views of the KDE file selector Author Stephan Kulow <coolo@kde.org>

### enums

- DropOptions = { AutoOpenDirs }
- ViewMode = { Files, Directories, All }

enum details

### methods

- KFileView ()

  returns a KFileView object

  Destructor

- actionCollection ()

  returns (KActionCollection)

  Returns the view-specific action-collection. Every view should add its actions here (if it has any) to make them available to e.g. the KDirOperator's popup-menu.

- addItemList (list)

  returns nothing

  Argument | Type | Default
  --- | --- | ---
  list | KFileItemList |

  inserts a list of items.

- autoOpenDelay ()

  returns (int)
  static

  Internal delay before auto opening a directory

- clear ()

  returns nothing

  Clears the view and all item lists.

- clearSelection ()

  returns nothing
  pure virtual

  Clears any selection, unhighlights everything. Must be implemented by the view.

- clearView ()

  returns nothing
  pure virtual

  pure virtual function, that should be implemented to clear the view. At this moment the list is already empty

- count ()

  returns (uint)

  Returns the number of dirs and files

- currentFileItem ()

  returns (KFileItem)
  pure virtual

  Returns the "current" KFileItem, e.g. where the cursor is. Returns 0L when there is no current item (e.g. in an empty view). Subclasses have to implement this.

- dropOptions ()

  returns (int)

  Returns the DND options in effect. See DropOptions for details.

- ensureItemVisible (i)

  returns nothing
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  i | KFileItem |

  pure virtual function, that should be implemented to make item i visible, i.e. by scrolling the view appropriately.

- firstFileItem ()

  returns (KFileItem)
  pure virtual

- insertItem (i)

  returns nothing

  Argument | Type | Default
  --- | --- | ---
  i | KFileItem |

  The derived view must implement this function to add the file in the widget.

  Make sure to call this implementation, i.e. KFileView.insertItem( i );

- invertSelection ()

  returns nothing

  Inverts the current selection, i.e. selects all items, that were up to now not selected and deselects the other.

- isReversed ()

  returns (bool)

  Tells whether the current items are in reversed order (shortcut to sorting() & QDir.Reversed).

- isSelected (a0)

  returns (bool)
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  a0 | KFileItem |

  Returns whether the given item is currently selected. Must be implemented by the view.

- items ()

  returns (KFileItemList)

  Returns all items currently available in the current sort-order

- listingCompleted ()

  returns nothing

  This hook is called when all items of the currently listed directory are listed and inserted into the view, i.e. there won't come any new items anymore.

- nextItem (a0)

  returns (KFileItem)
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  a0 | KFileItem |

- numDirs ()

  returns (uint)

  Returns the number of directories

- numFiles ()

  returns (uint)

  Returns the number of files.

- onlyDoubleClickSelectsFiles ()

  returns (bool)

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

  See also setOnlyDoubleClickSelectsFiles

- prevItem (a0)

  returns (KFileItem)
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  a0 | KFileItem |

- readConfig (a0)

  returns nothing

  Argument | Type | Default
  --- | --- | ---
  a0 | KConfigGroup |

- removeItem (item)

  returns nothing

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

  Removes an item from the list; has to be implemented by the view. Call KFileView.removeItem( item ) after removing it.

- selectAll ()

  returns nothing

  Selects all items. You may want to override this, if you can implement it more efficiently than calling setSelected() with every item. This works only in Multiselection mode of course.

- selectedItems ()

  returns (KFileItemList)

  Returns all currently highlighted items.

- selectionMode ()

  returns (KFile.SelectionMode)

- setCurrentItem (filename)

  returns nothing

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

  Sets filename the current item in the view, if available.

- setCurrentItem (item)

  returns nothing
  pure virtual

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

  Reimplement this to set item the current item in the view, e.g. the item having focus.

- setDropOptions (options)

  returns nothing

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

  Specify DND options. See DropOptions for details. All options are disabled by default.

- 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.

  Every view has to decide when to call select( item ) when a file was single-clicked, based on onlyDoubleClickSelectsFiles().

- setParentView (parent)

  returns nothing

  Argument | Type | Default
  --- | --- | ---
  parent | KFileView |

- setSelected (a0, enable)

  returns nothing
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  a0 | KFileItem |
  enable | bool |

  Tells the view that it should highlight the item. This function must be implemented by the view.

- setSelectionMode (sm)

  returns nothing

  Argument | Type | Default
  --- | --- | ---
  sm | KFile.SelectionMode |

- setSorting (sort)

  returns nothing

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

  Sets the sorting order of the view.

  Default is QDir.Name | QDir.IgnoreCase | QDir.DirsFirst Override this in your subclass and sort accordingly (usually by setting the sorting-key for every item and telling QIconView or QListView to sort.

  A view may choose to use a different sorting than QDir.Name, Time or Size. E.g. to sort by mimetype or any possible string. Set the sorting to QDir.Unsorted for that and do the rest internally.

  See also sortingKey

- setViewMode (vm)

  returns nothing

  Argument | Type | Default
  --- | --- | ---
  vm | KFileView.ViewMode |

- setViewName (name)

  returns nothing

  Argument | Type | Default
  --- | --- | ---
  name | QString |

  Sets the name of the view, which could be displayed somewhere. E.g. "Image Preview".

- signaler ()

  returns (KFileViewSignaler)

- sortReversed ()

  returns nothing

- sorting ()

  returns (QDir.SortFlags)

  Returns the sorting order of the internal list. Newly added files are added through this sorting.

- sortingKey (value, isDir, SortFlags)

  returns (QString)
  static

  Argument | Type | Default
  --- | --- | ---
  value | QString |
  isDir | bool |
  SortFlags | QDir.SortFlags |

  This method calculates a QString from the given parameters, that is suitable for sorting with e.g. QIconView or QListView. Their Item-classes usually have a setKey( const QString& ) method or a virtual method QString key() that is used for sorting.

  value - Any string that should be used as sort criterion

  isDir - Tells whether the key is computed for an item representing a directory (directories are usually sorted before files)

  SortFlags - An ORed combination of QDir.SortFlag flags. Currently, the values IgnoreCase, Reversed and DirsFirst are taken into account.

- sortingKey (value, isDir, SortFlags)

  returns (QString)
  static

  Argument | Type | Default
  --- | --- | ---
  value | KIO.filesize_t |
  isDir | bool |
  SortFlags | QDir.SortFlags |

  An overloaded method that takes not a QString, but a number as sort criterion. You can use this for file-sizes or dates/times for example. If you use a time_t, you need to cast that to KIO.filesize_t because of ambiguity problems.

- updateNumbers (i)

  returns (bool)

  Argument | Type | Default
  --- | --- | ---
  i | KFileItem |

  increases the number of dirs and files. Returns true if the item fits the view mode

- updateView (f)

  returns nothing

  Argument | Type | Default
  --- | --- | ---
  f | bool | True

  does a repaint of the view.

  The default implementation calls

      widget()->repaint(f)

- updateView (a0)

  returns nothing

  Argument | Type | Default
  --- | --- | ---
  a0 | KFileItem |

- viewMode ()

  returns (KFileView.ViewMode)

- viewName ()

  returns (QString)

  Returns the localized name of the view, which could be displayed somewhere, e.g. in a menu, where the user can choose between views.

  See also setViewName

- widget ()

  returns (QWidget)
  pure virtual

  a pure virtual function to get a QWidget, that can be added to other widgets. This function is needed to make it possible for derived classes to derive from other widgets.

- widget ()

  returns (QWidget)
  Method is not implemented

  a pure virtual function to get a QWidget, that can be added to other widgets. This function is needed to make it possible for derived classes to derive from other widgets.

- writeConfig (a0)

  returns nothing

  Argument | Type | Default
  --- | --- | ---
  a0 | KConfigGroup |

### enums - detail

- DropOptions = { AutoOpenDirs }

  | AutoOpenDirs | - |

- ViewMode = { Files, Directories, All }

  | Files | - |
  | Directories | - |
  | All | - |