7 #include "CmdMediator.h"
8 #include "DocumentModelGeneral.h"
9 #include "DocumentSerialize.h"
13 #include <QTextStream>
14 #include "QtToString.h"
15 #include <QXmlStreamWriter>
19 const int DEFAULT_CURSOR_SIZE = 3;
20 const int DEFAULT_EXTRA_PRECISION = 1;
23 m_cursorSize (DEFAULT_CURSOR_SIZE),
24 m_extraPrecision (DEFAULT_EXTRA_PRECISION)
26 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
27 settings.beginGroup (SETTINGS_GROUP_GENERAL);
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();
37 m_cursorSize (document.modelGeneral().cursorSize()),
38 m_extraPrecision (document.modelGeneral().extraPrecision())
43 m_cursorSize (other.cursorSize()),
44 m_extraPrecision (other.extraPrecision())
63 return m_extraPrecision;
68 LOG4CPP_INFO_S ((*mainCat)) <<
"DocumentModelGeneral::loadXml";
72 QXmlStreamAttributes attributes = reader.attributes();
74 if (attributes.hasAttribute(DOCUMENT_SERIALIZE_GENERAL_CURSOR_SIZE) &&
75 attributes.hasAttribute(DOCUMENT_SERIALIZE_GENERAL_EXTRA_PRECISION)) {
77 setCursorSize (attributes.value(DOCUMENT_SERIALIZE_GENERAL_CURSOR_SIZE).toInt());
78 setExtraPrecision (attributes.value(DOCUMENT_SERIALIZE_GENERAL_EXTRA_PRECISION).toInt());
81 while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
82 (reader.name() != DOCUMENT_SERIALIZE_GENERAL &&
83 reader.name() != DOCUMENT_SERIALIZE_COMMON)){
84 loadNextFromReader(reader);
93 reader.raiseError (QObject::tr (
"Cannot read general data"));
98 QTextStream &str)
const
100 str << indentation <<
"DocumentModelGeneral\n";
102 indentation += INDENTATION_DELTA;
104 str << indentation <<
"cursorSize=" << m_cursorSize <<
"\n";
105 str << indentation <<
"extraPrecision=" << m_extraPrecision <<
"\n";
110 LOG4CPP_INFO_S ((*mainCat)) <<
"DocumentModelGeneral::saveXml";
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();
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.