class KFileInfoContents

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

Contains pure virtuals
Definition#include <kfileinfocontents.h>
Inherited byKCombiView, KDirListBox, KFileDetailList, KFilePreview, KFileSimpleView
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Protected Types

Protected Methods

Protected Members


Detailed Description

A base class for views of the KDE file selector

This class defines an interface to all file views. It's 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 @code widget. This should return a pointer to the implemented widget.

 KFileInfoContents ( bool useSingleClick, QDir::SortSpec sorting )

Parameters:
useSingleClickdefines, if the view should react on single click or double click
sortingdefines, how the list should be sorted. Currently Name, Size and Date are supported.

KFileInfoContents ()

[virtual]

Destructor

bool  addItem (const KFileInfo *item)

[virtual]

Insert an item into the file view. The view will just maintain the pointer. It doesn't free the object.

This functions inserts the file at the correct place in the sorted list

Parameters:
itemthe file to be inserted

Returns: true, if a repaint is necessary

void  addItemList (const KFileInfoList *list)

[virtual]

inserts a list of items. This is an speed optimized version of function above.

const char * text (uint index)

[const virtual]

the meaning of index depends on the sorting and the other files in the view. So use this function with care.

Returns: the name of the file at position index.

QWidgetwidget ()

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

void  setCurrentItem (const char *filename, const KFileInfo * entry = 0)

[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 @see KFileInfo 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  setAutoUpdate (bool f)

[pure virtual]

set the autoUpdate flag for the specific widget. if set to false, no repaints should be done automaticly unless repaint is called.

this function is pure virtual, so it must be implemented

void  clear ()

clears all lists and calls clearView

void  repaint (bool f = true)

[virtual]

does a repaint of the view.

The default implementation calls <code>widget()->repaint(f)</code>

QDir::SortSpec  sorting ()

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

void  setSorting (QDir::SortSpec sort)

set the sorting of the view. If the sorting is the same as the current value and sortMode is Switching, it switches the order in the list.

Default is QDir::Name

uint  count ()

[const]

returns the number of added files

void  connectDirSelected ( QObject *receiver, const char *member)

to connect a slot to the internal signal, that is emited, if the user selects a directory.

the connected slot must have the form

member(KFileInfo*)</pre>

void  connectFileHighlighted ( QObject *receiver, const char *member)

to connect a slot to the internal signal, that is emited, if the user highlights a file.

the connected slot must have the form

member(KFileInfo*)</pre>

void  connectFileSelected ( QObject *receiver, const char *member)

to connect a slot to the internal signal, that is emited, if the user selects a file.

the connected slot must have the form

member(KFileInfo*)</pre>

uint  numFiles ()

[const]

the number of files.

uint  numDirs ()

[const]

the number of directories

QString  findCompletion ( const char *base, bool activateFound = false )

[virtual]

tries to find a completed filename, that starts with base

if it fails, it returns a null string.

Parameters:
activateFoundif true, the file should select the found file (or directory)

bool  acceptsFiles ()

[pure virtual]

a pure virtual function to indicate, if the view should list files.

bool  acceptsDirs ()

[pure virtual]

a pure virtual function to indicate, if the view should list directories.

bool  insertItem (const KFileInfo *i, int index)

[protected pure virtual]

this function is called after the class found out the correct index. The derived view must implement this function to add the file in the widget.

it's important, that the view keeps it's contents consistent with the indicies in the sorted list of the base class

Returns: true, if a repaint is necessary

bool  addItemInternal (const KFileInfo *)

[protected]

this function does the actual sorting. It is called by addItem and calls itself insertItem

enum SortMode {Increasing, Decreasing, Switching }

[protected]

Increasing means greater indicies means bigger values

Decrease means greater indicies means smaller values

Switching means, that it should switch between Increasing and Decreasing

void  setSortMode (SortMode mode)

[protected]

set the sorting mode. Default mode is Increasing

void  clearView ()

[protected pure virtual]

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

void  highlightItem (unsigned int index)

[protected pure virtual]

set the highlighted item to index. This function must be implemented by the view

static QPixmap * file_pixmap

[protected]

the pixmap for normal files

static QPixmap * locked_file

[protected]

the pixmap for locked files

static QPixmap * folder_pixmap

[protected]

the pixmap for normal folders

static QPixmap * locked_folder

[protected]

the pixmap for locked folders

void  select ( KFileInfo *entry)

[protected]

sets the value for the selected file and emits the correct signal (depending on the type of the entry)

void  select ( int index )

[protected]

gets the entry at index and calls the other select function with it

bool  useSingle ()

[protected const]

returns, if the view is using single click to activate directories Note, that some views do not work completly with single click

bool  isDir ( uint index)

[protected const]

returns true, if the file at the specific position is a directory

const KFileInfoat ( uint index )

[protected const]

returns the complete file information for the file at the position index

int  compareItems (const KFileInfo *fi1, const KFileInfo *fi2)

[protected]

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 (KFileInfo* a[], int lo0, int hi0)

[protected]

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

I heard, STL has a qsort function too, but I don't want to use STL now