KIO::StatJob Class

Header: #include <StatJob>
CMake: find_package(KF6 REQUIRED COMPONENTS KIO)
target_link_libraries(mytarget PRIVATE KF6::KIOCore)
Inherits: KIO::SimpleJob

Public Functions

(since 4.4) QUrl mostLocalUrl() const
void setDetails(KIO::StatDetails details)
void setSide(KIO::StatJob::StatSide side)
const KIO::UDSEntry &statResult() const

Signals

void permanentRedirection(KIO::Job *job, const QUrl &fromUrl, const QUrl &toUrl)
void redirection(KIO::Job *job, const QUrl &url)

Detailed Description

@class KIO::StatJob statjob.h <KIO/StatJob>

A KIO job that retrieves information about a file or directory. @see KIO::stat()

Member Function Documentation

[since 4.4] QUrl StatJob::mostLocalUrl() const

@brief most local URL

Since this method depends on UDSEntry::UDS_LOCAL_PATH having been previously set by a KIO worker, ideally you should first check that the protocol Class of the URL being stat'ed is ":local" before creating the StatJob at all. Typically only ":local" KIO workers set UDS_LOCAL_PATH. See KProtocolInfo::protocolClass().

Call this in a slot connected to the result signal, and only after making sure no error happened.

@return the most local URL for the URL we were stat'ing

Sample usage:

@code auto *job = KIO::mostLocalUrl("desktop:/foo"); job->uiDelegate()->setWindow(this); connect(job, &KJob::result, this, &MyClass::slotMostLocalUrlResult); [...] // and in slotMostLocalUrlResult(KJob *job) if (job->error()) { [...] // doesn't exist } else { const QUrl localUrl = job->mostLocalUrl(); // localUrl = file:///$HOME/Desktop/foo [...] } @endcode

This function was introduced in 4.4.

[signal] void StatJob::permanentRedirection(KIO::Job *job, const QUrl &fromUrl, const QUrl &toUrl)

Signals a permanent redirection. The redirection itself is handled internally. @param job the job that is redirected @param fromUrl the original URL @param toUrl the new URL

[signal] void StatJob::redirection(KIO::Job *job, const QUrl &url)

Signals a redirection. Use to update the URL shown to the user. The redirection itself is handled internally. @param job the job that is redirected @param url the new url

void StatJob::setDetails(KIO::StatDetails details)

Selects the level of @p details we want. @since 5.69

void StatJob::setSide(KIO::StatJob::StatSide side)

A stat() can have two meanings. Either we want to read from this URL, or to check if we can write to it. First case is "source", second is "dest". It is necessary to know what the StatJob is for, to tune the KIO worker's behavior (e.g. with FTP). By default it is SourceSide. @param side SourceSide or DestinationSide

const KIO::UDSEntry &StatJob::statResult() const

@brief Result of the stat operation. Call this in the slot connected to result, and only after making sure no error happened. @return the result of the stat