KFileWidget

#include <KFileWidget>

Inheritance diagram for KFileWidget:

Public Types

enum  OperationMode { Other = 0, Opening, Saving }
 
- Public Types inherited from QWidget
enum  RenderFlag
 
- Public Types inherited from QPaintDevice
enum  PaintDeviceMetric
 

Signals

void accepted ()
 
void fileHighlighted (const QUrl &)
 
void fileSelected (const QUrl &)
 
void filterChanged (const QString &filter)
 
void selectionChanged ()
 

Public Slots

void accept ()
 
void slotCancel ()
 
void slotOk ()
 

Public Member Functions

 KFileWidget (const QUrl &startDir, QWidget *parent=nullptr)
 
 ~KFileWidget () override
 
KActionCollectionactionCollection () const
 
QUrl baseUrl () const
 
QPushButtoncancelButton () const
 
void clearFilter ()
 
QString currentFilter () const
 
QMimeType currentFilterMimeType ()
 
QString currentMimeFilter () const
 
QSize dialogSizeHint () const
 
KDirOperatordirOperator ()
 
KFileFilterCombofilterWidget () const
 
bool keepsLocation () const
 
KUrlComboBoxlocationEdit () const
 
KFile::Modes mode () const
 
QPushButtonokButton () const
 
OperationMode operationMode () const
 
void readConfig (KConfigGroup &group)
 
QString selectedFile () const
 
QStringList selectedFiles () const
 
QUrl selectedUrl () const
 
QList< QUrlselectedUrls () const
 
void setConfirmOverwrite (bool enable)
 
void setCustomWidget (QWidget *widget)
 
void setCustomWidget (const QString &text, QWidget *widget)
 
void setFilter (const QString &filter)
 
void setInlinePreviewShown (bool show)
 
void setKeepLocation (bool keep)
 
void setLocationLabel (const QString &text)
 
void setMimeFilter (const QStringList &types, const QString &defaultType=QString())
 
void setMode (KFile::Modes m)
 
void setOperationMode (OperationMode)
 
void setPreviewWidget (KPreviewWidgetBase *w)
 
void setSelectedUrl (const QUrl &url)
 
void setSelection (const QString &pathOrUrl)
 
void setSupportedSchemes (const QStringList &schemes)
 
void setUrl (const QUrl &url, bool clearforward=true)
 
void setViewMode (KFile::FileView mode)
 
QSize sizeHint () const override
 
QStringList supportedSchemes () const
 
KToolBartoolBar () const
 
- Public Member Functions inherited from QWidget
 QWidget (QWidget *parent, Qt::WindowFlags f)
 
bool acceptDrops () const const
 
QString accessibleDescription () const const
 
QString accessibleName () const const
 
QList< QAction * > actions () const const
 
void activateWindow ()
 
void addAction (QAction *action)
 
void addActions (QList< QAction * > actions)
 
void adjustSize ()
 
bool autoFillBackground () const const
 
QPalette::ColorRole backgroundRole () const const
 
QBackingStorebackingStore () const const
 
QSize baseSize () const const
 
QWidgetchildAt (int x, int y) const const
 
QWidgetchildAt (const QPoint &p) const const
 
QRect childrenRect () const const
 
QRegion childrenRegion () const const
 
void clearFocus ()
 
void clearMask ()
 
bool close ()
 
QMargins contentsMargins () const const
 
QRect contentsRect () const const
 
Qt::ContextMenuPolicy contextMenuPolicy () const const
 
QCursor cursor () const const
 
void customContextMenuRequested (const QPoint &pos)
 
WId effectiveWinId () const const
 
void ensurePolished () const const
 
Qt::FocusPolicy focusPolicy () const const
 
QWidgetfocusProxy () const const
 
QWidgetfocusWidget () const const
 
const QFontfont () const const
 
QFontInfo fontInfo () const const
 
QFontMetrics fontMetrics () const const
 
QPalette::ColorRole foregroundRole () const const
 
QRect frameGeometry () const const
 
QSize frameSize () const const
 
const QRectgeometry () const const
 
void getContentsMargins (int *left, int *top, int *right, int *bottom) const const
 
QPixmap grab (const QRect &rectangle)
 
void grabGesture (Qt::GestureType gesture, Qt::GestureFlags flags)
 
void grabKeyboard ()
 
void grabMouse ()
 
void grabMouse (const QCursor &cursor)
 
int grabShortcut (const QKeySequence &key, Qt::ShortcutContext context)
 
QGraphicsEffectgraphicsEffect () const const
 
