File indexing completed on 2024-05-12 15:56:50

0001 /* This file is part of the KDE project
0002  * SPDX-FileCopyrightText: 2006 Thomas Zander <zander@kde.org>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 #ifndef KOSHAPEUSERDATA_H
0008 #define KOSHAPEUSERDATA_H
0009 
0010 #include <QObject>
0011 
0012 #include "kritaflake_export.h"
0013 
0014 /**
0015  * The KoShapeUserData class is used to associate custom data with a shape.
0016  *
0017  *  KoShapeUserData provides an abstract interface for container classes
0018  *  that are used to associate application-specific user data with shapes in KoShape
0019  *  Generally, subclasses of this class provide functions to allow data to
0020  *  be stored and retrieved, and instances are attached to KoShape using
0021  *  KoShape::setUserData(). This makes it possible to store additional data per
0022  *  shape in a way that allows applications to not know the implementation of a
0023  *  specific KoShape extending class.
0024  *
0025  *  Each subclass should provide a reimplementation of the destructor to ensure that
0026  *  any private data is automatically cleaned up when user data objects are deleted.
0027  *
0028  *  Please note that this object is a QObject to allow a
0029  *  <code>qobject_cast<MyData*> (shape->userData())</code> to work which is useful in an environment
0030  *  where classes from plugins may not be castable using a static_cast or a dynamic_cast
0031  */
0032 class KRITAFLAKE_EXPORT KoShapeUserData : public QObject
0033 {
0034     Q_OBJECT
0035 public:
0036     /// Constructor
0037     explicit KoShapeUserData(QObject *parent = 0);
0038     ~KoShapeUserData() override;
0039 
0040     virtual KoShapeUserData* clone() const = 0;
0041 
0042 protected:
0043     KoShapeUserData(const KoShapeUserData &rhs);
0044 };
0045 
0046 #endif