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
List of all members, including inherited members
Public Types
Public Functions
- quint64 currentCommandSerialNumber() const
- bool isRedoAvailable() const (since 6.17)
- 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)
- QString redoText() const (since 6.17)
- void setUiInterface(KIO::FileUndoManager::UiInterface *ui)
- KIO::FileUndoManager::UiInterface *uiInterface() const
- QString undoText() const
Public Slots
- void redo() (since 6.17)
- void undo()
Signals
- void jobRecordingFinished(KIO::FileUndoManager::CommandType op)
- void jobRecordingStarted(KIO::FileUndoManager::CommandType op)
- void redoAvailable(bool avail) (since 6.17)
- void redoTextChanged(const QString &text) (since 6.17)
- void undoAvailable(bool avail)
- void undoJobFinished()
- void undoTextChanged(const QString &text)
Static Public Members
Detailed Description
This class is a singleton, use self() to access its only instance.
Member Type Documentation
enum FileUndoManager::CommandType
The type of job.
| Constant | Value | |
|---|---|---|
KIO::FileUndoManager::Copy |
0 |
|
KIO::FileUndoManager::Move |
1 |
|
KIO::FileUndoManager::Rename |
2 |
|
KIO::FileUndoManager::Link |
3 |
|
KIO::FileUndoManager::Mkdir |
4 |
|
KIO::FileUndoManager::Trash |
5 |
|
KIO::FileUndoManager::Put (since Qt 4.7) |
6 |
Represents the creation of a file from data in memory. Used when pasting data from clipboard or drag-n-drop |
KIO::FileUndoManager::Mkpath (since Qt 5.4) |
7 |
Represents a KIO::mkpath() job |
KIO::FileUndoManager::BatchRename (since Qt 5.42) |
8 |
Represents a KIO::batchRename() job. Used when renaming multiple files |
Member Function Documentation
quint64 FileUndoManager::currentCommandSerialNumber() const
[since 6.17] bool FileUndoManager::isRedoAvailable() const
Returns true if redo is possible. Usually used for enabling/disabling the redo action.
This function was introduced in Qt 6.17.
bool FileUndoManager::isUndoAvailable() const
Returns true if undo is possible. Usually used for enabling/disabling the undo action.
[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
[slot, since 6.17] void FileUndoManager::redo()
Redoes 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 redo is complete.
This function was introduced in Qt 6.17.
[signal, since 6.17] void FileUndoManager::redoAvailable(bool avail)
Emitted when the value of isRedoAvailable() changes
This function was introduced in Qt 6.17.
[since 6.17] QString FileUndoManager::redoText() const
Returns the current text for the redo action.
This function was introduced in Qt 6.17.
[signal, since 6.17] void FileUndoManager::redoTextChanged(const QString &text)
Emitted when the value of redoText() changes
This function was introduced in Qt 6.17.
[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 (or redo) 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