QGraphicsProxyWidgetgraphicsProxyWidget () const const
 
bool hasEditFocus () const const
 
bool hasFocus () const const
 
virtual bool hasHeightForWidth () const const
 
bool hasMouseTracking () const const
 
bool hasTabletTracking () const const
 
int height () const const
 
virtual int heightForWidth (int w) const const
 
void hide ()
 
Qt::InputMethodHints inputMethodHints () const const
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const const
 
void insertAction (QAction *before, QAction *action)
 
void insertActions (QAction *before, QList< QAction * > actions)
 
bool isActiveWindow () const const
 
bool isAncestorOf (const QWidget *child) const const
 
bool isEnabled () const const
 
bool isEnabledTo (const QWidget *ancestor) const const
 
bool isEnabledToTLW () const const
 
bool isFullScreen () const const
 
bool isHidden () const const
 
bool isMaximized () const const
 
bool isMinimized () const const
 
bool isModal () const const
 
bool isTopLevel () const const
 
bool isVisible () const const
 
bool isVisibleTo (const QWidget *ancestor) const const
 
bool isWindow () const const
 
bool isWindowModified () const const
 
QLayoutlayout () const const
 
Qt::LayoutDirection layoutDirection () const const
 
QLocale locale () const const
 
void lower ()
 
QPoint mapFrom (const QWidget *parent, const QPoint &pos) const const
 
QPoint mapFromGlobal (const QPoint &pos) const const
 
QPoint mapFromParent (const QPoint &pos) const const
 
QPoint mapTo (const QWidget *parent, const QPoint &pos) const const
 
QPoint mapToGlobal (const QPoint &pos) const const
 
QPoint mapToParent (const QPoint &pos) const const
 
QRegion mask () const const
 
int maximumHeight () const const
 
QSize maximumSize () const const
 
int maximumWidth () const const
 
int minimumHeight () const const
 
QSize minimumSize () const const
 
virtual QSize minimumSizeHint () const const
 
int minimumWidth () const const
 
void move (int x, int y)
 
void move (const QPoint &)
 
QWidgetnativeParentWidget () const const
 
QWidgetnextInFocusChain () const const
 
QRect normalGeometry () const const
 
void overrideWindowFlags (Qt::WindowFlags flags)
 
virtual QPaintEnginepaintEngine () const const override
 
const QPalettepalette () const const
 
QWidgetparentWidget () const const
 
QPoint pos () const const
 
QWidgetpreviousInFocusChain () const const
 
 QWIDGETSIZE_MAX QWIDGETSIZE_MAX
 
void raise ()
 
QRect rect () const const
 
void releaseKeyboard ()
 
void releaseMouse ()
 
void releaseShortcut (int id)
 
void removeAction (QAction *action)
 
void render (QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags)
 
void render (QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags)
 
void repaint ()
 
void repaint (int x, int y, int w, int h)
 
void repaint (const QRect &rect)
 
void repaint (const QRegion &rgn)
 
void resize (int w, int h)
 
void resize (const QSize &)
 
bool restoreGeometry (const QByteArray &geometry)
 
QByteArray saveGeometry () const const
 
QScreenscreen () const const
 
void scroll (int dx, int dy)
 
void scroll (int dx, int dy, const QRect &r)
 
void setAcceptDrops (bool on)
 
void setAccessibleDescription (const QString &description)
 
void setAccessibleName (const QString &name)
 
void setAttribute (Qt::WidgetAttribute attribute, bool on)
 
void setAutoFillBackground (bool enabled)
 
void setBackgroundRole (QPalette::ColorRole role)
 
void setBaseSize (int basew, int baseh)
 
void setBaseSize (const QSize &)
 
void setContentsMargins (const QMargins &margins)
 
void setContentsMargins (int left, int top, int right, int bottom)
 
void setContextMenuPolicy (Qt::ContextMenuPolicy policy)
 
void setCursor (const QCursor &)
 
void setDisabled (bool disable)
 
void setEditFocus (bool enable)
 
void setEnabled (bool)
 
void setFixedHeight (int h)
 
void setFixedSize (const QSize &s)
 
void setFixedSize (int w, int h)
 
void setFixedWidth (int w)
 
void setFocus (Qt::FocusReason reason)
 
void setFocus ()
 
void setFocusPolicy (Qt::FocusPolicy policy)
 
void setFocusProxy (QWidget *w)
 
void setFont (const QFont &)
 
void setForegroundRole (QPalette::ColorRole role)
 
void setGeometry (const QRect &)
 
