Engauge Digitizer 2
Loading...
Searching...
No Matches
CmdAbstract.h
Go to the documentation of this file.
1/******************************************************************************************************
2 * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3 * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4 * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5 ******************************************************************************************************/
6
7#ifndef CMD_ABSTRACT_H
8#define CMD_ABSTRACT_H
9
10#include "DocumentHash.h"
11#include "PointIdentifiers.h"
12#include <QUndoCommand>
13
14class Document;
15class MainWindow;
16class QXmlStreamWriter;
17
19class CmdAbstract : public QUndoCommand
20{
21public:
25 const QString &cmdDescription);
26
27 virtual ~CmdAbstract();
28
30 virtual void cmdRedo () = 0;
31
33 virtual void cmdUndo () = 0;
34
36 virtual void saveXml (QXmlStreamWriter &writer) const = 0;
37
38protected:
41
43 const Document &document() const;
44
47
50 void resetSelection(const PointIdentifiers &pointIdentifiersToSelect);
51
56
61
62private:
64
65 virtual void redo (); // Calls cmdRedo
66 virtual void undo (); // Calls cmdUndo
67
68 MainWindow &m_mainWindow;
69 Document &m_document;
70
71 // Snapshots of GraphicsPointAbstractBase::identifierIndex before and after redo
72 bool m_isFirstRedo;
73 unsigned int m_identifierIndexBeforeRedo;
74 unsigned int m_identifierIndexAfterRedo;
75
76 // Hash value that represents Document state before and after CmdAbstract::redo
77 DocumentHash m_documentHashPost;
78 DocumentHash m_documentHashPre;
79};
80
81#endif // CMD_ABSTRACT_H
QByteArray DocumentHash
Wrapper around QUndoCommand. This simplifies the more complicated feature set of QUndoCommand.
Definition CmdAbstract.h:20
Document & document()
Return the Document that this command will modify during redo and undo.
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
virtual void cmdUndo()=0
Undo method that is called when QUndoStack is moved one command backward.
void saveOrCheckPostCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
void saveOrCheckPreCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
void resetSelection(const PointIdentifiers &pointIdentifiersToSelect)
Since the set of selected points has probably changed, changed that set back to the specified set.
virtual void saveXml(QXmlStreamWriter &writer) const =0
Save commands as xml for later uploading.
virtual ~CmdAbstract()
virtual void cmdRedo()=0
Redo method that is called when QUndoStack is moved one command forward.
Storage of one imported image and the data attached to that image.
Definition Document.h:42
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition MainWindow.h:92
Hash table class that tracks point identifiers as the key, with a corresponding boolean value.