Cockatrice 2026-10-19-Development-3.1.2-beta.2
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
deck_list_history_manager.h
Go to the documentation of this file.
1#ifndef COCKATRICE_DECK_LIST_HISTORY_MANAGER_H
2#define COCKATRICE_DECK_LIST_HISTORY_MANAGER_H
3
4#include "deck_list_memento.h"
5
6#include <QObject>
7#include <QStack>
8#include <qtmetamacros.h>
9
10class DeckList;
11
12class DeckListHistoryManager : public QObject
13{
14 Q_OBJECT
15
16signals:
18
19public:
20 explicit DeckListHistoryManager(QObject *parent = nullptr) : QObject(parent)
21 {
22 }
23
24 void save(const DeckListMemento &memento);
25
26 void clear();
27
28 [[nodiscard]] bool canUndo() const
29 {
30 return !undoStack.isEmpty();
31 }
32
33 [[nodiscard]] bool canRedo() const
34 {
35 return !redoStack.isEmpty();
36 }
37
38 void undo(DeckList *deck);
39
40 void redo(DeckList *deck);
41
42 [[nodiscard]] QStack<DeckListMemento> getRedoStack() const
43 {
44 return redoStack;
45 }
46 [[nodiscard]] QStack<DeckListMemento> getUndoStack() const
47 {
48 return undoStack;
49 }
50
51private:
57 void restoreAndSwap(QStack<DeckListMemento> &source, QStack<DeckListMemento> &target, DeckList *deck);
58
59 QStack<DeckListMemento> undoStack;
60 QStack<DeckListMemento> redoStack;
61};
62
63#endif // COCKATRICE_DECK_LIST_HISTORY_MANAGER_H
QStack< DeckListMemento > getRedoStack() const
Definition deck_list_history_manager.h:42
void undo(DeckList *deck)
Definition deck_list_history_manager.cpp:42
QStack< DeckListMemento > getUndoStack() const
Definition deck_list_history_manager.h:46
QStack< DeckListMemento > redoStack
Definition deck_list_history_manager.h:60
void restoreAndSwap(QStack< DeckListMemento > &source, QStack< DeckListMemento > &target, DeckList *deck)
Moves one state from source to target, applying it to deck.
Definition deck_list_history_manager.cpp:22
DeckListHistoryManager(QObject *parent=nullptr)
Definition deck_list_history_manager.h:20
void clear()
Definition deck_list_history_manager.cpp:15
void redo(DeckList *deck)
Definition deck_list_history_manager.cpp:47
bool canRedo() const
Definition deck_list_history_manager.h:33
bool canUndo() const
Definition deck_list_history_manager.h:28
void save(const DeckListMemento &memento)
Definition deck_list_history_manager.cpp:8
QStack< DeckListMemento > undoStack
Definition deck_list_history_manager.h:59
Definition deck_list_memento.h:6
Represents a complete deck, including metadata, zones, cards, and sideboard plans.
Definition deck_list.h:67