KDirOperator Class Reference
from PyKDE4.kio import *
Detailed Description
Method Documentation
Constructs the KDirOperator with no initial view. As the views are configurable, call readConfig() to load the user's configuration and then setView to explicitly set a view.
This constructor doesn't start loading the url, setView will do it.
KActionCollection actionCollection | ( | self ) |
an accessor to a collection of all available Actions. The actions are static, they will be there all the time (no need to connect to the signals KActionCollection.inserted() or removed().
There are the following actions:
The short and detailed view are in an exclusive group. The sort-by actions are in an exclusive group as well. Also the "separate dirs", "preview" and "single" actions are in an exclusive group.
You can e.g. use
actionCollection()->action( "up" )->plug( someToolBar );to add a button into a toolbar, which makes the dirOperator change to its parent directory.
- Returns:
- all available Actions
Called upon right-click to activate the popupmenu.
back | ( | self ) |
Goes one step back in the history and opens that url.
cdUp | ( | self ) |
Goes one directory up from the current url.
changeEvent | ( | self, | ||
QEvent | event | |||
) |
bool checkPreviewSupport | ( | self ) |
Checks if there support from KIO.PreviewJob for the currently shown files, taking mimeFilter() and nameFilter() into account Enables/disables the preview-action accordingly.
clearFilter | ( | self ) |
Clears both the namefilter and mimetype filter, so that all files and directories will be shown. Call updateDir() to apply it.
- See also:
- setMimeFilter
- See also:
- setNameFilter
clearHistory | ( | self ) |
Clears the forward and backward history.
close | ( | self ) |
Stops loading immediately. You don't need to call this, usually.
completion | ( | self, | ||
QString | a0 | |||
) |
- Signal syntax:
QObject.connect(source, SIGNAL("completion(const QString&)"), target_slot)
KCompletion completionObject | ( | self ) |
- Returns:
- a KCompletion object, containing all filenames and directories of the current directory/URL. You can use it to insert it into a KLineEdit or KComboBox Note: it will only contain files, after prepareCompletionObjects() has been called. It will be implicitly called from makeCompletion() or makeDirCompletion()
Emitted just before the context menu is shown, allows users to extend the menu with custom actions.
- Parameters:
-
item the file on which the context menu was invoked menu the context menu, pre-populated with the file-management actions
- Since:
- 4.2
- Signal syntax:
QObject.connect(source, SIGNAL("contextMenuAboutToShow(const KFileItem&, QMenu*)"), target_slot)
QAbstractItemView createView | ( | self, | ||
QWidget | parent, | |||
KFile.FileView | viewKind | |||
) |
A view factory for creating predefined fileviews. Called internally by setView, but you can also call it directly. Reimplement this if you depend on self defined fileviews.
- Parameters:
-
parent is the QWidget to be set as parent viewKind is the predefined view to be set, note: this can be several ones OR:ed together
- Returns:
- the created view
- See also:
- KFile.FileView
- See also:
- setView
currentIconSizeChanged | ( | self, | ||
int | size | |||
) |
Will notify that the icon size has changed. Since we save the icon size depending on the view type (list view or a different kind of view), a call to setView() can trigger this signal to be emitted.
- Since:
- 4.2
- Signal syntax:
QObject.connect(source, SIGNAL("currentIconSizeChanged(int)"), target_slot)
QStyleOptionViewItem.Position decorationPosition | ( | self ) |
Returns the position where icons are shown relative to the labels of file items in the icon view.
- Since:
- 4.2.3
KIO.DeleteJob del_ | ( | self, | ||
KFileItemList | items, | |||
QWidget | parent=0, | |||
bool | ask=1, | |||
bool | showProgress=1 | |||
) |
Starts and returns a KIO.DeleteJob to delete the given items.
- Parameters:
-
items the list of items to be deleted parent the parent widget used for the confirmation dialog ask specifies whether a confirmation dialog should be shown showProgress passed to the DeleteJob to show a progress dialog
deleteSelected | ( | self ) |
Deletes the currently selected files/directories.
dirActivated | ( | self, | ||
KFileItem | item | |||
) |
- Signal syntax:
QObject.connect(source, SIGNAL("dirActivated(const KFileItem&)"), target_slot)
KCompletion dirCompletionObject | ( | self ) |
- Returns:
- a KCompletion object, containing only all directories of the current directory/URL. You can use it to insert it into a KLineEdit or KComboBox Note: it will only contain directories, after prepareCompletionObjects() has been called. It will be implicitly called from makeCompletion() or makeDirCompletion()
bool dirHighlighting | ( | self ) |
- Returns:
- whether the last directory will be made the current item when going up in the directory hierarchy.
Default is false.
KDirLister dirLister | ( | self ) |
- Returns:
- the object listing the directory
bool dirOnlyMode | ( | self ) |
- Returns:
- true if we are in directory-only mode, that is, no files are shown.
bool dirOnlyMode | ( | long | mode | |
) |
dropped | ( | self, | ||
KFileItem | item, | |||
QDropEvent | event, | |||
KUrl.List | urls | |||
) |
Emitted when files are dropped. Dropping files is disabled by default. You need to enable it with setAcceptDrops()
- Parameters:
-
item the item on which the drop occurred or 0. event the drop event itself. urls the urls that where dropped.
- Signal syntax:
QObject.connect(source, SIGNAL("dropped(const KFileItem&, QDropEvent*, const List&)"), target_slot)
fileHighlighted | ( | self, | ||
KFileItem | item | |||
) |
Emitted when a file is highlighted or generally the selection changes in multiselection mode. In the latter case, item is 0. You can access the selected items with selectedItems().
- Signal syntax:
QObject.connect(source, SIGNAL("fileHighlighted(const KFileItem&)"), target_slot)
fileSelected | ( | self, | ||
KFileItem | item | |||
) |
- Signal syntax:
QObject.connect(source, SIGNAL("fileSelected(const KFileItem&)"), target_slot)
finishedLoading | ( | self ) |
- Signal syntax:
QObject.connect(source, SIGNAL("finishedLoading()"), target_slot)
forward | ( | self ) |
Goes one step forward in the history and opens that url.
highlightFile | ( | self, | ||
KFileItem | item | |||
) |
Emits fileHighlighted(item)
home | ( | self ) |
Enters the home directory.
int iconsZoom | ( | self ) |
Returns the icon zoom.
- Since:
- 4.2
bool isInlinePreviewShown | ( | self ) |
Returns whether the inline previews are shown or not.
- Since:
- 4.2
bool isRoot | ( | self ) |
- Returns:
- true if we are displaying the root directory of the current url
bool isSaving | ( | self ) |
Returns whether KDirOperator will force a double click to accept.
- Note:
- this is false by default
- Since:
- 4.2
bool isSelected | ( | self, | ||
KFileItem | item | |||
) |
- Returns:
- true if item is currently selected, or false otherwise.
Tries to complete the given string (only completes files).
Tries to complete the given string (only completes directores).
QStringList mimeFilter | ( | self ) |
- Returns:
- the current mime filter.
bool mkdir | ( | self, | ||
QString | directory, | |||
bool | enterDirectory=1 | |||
) |
Creates the given directory/url. If it is a relative path, it will be completed with the current directory. If enterDirectory is true, the directory will be entered after a successful operation. If unsuccessful, a messagebox will be presented to the user.
- Returns:
- true if the directory could be created.
mkdir | ( | self ) |
Opens a dialog to create a new directory.
KFile.Modes mode | ( | self ) |
- Returns:
- the listing/selection mode.
QString nameFilter | ( | self ) |
- Returns:
- the current namefilter.
- See also:
- setNameFilter
int numDirs | ( | self ) |
- Returns:
- the number of directories in the currently listed url. Returns 0 if there is no view.
int numFiles | ( | self ) |
- Returns:
- the number of files in the currently listed url. Returns 0 if there is no view.
bool onlyDoubleClickSelectsFiles | ( | self ) |
- Returns:
- whether files (not directories) should only be select()ed by double-clicks.
- See also:
- setOnlyDoubleClickSelectsFiles
pathChanged | ( | self ) |
Called after setUrl() to load the directory, update the history, etc.
prepareCompletionObjects | ( | self ) |
Synchronizes the completion objects with the entries of the currently listed url.
Automatically called from makeCompletion() and makeDirCompletion()
KFilePreviewGenerator previewGenerator | ( | self ) |
Returns the preview generator for the current view.
- Since:
- 4.2
QProgressBar progressBar | ( | self ) |
- Returns:
- the progress widget, that is shown during directory listing. You can for example reparent() it to put it into a statusbar.
readConfig | ( | self, | ||
KConfigGroup | configGroup | |||
) |
Reads the default settings for a view, i.e. the default KFile.FileView. Also reads the sorting and whether hidden files should be shown. Note: the default view will not be set - you have to call
setView( KFile.Default )to apply it.
- See also:
- setView
- See also:
- setViewConfig
- See also:
- writeConfig
rereadDir | ( | self ) |
Re-reads the current url.
resetCursor | ( | self ) |
Restores the normal cursor after showing the busy-cursor. Also hides the progressbar.
resizeEvent | ( | self, | ||
QResizeEvent | event | |||
) |
selectDir | ( | self, | ||
KFileItem | item | |||
) |
Enters the directory specified by the given item.
selectFile | ( | self, | ||
KFileItem | item | |||
) |
Emits fileSelected( item )
KFileItemList selectedItems | ( | self ) |
- Returns:
- a list of all currently selected items. If there is no view, or there are no selected items, an empty list is returned.
setAcceptDrops | ( | self, | ||
bool | b | |||
) |
Reimplemented - allow dropping of files if b is true
- Parameters:
-
b true if the widget should allow dropping of files
setCurrentItem | ( | self, | ||
QString | url | |||
) |
Clears the current selection and attempts to set url the current url file. Note that urls can be relative or absolute.
setCurrentItem | ( | self, | ||
KFileItem | item | |||
) |
Clears the current selection and attempts to set item as the current item.
setCurrentItems | ( | self, | ||
QStringList | urls | |||
) |
Clears the current selection and attempts to set urls the current url files. Note that urls can be relative or absolute.
- Since:
- 4.2
setCurrentItems | ( | self, | ||
KFileItemList | items | |||
) |
Clears the current selection and attempts to set items as the current items.
- Since:
- 4.2
setDecorationPosition | ( | self, | ||
QStyleOptionViewItem.Position | position | |||
) |
Sets the position where icons shall be shown relative to the labels of file items in the icon view.
- Since:
- 4.2.3
setDirLister | ( | self, | ||
KDirLister | lister | |||
) |
Sets a custom KDirLister to list directories. The KDirOperator takes ownership of the given KDirLister.
setDropOptions | ( | self, | ||
int | options | |||
) |
Sets the options for dropping files. CURRENTLY NOT IMPLEMENTED
setEnableDirHighlighting | ( | self, | ||
bool | enable | |||
) |
When going up in the directory hierarchy, KDirOperator can highlight the directory that was just left.
I.e. when you go from /home/gis/src to /home/gis, the item "src" will be made the current item.
Default is off.
setIconsZoom | ( | self, | ||
int | value | |||
) |
Notifies that the icons size should change. value is an int ranged from 0 to 100. 100 means KIconLoader.SizeEnormous.
- Since:
- 4.2
setInlinePreviewShown | ( | self, | ||
bool | show | |||
) |
Forces the inline previews to be shown or hidden, depending on show.
- Parameters:
-
show Whether to show inline previews or not.
- Since:
- 4.2
setIsSaving | ( | self, | ||
bool | isSaving | |||
) |
If the system is set up to trigger items on single click, if isSaving is true, we will force to double click to accept.
- Note:
- this is false by default
- Since:
- 4.2
setMimeFilter | ( | self, | ||
QStringList | mimetypes | |||
) |
Sets a list of mimetypes as filter. Only files of those mimetypes will be shown.
Example:
QStringList filter; filter << "text/html" << "image/png" << "inode/directory"; dirOperator->setMimefilter( filter );
Node: Without the mimetype inode/directory, only files would be shown. Call updateDir() to apply it.
- See also:
- KDirLister.setMimeFilter
- See also:
- mimeFilter
setMode | ( | self, | ||
KFile.Modes | m | |||
) |
Sets the listing/selection mode for the views, an OR'ed combination of
You cannot mix File and Files of course, as the former means single-selection mode, the latter multi-selection.
setNameFilter | ( | self, | ||
QString | filter | |||
) |
Sets a filter like "*.cpp *.h *.o". Only files matching that filter will be shown.
- See also:
- KDirLister.setNameFilter
- See also:
- nameFilter
setOnlyDoubleClickSelectsFiles | ( | self, | ||
bool | enable | |||
) |
This toggles between double/single click file and directory selection mode. When argument is true, files and directories are highlighted with single click and selected (executed) with double click.
The default follows the signle/double click system setting.
setPreviewWidget | ( | self, | ||
KPreviewWidgetBase | w | |||
) |
Sets a preview-widget to be shown next to the file-view. The ownership of w is transferred to KDirOperator, so don't delete it yourself!
setShowHiddenFiles | ( | self, | ||
bool | s | |||
) |
Enables/disables showing hidden files.
setSorting | ( | self, | ||
QDir.SortFlags | a0 | |||
) |
Sets the way to sort files and directories.
setUrl | ( | self, | ||
KUrl | url, | |||
bool | clearforward | |||
) |
Sets a new url to list.
- Parameters:
-
clearforward specifies whether the "forward" history should be cleared. url the URL to set
setView | ( | self, | ||
QAbstractItemView | view | |||
) |
Sets a new view to be used for showing and browsing files. Note: this will read the current url() to fill the view.
- See also:
- KFileTreeView
- See also:
- view
setView | ( | self, | ||
KFile.FileView | viewKind | |||
) |
Sets one of the predefined fileviews.
- See also:
- KFile.FileView
setViewConfig | ( | self, | ||
KConfigGroup | configGroup | |||
) |
Sets the config object and the to be used group in KDirOperator. This will be used to store the view's configuration. If you don't set this, the views cannot save and restore their configuration.
Usually you call this right after KDirOperator creation so that the view instantiation can make use of it already.
Note that KDirOperator does NOT take ownership of that object (typically it's KGlobal.config() anyway.
You must not delete the KConfig or KConfigGroup object (and master config object) before either deleting the KDirOperator or calling setViewConfig(0); or something like that
- See also:
- viewConfig
- See also:
- viewConfigGroup
setupActions | ( | self ) |
Sets up all the actions. Called from the constructor, you usually better not call this.
setupMenu | ( | self, | ||
int | whichActions | |||
) |
Sets up the action menu.
- Parameters:
-
whichActions is an value of OR'd ActionTypes that controls which actions to show in the action menu
setupMenu | ( | self ) |
Sets up the context-menu with all the necessary actions. Called from the constructor, you usually don't need to call this.
bool showHiddenFiles | ( | self ) |
- Returns:
- true when hidden files are shown or false otherwise.
slotCompletionMatch | ( | self, | ||
QString | match | |||
) |
Tries to make the given match as current item in the view and emits completion( match )
sortByDate | ( | self ) |
Changes sorting to sort by date
sortByName | ( | self ) |
Changes sorting to sort by name
sortBySize | ( | self ) |
Changes sorting to sort by size
sortByType | ( | self ) |
Changes sorting to sort by date
sortReversed | ( | self ) |
Changes sorting to reverse sorting
QDir.SortFlags sorting | ( | self ) |
- Returns:
- the current way of sorting files and directories
toggleDirsFirst | ( | self ) |
Toggles showing directories first / having them sorted like files.
toggleIgnoreCase | ( | self ) |
Toggles case sensitive / case insensitive sorting
KIO.CopyJob trash | ( | self, | ||
KFileItemList | items, | |||
QWidget | parent, | |||
bool | ask=1, | |||
bool | showProgress=1 | |||
) |
Starts and returns a KIO.CopyJob to trash the given items.
- Parameters:
-
items the list of items to be trashed parent the parent widget used for the confirmation dialog ask specifies whether a confirmation dialog should be shown showProgress passed to the CopyJob to show a progress dialog
trashSelected | ( | self ) |
Trashes the currently selected files/directories.
This function used to take activation reason and keyboard modifiers, in order to call deleteSelected() if the user wanted to delete. Instead, call deleteSelected().
FIXME KAction Port: link deleteSelected() up correctly
updateDir | ( | self ) |
to update the view after changing the settings
updateInformation | ( | self, | ||
int | files, | |||
int | dirs | |||
) |
- Signal syntax:
QObject.connect(source, SIGNAL("updateInformation(int, int)"), target_slot)
updateSelectionDependentActions | ( | self ) |
Enables/disables actions that are selection dependent. Call this e.g. when you are about to show a popup menu using some of KDirOperators actions.
updateSortActions | ( | self ) |
Updates the sorting-related actions to comply with the current sorting
- See also:
- sorting
updateViewActions | ( | self ) |
Updates the view-related actions to comply with the current KFile.FileView
KUrl url | ( | self ) |
- Returns:
- the current url
urlEntered | ( | self, | ||
KUrl | a0 | |||
) |
- Signal syntax:
QObject.connect(source, SIGNAL("urlEntered(const KUrl&)"), target_slot)
QAbstractItemView view | ( | self ) |
- Returns:
- the currently used view.
- See also:
- setView
viewChanged | ( | self, | ||
QAbstractItemView | newView | |||
) |
Emitted whenever the current fileview is changed, either by an explicit call to setView() or by the user selecting a different view thru the GUI.
- Signal syntax:
QObject.connect(source, SIGNAL("viewChanged(QAbstractItemView*)"), target_slot)
KConfigGroup viewConfigGroup | ( | self ) |
KFile.FileView viewKind | ( | self ) |
- Returns:
- the currently used view kind
- See also:
- setView
- Since:
- 4.3
writeConfig | ( | self, | ||
KConfigGroup | configGroup | |||
) |
Saves the current settings like sorting, simple or detailed view.
- See also:
- readConfig
- See also:
- setViewConfig
Enumeration Documentation
ActionType |
The various action types. These values can be or'd together
- Enumerator:
-
SortActions = 1 ViewActions = 2 NavActions = 4 FileActions = 8 AllActions = 15