1 #include "CmdMediator.h"
2 #include "DocumentModelGeneral.h"
3 #include "DocumentSerialize.h"
7 #include "QtToString.h"
8 #include <QXmlStreamWriter>
12 const int DEFAULT_CURSOR_SIZE = 3;
13 const int DEFAULT_EXTRA_PRECISION = 1;
16 m_cursorSize (DEFAULT_CURSOR_SIZE),
17 m_extraPrecision (DEFAULT_EXTRA_PRECISION)
19 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
20 settings.beginGroup (SETTINGS_GROUP_GENERAL);
22 m_cursorSize = settings.value (SETTINGS_GENERAL_CURSOR_SIZE,
23 QVariant (DEFAULT_CURSOR_SIZE)).toInt();
24 m_extraPrecision = settings.value (SETTINGS_GENERAL_EXTRA_PRECISION,
25 QVariant (DEFAULT_EXTRA_PRECISION)).toInt();
30 m_cursorSize (document.modelGeneral().cursorSize()),
31 m_extraPrecision (document.modelGeneral().extraPrecision())
36 m_cursorSize (other.cursorSize()),
37 m_extraPrecision (other.extraPrecision())
56 return m_extraPrecision;
61 LOG4CPP_INFO_S ((*mainCat)) <<
"DocumentModelGeneral::loadXml";
65 QXmlStreamAttributes attributes = reader.attributes();
67 if (attributes.hasAttribute(DOCUMENT_SERIALIZE_GENERAL_CURSOR_SIZE) &&
68 attributes.hasAttribute(DOCUMENT_SERIALIZE_GENERAL_EXTRA_PRECISION)) {
70 setCursorSize (attributes.value(DOCUMENT_SERIALIZE_GENERAL_CURSOR_SIZE).toInt());
71 setExtraPrecision (attributes.value(DOCUMENT_SERIALIZE_GENERAL_EXTRA_PRECISION).toInt());
74 while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
75 (reader.name() != DOCUMENT_SERIALIZE_GENERAL &&
76 reader.name() != DOCUMENT_SERIALIZE_COMMON)){
77 loadNextFromReader(reader);
86 reader.raiseError (
"Cannot read general data");
91 QTextStream &str)
const
93 str << indentation <<
"DocumentModelGeneral\n";
95 indentation += INDENTATION_DELTA;
97 str << indentation <<
"cursorSize=" << m_cursorSize <<
"\n";
98 str << indentation <<
"extraPrecision=" << m_extraPrecision <<
"\n";
103 LOG4CPP_INFO_S ((*mainCat)) <<
"DocumentModelGeneral::saveXml";
105 writer.writeStartElement(DOCUMENT_SERIALIZE_GENERAL);
106 writer.writeAttribute(DOCUMENT_SERIALIZE_GENERAL_CURSOR_SIZE, QString::number (m_cursorSize));
107 writer.writeAttribute(DOCUMENT_SERIALIZE_GENERAL_EXTRA_PRECISION, QString::number (m_extraPrecision));
108 writer.writeEndElement();
Model for DlgSettingsGeneral and CmdSettingsGeneral.
void setCursorSize(int cursorSize)
Set method for effective cursor size.
int cursorSize() const
Get method for effective cursor size.
DocumentModelGeneral()
Default constructor.
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(...
Storage of one imported image and the data attached to that image.
int extraPrecision() const
Get method for extra digits of precsion.
void setExtraPrecision(int extraPrecision)
Set method for extra digits of precision.
DocumentModelGeneral & operator=(const DocumentModelGeneral &other)
Assignment constructor.
virtual void saveXml(QXmlStreamWriter &writer) const
Save entire model as xml into stream.