! Loads from XML. */
| 1184 | Loads from XML. |
| 1185 | */ |
| 1186 | bool MQTTClient::load(XmlStreamReader* reader, bool preview) { |
| 1187 | if (!readBasicAttributes(reader)) |
| 1188 | return false; |
| 1189 | |
| 1190 | QString attributeWarning = i18n("Attribute '%1' missing or empty, default value is used"); |
| 1191 | QXmlStreamAttributes attribs; |
| 1192 | QString str; |
| 1193 | |
| 1194 | while (!reader->atEnd()) { |
| 1195 | reader->readNext(); |
| 1196 | if (reader->isEndElement() && reader->name() == QLatin1String("MQTTClient")) |
| 1197 | break; |
| 1198 | |
| 1199 | if (!reader->isStartElement()) |
| 1200 | continue; |
| 1201 | |
| 1202 | if (reader->name() == QLatin1String("comment")) { |
| 1203 | if (!readCommentElement(reader)) |
| 1204 | return false; |
| 1205 | } else if (reader->name() == QLatin1String("general")) { |
| 1206 | attribs = reader->attributes(); |
| 1207 | |
| 1208 | str = attribs.value(QStringLiteral("subscriptionCount")).toString(); |
| 1209 | if (str.isEmpty()) |
| 1210 | reader->raiseWarning(attributeWarning.arg(QStringLiteral("'subscriptionCount'"))); |
| 1211 | else |
| 1212 | m_subscriptionCountToLoad = str.toInt(); |
| 1213 | |
| 1214 | str = attribs.value(QStringLiteral("keepValues")).toString(); |
| 1215 | if (str.isEmpty()) |
| 1216 | reader->raiseWarning(attributeWarning.arg(QStringLiteral("'keepValues'"))); |
| 1217 | else |
| 1218 | m_keepNValues = str.toInt(); |
| 1219 | |
| 1220 | str = attribs.value(QStringLiteral("updateType")).toString(); |
| 1221 | if (str.isEmpty()) |
| 1222 | reader->raiseWarning(attributeWarning.arg(QStringLiteral("'updateType'"))); |
| 1223 | else |
| 1224 | m_updateType = static_cast<UpdateType>(str.toInt()); |
| 1225 | |
| 1226 | str = attribs.value(QStringLiteral("readingType")).toString(); |
| 1227 | if (str.isEmpty()) |
| 1228 | reader->raiseWarning(attributeWarning.arg(QStringLiteral("'readingType'"))); |
| 1229 | else |
| 1230 | m_readingType = static_cast<ReadingType>(str.toInt()); |
| 1231 | |
| 1232 | if (m_updateType == UpdateType::TimeInterval) { |
| 1233 | str = attribs.value(QStringLiteral("updateInterval")).toString(); |
| 1234 | if (str.isEmpty()) |
| 1235 | reader->raiseWarning(attributeWarning.arg(QStringLiteral("'updateInterval'"))); |
| 1236 | else |
| 1237 | m_updateInterval = str.toInt(); |
| 1238 | } |
| 1239 | |
| 1240 | if (m_readingType != ReadingType::TillEnd) { |
| 1241 | str = attribs.value(QStringLiteral("sampleSize")).toString(); |
| 1242 | if (str.isEmpty()) |
| 1243 | reader->raiseWarning(attributeWarning.arg(QStringLiteral("'sampleSize'"))); |
nothing calls this directly
no test coverage detected