Krita Source Code Documentation
Loading...
Searching...
No Matches
KoResourceManager_p.h
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2006, 2011 Boudewijn Rempt (boud@valdyas.org)
3 SPDX-FileCopyrightText: 2007, 2009, 2010 Thomas Zander <zander@kde.org>
4 SPDX-FileCopyrightText: 2008 Carlos Licea <carlos.licea@kdemail.net>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8#ifndef KO_RESOURCEMANAGER_P_H
9#define KO_RESOURCEMANAGER_P_H
10
11#include <QObject>
12#include <QSizeF>
13#include <QHash>
14
15#include "kritaflake_export.h"
16#include <KoColor.h>
17#include <KoUnit.h>
22
23class KoShape;
24class QVariant;
25
32class KRITAFLAKE_EXPORT KoResourceManager : public QObject
33{
34 Q_OBJECT
35public:
36
38
45 void setResource(int key, const QVariant &value);
46
53 void setResource(int key, const KoColor &color);
54
61 void setResource(int key, KoShape *shape);
62
69 void setResource(int key, const KoUnit &unit);
70
77 QVariant resource(int key) const;
78
84 bool boolResource(int key) const;
85
91 int intResource(int key) const;
92
98 KoColor koColorResource(int key) const;
99
105 KoShape *koShapeResource(int key) const;
106
112 QString stringResource(int key) const;
113
119 QSizeF sizeResource(int key) const;
120
126 KoUnit unitResource(int key) const;
127
133 bool hasResource(int key) const;
134
140 void clearResource(int key);
141
153 void addDerivedResourceConverter(KoDerivedResourceConverterSP converter);
154
161 bool hasDerivedResourceConverter(int key);
162
169 void removeDerivedResourceConverter(int key);
170
179 void addResourceUpdateMediator(KoResourceUpdateMediatorSP mediator);
180
184 bool hasResourceUpdateMediator(int key);
185
189 void removeResourceUpdateMediator(int key);
190
196 void addActiveCanvasResourceDependency(KoActiveCanvasResourceDependencySP dep);
197
203 bool hasActiveCanvasResourceDependency(int sourceKey, int targetKey) const;
204
210 void removeActiveCanvasResourceDependency(int sourceKey, int targetKey);
211
217 bool hasAbstractResource(int key);
218
224 void removeAbstractResource(int key);
225
231 void setAbstractResource(KoAbstractCanvasResourceInterfaceSP resource);
232
233Q_SIGNALS:
234 void resourceChanged(int key, const QVariant &value);
235 void resourceChangeAttempted(int key, const QVariant &value);
236
237private:
238 void notifyResourceChanged(int key, const QVariant &value);
239 void notifyDerivedResourcesChanged(int key, const QVariant &value);
240
241 void notifyResourceChangeAttempted(int key, const QVariant &value);
242 void notifyDerivedResourcesChangeAttempted(int key, const QVariant &value);
243
244 void notifyDependenciesAboutTargetChange(int targetKey, const QVariant &value);
245
246private Q_SLOTS:
247 void slotResourceInternalsChanged(int key);
248 void slotAbstractResourceChangedExternal(int key, const QVariant &value);
249
250private:
253
254 QHash<int, QVariant> m_resources;
255
256 QHash<int, KoDerivedResourceConverterSP> m_derivedResources;
257 QMultiHash<int, KoDerivedResourceConverterSP> m_derivedFromSource;
258
259 QMultiHash<int, KoActiveCanvasResourceDependencySP> m_dependencyFromSource;
260 QMultiHash<int, KoActiveCanvasResourceDependencySP> m_dependencyFromTarget;
261
262 QHash<int, KoResourceUpdateMediatorSP> m_updateMediators;
263 QHash<int, KoAbstractCanvasResourceInterfaceSP> m_abstractResources;
264};
265
266#endif
267
float value(const T *src, size_t ch)
The KoResourceManager class provides access to the currently active resources for a given canvas....
QMultiHash< int, KoActiveCanvasResourceDependencySP > m_dependencyFromSource
QHash< int, KoDerivedResourceConverterSP > m_derivedResources
void resourceChangeAttempted(int key, const QVariant &value)
KoResourceManager(const KoResourceManager &)
QHash< int, QVariant > m_resources
QMultiHash< int, KoDerivedResourceConverterSP > m_derivedFromSource
QMultiHash< int, KoActiveCanvasResourceDependencySP > m_dependencyFromTarget
QHash< int, KoAbstractCanvasResourceInterfaceSP > m_abstractResources
void resourceChanged(int key, const QVariant &value)
KoResourceManager & operator=(const KoResourceManager &)
QHash< int, KoResourceUpdateMediatorSP > m_updateMediators