Engauge Digitizer  2
 All Classes Files Functions Variables Enumerations Enumerator Friends Pages
CmdSettingsCommon.cpp
1 #include "CmdSettingsCommon.h"
2 #include "Document.h"
3 #include "DocumentSerialize.h"
4 #include "Logger.h"
5 #include "MainWindow.h"
6 #include <QXmlStreamReader>
7 
8 const QString CMD_DESCRIPTION ("Common settings");
9 
11  Document &document,
12  const DocumentModelCommon &modelCommonBefore,
13  const DocumentModelCommon &modelCommonAfter) :
14  CmdAbstract(mainWindow,
15  document,
16  CMD_DESCRIPTION),
17  m_modelCommonBefore (modelCommonBefore),
18  m_modelCommonAfter (modelCommonAfter)
19 {
20  LOG4CPP_INFO_S ((*mainCat)) << "CmdSettingsCommon::CmdSettingsCommon";
21 }
22 
24  Document &document,
25  const QString &cmdDescription,
26  QXmlStreamReader &reader) :
27  CmdAbstract (mainWindow,
28  document,
29  cmdDescription)
30 {
31  LOG4CPP_INFO_S ((*mainCat)) << "CmdSettingsCommon::CmdSettingsCommon";
32 
33  m_modelCommonBefore.loadXml (reader);
34  m_modelCommonAfter.loadXml (reader);
35 }
36 
37 CmdSettingsCommon::~CmdSettingsCommon ()
38 {
39 }
40 
42 {
43  LOG4CPP_INFO_S ((*mainCat)) << "CmdSettingsCommon::cmdRedo";
44 
45  mainWindow().updateSettingsCommon(m_modelCommonAfter);
47 }
48 
50 {
51  LOG4CPP_INFO_S ((*mainCat)) << "CmdSettingsCommon::cmdUndo";
52 
53  mainWindow().updateSettingsCommon(m_modelCommonBefore);
55 }
56 
57 void CmdSettingsCommon::saveXml (QXmlStreamWriter &writer) const
58 {
59  writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
60  writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_TYPE, DOCUMENT_SERIALIZE_CMD_SETTINGS_COMMON);
61  writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
62  m_modelCommonBefore.saveXml(writer);
63  m_modelCommonAfter.saveXml(writer);
64  writer.writeEndElement();
65 }
virtual void cmdUndo()
Undo method that is called when QUndoStack is moved one command backward.
void updateSettingsCommon(const DocumentModelCommon &modelCommon)
Update with new common properties.
Wrapper around QUndoCommand. This simplifies the more complicated feature set of QUndoCommand.
Definition: CmdAbstract.h:11
Model for DlgSettingsCommon and CmdSettingsCommon.
virtual void cmdRedo()
Redo method that is called when QUndoStack is moved one command forward.
virtual void saveXml(QXmlStreamWriter &writer) const
Save commands as xml for later uploading.
CmdSettingsCommon(MainWindow &mainWindow, Document &document, const DocumentModelCommon &modelCommonBefore, const DocumentModelCommon &modelCommonAfter)
Constructor for normal creation.
virtual void saveXml(QXmlStreamWriter &writer) const
Save entire model as xml into stream.
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
Definition: CmdAbstract.cpp:32
void updateAfterCommand()
See GraphicsScene::updateAfterCommand.
Storage of one imported image and the data attached to that image.
Definition: Document.h:29
virtual void loadXml(QXmlStreamReader &reader)
Load model from serialized xml.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition: MainWindow.h:60