Pages
API Documentation
On this page

KUrlCompletion Class

Completion of a single URL. More...

  • Header: #include <KUrlCompletion>
  • CMake: find_package(KF6 REQUIRED COMPONENTS KIO)
    target_link_libraries(mytarget PRIVATE KF6::KIOWidgets)
  • Inherited By: KShellCompletion

List of all members, including inherited members

Public Types

Public Functions

Detailed Description

This class does completion of URLs including user directories (~user) and environment variables. Remote URLs are passed to KIO.

Member Type Documentation

enum KUrlCompletion::Mode

Determines how completion is done.

Constant Value Description
KUrlCompletion::ExeCompletion 1 executables in $PATH or with full path.
KUrlCompletion::FileCompletion 2 all files with full path or in dir(), URLs are listed using KIO.
KUrlCompletion::DirCompletion 3 Same as FileCompletion but only returns directories.

Member Function Documentation

KUrlCompletion::KUrlCompletion()

Constructs a KUrlCompletion object in FileCompletion mode.

KUrlCompletion::KUrlCompletion(KUrlCompletion::Mode)

This overloaded constructor allows you to set the Mode to ExeCompletion or FileCompletion without using setMode. Default is FileCompletion.

[virtual] QUrl KUrlCompletion::dir() const

Returns the current directory, as it was given in setDir, as a URL (use QUrl::toLocalFile for local paths)

See also setDir()

[virtual] bool KUrlCompletion::isRunning() const

Check whether asynchronous completion is in progress.

[override virtual] QString KUrlCompletion::makeCompletion(const QString &text)

Finds completions to the given text.

Remote URLs are listed with KIO. For performance reasons, local files are listed with KIO only if KURLCOMPLETION_LOCAL_KIO is set. The completion is done asynchronously if KIO is used.

Returns the first match for user, environment, and local dir completion and QString() for asynchronous completion (KIO or threaded).

text the text to complete

Returns the first match, or QString() if not found

QStringList KUrlCompletion::mimeTypeFilters() const

Returns the MIME type filters for the file dialog.

See also setMimeTypeFilters(), QFileDialog::mimeTypeFilters()

[virtual] KUrlCompletion::Mode KUrlCompletion::mode() const

Returns the completion mode: exe or file completion (default FileCompletion).

See also setMode()

[virtual] bool KUrlCompletion::replaceEnv() const

Checks whether environment variables are completed and whether they are replaced internally while finding completions.

Default is enabled.

Returns true if environment variables will be replaced

See also setReplaceEnv()

[virtual] bool KUrlCompletion::replaceHome() const

Returns whether ~username is completed and whether ~username is replaced internally with the user's home directory while finding completions. Default is enabled.

Returns true to replace tilde with the home directory

See also setReplaceHome()

QString KUrlCompletion::replacedPath(const QString &text) const

Replaces username and/or environment variables, depending on the current settings and returns the filtered url. Only works with local files, i.e. returns back the original string for non-local urls.

text the text to process

Returns the path or URL resulting from this operation. If you want to convert it to a QUrl, use QUrl::fromUserInput.

[virtual] void KUrlCompletion::setDir(const QUrl &dir)

Sets the current directory (used as base for completion). Default = $HOME.

dir the current directory, as a URL (use QUrl::fromLocalFile for local paths)

See also dir()

void KUrlCompletion::setMimeTypeFilters(const QStringList &mimeTypes)

Sets the MIME type filters for the file dialog.

See also mimeTypeFilters(), QFileDialog::setMimeTypeFilters()

[virtual] void KUrlCompletion::setMode(KUrlCompletion::Mode mode)

Changes the completion mode: exe or file completion

mode the new completion mode

See also mode()

[virtual] void KUrlCompletion::setReplaceEnv(bool replace)

Enables/disables completion and replacement (internally) of environment variables in URLs. Default is enabled.

replace true to replace environment variables

See also replaceEnv()

[virtual] void KUrlCompletion::setReplaceHome(bool replace)

Enables/disables completion of ~username and replacement (internally) of ~username with the user's home directory. Default is enabled.

replace true to replace tilde with the home directory

See also replaceHome()

[virtual] void KUrlCompletion::stop()

Stops asynchronous completion.

We use cookies to personalize content and to analyze our traffic. Please decide if you are willing to accept cookies from our website.