Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_properties_configuration.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006 Boudewijn Rempt <boud@valdyas.org>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6#ifndef _KIS_PROPERTIES_CONFIGURATION_H_
7#define _KIS_PROPERTIES_CONFIGURATION_H_
8
9#include <QString>
10#include <QMap>
11#include <QVariant>
12#include <kis_debug.h>
13#include <kis_cubic_curve.h>
14#include <KoColor.h>
15
16class QDomElement;
17class QDomDocument;
18
20#include "kritaimage_export.h"
21#include "kis_types.h"
22
23
31class KRITAIMAGE_EXPORT KisPropertiesConfiguration : public KisSerializableConfiguration
32{
33
34public:
35
41
46
51
52public:
53
54
62 bool fromXML(const QString& xml, bool clear = true) override;
63
70 void fromXML(const QDomElement&) override;
71
76 void toXML(QDomDocument&, QDomElement&) const override;
77
82 QString toXML() const override;
83
87 virtual bool hasProperty(const QString& name) const;
88
92 virtual void setProperty(const QString & name, const QVariant & value);
93
101 virtual bool getProperty(const QString & name, QVariant & value) const;
102
103 virtual QVariant getProperty(const QString & name) const;
104
105 template <typename T>
106 T getPropertyLazy(const QString & name, const T &defaultValue) const {
107 QVariant value = getProperty(name);
108 return value.isValid() ? value.value<T>() : defaultValue;
109 }
110
111 QString getPropertyLazy(const QString & name, const char *defaultValue) const {
112 return getPropertyLazy(name, QString(defaultValue));
113 }
114
115 int getInt(const QString & name, int def = 0) const;
116
117 double getDouble(const QString & name, double def = 0.0) const;
118
119 float getFloat(const QString& name, float def = 0.0) const;
120
121 bool getBool(const QString & name, bool def = false) const;
122
123 QString getString(const QString & name, const QString & def = QString()) const;
124
125 KisCubicCurve getCubicCurve(const QString & name, const KisCubicCurve & curve = KisCubicCurve()) const;
126
144 KoColor getColor(const QString& name, const KoColor& color = KoColor()) const;
145
146 virtual QMap<QString, QVariant> getProperties() const;
147
149 void clearProperties();
150
152 void setPropertyNotSaved(const QString & name);
153
154 void removeProperty(const QString & name);
155
159 virtual QList<QString> getPropertiesKeys() const;
160
165 void getPrefixedProperties(const QString &prefix, KisPropertiesConfiguration *config) const;
166
170 void getPrefixedProperties(const QString &prefix, KisPropertiesConfigurationSP config) const;
171
176 void setPrefixedProperties(const QString &prefix, const KisPropertiesConfiguration *config);
177
181 void setPrefixedProperties(const QString &prefix, const KisPropertiesConfigurationSP config);
182
188 static QString extractedPrefixKey();
189
190 static QString escapeString(const QString &string);
191 static QString unescapeString(const QString &string);
192
193 void setProperty(const QString &name, const QStringList &value);
194 QStringList getStringList(const QString &name, const QStringList &defaultValue = QStringList()) const;
195 QStringList getPropertyLazy(const QString &name, const QStringList &defaultValue) const;
196
200 virtual bool compareTo(const KisPropertiesConfiguration* rhs) const;
201
202public:
203
204 virtual void dump() const;
205
206private:
207
208 struct Private;
209 Private* const d;
210};
211
213{
214public:
217 KisSerializableConfigurationSP createDefault() override;
218 KisSerializableConfigurationSP create(const QDomElement& e) override;
219private:
220 struct Private;
221 Private* const d;
222};
223
224#endif
float value(const T *src, size_t ch)
QList< QString > QStringList
virtual bool fromXML(const QString &, bool)
KisShared & operator=(const KisShared &)
QString getPropertyLazy(const QString &name, const char *defaultValue) const
T getPropertyLazy(const QString &name, const T &defaultValue) const