class KFileView

A base class for views of the KDE file selector. More...

Contains pure virtuals
Definition#include <kfileview.h>
Inherited byKCombiView, KFileDetailView, KFileIconView, KFilePreview
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Types

Public Methods

Public Static Methods

Protected Methods

Protected Members


Detailed Description

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.

 KFileView ()

KFileView

 ~KFileView ()

~KFileView

[virtual]

Destructor

void  addItemList (const KFileItemList &list)

addItemList

inserts a list of items.

QWidgetwidget ()

widget

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

QWidgetwidget ()

widget

[const]

### As const-method, to be fixed in 3.0

void  setCurrentItem ( const QString &filename )

setCurrentItem

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

void  setCurrentItem ( const KFileItem *item )

setCurrentItem

[pure virtual]

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

KFileItemcurrentFileItem ()

currentFileItem

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

void  clear ()

clear

[virtual]

Clears the view and all item lists.

void  updateView (bool f = true)

updateView

[virtual]

does a repaint of the view.

The default implementation calls

widget()->repaint(f)

void  updateView (const KFileItem*)

updateView

[virtual]

void  removeItem (const KFileItem *item)

removeItem

[virtual]

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

void  listingCompleted ()

listingCompleted

[virtual]

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.

QDir::SortSpec  sorting ()

sorting

[const]

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

void  setSorting (QDir::SortSpec sort)

setSorting

[virtual]

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

bool  isReversed ()

isReversed

[const]

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

void  sortReversed ()

sortReversed

uint  count ()

count

[const]

Returns: the number of dirs and files

uint  numFiles ()

numFiles

[const]

Returns: the number of files.

uint  numDirs ()

numDirs

[const]

Returns: the number of directories

void  setSelectionMode ( KFile::SelectionMode sm )

setSelectionMode

[virtual]

KFile::SelectionMode  selectionMode ()

selectionMode

[const virtual]

enum ViewMode { Files = 1, Directories = 2, All = Files | Directories }

ViewMode

void  setViewMode ( ViewMode vm )

setViewMode

[virtual]

ViewMode  viewMode ()

viewMode

[const virtual]

QString  viewName ()

viewName

[const]

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

void  setViewName ( const QString& name )

setViewName

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

void  setParentView (KFileView *parent)

setParentView

[virtual]

void  insertItem ( KFileItem *i)

insertItem

[virtual]

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 );

void  clearView ()

clearView

[pure virtual]

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

void  ensureItemVisible ( const KFileItem *i )

ensureItemVisible

[pure virtual]

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

void  clearSelection ()

clearSelection

[pure virtual]

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

void  selectAll ()

selectAll

[virtual]

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.

void  invertSelection ()

invertSelection

[virtual]

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

void  setSelected (const KFileItem *, bool enable)

setSelected

[pure virtual]

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

bool  isSelected ( const KFileItem * )

isSelected

[const pure virtual]

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

const KFileItemList *  selectedItems ()

selectedItems

[const]

Returns: all currently highlighted items.

const KFileItemList *  items ()

items

[const]

Returns: all items currently available in the current sort-order

KFileItem *  firstFileItem ()

firstFileItem

[const pure virtual]

KFileItem *  nextItem ( const KFileItem * )

nextItem

[const pure virtual]

KFileItem *  prevItem ( const KFileItem * )

prevItem

[const pure virtual]

void  setOnlyDoubleClickSelectsFiles ( bool enable )

setOnlyDoubleClickSelectsFiles

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

bool  onlyDoubleClickSelectsFiles ()

onlyDoubleClickSelectsFiles

[const]

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

See also: setOnlyDoubleClickSelectsFiles

bool  updateNumbers (const KFileItem *i)

updateNumbers

increases the number of dirs and files.

Returns: true if the item fits the view mode

KActionCollection *  actionCollection ()

actionCollection

[const virtual]

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.

KFileViewSignaler *  signaler ()

signaler

[const]

void  readConfig ( KConfig *, const QString& group = QString::null )

readConfig

[virtual]

void  writeConfig ( KConfig *, const QString& group = QString::null)

writeConfig

[virtual]

QString  sortingKey ( const QString& value, bool isDir, int sortSpec)

sortingKey

[static]

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.

Parameters:
valueAny string that should be used as sort criterion
isDirTells whether the key is computed for an item representing a directory (directories are usually sorted before files)
sortSpecAn ORed combination of QDir::SortSpec flags. Currently, the values IgnoreCase, Reversed and DirsFirst are taken into account.

QString  sortingKey ( KIO::filesize_t value, bool isDir,int sortSpec)

sortingKey

[static]

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.

KFileViewSignaler * sig

sig

[protected]

void  virtual_hook ( int id, void* data )

virtual_hook

[protected virtual]

counters