Engauge Digitizer
2
Toggle main menu visibility
Loading...
Searching...
No Matches
Document
DocumentModelLoadViews.cpp
Go to the documentation of this file.
1
/******************************************************************************************************
2
* (C) 2021 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
7
#include "
Document.h
"
8
#include "
DocumentModelLoadViews.h
"
9
#include "
DocumentSerialize.h
"
10
#include "
EngaugeAssert.h
"
11
#include "
Logger.h
"
12
#include <QObject>
13
#include <QTextStream>
14
#include "
QtToString.h
"
15
#include <QXmlStreamWriter>
16
#include "
Xml.h
"
17
18
DocumentModelLoadViews::DocumentModelLoadViews
() :
19
m_gridlines (false),
20
m_guidelines (false)
21
{
22
}
23
24
DocumentModelLoadViews::DocumentModelLoadViews
(
const
Document
&document) :
25
m_gridlines (document.modelLoadViews().
gridlines
()),
26
m_guidelines (document.modelLoadViews().
guidelines
())
27
{
28
}
29
30
DocumentModelLoadViews::DocumentModelLoadViews
(
const
DocumentModelLoadViews
&other) :
31
m_gridlines (other.
gridlines
()),
32
m_guidelines (other.
guidelines
())
33
{
34
}
35
36
DocumentModelLoadViews::DocumentModelLoadViews
(
bool
gridlines
,
37
bool
guidelines
) :
38
m_gridlines (
gridlines
),
39
m_guidelines (
guidelines
)
40
{
41
}
42
43
DocumentModelLoadViews
&
DocumentModelLoadViews::operator=
(
const
DocumentModelLoadViews
&other)
44
{
45
m_gridlines = other.
gridlines
();
46
m_guidelines = other.
guidelines
();
47
48
return
*
this
;
49
}
50
51
bool
DocumentModelLoadViews::gridlines
()
const
52
{
53
return
m_gridlines;
54
}
55
56
bool
DocumentModelLoadViews::guidelines
()
const
57
{
58
return
m_guidelines;
59
}
60
61
void
DocumentModelLoadViews::loadXml
(QXmlStreamReader &reader)
62
{
63
qCInfo(ENGAUGE_LOG) <<
"DocumentModelLoadViews::loadXml"
;
64
65
bool
success =
true
;
66
67
QXmlStreamAttributes attributes = reader.attributes();
68
69
if
(attributes.hasAttribute(
DOCUMENT_SERIALIZE_LOAD_VIEWS_GRIDLINES
) &&
70
attributes.hasAttribute(
DOCUMENT_SERIALIZE_LOAD_VIEWS_GUIDELINES
)) {
71
72
// Boolean values
73
QString stringGridlines = attributes.value (
DOCUMENT_SERIALIZE_LOAD_VIEWS_GRIDLINES
).toString();
74
QString stringGuidelines = attributes.value (
DOCUMENT_SERIALIZE_LOAD_VIEWS_GUIDELINES
).toString();
75
76
setGridlines
(stringGridlines ==
DOCUMENT_SERIALIZE_BOOL_TRUE
);
77
setGuidelines
(stringGuidelines ==
DOCUMENT_SERIALIZE_BOOL_TRUE
);
78
79
// Read until end of this subtree
80
while
((reader.tokenType() != QXmlStreamReader::EndElement) ||
81
(reader.name() !=
DOCUMENT_SERIALIZE_LOAD_VIEWS
)){
82
loadNextFromReader
(reader);
83
if
(reader.atEnd()) {
84
success =
false
;
85
break
;
86
}
87
}
88
}
89
90
if
(!success) {
91
reader.raiseError (QObject::tr (
"Cannot read settings for views loading"
));
92
}
93
}
94
95
void
DocumentModelLoadViews::printStream
(QString indentation,
96
QTextStream &str)
const
97
{
98
str << indentation <<
"DocumentModelLoadViews\n"
;
99
100
indentation +=
INDENTATION_DELTA
;
101
102
str << indentation <<
"gridlines="
<< (m_gridlines ?
"yes"
:
"no"
) <<
"\n"
;
103
str << indentation <<
"guidelines="
<< (m_guidelines ?
"yes"
:
"no"
) <<
"\n"
;
104
}
105
106
void
DocumentModelLoadViews::saveXml
(QXmlStreamWriter &writer)
const
107
{
108
qCInfo(ENGAUGE_LOG) <<
"DocumentModelLoadViews::saveXml"
;
109
110
writer.writeStartElement(
DOCUMENT_SERIALIZE_LOAD_VIEWS
);
111
writer.writeAttribute(
DOCUMENT_SERIALIZE_LOAD_VIEWS_GRIDLINES
, m_gridlines ?
112
DOCUMENT_SERIALIZE_BOOL_TRUE
:
113
DOCUMENT_SERIALIZE_BOOL_FALSE
);
114
writer.writeAttribute(
DOCUMENT_SERIALIZE_LOAD_VIEWS_GUIDELINES
, m_guidelines ?
115
DOCUMENT_SERIALIZE_BOOL_TRUE
:
116
DOCUMENT_SERIALIZE_BOOL_FALSE
);
117
writer.writeEndElement();
118
}
119
120
void
DocumentModelLoadViews::setGridlines
(
bool
gridlines
)
121
{
122
m_gridlines =
gridlines
;
123
}
124
125
void
DocumentModelLoadViews::setGuidelines
(
bool
guidelines
)
126
{
127
m_guidelines =
guidelines
;
128
}
DocumentModelLoadViews.h
DocumentSerialize.h
DOCUMENT_SERIALIZE_LOAD_VIEWS_GRIDLINES
const QString DOCUMENT_SERIALIZE_LOAD_VIEWS_GRIDLINES
DOCUMENT_SERIALIZE_LOAD_VIEWS
const QString DOCUMENT_SERIALIZE_LOAD_VIEWS
DOCUMENT_SERIALIZE_LOAD_VIEWS_GUIDELINES
const QString DOCUMENT_SERIALIZE_LOAD_VIEWS_GUIDELINES
DOCUMENT_SERIALIZE_BOOL_TRUE
const QString DOCUMENT_SERIALIZE_BOOL_TRUE
DOCUMENT_SERIALIZE_BOOL_FALSE
const QString DOCUMENT_SERIALIZE_BOOL_FALSE
Document.h
EngaugeAssert.h
Logger.h
INDENTATION_DELTA
const QString INDENTATION_DELTA
QtToString.h
loadNextFromReader
QXmlStreamReader::TokenType loadNextFromReader(QXmlStreamReader &reader)
Load next token from xml reader.
Definition
Xml.cpp:14
Xml.h
DocumentModelLoadViews::gridlines
bool gridlines() const
Get method for gridlines.
Definition
DocumentModelLoadViews.cpp:51
DocumentModelLoadViews::printStream
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
Definition
DocumentModelLoadViews.cpp:95
DocumentModelLoadViews::saveXml
virtual void saveXml(QXmlStreamWriter &writer) const
Save entire model as xml into stream.
Definition
DocumentModelLoadViews.cpp:106
DocumentModelLoadViews::setGuidelines
void setGuidelines(bool guidelines)
Set method for guidelines.
Definition
DocumentModelLoadViews.cpp:125
DocumentModelLoadViews::guidelines
bool guidelines() const
Get method for guidelines.
Definition
DocumentModelLoadViews.cpp:56
DocumentModelLoadViews::loadXml
virtual void loadXml(QXmlStreamReader &reader)
Load model from serialized xml.
Definition
DocumentModelLoadViews.cpp:61
DocumentModelLoadViews::setGridlines
void setGridlines(bool gridlines)
Set method for gridlines.
Definition
DocumentModelLoadViews.cpp:120
DocumentModelLoadViews::operator=
DocumentModelLoadViews & operator=(const DocumentModelLoadViews &other)
Assignment constructor.
Definition
DocumentModelLoadViews.cpp:43
DocumentModelLoadViews::DocumentModelLoadViews
DocumentModelLoadViews()
Default constructor.
Definition
DocumentModelLoadViews.cpp:18
Document
Storage of one imported image and the data attached to that image.
Definition
Document.h:44
Generated on
for Engauge Digitizer by
1.17.0