|
|
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 @code widget. This should return a pointer to the implemented widget.
~KFileView () |
Destructor
void addItemList (const KFileViewItemList *list) |
inserts a list of items.
QWidget * widget () |
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 QString &filename, const KFileViewItem * entry = 0) |
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 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 () |
clears the view and all item lists
void updateView (bool f = true) |
does a repaint of the view.
The default implementation calls
widget()->repaint(f)</pre>
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
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
enum SortMode {Increasing, Decreasing, Switching } |
Increasing means greater indicies means bigger values
Decrease means greater indicies means smaller values Switching is deprecated, don't use that anymore!
void setSortMode (SortMode mode) |
set the sorting mode. Default mode is Increasing. Affects only newly added items.
SortMode sortMode () |
Returns: the current sort mode
See also: setSortMode, setSorting
void sortReversed () |
Toggles the current sort order, i.e. the order is reversed.
bool isReversed () |
Tells whether the current items are in reversed order (= contrary to sortMode).
uint count () |
Returns: the number of dirs and files
uint numFiles () |
Returns: the number of files.
uint numDirs () |
Returns: the number of directories
QString 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.
void setViewName ( const QString& name ) |
Sets the name of the view, which could be displayed somewhere. E.g. "Image Preview".
void insertItem ( KFileViewItem *i) |
The derived view must implement this function to add the file in the widget.
void clearView () |
pure virtual function, that should be implemented to clear the view. At this moment the list is already empty
void clearSelection () |
Clear any selection, unhighlight everything. Must be implemented by the view.
void selectAll () |
Selects all items. You may want to override this, if you can implement it more efficiently than calling highlightItem() with every item. This works only in Multiselection mode of course.
bool isSelected ( const KFileViewItem * ) |
Returns: whether the given item is currently selected. Must be implemented by the view.
const KFileViewItemList * selectedItems () |
Returns: all currently highlighted items.
const KFileViewItemList * items () |
Returns: all items currently available in the current sort-order
void insertSorted (KFileViewItem *first, uint counter) |
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 () |
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 highlightItem (const KFileViewItem *) |
Tells the view that it should highlight the item. This function must be implemented by the view
void select ( const KFileViewItem *entry) |
Call this method when an item is selected (depends on single click / double click configuration). Emits the appropriate signal.
void highlight ( const KFileViewItem *item) |
emits the highlighted signal for item. Call this in your subclass, whenever the selection changes.
int compareItems (const KFileViewItem *fi1, const KFileViewItem *fi2) |
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) |
this is a help function for sorting, since I can't use the libc version (because I have a variable sort function)
KFileViewSignaler * sig |
class to distribute the signals
void setFirstItem ( KFileViewItem * item ) |
Call this method to set the first item after you call your own insertSorted(). You only need to call it when you override insertSorted().