Changeset View
Changeset View
Standalone View
Standalone View
imagelib/kpDocumentMetaInfo.cpp
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | |||||
55 | // public static | 55 | // public static | ||
56 | const int kpDocumentMetaInfo::MaxOffset = (4000/*big image*/ * 100)/*a very big image*/; | 56 | const int kpDocumentMetaInfo::MaxOffset = (4000/*big image*/ * 100)/*a very big image*/; | ||
57 | const int kpDocumentMetaInfo::MinOffset = -kpDocumentMetaInfo::MaxOffset; | 57 | const int kpDocumentMetaInfo::MinOffset = -kpDocumentMetaInfo::MaxOffset; | ||
58 | 58 | | |||
59 | //--------------------------------------------------------------------- | 59 | //--------------------------------------------------------------------- | ||
60 | 60 | | |||
61 | struct kpDocumentMetaInfoPrivate | 61 | struct kpDocumentMetaInfoPrivate | ||
62 | { | 62 | { | ||
63 | int m_dotsPerMeterX, m_dotsPerMeterY; | 63 | int m_dotsPerMeterX{}, m_dotsPerMeterY{}; | ||
64 | QPoint m_offset; | 64 | QPoint m_offset; | ||
65 | 65 | | |||
66 | QMap <QString, QString> m_textMap; | 66 | QMap <QString, QString> m_textMap; | ||
67 | }; | 67 | }; | ||
68 | 68 | | |||
69 | //--------------------------------------------------------------------- | 69 | //--------------------------------------------------------------------- | ||
70 | 70 | | |||
71 | // public | 71 | // public | ||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | 114 | { | |||
115 | return !(*this == rhs); | 115 | return !(*this == rhs); | ||
116 | } | 116 | } | ||
117 | 117 | | |||
118 | //--------------------------------------------------------------------- | 118 | //--------------------------------------------------------------------- | ||
119 | 119 | | |||
120 | // public | 120 | // public | ||
121 | kpDocumentMetaInfo &kpDocumentMetaInfo::operator= (const kpDocumentMetaInfo &rhs) | 121 | kpDocumentMetaInfo &kpDocumentMetaInfo::operator= (const kpDocumentMetaInfo &rhs) | ||
122 | { | 122 | { | ||
123 | if (this == &rhs) | 123 | if (this == &rhs) { | ||
124 | return *this; | 124 | return *this; | ||
125 | } | ||||
125 | 126 | | |||
126 | d->m_dotsPerMeterX = rhs.dotsPerMeterX (); | 127 | d->m_dotsPerMeterX = rhs.dotsPerMeterX (); | ||
127 | d->m_dotsPerMeterY = rhs.dotsPerMeterY (); | 128 | d->m_dotsPerMeterY = rhs.dotsPerMeterY (); | ||
128 | d->m_offset = rhs.offset (); | 129 | d->m_offset = rhs.offset (); | ||
129 | d->m_textMap = rhs.textMap (); | 130 | d->m_textMap = rhs.textMap (); | ||
130 | 131 | | |||
131 | return *this; | 132 | return *this; | ||
132 | } | 133 | } | ||
133 | 134 | | |||
134 | //--------------------------------------------------------------------- | 135 | //--------------------------------------------------------------------- | ||
135 | 136 | | |||
136 | // public | 137 | // public | ||
137 | void kpDocumentMetaInfo::printDebug (const QString &prefix) const | 138 | void kpDocumentMetaInfo::printDebug (const QString &prefix) const | ||
138 | { | 139 | { | ||
139 | const QString usedPrefix = !prefix.isEmpty() ? QString(prefix + QLatin1String(":")) : QString(); | 140 | const QString usedPrefix = !prefix.isEmpty() ? QString(prefix + QLatin1String(":")) : QString(); | ||
140 | 141 | | |||
141 | qCDebug(kpLogImagelib) << usedPrefix; | 142 | qCDebug(kpLogImagelib) << usedPrefix; | ||
142 | 143 | | |||
143 | qCDebug(kpLogImagelib) << "dotsPerMeter X=" << dotsPerMeterX () | 144 | qCDebug(kpLogImagelib) << "dotsPerMeter X=" << dotsPerMeterX () | ||
144 | << " Y=" << dotsPerMeterY () | 145 | << " Y=" << dotsPerMeterY () | ||
145 | << " offset=" << offset () << endl; | 146 | << " offset=" << offset (); | ||
146 | 147 | | |||
147 | QList <QString> keyList = textKeys (); | 148 | QList <QString> keyList = textKeys (); | ||
148 | for (QList <QString>::const_iterator it = keyList.constBegin (); | 149 | for (QList <QString>::const_iterator it = keyList.constBegin (); | ||
149 | it != keyList.constEnd (); | 150 | it != keyList.constEnd (); | ||
150 | ++it) | 151 | ++it) | ||
151 | { | 152 | { | ||
152 | qCDebug(kpLogImagelib) << "key=" << (*it) | 153 | qCDebug(kpLogImagelib) << "key=" << (*it) | ||
153 | << " text=" << text (*it) | 154 | << " text=" << text (*it); | ||
154 | << endl; | | |||
155 | } | 155 | } | ||
156 | 156 | | |||
157 | qCDebug(kpLogImagelib) << usedPrefix << "ENDS"; | 157 | qCDebug(kpLogImagelib) << usedPrefix << "ENDS"; | ||
158 | } | 158 | } | ||
159 | 159 | | |||
160 | //--------------------------------------------------------------------- | 160 | //--------------------------------------------------------------------- | ||
161 | 161 | | |||
162 | // public | 162 | // public | ||
163 | kpCommandSize::SizeType kpDocumentMetaInfo::size () const | 163 | kpCommandSize::SizeType kpDocumentMetaInfo::size () const | ||
164 | { | 164 | { | ||
165 | kpCommandSize::SizeType ret = 0; | 165 | kpCommandSize::SizeType ret = 0; | ||
166 | 166 | | |||
167 | foreach (const QString &key, d->m_textMap.keys ()) | 167 | for (const auto &key : d->m_textMap.keys ()) | ||
168 | { | 168 | { | ||
169 | ret += kpCommandSize::StringSize (key) + | 169 | ret += kpCommandSize::StringSize (key) + | ||
170 | kpCommandSize::StringSize (d->m_textMap [key]); | 170 | kpCommandSize::StringSize (d->m_textMap [key]); | ||
171 | } | 171 | } | ||
172 | 172 | | |||
173 | // We don't know what the QMap size overhead is so overestimate the size | 173 | // We don't know what the QMap size overhead is so overestimate the size | ||
174 | // rather than underestimating it. | 174 | // rather than underestimating it. | ||
175 | // LOTODO: Find the proper size in bytes. | 175 | // LOTODO: Find the proper size in bytes. | ||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Line(s) | 256 | { | |||
257 | return d->m_textMap.keys (); | 257 | return d->m_textMap.keys (); | ||
258 | } | 258 | } | ||
259 | 259 | | |||
260 | //--------------------------------------------------------------------- | 260 | //--------------------------------------------------------------------- | ||
261 | 261 | | |||
262 | // public | 262 | // public | ||
263 | QString kpDocumentMetaInfo::text (const QString &key) const | 263 | QString kpDocumentMetaInfo::text (const QString &key) const | ||
264 | { | 264 | { | ||
265 | if (key.isEmpty ()) | 265 | if (key.isEmpty ()) { | ||
266 | return QString (); | 266 | return {}; | ||
267 | } | ||||
267 | 268 | | |||
268 | return d->m_textMap [key]; | 269 | return d->m_textMap [key]; | ||
269 | } | 270 | } | ||
270 | 271 | | |||
271 | //--------------------------------------------------------------------- | 272 | //--------------------------------------------------------------------- | ||
272 | 273 | | |||
273 | // public | 274 | // public | ||
274 | void kpDocumentMetaInfo::setText (const QString &key, const QString &value) | 275 | void kpDocumentMetaInfo::setText (const QString &key, const QString &value) | ||
275 | { | 276 | { | ||
276 | if (key.isEmpty ()) | 277 | if (key.isEmpty ()) { | ||
277 | return; | 278 | return; | ||
279 | } | ||||
278 | 280 | | |||
279 | d->m_textMap [key] = value; | 281 | d->m_textMap [key] = value; | ||
280 | } | 282 | } | ||
281 | 283 | | |||
282 | //--------------------------------------------------------------------- | 284 | //--------------------------------------------------------------------- |