Engauge Digitizer  2
Public Member Functions | List of all members
DocumentModelGeneral Class Reference

Model for DlgSettingsGeneral and CmdSettingsGeneral. More...

#include <DocumentModelGeneral.h>

Inheritance diagram for DocumentModelGeneral:
Inheritance graph
Collaboration diagram for DocumentModelGeneral:
Collaboration graph

Public Member Functions

 DocumentModelGeneral ()
 Default constructor. More...
 
 DocumentModelGeneral (const Document &document)
 Initial constructor from Document. More...
 
 DocumentModelGeneral (const DocumentModelGeneral &other)
 Copy constructor. More...
 
DocumentModelGeneraloperator= (const DocumentModelGeneral &other)
 Assignment constructor. More...
 
int cursorSize () const
 Get method for effective cursor size. More...
 
int extraPrecision () const
 Get method for extra digits of precsion. More...
 
virtual void loadXml (QXmlStreamReader &reader)
 Load model from serialized xml. More...
 
void printStream (QString indentation, QTextStream &str) const
 Debugging method that supports print method of this class and printStream method of some other class(es) More...
 
virtual void saveXml (QXmlStreamWriter &writer) const
 Save entire model as xml into stream. More...
 
void setCursorSize (int cursorSize)
 Set method for effective cursor size. More...
 
void setExtraPrecision (int extraPrecision)
 Set method for extra digits of precision. More...
 
- Public Member Functions inherited from DocumentModelAbstractBase
 DocumentModelAbstractBase ()
 Single constructor. More...
 
virtual ~DocumentModelAbstractBase ()
 Single destructor. More...
 

Additional Inherited Members

Detailed Description

Model for DlgSettingsGeneral and CmdSettingsGeneral.

Definition at line 15 of file DocumentModelGeneral.h.

Constructor & Destructor Documentation

◆ DocumentModelGeneral() [1/3]

DocumentModelGeneral::DocumentModelGeneral ( )

Default constructor.

Definition at line 21 of file DocumentModelGeneral.cpp.

