org.kde.koala
Class KFileView

java.lang.Object
  extended by org.kde.koala.KFileView
All Implemented Interfaces:
KFileViewInterface, org.kde.qt.QtSupport

public class KFileView
extends java.lang.Object
implements org.kde.qt.QtSupport, KFileViewInterface

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

Author:
Stephan Kulow

Field Summary
static int All
           
static int AutoOpenDirs
          Various options for drag and drop support.
static int Directories
           
static int Files
           
static int VIRTUAL_SET_DROP_OPTIONS
           
 
Constructor Summary
protected KFileView(java.lang.Class dummy)
           
 
Method Summary
 KActionCollection actionCollection()
           
 void addItemList(java.util.ArrayList list)
          inserts a list of items.
static int autoOpenDelay()
          delay before auto opening a directory
 void clear()
          Clears the view and all item lists.
 void clearSelection()
          Clears any selection, unhighlights everything.
 void clearView()
          pure function, that should be implemented to clear the view.
 int count()
           
 KFileItem currentFileItem()
           
 int dropOptions()
          Returns the DND options in effect.
 void ensureItemVisible(KFileItem i)
          pure function, that should be implemented to make item i visible, i.e.
 KFileItem firstFileItem()
           
 void insertItem(KFileItem i)
          The derived view must implement this function to add the file in the widget.
 void invertSelection()
          Inverts the current selection, i.e.
 boolean isReversed()
          Tells whether the current items are in reversed order (shortcut to sorting() & QDir.Reversed).
 boolean isSelected(KFileItem arg1)
           
 java.util.ArrayList items()
           
 void listingCompleted()
          This hook is called when all items of the currently listed directory are listed and inserted into the view, i.e.
 KFileItem nextItem(KFileItem arg1)
           
 int numDirs()
           
 int numFiles()
           
 boolean onlyDoubleClickSelectsFiles()
           
 KFileItem prevItem(KFileItem arg1)
           
 void readConfig(KConfig arg1)
           
 void readConfig(KConfig arg1, java.lang.String group)
           
 void removeItem(KFileItem item)
          Removes an item from the list; has to be implemented by the view.
 void selectAll()
          Selects all items.
 java.util.ArrayList selectedItems()
           
 void setCurrentItem(KFileItem item)
          Reimplement this to set item the current item in the view, e.g.
 void setCurrentItem(java.lang.String filename)
          Sets filename the current item in the view, if available.
 void setDropOptions(int options)
          Specify DND options.
 void setOnlyDoubleClickSelectsFiles(boolean enable)
          This is a KFileDialog specific hack: we want to select directories with single click, but not files.
 void setParentView(KFileViewInterface parent)
           
 void setSelected(KFileItem arg1, boolean enable)
          Tells the view that it should highlight the item.
 void setSelectionMode(int sm)
           
 void setSorting(int sort)
          Sets the sorting order of the view.
 void setViewMode(int vm)
           
 void setViewName(java.lang.String name)
          Sets the name of the view, which could be displayed somewhere.
 KFileViewSignaler signaler()
           
 int sorting()
          Returns the sorting order of the internal list.
static java.lang.String sortingKey(long value, boolean isDir, int sortSpec)
          An overloaded method that takes not a String, but a number as sort criterion.
static java.lang.String sortingKey(java.lang.String value, boolean isDir, int sortSpec)
          This method calculates a String from the given parameters, that is suitable for sorting with e.g.
 void sortReversed()
           
 boolean updateNumbers(KFileItem i)
          increases the number of dirs and files.
 void updateView()
           
 void updateView(boolean f)
          does a repaint of the view.
 void updateView(KFileItem arg1)
           
 int viewMode()
           
 java.lang.String viewName()
           
 org.kde.qt.QWidget widget()
          a pure function to get a QWidget, that can be added to other widgets.
 void writeConfig(KConfig arg1)
           
 void writeConfig(KConfig arg1, java.lang.String group)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VIRTUAL_SET_DROP_OPTIONS

public static final int VIRTUAL_SET_DROP_OPTIONS
See Also:
Constant Field Values

Files

public static final int Files
See Also:
Constant Field Values

Directories

public static final int Directories
See Also:
Constant Field Values