void setGeometry (int x, int y, int w, int h)
 
void setGraphicsEffect (QGraphicsEffect *effect)
 
void setHidden (bool hidden)
 
void setInputMethodHints (Qt::InputMethodHints hints)
 
void setLayout (QLayout *layout)
 
void setLayoutDirection (Qt::LayoutDirection direction)
 
void setLocale (const QLocale &locale)
 
void setMask (const QBitmap &bitmap)
 
void setMask (const QRegion &region)
 
void setMaximumHeight (int maxh)
 
void setMaximumSize (int maxw, int maxh)
 
void setMaximumSize (const QSize &)
 
void setMaximumWidth (int maxw)
 
void setMinimumHeight (int minh)
 
void setMinimumSize (const QSize &)
 
void setMinimumSize (int minw, int minh)
 
void setMinimumWidth (int minw)
 
void setMouseTracking (bool enable)
 
void setPalette (const QPalette &)
 
void setParent (QWidget *parent, Qt::WindowFlags f)
 
void setParent (QWidget *parent)
 
void setShortcutAutoRepeat (int id, bool enable)
 
void setShortcutEnabled (int id, bool enable)
 
void setSizeIncrement (const QSize &)
 
void setSizeIncrement (int w, int h)
 
void setSizePolicy (QSizePolicy)
 
void setSizePolicy (QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical)
 
void setStatusTip (const QString &)
 
void setStyle (QStyle *style)
 
void setStyleSheet (const QString &styleSheet)
 
void setTabletTracking (bool enable)
 
void setToolTip (const QString &)
 
void setToolTipDuration (int msec)
 
void setUpdatesEnabled (bool enable)
 
void setupUi (QWidget *widget)
 
virtual void setVisible (bool visible)
 
void setWhatsThis (const QString &)
 
void setWindowFilePath (const QString &filePath)
 
void setWindowFlag (Qt::WindowType flag, bool on)
 
void setWindowFlags (Qt::WindowFlags type)
 
void setWindowIcon (const QIcon &icon)
 
void setWindowIconText (const QString &)
 
void setWindowModality (Qt::WindowModality windowModality)
 
void setWindowModified (bool)
 
void setWindowOpacity (qreal level)
 
void setWindowRole (const QString &role)
 
void setWindowState (Qt::WindowStates windowState)
 
void setWindowTitle (const QString &)
 
void show ()
 
void showFullScreen ()
 
void showMaximized ()
 
void showMinimized ()
 
void showNormal ()
 
QSize size () const const
 
QSize sizeIncrement () const const
 
QSizePolicy sizePolicy () const const
 
void stackUnder (QWidget *w)
 
QString statusTip () const const
 
QStylestyle () const const
 
QString styleSheet () const const
 
bool testAttribute (Qt::WidgetAttribute attribute) const const
 
QString toolTip () const const
 
int toolTipDuration () const const
 
QWidgettopLevelWidget () const const
 
bool underMouse () const const
 
void ungrabGesture (Qt::GestureType gesture)
 
void unsetCursor ()
 
void unsetLayoutDirection ()
 
void unsetLocale ()
 
void update (int x, int y, int w, int h)
 
void update (const QRect &rect)
 
void update (const QRegion &rgn)
 
void update ()
 
void updateGeometry ()
 
bool updatesEnabled () const const
 
QRegion visibleRegion () const const
 
QString whatsThis () const const
 
int width () const const
 
QWidgetwindow () const const
 
QString windowFilePath () const const
 
Qt::WindowFlags windowFlags () const const
 
QWindowwindowHandle () const const
 
QIcon windowIcon () const const
 
void windowIconChanged (const QIcon &icon)
 
QString windowIconText () const const
 
void windowIconTextChanged (const QString &iconText)
 
Qt::WindowModality windowModality () const const
 
qreal windowOpacity () const const
 
QString windowRole () const const
 
Qt::WindowStates windowState () const const
 
QString windowTitle () const const
 
void windowTitleChanged (const QString &title)
 
Qt::WindowType windowType () const const
 
WId winId () const const
 
int x () const const
 
int y () const const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
qobject_cast (QObject *object)
 
