Engauge Digitizer 2
Loading...
Searching...
No Matches
DocumentModelLoadViews Class Reference

Model for storing enabled/disabled states of views for optional restoration during loading. More...

#include <DocumentModelLoadViews.h>

Inheritance diagram for DocumentModelLoadViews:
Inheritance graph
Collaboration diagram for DocumentModelLoadViews:
Collaboration graph

Public Member Functions

 DocumentModelLoadViews ()
 Default constructor.
 DocumentModelLoadViews (const Document &document)
 Initial constructor from Document.
 DocumentModelLoadViews (const DocumentModelLoadViews &other)
 Copy constructor.
 DocumentModelLoadViews (bool gridlines, bool guidelines)
 Inline constructor.
DocumentModelLoadViewsoperator= (const DocumentModelLoadViews &other)
 Assignment constructor.
bool gridlines () const
 Get method for gridlines.
bool guidelines () const
 Get method for guidelines.
virtual void loadXml (QXmlStreamReader &reader)
 Load model from serialized xml.
void printStream (QString indentation, QTextStream &str) const
 Debugging method that supports print method of this class and printStream method of some other class(es)
virtual void saveXml (QXmlStreamWriter &writer) const
 Save entire model as xml into stream.
void setGridlines (bool gridlines)
 Set method for gridlines.
void setGuidelines (bool guidelines)
 Set method for guidelines.
Public Member Functions inherited from DocumentModelAbstractBase
 DocumentModelAbstractBase ()
 Single constructor.
virtual ~DocumentModelAbstractBase ()
 Single destructor.

Detailed Description

Model for storing enabled/disabled states of views for optional restoration during loading.

Definition at line 16 of file DocumentModelLoadViews.h.

Constructor & Destructor Documentation

◆ DocumentModelLoadViews() [1/4]

DocumentModelLoadViews::DocumentModelLoadViews ( )

Default constructor.

Definition at line 18 of file DocumentModelLoadViews.cpp.

18 :
19 m_gridlines (false),
20 m_guidelines (false)
21{
22}

◆ DocumentModelLoadViews() [2/4]

DocumentModelLoadViews::DocumentModelLoadViews ( const Document & document)

Initial constructor from Document.

Definition at line 24 of file DocumentModelLoadViews.cpp.

24 :
25 m_gridlines (document.modelLoadViews().gridlines ()),
26 m_guidelines (document.modelLoadViews().guidelines ())
27{
28}
bool gridlines() const
Get method for gridlines.
bool guidelines() const
Get method for guidelines.
DocumentModelLoadViews modelLoadViews() const
Get method for DocumentModelLoadViews.
Definition Document.cpp:763

◆ DocumentModelLoadViews() [3/4]

DocumentModelLoadViews::DocumentModelLoadViews ( const DocumentModelLoadViews & other)

Copy constructor.

Definition at line 30 of file DocumentModelLoadViews.cpp.

30 :
31 m_gridlines (other.gridlines ()),
32 m_guidelines (other.guidelines ())
33{
34}

◆ DocumentModelLoadViews() [4/4]

DocumentModelLoadViews::DocumentModelLoadViews ( bool gridlines,
bool guidelines )

Inline constructor.

Definition at line 36 of file DocumentModelLoadViews.cpp.

37 :
38 m_gridlines (gridlines),
39 m_guidelines (guidelines)
40{
41}

Member Function Documentation

◆ gridlines()

bool DocumentModelLoadViews::gridlines ( ) const

Get method for gridlines.

Definition at line 51 of file DocumentModelLoadViews.cpp.

52{
53 return m_gridlines;
54}

◆ guidelines()

bool DocumentModelLoadViews::guidelines ( ) const

Get method for guidelines.

Definition at line 56 of file DocumentModelLoadViews.cpp.

57{
58 return m_guidelines;
59}

◆ loadXml()

void DocumentModelLoadViews::loadXml ( QXmlStreamReader & reader)
virtual

Load model from serialized xml.

Implements DocumentModelAbstractBase.

Definition at line 61 of file DocumentModelLoadViews.cpp.

62{
63 LOG4CPP_INFO_S ((*mainCat)) << "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}
const QString DOCUMENT_SERIALIZE_LOAD_VIEWS_GRIDLINES
const QString DOCUMENT_SERIALIZE_LOAD_VIEWS
const QString DOCUMENT_SERIALIZE_LOAD_VIEWS_GUIDELINES
const QString DOCUMENT_SERIALIZE_BOOL_TRUE
log4cpp::Category * mainCat
Definition Logger.cpp:14
QXmlStreamReader::TokenType loadNextFromReader(QXmlStreamReader &reader)
Load next token from xml reader.
Definition Xml.cpp:14
void setGuidelines(bool guidelines)
Set method for guidelines.
void setGridlines(bool gridlines)
Set method for gridlines.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ operator=()

DocumentModelLoadViews & DocumentModelLoadViews::operator= ( const DocumentModelLoadViews & other)

Assignment constructor.

Definition at line 43 of file DocumentModelLoadViews.cpp.

44{
45 m_gridlines = other.gridlines ();
46 m_guidelines = other.guidelines ();
47
48 return *this;
49}

◆ printStream()

void DocumentModelLoadViews::printStream ( QString indentation,
QTextStream & str ) const

Debugging method that supports print method of this class and printStream method of some other class(es)

Definition at line 95 of file DocumentModelLoadViews.cpp.

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}
const QString INDENTATION_DELTA

◆ saveXml()

void DocumentModelLoadViews::saveXml ( QXmlStreamWriter & writer) const
virtual

Save entire model as xml into stream.

Implements DocumentModelAbstractBase.

Definition at line 106 of file DocumentModelLoadViews.cpp.

107{
108 LOG4CPP_INFO_S ((*mainCat)) << "DocumentModelLoadViews::saveXml";
109
110 writer.writeStartElement(DOCUMENT_SERIALIZE_LOAD_VIEWS);
111 writer.writeAttribute(DOCUMENT_SERIALIZE_LOAD_VIEWS_GRIDLINES, m_gridlines ?
114 writer.writeAttribute(DOCUMENT_SERIALIZE_LOAD_VIEWS_GUIDELINES, m_guidelines ?
117 writer.writeEndElement();
118}
const QString DOCUMENT_SERIALIZE_BOOL_FALSE

◆ setGridlines()

void DocumentModelLoadViews::setGridlines ( bool gridlines)

Set method for gridlines.

Definition at line 120 of file DocumentModelLoadViews.cpp.

121{
122 m_gridlines = gridlines;
123}

◆ setGuidelines()

void DocumentModelLoadViews::setGuidelines ( bool guidelines)

Set method for guidelines.

Definition at line 125 of file DocumentModelLoadViews.cpp.

126{
127 m_guidelines = guidelines;
128}

The documentation for this class was generated from the following files: