KIO::FileUndoManager Class

Makes it possible to undo KIO jobs. More...

Header: #include <KIO/FileUndoManager>
CMake: find_package(KF6 REQUIRED COMPONENTS KIO)
target_link_libraries(mytarget PRIVATE KF6::KIOWidgets)
Inherits: QObject

Public Types

class UiInterface
enum CommandType { Copy, Move, Rename, Link, Mkdir, …, Represents }

Public Functions

quint64 currentCommandSerialNumber() const
(since 5.79) bool isUndoAvailable() const
quint64 newCommandSerialNumber()
void recordCopyJob(KIO::CopyJob *copyJob)
void recordJob(KIO::FileUndoManager::CommandType op, const QList<QUrl> &src, const QUrl &dst, KIO::Job *job)
void setUiInterface(KIO::FileUndoManager::UiInterface *ui)
KIO::FileUndoManager::UiInterface *uiInterface() const
QString undoText() const

Public Slots

void undo()

Signals

void jobRecordingFinished(KIO::FileUndoManager::CommandType op)
void jobRecordingStarted(KIO::FileUndoManager::CommandType op)
void undoAvailable(bool avail)
void undoJobFinished()
void undoTextChanged(const QString &text)

Static Public Members

KIO::FileUndoManager *self()

Detailed Description

This class is a singleton, use self() to access its only instance.

Member Type Documentation

enum FileUndoManager::CommandType

The type of job.

ConstantValueDescription
KIO::FileUndoManager::Copy0 
KIO::FileUndoManager::Move1 
KIO::FileUndoManager::Rename2 
KIO::FileUndoManager::Link3 
KIO::FileUndoManager::Mkdir4 
KIO::FileUndoManager::Trash5 
KIO::FileUndoManager::Put (since Qt 4.7)6Represents the creation of a file from data in memory. Used when pasting data from clipboard or drag-n-drop \vaue[since 5.4] Represents a KIO::mkpath() job
KIO::FileUndoManager::Represents (since Qt 5.42)?a KIO::batchRename() job. Used when renaming multiple files

Member Function Documentation

quint64 FileUndoManager::currentCommandSerialNumber() const

[since 5.79] bool FileUndoManager::isUndoAvailable() const

Returns true if undo is possible. Usually used for enabling/disabling the undo action.

This function was introduced in 5.79.

[signal] void FileUndoManager::jobRecordingFinished(KIO::FileUndoManager::CommandType op)

Emitted when a job that has been recorded by FileUndoManager::recordJob() or FileUndoManager::recordCopyJob has been finished. The command is now available for an undo-operation.

[signal] void FileUndoManager::jobRecordingStarted(KIO::FileUndoManager::CommandType op)

Emitted when a job recording has been started by FileUndoManager::recordJob() or FileUndoManager::recordCopyJob(). After the job recording has been finished, the signal jobRecordingFinished() will be emitted.

quint64 FileUndoManager::newCommandSerialNumber()

These two functions are useful when wrapping FileUndoManager and adding custom commands. Each command has a unique ID. You can get a new serial number for a custom command with newCommandSerialNumber(), and then when you want to undo, check if the command FileUndoManager would undo is newer or older than your custom command.

See also currentCommandSerialNumber().

void FileUndoManager::recordCopyJob(KIO::CopyJob *copyJob)

Record this CopyJob while it's happening and add a command for it so that the user can undo it. The signal jobRecordingStarted() is emitted.

void FileUndoManager::recordJob(KIO::FileUndoManager::CommandType op, const QList<QUrl> &src, const QUrl &dst, KIO::Job *job)

Record this job while it's happening and add a command for it so that the user can undo it. The signal jobRecordingStarted() is emitted.

op the type of job - which is also the type of command that will be created for it

src list of source urls. This is empty for Mkdir, Mkpath, Put operations.

dst destination url

job the job to record

[static] KIO::FileUndoManager *FileUndoManager::self()

Returns the FileUndoManager instance

void FileUndoManager::setUiInterface(KIO::FileUndoManager::UiInterface *ui)

Set a new UiInterface implementation. This deletes the previous one.

ui the UiInterface instance, which becomes owned by the undo manager.

See also uiInterface().

KIO::FileUndoManager::UiInterface *FileUndoManager::uiInterface() const

Returns the UiInterface instance passed to setUiInterface. This is useful for calling setParentWidget on it. Never delete it!

See also setUiInterface().

[slot] void FileUndoManager::undo()

Undoes the last command Remember to call uiInterface()->setParentWidget(parentWidget) first, if you have multiple mainwindows.

This operation is asynchronous. undoJobFinished will be emitted once the undo is complete.

[signal] void FileUndoManager::undoAvailable(bool avail)

Emitted when the value of isUndoAvailable() changes

[signal] void FileUndoManager::undoJobFinished()

Emitted when an undo job finishes. Used for unit testing.

QString FileUndoManager::undoText() const

Returns the current text for the undo action.

[signal] void FileUndoManager::undoTextChanged(const QString &text)

Emitted when the value of undoText() changes