Krita Source Code Documentation
Loading...
Searching...
No Matches
InfoObject.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016 Boudewijn Rempt <boud@valdyas.org>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6#include "InfoObject.h"
7
9
15
17 : QObject(0)
18 , d(new Private)
19{
21}
22
23InfoObject::InfoObject(QObject *parent)
24 : QObject(parent)
25 , d(new Private)
26{
28}
29
31{
32 delete d;
33}
34
35bool InfoObject::operator==(const InfoObject &other) const
36{
37 return (d->properties == other.d->properties);
38}
39
40bool InfoObject::operator!=(const InfoObject &other) const
41{
42 return !(operator==(other));
43}
44
45QMap<QString, QVariant> InfoObject::properties() const
46{
47 QMap<QString, QVariant> map = d->properties->getProperties();
48
49 for (const QString &key : map.keys()) {
50 QVariant v = map.value(key);
51
52 if (v.isValid() && v.type() == QVariant::UserType && v.userType() == qMetaTypeId<KoColor>()) {
53 map[key] = QVariant::fromValue(v.value<KoColor>().toXML());
54 }
55 }
56
57 return map;
58}
59
60void InfoObject::setProperties(QMap<QString, QVariant> propertyMap)
61{
62 Q_FOREACH(const QString & key, propertyMap.keys()) {
63 d->properties->setProperty(key, propertyMap[key]);
64 }
65}
66
67void InfoObject::setProperty(const QString &key, QVariant value)
68{
69 d->properties->setProperty(key, value);
70}
71
72QVariant InfoObject::property(const QString &key)
73{
74 QVariant v;
75 if (d->properties->hasProperty(key)) {
76 d->properties->getProperty(key, v);
77
78 if (v.isValid() && v.type() == QVariant::UserType && v.userType() == qMetaTypeId<KoColor>()) {
79 return QVariant::fromValue(v.value<KoColor>().toXML());
80 }
81 }
82
83 return v;
84}
85
90
91
float value(const T *src, size_t ch)
qreal v
bool operator!=(const InfoObject &other) const
void setProperty(const QString &key, QVariant value)
QVariant property(const QString &key)
InfoObject(KisPropertiesConfigurationSP configuration)
Private * d
Definition InfoObject.h:72
~InfoObject() override
QMap< QString, QVariant > properties() const
KisPropertiesConfigurationSP configuration() const
configuration gives access to the internal configuration object. Must be used internally in libkis
void setProperties(QMap< QString, QVariant > propertyMap)
bool operator==(const InfoObject &other) const
void toXML(QDomDocument &doc, QDomElement &colorElt) const
Definition KoColor.cpp:304
KisPropertiesConfigurationSP properties