Engauge Digitizer  2
CmdSettingsMainWindow.cpp
1 #include "CmdSettingsMainWindow.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 ("Main window settings");
9 
11  Document &document,
12  const MainWindowModel &modelMainWindowBefore,
13  const MainWindowModel &modelMainWindowAfter) :
14  CmdAbstract(mainWindow,
15  document,
16  CMD_DESCRIPTION),
17  m_modelMainWindowBefore (modelMainWindowBefore),
18  m_modelMainWindowAfter (modelMainWindowAfter)
19 {
20  LOG4CPP_INFO_S ((*mainCat)) << "CmdSettingsMainWindow::CmdSettingsMainWindow";
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)) << "CmdSettingsMainWindow::CmdSettingsMainWindow";
32 
33  m_modelMainWindowBefore.loadXml (reader);
34  m_modelMainWindowAfter.loadXml (reader);
35 }
36 
37 CmdSettingsMainWindow::~CmdSettingsMainWindow ()
38 {
39 }
40 
42 {
43  LOG4CPP_INFO_S ((*mainCat)) << "CmdSettingsMainWindow::cmdRedo";
44 
45  mainWindow().updateSettingsMainWindow(m_modelMainWindowAfter);
47 }
48 
50 {
51  LOG4CPP_INFO_S ((*mainCat)) << "CmdSettingsMainWindow::cmdUndo";
52 
53  mainWindow().updateSettingsMainWindow(m_modelMainWindowBefore);
55 }
56 
57 void CmdSettingsMainWindow::saveXml (QXmlStreamWriter &writer) const
58 {
59  writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
60  writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_TYPE, DOCUMENT_SERIALIZE_CMD_SETTINGS_MAIN_WINDOW);
61  writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
62  m_modelMainWindowBefore.saveXml(writer);
63  m_modelMainWindowAfter.saveXml(writer);
64  writer.writeEndElement();
65 }
void updateSettingsMainWindow(const MainWindowModel &modelMainWindow)
Update with new main window properties.
virtual void saveXml(QXmlStreamWriter &writer) const
Save entire model as xml into stream.
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.
Model for DlgSettingsMainWindow and CmdSettingsMainWindow.
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
Definition: CmdAbstract.cpp:32
CmdSettingsMainWindow(MainWindow &mainWindow, Document &document, const MainWindowModel &modelMainWindowBefore, const MainWindowModel &modelMainWindowAfter)
Constructor for normal creation.
void updateAfterCommand()
See GraphicsScene::updateAfterCommand.
Storage of one imported image and the data attached to that image.
Definition: Document.h:29
virtual void saveXml(QXmlStreamWriter &writer) const
Save commands as xml for later uploading.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition: MainWindow.h:66
virtual void cmdRedo()
Redo method that is called when QUndoStack is moved one command forward.