digiKam
Loading...
Searching...
No Matches
undomanager.h
Go to the documentation of this file.
1/* ============================================================
2 *
3 * This file is a part of digiKam project
4 * https://www.digikam.org
5 *
6 * Date : 2005-02-06
7 * Description : an image editor actions undo/redo manager
8 *
9 * SPDX-FileCopyrightText: 2005-2006 by Renchi Raju <renchi dot raju at gmail dot com>
10 * SPDX-FileCopyrightText: 2005-2006 by Joern Ahrens <joern dot ahrens at kdemail dot net>
11 * SPDX-FileCopyrightText: 2006-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
12 *
13 * SPDX-License-Identifier: GPL-2.0-or-later
14 *
15 * ============================================================ */
16
17#pragma once
18
19// Qt includes
20
21#include <QStringList>
22
23// Local includes
24
25#include "digikam_export.h"
26
27namespace Digikam
28{
29
30class DImageHistory;
31class DImg;
32class EditorCore;
33class UndoAction;
34class UndoMetadataContainer;
35
36class DIGIKAM_EXPORT UndoManager
37{
38
39public:
40
41 explicit UndoManager(EditorCore* const core);
43
44 void addAction(UndoAction* const action);
45 void undo();
46 void redo();
47 void rollbackToOrigin();
48 bool putImageDataAndHistory(DImg* const img, int stepsBack) const;
49
50 void clear(bool clearCache = true);
51
52 bool anyMoreUndo() const;
53 bool anyMoreRedo() const;
54 int availableUndoSteps() const;
55 int availableRedoSteps() const;
56 QStringList getUndoHistory() const;
57 QStringList getRedoHistory() const;
58 bool isAtOrigin() const;
59 void setOrigin() const;
60 bool hasChanges() const;
61
63 DImageHistory getImageHistoryOfFullRedo() const;
64
65 void clearPreviousOriginData();
66
67private:
68
69 void clearUndoActions();
70 void clearRedoActions();
71 void undoStep(bool saveRedo, bool execute, bool flyingRollback);
72 void redoStep(bool execute, bool flyingRollback);
73 void makeSnapshot(int index);
74 void restoreSnapshot(int index, const UndoMetadataContainer& c);
75 void getSnapshot(int index, DImg* const img) const;
76
77private:
78
79 // Disable
80 UndoManager(const UndoManager&) = delete;
81 UndoManager& operator=(const UndoManager&) = delete;
82
83private:
84
85 class Private;
86 Private* const d = nullptr;
87};
88
89} // namespace Digikam
Definition dimagehistory.h:39
Definition dimg.h:52
Definition editorcore.h:48
Definition undoaction.h:56
Definition undomanager.h:37
Definition undoaction.h:32
Definition datefolderview.cpp:34