| 195 | } |
| 196 | |
| 197 | bool Note::load(XmlStreamReader* reader, bool preview) { |
| 198 | Q_D(Note); |
| 199 | |
| 200 | if (!reader->isStartElement() || reader->name() != QLatin1String("note")) { |
| 201 | reader->raiseError(i18n("no note element found")); |
| 202 | return false; |
| 203 | } |
| 204 | |
| 205 | if (!readBasicAttributes(reader)) |
| 206 | return false; |
| 207 | |
| 208 | QXmlStreamAttributes attribs; |
| 209 | QString str; |
| 210 | |
| 211 | while (!reader->atEnd()) { |
| 212 | reader->readNext(); |
| 213 | if (reader->isEndElement() && reader->name() == QLatin1String("note")) |
| 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 (!preview && reader->name() == QLatin1String("background")) { |
| 223 | attribs = reader->attributes(); |
| 224 | READ_QCOLOR(d->backgroundColor); |
| 225 | } else if (!preview && reader->name() == QLatin1String("text")) { |
| 226 | attribs = reader->attributes(); |
| 227 | READ_QCOLOR(d->textColor); |
| 228 | READ_QFONT(d->textFont); |
| 229 | d->text = attribs.value(QStringLiteral("text")).toString(); |
| 230 | } else { // unknown element |
| 231 | reader->raiseUnknownElementWarning(); |
| 232 | if (!reader->skipToEndElement()) |
| 233 | return false; |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | return true; |
| 238 | } |