qobject_cast (const QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 
- Public Member Functions inherited from QPaintDevice
int colorCount () const const
 
int depth () const const
 
int devicePixelRatio () const const
 
qreal devicePixelRatioF () const const
 
int height () const const
 
int heightMM () const const
 
int logicalDpiX () const const
 
int logicalDpiY () const const
 
bool paintingActive () const const
 
int physicalDpiX () const const
 
int physicalDpiY () const const
 
int width () const const
 
int widthMM () const const
 

Static Public Member Functions

static QUrl getStartUrl (const QUrl &startDir, QString &recentDirClass)
 
static QUrl getStartUrl (const QUrl &startDir, QString &recentDirClass, QString &fileName)
 
static void setStartDir (const QUrl &directory)
 
- Static Public Member Functions inherited from QWidget
QWidgetcreateWindowContainer (QWindow *window, QWidget *parent, Qt::WindowFlags flags)
 
QWidgetfind (WId id)
 
QWidgetkeyboardGrabber ()
 
QWidgetmouseGrabber ()
 
void setTabOrder (QWidget *first, QWidget *second)
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 

Protected Member Functions

bool eventFilter (QObject *watched, QEvent *event) override
 
void resizeEvent (QResizeEvent *event) override
 
void showEvent (QShowEvent *event) override
 
- Protected Member Functions inherited from QWidget
virtual void actionEvent (QActionEvent *event)
 
virtual void changeEvent (QEvent *event)
 
virtual void closeEvent (QCloseEvent *event)
 
virtual void contextMenuEvent (QContextMenuEvent *event)
 
void create (WId window, bool initializeWindow, bool destroyOldWindow)
 
void destroy (bool destroyWindow, bool destroySubWindows)
 
virtual void dragEnterEvent (QDragEnterEvent *event)
 
virtual void dragLeaveEvent (QDragLeaveEvent *event)
 
virtual void dragMoveEvent (QDragMoveEvent *event)
 
virtual void dropEvent (QDropEvent *event)
 
virtual void enterEvent (QEvent *event)
 
virtual bool event (QEvent *event) override
 
virtual void focusInEvent (QFocusEvent *event)
 
bool focusNextChild ()
 
virtual bool focusNextPrevChild (bool next)
 
virtual void focusOutEvent (QFocusEvent *event)
 
bool focusPreviousChild ()
 
virtual void hideEvent (QHideEvent *event)
 
virtual void initPainter (QPainter *painter) const const override
 
virtual void inputMethodEvent (QInputMethodEvent *event)
 
virtual void keyPressEvent (QKeyEvent *event)
 
virtual void keyReleaseEvent (QKeyEvent *event)
 
virtual void leaveEvent (QEvent *event)
 
virtual int metric (QPaintDevice::PaintDeviceMetric m) const const override
 
virtual void mouseDoubleClickEvent (QMouseEvent *event)
 
virtual void mouseMoveEvent (QMouseEvent *event)
 
virtual void mousePressEvent (QMouseEvent *event)
 
virtual void mouseReleaseEvent (QMouseEvent *event)
 
virtual void moveEvent (QMoveEvent *event)
 
virtual bool nativeEvent (const QByteArray &eventType, void *message, long *result)
 
virtual void paintEvent (QPaintEvent *event)
 
virtual void tabletEvent (QTabletEvent *event)
 
void updateMicroFocus ()
 
virtual void wheelEvent (QWheelEvent *event)
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Additional Inherited Members

- Properties inherited from QWidget
 acceptDrops
 
 accessibleDescription
 
 accessibleName
 
 autoFillBackground
 
 baseSize
 
 childrenRect
 
 childrenRegion
 
 contextMenuPolicy
 
 cursor
 
 enabled
 
 focus
 
 focusPolicy
 
 font
 
 frameGeometry
 
 frameSize
 
 fullScreen
 
 geometry
 
 height
 
 inputMethodHints
 
 isActiveWindow
 
 layoutDirection
 
 locale
 
 maximized
 
 maximumHeight
 
 maximumSize
 
 maximumWidth
 
 minimized
 
 minimumHeight
 
 minimumSize
 
 minimumSizeHint
 
 minimumWidth
 
 modal
 
 mouseTracking
 
 normalGeometry
 
 palette
 
 pos
 
 rect
 
 size
 
 sizeHint
 
 sizeIncrement
 
 sizePolicy
 
 statusTip
 
 styleSheet
 
 tabletTracking
 
 toolTip
 
 toolTipDuration
 
 updatesEnabled
 
 visible
 
 whatsThis
 
 width
 
 windowFilePath
 
 windowFlags
 
 windowIcon
 
 windowIconText
 
 windowModality
 
 windowModified
 
 windowOpacity
 
 windowTitle
 
 x
 
 y
 
- Properties inherited from QObject
 objectName
 
- Public Attributes inherited from QWidget
 DrawChildren
 
 DrawWindowBackground
 
 IgnoreMask
 
typedef RenderFlags
 
- Public Attributes inherited from QObject
typedef QObjectList
 
- Public Attributes inherited from QPaintDevice
 PdmDepth
 
 PdmDevicePixelRatio
 
 PdmDevicePixelRatioScaled
 
 PdmDpiX
 
 PdmDpiY
 
 PdmHeight
 
 PdmHeightMM
 
 PdmNumColors
 
 PdmPhysicalDpiX
 
 PdmPhysicalDpiY
 
 PdmWidth
 
 PdmWidthMM
 

Detailed Description

File selector widget.

This is the contents of the KDE file dialog, without the actual QDialog around it. It can be embedded directly into applications.

Definition at line 57 of file kfilewidget.h.

Member Enumeration Documentation

Defines some default behavior of the filedialog.

E.g. in mode Opening and Saving, the selected files/urls will be added to the "recent documents" list. The Saving mode also implies setKeepLocation() being set.

Other means that no default actions are performed.

See also
setOperationMode
operationMode

Definition at line 109 of file kfilewidget.h.

Constructor & Destructor Documentation

KFileWidget::KFileWidget ( const QUrl startDir,
QWidget parent = nullptr 
)
explicit

Constructs a file selector widget.

Parameters
startDirThis can either be:
  • An empty URL (QUrl()) to start in the current working directory, or the last directory where a file has been selected.
  • The path or URL of a starting directory.
  • An initial file name to select, with the starting directory being the current working directory or the last directory where a file has been selected.
  • The path or URL of a file, specifying both the starting directory and an initially selected file name.
  • A URL of the form kfiledialog:///<keyword> to start in the directory last used by a filedialog in the same application that specified the same keyword.
  • A URL of the form kfiledialog:///<keyword>/<filename> to start in the directory last used by a filedialog in the same application that specified the same keyword, and to initially select the specified filename.
  • A URL of the form kfiledialog:///<keyword>?global to start in the directory last used by a filedialog in any application that specified the same keyword.
  • A URL of the form kfiledialog:///<keyword>/<filename>?global to start in the directory last used by a filedialog in any application that specified the same keyword, and to initially select the specified filename.
parentThe parent widget of this widget

Definition at line 353 of file kfilewidget.cpp.

KFileWidget::~KFileWidget ( )
override

Destructor.

Definition at line 640 of file kfilewidget.cpp.

Member Function Documentation

void KFileWidget::accepted ( )
signal

Emitted by slotOk() (directly or asynchronously) once everything has been done.

Should be used by the caller to call accept().

KActionCollection * KFileWidget::actionCollection ( ) const
Returns
a pointer to the action collection, holding all the used KActions.

Definition at line 2568 of file kfilewidget.cpp.

QUrl KFileWidget::baseUrl ( ) const
Returns
the currently shown directory.

Definition at line 1786 of file kfilewidget.cpp.

QPushButton * KFileWidget::cancelButton ( ) const
Returns
a pointer to the Cancel-Button in the filedialog. Note that the button is hidden and unconnected when using KFileWidget alone; KFileDialog shows it and connects to it.

Definition at line 1994 of file kfilewidget.cpp.

void KFileWidget::clearFilter ( )

Clears any mime- or namefilter.

Does not reload the directory.

Definition at line 714 of file kfilewidget.cpp.

QString KFileWidget::currentFilter ( ) const

Returns the current filter as entered by the user or one of the predefined set via setFilter().

See also
setFilter()
filterChanged()

Definition at line 688 of file kfilewidget.cpp.

QMimeType KFileWidget::currentFilterMimeType ( )

Returns the mimetype for the desired output format.

This is only valid if setFilterMimeType() has been called previously.

See also
setFilterMimeType()

Definition at line 734 of file kfilewidget.cpp.

QString KFileWidget::currentMimeFilter ( ) const

The mimetype for the desired output format.

This is only valid if setMimeFilter() has been called previously.

See also
setMimeFilter()

Definition at line 724 of file kfilewidget.cpp.

QSize KFileWidget::dialogSizeHint ( ) const

Provides a size hint, useful for dialogs that embed the widget.

Returns
a QSize, calculated to be optimal for a dialog.
Since
5.0

Definition at line 2895 of file kfilewidget.cpp.

KDirOperator * KFileWidget::dirOperator ( )
Returns
the KDirOperator used to navigate the filesystem
Since
4.3

Definition at line 2839 of file kfilewidget.cpp.

void KFileWidget::fileHighlighted ( const QUrl )
signal

Emitted when the user highlights a file.

Since
4.4
void KFileWidget::fileSelected ( const QUrl )
signal

Emitted when the user selects a file.

It is only emitted in single- selection mode. The best way to get notified about selected file(s) is to connect to the okClicked() signal inherited from KDialog and call selectedFile(), selectedFiles(), selectedUrl() or selectedUrls().

Since
4.4
void KFileWidget::filterChanged ( const QString filter)
signal

Emitted when the filter changed, i.e.

the user entered an own filter or chose one of the predefined set via setFilter().

Parameters
filtercontains the new filter (only the extension part, not the explanation), i.e. "*.cpp" or "*.cpp *.cc".
See also
setFilter()
currentFilter()
KFileFilterCombo * KFileWidget::filterWidget ( ) const
Returns
the combobox that contains the filters

Definition at line 2563 of file kfilewidget.cpp.

QUrl KFileWidget::getStartUrl ( const QUrl startDir,
QString recentDirClass 
)
static

This method implements the logic to determine the user's default directory to be listed.

E.g. the documents directory, home directory or a recently used directory.

Parameters
startDirA URL specifying the initial directory, or using the kfiledialog:/// syntax to specify a last used directory. If this URL specifies a file name, it is ignored. Refer to the KFileWidget::KFileWidget() documentation for the kfiledialog:/// URL syntax.
recentDirClassIf the kfiledialog:/// syntax is used, this will return the string to be passed to KRecentDirs::dir() and KRecentDirs::add().
Returns
The URL that should be listed by default (e.g. by KFileDialog or KDirSelectDialog).
See also
KFileWidget::KFileWidget()

Definition at line 2652 of file kfilewidget.cpp.

QUrl KFileWidget::getStartUrl ( const QUrl startDir,
QString recentDirClass,
QString fileName 
)
static

Similar to getStartUrl(const QUrl& startDir,QString& recentDirClass), but allows both the recent start directory keyword and a suggested file name to be returned.

Parameters
startDirA URL specifying the initial directory and/or filename, or using the kfiledialog:/// syntax to specify a last used location. Refer to the KFileWidget::KFileWidget() documentation for the kfiledialog:/// URL syntax.
recentDirClassIf the kfiledialog:/// syntax is used, this will return the string to be passed to KRecentDirs::dir() and KRecentDirs::add().
fileNameThe suggested file name, if specified as part of the StartDir URL.
Returns
The URL that should be listed by default (e.g. by KFileDialog or KDirSelectDialog).
See also
KFileWidget::KFileWidget()
Since
4.3

Definition at line 2660 of file kfilewidget.cpp.

bool KFileWidget::keepsLocation ( ) const
Returns
whether the contents of the location edit are kept when changing directories.

Definition at line 2011 of file kfilewidget.cpp.

KUrlComboBox * KFileWidget::locationEdit ( ) const
Returns
the combobox used to type the filename or full location of the file.

Definition at line 2558 of file kfilewidget.cpp.

KFile::Modes KFileWidget::mode ( ) const

Returns the mode of the filedialog.

See also
setMode()

Definition at line 1869 of file kfilewidget.cpp.

QPushButton * KFileWidget::okButton ( ) const
Returns
a pointer to the OK-Button in the filedialog. Note that the button is hidden and unconnected when using KFileWidget alone; KFileDialog shows it and connects to it.

Definition at line 1989 of file kfilewidget.cpp.

KFileWidget::OperationMode KFileWidget::operationMode ( ) const
Returns
the current operation mode, Opening, Saving or Other. Default is Other.
See also
operationMode
KFileWidget::OperationMode

Definition at line 2044 of file kfilewidget.cpp.

void KFileWidget::readConfig ( KConfigGroup group)

reads the configuration for this widget from the given config group

Parameters
groupthe KConfigGroup to read from
Since
4.4

Definition at line 2844 of file kfilewidget.cpp.

QString KFileWidget::selectedFile ( ) const

Returns the full path of the selected file in the local filesystem.

(Local files only)

Definition at line 1740 of file kfilewidget.cpp.

QStringList KFileWidget::selectedFiles ( ) const

Returns a list of all selected local files.

Definition at line 1757 of file kfilewidget.cpp.

QUrl KFileWidget::selectedUrl ( ) const
Returns
The selected fully qualified filename.

Definition at line 1651 of file kfilewidget.cpp.

QList< QUrl > KFileWidget::selectedUrls ( ) const
Returns
The list of selected URLs.

Definition at line 1662 of file kfilewidget.cpp.

void KFileWidget::selectionChanged ( )
signal

Emitted when the user highlights one or more files in multiselection mode.

Note: fileHighlighted() or fileSelected() are not emitted in multiselection mode. You may use selectedItems() to ask for the current highlighted items.

See also
fileSelected
void KFileWidget::setConfirmOverwrite ( bool  enable)

Sets whether the user should be asked for confirmation when an overwrite might occur.

Parameters
enableSet this to true to enable checking.
Since
4.2

Definition at line 2885 of file kfilewidget.cpp.

void KFileWidget::setCustomWidget ( QWidget widget)

Set a custom widget that should be added to the file dialog.

Parameters
widgetA widget, or a widget of widgets, for displaying custom data in the file widget. This can be used, for example, to display a check box with the caption "Open as read-only". When creating this widget, you don't need to specify a parent, since the widget's parent will be set automatically by KFileWidget.

Definition at line 2806 of file kfilewidget.cpp.

void KFileWidget::setCustomWidget ( const QString text,
QWidget widget 
)

Sets a custom widget that should be added below the location and the filter editors.

Parameters
textLabel of the custom widget, which is displayed below the labels "Location:" and "Filter:".
widgetAny kind of widget, but preferable a combo box or a line editor to be compliant with the location and filter layout. When creating this widget, you don't need to specify a parent, since the widget's parent will be set automatically by KFileWidget.

Definition at line 2828 of file kfilewidget.cpp.

void KFileWidget::setFilter ( const QString filter)

Sets the filter to be used to filter.

You can set more filters for the user to select separated by '
'. Every filter entry is defined through namefilter|text to display. If no | is found in the expression, just the namefilter is shown. Examples:

kfile->setFilter("*.cpp|C++ Source Files\n*.h|Header files");
kfile->setFilter("*.cpp");
kfile->setFilter("*.cpp|Sources (*.cpp)");
kfile->setFilter("*.cpp|" + i18n("Sources (*.cpp)"));
kfile->setFilter("*.cpp *.cc *.C|C++ Source Files\n*.h *.H|Header files");

Note: The text to display is not parsed in any way. So, if you want to show the suffix to select by a specific filter, you must repeat it.

If the filter contains an unescaped '/', a mimetype-filter is assumed. If you would like a '/' visible in your filter it can be escaped with a '\'. You can specify multiple mimetypes like this (separated with space):

kfile->setFilter( "image/png text/html text/plain" );
kfile->setFilter( "*.cue|CUE\\/BIN Files (*.cue)" );
See also
filterChanged
setMimeFilter

Definition at line 653 of file kfilewidget.cpp.

void KFileWidget::setInlinePreviewShown ( bool  show)

Forces the inline previews to be shown or hidden, depending on show.

Parameters
showWhether to show inline previews or not.
Since
4.2

Definition at line 2890 of file kfilewidget.cpp.

void KFileWidget::setKeepLocation ( bool  keep)

Sets whether the filename/url should be kept when changing directories.

This is for example useful when having a predefined filename where the full path for that file is searched.

This is implicitly set when operationMode() is KFileWidget::Saving

getSaveFileName() and getSaveUrl() set this to true by default, so that you can type in the filename and change the directory without having to type the name again.

Definition at line 2006 of file kfilewidget.cpp.

void KFileWidget::setLocationLabel ( const QString text)

Sets the text to be displayed in front of the selection.

The default is "Location". Most useful if you want to make clear what the location is used for.

Definition at line 648 of file kfilewidget.cpp.

void KFileWidget::setMimeFilter ( const QStringList types,
const QString defaultType = QString() 
)

Sets the filter up to specify the output type.

Parameters
typesa list of mimetypes that can be used as output format
defaultTypethe default mimetype to use as output format, if any. If defaultType is set, it will be set as the current item. Otherwise, a first item showing all the mimetypes will be created. Typically, defaultType should be empty for loading and set for saving.

Do not use in conjunction with setFilter()

Definition at line 693 of file kfilewidget.cpp.

void KFileWidget::setMode ( KFile::Modes  m)

Sets the mode of the dialog.

The mode is defined as (in kfile.h):

enum Mode {
File = 1,
Directory = 2,
Files = 4,
ExistingOnly = 8,
LocalOnly = 16
};

You can OR the values, e.g.

KFile::Modes mode = KFile::Files |
KFile::ExistingOnly |
KFile::LocalOnly );
setMode( mode );