22  :
23  m_cursorSize (DEFAULT_CURSOR_SIZE),
24  m_extraPrecision (DEFAULT_EXTRA_PRECISION)
25 {
26  QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
27  settings.beginGroup (SETTINGS_GROUP_GENERAL);
28 
29  m_cursorSize = settings.value (SETTINGS_GENERAL_CURSOR_SIZE,
30  QVariant (DEFAULT_CURSOR_SIZE)).toInt();
31  m_extraPrecision = settings.value (SETTINGS_GENERAL_EXTRA_PRECISION,
32  QVariant (DEFAULT_EXTRA_PRECISION)).toInt();
33  settings.endGroup ();

◆ DocumentModelGeneral() [2/3]

DocumentModelGeneral::DocumentModelGeneral ( const Document document)

Initial constructor from Document.

Definition at line 35 of file DocumentModelGeneral.cpp.

36  :
37  m_cursorSize (document.modelGeneral().cursorSize()),
38  m_extraPrecision (document.modelGeneral().extraPrecision())
39 {

◆ DocumentModelGeneral() [3/3]

DocumentModelGeneral::DocumentModelGeneral ( const DocumentModelGeneral other)

Copy constructor.

Definition at line 41 of file DocumentModelGeneral.cpp.

42  :
43  m_cursorSize (other.cursorSize()),
44  m_extraPrecision (other.extraPrecision())
45 {

Member Function Documentation

◆ cursorSize()

int DocumentModelGeneral::cursorSize ( ) const

Get method for effective cursor size.

Definition at line 55 of file DocumentModelGeneral.cpp.

57 {
58  return m_cursorSize;

◆ extraPrecision()

int DocumentModelGeneral::extraPrecision ( ) const

Get method for extra digits of precsion.

Definition at line 60 of file DocumentModelGeneral.cpp.

62 {
63  return m_extraPrecision;

◆ loadXml()

void DocumentModelGeneral::loadXml ( QXmlStreamReader &  reader)
virtual

Load model from serialized xml.

Implements DocumentModelAbstractBase.

Definition at line 65 of file DocumentModelGeneral.cpp.

67 {
68  LOG4CPP_INFO_S ((*mainCat)) << "DocumentModelGeneral::loadXml";
69 
70  bool success = true;
71 
72  QXmlStreamAttributes attributes = reader.attributes();
73 
74  if (attributes.hasAttribute(DOCUMENT_SERIALIZE_GENERAL_CURSOR_SIZE) &&
75  attributes.hasAttribute(DOCUMENT_SERIALIZE_GENERAL_EXTRA_PRECISION)) {
76 
77  setCursorSize (attributes.value(DOCUMENT_SERIALIZE_GENERAL_CURSOR_SIZE).toInt());
79 
80  // Read until end of this subtree
81  while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
82  (reader.name() != DOCUMENT_SERIALIZE_GENERAL &&
83  reader.name() != DOCUMENT_SERIALIZE_COMMON)){
84  loadNextFromReader(reader);
85  if (reader.atEnd()) {
86  success = false;
87  break;
88  }
89  }
90  }
91 
92  if (!success) {
93  reader.raiseError (QObject::tr ("Cannot read general data"));
94  }

◆ operator=()

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

Assignment constructor.

Definition at line 47 of file DocumentModelGeneral.cpp.

49 {
50  m_cursorSize = other.cursorSize();
51  m_extraPrecision = other.extraPrecision();
52 
53  return *this;

◆ printStream()

void DocumentModelGeneral::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 96 of file DocumentModelGeneral.cpp.

99 {
100  str << indentation << "DocumentModelGeneral\n";
101 
102  indentation += INDENTATION_DELTA;
103 
104  str << indentation << "cursorSize=" << m_cursorSize << "\n";
105  str << indentation << "extraPrecision=" << m_extraPrecision << "\n";

◆ saveXml()

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

Save entire model as xml into stream.

Implements DocumentModelAbstractBase.

Definition at line 107 of file DocumentModelGeneral.cpp.

109 {
110  LOG4CPP_INFO_S ((*mainCat)) << "DocumentModelGeneral::saveXml";
111 
112  writer.writeStartElement(DOCUMENT_SERIALIZE_GENERAL);
113  writer.writeAttribute(DOCUMENT_SERIALIZE_GENERAL_CURSOR_SIZE, QString::number (m_cursorSize));
114  writer.writeAttribute(DOCUMENT_SERIALIZE_GENERAL_EXTRA_PRECISION, QString::number (m_extraPrecision));
115  writer.writeEndElement();

◆ setCursorSize()

void DocumentModelGeneral::setCursorSize ( int  cursorSize)

Set method for effective cursor size.

Definition at line 117 of file DocumentModelGeneral.cpp.

119 {
120  m_cursorSize = cursorSize;

◆ setExtraPrecision()

void DocumentModelGeneral::setExtraPrecision ( int  extraPrecision)

Set method for extra digits of precision.

Definition at line 122 of file DocumentModelGeneral.cpp.

124 {
125  m_extraPrecision = extraPrecision;

The documentation for this class was generated from the following files:
DOCUMENT_SERIALIZE_GENERAL_EXTRA_PRECISION
const QString DOCUMENT_SERIALIZE_GENERAL_EXTRA_PRECISION
Document::modelGeneral
DocumentModelGeneral modelGeneral() const
Get method for DocumentModelGeneral.
Definition: Document.cpp:723
DOCUMENT_SERIALIZE_GENERAL_CURSOR_SIZE
const QString DOCUMENT_SERIALIZE_GENERAL_CURSOR_SIZE
DEFAULT_EXTRA_PRECISION
const int DEFAULT_EXTRA_PRECISION
Definition: DocumentModelGeneral.cpp:19
SETTINGS_DIGITIZER
const QString SETTINGS_DIGITIZER
DocumentModelGeneral::cursorSize
int cursorSize() const
Get method for effective cursor size.
Definition: DocumentModelGeneral.cpp:55
DOCUMENT_SERIALIZE_COMMON
const QString DOCUMENT_SERIALIZE_COMMON
SETTINGS_GROUP_GENERAL
const QString SETTINGS_GROUP_GENERAL
DocumentModelGeneral::setExtraPrecision
void setExtraPrecision(int extraPrecision)
Set method for extra digits of precision.
Definition: DocumentModelGeneral.cpp:122
DocumentModelGeneral::extraPrecision
int extraPrecision() const
Get method for extra digits of precsion.
Definition: DocumentModelGeneral.cpp:60
LOG4CPP_INFO_S
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
SETTINGS_GENERAL_EXTRA_PRECISION
const QString SETTINGS_GENERAL_EXTRA_PRECISION
DOCUMENT_SERIALIZE_GENERAL
const QString DOCUMENT_SERIALIZE_GENERAL
SETTINGS_ENGAUGE
const QString SETTINGS_ENGAUGE
DEFAULT_CURSOR_SIZE
const int DEFAULT_CURSOR_SIZE
Definition: DocumentModelGeneral.cpp:18
DocumentModelGeneral::setCursorSize
void setCursorSize(int cursorSize)
Set method for effective cursor size.
Definition: DocumentModelGeneral.cpp:117
SETTINGS_GENERAL_CURSOR_SIZE
const QString SETTINGS_GENERAL_CURSOR_SIZE
mainCat
log4cpp::Category * mainCat
Definition: Logger.cpp:14
INDENTATION_DELTA
const QString INDENTATION_DELTA
loadNextFromReader
QXmlStreamReader::TokenType loadNextFromReader(QXmlStreamReader &reader)
Load next token from xml reader.
Definition: Xml.cpp:14