| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2020 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the tools applications of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
| 21 | ** included in the packaging of this file. Please review the following |
| 22 | ** information to ensure the GNU General Public License requirements will |
| 23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
| 24 | ** |
| 25 | ** $QT_END_LICENSE$ |
| 26 | ** |
| 27 | ****************************************************************************/ |
| 28 | |
| 29 | // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT! |
| 30 | |
| 31 | #include "ui4.h" |
| 32 | |
| 33 | |
| 34 | QT_BEGIN_NAMESPACE |
| 35 | #ifdef QFORMINTERNAL_NAMESPACE |
| 36 | using namespace QFormInternal; |
| 37 | #endif |
| 38 | |
| 39 | /******************************************************************************* |
| 40 | ** Implementations |
| 41 | */ |
| 42 | |
| 43 | DomUI::~DomUI() |
| 44 | { |
| 45 | delete m_widget; |
| 46 | delete m_layoutDefault; |
| 47 | delete m_layoutFunction; |
| 48 | delete m_customWidgets; |
| 49 | delete m_tabStops; |
| 50 | delete m_includes; |
| 51 | delete m_resources; |
| 52 | delete m_connections; |
| 53 | delete m_designerdata; |
| 54 | delete m_slots; |
| 55 | delete m_buttonGroups; |
| 56 | } |
| 57 | |
| 58 | void DomUI::read(QXmlStreamReader &reader) |
| 59 | { |
| 60 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 61 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 62 | const auto name = attribute.name(); |
| 63 | if (name == QLatin1String("version" )) { |
| 64 | setAttributeVersion(attribute.value().toString()); |
| 65 | continue; |
| 66 | } |
| 67 | if (name == QLatin1String("language" )) { |
| 68 | setAttributeLanguage(attribute.value().toString()); |
| 69 | continue; |
| 70 | } |
| 71 | if (name == QLatin1String("displayname" )) { |
| 72 | setAttributeDisplayname(attribute.value().toString()); |
| 73 | continue; |
| 74 | } |
| 75 | if (name == QLatin1String("idbasedtr" )) { |
| 76 | setAttributeIdbasedtr(attribute.value() == QLatin1String("true" )); |
| 77 | continue; |
| 78 | } |
| 79 | if (name == QLatin1String("connectslotsbyname" )) { |
| 80 | setAttributeConnectslotsbyname(attribute.value() == QLatin1String("true" )); |
| 81 | continue; |
| 82 | } |
| 83 | if (name == QLatin1String("stdsetdef" )) { |
| 84 | setAttributeStdsetdef(attribute.value().toInt()); |
| 85 | continue; |
| 86 | } |
| 87 | if (name == QLatin1String("stdSetDef" )) { |
| 88 | setAttributeStdSetDef(attribute.value().toInt()); |
| 89 | continue; |
| 90 | } |
| 91 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 92 | } |
| 93 | |
| 94 | while (!reader.hasError()) { |
| 95 | switch (reader.readNext()) { |
| 96 | case QXmlStreamReader::StartElement : { |
| 97 | const auto tag = reader.name(); |
| 98 | if (!tag.compare(QLatin1String("author" ), Qt::CaseInsensitive)) { |
| 99 | setElementAuthor(reader.readElementText()); |
| 100 | continue; |
| 101 | } |
| 102 | if (!tag.compare(QLatin1String("comment" ), Qt::CaseInsensitive)) { |
| 103 | setElementComment(reader.readElementText()); |
| 104 | continue; |
| 105 | } |
| 106 | if (!tag.compare(QLatin1String("exportmacro" ), Qt::CaseInsensitive)) { |
| 107 | setElementExportMacro(reader.readElementText()); |
| 108 | continue; |
| 109 | } |
| 110 | if (!tag.compare(QLatin1String("class" ), Qt::CaseInsensitive)) { |
| 111 | setElementClass(reader.readElementText()); |
| 112 | continue; |
| 113 | } |
| 114 | if (!tag.compare(QLatin1String("widget" ), Qt::CaseInsensitive)) { |
| 115 | auto *v = new DomWidget(); |
| 116 | v->read(reader); |
| 117 | setElementWidget(v); |
| 118 | continue; |
| 119 | } |
| 120 | if (!tag.compare(QLatin1String("layoutdefault" ), Qt::CaseInsensitive)) { |
| 121 | auto *v = new DomLayoutDefault(); |
| 122 | v->read(reader); |
| 123 | setElementLayoutDefault(v); |
| 124 | continue; |
| 125 | } |
| 126 | if (!tag.compare(QLatin1String("layoutfunction" ), Qt::CaseInsensitive)) { |
| 127 | auto *v = new DomLayoutFunction(); |
| 128 | v->read(reader); |
| 129 | setElementLayoutFunction(v); |
| 130 | continue; |
| 131 | } |
| 132 | if (!tag.compare(QLatin1String("pixmapfunction" ), Qt::CaseInsensitive)) { |
| 133 | setElementPixmapFunction(reader.readElementText()); |
| 134 | continue; |
| 135 | } |
| 136 | if (!tag.compare(QLatin1String("customwidgets" ), Qt::CaseInsensitive)) { |
| 137 | auto *v = new DomCustomWidgets(); |
| 138 | v->read(reader); |
| 139 | setElementCustomWidgets(v); |
| 140 | continue; |
| 141 | } |
| 142 | if (!tag.compare(QLatin1String("tabstops" ), Qt::CaseInsensitive)) { |
| 143 | auto *v = new DomTabStops(); |
| 144 | v->read(reader); |
| 145 | setElementTabStops(v); |
| 146 | continue; |
| 147 | } |
| 148 | if (!tag.compare(QLatin1String("images" ), Qt::CaseInsensitive)) { |
| 149 | qWarning("Omitting deprecated element <images>." ); |
| 150 | reader.skipCurrentElement(); |
| 151 | continue; |
| 152 | } |
| 153 | if (!tag.compare(QLatin1String("includes" ), Qt::CaseInsensitive)) { |
| 154 | auto *v = new DomIncludes(); |
| 155 | v->read(reader); |
| 156 | setElementIncludes(v); |
| 157 | continue; |
| 158 | } |
| 159 | if (!tag.compare(QLatin1String("resources" ), Qt::CaseInsensitive)) { |
| 160 | auto *v = new DomResources(); |
| 161 | v->read(reader); |
| 162 | setElementResources(v); |
| 163 | continue; |
| 164 | } |
| 165 | if (!tag.compare(QLatin1String("connections" ), Qt::CaseInsensitive)) { |
| 166 | auto *v = new DomConnections(); |
| 167 | v->read(reader); |
| 168 | setElementConnections(v); |
| 169 | continue; |
| 170 | } |
| 171 | if (!tag.compare(QLatin1String("designerdata" ), Qt::CaseInsensitive)) { |
| 172 | auto *v = new DomDesignerData(); |
| 173 | v->read(reader); |
| 174 | setElementDesignerdata(v); |
| 175 | continue; |
| 176 | } |
| 177 | if (!tag.compare(QLatin1String("slots" ), Qt::CaseInsensitive)) { |
| 178 | auto *v = new DomSlots(); |
| 179 | v->read(reader); |
| 180 | setElementSlots(v); |
| 181 | continue; |
| 182 | } |
| 183 | if (!tag.compare(QLatin1String("buttongroups" ), Qt::CaseInsensitive)) { |
| 184 | auto *v = new DomButtonGroups(); |
| 185 | v->read(reader); |
| 186 | setElementButtonGroups(v); |
| 187 | continue; |
| 188 | } |
| 189 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 190 | } |
| 191 | break; |
| 192 | case QXmlStreamReader::EndElement : |
| 193 | return; |
| 194 | default : |
| 195 | break; |
| 196 | } |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | void DomUI::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 201 | { |
| 202 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("ui" ) : tagName.toLower()); |
| 203 | |
| 204 | if (hasAttributeVersion()) |
| 205 | writer.writeAttribute(QStringLiteral("version" ), attributeVersion()); |
| 206 | |
| 207 | if (hasAttributeLanguage()) |
| 208 | writer.writeAttribute(QStringLiteral("language" ), attributeLanguage()); |
| 209 | |
| 210 | if (hasAttributeDisplayname()) |
| 211 | writer.writeAttribute(QStringLiteral("displayname" ), attributeDisplayname()); |
| 212 | |
| 213 | if (hasAttributeIdbasedtr()) |
| 214 | writer.writeAttribute(QStringLiteral("idbasedtr" ), (attributeIdbasedtr() ? QLatin1String("true" ) : QLatin1String("false" ))); |
| 215 | |
| 216 | if (hasAttributeConnectslotsbyname()) |
| 217 | writer.writeAttribute(QStringLiteral("connectslotsbyname" ), (attributeConnectslotsbyname() ? QLatin1String("true" ) : QLatin1String("false" ))); |
| 218 | |
| 219 | if (hasAttributeStdsetdef()) |
| 220 | writer.writeAttribute(QStringLiteral("stdsetdef" ), QString::number(attributeStdsetdef())); |
| 221 | |
| 222 | if (hasAttributeStdSetDef()) |
| 223 | writer.writeAttribute(QStringLiteral("stdsetdef" ), QString::number(attributeStdSetDef())); |
| 224 | |
| 225 | if (m_children & Author) |
| 226 | writer.writeTextElement(QStringLiteral("author" ), m_author); |
| 227 | |
| 228 | if (m_children & Comment) |
| 229 | writer.writeTextElement(QStringLiteral("comment" ), m_comment); |
| 230 | |
| 231 | if (m_children & ExportMacro) |
| 232 | writer.writeTextElement(QStringLiteral("exportmacro" ), m_exportMacro); |
| 233 | |
| 234 | if (m_children & Class) |
| 235 | writer.writeTextElement(QStringLiteral("class" ), m_class); |
| 236 | |
| 237 | if (m_children & Widget) |
| 238 | m_widget->write(writer, QStringLiteral("widget" )); |
| 239 | |
| 240 | if (m_children & LayoutDefault) |
| 241 | m_layoutDefault->write(writer, QStringLiteral("layoutdefault" )); |
| 242 | |
| 243 | if (m_children & LayoutFunction) |
| 244 | m_layoutFunction->write(writer, QStringLiteral("layoutfunction" )); |
| 245 | |
| 246 | if (m_children & PixmapFunction) |
| 247 | writer.writeTextElement(QStringLiteral("pixmapfunction" ), m_pixmapFunction); |
| 248 | |
| 249 | if (m_children & CustomWidgets) |
| 250 | m_customWidgets->write(writer, QStringLiteral("customwidgets" )); |
| 251 | |
| 252 | if (m_children & TabStops) |
| 253 | m_tabStops->write(writer, QStringLiteral("tabstops" )); |
| 254 | |
| 255 | if (m_children & Includes) |
| 256 | m_includes->write(writer, QStringLiteral("includes" )); |
| 257 | |
| 258 | if (m_children & Resources) |
| 259 | m_resources->write(writer, QStringLiteral("resources" )); |
| 260 | |
| 261 | if (m_children & Connections) |
| 262 | m_connections->write(writer, QStringLiteral("connections" )); |
| 263 | |
| 264 | if (m_children & Designerdata) |
| 265 | m_designerdata->write(writer, QStringLiteral("designerdata" )); |
| 266 | |
| 267 | if (m_children & Slots) |
| 268 | m_slots->write(writer, QStringLiteral("slots" )); |
| 269 | |
| 270 | if (m_children & ButtonGroups) |
| 271 | m_buttonGroups->write(writer, QStringLiteral("buttongroups" )); |
| 272 | |
| 273 | writer.writeEndElement(); |
| 274 | } |
| 275 | |
| 276 | void DomUI::setElementAuthor(const QString &a) |
| 277 | { |
| 278 | m_children |= Author; |
| 279 | m_author = a; |
| 280 | } |
| 281 | |
| 282 | void DomUI::(const QString &a) |
| 283 | { |
| 284 | m_children |= Comment; |
| 285 | m_comment = a; |
| 286 | } |
| 287 | |
| 288 | void DomUI::setElementExportMacro(const QString &a) |
| 289 | { |
| 290 | m_children |= ExportMacro; |
| 291 | m_exportMacro = a; |
| 292 | } |
| 293 | |
| 294 | void DomUI::setElementClass(const QString &a) |
| 295 | { |
| 296 | m_children |= Class; |
| 297 | m_class = a; |
| 298 | } |
| 299 | |
| 300 | DomWidget *DomUI::takeElementWidget() |
| 301 | { |
| 302 | DomWidget *a = m_widget; |
| 303 | m_widget = nullptr; |
| 304 | m_children ^= Widget; |
| 305 | return a; |
| 306 | } |
| 307 | |
| 308 | void DomUI::setElementWidget(DomWidget *a) |
| 309 | { |
| 310 | delete m_widget; |
| 311 | m_children |= Widget; |
| 312 | m_widget = a; |
| 313 | } |
| 314 | |
| 315 | DomLayoutDefault *DomUI::takeElementLayoutDefault() |
| 316 | { |
| 317 | DomLayoutDefault *a = m_layoutDefault; |
| 318 | m_layoutDefault = nullptr; |
| 319 | m_children ^= LayoutDefault; |
| 320 | return a; |
| 321 | } |
| 322 | |
| 323 | void DomUI::setElementLayoutDefault(DomLayoutDefault *a) |
| 324 | { |
| 325 | delete m_layoutDefault; |
| 326 | m_children |= LayoutDefault; |
| 327 | m_layoutDefault = a; |
| 328 | } |
| 329 | |
| 330 | DomLayoutFunction *DomUI::takeElementLayoutFunction() |
| 331 | { |
| 332 | DomLayoutFunction *a = m_layoutFunction; |
| 333 | m_layoutFunction = nullptr; |
| 334 | m_children ^= LayoutFunction; |
| 335 | return a; |
| 336 | } |
| 337 | |
| 338 | void DomUI::setElementLayoutFunction(DomLayoutFunction *a) |
| 339 | { |
| 340 | delete m_layoutFunction; |
| 341 | m_children |= LayoutFunction; |
| 342 | m_layoutFunction = a; |
| 343 | } |
| 344 | |
| 345 | void DomUI::setElementPixmapFunction(const QString &a) |
| 346 | { |
| 347 | m_children |= PixmapFunction; |
| 348 | m_pixmapFunction = a; |
| 349 | } |
| 350 | |
| 351 | DomCustomWidgets *DomUI::takeElementCustomWidgets() |
| 352 | { |
| 353 | DomCustomWidgets *a = m_customWidgets; |
| 354 | m_customWidgets = nullptr; |
| 355 | m_children ^= CustomWidgets; |
| 356 | return a; |
| 357 | } |
| 358 | |
| 359 | void DomUI::setElementCustomWidgets(DomCustomWidgets *a) |
| 360 | { |
| 361 | delete m_customWidgets; |
| 362 | m_children |= CustomWidgets; |
| 363 | m_customWidgets = a; |
| 364 | } |
| 365 | |
| 366 | DomTabStops *DomUI::takeElementTabStops() |
| 367 | { |
| 368 | DomTabStops *a = m_tabStops; |
| 369 | m_tabStops = nullptr; |
| 370 | m_children ^= TabStops; |
| 371 | return a; |
| 372 | } |
| 373 | |
| 374 | void DomUI::setElementTabStops(DomTabStops *a) |
| 375 | { |
| 376 | delete m_tabStops; |
| 377 | m_children |= TabStops; |
| 378 | m_tabStops = a; |
| 379 | } |
| 380 | |
| 381 | DomIncludes *DomUI::takeElementIncludes() |
| 382 | { |
| 383 | DomIncludes *a = m_includes; |
| 384 | m_includes = nullptr; |
| 385 | m_children ^= Includes; |
| 386 | return a; |
| 387 | } |
| 388 | |
| 389 | void DomUI::setElementIncludes(DomIncludes *a) |
| 390 | { |
| 391 | delete m_includes; |
| 392 | m_children |= Includes; |
| 393 | m_includes = a; |
| 394 | } |
| 395 | |
| 396 | DomResources *DomUI::takeElementResources() |
| 397 | { |
| 398 | DomResources *a = m_resources; |
| 399 | m_resources = nullptr; |
| 400 | m_children ^= Resources; |
| 401 | return a; |
| 402 | } |
| 403 | |
| 404 | void DomUI::setElementResources(DomResources *a) |
| 405 | { |
| 406 | delete m_resources; |
| 407 | m_children |= Resources; |
| 408 | m_resources = a; |
| 409 | } |
| 410 | |
| 411 | DomConnections *DomUI::takeElementConnections() |
| 412 | { |
| 413 | DomConnections *a = m_connections; |
| 414 | m_connections = nullptr; |
| 415 | m_children ^= Connections; |
| 416 | return a; |
| 417 | } |
| 418 | |
| 419 | void DomUI::setElementConnections(DomConnections *a) |
| 420 | { |
| 421 | delete m_connections; |
| 422 | m_children |= Connections; |
| 423 | m_connections = a; |
| 424 | } |
| 425 | |
| 426 | DomDesignerData *DomUI::takeElementDesignerdata() |
| 427 | { |
| 428 | DomDesignerData *a = m_designerdata; |
| 429 | m_designerdata = nullptr; |
| 430 | m_children ^= Designerdata; |
| 431 | return a; |
| 432 | } |
| 433 | |
| 434 | void DomUI::setElementDesignerdata(DomDesignerData *a) |
| 435 | { |
| 436 | delete m_designerdata; |
| 437 | m_children |= Designerdata; |
| 438 | m_designerdata = a; |
| 439 | } |
| 440 | |
| 441 | DomSlots *DomUI::takeElementSlots() |
| 442 | { |
| 443 | DomSlots *a = m_slots; |
| 444 | m_slots = nullptr; |
| 445 | m_children ^= Slots; |
| 446 | return a; |
| 447 | } |
| 448 | |
| 449 | void DomUI::setElementSlots(DomSlots *a) |
| 450 | { |
| 451 | delete m_slots; |
| 452 | m_children |= Slots; |
| 453 | m_slots = a; |
| 454 | } |
| 455 | |
| 456 | DomButtonGroups *DomUI::takeElementButtonGroups() |
| 457 | { |
| 458 | DomButtonGroups *a = m_buttonGroups; |
| 459 | m_buttonGroups = nullptr; |
| 460 | m_children ^= ButtonGroups; |
| 461 | return a; |
| 462 | } |
| 463 | |
| 464 | void DomUI::setElementButtonGroups(DomButtonGroups *a) |
| 465 | { |
| 466 | delete m_buttonGroups; |
| 467 | m_children |= ButtonGroups; |
| 468 | m_buttonGroups = a; |
| 469 | } |
| 470 | |
| 471 | void DomUI::clearElementAuthor() |
| 472 | { |
| 473 | m_children &= ~Author; |
| 474 | } |
| 475 | |
| 476 | void DomUI::() |
| 477 | { |
| 478 | m_children &= ~Comment; |
| 479 | } |
| 480 | |
| 481 | void DomUI::clearElementExportMacro() |
| 482 | { |
| 483 | m_children &= ~ExportMacro; |
| 484 | } |
| 485 | |
| 486 | void DomUI::clearElementClass() |
| 487 | { |
| 488 | m_children &= ~Class; |
| 489 | } |
| 490 | |
| 491 | void DomUI::clearElementWidget() |
| 492 | { |
| 493 | delete m_widget; |
| 494 | m_widget = nullptr; |
| 495 | m_children &= ~Widget; |
| 496 | } |
| 497 | |
| 498 | void DomUI::clearElementLayoutDefault() |
| 499 | { |
| 500 | delete m_layoutDefault; |
| 501 | m_layoutDefault = nullptr; |
| 502 | m_children &= ~LayoutDefault; |
| 503 | } |
| 504 | |
| 505 | void DomUI::clearElementLayoutFunction() |
| 506 | { |
| 507 | delete m_layoutFunction; |
| 508 | m_layoutFunction = nullptr; |
| 509 | m_children &= ~LayoutFunction; |
| 510 | } |
| 511 | |
| 512 | void DomUI::clearElementPixmapFunction() |
| 513 | { |
| 514 | m_children &= ~PixmapFunction; |
| 515 | } |
| 516 | |
| 517 | void DomUI::clearElementCustomWidgets() |
| 518 | { |
| 519 | delete m_customWidgets; |
| 520 | m_customWidgets = nullptr; |
| 521 | m_children &= ~CustomWidgets; |
| 522 | } |
| 523 | |
| 524 | void DomUI::clearElementTabStops() |
| 525 | { |
| 526 | delete m_tabStops; |
| 527 | m_tabStops = nullptr; |
| 528 | m_children &= ~TabStops; |
| 529 | } |
| 530 | |
| 531 | void DomUI::clearElementIncludes() |
| 532 | { |
| 533 | delete m_includes; |
| 534 | m_includes = nullptr; |
| 535 | m_children &= ~Includes; |
| 536 | } |
| 537 | |
| 538 | void DomUI::clearElementResources() |
| 539 | { |
| 540 | delete m_resources; |
| 541 | m_resources = nullptr; |
| 542 | m_children &= ~Resources; |
| 543 | } |
| 544 | |
| 545 | void DomUI::clearElementConnections() |
| 546 | { |
| 547 | delete m_connections; |
| 548 | m_connections = nullptr; |
| 549 | m_children &= ~Connections; |
| 550 | } |
| 551 | |
| 552 | void DomUI::clearElementDesignerdata() |
| 553 | { |
| 554 | delete m_designerdata; |
| 555 | m_designerdata = nullptr; |
| 556 | m_children &= ~Designerdata; |
| 557 | } |
| 558 | |
| 559 | void DomUI::clearElementSlots() |
| 560 | { |
| 561 | delete m_slots; |
| 562 | m_slots = nullptr; |
| 563 | m_children &= ~Slots; |
| 564 | } |
| 565 | |
| 566 | void DomUI::clearElementButtonGroups() |
| 567 | { |
| 568 | delete m_buttonGroups; |
| 569 | m_buttonGroups = nullptr; |
| 570 | m_children &= ~ButtonGroups; |
| 571 | } |
| 572 | |
| 573 | DomIncludes::~DomIncludes() |
| 574 | { |
| 575 | qDeleteAll(m_include); |
| 576 | m_include.clear(); |
| 577 | } |
| 578 | |
| 579 | void DomIncludes::read(QXmlStreamReader &reader) |
| 580 | { |
| 581 | while (!reader.hasError()) { |
| 582 | switch (reader.readNext()) { |
| 583 | case QXmlStreamReader::StartElement : { |
| 584 | const auto tag = reader.name(); |
| 585 | if (!tag.compare(QLatin1String("include" ), Qt::CaseInsensitive)) { |
| 586 | auto *v = new DomInclude(); |
| 587 | v->read(reader); |
| 588 | m_include.append(v); |
| 589 | continue; |
| 590 | } |
| 591 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 592 | } |
| 593 | break; |
| 594 | case QXmlStreamReader::EndElement : |
| 595 | return; |
| 596 | default : |
| 597 | break; |
| 598 | } |
| 599 | } |
| 600 | } |
| 601 | |
| 602 | void DomIncludes::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 603 | { |
| 604 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("includes" ) : tagName.toLower()); |
| 605 | |
| 606 | for (DomInclude *v : m_include) |
| 607 | v->write(writer, QStringLiteral("include" )); |
| 608 | |
| 609 | writer.writeEndElement(); |
| 610 | } |
| 611 | |
| 612 | void DomIncludes::setElementInclude(const QList<DomInclude *> &a) |
| 613 | { |
| 614 | m_children |= Include; |
| 615 | m_include = a; |
| 616 | } |
| 617 | |
| 618 | DomInclude::~DomInclude() = default; |
| 619 | |
| 620 | void DomInclude::read(QXmlStreamReader &reader) |
| 621 | { |
| 622 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 623 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 624 | const auto name = attribute.name(); |
| 625 | if (name == QLatin1String("location" )) { |
| 626 | setAttributeLocation(attribute.value().toString()); |
| 627 | continue; |
| 628 | } |
| 629 | if (name == QLatin1String("impldecl" )) { |
| 630 | setAttributeImpldecl(attribute.value().toString()); |
| 631 | continue; |
| 632 | } |
| 633 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 634 | } |
| 635 | |
| 636 | while (!reader.hasError()) { |
| 637 | switch (reader.readNext()) { |
| 638 | case QXmlStreamReader::StartElement : { |
| 639 | const auto tag = reader.name(); |
| 640 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 641 | } |
| 642 | break; |
| 643 | case QXmlStreamReader::EndElement : |
| 644 | return; |
| 645 | case QXmlStreamReader::Characters : |
| 646 | if (!reader.isWhitespace()) |
| 647 | m_text.append(reader.text().toString()); |
| 648 | break; |
| 649 | default : |
| 650 | break; |
| 651 | } |
| 652 | } |
| 653 | } |
| 654 | |
| 655 | void DomInclude::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 656 | { |
| 657 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("include" ) : tagName.toLower()); |
| 658 | |
| 659 | if (hasAttributeLocation()) |
| 660 | writer.writeAttribute(QStringLiteral("location" ), attributeLocation()); |
| 661 | |
| 662 | if (hasAttributeImpldecl()) |
| 663 | writer.writeAttribute(QStringLiteral("impldecl" ), attributeImpldecl()); |
| 664 | |
| 665 | if (!m_text.isEmpty()) |
| 666 | writer.writeCharacters(m_text); |
| 667 | |
| 668 | writer.writeEndElement(); |
| 669 | } |
| 670 | |
| 671 | DomResources::~DomResources() |
| 672 | { |
| 673 | qDeleteAll(m_include); |
| 674 | m_include.clear(); |
| 675 | } |
| 676 | |
| 677 | void DomResources::read(QXmlStreamReader &reader) |
| 678 | { |
| 679 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 680 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 681 | const auto name = attribute.name(); |
| 682 | if (name == QLatin1String("name" )) { |
| 683 | setAttributeName(attribute.value().toString()); |
| 684 | continue; |
| 685 | } |
| 686 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 687 | } |
| 688 | |
| 689 | while (!reader.hasError()) { |
| 690 | switch (reader.readNext()) { |
| 691 | case QXmlStreamReader::StartElement : { |
| 692 | const auto tag = reader.name(); |
| 693 | if (!tag.compare(QLatin1String("include" ), Qt::CaseInsensitive)) { |
| 694 | auto *v = new DomResource(); |
| 695 | v->read(reader); |
| 696 | m_include.append(v); |
| 697 | continue; |
| 698 | } |
| 699 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 700 | } |
| 701 | break; |
| 702 | case QXmlStreamReader::EndElement : |
| 703 | return; |
| 704 | default : |
| 705 | break; |
| 706 | } |
| 707 | } |
| 708 | } |
| 709 | |
| 710 | void DomResources::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 711 | { |
| 712 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("resources" ) : tagName.toLower()); |
| 713 | |
| 714 | if (hasAttributeName()) |
| 715 | writer.writeAttribute(QStringLiteral("name" ), attributeName()); |
| 716 | |
| 717 | for (DomResource *v : m_include) |
| 718 | v->write(writer, QStringLiteral("include" )); |
| 719 | |
| 720 | writer.writeEndElement(); |
| 721 | } |
| 722 | |
| 723 | void DomResources::setElementInclude(const QList<DomResource *> &a) |
| 724 | { |
| 725 | m_children |= Include; |
| 726 | m_include = a; |
| 727 | } |
| 728 | |
| 729 | DomResource::~DomResource() = default; |
| 730 | |
| 731 | void DomResource::read(QXmlStreamReader &reader) |
| 732 | { |
| 733 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 734 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 735 | const auto name = attribute.name(); |
| 736 | if (name == QLatin1String("location" )) { |
| 737 | setAttributeLocation(attribute.value().toString()); |
| 738 | continue; |
| 739 | } |
| 740 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 741 | } |
| 742 | |
| 743 | while (!reader.hasError()) { |
| 744 | switch (reader.readNext()) { |
| 745 | case QXmlStreamReader::StartElement : { |
| 746 | const auto tag = reader.name(); |
| 747 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 748 | } |
| 749 | break; |
| 750 | case QXmlStreamReader::EndElement : |
| 751 | return; |
| 752 | default : |
| 753 | break; |
| 754 | } |
| 755 | } |
| 756 | } |
| 757 | |
| 758 | void DomResource::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 759 | { |
| 760 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("resource" ) : tagName.toLower()); |
| 761 | |
| 762 | if (hasAttributeLocation()) |
| 763 | writer.writeAttribute(QStringLiteral("location" ), attributeLocation()); |
| 764 | |
| 765 | writer.writeEndElement(); |
| 766 | } |
| 767 | |
| 768 | DomActionGroup::~DomActionGroup() |
| 769 | { |
| 770 | qDeleteAll(m_action); |
| 771 | m_action.clear(); |
| 772 | qDeleteAll(m_actionGroup); |
| 773 | m_actionGroup.clear(); |
| 774 | qDeleteAll(m_property); |
| 775 | m_property.clear(); |
| 776 | qDeleteAll(m_attribute); |
| 777 | m_attribute.clear(); |
| 778 | } |
| 779 | |
| 780 | void DomActionGroup::read(QXmlStreamReader &reader) |
| 781 | { |
| 782 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 783 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 784 | const auto name = attribute.name(); |
| 785 | if (name == QLatin1String("name" )) { |
| 786 | setAttributeName(attribute.value().toString()); |
| 787 | continue; |
| 788 | } |
| 789 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 790 | } |
| 791 | |
| 792 | while (!reader.hasError()) { |
| 793 | switch (reader.readNext()) { |
| 794 | case QXmlStreamReader::StartElement : { |
| 795 | const auto tag = reader.name(); |
| 796 | if (!tag.compare(QLatin1String("action" ), Qt::CaseInsensitive)) { |
| 797 | auto *v = new DomAction(); |
| 798 | v->read(reader); |
| 799 | m_action.append(v); |
| 800 | continue; |
| 801 | } |
| 802 | if (!tag.compare(QLatin1String("actiongroup" ), Qt::CaseInsensitive)) { |
| 803 | auto *v = new DomActionGroup(); |
| 804 | v->read(reader); |
| 805 | m_actionGroup.append(v); |
| 806 | continue; |
| 807 | } |
| 808 | if (!tag.compare(QLatin1String("property" ), Qt::CaseInsensitive)) { |
| 809 | auto *v = new DomProperty(); |
| 810 | v->read(reader); |
| 811 | m_property.append(v); |
| 812 | continue; |
| 813 | } |
| 814 | if (!tag.compare(QLatin1String("attribute" ), Qt::CaseInsensitive)) { |
| 815 | auto *v = new DomProperty(); |
| 816 | v->read(reader); |
| 817 | m_attribute.append(v); |
| 818 | continue; |
| 819 | } |
| 820 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 821 | } |
| 822 | break; |
| 823 | case QXmlStreamReader::EndElement : |
| 824 | return; |
| 825 | default : |
| 826 | break; |
| 827 | } |
| 828 | } |
| 829 | } |
| 830 | |
| 831 | void DomActionGroup::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 832 | { |
| 833 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("actiongroup" ) : tagName.toLower()); |
| 834 | |
| 835 | if (hasAttributeName()) |
| 836 | writer.writeAttribute(QStringLiteral("name" ), attributeName()); |
| 837 | |
| 838 | for (DomAction *v : m_action) |
| 839 | v->write(writer, QStringLiteral("action" )); |
| 840 | |
| 841 | for (DomActionGroup *v : m_actionGroup) |
| 842 | v->write(writer, QStringLiteral("actiongroup" )); |
| 843 | |
| 844 | for (DomProperty *v : m_property) |
| 845 | v->write(writer, QStringLiteral("property" )); |
| 846 | |
| 847 | for (DomProperty *v : m_attribute) |
| 848 | v->write(writer, QStringLiteral("attribute" )); |
| 849 | |
| 850 | writer.writeEndElement(); |
| 851 | } |
| 852 | |
| 853 | void DomActionGroup::setElementAction(const QList<DomAction *> &a) |
| 854 | { |
| 855 | m_children |= Action; |
| 856 | m_action = a; |
| 857 | } |
| 858 | |
| 859 | void DomActionGroup::setElementActionGroup(const QList<DomActionGroup *> &a) |
| 860 | { |
| 861 | m_children |= ActionGroup; |
| 862 | m_actionGroup = a; |
| 863 | } |
| 864 | |
| 865 | void DomActionGroup::setElementProperty(const QList<DomProperty *> &a) |
| 866 | { |
| 867 | m_children |= Property; |
| 868 | m_property = a; |
| 869 | } |
| 870 | |
| 871 | void DomActionGroup::setElementAttribute(const QList<DomProperty *> &a) |
| 872 | { |
| 873 | m_children |= Attribute; |
| 874 | m_attribute = a; |
| 875 | } |
| 876 | |
| 877 | DomAction::~DomAction() |
| 878 | { |
| 879 | qDeleteAll(m_property); |
| 880 | m_property.clear(); |
| 881 | qDeleteAll(m_attribute); |
| 882 | m_attribute.clear(); |
| 883 | } |
| 884 | |
| 885 | void DomAction::read(QXmlStreamReader &reader) |
| 886 | { |
| 887 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 888 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 889 | const auto name = attribute.name(); |
| 890 | if (name == QLatin1String("name" )) { |
| 891 | setAttributeName(attribute.value().toString()); |
| 892 | continue; |
| 893 | } |
| 894 | if (name == QLatin1String("menu" )) { |
| 895 | setAttributeMenu(attribute.value().toString()); |
| 896 | continue; |
| 897 | } |
| 898 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 899 | } |
| 900 | |
| 901 | while (!reader.hasError()) { |
| 902 | switch (reader.readNext()) { |
| 903 | case QXmlStreamReader::StartElement : { |
| 904 | const auto tag = reader.name(); |
| 905 | if (!tag.compare(QLatin1String("property" ), Qt::CaseInsensitive)) { |
| 906 | auto *v = new DomProperty(); |
| 907 | v->read(reader); |
| 908 | m_property.append(v); |
| 909 | continue; |
| 910 | } |
| 911 | if (!tag.compare(QLatin1String("attribute" ), Qt::CaseInsensitive)) { |
| 912 | auto *v = new DomProperty(); |
| 913 | v->read(reader); |
| 914 | m_attribute.append(v); |
| 915 | continue; |
| 916 | } |
| 917 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 918 | } |
| 919 | break; |
| 920 | case QXmlStreamReader::EndElement : |
| 921 | return; |
| 922 | default : |
| 923 | break; |
| 924 | } |
| 925 | } |
| 926 | } |
| 927 | |
| 928 | void DomAction::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 929 | { |
| 930 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("action" ) : tagName.toLower()); |
| 931 | |
| 932 | if (hasAttributeName()) |
| 933 | writer.writeAttribute(QStringLiteral("name" ), attributeName()); |
| 934 | |
| 935 | if (hasAttributeMenu()) |
| 936 | writer.writeAttribute(QStringLiteral("menu" ), attributeMenu()); |
| 937 | |
| 938 | for (DomProperty *v : m_property) |
| 939 | v->write(writer, QStringLiteral("property" )); |
| 940 | |
| 941 | for (DomProperty *v : m_attribute) |
| 942 | v->write(writer, QStringLiteral("attribute" )); |
| 943 | |
| 944 | writer.writeEndElement(); |
| 945 | } |
| 946 | |
| 947 | void DomAction::setElementProperty(const QList<DomProperty *> &a) |
| 948 | { |
| 949 | m_children |= Property; |
| 950 | m_property = a; |
| 951 | } |
| 952 | |
| 953 | void DomAction::setElementAttribute(const QList<DomProperty *> &a) |
| 954 | { |
| 955 | m_children |= Attribute; |
| 956 | m_attribute = a; |
| 957 | } |
| 958 | |
| 959 | DomActionRef::~DomActionRef() = default; |
| 960 | |
| 961 | void DomActionRef::read(QXmlStreamReader &reader) |
| 962 | { |
| 963 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 964 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 965 | const auto name = attribute.name(); |
| 966 | if (name == QLatin1String("name" )) { |
| 967 | setAttributeName(attribute.value().toString()); |
| 968 | continue; |
| 969 | } |
| 970 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 971 | } |
| 972 | |
| 973 | while (!reader.hasError()) { |
| 974 | switch (reader.readNext()) { |
| 975 | case QXmlStreamReader::StartElement : { |
| 976 | const auto tag = reader.name(); |
| 977 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 978 | } |
| 979 | break; |
| 980 | case QXmlStreamReader::EndElement : |
| 981 | return; |
| 982 | default : |
| 983 | break; |
| 984 | } |
| 985 | } |
| 986 | } |
| 987 | |
| 988 | void DomActionRef::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 989 | { |
| 990 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("actionref" ) : tagName.toLower()); |
| 991 | |
| 992 | if (hasAttributeName()) |
| 993 | writer.writeAttribute(QStringLiteral("name" ), attributeName()); |
| 994 | |
| 995 | writer.writeEndElement(); |
| 996 | } |
| 997 | |
| 998 | DomButtonGroup::~DomButtonGroup() |
| 999 | { |
| 1000 | qDeleteAll(m_property); |
| 1001 | m_property.clear(); |
| 1002 | qDeleteAll(m_attribute); |
| 1003 | m_attribute.clear(); |
| 1004 | } |
| 1005 | |
| 1006 | void DomButtonGroup::read(QXmlStreamReader &reader) |
| 1007 | { |
| 1008 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 1009 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 1010 | const auto name = attribute.name(); |
| 1011 | if (name == QLatin1String("name" )) { |
| 1012 | setAttributeName(attribute.value().toString()); |
| 1013 | continue; |
| 1014 | } |
| 1015 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 1016 | } |
| 1017 | |
| 1018 | while (!reader.hasError()) { |
| 1019 | switch (reader.readNext()) { |
| 1020 | case QXmlStreamReader::StartElement : { |
| 1021 | const auto tag = reader.name(); |
| 1022 | if (!tag.compare(QLatin1String("property" ), Qt::CaseInsensitive)) { |
| 1023 | auto *v = new DomProperty(); |
| 1024 | v->read(reader); |
| 1025 | m_property.append(v); |
| 1026 | continue; |
| 1027 | } |
| 1028 | if (!tag.compare(QLatin1String("attribute" ), Qt::CaseInsensitive)) { |
| 1029 | auto *v = new DomProperty(); |
| 1030 | v->read(reader); |
| 1031 | m_attribute.append(v); |
| 1032 | continue; |
| 1033 | } |
| 1034 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 1035 | } |
| 1036 | break; |
| 1037 | case QXmlStreamReader::EndElement : |
| 1038 | return; |
| 1039 | default : |
| 1040 | break; |
| 1041 | } |
| 1042 | } |
| 1043 | } |
| 1044 | |
| 1045 | void DomButtonGroup::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 1046 | { |
| 1047 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("buttongroup" ) : tagName.toLower()); |
| 1048 | |
| 1049 | if (hasAttributeName()) |
| 1050 | writer.writeAttribute(QStringLiteral("name" ), attributeName()); |
| 1051 | |
| 1052 | for (DomProperty *v : m_property) |
| 1053 | v->write(writer, QStringLiteral("property" )); |
| 1054 | |
| 1055 | for (DomProperty *v : m_attribute) |
| 1056 | v->write(writer, QStringLiteral("attribute" )); |
| 1057 | |
| 1058 | writer.writeEndElement(); |
| 1059 | } |
| 1060 | |
| 1061 | void DomButtonGroup::setElementProperty(const QList<DomProperty *> &a) |
| 1062 | { |
| 1063 | m_children |= Property; |
| 1064 | m_property = a; |
| 1065 | } |
| 1066 | |
| 1067 | void DomButtonGroup::setElementAttribute(const QList<DomProperty *> &a) |
| 1068 | { |
| 1069 | m_children |= Attribute; |
| 1070 | m_attribute = a; |
| 1071 | } |
| 1072 | |
| 1073 | DomButtonGroups::~DomButtonGroups() |
| 1074 | { |
| 1075 | qDeleteAll(m_buttonGroup); |
| 1076 | m_buttonGroup.clear(); |
| 1077 | } |
| 1078 | |
| 1079 | void DomButtonGroups::read(QXmlStreamReader &reader) |
| 1080 | { |
| 1081 | while (!reader.hasError()) { |
| 1082 | switch (reader.readNext()) { |
| 1083 | case QXmlStreamReader::StartElement : { |
| 1084 | const auto tag = reader.name(); |
| 1085 | if (!tag.compare(QLatin1String("buttongroup" ), Qt::CaseInsensitive)) { |
| 1086 | auto *v = new DomButtonGroup(); |
| 1087 | v->read(reader); |
| 1088 | m_buttonGroup.append(v); |
| 1089 | continue; |
| 1090 | } |
| 1091 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 1092 | } |
| 1093 | break; |
| 1094 | case QXmlStreamReader::EndElement : |
| 1095 | return; |
| 1096 | default : |
| 1097 | break; |
| 1098 | } |
| 1099 | } |
| 1100 | } |
| 1101 | |
| 1102 | void DomButtonGroups::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 1103 | { |
| 1104 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("buttongroups" ) : tagName.toLower()); |
| 1105 | |
| 1106 | for (DomButtonGroup *v : m_buttonGroup) |
| 1107 | v->write(writer, QStringLiteral("buttongroup" )); |
| 1108 | |
| 1109 | writer.writeEndElement(); |
| 1110 | } |
| 1111 | |
| 1112 | void DomButtonGroups::setElementButtonGroup(const QList<DomButtonGroup *> &a) |
| 1113 | { |
| 1114 | m_children |= ButtonGroup; |
| 1115 | m_buttonGroup = a; |
| 1116 | } |
| 1117 | |
| 1118 | DomCustomWidgets::~DomCustomWidgets() |
| 1119 | { |
| 1120 | qDeleteAll(m_customWidget); |
| 1121 | m_customWidget.clear(); |
| 1122 | } |
| 1123 | |
| 1124 | void DomCustomWidgets::read(QXmlStreamReader &reader) |
| 1125 | { |
| 1126 | while (!reader.hasError()) { |
| 1127 | switch (reader.readNext()) { |
| 1128 | case QXmlStreamReader::StartElement : { |
| 1129 | const auto tag = reader.name(); |
| 1130 | if (!tag.compare(QLatin1String("customwidget" ), Qt::CaseInsensitive)) { |
| 1131 | auto *v = new DomCustomWidget(); |
| 1132 | v->read(reader); |
| 1133 | m_customWidget.append(v); |
| 1134 | continue; |
| 1135 | } |
| 1136 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 1137 | } |
| 1138 | break; |
| 1139 | case QXmlStreamReader::EndElement : |
| 1140 | return; |
| 1141 | default : |
| 1142 | break; |
| 1143 | } |
| 1144 | } |
| 1145 | } |
| 1146 | |
| 1147 | void DomCustomWidgets::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 1148 | { |
| 1149 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("customwidgets" ) : tagName.toLower()); |
| 1150 | |
| 1151 | for (DomCustomWidget *v : m_customWidget) |
| 1152 | v->write(writer, QStringLiteral("customwidget" )); |
| 1153 | |
| 1154 | writer.writeEndElement(); |
| 1155 | } |
| 1156 | |
| 1157 | void DomCustomWidgets::setElementCustomWidget(const QList<DomCustomWidget *> &a) |
| 1158 | { |
| 1159 | m_children |= CustomWidget; |
| 1160 | m_customWidget = a; |
| 1161 | } |
| 1162 | |
| 1163 | DomHeader::() = default; |
| 1164 | |
| 1165 | void DomHeader::(QXmlStreamReader &reader) |
| 1166 | { |
| 1167 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 1168 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 1169 | const auto name = attribute.name(); |
| 1170 | if (name == QLatin1String("location" )) { |
| 1171 | setAttributeLocation(attribute.value().toString()); |
| 1172 | continue; |
| 1173 | } |
| 1174 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 1175 | } |
| 1176 | |
| 1177 | while (!reader.hasError()) { |
| 1178 | switch (reader.readNext()) { |
| 1179 | case QXmlStreamReader::StartElement : { |
| 1180 | const auto tag = reader.name(); |
| 1181 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 1182 | } |
| 1183 | break; |
| 1184 | case QXmlStreamReader::EndElement : |
| 1185 | return; |
| 1186 | case QXmlStreamReader::Characters : |
| 1187 | if (!reader.isWhitespace()) |
| 1188 | m_text.append(reader.text().toString()); |
| 1189 | break; |
| 1190 | default : |
| 1191 | break; |
| 1192 | } |
| 1193 | } |
| 1194 | } |
| 1195 | |
| 1196 | void DomHeader::(QXmlStreamWriter &writer, const QString &tagName) const |
| 1197 | { |
| 1198 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("header" ) : tagName.toLower()); |
| 1199 | |
| 1200 | if (hasAttributeLocation()) |
| 1201 | writer.writeAttribute(QStringLiteral("location" ), attributeLocation()); |
| 1202 | |
| 1203 | if (!m_text.isEmpty()) |
| 1204 | writer.writeCharacters(m_text); |
| 1205 | |
| 1206 | writer.writeEndElement(); |
| 1207 | } |
| 1208 | |
| 1209 | DomCustomWidget::~DomCustomWidget() |
| 1210 | { |
| 1211 | delete m_header; |
| 1212 | delete m_sizeHint; |
| 1213 | delete m_slots; |
| 1214 | delete m_propertyspecifications; |
| 1215 | } |
| 1216 | |
| 1217 | void DomCustomWidget::read(QXmlStreamReader &reader) |
| 1218 | { |
| 1219 | while (!reader.hasError()) { |
| 1220 | switch (reader.readNext()) { |
| 1221 | case QXmlStreamReader::StartElement : { |
| 1222 | const auto tag = reader.name(); |
| 1223 | if (!tag.compare(QLatin1String("class" ), Qt::CaseInsensitive)) { |
| 1224 | setElementClass(reader.readElementText()); |
| 1225 | continue; |
| 1226 | } |
| 1227 | if (!tag.compare(QLatin1String("extends" ), Qt::CaseInsensitive)) { |
| 1228 | setElementExtends(reader.readElementText()); |
| 1229 | continue; |
| 1230 | } |
| 1231 | if (!tag.compare(QLatin1String("header" ), Qt::CaseInsensitive)) { |
| 1232 | auto *v = new DomHeader(); |
| 1233 | v->read(reader); |
| 1234 | setElementHeader(v); |
| 1235 | continue; |
| 1236 | } |
| 1237 | if (!tag.compare(QLatin1String("sizehint" ), Qt::CaseInsensitive)) { |
| 1238 | auto *v = new DomSize(); |
| 1239 | v->read(reader); |
| 1240 | setElementSizeHint(v); |
| 1241 | continue; |
| 1242 | } |
| 1243 | if (!tag.compare(QLatin1String("addpagemethod" ), Qt::CaseInsensitive)) { |
| 1244 | setElementAddPageMethod(reader.readElementText()); |
| 1245 | continue; |
| 1246 | } |
| 1247 | if (!tag.compare(QLatin1String("container" ), Qt::CaseInsensitive)) { |
| 1248 | setElementContainer(reader.readElementText().toInt()); |
| 1249 | continue; |
| 1250 | } |
| 1251 | if (!tag.compare(QLatin1String("sizepolicy" ), Qt::CaseInsensitive)) { |
| 1252 | qWarning("Omitting deprecated element <sizepolicy>." ); |
| 1253 | reader.skipCurrentElement(); |
| 1254 | continue; |
| 1255 | } |
| 1256 | if (!tag.compare(QLatin1String("pixmap" ), Qt::CaseInsensitive)) { |
| 1257 | setElementPixmap(reader.readElementText()); |
| 1258 | continue; |
| 1259 | } |
| 1260 | if (!tag.compare(QLatin1String("script" ), Qt::CaseInsensitive)) { |
| 1261 | qWarning("Omitting deprecated element <script>." ); |
| 1262 | reader.skipCurrentElement(); |
| 1263 | continue; |
| 1264 | } |
| 1265 | if (!tag.compare(QLatin1String("properties" ), Qt::CaseInsensitive)) { |
| 1266 | qWarning("Omitting deprecated element <properties>." ); |
| 1267 | reader.skipCurrentElement(); |
| 1268 | continue; |
| 1269 | } |
| 1270 | if (!tag.compare(QLatin1String("slots" ), Qt::CaseInsensitive)) { |
| 1271 | auto *v = new DomSlots(); |
| 1272 | v->read(reader); |
| 1273 | setElementSlots(v); |
| 1274 | continue; |
| 1275 | } |
| 1276 | if (!tag.compare(QLatin1String("propertyspecifications" ), Qt::CaseInsensitive)) { |
| 1277 | auto *v = new DomPropertySpecifications(); |
| 1278 | v->read(reader); |
| 1279 | setElementPropertyspecifications(v); |
| 1280 | continue; |
| 1281 | } |
| 1282 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 1283 | } |
| 1284 | break; |
| 1285 | case QXmlStreamReader::EndElement : |
| 1286 | return; |
| 1287 | default : |
| 1288 | break; |
| 1289 | } |
| 1290 | } |
| 1291 | } |
| 1292 | |
| 1293 | void DomCustomWidget::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 1294 | { |
| 1295 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("customwidget" ) : tagName.toLower()); |
| 1296 | |
| 1297 | if (m_children & Class) |
| 1298 | writer.writeTextElement(QStringLiteral("class" ), m_class); |
| 1299 | |
| 1300 | if (m_children & Extends) |
| 1301 | writer.writeTextElement(QStringLiteral("extends" ), m_extends); |
| 1302 | |
| 1303 | if (m_children & Header) |
| 1304 | m_header->write(writer, QStringLiteral("header" )); |
| 1305 | |
| 1306 | if (m_children & SizeHint) |
| 1307 | m_sizeHint->write(writer, QStringLiteral("sizehint" )); |
| 1308 | |
| 1309 | if (m_children & AddPageMethod) |
| 1310 | writer.writeTextElement(QStringLiteral("addpagemethod" ), m_addPageMethod); |
| 1311 | |
| 1312 | if (m_children & Container) |
| 1313 | writer.writeTextElement(QStringLiteral("container" ), QString::number(m_container)); |
| 1314 | |
| 1315 | if (m_children & Pixmap) |
| 1316 | writer.writeTextElement(QStringLiteral("pixmap" ), m_pixmap); |
| 1317 | |
| 1318 | if (m_children & Slots) |
| 1319 | m_slots->write(writer, QStringLiteral("slots" )); |
| 1320 | |
| 1321 | if (m_children & Propertyspecifications) |
| 1322 | m_propertyspecifications->write(writer, QStringLiteral("propertyspecifications" )); |
| 1323 | |
| 1324 | writer.writeEndElement(); |
| 1325 | } |
| 1326 | |
| 1327 | void DomCustomWidget::setElementClass(const QString &a) |
| 1328 | { |
| 1329 | m_children |= Class; |
| 1330 | m_class = a; |
| 1331 | } |
| 1332 | |
| 1333 | void DomCustomWidget::setElementExtends(const QString &a) |
| 1334 | { |
| 1335 | m_children |= Extends; |
| 1336 | m_extends = a; |
| 1337 | } |
| 1338 | |
| 1339 | DomHeader *DomCustomWidget::() |
| 1340 | { |
| 1341 | DomHeader *a = m_header; |
| 1342 | m_header = nullptr; |
| 1343 | m_children ^= Header; |
| 1344 | return a; |
| 1345 | } |
| 1346 | |
| 1347 | void DomCustomWidget::(DomHeader *a) |
| 1348 | { |
| 1349 | delete m_header; |
| 1350 | m_children |= Header; |
| 1351 | m_header = a; |
| 1352 | } |
| 1353 | |
| 1354 | DomSize *DomCustomWidget::takeElementSizeHint() |
| 1355 | { |
| 1356 | DomSize *a = m_sizeHint; |
| 1357 | m_sizeHint = nullptr; |
| 1358 | m_children ^= SizeHint; |
| 1359 | return a; |
| 1360 | } |
| 1361 | |
| 1362 | void DomCustomWidget::setElementSizeHint(DomSize *a) |
| 1363 | { |
| 1364 | delete m_sizeHint; |
| 1365 | m_children |= SizeHint; |
| 1366 | m_sizeHint = a; |
| 1367 | } |
| 1368 | |
| 1369 | void DomCustomWidget::setElementAddPageMethod(const QString &a) |
| 1370 | { |
| 1371 | m_children |= AddPageMethod; |
| 1372 | m_addPageMethod = a; |
| 1373 | } |
| 1374 | |
| 1375 | void DomCustomWidget::setElementContainer(int a) |
| 1376 | { |
| 1377 | m_children |= Container; |
| 1378 | m_container = a; |
| 1379 | } |
| 1380 | |
| 1381 | void DomCustomWidget::setElementPixmap(const QString &a) |
| 1382 | { |
| 1383 | m_children |= Pixmap; |
| 1384 | m_pixmap = a; |
| 1385 | } |
| 1386 | |
| 1387 | DomSlots *DomCustomWidget::takeElementSlots() |
| 1388 | { |
| 1389 | DomSlots *a = m_slots; |
| 1390 | m_slots = nullptr; |
| 1391 | m_children ^= Slots; |
| 1392 | return a; |
| 1393 | } |
| 1394 | |
| 1395 | void DomCustomWidget::setElementSlots(DomSlots *a) |
| 1396 | { |
| 1397 | delete m_slots; |
| 1398 | m_children |= Slots; |
| 1399 | m_slots = a; |
| 1400 | } |
| 1401 | |
| 1402 | DomPropertySpecifications *DomCustomWidget::takeElementPropertyspecifications() |
| 1403 | { |
| 1404 | DomPropertySpecifications *a = m_propertyspecifications; |
| 1405 | m_propertyspecifications = nullptr; |
| 1406 | m_children ^= Propertyspecifications; |
| 1407 | return a; |
| 1408 | } |
| 1409 | |
| 1410 | void DomCustomWidget::setElementPropertyspecifications(DomPropertySpecifications *a) |
| 1411 | { |
| 1412 | delete m_propertyspecifications; |
| 1413 | m_children |= Propertyspecifications; |
| 1414 | m_propertyspecifications = a; |
| 1415 | } |
| 1416 | |
| 1417 | void DomCustomWidget::clearElementClass() |
| 1418 | { |
| 1419 | m_children &= ~Class; |
| 1420 | } |
| 1421 | |
| 1422 | void DomCustomWidget::clearElementExtends() |
| 1423 | { |
| 1424 | m_children &= ~Extends; |
| 1425 | } |
| 1426 | |
| 1427 | void DomCustomWidget::() |
| 1428 | { |
| 1429 | delete m_header; |
| 1430 | m_header = nullptr; |
| 1431 | m_children &= ~Header; |
| 1432 | } |
| 1433 | |
| 1434 | void DomCustomWidget::clearElementSizeHint() |
| 1435 | { |
| 1436 | delete m_sizeHint; |
| 1437 | m_sizeHint = nullptr; |
| 1438 | m_children &= ~SizeHint; |
| 1439 | } |
| 1440 | |
| 1441 | void DomCustomWidget::clearElementAddPageMethod() |
| 1442 | { |
| 1443 | m_children &= ~AddPageMethod; |
| 1444 | } |
| 1445 | |
| 1446 | void DomCustomWidget::clearElementContainer() |
| 1447 | { |
| 1448 | m_children &= ~Container; |
| 1449 | } |
| 1450 | |
| 1451 | void DomCustomWidget::clearElementPixmap() |
| 1452 | { |
| 1453 | m_children &= ~Pixmap; |
| 1454 | } |
| 1455 | |
| 1456 | void DomCustomWidget::clearElementSlots() |
| 1457 | { |
| 1458 | delete m_slots; |
| 1459 | m_slots = nullptr; |
| 1460 | m_children &= ~Slots; |
| 1461 | } |
| 1462 | |
| 1463 | void DomCustomWidget::clearElementPropertyspecifications() |
| 1464 | { |
| 1465 | delete m_propertyspecifications; |
| 1466 | m_propertyspecifications = nullptr; |
| 1467 | m_children &= ~Propertyspecifications; |
| 1468 | } |
| 1469 | |
| 1470 | DomLayoutDefault::~DomLayoutDefault() = default; |
| 1471 | |
| 1472 | void DomLayoutDefault::read(QXmlStreamReader &reader) |
| 1473 | { |
| 1474 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 1475 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 1476 | const auto name = attribute.name(); |
| 1477 | if (name == QLatin1String("spacing" )) { |
| 1478 | setAttributeSpacing(attribute.value().toInt()); |
| 1479 | continue; |
| 1480 | } |
| 1481 | if (name == QLatin1String("margin" )) { |
| 1482 | setAttributeMargin(attribute.value().toInt()); |
| 1483 | continue; |
| 1484 | } |
| 1485 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 1486 | } |
| 1487 | |
| 1488 | while (!reader.hasError()) { |
| 1489 | switch (reader.readNext()) { |
| 1490 | case QXmlStreamReader::StartElement : { |
| 1491 | const auto tag = reader.name(); |
| 1492 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 1493 | } |
| 1494 | break; |
| 1495 | case QXmlStreamReader::EndElement : |
| 1496 | return; |
| 1497 | default : |
| 1498 | break; |
| 1499 | } |
| 1500 | } |
| 1501 | } |
| 1502 | |
| 1503 | void DomLayoutDefault::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 1504 | { |
| 1505 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("layoutdefault" ) : tagName.toLower()); |
| 1506 | |
| 1507 | if (hasAttributeSpacing()) |
| 1508 | writer.writeAttribute(QStringLiteral("spacing" ), QString::number(attributeSpacing())); |
| 1509 | |
| 1510 | if (hasAttributeMargin()) |
| 1511 | writer.writeAttribute(QStringLiteral("margin" ), QString::number(attributeMargin())); |
| 1512 | |
| 1513 | writer.writeEndElement(); |
| 1514 | } |
| 1515 | |
| 1516 | DomLayoutFunction::~DomLayoutFunction() = default; |
| 1517 | |
| 1518 | void DomLayoutFunction::read(QXmlStreamReader &reader) |
| 1519 | { |
| 1520 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 1521 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 1522 | const auto name = attribute.name(); |
| 1523 | if (name == QLatin1String("spacing" )) { |
| 1524 | setAttributeSpacing(attribute.value().toString()); |
| 1525 | continue; |
| 1526 | } |
| 1527 | if (name == QLatin1String("margin" )) { |
| 1528 | setAttributeMargin(attribute.value().toString()); |
| 1529 | continue; |
| 1530 | } |
| 1531 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 1532 | } |
| 1533 | |
| 1534 | while (!reader.hasError()) { |
| 1535 | switch (reader.readNext()) { |
| 1536 | case QXmlStreamReader::StartElement : { |
| 1537 | const auto tag = reader.name(); |
| 1538 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 1539 | } |
| 1540 | break; |
| 1541 | case QXmlStreamReader::EndElement : |
| 1542 | return; |
| 1543 | default : |
| 1544 | break; |
| 1545 | } |
| 1546 | } |
| 1547 | } |
| 1548 | |
| 1549 | void DomLayoutFunction::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 1550 | { |
| 1551 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("layoutfunction" ) : tagName.toLower()); |
| 1552 | |
| 1553 | if (hasAttributeSpacing()) |
| 1554 | writer.writeAttribute(QStringLiteral("spacing" ), attributeSpacing()); |
| 1555 | |
| 1556 | if (hasAttributeMargin()) |
| 1557 | writer.writeAttribute(QStringLiteral("margin" ), attributeMargin()); |
| 1558 | |
| 1559 | writer.writeEndElement(); |
| 1560 | } |
| 1561 | |
| 1562 | DomTabStops::~DomTabStops() |
| 1563 | { |
| 1564 | m_tabStop.clear(); |
| 1565 | } |
| 1566 | |
| 1567 | void DomTabStops::read(QXmlStreamReader &reader) |
| 1568 | { |
| 1569 | while (!reader.hasError()) { |
| 1570 | switch (reader.readNext()) { |
| 1571 | case QXmlStreamReader::StartElement : { |
| 1572 | const auto tag = reader.name(); |
| 1573 | if (!tag.compare(QLatin1String("tabstop" ), Qt::CaseInsensitive)) { |
| 1574 | m_tabStop.append(reader.readElementText()); |
| 1575 | continue; |
| 1576 | } |
| 1577 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 1578 | } |
| 1579 | break; |
| 1580 | case QXmlStreamReader::EndElement : |
| 1581 | return; |
| 1582 | default : |
| 1583 | break; |
| 1584 | } |
| 1585 | } |
| 1586 | } |
| 1587 | |
| 1588 | void DomTabStops::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 1589 | { |
| 1590 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("tabstops" ) : tagName.toLower()); |
| 1591 | |
| 1592 | for (const QString &v : m_tabStop) |
| 1593 | writer.writeTextElement(QStringLiteral("tabstop" ), v); |
| 1594 | |
| 1595 | writer.writeEndElement(); |
| 1596 | } |
| 1597 | |
| 1598 | void DomTabStops::setElementTabStop(const QStringList &a) |
| 1599 | { |
| 1600 | m_children |= TabStop; |
| 1601 | m_tabStop = a; |
| 1602 | } |
| 1603 | |
| 1604 | DomLayout::~DomLayout() |
| 1605 | { |
| 1606 | qDeleteAll(m_property); |
| 1607 | m_property.clear(); |
| 1608 | qDeleteAll(m_attribute); |
| 1609 | m_attribute.clear(); |
| 1610 | qDeleteAll(m_item); |
| 1611 | m_item.clear(); |
| 1612 | } |
| 1613 | |
| 1614 | void DomLayout::read(QXmlStreamReader &reader) |
| 1615 | { |
| 1616 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 1617 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 1618 | const auto name = attribute.name(); |
| 1619 | if (name == QLatin1String("class" )) { |
| 1620 | setAttributeClass(attribute.value().toString()); |
| 1621 | continue; |
| 1622 | } |
| 1623 | if (name == QLatin1String("name" )) { |
| 1624 | setAttributeName(attribute.value().toString()); |
| 1625 | continue; |
| 1626 | } |
| 1627 | if (name == QLatin1String("stretch" )) { |
| 1628 | setAttributeStretch(attribute.value().toString()); |
| 1629 | continue; |
| 1630 | } |
| 1631 | if (name == QLatin1String("rowstretch" )) { |
| 1632 | setAttributeRowStretch(attribute.value().toString()); |
| 1633 | continue; |
| 1634 | } |
| 1635 | if (name == QLatin1String("columnstretch" )) { |
| 1636 | setAttributeColumnStretch(attribute.value().toString()); |
| 1637 | continue; |
| 1638 | } |
| 1639 | if (name == QLatin1String("rowminimumheight" )) { |
| 1640 | setAttributeRowMinimumHeight(attribute.value().toString()); |
| 1641 | continue; |
| 1642 | } |
| 1643 | if (name == QLatin1String("columnminimumwidth" )) { |
| 1644 | setAttributeColumnMinimumWidth(attribute.value().toString()); |
| 1645 | continue; |
| 1646 | } |
| 1647 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 1648 | } |
| 1649 | |
| 1650 | while (!reader.hasError()) { |
| 1651 | switch (reader.readNext()) { |
| 1652 | case QXmlStreamReader::StartElement : { |
| 1653 | const auto tag = reader.name(); |
| 1654 | if (!tag.compare(QLatin1String("property" ), Qt::CaseInsensitive)) { |
| 1655 | auto *v = new DomProperty(); |
| 1656 | v->read(reader); |
| 1657 | m_property.append(v); |
| 1658 | continue; |
| 1659 | } |
| 1660 | if (!tag.compare(QLatin1String("attribute" ), Qt::CaseInsensitive)) { |
| 1661 | auto *v = new DomProperty(); |
| 1662 | v->read(reader); |
| 1663 | m_attribute.append(v); |
| 1664 | continue; |
| 1665 | } |
| 1666 | if (!tag.compare(QLatin1String("item" ), Qt::CaseInsensitive)) { |
| 1667 | auto *v = new DomLayoutItem(); |
| 1668 | v->read(reader); |
| 1669 | m_item.append(v); |
| 1670 | continue; |
| 1671 | } |
| 1672 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 1673 | } |
| 1674 | break; |
| 1675 | case QXmlStreamReader::EndElement : |
| 1676 | return; |
| 1677 | default : |
| 1678 | break; |
| 1679 | } |
| 1680 | } |
| 1681 | } |
| 1682 | |
| 1683 | void DomLayout::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 1684 | { |
| 1685 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("layout" ) : tagName.toLower()); |
| 1686 | |
| 1687 | if (hasAttributeClass()) |
| 1688 | writer.writeAttribute(QStringLiteral("class" ), attributeClass()); |
| 1689 | |
| 1690 | if (hasAttributeName()) |
| 1691 | writer.writeAttribute(QStringLiteral("name" ), attributeName()); |
| 1692 | |
| 1693 | if (hasAttributeStretch()) |
| 1694 | writer.writeAttribute(QStringLiteral("stretch" ), attributeStretch()); |
| 1695 | |
| 1696 | if (hasAttributeRowStretch()) |
| 1697 | writer.writeAttribute(QStringLiteral("rowstretch" ), attributeRowStretch()); |
| 1698 | |
| 1699 | if (hasAttributeColumnStretch()) |
| 1700 | writer.writeAttribute(QStringLiteral("columnstretch" ), attributeColumnStretch()); |
| 1701 | |
| 1702 | if (hasAttributeRowMinimumHeight()) |
| 1703 | writer.writeAttribute(QStringLiteral("rowminimumheight" ), attributeRowMinimumHeight()); |
| 1704 | |
| 1705 | if (hasAttributeColumnMinimumWidth()) |
| 1706 | writer.writeAttribute(QStringLiteral("columnminimumwidth" ), attributeColumnMinimumWidth()); |
| 1707 | |
| 1708 | for (DomProperty *v : m_property) |
| 1709 | v->write(writer, QStringLiteral("property" )); |
| 1710 | |
| 1711 | for (DomProperty *v : m_attribute) |
| 1712 | v->write(writer, QStringLiteral("attribute" )); |
| 1713 | |
| 1714 | for (DomLayoutItem *v : m_item) |
| 1715 | v->write(writer, QStringLiteral("item" )); |
| 1716 | |
| 1717 | writer.writeEndElement(); |
| 1718 | } |
| 1719 | |
| 1720 | void DomLayout::setElementProperty(const QList<DomProperty *> &a) |
| 1721 | { |
| 1722 | m_children |= Property; |
| 1723 | m_property = a; |
| 1724 | } |
| 1725 | |
| 1726 | void DomLayout::setElementAttribute(const QList<DomProperty *> &a) |
| 1727 | { |
| 1728 | m_children |= Attribute; |
| 1729 | m_attribute = a; |
| 1730 | } |
| 1731 | |
| 1732 | void DomLayout::setElementItem(const QList<DomLayoutItem *> &a) |
| 1733 | { |
| 1734 | m_children |= Item; |
| 1735 | m_item = a; |
| 1736 | } |
| 1737 | |
| 1738 | DomLayoutItem::~DomLayoutItem() |
| 1739 | { |
| 1740 | delete m_widget; |
| 1741 | delete m_layout; |
| 1742 | delete m_spacer; |
| 1743 | } |
| 1744 | |
| 1745 | void DomLayoutItem::clear() |
| 1746 | { |
| 1747 | delete m_widget; |
| 1748 | delete m_layout; |
| 1749 | delete m_spacer; |
| 1750 | |
| 1751 | m_kind = Unknown; |
| 1752 | |
| 1753 | m_widget = nullptr; |
| 1754 | m_layout = nullptr; |
| 1755 | m_spacer = nullptr; |
| 1756 | } |
| 1757 | |
| 1758 | void DomLayoutItem::read(QXmlStreamReader &reader) |
| 1759 | { |
| 1760 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 1761 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 1762 | const auto name = attribute.name(); |
| 1763 | if (name == QLatin1String("row" )) { |
| 1764 | setAttributeRow(attribute.value().toInt()); |
| 1765 | continue; |
| 1766 | } |
| 1767 | if (name == QLatin1String("column" )) { |
| 1768 | setAttributeColumn(attribute.value().toInt()); |
| 1769 | continue; |
| 1770 | } |
| 1771 | if (name == QLatin1String("rowspan" )) { |
| 1772 | setAttributeRowSpan(attribute.value().toInt()); |
| 1773 | continue; |
| 1774 | } |
| 1775 | if (name == QLatin1String("colspan" )) { |
| 1776 | setAttributeColSpan(attribute.value().toInt()); |
| 1777 | continue; |
| 1778 | } |
| 1779 | if (name == QLatin1String("alignment" )) { |
| 1780 | setAttributeAlignment(attribute.value().toString()); |
| 1781 | continue; |
| 1782 | } |
| 1783 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 1784 | } |
| 1785 | |
| 1786 | while (!reader.hasError()) { |
| 1787 | switch (reader.readNext()) { |
| 1788 | case QXmlStreamReader::StartElement : { |
| 1789 | const auto tag = reader.name(); |
| 1790 | if (!tag.compare(QLatin1String("widget" ), Qt::CaseInsensitive)) { |
| 1791 | auto *v = new DomWidget(); |
| 1792 | v->read(reader); |
| 1793 | setElementWidget(v); |
| 1794 | continue; |
| 1795 | } |
| 1796 | if (!tag.compare(QLatin1String("layout" ), Qt::CaseInsensitive)) { |
| 1797 | auto *v = new DomLayout(); |
| 1798 | v->read(reader); |
| 1799 | setElementLayout(v); |
| 1800 | continue; |
| 1801 | } |
| 1802 | if (!tag.compare(QLatin1String("spacer" ), Qt::CaseInsensitive)) { |
| 1803 | auto *v = new DomSpacer(); |
| 1804 | v->read(reader); |
| 1805 | setElementSpacer(v); |
| 1806 | continue; |
| 1807 | } |
| 1808 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 1809 | } |
| 1810 | break; |
| 1811 | case QXmlStreamReader::EndElement : |
| 1812 | return; |
| 1813 | default : |
| 1814 | break; |
| 1815 | } |
| 1816 | } |
| 1817 | } |
| 1818 | |
| 1819 | void DomLayoutItem::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 1820 | { |
| 1821 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("layoutitem" ) : tagName.toLower()); |
| 1822 | |
| 1823 | if (hasAttributeRow()) |
| 1824 | writer.writeAttribute(QStringLiteral("row" ), QString::number(attributeRow())); |
| 1825 | |
| 1826 | if (hasAttributeColumn()) |
| 1827 | writer.writeAttribute(QStringLiteral("column" ), QString::number(attributeColumn())); |
| 1828 | |
| 1829 | if (hasAttributeRowSpan()) |
| 1830 | writer.writeAttribute(QStringLiteral("rowspan" ), QString::number(attributeRowSpan())); |
| 1831 | |
| 1832 | if (hasAttributeColSpan()) |
| 1833 | writer.writeAttribute(QStringLiteral("colspan" ), QString::number(attributeColSpan())); |
| 1834 | |
| 1835 | if (hasAttributeAlignment()) |
| 1836 | writer.writeAttribute(QStringLiteral("alignment" ), attributeAlignment()); |
| 1837 | |
| 1838 | switch (kind()) { |
| 1839 | case Widget: |
| 1840 | if (m_widget != nullptr) |
| 1841 | m_widget->write(writer, QStringLiteral("widget" )); |
| 1842 | break; |
| 1843 | |
| 1844 | case Layout: |
| 1845 | if (m_layout != nullptr) |
| 1846 | m_layout->write(writer, QStringLiteral("layout" )); |
| 1847 | break; |
| 1848 | |
| 1849 | case Spacer: |
| 1850 | if (m_spacer != nullptr) |
| 1851 | m_spacer->write(writer, QStringLiteral("spacer" )); |
| 1852 | break; |
| 1853 | |
| 1854 | default: |
| 1855 | break; |
| 1856 | } |
| 1857 | writer.writeEndElement(); |
| 1858 | } |
| 1859 | |
| 1860 | DomWidget *DomLayoutItem::takeElementWidget() |
| 1861 | { |
| 1862 | DomWidget *a = m_widget; |
| 1863 | m_widget = nullptr; |
| 1864 | return a; |
| 1865 | } |
| 1866 | |
| 1867 | void DomLayoutItem::setElementWidget(DomWidget *a) |
| 1868 | { |
| 1869 | clear(); |
| 1870 | m_kind = Widget; |
| 1871 | m_widget = a; |
| 1872 | } |
| 1873 | |
| 1874 | DomLayout *DomLayoutItem::takeElementLayout() |
| 1875 | { |
| 1876 | DomLayout *a = m_layout; |
| 1877 | m_layout = nullptr; |
| 1878 | return a; |
| 1879 | } |
| 1880 | |
| 1881 | void DomLayoutItem::setElementLayout(DomLayout *a) |
| 1882 | { |
| 1883 | clear(); |
| 1884 | m_kind = Layout; |
| 1885 | m_layout = a; |
| 1886 | } |
| 1887 | |
| 1888 | DomSpacer *DomLayoutItem::takeElementSpacer() |
| 1889 | { |
| 1890 | DomSpacer *a = m_spacer; |
| 1891 | m_spacer = nullptr; |
| 1892 | return a; |
| 1893 | } |
| 1894 | |
| 1895 | void DomLayoutItem::setElementSpacer(DomSpacer *a) |
| 1896 | { |
| 1897 | clear(); |
| 1898 | m_kind = Spacer; |
| 1899 | m_spacer = a; |
| 1900 | } |
| 1901 | |
| 1902 | DomRow::~DomRow() |
| 1903 | { |
| 1904 | qDeleteAll(m_property); |
| 1905 | m_property.clear(); |
| 1906 | } |
| 1907 | |
| 1908 | void DomRow::read(QXmlStreamReader &reader) |
| 1909 | { |
| 1910 | while (!reader.hasError()) { |
| 1911 | switch (reader.readNext()) { |
| 1912 | case QXmlStreamReader::StartElement : { |
| 1913 | const auto tag = reader.name(); |
| 1914 | if (!tag.compare(QLatin1String("property" ), Qt::CaseInsensitive)) { |
| 1915 | auto *v = new DomProperty(); |
| 1916 | v->read(reader); |
| 1917 | m_property.append(v); |
| 1918 | continue; |
| 1919 | } |
| 1920 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 1921 | } |
| 1922 | break; |
| 1923 | case QXmlStreamReader::EndElement : |
| 1924 | return; |
| 1925 | default : |
| 1926 | break; |
| 1927 | } |
| 1928 | } |
| 1929 | } |
| 1930 | |
| 1931 | void DomRow::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 1932 | { |
| 1933 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("row" ) : tagName.toLower()); |
| 1934 | |
| 1935 | for (DomProperty *v : m_property) |
| 1936 | v->write(writer, QStringLiteral("property" )); |
| 1937 | |
| 1938 | writer.writeEndElement(); |
| 1939 | } |
| 1940 | |
| 1941 | void DomRow::setElementProperty(const QList<DomProperty *> &a) |
| 1942 | { |
| 1943 | m_children |= Property; |
| 1944 | m_property = a; |
| 1945 | } |
| 1946 | |
| 1947 | DomColumn::~DomColumn() |
| 1948 | { |
| 1949 | qDeleteAll(m_property); |
| 1950 | m_property.clear(); |
| 1951 | } |
| 1952 | |
| 1953 | void DomColumn::read(QXmlStreamReader &reader) |
| 1954 | { |
| 1955 | while (!reader.hasError()) { |
| 1956 | switch (reader.readNext()) { |
| 1957 | case QXmlStreamReader::StartElement : { |
| 1958 | const auto tag = reader.name(); |
| 1959 | if (!tag.compare(QLatin1String("property" ), Qt::CaseInsensitive)) { |
| 1960 | auto *v = new DomProperty(); |
| 1961 | v->read(reader); |
| 1962 | m_property.append(v); |
| 1963 | continue; |
| 1964 | } |
| 1965 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 1966 | } |
| 1967 | break; |
| 1968 | case QXmlStreamReader::EndElement : |
| 1969 | return; |
| 1970 | default : |
| 1971 | break; |
| 1972 | } |
| 1973 | } |
| 1974 | } |
| 1975 | |
| 1976 | void DomColumn::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 1977 | { |
| 1978 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("column" ) : tagName.toLower()); |
| 1979 | |
| 1980 | for (DomProperty *v : m_property) |
| 1981 | v->write(writer, QStringLiteral("property" )); |
| 1982 | |
| 1983 | writer.writeEndElement(); |
| 1984 | } |
| 1985 | |
| 1986 | void DomColumn::setElementProperty(const QList<DomProperty *> &a) |
| 1987 | { |
| 1988 | m_children |= Property; |
| 1989 | m_property = a; |
| 1990 | } |
| 1991 | |
| 1992 | DomItem::~DomItem() |
| 1993 | { |
| 1994 | qDeleteAll(m_property); |
| 1995 | m_property.clear(); |
| 1996 | qDeleteAll(m_item); |
| 1997 | m_item.clear(); |
| 1998 | } |
| 1999 | |
| 2000 | void DomItem::read(QXmlStreamReader &reader) |
| 2001 | { |
| 2002 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 2003 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 2004 | const auto name = attribute.name(); |
| 2005 | if (name == QLatin1String("row" )) { |
| 2006 | setAttributeRow(attribute.value().toInt()); |
| 2007 | continue; |
| 2008 | } |
| 2009 | if (name == QLatin1String("column" )) { |
| 2010 | setAttributeColumn(attribute.value().toInt()); |
| 2011 | continue; |
| 2012 | } |
| 2013 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 2014 | } |
| 2015 | |
| 2016 | while (!reader.hasError()) { |
| 2017 | switch (reader.readNext()) { |
| 2018 | case QXmlStreamReader::StartElement : { |
| 2019 | const auto tag = reader.name(); |
| 2020 | if (!tag.compare(QLatin1String("property" ), Qt::CaseInsensitive)) { |
| 2021 | auto *v = new DomProperty(); |
| 2022 | v->read(reader); |
| 2023 | m_property.append(v); |
| 2024 | continue; |
| 2025 | } |
| 2026 | if (!tag.compare(QLatin1String("item" ), Qt::CaseInsensitive)) { |
| 2027 | auto *v = new DomItem(); |
| 2028 | v->read(reader); |
| 2029 | m_item.append(v); |
| 2030 | continue; |
| 2031 | } |
| 2032 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 2033 | } |
| 2034 | break; |
| 2035 | case QXmlStreamReader::EndElement : |
| 2036 | return; |
| 2037 | default : |
| 2038 | break; |
| 2039 | } |
| 2040 | } |
| 2041 | } |
| 2042 | |
| 2043 | void DomItem::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 2044 | { |
| 2045 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("item" ) : tagName.toLower()); |
| 2046 | |
| 2047 | if (hasAttributeRow()) |
| 2048 | writer.writeAttribute(QStringLiteral("row" ), QString::number(attributeRow())); |
| 2049 | |
| 2050 | if (hasAttributeColumn()) |
| 2051 | writer.writeAttribute(QStringLiteral("column" ), QString::number(attributeColumn())); |
| 2052 | |
| 2053 | for (DomProperty *v : m_property) |
| 2054 | v->write(writer, QStringLiteral("property" )); |
| 2055 | |
| 2056 | for (DomItem *v : m_item) |
| 2057 | v->write(writer, QStringLiteral("item" )); |
| 2058 | |
| 2059 | writer.writeEndElement(); |
| 2060 | } |
| 2061 | |
| 2062 | void DomItem::setElementProperty(const QList<DomProperty *> &a) |
| 2063 | { |
| 2064 | m_children |= Property; |
| 2065 | m_property = a; |
| 2066 | } |
| 2067 | |
| 2068 | void DomItem::setElementItem(const QList<DomItem *> &a) |
| 2069 | { |
| 2070 | m_children |= Item; |
| 2071 | m_item = a; |
| 2072 | } |
| 2073 | |
| 2074 | DomWidget::~DomWidget() |
| 2075 | { |
| 2076 | m_class.clear(); |
| 2077 | qDeleteAll(m_property); |
| 2078 | m_property.clear(); |
| 2079 | qDeleteAll(m_attribute); |
| 2080 | m_attribute.clear(); |
| 2081 | qDeleteAll(m_row); |
| 2082 | m_row.clear(); |
| 2083 | qDeleteAll(m_column); |
| 2084 | m_column.clear(); |
| 2085 | qDeleteAll(m_item); |
| 2086 | m_item.clear(); |
| 2087 | qDeleteAll(m_layout); |
| 2088 | m_layout.clear(); |
| 2089 | qDeleteAll(m_widget); |
| 2090 | m_widget.clear(); |
| 2091 | qDeleteAll(m_action); |
| 2092 | m_action.clear(); |
| 2093 | qDeleteAll(m_actionGroup); |
| 2094 | m_actionGroup.clear(); |
| 2095 | qDeleteAll(m_addAction); |
| 2096 | m_addAction.clear(); |
| 2097 | m_zOrder.clear(); |
| 2098 | } |
| 2099 | |
| 2100 | void DomWidget::read(QXmlStreamReader &reader) |
| 2101 | { |
| 2102 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 2103 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 2104 | const auto name = attribute.name(); |
| 2105 | if (name == QLatin1String("class" )) { |
| 2106 | setAttributeClass(attribute.value().toString()); |
| 2107 | continue; |
| 2108 | } |
| 2109 | if (name == QLatin1String("name" )) { |
| 2110 | setAttributeName(attribute.value().toString()); |
| 2111 | continue; |
| 2112 | } |
| 2113 | if (name == QLatin1String("native" )) { |
| 2114 | setAttributeNative(attribute.value() == QLatin1String("true" )); |
| 2115 | continue; |
| 2116 | } |
| 2117 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 2118 | } |
| 2119 | |
| 2120 | while (!reader.hasError()) { |
| 2121 | switch (reader.readNext()) { |
| 2122 | case QXmlStreamReader::StartElement : { |
| 2123 | const auto tag = reader.name(); |
| 2124 | if (!tag.compare(QLatin1String("class" ), Qt::CaseInsensitive)) { |
| 2125 | m_class.append(reader.readElementText()); |
| 2126 | continue; |
| 2127 | } |
| 2128 | if (!tag.compare(QLatin1String("property" ), Qt::CaseInsensitive)) { |
| 2129 | auto *v = new DomProperty(); |
| 2130 | v->read(reader); |
| 2131 | m_property.append(v); |
| 2132 | continue; |
| 2133 | } |
| 2134 | if (!tag.compare(QLatin1String("script" ), Qt::CaseInsensitive)) { |
| 2135 | qWarning("Omitting deprecated element <script>." ); |
| 2136 | reader.skipCurrentElement(); |
| 2137 | continue; |
| 2138 | } |
| 2139 | if (!tag.compare(QLatin1String("widgetdata" ), Qt::CaseInsensitive)) { |
| 2140 | qWarning("Omitting deprecated element <widgetdata>." ); |
| 2141 | reader.skipCurrentElement(); |
| 2142 | continue; |
| 2143 | } |
| 2144 | if (!tag.compare(QLatin1String("attribute" ), Qt::CaseInsensitive)) { |
| 2145 | auto *v = new DomProperty(); |
| 2146 | v->read(reader); |
| 2147 | m_attribute.append(v); |
| 2148 | continue; |
| 2149 | } |
| 2150 | if (!tag.compare(QLatin1String("row" ), Qt::CaseInsensitive)) { |
| 2151 | auto *v = new DomRow(); |
| 2152 | v->read(reader); |
| 2153 | m_row.append(v); |
| 2154 | continue; |
| 2155 | } |
| 2156 | if (!tag.compare(QLatin1String("column" ), Qt::CaseInsensitive)) { |
| 2157 | auto *v = new DomColumn(); |
| 2158 | v->read(reader); |
| 2159 | m_column.append(v); |
| 2160 | continue; |
| 2161 | } |
| 2162 | if (!tag.compare(QLatin1String("item" ), Qt::CaseInsensitive)) { |
| 2163 | auto *v = new DomItem(); |
| 2164 | v->read(reader); |
| 2165 | m_item.append(v); |
| 2166 | continue; |
| 2167 | } |
| 2168 | if (!tag.compare(QLatin1String("layout" ), Qt::CaseInsensitive)) { |
| 2169 | auto *v = new DomLayout(); |
| 2170 | v->read(reader); |
| 2171 | m_layout.append(v); |
| 2172 | continue; |
| 2173 | } |
| 2174 | if (!tag.compare(QLatin1String("widget" ), Qt::CaseInsensitive)) { |
| 2175 | auto *v = new DomWidget(); |
| 2176 | v->read(reader); |
| 2177 | m_widget.append(v); |
| 2178 | continue; |
| 2179 | } |
| 2180 | if (!tag.compare(QLatin1String("action" ), Qt::CaseInsensitive)) { |
| 2181 | auto *v = new DomAction(); |
| 2182 | v->read(reader); |
| 2183 | m_action.append(v); |
| 2184 | continue; |
| 2185 | } |
| 2186 | if (!tag.compare(QLatin1String("actiongroup" ), Qt::CaseInsensitive)) { |
| 2187 | auto *v = new DomActionGroup(); |
| 2188 | v->read(reader); |
| 2189 | m_actionGroup.append(v); |
| 2190 | continue; |
| 2191 | } |
| 2192 | if (!tag.compare(QLatin1String("addaction" ), Qt::CaseInsensitive)) { |
| 2193 | auto *v = new DomActionRef(); |
| 2194 | v->read(reader); |
| 2195 | m_addAction.append(v); |
| 2196 | continue; |
| 2197 | } |
| 2198 | if (!tag.compare(QLatin1String("zorder" ), Qt::CaseInsensitive)) { |
| 2199 | m_zOrder.append(reader.readElementText()); |
| 2200 | continue; |
| 2201 | } |
| 2202 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 2203 | } |
| 2204 | break; |
| 2205 | case QXmlStreamReader::EndElement : |
| 2206 | return; |
| 2207 | default : |
| 2208 | break; |
| 2209 | } |
| 2210 | } |
| 2211 | } |
| 2212 | |
| 2213 | void DomWidget::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 2214 | { |
| 2215 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("widget" ) : tagName.toLower()); |
| 2216 | |
| 2217 | if (hasAttributeClass()) |
| 2218 | writer.writeAttribute(QStringLiteral("class" ), attributeClass()); |
| 2219 | |
| 2220 | if (hasAttributeName()) |
| 2221 | writer.writeAttribute(QStringLiteral("name" ), attributeName()); |
| 2222 | |
| 2223 | if (hasAttributeNative()) |
| 2224 | writer.writeAttribute(QStringLiteral("native" ), (attributeNative() ? QLatin1String("true" ) : QLatin1String("false" ))); |
| 2225 | |
| 2226 | for (const QString &v : m_class) |
| 2227 | writer.writeTextElement(QStringLiteral("class" ), v); |
| 2228 | |
| 2229 | for (DomProperty *v : m_property) |
| 2230 | v->write(writer, QStringLiteral("property" )); |
| 2231 | |
| 2232 | for (DomProperty *v : m_attribute) |
| 2233 | v->write(writer, QStringLiteral("attribute" )); |
| 2234 | |
| 2235 | for (DomRow *v : m_row) |
| 2236 | v->write(writer, QStringLiteral("row" )); |
| 2237 | |
| 2238 | for (DomColumn *v : m_column) |
| 2239 | v->write(writer, QStringLiteral("column" )); |
| 2240 | |
| 2241 | for (DomItem *v : m_item) |
| 2242 | v->write(writer, QStringLiteral("item" )); |
| 2243 | |
| 2244 | for (DomLayout *v : m_layout) |
| 2245 | v->write(writer, QStringLiteral("layout" )); |
| 2246 | |
| 2247 | for (DomWidget *v : m_widget) |
| 2248 | v->write(writer, QStringLiteral("widget" )); |
| 2249 | |
| 2250 | for (DomAction *v : m_action) |
| 2251 | v->write(writer, QStringLiteral("action" )); |
| 2252 | |
| 2253 | for (DomActionGroup *v : m_actionGroup) |
| 2254 | v->write(writer, QStringLiteral("actiongroup" )); |
| 2255 | |
| 2256 | for (DomActionRef *v : m_addAction) |
| 2257 | v->write(writer, QStringLiteral("addaction" )); |
| 2258 | |
| 2259 | for (const QString &v : m_zOrder) |
| 2260 | writer.writeTextElement(QStringLiteral("zorder" ), v); |
| 2261 | |
| 2262 | writer.writeEndElement(); |
| 2263 | } |
| 2264 | |
| 2265 | void DomWidget::setElementClass(const QStringList &a) |
| 2266 | { |
| 2267 | m_children |= Class; |
| 2268 | m_class = a; |
| 2269 | } |
| 2270 | |
| 2271 | void DomWidget::setElementProperty(const QList<DomProperty *> &a) |
| 2272 | { |
| 2273 | m_children |= Property; |
| 2274 | m_property = a; |
| 2275 | } |
| 2276 | |
| 2277 | void DomWidget::setElementAttribute(const QList<DomProperty *> &a) |
| 2278 | { |
| 2279 | m_children |= Attribute; |
| 2280 | m_attribute = a; |
| 2281 | } |
| 2282 | |
| 2283 | void DomWidget::setElementRow(const QList<DomRow *> &a) |
| 2284 | { |
| 2285 | m_children |= Row; |
| 2286 | m_row = a; |
| 2287 | } |
| 2288 | |
| 2289 | void DomWidget::setElementColumn(const QList<DomColumn *> &a) |
| 2290 | { |
| 2291 | m_children |= Column; |
| 2292 | m_column = a; |
| 2293 | } |
| 2294 | |
| 2295 | void DomWidget::setElementItem(const QList<DomItem *> &a) |
| 2296 | { |
| 2297 | m_children |= Item; |
| 2298 | m_item = a; |
| 2299 | } |
| 2300 | |
| 2301 | void DomWidget::setElementLayout(const QList<DomLayout *> &a) |
| 2302 | { |
| 2303 | m_children |= Layout; |
| 2304 | m_layout = a; |
| 2305 | } |
| 2306 | |
| 2307 | void DomWidget::setElementWidget(const QList<DomWidget *> &a) |
| 2308 | { |
| 2309 | m_children |= Widget; |
| 2310 | m_widget = a; |
| 2311 | } |
| 2312 | |
| 2313 | void DomWidget::setElementAction(const QList<DomAction *> &a) |
| 2314 | { |
| 2315 | m_children |= Action; |
| 2316 | m_action = a; |
| 2317 | } |
| 2318 | |
| 2319 | void DomWidget::setElementActionGroup(const QList<DomActionGroup *> &a) |
| 2320 | { |
| 2321 | m_children |= ActionGroup; |
| 2322 | m_actionGroup = a; |
| 2323 | } |
| 2324 | |
| 2325 | void DomWidget::setElementAddAction(const QList<DomActionRef *> &a) |
| 2326 | { |
| 2327 | m_children |= AddAction; |
| 2328 | m_addAction = a; |
| 2329 | } |
| 2330 | |
| 2331 | void DomWidget::setElementZOrder(const QStringList &a) |
| 2332 | { |
| 2333 | m_children |= ZOrder; |
| 2334 | m_zOrder = a; |
| 2335 | } |
| 2336 | |
| 2337 | DomSpacer::~DomSpacer() |
| 2338 | { |
| 2339 | qDeleteAll(m_property); |
| 2340 | m_property.clear(); |
| 2341 | } |
| 2342 | |
| 2343 | void DomSpacer::read(QXmlStreamReader &reader) |
| 2344 | { |
| 2345 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 2346 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 2347 | const auto name = attribute.name(); |
| 2348 | if (name == QLatin1String("name" )) { |
| 2349 | setAttributeName(attribute.value().toString()); |
| 2350 | continue; |
| 2351 | } |
| 2352 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 2353 | } |
| 2354 | |
| 2355 | while (!reader.hasError()) { |
| 2356 | switch (reader.readNext()) { |
| 2357 | case QXmlStreamReader::StartElement : { |
| 2358 | const auto tag = reader.name(); |
| 2359 | if (!tag.compare(QLatin1String("property" ), Qt::CaseInsensitive)) { |
| 2360 | auto *v = new DomProperty(); |
| 2361 | v->read(reader); |
| 2362 | m_property.append(v); |
| 2363 | continue; |
| 2364 | } |
| 2365 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 2366 | } |
| 2367 | break; |
| 2368 | case QXmlStreamReader::EndElement : |
| 2369 | return; |
| 2370 | default : |
| 2371 | break; |
| 2372 | } |
| 2373 | } |
| 2374 | } |
| 2375 | |
| 2376 | void DomSpacer::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 2377 | { |
| 2378 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("spacer" ) : tagName.toLower()); |
| 2379 | |
| 2380 | if (hasAttributeName()) |
| 2381 | writer.writeAttribute(QStringLiteral("name" ), attributeName()); |
| 2382 | |
| 2383 | for (DomProperty *v : m_property) |
| 2384 | v->write(writer, QStringLiteral("property" )); |
| 2385 | |
| 2386 | writer.writeEndElement(); |
| 2387 | } |
| 2388 | |
| 2389 | void DomSpacer::setElementProperty(const QList<DomProperty *> &a) |
| 2390 | { |
| 2391 | m_children |= Property; |
| 2392 | m_property = a; |
| 2393 | } |
| 2394 | |
| 2395 | DomColor::~DomColor() = default; |
| 2396 | |
| 2397 | void DomColor::read(QXmlStreamReader &reader) |
| 2398 | { |
| 2399 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 2400 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 2401 | const auto name = attribute.name(); |
| 2402 | if (name == QLatin1String("alpha" )) { |
| 2403 | setAttributeAlpha(attribute.value().toInt()); |
| 2404 | continue; |
| 2405 | } |
| 2406 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 2407 | } |
| 2408 | |
| 2409 | while (!reader.hasError()) { |
| 2410 | switch (reader.readNext()) { |
| 2411 | case QXmlStreamReader::StartElement : { |
| 2412 | const auto tag = reader.name(); |
| 2413 | if (!tag.compare(QLatin1String("red" ), Qt::CaseInsensitive)) { |
| 2414 | setElementRed(reader.readElementText().toInt()); |
| 2415 | continue; |
| 2416 | } |
| 2417 | if (!tag.compare(QLatin1String("green" ), Qt::CaseInsensitive)) { |
| 2418 | setElementGreen(reader.readElementText().toInt()); |
| 2419 | continue; |
| 2420 | } |
| 2421 | if (!tag.compare(QLatin1String("blue" ), Qt::CaseInsensitive)) { |
| 2422 | setElementBlue(reader.readElementText().toInt()); |
| 2423 | continue; |
| 2424 | } |
| 2425 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 2426 | } |
| 2427 | break; |
| 2428 | case QXmlStreamReader::EndElement : |
| 2429 | return; |
| 2430 | default : |
| 2431 | break; |
| 2432 | } |
| 2433 | } |
| 2434 | } |
| 2435 | |
| 2436 | void DomColor::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 2437 | { |
| 2438 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("color" ) : tagName.toLower()); |
| 2439 | |
| 2440 | if (hasAttributeAlpha()) |
| 2441 | writer.writeAttribute(QStringLiteral("alpha" ), QString::number(attributeAlpha())); |
| 2442 | |
| 2443 | if (m_children & Red) |
| 2444 | writer.writeTextElement(QStringLiteral("red" ), QString::number(m_red)); |
| 2445 | |
| 2446 | if (m_children & Green) |
| 2447 | writer.writeTextElement(QStringLiteral("green" ), QString::number(m_green)); |
| 2448 | |
| 2449 | if (m_children & Blue) |
| 2450 | writer.writeTextElement(QStringLiteral("blue" ), QString::number(m_blue)); |
| 2451 | |
| 2452 | writer.writeEndElement(); |
| 2453 | } |
| 2454 | |
| 2455 | void DomColor::setElementRed(int a) |
| 2456 | { |
| 2457 | m_children |= Red; |
| 2458 | m_red = a; |
| 2459 | } |
| 2460 | |
| 2461 | void DomColor::setElementGreen(int a) |
| 2462 | { |
| 2463 | m_children |= Green; |
| 2464 | m_green = a; |
| 2465 | } |
| 2466 | |
| 2467 | void DomColor::setElementBlue(int a) |
| 2468 | { |
| 2469 | m_children |= Blue; |
| 2470 | m_blue = a; |
| 2471 | } |
| 2472 | |
| 2473 | void DomColor::clearElementRed() |
| 2474 | { |
| 2475 | m_children &= ~Red; |
| 2476 | } |
| 2477 | |
| 2478 | void DomColor::clearElementGreen() |
| 2479 | { |
| 2480 | m_children &= ~Green; |
| 2481 | } |
| 2482 | |
| 2483 | void DomColor::clearElementBlue() |
| 2484 | { |
| 2485 | m_children &= ~Blue; |
| 2486 | } |
| 2487 | |
| 2488 | DomGradientStop::~DomGradientStop() |
| 2489 | { |
| 2490 | delete m_color; |
| 2491 | } |
| 2492 | |
| 2493 | void DomGradientStop::read(QXmlStreamReader &reader) |
| 2494 | { |
| 2495 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 2496 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 2497 | const auto name = attribute.name(); |
| 2498 | if (name == QLatin1String("position" )) { |
| 2499 | setAttributePosition(attribute.value().toDouble()); |
| 2500 | continue; |
| 2501 | } |
| 2502 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 2503 | } |
| 2504 | |
| 2505 | while (!reader.hasError()) { |
| 2506 | switch (reader.readNext()) { |
| 2507 | case QXmlStreamReader::StartElement : { |
| 2508 | const auto tag = reader.name(); |
| 2509 | if (!tag.compare(QLatin1String("color" ), Qt::CaseInsensitive)) { |
| 2510 | auto *v = new DomColor(); |
| 2511 | v->read(reader); |
| 2512 | setElementColor(v); |
| 2513 | continue; |
| 2514 | } |
| 2515 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 2516 | } |
| 2517 | break; |
| 2518 | case QXmlStreamReader::EndElement : |
| 2519 | return; |
| 2520 | default : |
| 2521 | break; |
| 2522 | } |
| 2523 | } |
| 2524 | } |
| 2525 | |
| 2526 | void DomGradientStop::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 2527 | { |
| 2528 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("gradientstop" ) : tagName.toLower()); |
| 2529 | |
| 2530 | if (hasAttributePosition()) |
| 2531 | writer.writeAttribute(QStringLiteral("position" ), QString::number(attributePosition(), 'f', 15)); |
| 2532 | |
| 2533 | if (m_children & Color) |
| 2534 | m_color->write(writer, QStringLiteral("color" )); |
| 2535 | |
| 2536 | writer.writeEndElement(); |
| 2537 | } |
| 2538 | |
| 2539 | DomColor *DomGradientStop::takeElementColor() |
| 2540 | { |
| 2541 | DomColor *a = m_color; |
| 2542 | m_color = nullptr; |
| 2543 | m_children ^= Color; |
| 2544 | return a; |
| 2545 | } |
| 2546 | |
| 2547 | void DomGradientStop::setElementColor(DomColor *a) |
| 2548 | { |
| 2549 | delete m_color; |
| 2550 | m_children |= Color; |
| 2551 | m_color = a; |
| 2552 | } |
| 2553 | |
| 2554 | void DomGradientStop::clearElementColor() |
| 2555 | { |
| 2556 | delete m_color; |
| 2557 | m_color = nullptr; |
| 2558 | m_children &= ~Color; |
| 2559 | } |
| 2560 | |
| 2561 | DomGradient::~DomGradient() |
| 2562 | { |
| 2563 | qDeleteAll(m_gradientStop); |
| 2564 | m_gradientStop.clear(); |
| 2565 | } |
| 2566 | |
| 2567 | void DomGradient::read(QXmlStreamReader &reader) |
| 2568 | { |
| 2569 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 2570 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 2571 | const auto name = attribute.name(); |
| 2572 | if (name == QLatin1String("startx" )) { |
| 2573 | setAttributeStartX(attribute.value().toDouble()); |
| 2574 | continue; |
| 2575 | } |
| 2576 | if (name == QLatin1String("starty" )) { |
| 2577 | setAttributeStartY(attribute.value().toDouble()); |
| 2578 | continue; |
| 2579 | } |
| 2580 | if (name == QLatin1String("endx" )) { |
| 2581 | setAttributeEndX(attribute.value().toDouble()); |
| 2582 | continue; |
| 2583 | } |
| 2584 | if (name == QLatin1String("endy" )) { |
| 2585 | setAttributeEndY(attribute.value().toDouble()); |
| 2586 | continue; |
| 2587 | } |
| 2588 | if (name == QLatin1String("centralx" )) { |
| 2589 | setAttributeCentralX(attribute.value().toDouble()); |
| 2590 | continue; |
| 2591 | } |
| 2592 | if (name == QLatin1String("centraly" )) { |
| 2593 | setAttributeCentralY(attribute.value().toDouble()); |
| 2594 | continue; |
| 2595 | } |
| 2596 | if (name == QLatin1String("focalx" )) { |
| 2597 | setAttributeFocalX(attribute.value().toDouble()); |
| 2598 | continue; |
| 2599 | } |
| 2600 | if (name == QLatin1String("focaly" )) { |
| 2601 | setAttributeFocalY(attribute.value().toDouble()); |
| 2602 | continue; |
| 2603 | } |
| 2604 | if (name == QLatin1String("radius" )) { |
| 2605 | setAttributeRadius(attribute.value().toDouble()); |
| 2606 | continue; |
| 2607 | } |
| 2608 | if (name == QLatin1String("angle" )) { |
| 2609 | setAttributeAngle(attribute.value().toDouble()); |
| 2610 | continue; |
| 2611 | } |
| 2612 | if (name == QLatin1String("type" )) { |
| 2613 | setAttributeType(attribute.value().toString()); |
| 2614 | continue; |
| 2615 | } |
| 2616 | if (name == QLatin1String("spread" )) { |
| 2617 | setAttributeSpread(attribute.value().toString()); |
| 2618 | continue; |
| 2619 | } |
| 2620 | if (name == QLatin1String("coordinatemode" )) { |
| 2621 | setAttributeCoordinateMode(attribute.value().toString()); |
| 2622 | continue; |
| 2623 | } |
| 2624 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 2625 | } |
| 2626 | |
| 2627 | while (!reader.hasError()) { |
| 2628 | switch (reader.readNext()) { |
| 2629 | case QXmlStreamReader::StartElement : { |
| 2630 | const auto tag = reader.name(); |
| 2631 | if (!tag.compare(QLatin1String("gradientstop" ), Qt::CaseInsensitive)) { |
| 2632 | auto *v = new DomGradientStop(); |
| 2633 | v->read(reader); |
| 2634 | m_gradientStop.append(v); |
| 2635 | continue; |
| 2636 | } |
| 2637 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 2638 | } |
| 2639 | break; |
| 2640 | case QXmlStreamReader::EndElement : |
| 2641 | return; |
| 2642 | default : |
| 2643 | break; |
| 2644 | } |
| 2645 | } |
| 2646 | } |
| 2647 | |
| 2648 | void DomGradient::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 2649 | { |
| 2650 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("gradient" ) : tagName.toLower()); |
| 2651 | |
| 2652 | if (hasAttributeStartX()) |
| 2653 | writer.writeAttribute(QStringLiteral("startx" ), QString::number(attributeStartX(), 'f', 15)); |
| 2654 | |
| 2655 | if (hasAttributeStartY()) |
| 2656 | writer.writeAttribute(QStringLiteral("starty" ), QString::number(attributeStartY(), 'f', 15)); |
| 2657 | |
| 2658 | if (hasAttributeEndX()) |
| 2659 | writer.writeAttribute(QStringLiteral("endx" ), QString::number(attributeEndX(), 'f', 15)); |
| 2660 | |
| 2661 | if (hasAttributeEndY()) |
| 2662 | writer.writeAttribute(QStringLiteral("endy" ), QString::number(attributeEndY(), 'f', 15)); |
| 2663 | |
| 2664 | if (hasAttributeCentralX()) |
| 2665 | writer.writeAttribute(QStringLiteral("centralx" ), QString::number(attributeCentralX(), 'f', 15)); |
| 2666 | |
| 2667 | if (hasAttributeCentralY()) |
| 2668 | writer.writeAttribute(QStringLiteral("centraly" ), QString::number(attributeCentralY(), 'f', 15)); |
| 2669 | |
| 2670 | if (hasAttributeFocalX()) |
| 2671 | writer.writeAttribute(QStringLiteral("focalx" ), QString::number(attributeFocalX(), 'f', 15)); |
| 2672 | |
| 2673 | if (hasAttributeFocalY()) |
| 2674 | writer.writeAttribute(QStringLiteral("focaly" ), QString::number(attributeFocalY(), 'f', 15)); |
| 2675 | |
| 2676 | if (hasAttributeRadius()) |
| 2677 | writer.writeAttribute(QStringLiteral("radius" ), QString::number(attributeRadius(), 'f', 15)); |
| 2678 | |
| 2679 | if (hasAttributeAngle()) |
| 2680 | writer.writeAttribute(QStringLiteral("angle" ), QString::number(attributeAngle(), 'f', 15)); |
| 2681 | |
| 2682 | if (hasAttributeType()) |
| 2683 | writer.writeAttribute(QStringLiteral("type" ), attributeType()); |
| 2684 | |
| 2685 | if (hasAttributeSpread()) |
| 2686 | writer.writeAttribute(QStringLiteral("spread" ), attributeSpread()); |
| 2687 | |
| 2688 | if (hasAttributeCoordinateMode()) |
| 2689 | writer.writeAttribute(QStringLiteral("coordinatemode" ), attributeCoordinateMode()); |
| 2690 | |
| 2691 | for (DomGradientStop *v : m_gradientStop) |
| 2692 | v->write(writer, QStringLiteral("gradientstop" )); |
| 2693 | |
| 2694 | writer.writeEndElement(); |
| 2695 | } |
| 2696 | |
| 2697 | void DomGradient::setElementGradientStop(const QList<DomGradientStop *> &a) |
| 2698 | { |
| 2699 | m_children |= GradientStop; |
| 2700 | m_gradientStop = a; |
| 2701 | } |
| 2702 | |
| 2703 | DomBrush::~DomBrush() |
| 2704 | { |
| 2705 | delete m_color; |
| 2706 | delete m_texture; |
| 2707 | delete m_gradient; |
| 2708 | } |
| 2709 | |
| 2710 | void DomBrush::clear() |
| 2711 | { |
| 2712 | delete m_color; |
| 2713 | delete m_texture; |
| 2714 | delete m_gradient; |
| 2715 | |
| 2716 | m_kind = Unknown; |
| 2717 | |
| 2718 | m_color = nullptr; |
| 2719 | m_texture = nullptr; |
| 2720 | m_gradient = nullptr; |
| 2721 | } |
| 2722 | |
| 2723 | void DomBrush::read(QXmlStreamReader &reader) |
| 2724 | { |
| 2725 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 2726 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 2727 | const auto name = attribute.name(); |
| 2728 | if (name == QLatin1String("brushstyle" )) { |
| 2729 | setAttributeBrushStyle(attribute.value().toString()); |
| 2730 | continue; |
| 2731 | } |
| 2732 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 2733 | } |
| 2734 | |
| 2735 | while (!reader.hasError()) { |
| 2736 | switch (reader.readNext()) { |
| 2737 | case QXmlStreamReader::StartElement : { |
| 2738 | const auto tag = reader.name(); |
| 2739 | if (!tag.compare(QLatin1String("color" ), Qt::CaseInsensitive)) { |
| 2740 | auto *v = new DomColor(); |
| 2741 | v->read(reader); |
| 2742 | setElementColor(v); |
| 2743 | continue; |
| 2744 | } |
| 2745 | if (!tag.compare(QLatin1String("texture" ), Qt::CaseInsensitive)) { |
| 2746 | auto *v = new DomProperty(); |
| 2747 | v->read(reader); |
| 2748 | setElementTexture(v); |
| 2749 | continue; |
| 2750 | } |
| 2751 | if (!tag.compare(QLatin1String("gradient" ), Qt::CaseInsensitive)) { |
| 2752 | auto *v = new DomGradient(); |
| 2753 | v->read(reader); |
| 2754 | setElementGradient(v); |
| 2755 | continue; |
| 2756 | } |
| 2757 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 2758 | } |
| 2759 | break; |
| 2760 | case QXmlStreamReader::EndElement : |
| 2761 | return; |
| 2762 | default : |
| 2763 | break; |
| 2764 | } |
| 2765 | } |
| 2766 | } |
| 2767 | |
| 2768 | void DomBrush::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 2769 | { |
| 2770 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("brush" ) : tagName.toLower()); |
| 2771 | |
| 2772 | if (hasAttributeBrushStyle()) |
| 2773 | writer.writeAttribute(QStringLiteral("brushstyle" ), attributeBrushStyle()); |
| 2774 | |
| 2775 | switch (kind()) { |
| 2776 | case Color: |
| 2777 | if (m_color != nullptr) |
| 2778 | m_color->write(writer, QStringLiteral("color" )); |
| 2779 | break; |
| 2780 | |
| 2781 | case Texture: |
| 2782 | if (m_texture != nullptr) |
| 2783 | m_texture->write(writer, QStringLiteral("texture" )); |
| 2784 | break; |
| 2785 | |
| 2786 | case Gradient: |
| 2787 | if (m_gradient != nullptr) |
| 2788 | m_gradient->write(writer, QStringLiteral("gradient" )); |
| 2789 | break; |
| 2790 | |
| 2791 | default: |
| 2792 | break; |
| 2793 | } |
| 2794 | writer.writeEndElement(); |
| 2795 | } |
| 2796 | |
| 2797 | DomColor *DomBrush::takeElementColor() |
| 2798 | { |
| 2799 | DomColor *a = m_color; |
| 2800 | m_color = nullptr; |
| 2801 | return a; |
| 2802 | } |
| 2803 | |
| 2804 | void DomBrush::setElementColor(DomColor *a) |
| 2805 | { |
| 2806 | clear(); |
| 2807 | m_kind = Color; |
| 2808 | m_color = a; |
| 2809 | } |
| 2810 | |
| 2811 | DomProperty *DomBrush::takeElementTexture() |
| 2812 | { |
| 2813 | DomProperty *a = m_texture; |
| 2814 | m_texture = nullptr; |
| 2815 | return a; |
| 2816 | } |
| 2817 | |
| 2818 | void DomBrush::setElementTexture(DomProperty *a) |
| 2819 | { |
| 2820 | clear(); |
| 2821 | m_kind = Texture; |
| 2822 | m_texture = a; |
| 2823 | } |
| 2824 | |
| 2825 | DomGradient *DomBrush::takeElementGradient() |
| 2826 | { |
| 2827 | DomGradient *a = m_gradient; |
| 2828 | m_gradient = nullptr; |
| 2829 | return a; |
| 2830 | } |
| 2831 | |
| 2832 | void DomBrush::setElementGradient(DomGradient *a) |
| 2833 | { |
| 2834 | clear(); |
| 2835 | m_kind = Gradient; |
| 2836 | m_gradient = a; |
| 2837 | } |
| 2838 | |
| 2839 | DomColorRole::~DomColorRole() |
| 2840 | { |
| 2841 | delete m_brush; |
| 2842 | } |
| 2843 | |
| 2844 | void DomColorRole::read(QXmlStreamReader &reader) |
| 2845 | { |
| 2846 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 2847 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 2848 | const auto name = attribute.name(); |
| 2849 | if (name == QLatin1String("role" )) { |
| 2850 | setAttributeRole(attribute.value().toString()); |
| 2851 | continue; |
| 2852 | } |
| 2853 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 2854 | } |
| 2855 | |
| 2856 | while (!reader.hasError()) { |
| 2857 | switch (reader.readNext()) { |
| 2858 | case QXmlStreamReader::StartElement : { |
| 2859 | const auto tag = reader.name(); |
| 2860 | if (!tag.compare(QLatin1String("brush" ), Qt::CaseInsensitive)) { |
| 2861 | auto *v = new DomBrush(); |
| 2862 | v->read(reader); |
| 2863 | setElementBrush(v); |
| 2864 | continue; |
| 2865 | } |
| 2866 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 2867 | } |
| 2868 | break; |
| 2869 | case QXmlStreamReader::EndElement : |
| 2870 | return; |
| 2871 | default : |
| 2872 | break; |
| 2873 | } |
| 2874 | } |
| 2875 | } |
| 2876 | |
| 2877 | void DomColorRole::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 2878 | { |
| 2879 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("colorrole" ) : tagName.toLower()); |
| 2880 | |
| 2881 | if (hasAttributeRole()) |
| 2882 | writer.writeAttribute(QStringLiteral("role" ), attributeRole()); |
| 2883 | |
| 2884 | if (m_children & Brush) |
| 2885 | m_brush->write(writer, QStringLiteral("brush" )); |
| 2886 | |
| 2887 | writer.writeEndElement(); |
| 2888 | } |
| 2889 | |
| 2890 | DomBrush *DomColorRole::takeElementBrush() |
| 2891 | { |
| 2892 | DomBrush *a = m_brush; |
| 2893 | m_brush = nullptr; |
| 2894 | m_children ^= Brush; |
| 2895 | return a; |
| 2896 | } |
| 2897 | |
| 2898 | void DomColorRole::setElementBrush(DomBrush *a) |
| 2899 | { |
| 2900 | delete m_brush; |
| 2901 | m_children |= Brush; |
| 2902 | m_brush = a; |
| 2903 | } |
| 2904 | |
| 2905 | void DomColorRole::clearElementBrush() |
| 2906 | { |
| 2907 | delete m_brush; |
| 2908 | m_brush = nullptr; |
| 2909 | m_children &= ~Brush; |
| 2910 | } |
| 2911 | |
| 2912 | DomColorGroup::~DomColorGroup() |
| 2913 | { |
| 2914 | qDeleteAll(m_colorRole); |
| 2915 | m_colorRole.clear(); |
| 2916 | qDeleteAll(m_color); |
| 2917 | m_color.clear(); |
| 2918 | } |
| 2919 | |
| 2920 | void DomColorGroup::read(QXmlStreamReader &reader) |
| 2921 | { |
| 2922 | while (!reader.hasError()) { |
| 2923 | switch (reader.readNext()) { |
| 2924 | case QXmlStreamReader::StartElement : { |
| 2925 | const auto tag = reader.name(); |
| 2926 | if (!tag.compare(QLatin1String("colorrole" ), Qt::CaseInsensitive)) { |
| 2927 | auto *v = new DomColorRole(); |
| 2928 | v->read(reader); |
| 2929 | m_colorRole.append(v); |
| 2930 | continue; |
| 2931 | } |
| 2932 | if (!tag.compare(QLatin1String("color" ), Qt::CaseInsensitive)) { |
| 2933 | auto *v = new DomColor(); |
| 2934 | v->read(reader); |
| 2935 | m_color.append(v); |
| 2936 | continue; |
| 2937 | } |
| 2938 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 2939 | } |
| 2940 | break; |
| 2941 | case QXmlStreamReader::EndElement : |
| 2942 | return; |
| 2943 | default : |
| 2944 | break; |
| 2945 | } |
| 2946 | } |
| 2947 | } |
| 2948 | |
| 2949 | void DomColorGroup::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 2950 | { |
| 2951 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("colorgroup" ) : tagName.toLower()); |
| 2952 | |
| 2953 | for (DomColorRole *v : m_colorRole) |
| 2954 | v->write(writer, QStringLiteral("colorrole" )); |
| 2955 | |
| 2956 | for (DomColor *v : m_color) |
| 2957 | v->write(writer, QStringLiteral("color" )); |
| 2958 | |
| 2959 | writer.writeEndElement(); |
| 2960 | } |
| 2961 | |
| 2962 | void DomColorGroup::setElementColorRole(const QList<DomColorRole *> &a) |
| 2963 | { |
| 2964 | m_children |= ColorRole; |
| 2965 | m_colorRole = a; |
| 2966 | } |
| 2967 | |
| 2968 | void DomColorGroup::setElementColor(const QList<DomColor *> &a) |
| 2969 | { |
| 2970 | m_children |= Color; |
| 2971 | m_color = a; |
| 2972 | } |
| 2973 | |
| 2974 | DomPalette::~DomPalette() |
| 2975 | { |
| 2976 | delete m_active; |
| 2977 | delete m_inactive; |
| 2978 | delete m_disabled; |
| 2979 | } |
| 2980 | |
| 2981 | void DomPalette::read(QXmlStreamReader &reader) |
| 2982 | { |
| 2983 | while (!reader.hasError()) { |
| 2984 | switch (reader.readNext()) { |
| 2985 | case QXmlStreamReader::StartElement : { |
| 2986 | const auto tag = reader.name(); |
| 2987 | if (!tag.compare(QLatin1String("active" ), Qt::CaseInsensitive)) { |
| 2988 | auto *v = new DomColorGroup(); |
| 2989 | v->read(reader); |
| 2990 | setElementActive(v); |
| 2991 | continue; |
| 2992 | } |
| 2993 | if (!tag.compare(QLatin1String("inactive" ), Qt::CaseInsensitive)) { |
| 2994 | auto *v = new DomColorGroup(); |
| 2995 | v->read(reader); |
| 2996 | setElementInactive(v); |
| 2997 | continue; |
| 2998 | } |
| 2999 | if (!tag.compare(QLatin1String("disabled" ), Qt::CaseInsensitive)) { |
| 3000 | auto *v = new DomColorGroup(); |
| 3001 | v->read(reader); |
| 3002 | setElementDisabled(v); |
| 3003 | continue; |
| 3004 | } |
| 3005 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 3006 | } |
| 3007 | break; |
| 3008 | case QXmlStreamReader::EndElement : |
| 3009 | return; |
| 3010 | default : |
| 3011 | break; |
| 3012 | } |
| 3013 | } |
| 3014 | } |
| 3015 | |
| 3016 | void DomPalette::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 3017 | { |
| 3018 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("palette" ) : tagName.toLower()); |
| 3019 | |
| 3020 | if (m_children & Active) |
| 3021 | m_active->write(writer, QStringLiteral("active" )); |
| 3022 | |
| 3023 | if (m_children & Inactive) |
| 3024 | m_inactive->write(writer, QStringLiteral("inactive" )); |
| 3025 | |
| 3026 | if (m_children & Disabled) |
| 3027 | m_disabled->write(writer, QStringLiteral("disabled" )); |
| 3028 | |
| 3029 | writer.writeEndElement(); |
| 3030 | } |
| 3031 | |
| 3032 | DomColorGroup *DomPalette::takeElementActive() |
| 3033 | { |
| 3034 | DomColorGroup *a = m_active; |
| 3035 | m_active = nullptr; |
| 3036 | m_children ^= Active; |
| 3037 | return a; |
| 3038 | } |
| 3039 | |
| 3040 | void DomPalette::setElementActive(DomColorGroup *a) |
| 3041 | { |
| 3042 | delete m_active; |
| 3043 | m_children |= Active; |
| 3044 | m_active = a; |
| 3045 | } |
| 3046 | |
| 3047 | DomColorGroup *DomPalette::takeElementInactive() |
| 3048 | { |
| 3049 | DomColorGroup *a = m_inactive; |
| 3050 | m_inactive = nullptr; |
| 3051 | m_children ^= Inactive; |
| 3052 | return a; |
| 3053 | } |
| 3054 | |
| 3055 | void DomPalette::setElementInactive(DomColorGroup *a) |
| 3056 | { |
| 3057 | delete m_inactive; |
| 3058 | m_children |= Inactive; |
| 3059 | m_inactive = a; |
| 3060 | } |
| 3061 | |
| 3062 | DomColorGroup *DomPalette::takeElementDisabled() |
| 3063 | { |
| 3064 | DomColorGroup *a = m_disabled; |
| 3065 | m_disabled = nullptr; |
| 3066 | m_children ^= Disabled; |
| 3067 | return a; |
| 3068 | } |
| 3069 | |
| 3070 | void DomPalette::setElementDisabled(DomColorGroup *a) |
| 3071 | { |
| 3072 | delete m_disabled; |
| 3073 | m_children |= Disabled; |
| 3074 | m_disabled = a; |
| 3075 | } |
| 3076 | |
| 3077 | void DomPalette::clearElementActive() |
| 3078 | { |
| 3079 | delete m_active; |
| 3080 | m_active = nullptr; |
| 3081 | m_children &= ~Active; |
| 3082 | } |
| 3083 | |
| 3084 | void DomPalette::clearElementInactive() |
| 3085 | { |
| 3086 | delete m_inactive; |
| 3087 | m_inactive = nullptr; |
| 3088 | m_children &= ~Inactive; |
| 3089 | } |
| 3090 | |
| 3091 | void DomPalette::clearElementDisabled() |
| 3092 | { |
| 3093 | delete m_disabled; |
| 3094 | m_disabled = nullptr; |
| 3095 | m_children &= ~Disabled; |
| 3096 | } |
| 3097 | |
| 3098 | DomFont::~DomFont() = default; |
| 3099 | |
| 3100 | void DomFont::read(QXmlStreamReader &reader) |
| 3101 | { |
| 3102 | while (!reader.hasError()) { |
| 3103 | switch (reader.readNext()) { |
| 3104 | case QXmlStreamReader::StartElement : { |
| 3105 | const auto tag = reader.name(); |
| 3106 | if (!tag.compare(QLatin1String("family" ), Qt::CaseInsensitive)) { |
| 3107 | setElementFamily(reader.readElementText()); |
| 3108 | continue; |
| 3109 | } |
| 3110 | if (!tag.compare(QLatin1String("pointsize" ), Qt::CaseInsensitive)) { |
| 3111 | setElementPointSize(reader.readElementText().toInt()); |
| 3112 | continue; |
| 3113 | } |
| 3114 | if (!tag.compare(QLatin1String("weight" ), Qt::CaseInsensitive)) { |
| 3115 | setElementWeight(reader.readElementText().toInt()); |
| 3116 | continue; |
| 3117 | } |
| 3118 | if (!tag.compare(QLatin1String("italic" ), Qt::CaseInsensitive)) { |
| 3119 | setElementItalic(reader.readElementText() == QLatin1String("true" )); |
| 3120 | continue; |
| 3121 | } |
| 3122 | if (!tag.compare(QLatin1String("bold" ), Qt::CaseInsensitive)) { |
| 3123 | setElementBold(reader.readElementText() == QLatin1String("true" )); |
| 3124 | continue; |
| 3125 | } |
| 3126 | if (!tag.compare(QLatin1String("underline" ), Qt::CaseInsensitive)) { |
| 3127 | setElementUnderline(reader.readElementText() == QLatin1String("true" )); |
| 3128 | continue; |
| 3129 | } |
| 3130 | if (!tag.compare(QLatin1String("strikeout" ), Qt::CaseInsensitive)) { |
| 3131 | setElementStrikeOut(reader.readElementText() == QLatin1String("true" )); |
| 3132 | continue; |
| 3133 | } |
| 3134 | if (!tag.compare(QLatin1String("antialiasing" ), Qt::CaseInsensitive)) { |
| 3135 | setElementAntialiasing(reader.readElementText() == QLatin1String("true" )); |
| 3136 | continue; |
| 3137 | } |
| 3138 | if (!tag.compare(QLatin1String("stylestrategy" ), Qt::CaseInsensitive)) { |
| 3139 | setElementStyleStrategy(reader.readElementText()); |
| 3140 | continue; |
| 3141 | } |
| 3142 | if (!tag.compare(QLatin1String("kerning" ), Qt::CaseInsensitive)) { |
| 3143 | setElementKerning(reader.readElementText() == QLatin1String("true" )); |
| 3144 | continue; |
| 3145 | } |
| 3146 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 3147 | } |
| 3148 | break; |
| 3149 | case QXmlStreamReader::EndElement : |
| 3150 | return; |
| 3151 | default : |
| 3152 | break; |
| 3153 | } |
| 3154 | } |
| 3155 | } |
| 3156 | |
| 3157 | void DomFont::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 3158 | { |
| 3159 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("font" ) : tagName.toLower()); |
| 3160 | |
| 3161 | if (m_children & Family) |
| 3162 | writer.writeTextElement(QStringLiteral("family" ), m_family); |
| 3163 | |
| 3164 | if (m_children & PointSize) |
| 3165 | writer.writeTextElement(QStringLiteral("pointsize" ), QString::number(m_pointSize)); |
| 3166 | |
| 3167 | if (m_children & Weight) |
| 3168 | writer.writeTextElement(QStringLiteral("weight" ), QString::number(m_weight)); |
| 3169 | |
| 3170 | if (m_children & Italic) |
| 3171 | writer.writeTextElement(QStringLiteral("italic" ), (m_italic ? QLatin1String("true" ) : QLatin1String("false" ))); |
| 3172 | |
| 3173 | if (m_children & Bold) |
| 3174 | writer.writeTextElement(QStringLiteral("bold" ), (m_bold ? QLatin1String("true" ) : QLatin1String("false" ))); |
| 3175 | |
| 3176 | if (m_children & Underline) |
| 3177 | writer.writeTextElement(QStringLiteral("underline" ), (m_underline ? QLatin1String("true" ) : QLatin1String("false" ))); |
| 3178 | |
| 3179 | if (m_children & StrikeOut) |
| 3180 | writer.writeTextElement(QStringLiteral("strikeout" ), (m_strikeOut ? QLatin1String("true" ) : QLatin1String("false" ))); |
| 3181 | |
| 3182 | if (m_children & Antialiasing) |
| 3183 | writer.writeTextElement(QStringLiteral("antialiasing" ), (m_antialiasing ? QLatin1String("true" ) : QLatin1String("false" ))); |
| 3184 | |
| 3185 | if (m_children & StyleStrategy) |
| 3186 | writer.writeTextElement(QStringLiteral("stylestrategy" ), m_styleStrategy); |
| 3187 | |
| 3188 | if (m_children & Kerning) |
| 3189 | writer.writeTextElement(QStringLiteral("kerning" ), (m_kerning ? QLatin1String("true" ) : QLatin1String("false" ))); |
| 3190 | |
| 3191 | writer.writeEndElement(); |
| 3192 | } |
| 3193 | |
| 3194 | void DomFont::setElementFamily(const QString &a) |
| 3195 | { |
| 3196 | m_children |= Family; |
| 3197 | m_family = a; |
| 3198 | } |
| 3199 | |
| 3200 | void DomFont::setElementPointSize(int a) |
| 3201 | { |
| 3202 | m_children |= PointSize; |
| 3203 | m_pointSize = a; |
| 3204 | } |
| 3205 | |
| 3206 | void DomFont::setElementWeight(int a) |
| 3207 | { |
| 3208 | m_children |= Weight; |
| 3209 | m_weight = a; |
| 3210 | } |
| 3211 | |
| 3212 | void DomFont::setElementItalic(bool a) |
| 3213 | { |
| 3214 | m_children |= Italic; |
| 3215 | m_italic = a; |
| 3216 | } |
| 3217 | |
| 3218 | void DomFont::setElementBold(bool a) |
| 3219 | { |
| 3220 | m_children |= Bold; |
| 3221 | m_bold = a; |
| 3222 | } |
| 3223 | |
| 3224 | void DomFont::setElementUnderline(bool a) |
| 3225 | { |
| 3226 | m_children |= Underline; |
| 3227 | m_underline = a; |
| 3228 | } |
| 3229 | |
| 3230 | void DomFont::setElementStrikeOut(bool a) |
| 3231 | { |
| 3232 | m_children |= StrikeOut; |
| 3233 | m_strikeOut = a; |
| 3234 | } |
| 3235 | |
| 3236 | void DomFont::setElementAntialiasing(bool a) |
| 3237 | { |
| 3238 | m_children |= Antialiasing; |
| 3239 | m_antialiasing = a; |
| 3240 | } |
| 3241 | |
| 3242 | void DomFont::setElementStyleStrategy(const QString &a) |
| 3243 | { |
| 3244 | m_children |= StyleStrategy; |
| 3245 | m_styleStrategy = a; |
| 3246 | } |
| 3247 | |
| 3248 | void DomFont::setElementKerning(bool a) |
| 3249 | { |
| 3250 | m_children |= Kerning; |
| 3251 | m_kerning = a; |
| 3252 | } |
| 3253 | |
| 3254 | void DomFont::clearElementFamily() |
| 3255 | { |
| 3256 | m_children &= ~Family; |
| 3257 | } |
| 3258 | |
| 3259 | void DomFont::clearElementPointSize() |
| 3260 | { |
| 3261 | m_children &= ~PointSize; |
| 3262 | } |
| 3263 | |
| 3264 | void DomFont::clearElementWeight() |
| 3265 | { |
| 3266 | m_children &= ~Weight; |
| 3267 | } |
| 3268 | |
| 3269 | void DomFont::clearElementItalic() |
| 3270 | { |
| 3271 | m_children &= ~Italic; |
| 3272 | } |
| 3273 | |
| 3274 | void DomFont::clearElementBold() |
| 3275 | { |
| 3276 | m_children &= ~Bold; |
| 3277 | } |
| 3278 | |
| 3279 | void DomFont::clearElementUnderline() |
| 3280 | { |
| 3281 | m_children &= ~Underline; |
| 3282 | } |
| 3283 | |
| 3284 | void DomFont::clearElementStrikeOut() |
| 3285 | { |
| 3286 | m_children &= ~StrikeOut; |
| 3287 | } |
| 3288 | |
| 3289 | void DomFont::clearElementAntialiasing() |
| 3290 | { |
| 3291 | m_children &= ~Antialiasing; |
| 3292 | } |
| 3293 | |
| 3294 | void DomFont::clearElementStyleStrategy() |
| 3295 | { |
| 3296 | m_children &= ~StyleStrategy; |
| 3297 | } |
| 3298 | |
| 3299 | void DomFont::clearElementKerning() |
| 3300 | { |
| 3301 | m_children &= ~Kerning; |
| 3302 | } |
| 3303 | |
| 3304 | DomPoint::~DomPoint() = default; |
| 3305 | |
| 3306 | void DomPoint::read(QXmlStreamReader &reader) |
| 3307 | { |
| 3308 | while (!reader.hasError()) { |
| 3309 | switch (reader.readNext()) { |
| 3310 | case QXmlStreamReader::StartElement : { |
| 3311 | const auto tag = reader.name(); |
| 3312 | if (!tag.compare(QLatin1String("x" ), Qt::CaseInsensitive)) { |
| 3313 | setElementX(reader.readElementText().toInt()); |
| 3314 | continue; |
| 3315 | } |
| 3316 | if (!tag.compare(QLatin1String("y" ), Qt::CaseInsensitive)) { |
| 3317 | setElementY(reader.readElementText().toInt()); |
| 3318 | continue; |
| 3319 | } |
| 3320 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 3321 | } |
| 3322 | break; |
| 3323 | case QXmlStreamReader::EndElement : |
| 3324 | return; |
| 3325 | default : |
| 3326 | break; |
| 3327 | } |
| 3328 | } |
| 3329 | } |
| 3330 | |
| 3331 | void DomPoint::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 3332 | { |
| 3333 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("point" ) : tagName.toLower()); |
| 3334 | |
| 3335 | if (m_children & X) |
| 3336 | writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x)); |
| 3337 | |
| 3338 | if (m_children & Y) |
| 3339 | writer.writeTextElement(QString(QLatin1Char('y')), QString::number(m_y)); |
| 3340 | |
| 3341 | writer.writeEndElement(); |
| 3342 | } |
| 3343 | |
| 3344 | void DomPoint::setElementX(int a) |
| 3345 | { |
| 3346 | m_children |= X; |
| 3347 | m_x = a; |
| 3348 | } |
| 3349 | |
| 3350 | void DomPoint::setElementY(int a) |
| 3351 | { |
| 3352 | m_children |= Y; |
| 3353 | m_y = a; |
| 3354 | } |
| 3355 | |
| 3356 | void DomPoint::clearElementX() |
| 3357 | { |
| 3358 | m_children &= ~X; |
| 3359 | } |
| 3360 | |
| 3361 | void DomPoint::clearElementY() |
| 3362 | { |
| 3363 | m_children &= ~Y; |
| 3364 | } |
| 3365 | |
| 3366 | DomRect::~DomRect() = default; |
| 3367 | |
| 3368 | void DomRect::read(QXmlStreamReader &reader) |
| 3369 | { |
| 3370 | while (!reader.hasError()) { |
| 3371 | switch (reader.readNext()) { |
| 3372 | case QXmlStreamReader::StartElement : { |
| 3373 | const auto tag = reader.name(); |
| 3374 | if (!tag.compare(QLatin1String("x" ), Qt::CaseInsensitive)) { |
| 3375 | setElementX(reader.readElementText().toInt()); |
| 3376 | continue; |
| 3377 | } |
| 3378 | if (!tag.compare(QLatin1String("y" ), Qt::CaseInsensitive)) { |
| 3379 | setElementY(reader.readElementText().toInt()); |
| 3380 | continue; |
| 3381 | } |
| 3382 | if (!tag.compare(QLatin1String("width" ), Qt::CaseInsensitive)) { |
| 3383 | setElementWidth(reader.readElementText().toInt()); |
| 3384 | continue; |
| 3385 | } |
| 3386 | if (!tag.compare(QLatin1String("height" ), Qt::CaseInsensitive)) { |
| 3387 | setElementHeight(reader.readElementText().toInt()); |
| 3388 | continue; |
| 3389 | } |
| 3390 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 3391 | } |
| 3392 | break; |
| 3393 | case QXmlStreamReader::EndElement : |
| 3394 | return; |
| 3395 | default : |
| 3396 | break; |
| 3397 | } |
| 3398 | } |
| 3399 | } |
| 3400 | |
| 3401 | void DomRect::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 3402 | { |
| 3403 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("rect" ) : tagName.toLower()); |
| 3404 | |
| 3405 | if (m_children & X) |
| 3406 | writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x)); |
| 3407 | |
| 3408 | if (m_children & Y) |
| 3409 | writer.writeTextElement(QString(QLatin1Char('y')), QString::number(m_y)); |
| 3410 | |
| 3411 | if (m_children & Width) |
| 3412 | writer.writeTextElement(QStringLiteral("width" ), QString::number(m_width)); |
| 3413 | |
| 3414 | if (m_children & Height) |
| 3415 | writer.writeTextElement(QStringLiteral("height" ), QString::number(m_height)); |
| 3416 | |
| 3417 | writer.writeEndElement(); |
| 3418 | } |
| 3419 | |
| 3420 | void DomRect::setElementX(int a) |
| 3421 | { |
| 3422 | m_children |= X; |
| 3423 | m_x = a; |
| 3424 | } |
| 3425 | |
| 3426 | void DomRect::setElementY(int a) |
| 3427 | { |
| 3428 | m_children |= Y; |
| 3429 | m_y = a; |
| 3430 | } |
| 3431 | |
| 3432 | void DomRect::setElementWidth(int a) |
| 3433 | { |
| 3434 | m_children |= Width; |
| 3435 | m_width = a; |
| 3436 | } |
| 3437 | |
| 3438 | void DomRect::setElementHeight(int a) |
| 3439 | { |
| 3440 | m_children |= Height; |
| 3441 | m_height = a; |
| 3442 | } |
| 3443 | |
| 3444 | void DomRect::clearElementX() |
| 3445 | { |
| 3446 | m_children &= ~X; |
| 3447 | } |
| 3448 | |
| 3449 | void DomRect::clearElementY() |
| 3450 | { |
| 3451 | m_children &= ~Y; |
| 3452 | } |
| 3453 | |
| 3454 | void DomRect::clearElementWidth() |
| 3455 | { |
| 3456 | m_children &= ~Width; |
| 3457 | } |
| 3458 | |
| 3459 | void DomRect::clearElementHeight() |
| 3460 | { |
| 3461 | m_children &= ~Height; |
| 3462 | } |
| 3463 | |
| 3464 | DomLocale::~DomLocale() = default; |
| 3465 | |
| 3466 | void DomLocale::read(QXmlStreamReader &reader) |
| 3467 | { |
| 3468 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 3469 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 3470 | const auto name = attribute.name(); |
| 3471 | if (name == QLatin1String("language" )) { |
| 3472 | setAttributeLanguage(attribute.value().toString()); |
| 3473 | continue; |
| 3474 | } |
| 3475 | if (name == QLatin1String("country" )) { |
| 3476 | setAttributeCountry(attribute.value().toString()); |
| 3477 | continue; |
| 3478 | } |
| 3479 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 3480 | } |
| 3481 | |
| 3482 | while (!reader.hasError()) { |
| 3483 | switch (reader.readNext()) { |
| 3484 | case QXmlStreamReader::StartElement : { |
| 3485 | const auto tag = reader.name(); |
| 3486 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 3487 | } |
| 3488 | break; |
| 3489 | case QXmlStreamReader::EndElement : |
| 3490 | return; |
| 3491 | default : |
| 3492 | break; |
| 3493 | } |
| 3494 | } |
| 3495 | } |
| 3496 | |
| 3497 | void DomLocale::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 3498 | { |
| 3499 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("locale" ) : tagName.toLower()); |
| 3500 | |
| 3501 | if (hasAttributeLanguage()) |
| 3502 | writer.writeAttribute(QStringLiteral("language" ), attributeLanguage()); |
| 3503 | |
| 3504 | if (hasAttributeCountry()) |
| 3505 | writer.writeAttribute(QStringLiteral("country" ), attributeCountry()); |
| 3506 | |
| 3507 | writer.writeEndElement(); |
| 3508 | } |
| 3509 | |
| 3510 | DomSizePolicy::~DomSizePolicy() = default; |
| 3511 | |
| 3512 | void DomSizePolicy::read(QXmlStreamReader &reader) |
| 3513 | { |
| 3514 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 3515 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 3516 | const auto name = attribute.name(); |
| 3517 | if (name == QLatin1String("hsizetype" )) { |
| 3518 | setAttributeHSizeType(attribute.value().toString()); |
| 3519 | continue; |
| 3520 | } |
| 3521 | if (name == QLatin1String("vsizetype" )) { |
| 3522 | setAttributeVSizeType(attribute.value().toString()); |
| 3523 | continue; |
| 3524 | } |
| 3525 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 3526 | } |
| 3527 | |
| 3528 | while (!reader.hasError()) { |
| 3529 | switch (reader.readNext()) { |
| 3530 | case QXmlStreamReader::StartElement : { |
| 3531 | const auto tag = reader.name(); |
| 3532 | if (!tag.compare(QLatin1String("hsizetype" ), Qt::CaseInsensitive)) { |
| 3533 | setElementHSizeType(reader.readElementText().toInt()); |
| 3534 | continue; |
| 3535 | } |
| 3536 | if (!tag.compare(QLatin1String("vsizetype" ), Qt::CaseInsensitive)) { |
| 3537 | setElementVSizeType(reader.readElementText().toInt()); |
| 3538 | continue; |
| 3539 | } |
| 3540 | if (!tag.compare(QLatin1String("horstretch" ), Qt::CaseInsensitive)) { |
| 3541 | setElementHorStretch(reader.readElementText().toInt()); |
| 3542 | continue; |
| 3543 | } |
| 3544 | if (!tag.compare(QLatin1String("verstretch" ), Qt::CaseInsensitive)) { |
| 3545 | setElementVerStretch(reader.readElementText().toInt()); |
| 3546 | continue; |
| 3547 | } |
| 3548 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 3549 | } |
| 3550 | break; |
| 3551 | case QXmlStreamReader::EndElement : |
| 3552 | return; |
| 3553 | default : |
| 3554 | break; |
| 3555 | } |
| 3556 | } |
| 3557 | } |
| 3558 | |
| 3559 | void DomSizePolicy::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 3560 | { |
| 3561 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("sizepolicy" ) : tagName.toLower()); |
| 3562 | |
| 3563 | if (hasAttributeHSizeType()) |
| 3564 | writer.writeAttribute(QStringLiteral("hsizetype" ), attributeHSizeType()); |
| 3565 | |
| 3566 | if (hasAttributeVSizeType()) |
| 3567 | writer.writeAttribute(QStringLiteral("vsizetype" ), attributeVSizeType()); |
| 3568 | |
| 3569 | if (m_children & HSizeType) |
| 3570 | writer.writeTextElement(QStringLiteral("hsizetype" ), QString::number(m_hSizeType)); |
| 3571 | |
| 3572 | if (m_children & VSizeType) |
| 3573 | writer.writeTextElement(QStringLiteral("vsizetype" ), QString::number(m_vSizeType)); |
| 3574 | |
| 3575 | if (m_children & HorStretch) |
| 3576 | writer.writeTextElement(QStringLiteral("horstretch" ), QString::number(m_horStretch)); |
| 3577 | |
| 3578 | if (m_children & VerStretch) |
| 3579 | writer.writeTextElement(QStringLiteral("verstretch" ), QString::number(m_verStretch)); |
| 3580 | |
| 3581 | writer.writeEndElement(); |
| 3582 | } |
| 3583 | |
| 3584 | void DomSizePolicy::setElementHSizeType(int a) |
| 3585 | { |
| 3586 | m_children |= HSizeType; |
| 3587 | m_hSizeType = a; |
| 3588 | } |
| 3589 | |
| 3590 | void DomSizePolicy::setElementVSizeType(int a) |
| 3591 | { |
| 3592 | m_children |= VSizeType; |
| 3593 | m_vSizeType = a; |
| 3594 | } |
| 3595 | |
| 3596 | void DomSizePolicy::setElementHorStretch(int a) |
| 3597 | { |
| 3598 | m_children |= HorStretch; |
| 3599 | m_horStretch = a; |
| 3600 | } |
| 3601 | |
| 3602 | void DomSizePolicy::setElementVerStretch(int a) |
| 3603 | { |
| 3604 | m_children |= VerStretch; |
| 3605 | m_verStretch = a; |
| 3606 | } |
| 3607 | |
| 3608 | void DomSizePolicy::clearElementHSizeType() |
| 3609 | { |
| 3610 | m_children &= ~HSizeType; |
| 3611 | } |
| 3612 | |
| 3613 | void DomSizePolicy::clearElementVSizeType() |
| 3614 | { |
| 3615 | m_children &= ~VSizeType; |
| 3616 | } |
| 3617 | |
| 3618 | void DomSizePolicy::clearElementHorStretch() |
| 3619 | { |
| 3620 | m_children &= ~HorStretch; |
| 3621 | } |
| 3622 | |
| 3623 | void DomSizePolicy::clearElementVerStretch() |
| 3624 | { |
| 3625 | m_children &= ~VerStretch; |
| 3626 | } |
| 3627 | |
| 3628 | DomSize::~DomSize() = default; |
| 3629 | |
| 3630 | void DomSize::read(QXmlStreamReader &reader) |
| 3631 | { |
| 3632 | while (!reader.hasError()) { |
| 3633 | switch (reader.readNext()) { |
| 3634 | case QXmlStreamReader::StartElement : { |
| 3635 | const auto tag = reader.name(); |
| 3636 | if (!tag.compare(QLatin1String("width" ), Qt::CaseInsensitive)) { |
| 3637 | setElementWidth(reader.readElementText().toInt()); |
| 3638 | continue; |
| 3639 | } |
| 3640 | if (!tag.compare(QLatin1String("height" ), Qt::CaseInsensitive)) { |
| 3641 | setElementHeight(reader.readElementText().toInt()); |
| 3642 | continue; |
| 3643 | } |
| 3644 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 3645 | } |
| 3646 | break; |
| 3647 | case QXmlStreamReader::EndElement : |
| 3648 | return; |
| 3649 | default : |
| 3650 | break; |
| 3651 | } |
| 3652 | } |
| 3653 | } |
| 3654 | |
| 3655 | void DomSize::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 3656 | { |
| 3657 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("size" ) : tagName.toLower()); |
| 3658 | |
| 3659 | if (m_children & Width) |
| 3660 | writer.writeTextElement(QStringLiteral("width" ), QString::number(m_width)); |
| 3661 | |
| 3662 | if (m_children & Height) |
| 3663 | writer.writeTextElement(QStringLiteral("height" ), QString::number(m_height)); |
| 3664 | |
| 3665 | writer.writeEndElement(); |
| 3666 | } |
| 3667 | |
| 3668 | void DomSize::setElementWidth(int a) |
| 3669 | { |
| 3670 | m_children |= Width; |
| 3671 | m_width = a; |
| 3672 | } |
| 3673 | |
| 3674 | void DomSize::setElementHeight(int a) |
| 3675 | { |
| 3676 | m_children |= Height; |
| 3677 | m_height = a; |
| 3678 | } |
| 3679 | |
| 3680 | void DomSize::clearElementWidth() |
| 3681 | { |
| 3682 | m_children &= ~Width; |
| 3683 | } |
| 3684 | |
| 3685 | void DomSize::clearElementHeight() |
| 3686 | { |
| 3687 | m_children &= ~Height; |
| 3688 | } |
| 3689 | |
| 3690 | DomDate::~DomDate() = default; |
| 3691 | |
| 3692 | void DomDate::read(QXmlStreamReader &reader) |
| 3693 | { |
| 3694 | while (!reader.hasError()) { |
| 3695 | switch (reader.readNext()) { |
| 3696 | case QXmlStreamReader::StartElement : { |
| 3697 | const auto tag = reader.name(); |
| 3698 | if (!tag.compare(QLatin1String("year" ), Qt::CaseInsensitive)) { |
| 3699 | setElementYear(reader.readElementText().toInt()); |
| 3700 | continue; |
| 3701 | } |
| 3702 | if (!tag.compare(QLatin1String("month" ), Qt::CaseInsensitive)) { |
| 3703 | setElementMonth(reader.readElementText().toInt()); |
| 3704 | continue; |
| 3705 | } |
| 3706 | if (!tag.compare(QLatin1String("day" ), Qt::CaseInsensitive)) { |
| 3707 | setElementDay(reader.readElementText().toInt()); |
| 3708 | continue; |
| 3709 | } |
| 3710 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 3711 | } |
| 3712 | break; |
| 3713 | case QXmlStreamReader::EndElement : |
| 3714 | return; |
| 3715 | default : |
| 3716 | break; |
| 3717 | } |
| 3718 | } |
| 3719 | } |
| 3720 | |
| 3721 | void DomDate::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 3722 | { |
| 3723 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("date" ) : tagName.toLower()); |
| 3724 | |
| 3725 | if (m_children & Year) |
| 3726 | writer.writeTextElement(QStringLiteral("year" ), QString::number(m_year)); |
| 3727 | |
| 3728 | if (m_children & Month) |
| 3729 | writer.writeTextElement(QStringLiteral("month" ), QString::number(m_month)); |
| 3730 | |
| 3731 | if (m_children & Day) |
| 3732 | writer.writeTextElement(QStringLiteral("day" ), QString::number(m_day)); |
| 3733 | |
| 3734 | writer.writeEndElement(); |
| 3735 | } |
| 3736 | |
| 3737 | void DomDate::setElementYear(int a) |
| 3738 | { |
| 3739 | m_children |= Year; |
| 3740 | m_year = a; |
| 3741 | } |
| 3742 | |
| 3743 | void DomDate::setElementMonth(int a) |
| 3744 | { |
| 3745 | m_children |= Month; |
| 3746 | m_month = a; |
| 3747 | } |
| 3748 | |
| 3749 | void DomDate::setElementDay(int a) |
| 3750 | { |
| 3751 | m_children |= Day; |
| 3752 | m_day = a; |
| 3753 | } |
| 3754 | |
| 3755 | void DomDate::clearElementYear() |
| 3756 | { |
| 3757 | m_children &= ~Year; |
| 3758 | } |
| 3759 | |
| 3760 | void DomDate::clearElementMonth() |
| 3761 | { |
| 3762 | m_children &= ~Month; |
| 3763 | } |
| 3764 | |
| 3765 | void DomDate::clearElementDay() |
| 3766 | { |
| 3767 | m_children &= ~Day; |
| 3768 | } |
| 3769 | |
| 3770 | DomTime::~DomTime() = default; |
| 3771 | |
| 3772 | void DomTime::read(QXmlStreamReader &reader) |
| 3773 | { |
| 3774 | while (!reader.hasError()) { |
| 3775 | switch (reader.readNext()) { |
| 3776 | case QXmlStreamReader::StartElement : { |
| 3777 | const auto tag = reader.name(); |
| 3778 | if (!tag.compare(QLatin1String("hour" ), Qt::CaseInsensitive)) { |
| 3779 | setElementHour(reader.readElementText().toInt()); |
| 3780 | continue; |
| 3781 | } |
| 3782 | if (!tag.compare(QLatin1String("minute" ), Qt::CaseInsensitive)) { |
| 3783 | setElementMinute(reader.readElementText().toInt()); |
| 3784 | continue; |
| 3785 | } |
| 3786 | if (!tag.compare(QLatin1String("second" ), Qt::CaseInsensitive)) { |
| 3787 | setElementSecond(reader.readElementText().toInt()); |
| 3788 | continue; |
| 3789 | } |
| 3790 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 3791 | } |
| 3792 | break; |
| 3793 | case QXmlStreamReader::EndElement : |
| 3794 | return; |
| 3795 | default : |
| 3796 | break; |
| 3797 | } |
| 3798 | } |
| 3799 | } |
| 3800 | |
| 3801 | void DomTime::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 3802 | { |
| 3803 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("time" ) : tagName.toLower()); |
| 3804 | |
| 3805 | if (m_children & Hour) |
| 3806 | writer.writeTextElement(QStringLiteral("hour" ), QString::number(m_hour)); |
| 3807 | |
| 3808 | if (m_children & Minute) |
| 3809 | writer.writeTextElement(QStringLiteral("minute" ), QString::number(m_minute)); |
| 3810 | |
| 3811 | if (m_children & Second) |
| 3812 | writer.writeTextElement(QStringLiteral("second" ), QString::number(m_second)); |
| 3813 | |
| 3814 | writer.writeEndElement(); |
| 3815 | } |
| 3816 | |
| 3817 | void DomTime::setElementHour(int a) |
| 3818 | { |
| 3819 | m_children |= Hour; |
| 3820 | m_hour = a; |
| 3821 | } |
| 3822 | |
| 3823 | void DomTime::setElementMinute(int a) |
| 3824 | { |
| 3825 | m_children |= Minute; |
| 3826 | m_minute = a; |
| 3827 | } |
| 3828 | |
| 3829 | void DomTime::setElementSecond(int a) |
| 3830 | { |
| 3831 | m_children |= Second; |
| 3832 | m_second = a; |
| 3833 | } |
| 3834 | |
| 3835 | void DomTime::clearElementHour() |
| 3836 | { |
| 3837 | m_children &= ~Hour; |
| 3838 | } |
| 3839 | |
| 3840 | void DomTime::clearElementMinute() |
| 3841 | { |
| 3842 | m_children &= ~Minute; |
| 3843 | } |
| 3844 | |
| 3845 | void DomTime::clearElementSecond() |
| 3846 | { |
| 3847 | m_children &= ~Second; |
| 3848 | } |
| 3849 | |
| 3850 | DomDateTime::~DomDateTime() = default; |
| 3851 | |
| 3852 | void DomDateTime::read(QXmlStreamReader &reader) |
| 3853 | { |
| 3854 | while (!reader.hasError()) { |
| 3855 | switch (reader.readNext()) { |
| 3856 | case QXmlStreamReader::StartElement : { |
| 3857 | const auto tag = reader.name(); |
| 3858 | if (!tag.compare(QLatin1String("hour" ), Qt::CaseInsensitive)) { |
| 3859 | setElementHour(reader.readElementText().toInt()); |
| 3860 | continue; |
| 3861 | } |
| 3862 | if (!tag.compare(QLatin1String("minute" ), Qt::CaseInsensitive)) { |
| 3863 | setElementMinute(reader.readElementText().toInt()); |
| 3864 | continue; |
| 3865 | } |
| 3866 | if (!tag.compare(QLatin1String("second" ), Qt::CaseInsensitive)) { |
| 3867 | setElementSecond(reader.readElementText().toInt()); |
| 3868 | continue; |
| 3869 | } |
| 3870 | if (!tag.compare(QLatin1String("year" ), Qt::CaseInsensitive)) { |
| 3871 | setElementYear(reader.readElementText().toInt()); |
| 3872 | continue; |
| 3873 | } |
| 3874 | if (!tag.compare(QLatin1String("month" ), Qt::CaseInsensitive)) { |
| 3875 | setElementMonth(reader.readElementText().toInt()); |
| 3876 | continue; |
| 3877 | } |
| 3878 | if (!tag.compare(QLatin1String("day" ), Qt::CaseInsensitive)) { |
| 3879 | setElementDay(reader.readElementText().toInt()); |
| 3880 | continue; |
| 3881 | } |
| 3882 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 3883 | } |
| 3884 | break; |
| 3885 | case QXmlStreamReader::EndElement : |
| 3886 | return; |
| 3887 | default : |
| 3888 | break; |
| 3889 | } |
| 3890 | } |
| 3891 | } |
| 3892 | |
| 3893 | void DomDateTime::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 3894 | { |
| 3895 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("datetime" ) : tagName.toLower()); |
| 3896 | |
| 3897 | if (m_children & Hour) |
| 3898 | writer.writeTextElement(QStringLiteral("hour" ), QString::number(m_hour)); |
| 3899 | |
| 3900 | if (m_children & Minute) |
| 3901 | writer.writeTextElement(QStringLiteral("minute" ), QString::number(m_minute)); |
| 3902 | |
| 3903 | if (m_children & Second) |
| 3904 | writer.writeTextElement(QStringLiteral("second" ), QString::number(m_second)); |
| 3905 | |
| 3906 | if (m_children & Year) |
| 3907 | writer.writeTextElement(QStringLiteral("year" ), QString::number(m_year)); |
| 3908 | |
| 3909 | if (m_children & Month) |
| 3910 | writer.writeTextElement(QStringLiteral("month" ), QString::number(m_month)); |
| 3911 | |
| 3912 | if (m_children & Day) |
| 3913 | writer.writeTextElement(QStringLiteral("day" ), QString::number(m_day)); |
| 3914 | |
| 3915 | writer.writeEndElement(); |
| 3916 | } |
| 3917 | |
| 3918 | void DomDateTime::setElementHour(int a) |
| 3919 | { |
| 3920 | m_children |= Hour; |
| 3921 | m_hour = a; |
| 3922 | } |
| 3923 | |
| 3924 | void DomDateTime::setElementMinute(int a) |
| 3925 | { |
| 3926 | m_children |= Minute; |
| 3927 | m_minute = a; |
| 3928 | } |
| 3929 | |
| 3930 | void DomDateTime::setElementSecond(int a) |
| 3931 | { |
| 3932 | m_children |= Second; |
| 3933 | m_second = a; |
| 3934 | } |
| 3935 | |
| 3936 | void DomDateTime::setElementYear(int a) |
| 3937 | { |
| 3938 | m_children |= Year; |
| 3939 | m_year = a; |
| 3940 | } |
| 3941 | |
| 3942 | void DomDateTime::setElementMonth(int a) |
| 3943 | { |
| 3944 | m_children |= Month; |
| 3945 | m_month = a; |
| 3946 | } |
| 3947 | |
| 3948 | void DomDateTime::setElementDay(int a) |
| 3949 | { |
| 3950 | m_children |= Day; |
| 3951 | m_day = a; |
| 3952 | } |
| 3953 | |
| 3954 | void DomDateTime::clearElementHour() |
| 3955 | { |
| 3956 | m_children &= ~Hour; |
| 3957 | } |
| 3958 | |
| 3959 | void DomDateTime::clearElementMinute() |
| 3960 | { |
| 3961 | m_children &= ~Minute; |
| 3962 | } |
| 3963 | |
| 3964 | void DomDateTime::clearElementSecond() |
| 3965 | { |
| 3966 | m_children &= ~Second; |
| 3967 | } |
| 3968 | |
| 3969 | void DomDateTime::clearElementYear() |
| 3970 | { |
| 3971 | m_children &= ~Year; |
| 3972 | } |
| 3973 | |
| 3974 | void DomDateTime::clearElementMonth() |
| 3975 | { |
| 3976 | m_children &= ~Month; |
| 3977 | } |
| 3978 | |
| 3979 | void DomDateTime::clearElementDay() |
| 3980 | { |
| 3981 | m_children &= ~Day; |
| 3982 | } |
| 3983 | |
| 3984 | DomStringList::~DomStringList() |
| 3985 | { |
| 3986 | m_string.clear(); |
| 3987 | } |
| 3988 | |
| 3989 | void DomStringList::read(QXmlStreamReader &reader) |
| 3990 | { |
| 3991 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 3992 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 3993 | const auto name = attribute.name(); |
| 3994 | if (name == QLatin1String("notr" )) { |
| 3995 | setAttributeNotr(attribute.value().toString()); |
| 3996 | continue; |
| 3997 | } |
| 3998 | if (name == QLatin1String("comment" )) { |
| 3999 | setAttributeComment(attribute.value().toString()); |
| 4000 | continue; |
| 4001 | } |
| 4002 | if (name == QLatin1String("extracomment" )) { |
| 4003 | setAttributeExtraComment(attribute.value().toString()); |
| 4004 | continue; |
| 4005 | } |
| 4006 | if (name == QLatin1String("id" )) { |
| 4007 | setAttributeId(attribute.value().toString()); |
| 4008 | continue; |
| 4009 | } |
| 4010 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 4011 | } |
| 4012 | |
| 4013 | while (!reader.hasError()) { |
| 4014 | switch (reader.readNext()) { |
| 4015 | case QXmlStreamReader::StartElement : { |
| 4016 | const auto tag = reader.name(); |
| 4017 | if (!tag.compare(QLatin1String("string" ), Qt::CaseInsensitive)) { |
| 4018 | m_string.append(reader.readElementText()); |
| 4019 | continue; |
| 4020 | } |
| 4021 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 4022 | } |
| 4023 | break; |
| 4024 | case QXmlStreamReader::EndElement : |
| 4025 | return; |
| 4026 | default : |
| 4027 | break; |
| 4028 | } |
| 4029 | } |
| 4030 | } |
| 4031 | |
| 4032 | void DomStringList::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 4033 | { |
| 4034 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("stringlist" ) : tagName.toLower()); |
| 4035 | |
| 4036 | if (hasAttributeNotr()) |
| 4037 | writer.writeAttribute(QStringLiteral("notr" ), attributeNotr()); |
| 4038 | |
| 4039 | if (hasAttributeComment()) |
| 4040 | writer.writeAttribute(QStringLiteral("comment" ), attributeComment()); |
| 4041 | |
| 4042 | if (hasAttributeExtraComment()) |
| 4043 | writer.writeAttribute(QStringLiteral("extracomment" ), attributeExtraComment()); |
| 4044 | |
| 4045 | if (hasAttributeId()) |
| 4046 | writer.writeAttribute(QStringLiteral("id" ), attributeId()); |
| 4047 | |
| 4048 | for (const QString &v : m_string) |
| 4049 | writer.writeTextElement(QStringLiteral("string" ), v); |
| 4050 | |
| 4051 | writer.writeEndElement(); |
| 4052 | } |
| 4053 | |
| 4054 | void DomStringList::setElementString(const QStringList &a) |
| 4055 | { |
| 4056 | m_children |= String; |
| 4057 | m_string = a; |
| 4058 | } |
| 4059 | |
| 4060 | DomResourcePixmap::~DomResourcePixmap() = default; |
| 4061 | |
| 4062 | void DomResourcePixmap::read(QXmlStreamReader &reader) |
| 4063 | { |
| 4064 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 4065 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 4066 | const auto name = attribute.name(); |
| 4067 | if (name == QLatin1String("resource" )) { |
| 4068 | setAttributeResource(attribute.value().toString()); |
| 4069 | continue; |
| 4070 | } |
| 4071 | if (name == QLatin1String("alias" )) { |
| 4072 | setAttributeAlias(attribute.value().toString()); |
| 4073 | continue; |
| 4074 | } |
| 4075 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 4076 | } |
| 4077 | |
| 4078 | while (!reader.hasError()) { |
| 4079 | switch (reader.readNext()) { |
| 4080 | case QXmlStreamReader::StartElement : { |
| 4081 | const auto tag = reader.name(); |
| 4082 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 4083 | } |
| 4084 | break; |
| 4085 | case QXmlStreamReader::EndElement : |
| 4086 | return; |
| 4087 | case QXmlStreamReader::Characters : |
| 4088 | if (!reader.isWhitespace()) |
| 4089 | m_text.append(reader.text().toString()); |
| 4090 | break; |
| 4091 | default : |
| 4092 | break; |
| 4093 | } |
| 4094 | } |
| 4095 | } |
| 4096 | |
| 4097 | void DomResourcePixmap::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 4098 | { |
| 4099 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("resourcepixmap" ) : tagName.toLower()); |
| 4100 | |
| 4101 | if (hasAttributeResource()) |
| 4102 | writer.writeAttribute(QStringLiteral("resource" ), attributeResource()); |
| 4103 | |
| 4104 | if (hasAttributeAlias()) |
| 4105 | writer.writeAttribute(QStringLiteral("alias" ), attributeAlias()); |
| 4106 | |
| 4107 | if (!m_text.isEmpty()) |
| 4108 | writer.writeCharacters(m_text); |
| 4109 | |
| 4110 | writer.writeEndElement(); |
| 4111 | } |
| 4112 | |
| 4113 | DomResourceIcon::~DomResourceIcon() |
| 4114 | { |
| 4115 | delete m_normalOff; |
| 4116 | delete m_normalOn; |
| 4117 | delete m_disabledOff; |
| 4118 | delete m_disabledOn; |
| 4119 | delete m_activeOff; |
| 4120 | delete m_activeOn; |
| 4121 | delete m_selectedOff; |
| 4122 | delete m_selectedOn; |
| 4123 | } |
| 4124 | |
| 4125 | void DomResourceIcon::read(QXmlStreamReader &reader) |
| 4126 | { |
| 4127 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 4128 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 4129 | const auto name = attribute.name(); |
| 4130 | if (name == QLatin1String("theme" )) { |
| 4131 | setAttributeTheme(attribute.value().toString()); |
| 4132 | continue; |
| 4133 | } |
| 4134 | if (name == QLatin1String("resource" )) { |
| 4135 | setAttributeResource(attribute.value().toString()); |
| 4136 | continue; |
| 4137 | } |
| 4138 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 4139 | } |
| 4140 | |
| 4141 | while (!reader.hasError()) { |
| 4142 | switch (reader.readNext()) { |
| 4143 | case QXmlStreamReader::StartElement : { |
| 4144 | const auto tag = reader.name(); |
| 4145 | if (!tag.compare(QLatin1String("normaloff" ), Qt::CaseInsensitive)) { |
| 4146 | auto *v = new DomResourcePixmap(); |
| 4147 | v->read(reader); |
| 4148 | setElementNormalOff(v); |
| 4149 | continue; |
| 4150 | } |
| 4151 | if (!tag.compare(QLatin1String("normalon" ), Qt::CaseInsensitive)) { |
| 4152 | auto *v = new DomResourcePixmap(); |
| 4153 | v->read(reader); |
| 4154 | setElementNormalOn(v); |
| 4155 | continue; |
| 4156 | } |
| 4157 | if (!tag.compare(QLatin1String("disabledoff" ), Qt::CaseInsensitive)) { |
| 4158 | auto *v = new DomResourcePixmap(); |
| 4159 | v->read(reader); |
| 4160 | setElementDisabledOff(v); |
| 4161 | continue; |
| 4162 | } |
| 4163 | if (!tag.compare(QLatin1String("disabledon" ), Qt::CaseInsensitive)) { |
| 4164 | auto *v = new DomResourcePixmap(); |
| 4165 | v->read(reader); |
| 4166 | setElementDisabledOn(v); |
| 4167 | continue; |
| 4168 | } |
| 4169 | if (!tag.compare(QLatin1String("activeoff" ), Qt::CaseInsensitive)) { |
| 4170 | auto *v = new DomResourcePixmap(); |
| 4171 | v->read(reader); |
| 4172 | setElementActiveOff(v); |
| 4173 | continue; |
| 4174 | } |
| 4175 | if (!tag.compare(QLatin1String("activeon" ), Qt::CaseInsensitive)) { |
| 4176 | auto *v = new DomResourcePixmap(); |
| 4177 | v->read(reader); |
| 4178 | setElementActiveOn(v); |
| 4179 | continue; |
| 4180 | } |
| 4181 | if (!tag.compare(QLatin1String("selectedoff" ), Qt::CaseInsensitive)) { |
| 4182 | auto *v = new DomResourcePixmap(); |
| 4183 | v->read(reader); |
| 4184 | setElementSelectedOff(v); |
| 4185 | continue; |
| 4186 | } |
| 4187 | if (!tag.compare(QLatin1String("selectedon" ), Qt::CaseInsensitive)) { |
| 4188 | auto *v = new DomResourcePixmap(); |
| 4189 | v->read(reader); |
| 4190 | setElementSelectedOn(v); |
| 4191 | continue; |
| 4192 | } |
| 4193 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 4194 | } |
| 4195 | break; |
| 4196 | case QXmlStreamReader::EndElement : |
| 4197 | return; |
| 4198 | case QXmlStreamReader::Characters : |
| 4199 | if (!reader.isWhitespace()) |
| 4200 | m_text.append(reader.text().toString()); |
| 4201 | break; |
| 4202 | default : |
| 4203 | break; |
| 4204 | } |
| 4205 | } |
| 4206 | } |
| 4207 | |
| 4208 | void DomResourceIcon::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 4209 | { |
| 4210 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("resourceicon" ) : tagName.toLower()); |
| 4211 | |
| 4212 | if (hasAttributeTheme()) |
| 4213 | writer.writeAttribute(QStringLiteral("theme" ), attributeTheme()); |
| 4214 | |
| 4215 | if (hasAttributeResource()) |
| 4216 | writer.writeAttribute(QStringLiteral("resource" ), attributeResource()); |
| 4217 | |
| 4218 | if (m_children & NormalOff) |
| 4219 | m_normalOff->write(writer, QStringLiteral("normaloff" )); |
| 4220 | |
| 4221 | if (m_children & NormalOn) |
| 4222 | m_normalOn->write(writer, QStringLiteral("normalon" )); |
| 4223 | |
| 4224 | if (m_children & DisabledOff) |
| 4225 | m_disabledOff->write(writer, QStringLiteral("disabledoff" )); |
| 4226 | |
| 4227 | if (m_children & DisabledOn) |
| 4228 | m_disabledOn->write(writer, QStringLiteral("disabledon" )); |
| 4229 | |
| 4230 | if (m_children & ActiveOff) |
| 4231 | m_activeOff->write(writer, QStringLiteral("activeoff" )); |
| 4232 | |
| 4233 | if (m_children & ActiveOn) |
| 4234 | m_activeOn->write(writer, QStringLiteral("activeon" )); |
| 4235 | |
| 4236 | if (m_children & SelectedOff) |
| 4237 | m_selectedOff->write(writer, QStringLiteral("selectedoff" )); |
| 4238 | |
| 4239 | if (m_children & SelectedOn) |
| 4240 | m_selectedOn->write(writer, QStringLiteral("selectedon" )); |
| 4241 | |
| 4242 | if (!m_text.isEmpty()) |
| 4243 | writer.writeCharacters(m_text); |
| 4244 | |
| 4245 | writer.writeEndElement(); |
| 4246 | } |
| 4247 | |
| 4248 | DomResourcePixmap *DomResourceIcon::takeElementNormalOff() |
| 4249 | { |
| 4250 | DomResourcePixmap *a = m_normalOff; |
| 4251 | m_normalOff = nullptr; |
| 4252 | m_children ^= NormalOff; |
| 4253 | return a; |
| 4254 | } |
| 4255 | |
| 4256 | void DomResourceIcon::setElementNormalOff(DomResourcePixmap *a) |
| 4257 | { |
| 4258 | delete m_normalOff; |
| 4259 | m_children |= NormalOff; |
| 4260 | m_normalOff = a; |
| 4261 | } |
| 4262 | |
| 4263 | DomResourcePixmap *DomResourceIcon::takeElementNormalOn() |
| 4264 | { |
| 4265 | DomResourcePixmap *a = m_normalOn; |
| 4266 | m_normalOn = nullptr; |
| 4267 | m_children ^= NormalOn; |
| 4268 | return a; |
| 4269 | } |
| 4270 | |
| 4271 | void DomResourceIcon::setElementNormalOn(DomResourcePixmap *a) |
| 4272 | { |
| 4273 | delete m_normalOn; |
| 4274 | m_children |= NormalOn; |
| 4275 | m_normalOn = a; |
| 4276 | } |
| 4277 | |
| 4278 | DomResourcePixmap *DomResourceIcon::takeElementDisabledOff() |
| 4279 | { |
| 4280 | DomResourcePixmap *a = m_disabledOff; |
| 4281 | m_disabledOff = nullptr; |
| 4282 | m_children ^= DisabledOff; |
| 4283 | return a; |
| 4284 | } |
| 4285 | |
| 4286 | void DomResourceIcon::setElementDisabledOff(DomResourcePixmap *a) |
| 4287 | { |
| 4288 | delete m_disabledOff; |
| 4289 | m_children |= DisabledOff; |
| 4290 | m_disabledOff = a; |
| 4291 | } |
| 4292 | |
| 4293 | DomResourcePixmap *DomResourceIcon::takeElementDisabledOn() |
| 4294 | { |
| 4295 | DomResourcePixmap *a = m_disabledOn; |
| 4296 | m_disabledOn = nullptr; |
| 4297 | m_children ^= DisabledOn; |
| 4298 | return a; |
| 4299 | } |
| 4300 | |
| 4301 | void DomResourceIcon::setElementDisabledOn(DomResourcePixmap *a) |
| 4302 | { |
| 4303 | delete m_disabledOn; |
| 4304 | m_children |= DisabledOn; |
| 4305 | m_disabledOn = a; |
| 4306 | } |
| 4307 | |
| 4308 | DomResourcePixmap *DomResourceIcon::takeElementActiveOff() |
| 4309 | { |
| 4310 | DomResourcePixmap *a = m_activeOff; |
| 4311 | m_activeOff = nullptr; |
| 4312 | m_children ^= ActiveOff; |
| 4313 | return a; |
| 4314 | } |
| 4315 | |
| 4316 | void DomResourceIcon::setElementActiveOff(DomResourcePixmap *a) |
| 4317 | { |
| 4318 | delete m_activeOff; |
| 4319 | m_children |= ActiveOff; |
| 4320 | m_activeOff = a; |
| 4321 | } |
| 4322 | |
| 4323 | DomResourcePixmap *DomResourceIcon::takeElementActiveOn() |
| 4324 | { |
| 4325 | DomResourcePixmap *a = m_activeOn; |
| 4326 | m_activeOn = nullptr; |
| 4327 | m_children ^= ActiveOn; |
| 4328 | return a; |
| 4329 | } |
| 4330 | |
| 4331 | void DomResourceIcon::setElementActiveOn(DomResourcePixmap *a) |
| 4332 | { |
| 4333 | delete m_activeOn; |
| 4334 | m_children |= ActiveOn; |
| 4335 | m_activeOn = a; |
| 4336 | } |
| 4337 | |
| 4338 | DomResourcePixmap *DomResourceIcon::takeElementSelectedOff() |
| 4339 | { |
| 4340 | DomResourcePixmap *a = m_selectedOff; |
| 4341 | m_selectedOff = nullptr; |
| 4342 | m_children ^= SelectedOff; |
| 4343 | return a; |
| 4344 | } |
| 4345 | |
| 4346 | void DomResourceIcon::setElementSelectedOff(DomResourcePixmap *a) |
| 4347 | { |
| 4348 | delete m_selectedOff; |
| 4349 | m_children |= SelectedOff; |
| 4350 | m_selectedOff = a; |
| 4351 | } |
| 4352 | |
| 4353 | DomResourcePixmap *DomResourceIcon::takeElementSelectedOn() |
| 4354 | { |
| 4355 | DomResourcePixmap *a = m_selectedOn; |
| 4356 | m_selectedOn = nullptr; |
| 4357 | m_children ^= SelectedOn; |
| 4358 | return a; |
| 4359 | } |
| 4360 | |
| 4361 | void DomResourceIcon::setElementSelectedOn(DomResourcePixmap *a) |
| 4362 | { |
| 4363 | delete m_selectedOn; |
| 4364 | m_children |= SelectedOn; |
| 4365 | m_selectedOn = a; |
| 4366 | } |
| 4367 | |
| 4368 | void DomResourceIcon::clearElementNormalOff() |
| 4369 | { |
| 4370 | delete m_normalOff; |
| 4371 | m_normalOff = nullptr; |
| 4372 | m_children &= ~NormalOff; |
| 4373 | } |
| 4374 | |
| 4375 | void DomResourceIcon::clearElementNormalOn() |
| 4376 | { |
| 4377 | delete m_normalOn; |
| 4378 | m_normalOn = nullptr; |
| 4379 | m_children &= ~NormalOn; |
| 4380 | } |
| 4381 | |
| 4382 | void DomResourceIcon::clearElementDisabledOff() |
| 4383 | { |
| 4384 | delete m_disabledOff; |
| 4385 | m_disabledOff = nullptr; |
| 4386 | m_children &= ~DisabledOff; |
| 4387 | } |
| 4388 | |
| 4389 | void DomResourceIcon::clearElementDisabledOn() |
| 4390 | { |
| 4391 | delete m_disabledOn; |
| 4392 | m_disabledOn = nullptr; |
| 4393 | m_children &= ~DisabledOn; |
| 4394 | } |
| 4395 | |
| 4396 | void DomResourceIcon::clearElementActiveOff() |
| 4397 | { |
| 4398 | delete m_activeOff; |
| 4399 | m_activeOff = nullptr; |
| 4400 | m_children &= ~ActiveOff; |
| 4401 | } |
| 4402 | |
| 4403 | void DomResourceIcon::clearElementActiveOn() |
| 4404 | { |
| 4405 | delete m_activeOn; |
| 4406 | m_activeOn = nullptr; |
| 4407 | m_children &= ~ActiveOn; |
| 4408 | } |
| 4409 | |
| 4410 | void DomResourceIcon::clearElementSelectedOff() |
| 4411 | { |
| 4412 | delete m_selectedOff; |
| 4413 | m_selectedOff = nullptr; |
| 4414 | m_children &= ~SelectedOff; |
| 4415 | } |
| 4416 | |
| 4417 | void DomResourceIcon::clearElementSelectedOn() |
| 4418 | { |
| 4419 | delete m_selectedOn; |
| 4420 | m_selectedOn = nullptr; |
| 4421 | m_children &= ~SelectedOn; |
| 4422 | } |
| 4423 | |
| 4424 | DomString::~DomString() = default; |
| 4425 | |
| 4426 | void DomString::read(QXmlStreamReader &reader) |
| 4427 | { |
| 4428 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 4429 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 4430 | const auto name = attribute.name(); |
| 4431 | if (name == QLatin1String("notr" )) { |
| 4432 | setAttributeNotr(attribute.value().toString()); |
| 4433 | continue; |
| 4434 | } |
| 4435 | if (name == QLatin1String("comment" )) { |
| 4436 | setAttributeComment(attribute.value().toString()); |
| 4437 | continue; |
| 4438 | } |
| 4439 | if (name == QLatin1String("extracomment" )) { |
| 4440 | setAttributeExtraComment(attribute.value().toString()); |
| 4441 | continue; |
| 4442 | } |
| 4443 | if (name == QLatin1String("id" )) { |
| 4444 | setAttributeId(attribute.value().toString()); |
| 4445 | continue; |
| 4446 | } |
| 4447 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 4448 | } |
| 4449 | |
| 4450 | while (!reader.hasError()) { |
| 4451 | switch (reader.readNext()) { |
| 4452 | case QXmlStreamReader::StartElement : { |
| 4453 | const auto tag = reader.name(); |
| 4454 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 4455 | } |
| 4456 | break; |
| 4457 | case QXmlStreamReader::EndElement : |
| 4458 | return; |
| 4459 | case QXmlStreamReader::Characters : |
| 4460 | if (!reader.isWhitespace()) |
| 4461 | m_text.append(reader.text().toString()); |
| 4462 | break; |
| 4463 | default : |
| 4464 | break; |
| 4465 | } |
| 4466 | } |
| 4467 | } |
| 4468 | |
| 4469 | void DomString::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 4470 | { |
| 4471 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("string" ) : tagName.toLower()); |
| 4472 | |
| 4473 | if (hasAttributeNotr()) |
| 4474 | writer.writeAttribute(QStringLiteral("notr" ), attributeNotr()); |
| 4475 | |
| 4476 | if (hasAttributeComment()) |
| 4477 | writer.writeAttribute(QStringLiteral("comment" ), attributeComment()); |
| 4478 | |
| 4479 | if (hasAttributeExtraComment()) |
| 4480 | writer.writeAttribute(QStringLiteral("extracomment" ), attributeExtraComment()); |
| 4481 | |
| 4482 | if (hasAttributeId()) |
| 4483 | writer.writeAttribute(QStringLiteral("id" ), attributeId()); |
| 4484 | |
| 4485 | if (!m_text.isEmpty()) |
| 4486 | writer.writeCharacters(m_text); |
| 4487 | |
| 4488 | writer.writeEndElement(); |
| 4489 | } |
| 4490 | |
| 4491 | DomPointF::~DomPointF() = default; |
| 4492 | |
| 4493 | void DomPointF::read(QXmlStreamReader &reader) |
| 4494 | { |
| 4495 | while (!reader.hasError()) { |
| 4496 | switch (reader.readNext()) { |
| 4497 | case QXmlStreamReader::StartElement : { |
| 4498 | const auto tag = reader.name(); |
| 4499 | if (!tag.compare(QLatin1String("x" ), Qt::CaseInsensitive)) { |
| 4500 | setElementX(reader.readElementText().toDouble()); |
| 4501 | continue; |
| 4502 | } |
| 4503 | if (!tag.compare(QLatin1String("y" ), Qt::CaseInsensitive)) { |
| 4504 | setElementY(reader.readElementText().toDouble()); |
| 4505 | continue; |
| 4506 | } |
| 4507 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 4508 | } |
| 4509 | break; |
| 4510 | case QXmlStreamReader::EndElement : |
| 4511 | return; |
| 4512 | default : |
| 4513 | break; |
| 4514 | } |
| 4515 | } |
| 4516 | } |
| 4517 | |
| 4518 | void DomPointF::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 4519 | { |
| 4520 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("pointf" ) : tagName.toLower()); |
| 4521 | |
| 4522 | if (m_children & X) |
| 4523 | writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x, 'f', 15)); |
| 4524 | |
| 4525 | if (m_children & Y) |
| 4526 | writer.writeTextElement(QString(QLatin1Char('y')), QString::number(m_y, 'f', 15)); |
| 4527 | |
| 4528 | writer.writeEndElement(); |
| 4529 | } |
| 4530 | |
| 4531 | void DomPointF::setElementX(double a) |
| 4532 | { |
| 4533 | m_children |= X; |
| 4534 | m_x = a; |
| 4535 | } |
| 4536 | |
| 4537 | void DomPointF::setElementY(double a) |
| 4538 | { |
| 4539 | m_children |= Y; |
| 4540 | m_y = a; |
| 4541 | } |
| 4542 | |
| 4543 | void DomPointF::clearElementX() |
| 4544 | { |
| 4545 | m_children &= ~X; |
| 4546 | } |
| 4547 | |
| 4548 | void DomPointF::clearElementY() |
| 4549 | { |
| 4550 | m_children &= ~Y; |
| 4551 | } |
| 4552 | |
| 4553 | DomRectF::~DomRectF() = default; |
| 4554 | |
| 4555 | void DomRectF::read(QXmlStreamReader &reader) |
| 4556 | { |
| 4557 | while (!reader.hasError()) { |
| 4558 | switch (reader.readNext()) { |
| 4559 | case QXmlStreamReader::StartElement : { |
| 4560 | const auto tag = reader.name(); |
| 4561 | if (!tag.compare(QLatin1String("x" ), Qt::CaseInsensitive)) { |
| 4562 | setElementX(reader.readElementText().toDouble()); |
| 4563 | continue; |
| 4564 | } |
| 4565 | if (!tag.compare(QLatin1String("y" ), Qt::CaseInsensitive)) { |
| 4566 | setElementY(reader.readElementText().toDouble()); |
| 4567 | continue; |
| 4568 | } |
| 4569 | if (!tag.compare(QLatin1String("width" ), Qt::CaseInsensitive)) { |
| 4570 | setElementWidth(reader.readElementText().toDouble()); |
| 4571 | continue; |
| 4572 | } |
| 4573 | if (!tag.compare(QLatin1String("height" ), Qt::CaseInsensitive)) { |
| 4574 | setElementHeight(reader.readElementText().toDouble()); |
| 4575 | continue; |
| 4576 | } |
| 4577 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 4578 | } |
| 4579 | break; |
| 4580 | case QXmlStreamReader::EndElement : |
| 4581 | return; |
| 4582 | default : |
| 4583 | break; |
| 4584 | } |
| 4585 | } |
| 4586 | } |
| 4587 | |
| 4588 | void DomRectF::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 4589 | { |
| 4590 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("rectf" ) : tagName.toLower()); |
| 4591 | |
| 4592 | if (m_children & X) |
| 4593 | writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x, 'f', 15)); |
| 4594 | |
| 4595 | if (m_children & Y) |
| 4596 | writer.writeTextElement(QString(QLatin1Char('y')), QString::number(m_y, 'f', 15)); |
| 4597 | |
| 4598 | if (m_children & Width) |
| 4599 | writer.writeTextElement(QStringLiteral("width" ), QString::number(m_width, 'f', 15)); |
| 4600 | |
| 4601 | if (m_children & Height) |
| 4602 | writer.writeTextElement(QStringLiteral("height" ), QString::number(m_height, 'f', 15)); |
| 4603 | |
| 4604 | writer.writeEndElement(); |
| 4605 | } |
| 4606 | |
| 4607 | void DomRectF::setElementX(double a) |
| 4608 | { |
| 4609 | m_children |= X; |
| 4610 | m_x = a; |
| 4611 | } |
| 4612 | |
| 4613 | void DomRectF::setElementY(double a) |
| 4614 | { |
| 4615 | m_children |= Y; |
| 4616 | m_y = a; |
| 4617 | } |
| 4618 | |
| 4619 | void DomRectF::setElementWidth(double a) |
| 4620 | { |
| 4621 | m_children |= Width; |
| 4622 | m_width = a; |
| 4623 | } |
| 4624 | |
| 4625 | void DomRectF::setElementHeight(double a) |
| 4626 | { |
| 4627 | m_children |= Height; |
| 4628 | m_height = a; |
| 4629 | } |
| 4630 | |
| 4631 | void DomRectF::clearElementX() |
| 4632 | { |
| 4633 | m_children &= ~X; |
| 4634 | } |
| 4635 | |
| 4636 | void DomRectF::clearElementY() |
| 4637 | { |
| 4638 | m_children &= ~Y; |
| 4639 | } |
| 4640 | |
| 4641 | void DomRectF::clearElementWidth() |
| 4642 | { |
| 4643 | m_children &= ~Width; |
| 4644 | } |
| 4645 | |
| 4646 | void DomRectF::clearElementHeight() |
| 4647 | { |
| 4648 | m_children &= ~Height; |
| 4649 | } |
| 4650 | |
| 4651 | DomSizeF::~DomSizeF() = default; |
| 4652 | |
| 4653 | void DomSizeF::read(QXmlStreamReader &reader) |
| 4654 | { |
| 4655 | while (!reader.hasError()) { |
| 4656 | switch (reader.readNext()) { |
| 4657 | case QXmlStreamReader::StartElement : { |
| 4658 | const auto tag = reader.name(); |
| 4659 | if (!tag.compare(QLatin1String("width" ), Qt::CaseInsensitive)) { |
| 4660 | setElementWidth(reader.readElementText().toDouble()); |
| 4661 | continue; |
| 4662 | } |
| 4663 | if (!tag.compare(QLatin1String("height" ), Qt::CaseInsensitive)) { |
| 4664 | setElementHeight(reader.readElementText().toDouble()); |
| 4665 | continue; |
| 4666 | } |
| 4667 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 4668 | } |
| 4669 | break; |
| 4670 | case QXmlStreamReader::EndElement : |
| 4671 | return; |
| 4672 | default : |
| 4673 | break; |
| 4674 | } |
| 4675 | } |
| 4676 | } |
| 4677 | |
| 4678 | void DomSizeF::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 4679 | { |
| 4680 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("sizef" ) : tagName.toLower()); |
| 4681 | |
| 4682 | if (m_children & Width) |
| 4683 | writer.writeTextElement(QStringLiteral("width" ), QString::number(m_width, 'f', 15)); |
| 4684 | |
| 4685 | if (m_children & Height) |
| 4686 | writer.writeTextElement(QStringLiteral("height" ), QString::number(m_height, 'f', 15)); |
| 4687 | |
| 4688 | writer.writeEndElement(); |
| 4689 | } |
| 4690 | |
| 4691 | void DomSizeF::setElementWidth(double a) |
| 4692 | { |
| 4693 | m_children |= Width; |
| 4694 | m_width = a; |
| 4695 | } |
| 4696 | |
| 4697 | void DomSizeF::setElementHeight(double a) |
| 4698 | { |
| 4699 | m_children |= Height; |
| 4700 | m_height = a; |
| 4701 | } |
| 4702 | |
| 4703 | void DomSizeF::clearElementWidth() |
| 4704 | { |
| 4705 | m_children &= ~Width; |
| 4706 | } |
| 4707 | |
| 4708 | void DomSizeF::clearElementHeight() |
| 4709 | { |
| 4710 | m_children &= ~Height; |
| 4711 | } |
| 4712 | |
| 4713 | DomChar::~DomChar() = default; |
| 4714 | |
| 4715 | void DomChar::read(QXmlStreamReader &reader) |
| 4716 | { |
| 4717 | while (!reader.hasError()) { |
| 4718 | switch (reader.readNext()) { |
| 4719 | case QXmlStreamReader::StartElement : { |
| 4720 | const auto tag = reader.name(); |
| 4721 | if (!tag.compare(QLatin1String("unicode" ), Qt::CaseInsensitive)) { |
| 4722 | setElementUnicode(reader.readElementText().toInt()); |
| 4723 | continue; |
| 4724 | } |
| 4725 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 4726 | } |
| 4727 | break; |
| 4728 | case QXmlStreamReader::EndElement : |
| 4729 | return; |
| 4730 | default : |
| 4731 | break; |
| 4732 | } |
| 4733 | } |
| 4734 | } |
| 4735 | |
| 4736 | void DomChar::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 4737 | { |
| 4738 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("char" ) : tagName.toLower()); |
| 4739 | |
| 4740 | if (m_children & Unicode) |
| 4741 | writer.writeTextElement(QStringLiteral("unicode" ), QString::number(m_unicode)); |
| 4742 | |
| 4743 | writer.writeEndElement(); |
| 4744 | } |
| 4745 | |
| 4746 | void DomChar::setElementUnicode(int a) |
| 4747 | { |
| 4748 | m_children |= Unicode; |
| 4749 | m_unicode = a; |
| 4750 | } |
| 4751 | |
| 4752 | void DomChar::clearElementUnicode() |
| 4753 | { |
| 4754 | m_children &= ~Unicode; |
| 4755 | } |
| 4756 | |
| 4757 | DomUrl::~DomUrl() |
| 4758 | { |
| 4759 | delete m_string; |
| 4760 | } |
| 4761 | |
| 4762 | void DomUrl::read(QXmlStreamReader &reader) |
| 4763 | { |
| 4764 | while (!reader.hasError()) { |
| 4765 | switch (reader.readNext()) { |
| 4766 | case QXmlStreamReader::StartElement : { |
| 4767 | const auto tag = reader.name(); |
| 4768 | if (!tag.compare(QLatin1String("string" ), Qt::CaseInsensitive)) { |
| 4769 | auto *v = new DomString(); |
| 4770 | v->read(reader); |
| 4771 | setElementString(v); |
| 4772 | continue; |
| 4773 | } |
| 4774 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 4775 | } |
| 4776 | break; |
| 4777 | case QXmlStreamReader::EndElement : |
| 4778 | return; |
| 4779 | default : |
| 4780 | break; |
| 4781 | } |
| 4782 | } |
| 4783 | } |
| 4784 | |
| 4785 | void DomUrl::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 4786 | { |
| 4787 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("url" ) : tagName.toLower()); |
| 4788 | |
| 4789 | if (m_children & String) |
| 4790 | m_string->write(writer, QStringLiteral("string" )); |
| 4791 | |
| 4792 | writer.writeEndElement(); |
| 4793 | } |
| 4794 | |
| 4795 | DomString *DomUrl::takeElementString() |
| 4796 | { |
| 4797 | DomString *a = m_string; |
| 4798 | m_string = nullptr; |
| 4799 | m_children ^= String; |
| 4800 | return a; |
| 4801 | } |
| 4802 | |
| 4803 | void DomUrl::setElementString(DomString *a) |
| 4804 | { |
| 4805 | delete m_string; |
| 4806 | m_children |= String; |
| 4807 | m_string = a; |
| 4808 | } |
| 4809 | |
| 4810 | void DomUrl::clearElementString() |
| 4811 | { |
| 4812 | delete m_string; |
| 4813 | m_string = nullptr; |
| 4814 | m_children &= ~String; |
| 4815 | } |
| 4816 | |
| 4817 | DomProperty::~DomProperty() |
| 4818 | { |
| 4819 | delete m_color; |
| 4820 | delete m_font; |
| 4821 | delete m_iconSet; |
| 4822 | delete m_pixmap; |
| 4823 | delete m_palette; |
| 4824 | delete m_point; |
| 4825 | delete m_rect; |
| 4826 | delete m_locale; |
| 4827 | delete m_sizePolicy; |
| 4828 | delete m_size; |
| 4829 | delete m_string; |
| 4830 | delete m_stringList; |
| 4831 | delete m_date; |
| 4832 | delete m_time; |
| 4833 | delete m_dateTime; |
| 4834 | delete m_pointF; |
| 4835 | delete m_rectF; |
| 4836 | delete m_sizeF; |
| 4837 | delete m_char; |
| 4838 | delete m_url; |
| 4839 | delete m_brush; |
| 4840 | } |
| 4841 | |
| 4842 | void DomProperty::clear() |
| 4843 | { |
| 4844 | delete m_color; |
| 4845 | delete m_font; |
| 4846 | delete m_iconSet; |
| 4847 | delete m_pixmap; |
| 4848 | delete m_palette; |
| 4849 | delete m_point; |
| 4850 | delete m_rect; |
| 4851 | delete m_locale; |
| 4852 | delete m_sizePolicy; |
| 4853 | delete m_size; |
| 4854 | delete m_string; |
| 4855 | delete m_stringList; |
| 4856 | delete m_date; |
| 4857 | delete m_time; |
| 4858 | delete m_dateTime; |
| 4859 | delete m_pointF; |
| 4860 | delete m_rectF; |
| 4861 | delete m_sizeF; |
| 4862 | delete m_char; |
| 4863 | delete m_url; |
| 4864 | delete m_brush; |
| 4865 | |
| 4866 | m_kind = Unknown; |
| 4867 | |
| 4868 | m_color = nullptr; |
| 4869 | m_cursor = 0; |
| 4870 | m_font = nullptr; |
| 4871 | m_iconSet = nullptr; |
| 4872 | m_pixmap = nullptr; |
| 4873 | m_palette = nullptr; |
| 4874 | m_point = nullptr; |
| 4875 | m_rect = nullptr; |
| 4876 | m_locale = nullptr; |
| 4877 | m_sizePolicy = nullptr; |
| 4878 | m_size = nullptr; |
| 4879 | m_string = nullptr; |
| 4880 | m_stringList = nullptr; |
| 4881 | m_number = 0; |
| 4882 | m_float = 0.0; |
| 4883 | m_double = 0.0; |
| 4884 | m_date = nullptr; |
| 4885 | m_time = nullptr; |
| 4886 | m_dateTime = nullptr; |
| 4887 | m_pointF = nullptr; |
| 4888 | m_rectF = nullptr; |
| 4889 | m_sizeF = nullptr; |
| 4890 | m_longLong = 0; |
| 4891 | m_char = nullptr; |
| 4892 | m_url = nullptr; |
| 4893 | m_UInt = 0; |
| 4894 | m_uLongLong = 0; |
| 4895 | m_brush = nullptr; |
| 4896 | } |
| 4897 | |
| 4898 | void DomProperty::read(QXmlStreamReader &reader) |
| 4899 | { |
| 4900 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 4901 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 4902 | const auto name = attribute.name(); |
| 4903 | if (name == QLatin1String("name" )) { |
| 4904 | setAttributeName(attribute.value().toString()); |
| 4905 | continue; |
| 4906 | } |
| 4907 | if (name == QLatin1String("stdset" )) { |
| 4908 | setAttributeStdset(attribute.value().toInt()); |
| 4909 | continue; |
| 4910 | } |
| 4911 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 4912 | } |
| 4913 | |
| 4914 | while (!reader.hasError()) { |
| 4915 | switch (reader.readNext()) { |
| 4916 | case QXmlStreamReader::StartElement : { |
| 4917 | const auto tag = reader.name(); |
| 4918 | if (!tag.compare(QLatin1String("bool" ), Qt::CaseInsensitive)) { |
| 4919 | setElementBool(reader.readElementText()); |
| 4920 | continue; |
| 4921 | } |
| 4922 | if (!tag.compare(QLatin1String("color" ), Qt::CaseInsensitive)) { |
| 4923 | auto *v = new DomColor(); |
| 4924 | v->read(reader); |
| 4925 | setElementColor(v); |
| 4926 | continue; |
| 4927 | } |
| 4928 | if (!tag.compare(QLatin1String("cstring" ), Qt::CaseInsensitive)) { |
| 4929 | setElementCstring(reader.readElementText()); |
| 4930 | continue; |
| 4931 | } |
| 4932 | if (!tag.compare(QLatin1String("cursor" ), Qt::CaseInsensitive)) { |
| 4933 | setElementCursor(reader.readElementText().toInt()); |
| 4934 | continue; |
| 4935 | } |
| 4936 | if (!tag.compare(QLatin1String("cursorshape" ), Qt::CaseInsensitive)) { |
| 4937 | setElementCursorShape(reader.readElementText()); |
| 4938 | continue; |
| 4939 | } |
| 4940 | if (!tag.compare(QLatin1String("enum" ), Qt::CaseInsensitive)) { |
| 4941 | setElementEnum(reader.readElementText()); |
| 4942 | continue; |
| 4943 | } |
| 4944 | if (!tag.compare(QLatin1String("font" ), Qt::CaseInsensitive)) { |
| 4945 | auto *v = new DomFont(); |
| 4946 | v->read(reader); |
| 4947 | setElementFont(v); |
| 4948 | continue; |
| 4949 | } |
| 4950 | if (!tag.compare(QLatin1String("iconset" ), Qt::CaseInsensitive)) { |
| 4951 | auto *v = new DomResourceIcon(); |
| 4952 | v->read(reader); |
| 4953 | setElementIconSet(v); |
| 4954 | continue; |
| 4955 | } |
| 4956 | if (!tag.compare(QLatin1String("pixmap" ), Qt::CaseInsensitive)) { |
| 4957 | auto *v = new DomResourcePixmap(); |
| 4958 | v->read(reader); |
| 4959 | setElementPixmap(v); |
| 4960 | continue; |
| 4961 | } |
| 4962 | if (!tag.compare(QLatin1String("palette" ), Qt::CaseInsensitive)) { |
| 4963 | auto *v = new DomPalette(); |
| 4964 | v->read(reader); |
| 4965 | setElementPalette(v); |
| 4966 | continue; |
| 4967 | } |
| 4968 | if (!tag.compare(QLatin1String("point" ), Qt::CaseInsensitive)) { |
| 4969 | auto *v = new DomPoint(); |
| 4970 | v->read(reader); |
| 4971 | setElementPoint(v); |
| 4972 | continue; |
| 4973 | } |
| 4974 | if (!tag.compare(QLatin1String("rect" ), Qt::CaseInsensitive)) { |
| 4975 | auto *v = new DomRect(); |
| 4976 | v->read(reader); |
| 4977 | setElementRect(v); |
| 4978 | continue; |
| 4979 | } |
| 4980 | if (!tag.compare(QLatin1String("set" ), Qt::CaseInsensitive)) { |
| 4981 | setElementSet(reader.readElementText()); |
| 4982 | continue; |
| 4983 | } |
| 4984 | if (!tag.compare(QLatin1String("locale" ), Qt::CaseInsensitive)) { |
| 4985 | auto *v = new DomLocale(); |
| 4986 | v->read(reader); |
| 4987 | setElementLocale(v); |
| 4988 | continue; |
| 4989 | } |
| 4990 | if (!tag.compare(QLatin1String("sizepolicy" ), Qt::CaseInsensitive)) { |
| 4991 | auto *v = new DomSizePolicy(); |
| 4992 | v->read(reader); |
| 4993 | setElementSizePolicy(v); |
| 4994 | continue; |
| 4995 | } |
| 4996 | if (!tag.compare(QLatin1String("size" ), Qt::CaseInsensitive)) { |
| 4997 | auto *v = new DomSize(); |
| 4998 | v->read(reader); |
| 4999 | setElementSize(v); |
| 5000 | continue; |
| 5001 | } |
| 5002 | if (!tag.compare(QLatin1String("string" ), Qt::CaseInsensitive)) { |
| 5003 | auto *v = new DomString(); |
| 5004 | v->read(reader); |
| 5005 | setElementString(v); |
| 5006 | continue; |
| 5007 | } |
| 5008 | if (!tag.compare(QLatin1String("stringlist" ), Qt::CaseInsensitive)) { |
| 5009 | auto *v = new DomStringList(); |
| 5010 | v->read(reader); |
| 5011 | setElementStringList(v); |
| 5012 | continue; |
| 5013 | } |
| 5014 | if (!tag.compare(QLatin1String("number" ), Qt::CaseInsensitive)) { |
| 5015 | setElementNumber(reader.readElementText().toInt()); |
| 5016 | continue; |
| 5017 | } |
| 5018 | if (!tag.compare(QLatin1String("float" ), Qt::CaseInsensitive)) { |
| 5019 | setElementFloat(reader.readElementText().toFloat()); |
| 5020 | continue; |
| 5021 | } |
| 5022 | if (!tag.compare(QLatin1String("double" ), Qt::CaseInsensitive)) { |
| 5023 | setElementDouble(reader.readElementText().toDouble()); |
| 5024 | continue; |
| 5025 | } |
| 5026 | if (!tag.compare(QLatin1String("date" ), Qt::CaseInsensitive)) { |
| 5027 | auto *v = new DomDate(); |
| 5028 | v->read(reader); |
| 5029 | setElementDate(v); |
| 5030 | continue; |
| 5031 | } |
| 5032 | if (!tag.compare(QLatin1String("time" ), Qt::CaseInsensitive)) { |
| 5033 | auto *v = new DomTime(); |
| 5034 | v->read(reader); |
| 5035 | setElementTime(v); |
| 5036 | continue; |
| 5037 | } |
| 5038 | if (!tag.compare(QLatin1String("datetime" ), Qt::CaseInsensitive)) { |
| 5039 | auto *v = new DomDateTime(); |
| 5040 | v->read(reader); |
| 5041 | setElementDateTime(v); |
| 5042 | continue; |
| 5043 | } |
| 5044 | if (!tag.compare(QLatin1String("pointf" ), Qt::CaseInsensitive)) { |
| 5045 | auto *v = new DomPointF(); |
| 5046 | v->read(reader); |
| 5047 | setElementPointF(v); |
| 5048 | continue; |
| 5049 | } |
| 5050 | if (!tag.compare(QLatin1String("rectf" ), Qt::CaseInsensitive)) { |
| 5051 | auto *v = new DomRectF(); |
| 5052 | v->read(reader); |
| 5053 | setElementRectF(v); |
| 5054 | continue; |
| 5055 | } |
| 5056 | if (!tag.compare(QLatin1String("sizef" ), Qt::CaseInsensitive)) { |
| 5057 | auto *v = new DomSizeF(); |
| 5058 | v->read(reader); |
| 5059 | setElementSizeF(v); |
| 5060 | continue; |
| 5061 | } |
| 5062 | if (!tag.compare(QLatin1String("longlong" ), Qt::CaseInsensitive)) { |
| 5063 | setElementLongLong(reader.readElementText().toLongLong()); |
| 5064 | continue; |
| 5065 | } |
| 5066 | if (!tag.compare(QLatin1String("char" ), Qt::CaseInsensitive)) { |
| 5067 | auto *v = new DomChar(); |
| 5068 | v->read(reader); |
| 5069 | setElementChar(v); |
| 5070 | continue; |
| 5071 | } |
| 5072 | if (!tag.compare(QLatin1String("url" ), Qt::CaseInsensitive)) { |
| 5073 | auto *v = new DomUrl(); |
| 5074 | v->read(reader); |
| 5075 | setElementUrl(v); |
| 5076 | continue; |
| 5077 | } |
| 5078 | if (!tag.compare(QLatin1String("uint" ), Qt::CaseInsensitive)) { |
| 5079 | setElementUInt(reader.readElementText().toUInt()); |
| 5080 | continue; |
| 5081 | } |
| 5082 | if (!tag.compare(QLatin1String("ulonglong" ), Qt::CaseInsensitive)) { |
| 5083 | setElementULongLong(reader.readElementText().toULongLong()); |
| 5084 | continue; |
| 5085 | } |
| 5086 | if (!tag.compare(QLatin1String("brush" ), Qt::CaseInsensitive)) { |
| 5087 | auto *v = new DomBrush(); |
| 5088 | v->read(reader); |
| 5089 | setElementBrush(v); |
| 5090 | continue; |
| 5091 | } |
| 5092 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 5093 | } |
| 5094 | break; |
| 5095 | case QXmlStreamReader::EndElement : |
| 5096 | return; |
| 5097 | default : |
| 5098 | break; |
| 5099 | } |
| 5100 | } |
| 5101 | } |
| 5102 | |
| 5103 | void DomProperty::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 5104 | { |
| 5105 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("property" ) : tagName.toLower()); |
| 5106 | |
| 5107 | if (hasAttributeName()) |
| 5108 | writer.writeAttribute(QStringLiteral("name" ), attributeName()); |
| 5109 | |
| 5110 | if (hasAttributeStdset()) |
| 5111 | writer.writeAttribute(QStringLiteral("stdset" ), QString::number(attributeStdset())); |
| 5112 | |
| 5113 | switch (kind()) { |
| 5114 | case Bool: |
| 5115 | writer.writeTextElement(QStringLiteral("bool" ), elementBool()); |
| 5116 | break; |
| 5117 | |
| 5118 | case Color: |
| 5119 | if (m_color != nullptr) |
| 5120 | m_color->write(writer, QStringLiteral("color" )); |
| 5121 | break; |
| 5122 | |
| 5123 | case Cstring: |
| 5124 | writer.writeTextElement(QStringLiteral("cstring" ), elementCstring()); |
| 5125 | break; |
| 5126 | |
| 5127 | case Cursor: |
| 5128 | writer.writeTextElement(QStringLiteral("cursor" ), QString::number(elementCursor())); |
| 5129 | break; |
| 5130 | |
| 5131 | case CursorShape: |
| 5132 | writer.writeTextElement(QStringLiteral("cursorShape" ), elementCursorShape()); |
| 5133 | break; |
| 5134 | |
| 5135 | case Enum: |
| 5136 | writer.writeTextElement(QStringLiteral("enum" ), elementEnum()); |
| 5137 | break; |
| 5138 | |
| 5139 | case Font: |
| 5140 | if (m_font != nullptr) |
| 5141 | m_font->write(writer, QStringLiteral("font" )); |
| 5142 | break; |
| 5143 | |
| 5144 | case IconSet: |
| 5145 | if (m_iconSet != nullptr) |
| 5146 | m_iconSet->write(writer, QStringLiteral("iconset" )); |
| 5147 | break; |
| 5148 | |
| 5149 | case Pixmap: |
| 5150 | if (m_pixmap != nullptr) |
| 5151 | m_pixmap->write(writer, QStringLiteral("pixmap" )); |
| 5152 | break; |
| 5153 | |
| 5154 | case Palette: |
| 5155 | if (m_palette != nullptr) |
| 5156 | m_palette->write(writer, QStringLiteral("palette" )); |
| 5157 | break; |
| 5158 | |
| 5159 | case Point: |
| 5160 | if (m_point != nullptr) |
| 5161 | m_point->write(writer, QStringLiteral("point" )); |
| 5162 | break; |
| 5163 | |
| 5164 | case Rect: |
| 5165 | if (m_rect != nullptr) |
| 5166 | m_rect->write(writer, QStringLiteral("rect" )); |
| 5167 | break; |
| 5168 | |
| 5169 | case Set: |
| 5170 | writer.writeTextElement(QStringLiteral("set" ), elementSet()); |
| 5171 | break; |
| 5172 | |
| 5173 | case Locale: |
| 5174 | if (m_locale != nullptr) |
| 5175 | m_locale->write(writer, QStringLiteral("locale" )); |
| 5176 | break; |
| 5177 | |
| 5178 | case SizePolicy: |
| 5179 | if (m_sizePolicy != nullptr) |
| 5180 | m_sizePolicy->write(writer, QStringLiteral("sizepolicy" )); |
| 5181 | break; |
| 5182 | |
| 5183 | case Size: |
| 5184 | if (m_size != nullptr) |
| 5185 | m_size->write(writer, QStringLiteral("size" )); |
| 5186 | break; |
| 5187 | |
| 5188 | case String: |
| 5189 | if (m_string != nullptr) |
| 5190 | m_string->write(writer, QStringLiteral("string" )); |
| 5191 | break; |
| 5192 | |
| 5193 | case StringList: |
| 5194 | if (m_stringList != nullptr) |
| 5195 | m_stringList->write(writer, QStringLiteral("stringlist" )); |
| 5196 | break; |
| 5197 | |
| 5198 | case Number: |
| 5199 | writer.writeTextElement(QStringLiteral("number" ), QString::number(elementNumber())); |
| 5200 | break; |
| 5201 | |
| 5202 | case Float: |
| 5203 | writer.writeTextElement(QStringLiteral("float" ), QString::number(elementFloat(), 'f', 8)); |
| 5204 | break; |
| 5205 | |
| 5206 | case Double: |
| 5207 | writer.writeTextElement(QStringLiteral("double" ), QString::number(elementDouble(), 'f', 15)); |
| 5208 | break; |
| 5209 | |
| 5210 | case Date: |
| 5211 | if (m_date != nullptr) |
| 5212 | m_date->write(writer, QStringLiteral("date" )); |
| 5213 | break; |
| 5214 | |
| 5215 | case Time: |
| 5216 | if (m_time != nullptr) |
| 5217 | m_time->write(writer, QStringLiteral("time" )); |
| 5218 | break; |
| 5219 | |
| 5220 | case DateTime: |
| 5221 | if (m_dateTime != nullptr) |
| 5222 | m_dateTime->write(writer, QStringLiteral("datetime" )); |
| 5223 | break; |
| 5224 | |
| 5225 | case PointF: |
| 5226 | if (m_pointF != nullptr) |
| 5227 | m_pointF->write(writer, QStringLiteral("pointf" )); |
| 5228 | break; |
| 5229 | |
| 5230 | case RectF: |
| 5231 | if (m_rectF != nullptr) |
| 5232 | m_rectF->write(writer, QStringLiteral("rectf" )); |
| 5233 | break; |
| 5234 | |
| 5235 | case SizeF: |
| 5236 | if (m_sizeF != nullptr) |
| 5237 | m_sizeF->write(writer, QStringLiteral("sizef" )); |
| 5238 | break; |
| 5239 | |
| 5240 | case LongLong: |
| 5241 | writer.writeTextElement(QStringLiteral("longLong" ), QString::number(elementLongLong())); |
| 5242 | break; |
| 5243 | |
| 5244 | case Char: |
| 5245 | if (m_char != nullptr) |
| 5246 | m_char->write(writer, QStringLiteral("char" )); |
| 5247 | break; |
| 5248 | |
| 5249 | case Url: |
| 5250 | if (m_url != nullptr) |
| 5251 | m_url->write(writer, QStringLiteral("url" )); |
| 5252 | break; |
| 5253 | |
| 5254 | case UInt: |
| 5255 | writer.writeTextElement(QStringLiteral("UInt" ), QString::number(elementUInt())); |
| 5256 | break; |
| 5257 | |
| 5258 | case ULongLong: |
| 5259 | writer.writeTextElement(QStringLiteral("uLongLong" ), QString::number(elementULongLong())); |
| 5260 | break; |
| 5261 | |
| 5262 | case Brush: |
| 5263 | if (m_brush != nullptr) |
| 5264 | m_brush->write(writer, QStringLiteral("brush" )); |
| 5265 | break; |
| 5266 | |
| 5267 | default: |
| 5268 | break; |
| 5269 | } |
| 5270 | writer.writeEndElement(); |
| 5271 | } |
| 5272 | |
| 5273 | void DomProperty::setElementBool(const QString &a) |
| 5274 | { |
| 5275 | clear(); |
| 5276 | m_kind = Bool; |
| 5277 | m_bool = a; |
| 5278 | } |
| 5279 | |
| 5280 | DomColor *DomProperty::takeElementColor() |
| 5281 | { |
| 5282 | DomColor *a = m_color; |
| 5283 | m_color = nullptr; |
| 5284 | return a; |
| 5285 | } |
| 5286 | |
| 5287 | void DomProperty::setElementColor(DomColor *a) |
| 5288 | { |
| 5289 | clear(); |
| 5290 | m_kind = Color; |
| 5291 | m_color = a; |
| 5292 | } |
| 5293 | |
| 5294 | void DomProperty::setElementCstring(const QString &a) |
| 5295 | { |
| 5296 | clear(); |
| 5297 | m_kind = Cstring; |
| 5298 | m_cstring = a; |
| 5299 | } |
| 5300 | |
| 5301 | void DomProperty::setElementCursor(int a) |
| 5302 | { |
| 5303 | clear(); |
| 5304 | m_kind = Cursor; |
| 5305 | m_cursor = a; |
| 5306 | } |
| 5307 | |
| 5308 | void DomProperty::setElementCursorShape(const QString &a) |
| 5309 | { |
| 5310 | clear(); |
| 5311 | m_kind = CursorShape; |
| 5312 | m_cursorShape = a; |
| 5313 | } |
| 5314 | |
| 5315 | void DomProperty::setElementEnum(const QString &a) |
| 5316 | { |
| 5317 | clear(); |
| 5318 | m_kind = Enum; |
| 5319 | m_enum = a; |
| 5320 | } |
| 5321 | |
| 5322 | DomFont *DomProperty::takeElementFont() |
| 5323 | { |
| 5324 | DomFont *a = m_font; |
| 5325 | m_font = nullptr; |
| 5326 | return a; |
| 5327 | } |
| 5328 | |
| 5329 | void DomProperty::setElementFont(DomFont *a) |
| 5330 | { |
| 5331 | clear(); |
| 5332 | m_kind = Font; |
| 5333 | m_font = a; |
| 5334 | } |
| 5335 | |
| 5336 | DomResourceIcon *DomProperty::takeElementIconSet() |
| 5337 | { |
| 5338 | DomResourceIcon *a = m_iconSet; |
| 5339 | m_iconSet = nullptr; |
| 5340 | return a; |
| 5341 | } |
| 5342 | |
| 5343 | void DomProperty::setElementIconSet(DomResourceIcon *a) |
| 5344 | { |
| 5345 | clear(); |
| 5346 | m_kind = IconSet; |
| 5347 | m_iconSet = a; |
| 5348 | } |
| 5349 | |
| 5350 | DomResourcePixmap *DomProperty::takeElementPixmap() |
| 5351 | { |
| 5352 | DomResourcePixmap *a = m_pixmap; |
| 5353 | m_pixmap = nullptr; |
| 5354 | return a; |
| 5355 | } |
| 5356 | |
| 5357 | void DomProperty::setElementPixmap(DomResourcePixmap *a) |
| 5358 | { |
| 5359 | clear(); |
| 5360 | m_kind = Pixmap; |
| 5361 | m_pixmap = a; |
| 5362 | } |
| 5363 | |
| 5364 | DomPalette *DomProperty::takeElementPalette() |
| 5365 | { |
| 5366 | DomPalette *a = m_palette; |
| 5367 | m_palette = nullptr; |
| 5368 | return a; |
| 5369 | } |
| 5370 | |
| 5371 | void DomProperty::setElementPalette(DomPalette *a) |
| 5372 | { |
| 5373 | clear(); |
| 5374 | m_kind = Palette; |
| 5375 | m_palette = a; |
| 5376 | } |
| 5377 | |
| 5378 | DomPoint *DomProperty::takeElementPoint() |
| 5379 | { |
| 5380 | DomPoint *a = m_point; |
| 5381 | m_point = nullptr; |
| 5382 | return a; |
| 5383 | } |
| 5384 | |
| 5385 | void DomProperty::setElementPoint(DomPoint *a) |
| 5386 | { |
| 5387 | clear(); |
| 5388 | m_kind = Point; |
| 5389 | m_point = a; |
| 5390 | } |
| 5391 | |
| 5392 | DomRect *DomProperty::takeElementRect() |
| 5393 | { |
| 5394 | DomRect *a = m_rect; |
| 5395 | m_rect = nullptr; |
| 5396 | return a; |
| 5397 | } |
| 5398 | |
| 5399 | void DomProperty::setElementRect(DomRect *a) |
| 5400 | { |
| 5401 | clear(); |
| 5402 | m_kind = Rect; |
| 5403 | m_rect = a; |
| 5404 | } |
| 5405 | |
| 5406 | void DomProperty::setElementSet(const QString &a) |
| 5407 | { |
| 5408 | clear(); |
| 5409 | m_kind = Set; |
| 5410 | m_set = a; |
| 5411 | } |
| 5412 | |
| 5413 | DomLocale *DomProperty::takeElementLocale() |
| 5414 | { |
| 5415 | DomLocale *a = m_locale; |
| 5416 | m_locale = nullptr; |
| 5417 | return a; |
| 5418 | } |
| 5419 | |
| 5420 | void DomProperty::setElementLocale(DomLocale *a) |
| 5421 | { |
| 5422 | clear(); |
| 5423 | m_kind = Locale; |
| 5424 | m_locale = a; |
| 5425 | } |
| 5426 | |
| 5427 | DomSizePolicy *DomProperty::takeElementSizePolicy() |
| 5428 | { |
| 5429 | DomSizePolicy *a = m_sizePolicy; |
| 5430 | m_sizePolicy = nullptr; |
| 5431 | return a; |
| 5432 | } |
| 5433 | |
| 5434 | void DomProperty::setElementSizePolicy(DomSizePolicy *a) |
| 5435 | { |
| 5436 | clear(); |
| 5437 | m_kind = SizePolicy; |
| 5438 | m_sizePolicy = a; |
| 5439 | } |
| 5440 | |
| 5441 | DomSize *DomProperty::takeElementSize() |
| 5442 | { |
| 5443 | DomSize *a = m_size; |
| 5444 | m_size = nullptr; |
| 5445 | return a; |
| 5446 | } |
| 5447 | |
| 5448 | void DomProperty::setElementSize(DomSize *a) |
| 5449 | { |
| 5450 | clear(); |
| 5451 | m_kind = Size; |
| 5452 | m_size = a; |
| 5453 | } |
| 5454 | |
| 5455 | DomString *DomProperty::takeElementString() |
| 5456 | { |
| 5457 | DomString *a = m_string; |
| 5458 | m_string = nullptr; |
| 5459 | return a; |
| 5460 | } |
| 5461 | |
| 5462 | void DomProperty::setElementString(DomString *a) |
| 5463 | { |
| 5464 | clear(); |
| 5465 | m_kind = String; |
| 5466 | m_string = a; |
| 5467 | } |
| 5468 | |
| 5469 | DomStringList *DomProperty::takeElementStringList() |
| 5470 | { |
| 5471 | DomStringList *a = m_stringList; |
| 5472 | m_stringList = nullptr; |
| 5473 | return a; |
| 5474 | } |
| 5475 | |
| 5476 | void DomProperty::setElementStringList(DomStringList *a) |
| 5477 | { |
| 5478 | clear(); |
| 5479 | m_kind = StringList; |
| 5480 | m_stringList = a; |
| 5481 | } |
| 5482 | |
| 5483 | void DomProperty::setElementNumber(int a) |
| 5484 | { |
| 5485 | clear(); |
| 5486 | m_kind = Number; |
| 5487 | m_number = a; |
| 5488 | } |
| 5489 | |
| 5490 | void DomProperty::setElementFloat(float a) |
| 5491 | { |
| 5492 | clear(); |
| 5493 | m_kind = Float; |
| 5494 | m_float = a; |
| 5495 | } |
| 5496 | |
| 5497 | void DomProperty::setElementDouble(double a) |
| 5498 | { |
| 5499 | clear(); |
| 5500 | m_kind = Double; |
| 5501 | m_double = a; |
| 5502 | } |
| 5503 | |
| 5504 | DomDate *DomProperty::takeElementDate() |
| 5505 | { |
| 5506 | DomDate *a = m_date; |
| 5507 | m_date = nullptr; |
| 5508 | return a; |
| 5509 | } |
| 5510 | |
| 5511 | void DomProperty::setElementDate(DomDate *a) |
| 5512 | { |
| 5513 | clear(); |
| 5514 | m_kind = Date; |
| 5515 | m_date = a; |
| 5516 | } |
| 5517 | |
| 5518 | DomTime *DomProperty::takeElementTime() |
| 5519 | { |
| 5520 | DomTime *a = m_time; |
| 5521 | m_time = nullptr; |
| 5522 | return a; |
| 5523 | } |
| 5524 | |
| 5525 | void DomProperty::setElementTime(DomTime *a) |
| 5526 | { |
| 5527 | clear(); |
| 5528 | m_kind = Time; |
| 5529 | m_time = a; |
| 5530 | } |
| 5531 | |
| 5532 | DomDateTime *DomProperty::takeElementDateTime() |
| 5533 | { |
| 5534 | DomDateTime *a = m_dateTime; |
| 5535 | m_dateTime = nullptr; |
| 5536 | return a; |
| 5537 | } |
| 5538 | |
| 5539 | void DomProperty::setElementDateTime(DomDateTime *a) |
| 5540 | { |
| 5541 | clear(); |
| 5542 | m_kind = DateTime; |
| 5543 | m_dateTime = a; |
| 5544 | } |
| 5545 | |
| 5546 | DomPointF *DomProperty::takeElementPointF() |
| 5547 | { |
| 5548 | DomPointF *a = m_pointF; |
| 5549 | m_pointF = nullptr; |
| 5550 | return a; |
| 5551 | } |
| 5552 | |
| 5553 | void DomProperty::setElementPointF(DomPointF *a) |
| 5554 | { |
| 5555 | clear(); |
| 5556 | m_kind = PointF; |
| 5557 | m_pointF = a; |
| 5558 | } |
| 5559 | |
| 5560 | DomRectF *DomProperty::takeElementRectF() |
| 5561 | { |
| 5562 | DomRectF *a = m_rectF; |
| 5563 | m_rectF = nullptr; |
| 5564 | return a; |
| 5565 | } |
| 5566 | |
| 5567 | void DomProperty::setElementRectF(DomRectF *a) |
| 5568 | { |
| 5569 | clear(); |
| 5570 | m_kind = RectF; |
| 5571 | m_rectF = a; |
| 5572 | } |
| 5573 | |
| 5574 | DomSizeF *DomProperty::takeElementSizeF() |
| 5575 | { |
| 5576 | DomSizeF *a = m_sizeF; |
| 5577 | m_sizeF = nullptr; |
| 5578 | return a; |
| 5579 | } |
| 5580 | |
| 5581 | void DomProperty::setElementSizeF(DomSizeF *a) |
| 5582 | { |
| 5583 | clear(); |
| 5584 | m_kind = SizeF; |
| 5585 | m_sizeF = a; |
| 5586 | } |
| 5587 | |
| 5588 | void DomProperty::setElementLongLong(qlonglong a) |
| 5589 | { |
| 5590 | clear(); |
| 5591 | m_kind = LongLong; |
| 5592 | m_longLong = a; |
| 5593 | } |
| 5594 | |
| 5595 | DomChar *DomProperty::takeElementChar() |
| 5596 | { |
| 5597 | DomChar *a = m_char; |
| 5598 | m_char = nullptr; |
| 5599 | return a; |
| 5600 | } |
| 5601 | |
| 5602 | void DomProperty::setElementChar(DomChar *a) |
| 5603 | { |
| 5604 | clear(); |
| 5605 | m_kind = Char; |
| 5606 | m_char = a; |
| 5607 | } |
| 5608 | |
| 5609 | DomUrl *DomProperty::takeElementUrl() |
| 5610 | { |
| 5611 | DomUrl *a = m_url; |
| 5612 | m_url = nullptr; |
| 5613 | return a; |
| 5614 | } |
| 5615 | |
| 5616 | void DomProperty::setElementUrl(DomUrl *a) |
| 5617 | { |
| 5618 | clear(); |
| 5619 | m_kind = Url; |
| 5620 | m_url = a; |
| 5621 | } |
| 5622 | |
| 5623 | void DomProperty::setElementUInt(uint a) |
| 5624 | { |
| 5625 | clear(); |
| 5626 | m_kind = UInt; |
| 5627 | m_UInt = a; |
| 5628 | } |
| 5629 | |
| 5630 | void DomProperty::setElementULongLong(qulonglong a) |
| 5631 | { |
| 5632 | clear(); |
| 5633 | m_kind = ULongLong; |
| 5634 | m_uLongLong = a; |
| 5635 | } |
| 5636 | |
| 5637 | DomBrush *DomProperty::takeElementBrush() |
| 5638 | { |
| 5639 | DomBrush *a = m_brush; |
| 5640 | m_brush = nullptr; |
| 5641 | return a; |
| 5642 | } |
| 5643 | |
| 5644 | void DomProperty::setElementBrush(DomBrush *a) |
| 5645 | { |
| 5646 | clear(); |
| 5647 | m_kind = Brush; |
| 5648 | m_brush = a; |
| 5649 | } |
| 5650 | |
| 5651 | DomConnections::~DomConnections() |
| 5652 | { |
| 5653 | qDeleteAll(m_connection); |
| 5654 | m_connection.clear(); |
| 5655 | } |
| 5656 | |
| 5657 | void DomConnections::read(QXmlStreamReader &reader) |
| 5658 | { |
| 5659 | while (!reader.hasError()) { |
| 5660 | switch (reader.readNext()) { |
| 5661 | case QXmlStreamReader::StartElement : { |
| 5662 | const auto tag = reader.name(); |
| 5663 | if (!tag.compare(QLatin1String("connection" ), Qt::CaseInsensitive)) { |
| 5664 | auto *v = new DomConnection(); |
| 5665 | v->read(reader); |
| 5666 | m_connection.append(v); |
| 5667 | continue; |
| 5668 | } |
| 5669 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 5670 | } |
| 5671 | break; |
| 5672 | case QXmlStreamReader::EndElement : |
| 5673 | return; |
| 5674 | default : |
| 5675 | break; |
| 5676 | } |
| 5677 | } |
| 5678 | } |
| 5679 | |
| 5680 | void DomConnections::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 5681 | { |
| 5682 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("connections" ) : tagName.toLower()); |
| 5683 | |
| 5684 | for (DomConnection *v : m_connection) |
| 5685 | v->write(writer, QStringLiteral("connection" )); |
| 5686 | |
| 5687 | writer.writeEndElement(); |
| 5688 | } |
| 5689 | |
| 5690 | void DomConnections::setElementConnection(const QList<DomConnection *> &a) |
| 5691 | { |
| 5692 | m_children |= Connection; |
| 5693 | m_connection = a; |
| 5694 | } |
| 5695 | |
| 5696 | DomConnection::~DomConnection() |
| 5697 | { |
| 5698 | delete m_hints; |
| 5699 | } |
| 5700 | |
| 5701 | void DomConnection::read(QXmlStreamReader &reader) |
| 5702 | { |
| 5703 | while (!reader.hasError()) { |
| 5704 | switch (reader.readNext()) { |
| 5705 | case QXmlStreamReader::StartElement : { |
| 5706 | const auto tag = reader.name(); |
| 5707 | if (!tag.compare(QLatin1String("sender" ), Qt::CaseInsensitive)) { |
| 5708 | setElementSender(reader.readElementText()); |
| 5709 | continue; |
| 5710 | } |
| 5711 | if (!tag.compare(QLatin1String("signal" ), Qt::CaseInsensitive)) { |
| 5712 | setElementSignal(reader.readElementText()); |
| 5713 | continue; |
| 5714 | } |
| 5715 | if (!tag.compare(QLatin1String("receiver" ), Qt::CaseInsensitive)) { |
| 5716 | setElementReceiver(reader.readElementText()); |
| 5717 | continue; |
| 5718 | } |
| 5719 | if (!tag.compare(QLatin1String("slot" ), Qt::CaseInsensitive)) { |
| 5720 | setElementSlot(reader.readElementText()); |
| 5721 | continue; |
| 5722 | } |
| 5723 | if (!tag.compare(QLatin1String("hints" ), Qt::CaseInsensitive)) { |
| 5724 | auto *v = new DomConnectionHints(); |
| 5725 | v->read(reader); |
| 5726 | setElementHints(v); |
| 5727 | continue; |
| 5728 | } |
| 5729 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 5730 | } |
| 5731 | break; |
| 5732 | case QXmlStreamReader::EndElement : |
| 5733 | return; |
| 5734 | default : |
| 5735 | break; |
| 5736 | } |
| 5737 | } |
| 5738 | } |
| 5739 | |
| 5740 | void DomConnection::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 5741 | { |
| 5742 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("connection" ) : tagName.toLower()); |
| 5743 | |
| 5744 | if (m_children & Sender) |
| 5745 | writer.writeTextElement(QStringLiteral("sender" ), m_sender); |
| 5746 | |
| 5747 | if (m_children & Signal) |
| 5748 | writer.writeTextElement(QStringLiteral("signal" ), m_signal); |
| 5749 | |
| 5750 | if (m_children & Receiver) |
| 5751 | writer.writeTextElement(QStringLiteral("receiver" ), m_receiver); |
| 5752 | |
| 5753 | if (m_children & Slot) |
| 5754 | writer.writeTextElement(QStringLiteral("slot" ), m_slot); |
| 5755 | |
| 5756 | if (m_children & Hints) |
| 5757 | m_hints->write(writer, QStringLiteral("hints" )); |
| 5758 | |
| 5759 | writer.writeEndElement(); |
| 5760 | } |
| 5761 | |
| 5762 | void DomConnection::setElementSender(const QString &a) |
| 5763 | { |
| 5764 | m_children |= Sender; |
| 5765 | m_sender = a; |
| 5766 | } |
| 5767 | |
| 5768 | void DomConnection::setElementSignal(const QString &a) |
| 5769 | { |
| 5770 | m_children |= Signal; |
| 5771 | m_signal = a; |
| 5772 | } |
| 5773 | |
| 5774 | void DomConnection::setElementReceiver(const QString &a) |
| 5775 | { |
| 5776 | m_children |= Receiver; |
| 5777 | m_receiver = a; |
| 5778 | } |
| 5779 | |
| 5780 | void DomConnection::setElementSlot(const QString &a) |
| 5781 | { |
| 5782 | m_children |= Slot; |
| 5783 | m_slot = a; |
| 5784 | } |
| 5785 | |
| 5786 | DomConnectionHints *DomConnection::takeElementHints() |
| 5787 | { |
| 5788 | DomConnectionHints *a = m_hints; |
| 5789 | m_hints = nullptr; |
| 5790 | m_children ^= Hints; |
| 5791 | return a; |
| 5792 | } |
| 5793 | |
| 5794 | void DomConnection::setElementHints(DomConnectionHints *a) |
| 5795 | { |
| 5796 | delete m_hints; |
| 5797 | m_children |= Hints; |
| 5798 | m_hints = a; |
| 5799 | } |
| 5800 | |
| 5801 | void DomConnection::clearElementSender() |
| 5802 | { |
| 5803 | m_children &= ~Sender; |
| 5804 | } |
| 5805 | |
| 5806 | void DomConnection::clearElementSignal() |
| 5807 | { |
| 5808 | m_children &= ~Signal; |
| 5809 | } |
| 5810 | |
| 5811 | void DomConnection::clearElementReceiver() |
| 5812 | { |
| 5813 | m_children &= ~Receiver; |
| 5814 | } |
| 5815 | |
| 5816 | void DomConnection::clearElementSlot() |
| 5817 | { |
| 5818 | m_children &= ~Slot; |
| 5819 | } |
| 5820 | |
| 5821 | void DomConnection::clearElementHints() |
| 5822 | { |
| 5823 | delete m_hints; |
| 5824 | m_hints = nullptr; |
| 5825 | m_children &= ~Hints; |
| 5826 | } |
| 5827 | |
| 5828 | DomConnectionHints::~DomConnectionHints() |
| 5829 | { |
| 5830 | qDeleteAll(m_hint); |
| 5831 | m_hint.clear(); |
| 5832 | } |
| 5833 | |
| 5834 | void DomConnectionHints::read(QXmlStreamReader &reader) |
| 5835 | { |
| 5836 | while (!reader.hasError()) { |
| 5837 | switch (reader.readNext()) { |
| 5838 | case QXmlStreamReader::StartElement : { |
| 5839 | const auto tag = reader.name(); |
| 5840 | if (!tag.compare(QLatin1String("hint" ), Qt::CaseInsensitive)) { |
| 5841 | auto *v = new DomConnectionHint(); |
| 5842 | v->read(reader); |
| 5843 | m_hint.append(v); |
| 5844 | continue; |
| 5845 | } |
| 5846 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 5847 | } |
| 5848 | break; |
| 5849 | case QXmlStreamReader::EndElement : |
| 5850 | return; |
| 5851 | default : |
| 5852 | break; |
| 5853 | } |
| 5854 | } |
| 5855 | } |
| 5856 | |
| 5857 | void DomConnectionHints::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 5858 | { |
| 5859 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("connectionhints" ) : tagName.toLower()); |
| 5860 | |
| 5861 | for (DomConnectionHint *v : m_hint) |
| 5862 | v->write(writer, QStringLiteral("hint" )); |
| 5863 | |
| 5864 | writer.writeEndElement(); |
| 5865 | } |
| 5866 | |
| 5867 | void DomConnectionHints::setElementHint(const QList<DomConnectionHint *> &a) |
| 5868 | { |
| 5869 | m_children |= Hint; |
| 5870 | m_hint = a; |
| 5871 | } |
| 5872 | |
| 5873 | DomConnectionHint::~DomConnectionHint() = default; |
| 5874 | |
| 5875 | void DomConnectionHint::read(QXmlStreamReader &reader) |
| 5876 | { |
| 5877 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 5878 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 5879 | const auto name = attribute.name(); |
| 5880 | if (name == QLatin1String("type" )) { |
| 5881 | setAttributeType(attribute.value().toString()); |
| 5882 | continue; |
| 5883 | } |
| 5884 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 5885 | } |
| 5886 | |
| 5887 | while (!reader.hasError()) { |
| 5888 | switch (reader.readNext()) { |
| 5889 | case QXmlStreamReader::StartElement : { |
| 5890 | const auto tag = reader.name(); |
| 5891 | if (!tag.compare(QLatin1String("x" ), Qt::CaseInsensitive)) { |
| 5892 | setElementX(reader.readElementText().toInt()); |
| 5893 | continue; |
| 5894 | } |
| 5895 | if (!tag.compare(QLatin1String("y" ), Qt::CaseInsensitive)) { |
| 5896 | setElementY(reader.readElementText().toInt()); |
| 5897 | continue; |
| 5898 | } |
| 5899 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 5900 | } |
| 5901 | break; |
| 5902 | case QXmlStreamReader::EndElement : |
| 5903 | return; |
| 5904 | default : |
| 5905 | break; |
| 5906 | } |
| 5907 | } |
| 5908 | } |
| 5909 | |
| 5910 | void DomConnectionHint::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 5911 | { |
| 5912 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("connectionhint" ) : tagName.toLower()); |
| 5913 | |
| 5914 | if (hasAttributeType()) |
| 5915 | writer.writeAttribute(QStringLiteral("type" ), attributeType()); |
| 5916 | |
| 5917 | if (m_children & X) |
| 5918 | writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x)); |
| 5919 | |
| 5920 | if (m_children & Y) |
| 5921 | writer.writeTextElement(QString(QLatin1Char('y')), QString::number(m_y)); |
| 5922 | |
| 5923 | writer.writeEndElement(); |
| 5924 | } |
| 5925 | |
| 5926 | void DomConnectionHint::setElementX(int a) |
| 5927 | { |
| 5928 | m_children |= X; |
| 5929 | m_x = a; |
| 5930 | } |
| 5931 | |
| 5932 | void DomConnectionHint::setElementY(int a) |
| 5933 | { |
| 5934 | m_children |= Y; |
| 5935 | m_y = a; |
| 5936 | } |
| 5937 | |
| 5938 | void DomConnectionHint::clearElementX() |
| 5939 | { |
| 5940 | m_children &= ~X; |
| 5941 | } |
| 5942 | |
| 5943 | void DomConnectionHint::clearElementY() |
| 5944 | { |
| 5945 | m_children &= ~Y; |
| 5946 | } |
| 5947 | |
| 5948 | DomDesignerData::~DomDesignerData() |
| 5949 | { |
| 5950 | qDeleteAll(m_property); |
| 5951 | m_property.clear(); |
| 5952 | } |
| 5953 | |
| 5954 | void DomDesignerData::read(QXmlStreamReader &reader) |
| 5955 | { |
| 5956 | while (!reader.hasError()) { |
| 5957 | switch (reader.readNext()) { |
| 5958 | case QXmlStreamReader::StartElement : { |
| 5959 | const auto tag = reader.name(); |
| 5960 | if (!tag.compare(QLatin1String("property" ), Qt::CaseInsensitive)) { |
| 5961 | auto *v = new DomProperty(); |
| 5962 | v->read(reader); |
| 5963 | m_property.append(v); |
| 5964 | continue; |
| 5965 | } |
| 5966 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 5967 | } |
| 5968 | break; |
| 5969 | case QXmlStreamReader::EndElement : |
| 5970 | return; |
| 5971 | default : |
| 5972 | break; |
| 5973 | } |
| 5974 | } |
| 5975 | } |
| 5976 | |
| 5977 | void DomDesignerData::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 5978 | { |
| 5979 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("designerdata" ) : tagName.toLower()); |
| 5980 | |
| 5981 | for (DomProperty *v : m_property) |
| 5982 | v->write(writer, QStringLiteral("property" )); |
| 5983 | |
| 5984 | writer.writeEndElement(); |
| 5985 | } |
| 5986 | |
| 5987 | void DomDesignerData::setElementProperty(const QList<DomProperty *> &a) |
| 5988 | { |
| 5989 | m_children |= Property; |
| 5990 | m_property = a; |
| 5991 | } |
| 5992 | |
| 5993 | DomSlots::~DomSlots() |
| 5994 | { |
| 5995 | m_signal.clear(); |
| 5996 | m_slot.clear(); |
| 5997 | } |
| 5998 | |
| 5999 | void DomSlots::read(QXmlStreamReader &reader) |
| 6000 | { |
| 6001 | while (!reader.hasError()) { |
| 6002 | switch (reader.readNext()) { |
| 6003 | case QXmlStreamReader::StartElement : { |
| 6004 | const auto tag = reader.name(); |
| 6005 | if (!tag.compare(QLatin1String("signal" ), Qt::CaseInsensitive)) { |
| 6006 | m_signal.append(reader.readElementText()); |
| 6007 | continue; |
| 6008 | } |
| 6009 | if (!tag.compare(QLatin1String("slot" ), Qt::CaseInsensitive)) { |
| 6010 | m_slot.append(reader.readElementText()); |
| 6011 | continue; |
| 6012 | } |
| 6013 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 6014 | } |
| 6015 | break; |
| 6016 | case QXmlStreamReader::EndElement : |
| 6017 | return; |
| 6018 | default : |
| 6019 | break; |
| 6020 | } |
| 6021 | } |
| 6022 | } |
| 6023 | |
| 6024 | void DomSlots::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 6025 | { |
| 6026 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("slots" ) : tagName.toLower()); |
| 6027 | |
| 6028 | for (const QString &v : m_signal) |
| 6029 | writer.writeTextElement(QStringLiteral("signal" ), v); |
| 6030 | |
| 6031 | for (const QString &v : m_slot) |
| 6032 | writer.writeTextElement(QStringLiteral("slot" ), v); |
| 6033 | |
| 6034 | writer.writeEndElement(); |
| 6035 | } |
| 6036 | |
| 6037 | void DomSlots::setElementSignal(const QStringList &a) |
| 6038 | { |
| 6039 | m_children |= Signal; |
| 6040 | m_signal = a; |
| 6041 | } |
| 6042 | |
| 6043 | void DomSlots::setElementSlot(const QStringList &a) |
| 6044 | { |
| 6045 | m_children |= Slot; |
| 6046 | m_slot = a; |
| 6047 | } |
| 6048 | |
| 6049 | DomPropertySpecifications::~DomPropertySpecifications() |
| 6050 | { |
| 6051 | qDeleteAll(m_tooltip); |
| 6052 | m_tooltip.clear(); |
| 6053 | qDeleteAll(m_stringpropertyspecification); |
| 6054 | m_stringpropertyspecification.clear(); |
| 6055 | } |
| 6056 | |
| 6057 | void DomPropertySpecifications::read(QXmlStreamReader &reader) |
| 6058 | { |
| 6059 | while (!reader.hasError()) { |
| 6060 | switch (reader.readNext()) { |
| 6061 | case QXmlStreamReader::StartElement : { |
| 6062 | const auto tag = reader.name(); |
| 6063 | if (!tag.compare(QLatin1String("tooltip" ), Qt::CaseInsensitive)) { |
| 6064 | auto *v = new DomPropertyToolTip(); |
| 6065 | v->read(reader); |
| 6066 | m_tooltip.append(v); |
| 6067 | continue; |
| 6068 | } |
| 6069 | if (!tag.compare(QLatin1String("stringpropertyspecification" ), Qt::CaseInsensitive)) { |
| 6070 | auto *v = new DomStringPropertySpecification(); |
| 6071 | v->read(reader); |
| 6072 | m_stringpropertyspecification.append(v); |
| 6073 | continue; |
| 6074 | } |
| 6075 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 6076 | } |
| 6077 | break; |
| 6078 | case QXmlStreamReader::EndElement : |
| 6079 | return; |
| 6080 | default : |
| 6081 | break; |
| 6082 | } |
| 6083 | } |
| 6084 | } |
| 6085 | |
| 6086 | void DomPropertySpecifications::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 6087 | { |
| 6088 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("propertyspecifications" ) : tagName.toLower()); |
| 6089 | |
| 6090 | for (DomPropertyToolTip *v : m_tooltip) |
| 6091 | v->write(writer, QStringLiteral("tooltip" )); |
| 6092 | |
| 6093 | for (DomStringPropertySpecification *v : m_stringpropertyspecification) |
| 6094 | v->write(writer, QStringLiteral("stringpropertyspecification" )); |
| 6095 | |
| 6096 | writer.writeEndElement(); |
| 6097 | } |
| 6098 | |
| 6099 | void DomPropertySpecifications::setElementTooltip(const QList<DomPropertyToolTip *> &a) |
| 6100 | { |
| 6101 | m_children |= Tooltip; |
| 6102 | m_tooltip = a; |
| 6103 | } |
| 6104 | |
| 6105 | void DomPropertySpecifications::setElementStringpropertyspecification(const QList<DomStringPropertySpecification *> &a) |
| 6106 | { |
| 6107 | m_children |= Stringpropertyspecification; |
| 6108 | m_stringpropertyspecification = a; |
| 6109 | } |
| 6110 | |
| 6111 | DomPropertyToolTip::~DomPropertyToolTip() = default; |
| 6112 | |
| 6113 | void DomPropertyToolTip::read(QXmlStreamReader &reader) |
| 6114 | { |
| 6115 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 6116 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 6117 | const auto name = attribute.name(); |
| 6118 | if (name == QLatin1String("name" )) { |
| 6119 | setAttributeName(attribute.value().toString()); |
| 6120 | continue; |
| 6121 | } |
| 6122 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 6123 | } |
| 6124 | |
| 6125 | while (!reader.hasError()) { |
| 6126 | switch (reader.readNext()) { |
| 6127 | case QXmlStreamReader::StartElement : { |
| 6128 | const auto tag = reader.name(); |
| 6129 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 6130 | } |
| 6131 | break; |
| 6132 | case QXmlStreamReader::EndElement : |
| 6133 | return; |
| 6134 | default : |
| 6135 | break; |
| 6136 | } |
| 6137 | } |
| 6138 | } |
| 6139 | |
| 6140 | void DomPropertyToolTip::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 6141 | { |
| 6142 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("propertytooltip" ) : tagName.toLower()); |
| 6143 | |
| 6144 | if (hasAttributeName()) |
| 6145 | writer.writeAttribute(QStringLiteral("name" ), attributeName()); |
| 6146 | |
| 6147 | writer.writeEndElement(); |
| 6148 | } |
| 6149 | |
| 6150 | DomStringPropertySpecification::~DomStringPropertySpecification() = default; |
| 6151 | |
| 6152 | void DomStringPropertySpecification::read(QXmlStreamReader &reader) |
| 6153 | { |
| 6154 | const QXmlStreamAttributes &attributes = reader.attributes(); |
| 6155 | for (const QXmlStreamAttribute &attribute : attributes) { |
| 6156 | const auto name = attribute.name(); |
| 6157 | if (name == QLatin1String("name" )) { |
| 6158 | setAttributeName(attribute.value().toString()); |
| 6159 | continue; |
| 6160 | } |
| 6161 | if (name == QLatin1String("type" )) { |
| 6162 | setAttributeType(attribute.value().toString()); |
| 6163 | continue; |
| 6164 | } |
| 6165 | if (name == QLatin1String("notr" )) { |
| 6166 | setAttributeNotr(attribute.value().toString()); |
| 6167 | continue; |
| 6168 | } |
| 6169 | reader.raiseError(QLatin1String("Unexpected attribute " ) + name); |
| 6170 | } |
| 6171 | |
| 6172 | while (!reader.hasError()) { |
| 6173 | switch (reader.readNext()) { |
| 6174 | case QXmlStreamReader::StartElement : { |
| 6175 | const auto tag = reader.name(); |
| 6176 | reader.raiseError(QLatin1String("Unexpected element " ) + tag); |
| 6177 | } |
| 6178 | break; |
| 6179 | case QXmlStreamReader::EndElement : |
| 6180 | return; |
| 6181 | default : |
| 6182 | break; |
| 6183 | } |
| 6184 | } |
| 6185 | } |
| 6186 | |
| 6187 | void DomStringPropertySpecification::write(QXmlStreamWriter &writer, const QString &tagName) const |
| 6188 | { |
| 6189 | writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("stringpropertyspecification" ) : tagName.toLower()); |
| 6190 | |
| 6191 | if (hasAttributeName()) |
| 6192 | writer.writeAttribute(QStringLiteral("name" ), attributeName()); |
| 6193 | |
| 6194 | if (hasAttributeType()) |
| 6195 | writer.writeAttribute(QStringLiteral("type" ), attributeType()); |
| 6196 | |
| 6197 | if (hasAttributeNotr()) |
| 6198 | writer.writeAttribute(QStringLiteral("notr" ), attributeNotr()); |
| 6199 | |
| 6200 | writer.writeEndElement(); |
| 6201 | } |
| 6202 | |
| 6203 | QT_END_NAMESPACE |
| 6204 | |
| 6205 | |