Definition at line 1855 of file kfilewidget.cpp.

void KFileWidget::setOperationMode ( OperationMode  mode)

Sets the operational mode of the filedialog to Saving, Opening or Other.

This will set some flags that are specific to loading or saving files. E.g. setKeepLocation() makes mostly sense for a save-as dialog. So setOperationMode( KFileWidget::Saving ); sets setKeepLocation for example.

The mode Saving, together with a default filter set via setMimeFilter() will make the filter combobox read-only.

The default mode is Opening.

Call this method right after instantiating KFileWidget.

See also
operationMode
KFileWidget::OperationMode

Definition at line 2016 of file kfilewidget.cpp.

void KFileWidget::setPreviewWidget ( KPreviewWidgetBase w)

Adds a preview widget and enters the preview mode.

In this mode the dialog is split and the right part contains your preview widget.

Ownership is transferred to KFileWidget. You need to create the preview-widget with "new", i.e. on the heap.

Parameters
wThe widget to be used for the preview.

Definition at line 740 of file kfilewidget.cpp.

void KFileWidget::setSelectedUrl ( const QUrl url)

Sets the URL to preselect to url.

This method handles absolute URLs (remember to use fromLocalFile for local paths). It also handles relative URLs, which you should construct like this: QUrl relativeUrl; relativeUrl.setPath(fileName);

