Engauge Digitizer  2
 All Classes Files Functions Variables Enumerations Enumerator Friends Pages
CmdSettingsGeneral.cpp
1 #include "CmdSettingsGeneral.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 ("General settings");
9 
11  Document &document,
12  const DocumentModelGeneral &modelGeneralBefore,
13  const DocumentModelGeneral &modelGeneralAfter) :
14  CmdAbstract(mainWindow,
15  document,
16  CMD_DESCRIPTION),
17  m_modelGeneralBefore (modelGeneralBefore),
18  m_modelGeneralAfter (modelGeneralAfter)
19 {
20  LOG4CPP_INFO_S ((*mainCat)) << "CmdSettingsGeneral::CmdSettingsGeneral";
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)) << "CmdSettingsGeneral::CmdSettingsGeneral";
32 
33  m_modelGeneralBefore.loadXml (reader);
34  m_modelGeneralAfter.loadXml (reader);
35 }
36 
37 CmdSettingsGeneral::~CmdSettingsGeneral ()
38 {
39 }
40 
42 {
43  LOG4CPP_INFO_S ((*mainCat)) << "CmdSettingsGeneral::cmdRedo";
44 
45  mainWindow().updateSettingsGeneral(m_modelGeneralAfter);
47 }
48 
50 {
51  LOG4CPP_INFO_S ((*mainCat)) << "CmdSettingsGeneral::cmdUndo";
52 
53  mainWindow().updateSettingsGeneral(m_modelGeneralBefore);
55 }
56 
57 void CmdSettingsGeneral::saveXml (QXmlStreamWriter &writer) const
58 {
59  writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
60  writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_TYPE, DOCUMENT_SERIALIZE_CMD_SETTINGS_GENERAL);
61  writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
62  m_modelGeneralBefore.saveXml(writer);
63  m_modelGeneralAfter.saveXml(writer);
64  writer.writeEndElement();
65 }
Model for DlgSettingsGeneral and CmdSettingsGeneral.
Wrapper around QUndoCommand. This simplifies the more complicated feature set of QUndoCommand.
Definition: CmdAbstract.h:11
virtual void cmdUndo()
Undo method that is called when QUndoStack is moved one command backward.
virtual void loadXml(QXmlStreamReader &reader)
Load model from serialized xml.
virtual void saveXml(QXmlStreamWriter &writer) const
Save commands as xml for later uploading.
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
void updateSettingsGeneral(const DocumentModelGeneral &modelGeneral)
Update with new general properties.
virtual void cmdRedo()
Redo method that is called when QUndoStack is moved one command forward.
CmdSettingsGeneral(MainWindow &mainWindow, Document &document, const DocumentModelGeneral &modelGeneralBefore, const DocumentModelGeneral &modelGeneralAfter)
Constructor for normal creation.
virtual void saveXml(QXmlStreamWriter &writer) const
Save entire model as xml into stream.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition: MainWindow.h:66