00001 /****************************************************************************************************** 00002 * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released * 00003 * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file * 00004 * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. * 00005 ******************************************************************************************************/ 00006 00007 #ifndef CMD_ABSTRACT_H 00008 #define CMD_ABSTRACT_H 00009 00010 #include "DocumentHash.h" 00011 #include "PointIdentifiers.h" 00012 #include <QUndoCommand> 00013 00014 class Document; 00015 class MainWindow; 00016 class QXmlStreamWriter; 00017 00019 class CmdAbstract : public QUndoCommand 00020 { 00021 public: 00023 CmdAbstract(MainWindow &mainWindow, 00024 Document &document, 00025 const QString &cmdDescription); 00026 00027 virtual ~CmdAbstract(); 00028 00030 virtual void cmdRedo () = 0; 00031 00033 virtual void cmdUndo () = 0; 00034 00036 virtual void saveXml (QXmlStreamWriter &writer) const = 0; 00037 00038 protected: 00040 Document &document(); 00041 00043 const Document &document() const; 00044 00046 MainWindow &mainWindow (); 00047 00050 void resetSelection(const PointIdentifiers &pointIdentifiersToSelect); 00051 00055 void saveOrCheckPostCommandDocumentStateHash (const Document &document); 00056 00060 void saveOrCheckPreCommandDocumentStateHash (const Document &document); 00061 00062 private: 00063 CmdAbstract(); 00064 00065 virtual void redo (); // Calls cmdRedo 00066 virtual void undo (); // Calls cmdUndo 00067 00068 MainWindow &m_mainWindow; 00069 Document &m_document; 00070 00071 // Snapshots of GraphicsPointAbstractBase::identifierIndex before and after redo 00072 bool m_isFirstRedo; 00073 unsigned int m_identifierIndexBeforeRedo; 00074 unsigned int m_identifierIndexAfterRedo; 00075 00076 // Hash value that represents Document state before and after CmdAbstract::redo 00077 DocumentHash m_documentHashPost; 00078 DocumentHash m_documentHashPre; 00079 }; 00080 00081 #endif // CMD_ABSTRACT_H