Since
5.33

Definition at line 1588 of file kfilewidget.cpp.

void KFileWidget::setSelection ( const QString pathOrUrl)

Sets the file to preselect to pathOrUrl.

This method handles absolute paths (on Unix, but probably not correctly on Windows) and absolute URLs as strings (but for those you should use setSelectedUrl instead).

This method does not work with relative paths (filenames) (it would misinterpret a ':' or a '#' in the filename).

Deprecated:
since 5.33, use setSelectedUrl instead, after ensuring that construct the QUrl correctly (e.g. use fromLocalFile for local paths).

Definition at line 1569 of file kfilewidget.cpp.

void KFileWidget::setStartDir ( const QUrl directory)
static

Used by KDirSelectDialog to share the dialog's start directory.

Definition at line 2744 of file kfilewidget.cpp.

void KFileWidget::setSupportedSchemes ( const QStringList schemes)

Set the URL schemes that the file widget should allow navigating to.

If the returned list is empty, all schemes are supported.

See also
QFileDialog::setSupportedSchemes
Since
5.43

Definition at line 2911 of file kfilewidget.cpp.

void KFileWidget::setUrl ( const QUrl url,
bool  clearforward = true 
)

Sets the directory to view.

Parameters
urlURL to show.
clearforwardIndicates whether the forward queue should be cleared.

