Engauge Digitizer 2
Loading...
Searching...
No Matches
CmdGuidelineViewState.cpp
Go to the documentation of this file.
1/******************************************************************************************************
2 * (C) 2020 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
8#include "Document.h"
9#include "DocumentSerialize.h"
10#include "Logger.h"
11#include "MainWindow.h"
12#include "Xml.h"
13
14const QString CMD_DESCRIPTION ("GuidelineViewState");
15
18 GuidelineViewState stateBefore,
19 GuidelineViewState stateAfter) :
23 m_stateBefore (stateBefore),
24 m_stateAfter (stateAfter)
25{
26 LOG4CPP_INFO_S ((*mainCat)) << "CmdGuidelineViewState::CmdGuidelineViewState";
27}
28
31 const QString &cmdDescription,
32 QXmlStreamReader &reader) :
35 cmdDescription)
36{
37 LOG4CPP_INFO_S ((*mainCat)) << "CmdGuidelineViewState::CmdGuidelineViewState";
38
39 QXmlStreamAttributes attributes = reader.attributes();
40
41 if (!attributes.hasAttribute(DOCUMENT_SERIALIZE_GUIDELINE_VIEW_STATE_BEFORE) ||
42 !attributes.hasAttribute(DOCUMENT_SERIALIZE_GUIDELINE_VIEW_STATE_AFTER)) {
43 xmlExitWithError (reader,
44 QString ("%1 %2 %3 %4")
45 .arg (QObject::tr ("Missing attribute(s)"))
47 .arg (QObject::tr ("and/or"))
49 }
50
51 m_stateBefore = static_cast<GuidelineViewState> (attributes.value(DOCUMENT_SERIALIZE_GUIDELINE_VIEW_STATE_BEFORE).toInt());
52 m_stateAfter = static_cast<GuidelineViewState> (attributes.value(DOCUMENT_SERIALIZE_GUIDELINE_VIEW_STATE_AFTER).toInt());
53}
54
58
60{
61 LOG4CPP_INFO_S ((*mainCat)) << "CmdGuidelineViewState::cmdRedo"
62 << " state=" << m_stateAfter;
63
64 mainWindow().guidelineViewState (m_stateAfter);
65}
66
68{
69 LOG4CPP_INFO_S ((*mainCat)) << "CmdGuidelineViewState::cmdUndo"
70 << " state=" << m_stateBefore;
71
72 mainWindow().guidelineViewState (m_stateBefore);
73}
74
75void CmdGuidelineViewState::saveXml (QXmlStreamWriter &writer) const
76{
77 writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
79 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
80 writer.writeAttribute(DOCUMENT_SERIALIZE_GUIDELINE_VIEW_STATE_BEFORE, QString::number (m_stateBefore));
81 writer.writeAttribute(DOCUMENT_SERIALIZE_GUIDELINE_VIEW_STATE_AFTER, QString::number (m_stateAfter));
82 writer.writeEndElement();
83}
const QString CMD_DESCRIPTION("Add axis point")
const QString CMD_DESCRIPTION("GuidelineViewState")
const QString DOCUMENT_SERIALIZE_CMD_GUIDELINE_VIEW_STATE
const QString DOCUMENT_SERIALIZE_GUIDELINE_VIEW_STATE_AFTER
const QString DOCUMENT_SERIALIZE_CMD
const QString DOCUMENT_SERIALIZE_CMD_TYPE
const QString DOCUMENT_SERIALIZE_GUIDELINE_VIEW_STATE_BEFORE
const QString DOCUMENT_SERIALIZE_CMD_DESCRIPTION
GuidelineViewState
Set of possible Guideline view states.
log4cpp::Category * mainCat
Definition Logger.cpp:14
void xmlExitWithError(QXmlStreamReader &reader, const QString &message)
Show specified message for an error while reading xml, then quit.
Definition Xml.cpp:25
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.
CmdAbstract(MainWindow &mainWindow, Document &document, const QString &cmdDescription)
Single constructor.
virtual void cmdRedo()
Redo method that is called when QUndoStack is moved one command forward.
CmdGuidelineViewState(MainWindow &mainWindow, Document &document, GuidelineViewState stateBefore, GuidelineViewState stateAfter)
Constructor for normal creation.
virtual void saveXml(QXmlStreamWriter &writer) const
Save commands as xml for later uploading.
virtual void cmdUndo()
Undo method that is called when QUndoStack is moved one command backward.
Storage of one imported image and the data attached to that image.
Definition Document.h:44
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition MainWindow.h:96
void guidelineViewState(GuidelineViewState state) const
Guideline view state in View menu.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18