File indexing completed on 2024-05-12 15:59:05

0001 /*
0002  *  SPDX-FileCopyrightText: 2016 Boudewijn Rempt <boud@valdyas.org>
0003  *
0004  *  SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 #ifndef LIBKIS_INFOOBJECT_H
0007 #define LIBKIS_INFOOBJECT_H
0008 
0009 #include <QObject>
0010 #include <kis_properties_configuration.h>
0011 
0012 #include "kritalibkis_export.h"
0013 #include "libkis.h"
0014 
0015 /**
0016  * InfoObject wrap a properties map. These maps can be used to set the
0017  * configuration for filters.
0018  */
0019 class KRITALIBKIS_EXPORT InfoObject : public QObject
0020 {
0021     Q_OBJECT
0022 
0023 public:
0024     InfoObject(KisPropertiesConfigurationSP configuration);
0025 
0026     /**
0027      * Create a new, empty InfoObject.
0028      */
0029     explicit InfoObject(QObject *parent = 0);
0030     ~InfoObject() override;
0031 
0032     bool operator==(const InfoObject &other) const;
0033     bool operator!=(const InfoObject &other) const;
0034     /**
0035      * Return all properties this InfoObject manages.
0036      */
0037     QMap<QString, QVariant> properties() const;
0038 
0039     /**
0040      * Add all properties in the @p propertyMap to this InfoObject
0041      */
0042     void setProperties(QMap<QString, QVariant> propertyMap);
0043 
0044 public Q_SLOTS:
0045     /**
0046      * set the property identified by @p key to @p value
0047      *
0048      * If you want create a property that represents a color, you can use a QColor
0049      * or hex string, as defined in https://doc.qt.io/qt-5/qcolor.html#setNamedColor.
0050      *
0051      */
0052     void setProperty(const QString &key, QVariant value);
0053 
0054     /**
0055      * return the value for the property identified by key, or None if there is no such key.
0056      */
0057     QVariant property(const QString &key);
0058 
0059 private:
0060 
0061     friend class Filter;
0062     friend class Document;
0063     friend class Node;
0064     /**
0065      * @brief configuration gives access to the internal configuration object. Must
0066      * be used used internally in libkis
0067      * @return the internal configuration object.
0068      */
0069     KisPropertiesConfigurationSP configuration() const;
0070 
0071     struct Private;
0072     Private *d;
0073 
0074 };
0075 
0076 #endif // LIBKIS_INFOOBJECT_H