# class KFileView | A base class for views of the KDE file selector. More...
Contains pure virtuals
Definition | `#include <kfileview.h>`
Inherited by | KCombiView, KFileDetailView, KFileIconView, KFilePreview
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Types

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

#### Public Methods

- KFileView ()
- virtual ~KFileView ()
- virtual void addItemList (const KFileViewItemList &list)
- void addItemList ( const KFileItemList& list )
- virtual QWidget * widget ()
- QWidget * widget () const
- virtual void setCurrentItem (const QString &filename, const KFileViewItem * entry = 0)
- virtual void clear ()
- virtual void updateView (bool f = true)
- virtual void updateView (const KFileViewItem*)
- virtual void removeItem (const KFileViewItem *item)
- QDir::SortSpec sorting () const
- virtual void setSorting (QDir::SortSpec sort)
- void setSortMode (KFile::SortMode mode)
- KFile::SortMode sortMode () const
- virtual void sortReversed ()
- bool isReversed () const
- uint count () const
- uint numFiles () const
- uint numDirs () const
- virtual void setSelectionMode ( KFile::SelectionMode sm )
- virtual KFile::SelectionMode selectionMode () const
- virtual void setViewMode ( ViewMode vm )
- virtual ViewMode viewMode () const
- QString viewName ()
- void setViewName ( const QString& name )
- virtual void setOperator (QObject *ops)
- virtual void insertItem ( KFileViewItem *i)
- virtual void clearView ()
- virtual void ensureItemVisible ( const KFileViewItem *i )
- virtual void clearSelection ()
- virtual void selectAll ()
- virtual void invertSelection ()
- virtual void setSelected (const KFileViewItem *, bool enable)
- virtual bool isSelected ( const KFileViewItem * ) const
- const KFileViewItemList * selectedItems () const
- const KFileViewItemList * items () const
- virtual void insertSorted (KFileViewItem *tfirst, uint counter)
- KFileViewItem * firstItem () const
- void setOnlyDoubleClickSelectsFiles ( bool enable )
- bool onlyDoubleClickSelectsFiles () const
- bool updateNumbers (const KFileViewItem *i)

#### Protected Methods

- void select ( const KFileViewItem *item )
- void highlight ( const KFileViewItem *item)
- int compareItems (const KFileViewItem *fi1, const KFileViewItem *fi2) const
- void QuickSort (KFileViewItem* a[], int lo0, int hi0) const
- KFileViewItem * mergeLists (KFileViewItem *list1, KFileViewItem *list2)
- void activateMenu ( const KFileViewItem *i )
- void setFirstItem ( KFileViewItem * item )
- void resort ()

#### Protected Members

- KFileViewSignaler *sig

## Detailed Description

A base class for views of the KDE file selector

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]

void addItemList (const KFileViewItemList &list) | ### addItemList

[virtual]

inserts a list of items.

void addItemList ( const KFileItemList& list ) | ### addItemList

Inserts a list of items. Use this method <b>only</b> if you are sure that the list really contains KFileViewItems or items subclassing KFileViewItem. You can use KDirLister to create a KFileItemList with any item, subclassing KFileItem. E.g. KFileReader creates KFileViewItems

See also: createFileItem

QWidget * widget () | ### 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.

QWidget * widget () | ### widget

[const]

As const-method, to be fixed in 3.0

void setCurrentItem (const QString &filename, const KFileViewItem * entry = 0) | ### setCurrentItem

[virtual]

set the current item in the view.

the normal use of this function is to use the parameter filename to set the highlight on this file.

the extend use of this function is to set filename to 0. In this case the KFileViewItem is used to find out the position of the file. Since this is faster, this way is used in case a view has other child views.

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)</pre>

void updateView (const KFileViewItem*) | ### updateView

[virtual]

void removeItem (const KFileViewItem *item) | ### removeItem

[virtual]

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

QDir::SortSpec sorting () | ### sorting

[const]

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

void setSorting (QDir::SortSpec sort) | ### setSorting

[virtual]

set the sorting of the view

Default is QDir::Name | QDir::IgnoreCase | QDir::DirsFirst Don't use QDir::Reversed, use sortReversed() if you want to reverse the sort order. Calling this method keeps the reversed-setting If your view wants to get notified about sorting-changes (e.g. to show a sorting indicator), override this method and call this implementation in the beginning of your method.

See also: setSortMode

void setSortMode (KFile::SortMode mode) | ### setSortMode

set the sorting mode. Default mode is Increasing. Affects only newly added items.

See also: setSorting

KFile::SortMode sortMode () | ### sortMode

[const]

Returns: the current sort mode

See also: setSortMode, setSorting

void sortReversed () | ### sortReversed

[virtual]

Toggles the current sort order, i.e. the order is reversed.

See also: isReversed

bool isReversed () | ### isReversed

[const]

Tells whether the current items are in reversed order (= contrary to sortMode).

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

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 setOperator (QObject *ops) | ### setOperator

[virtual]

void insertItem ( KFileViewItem *i) | ### insertItem

[pure virtual]

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

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 KFileViewItem *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]

Clear any selection, unhighlight 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 KFileViewItem *, 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 KFileViewItem * ) | ### isSelected

[const pure virtual]

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

const KFileViewItemList * selectedItems () | ### selectedItems

[const]

Returns: all currently highlighted items.

const KFileViewItemList * items () | ### items

[const]

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

void insertSorted (KFileViewItem *tfirst, uint counter) | ### insertSorted

[virtual]

Inserts "counter" KFileViewItems and sorts them conforming to the current sort-order. If you override this method, you have to call setFirstItem() afterwards, to set the first item of your newly sorted items.

KFileViewItem * firstItem () | ### firstItem

[const]

Returns: the first (depending on sort order) item. It forms sort of a list, as each item holds a pointer to the next item. This is only public for internal reasons, DON'T call it unless you implement a View yourself and really need to.

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 KFileViewItem *i) | ### updateNumbers

increases the number of dirs and files.

Returns: true if the item fits the view mode

void select ( const KFileViewItem *item ) | ### select

[protected]

Call this method when an item is selected (depends on single click / double click configuration). Emits the appropriate signal.

void highlight ( const KFileViewItem *item) | ### highlight

[protected]

emits the highlighted signal for item. Call this in your subclass, whenever the selection changes.

int compareItems (const KFileViewItem *fi1, const KFileViewItem *fi2) | ### compareItems

[protected const]

compares two items in the current context (sortMode and others) returns -1, if i1 is before i2 and 1, if the other case is true in case, both are equal (in current context), the behaviour is undefined!

void QuickSort (KFileViewItem* a[], int lo0, int hi0) | ### QuickSort

[protected const]

this is a help function for sorting, since I can't use the libc version (because I have a variable sort function)

KFileViewItem * mergeLists (KFileViewItem *list1, KFileViewItem *list2) | ### mergeLists

[protected]

void activateMenu ( const KFileViewItem *i ) | ### activateMenu

[protected]

KFileViewSignaler * sig | ### sig

[protected]

void setFirstItem ( KFileViewItem * item ) | ### setFirstItem

[protected]

Call this method to set the first item after you call your own insertSorted(). You only need to call it when you override insertSorted().

void resort () | ### resort

[protected]

Call this if you changed the sort order and want to perform the actual sorting and show the new items.

- Version: $Id: kfileview.h,v 1.24 2001/02/04 22:21:48 pfeiffer Exp $
- Author: Stephan Kulow <coolo@kde.org>
- Generated: root@sparc.ports.openbsd.org on Wed May 2 09:42:26 2001, using kdoc 2.0a53.