! Loads from XML. */
| 138 | Loads from XML. |
| 139 | */ |
| 140 | bool MQTTSubscription::load(XmlStreamReader* reader, bool preview) { |
| 141 | if (!readBasicAttributes(reader)) |
| 142 | return false; |
| 143 | |
| 144 | QXmlStreamAttributes attribs; |
| 145 | |
| 146 | while (!reader->atEnd()) { |
| 147 | reader->readNext(); |
| 148 | if (reader->isEndElement() && reader->name() == QLatin1String("MQTTSubscription")) |
| 149 | break; |
| 150 | |
| 151 | if (!reader->isStartElement()) |
| 152 | continue; |
| 153 | |
| 154 | if (reader->name() == QLatin1String("comment")) { |
| 155 | if (!readCommentElement(reader)) |
| 156 | return false; |
| 157 | } else if (reader->name() == QLatin1String("general")) { |
| 158 | attribs = reader->attributes(); |
| 159 | m_subscriptionName = attribs.value(QStringLiteral("subscriptionName")).toString(); |
| 160 | } else if (reader->name() == QLatin1String("MQTTTopic")) { |
| 161 | auto* topic = new MQTTTopic(QString(), this, false); |
| 162 | if (!topic->load(reader, preview)) { |
| 163 | delete topic; |
| 164 | return false; |
| 165 | } |
| 166 | addChildFast(topic); |
| 167 | } else { // unknown element |
| 168 | reader->raiseWarning(i18n("unknown element '%1'", reader->name().toString())); |
| 169 | if (!reader->skipToEndElement()) |
| 170 | return false; |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | Q_EMIT loaded(this->subscriptionName()); |
| 175 | return !reader->hasError(); |
| 176 | } |
nothing calls this directly
no test coverage detected