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

0001 /*
0002  *  SPDX-FileCopyrightText: 2016 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef __KO_RESOURCE_UPDATE_MEDIATOR_H
0008 #define __KO_RESOURCE_UPDATE_MEDIATOR_H
0009 
0010 #include <QScopedPointer>
0011 #include <QSharedPointer>
0012 #include "kritaflake_export.h"
0013 
0014 /**
0015  * A special mediator class that connects the resource and the
0016  * resource manager.  The resource manager connects to a
0017  * sigResourceChanged() changed and when a resource changes, the
0018  * manager calls connectResource() for this resource. After that, the
0019  * mediator should notify the manager about every change that happens
0020  * to the resource by emitting the corresponding signal.
0021  *
0022  * There is only one mediator for one type (key) of the resource.
0023  */
0024 
0025 class KRITAFLAKE_EXPORT KoResourceUpdateMediator : public QObject
0026 {
0027     Q_OBJECT
0028 public:
0029     KoResourceUpdateMediator(int key);
0030     ~KoResourceUpdateMediator() override;
0031 
0032     int key() const;
0033     virtual void connectResource(QVariant sourceResource) = 0;
0034 
0035 Q_SIGNALS:
0036     void sigResourceChanged(int key);
0037 
0038 private:
0039     struct Private;
0040     const QScopedPointer<Private> m_d;
0041 };
0042 
0043 typedef QSharedPointer<KoResourceUpdateMediator> KoResourceUpdateMediatorSP;
0044 
0045 #endif /* __KO_RESOURCE_UPDATE_MEDIATOR_H */