Krita

Preset.cpp
1 /*
2  * SPDX-FileCopyrightText: 2017 Wolthera van Hövell tot Westerflier <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.0-or-later
5  */
6 #include "Preset.h"
7 #include <QDomDocument>
8 
9 struct Preset::Private {
10  KisPaintOpPresetSP preset {0};
11 };
12 
13 Preset::Preset(Resource *resource): d(new Private()) {
14  d->preset = resource->resource().dynamicCast<KisPaintOpPreset>();
15 }
16 
17 Preset::~Preset()
18 {
19  delete d;
20 }
21 
22 
24 {
25  QDomDocument xmlDoc;
26  QDomElement root = xmlDoc.createElement("Preset");
27 
28  d->preset->toXML(xmlDoc,root);
29 
30  xmlDoc.appendChild(root);
31 
32  return xmlDoc.toString();
33 }
34 
35 void Preset::fromXML(const QString &xml)
36 {
37  QDomDocument xmlDoc;
38 
39  if (!xmlDoc.setContent(xml)) {
40  qWarning() << "XML string format is invalid!";
41  return;
42  }
43 
44  d->preset->fromXML(xmlDoc.documentElement(),d->preset->resourcesInterface());
45  d->preset->setDirty(true);
46 }
QString toString(int indent) const const
A Resource represents a gradient, pattern, brush tip, brush preset, palette or workspace definition.
Definition: Resource.h:30
QString toXML() const
toXML convert the preset settings into a preset formatted xml.
Definition: Preset.cpp:23
bool setContent(const QByteArray &data, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn)
QDomElement createElement(const QString &tagName)
QDomElement documentElement() const const
QDomNode appendChild(const QDomNode &newChild)
void fromXML(const QString &xml)
fromXML convert the preset settings into a preset formatted xml.
Definition: Preset.cpp:35
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Dec 4 2022 04:12:55 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.