All

public static final int All
See Also:
Constant Field Values

AutoOpenDirs

public static final int AutoOpenDirs
Various options for drag and drop support. These values can be or'd together.
  • AutoOpenDirs Automatically open directory after hovering above it for a short while while dragging.
  • See Also:
    Constant Field Values
    Constructor Detail

    KFileView

    protected KFileView(java.lang.Class dummy)
    Method Detail

    addItemList

    public void addItemList(java.util.ArrayList list)
    inserts a list of items.

    Specified by:
    addItemList in interface KFileViewInterface

    widget

    public org.kde.qt.QWidget widget()
    a pure 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.

    Specified by:
    widget in interface KFileViewInterface

    setCurrentItem

    public void setCurrentItem(java.lang.String filename)
    Sets filename the current item in the view, if available.

    Specified by:
    setCurrentItem in interface KFileViewInterface

    setCurrentItem

    public void setCurrentItem(KFileItem item)
    Reimplement this to set item the current item in the view, e.g. the item having focus.

    Specified by:
    setCurrentItem in interface KFileViewInterface

    currentFileItem

    public KFileItem currentFileItem()
    Specified by:
    currentFileItem in interface KFileViewInterface
    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.

    clear

    public void clear()
    Clears the view and all item lists.

    Specified by:
    clear in interface KFileViewInterface

    updateView

    public void updateView(boolean f)
    does a repaint of the view. The default implementation calls
                     widget().repaint(f)
                     

    Specified by:
    updateView in interface KFileViewInterface

    updateView

    public void updateView()
    Specified by:
    updateView in interface KFileViewInterface

    updateView

    public void updateView(KFileItem arg1)
    Specified by:
    updateView in interface KFileViewInterface

    removeItem

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

    Specified by:
    removeItem in interface KFileViewInterface

    listingCompleted

    public void listingCompleted()
    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.

    Specified by:
    listingCompleted in interface KFileViewInterface

    sorting

    public int sorting()
    Returns the sorting order of the internal list. Newly added files are added through this sorting.

    Specified by:
    sorting in interface KFileViewInterface

    setSorting

    public void setSorting(int sort)
    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.

    Specified by:
    setSorting in interface KFileViewInterface
    See Also:
    sortingKey(java.lang.String, boolean, int)

    isReversed

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

    Specified by:
    isReversed in interface KFileViewInterface

    sortReversed

    public void sortReversed()
    Specified by:
    sortReversed in interface KFileViewInterface

    count

    public int count()
    Specified by:
    count in interface KFileViewInterface
    Returns:
    the number of dirs and files

    numFiles

    public int numFiles()
    Specified by:
    numFiles in interface KFileViewInterface
    Returns:
    the number of files.

    numDirs

    public int numDirs()
    Specified by:
    numDirs in interface KFileViewInterface
    Returns:
    the number of directories

    setSelectionMode

    public void setSelectionMode(int sm)
    Specified by:
    setSelectionMode in interface KFileViewInterface

    setViewMode

    public void setViewMode(int vm)
    Specified by:
    setViewMode in interface KFileViewInterface

    viewMode

    public int viewMode()
    Specified by:
    viewMode in interface KFileViewInterface

    viewName

    public java.lang.String viewName()
    Specified by:
    viewName in interface KFileViewInterface
    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(java.lang.String)

    setViewName

    public void setViewName(java.lang.String name)
    Sets the name of the view, which could be displayed somewhere. E.g. "Image Preview".

    Specified by:
    setViewName in interface KFileViewInterface

    setParentView

    public void setParentView(KFileViewInterface parent)
    Specified by:
    setParentView in interface KFileViewInterface

    insertItem

    public void insertItem(KFileItem i)
    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 );

    Specified by:
    insertItem in interface KFileViewInterface

    clearView

    public void clearView()
    pure function, that should be implemented to clear the view. At this moment the list is already empty

    Specified by:
    clearView in interface KFileViewInterface

    ensureItemVisible

    public void ensureItemVisible(KFileItem i)
    pure function, that should be implemented to make item i visible, i.e. by scrolling the view appropriately.

    Specified by:
    ensureItemVisible in interface KFileViewInterface

    clearSelection

    public void clearSelection()
    Clears any selection, unhighlights everything. Must be implemented by the view.

    Specified by:
    clearSelection in interface KFileViewInterface

    selectAll

    public void selectAll()
    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.

    Specified by:
    selectAll in interface KFileViewInterface

    invertSelection

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

    Specified by:
    invertSelection in interface KFileViewInterface

    setSelected

    public void setSelected(KFileItem arg1,
                            boolean enable)
    Tells the view that it should highlight the item. This function must be implemented by the view.

    Specified by:
    setSelected in interface KFileViewInterface

    isSelected

    public boolean isSelected(KFileItem arg1)
    Specified by:
    isSelected in interface KFileViewInterface
    Returns:
    whether the given item is currently selected. Must be implemented by the view.

    selectedItems

    public java.util.ArrayList selectedItems()
    Specified by:
    selectedItems in interface KFileViewInterface
    Returns:
    all currently highlighted items.

    items

    public java.util.ArrayList items()
    Specified by:
    items in interface KFileViewInterface
    Returns:
    all items currently available in the current sort-order

    firstFileItem

    public KFileItem firstFileItem()
    Specified by:
    firstFileItem in interface KFileViewInterface

    nextItem

    public KFileItem nextItem(KFileItem arg1)
    Specified by:
    nextItem in interface KFileViewInterface

    prevItem

    public KFileItem prevItem(KFileItem arg1)
    Specified by:
    prevItem in interface KFileViewInterface

    setOnlyDoubleClickSelectsFiles

    public void setOnlyDoubleClickSelectsFiles(boolean enable)
    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().

    Specified by:
    setOnlyDoubleClickSelectsFiles in interface KFileViewInterface

    onlyDoubleClickSelectsFiles

    public boolean onlyDoubleClickSelectsFiles()
    Specified by:
    onlyDoubleClickSelectsFiles in interface KFileViewInterface
    Returns:
    whether files (not directories) should only be select()ed by double-clicks.
    See Also:
    setOnlyDoubleClickSelectsFiles(boolean)

    updateNumbers

    public boolean updateNumbers(KFileItem i)
    increases the number of dirs and files.

    Specified by:
    updateNumbers in interface KFileViewInterface
    Returns:
    true if the item fits the view mode

    actionCollection

    public KActionCollection actionCollection()
    Specified by:
    actionCollection in interface KFileViewInterface
    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.

    signaler

    public KFileViewSignaler signaler()
    Specified by:
    signaler in interface KFileViewInterface

    readConfig

    public void readConfig(KConfig arg1,
                           java.lang.String group)
    Specified by:
    readConfig in interface KFileViewInterface

    readConfig

    public void readConfig(KConfig arg1)
    Specified by:
    readConfig in interface KFileViewInterface

    writeConfig

    public void writeConfig(KConfig arg1,
                            java.lang.String group)
    Specified by:
    writeConfig in interface KFileViewInterface

    writeConfig

    public void writeConfig(KConfig arg1)
    Specified by:
    writeConfig in interface KFileViewInterface

    setDropOptions

    public void setDropOptions(int options)
    Specify DND options. See DropOptions for details. All options are disabled by default.

    Specified by:
    setDropOptions in interface KFileViewInterface

    dropOptions

    public int dropOptions()
    Returns the DND options in effect. See DropOptions for details.

    Specified by:
    dropOptions in interface KFileViewInterface

    sortingKey

    public static java.lang.String sortingKey(java.lang.String value,
                                              boolean isDir,
                                              int sortSpec)
    This method calculates a String from the given parameters, that is suitable for sorting with e.g. QIconView or QListView. Their Item-classes usually have a setKey( String ) method or a virtual method String key() that is used for sorting.

    Parameters:
    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)
    sortSpec - An ORed combination of QDir.SortSpec flags. Currently, the values IgnoreCase, Reversed and DirsFirst are taken into account.

    sortingKey

    public static java.lang.String sortingKey(long value,
                                              boolean isDir,
                                              int sortSpec)
    An overloaded method that takes not a String, 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.


    autoOpenDelay

    public static int autoOpenDelay()
    delay before auto opening a directory