Definition at line 1469 of file kfilewidget.cpp.

void KFileWidget::setViewMode ( KFile::FileView  mode)

Sets how the view should be displayed.

See also
KFile::FileView
Since
5.0

Definition at line 2905 of file kfilewidget.cpp.

QSize KFileWidget::sizeHint ( void  ) const
overridevirtual

Reimplemented.

Reimplemented from QWidget.

Definition at line 776 of file kfilewidget.cpp.

void KFileWidget::slotOk ( )
slot

Called when clicking ok (when this widget is used in KFileDialog) Might or might not call accept().

Logic of the next part of code (ends at "end multi relative urls").

We allow for instance to be at "/" and insert '"home/foo/bar.txt" "boot/grub/menu.lst"'. Why we need to support this ? Because we provide tree views, which aren't plain.

Now, how does this logic work. It will get the first element on the list (with no filename), following the previous example say "/home/foo" and set it as the top most url.

After this, it will iterate over the rest of items and check if this URL (topmost url) contains the url being iterated.

As you might have guessed it will do "/home/foo" against "/boot/grub" (again stripping filename), and a false will be returned. Then we upUrl the top most url, resulting in "/home" against "/boot/grub", what will again return false, so we upUrl again. Now we have "/" against "/boot/grub", what returns true for us, so we can say that the closest common ancestor of both is "/".

This example has been written for 2 urls, but this works for any number of urls.

end multi relative urls

Definition at line 789 of file kfilewidget.cpp.

QStringList KFileWidget::supportedSchemes ( ) const

Returns the URL schemes that the file widget should allow navigating to.

If the returned list is empty, all schemes are supported. Examples for schemes are "file" or "ftp".

See also
QFileDialog::supportedSchemes
Since
5.43

Definition at line 2918 of file kfilewidget.cpp.

KToolBar * KFileWidget::toolBar ( ) const

Returns a pointer to the toolbar.

Deprecated:
since 5.66 due to no known users and leaking KXMLGui into the API.

Definition at line 2800 of file kfilewidget.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Aug 7 2020 22:58:58 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.