! Loads from XML. */
| 197 | Loads from XML. |
| 198 | */ |
| 199 | bool MQTTTopic::load(XmlStreamReader* reader, bool preview) { |
| 200 | removeColumns(0, columnCount()); |
| 201 | if (!readBasicAttributes(reader)) |
| 202 | return false; |
| 203 | |
| 204 | bool isFilterPrepared = false; |
| 205 | QString separator; |
| 206 | |
| 207 | QString attributeWarning = i18n("Attribute '%1' missing or empty, default value is used"); |
| 208 | QXmlStreamAttributes attribs; |
| 209 | QString str; |
| 210 | |
| 211 | while (!reader->atEnd()) { |
| 212 | reader->readNext(); |
| 213 | if (reader->isEndElement() && reader->name() == QLatin1String("MQTTTopic")) |
| 214 | break; |
| 215 | |
| 216 | if (!reader->isStartElement()) |
| 217 | continue; |
| 218 | |
| 219 | if (reader->name() == QLatin1String("comment")) { |
| 220 | if (!readCommentElement(reader)) |
| 221 | return false; |
| 222 | } else if (reader->name() == QLatin1String("general")) { |
| 223 | attribs = reader->attributes(); |
| 224 | |
| 225 | str = attribs.value(QStringLiteral("topicName")).toString(); |
| 226 | if (str.isEmpty()) |
| 227 | reader->raiseWarning(attributeWarning.arg(QStringLiteral("'topicName'"))); |
| 228 | else { |
| 229 | m_topicName = str; |
| 230 | setName(str); |
| 231 | } |
| 232 | |
| 233 | str = attribs.value(QStringLiteral("filterPrepared")).toString(); |
| 234 | if (str.isEmpty()) |
| 235 | reader->raiseWarning(attributeWarning.arg(QStringLiteral("'filterPrepared'"))); |
| 236 | else { |
| 237 | isFilterPrepared = str.toInt(); |
| 238 | } |
| 239 | |
| 240 | str = attribs.value(QStringLiteral("filterSeparator")).toString(); |
| 241 | if (str.isEmpty()) |
| 242 | reader->raiseWarning(attributeWarning.arg(QStringLiteral("'filterSeparator'"))); |
| 243 | else { |
| 244 | separator = str; |
| 245 | } |
| 246 | |
| 247 | int pufferSize = 0; |
| 248 | str = attribs.value(QStringLiteral("messagePufferSize")).toString(); |
| 249 | if (str.isEmpty()) |
| 250 | reader->raiseWarning(attributeWarning.arg(QStringLiteral("'messagePufferSize'"))); |
| 251 | else |
| 252 | pufferSize = str.toInt(); |
| 253 | for (int i = 0; i < pufferSize; ++i) { |
| 254 | str = attribs.value(QStringLiteral("message") + QString::number(i)).toString(); |
| 255 | if (str.isEmpty()) |
| 256 | reader->raiseWarning(attributeWarning.arg(QStringLiteral("'message") + QString::number(i) + QLatin1Char('\''))); |
nothing calls this directly
no test coverage detected