File indexing completed on 2024-05-12 15:58:47

0001 /*
0002  *  SPDX-FileCopyrightText: 2003 Patrick Julien <freak@codepimps.org>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef KIS_UNDO_ADAPTER_H_
0008 #define KIS_UNDO_ADAPTER_H_
0009 
0010 #include <QObject>
0011 
0012 #include <kritaimage_export.h>
0013 #include <kis_undo_store.h>
0014 
0015 
0016 class KRITAIMAGE_EXPORT KisUndoAdapter : public QObject
0017 {
0018     Q_OBJECT
0019 
0020 public:
0021     KisUndoAdapter(KisUndoStore *undoStore, QObject *parent = 0);
0022     ~KisUndoAdapter() override;
0023 
0024 public:
0025     void emitSelectionChanged();
0026 
0027     virtual const KUndo2Command* presentCommand() = 0;
0028     virtual void undoLastCommand() = 0;
0029     virtual void addCommand(KUndo2Command *cmd) = 0;
0030     virtual void beginMacro(const KUndo2MagicString& macroName) = 0;
0031     virtual void endMacro() = 0;
0032 
0033     inline void setUndoStore(KisUndoStore *undoStore) {
0034         m_undoStore = undoStore;
0035     }
0036 
0037 Q_SIGNALS:
0038     void selectionChanged();
0039 
0040 protected:
0041     inline KisUndoStore* undoStore() {
0042         return m_undoStore;
0043     }
0044 
0045 private:
0046     Q_DISABLE_COPY(KisUndoAdapter)
0047     KisUndoStore *m_undoStore;
0048 };
0049 
0050 
0051 #endif // KIS_UNDO_ADAPTER_H_
0052