Krita Source Code Documentation
Loading...
Searching...
No Matches
KoShapeRegistry Class Reference

#include <KoShapeRegistry.h>

+ Inheritance diagram for KoShapeRegistry:

Public Member Functions

void addFactory (KoShapeFactoryBase *factory)
 
QList< KoShapeFactoryBase * > factoriesForElement (const QString &nameSpace, const QString &elementName)
 
void init (KoShapeRegistry *q)
 
void insertFactory (KoShapeFactoryBase *factory)
 
 KoShapeRegistry ()
 
 ~KoShapeRegistry () override
 
- Public Member Functions inherited from KoGenericRegistry< KoShapeFactoryBase * >
void add (const QString &id, KoShapeFactoryBase * item)
 
void add (KoShapeFactoryBase * item)
 
void addAlias (const QString &alias, const QString &id)
 
QHash< QString, KoShapeFactoryBase * >::const_iterator constBegin () const
 
QHash< QString, KoShapeFactoryBase * >::const_iterator constEnd () const
 
bool contains (const QString &id) const
 
int count () const
 
QList< KoShapeFactoryBase * > doubleEntries () const
 
KoShapeFactoryBaseget (const QString &id) const
 
QList< QString > keys () const
 
 KoGenericRegistry ()
 
void remove (const QString &id)
 
void removeAlias (const QString &alias)
 
const KoShapeFactoryBasevalue (const QString &id) const
 
QList< KoShapeFactoryBase * > values () const
 
virtual ~KoGenericRegistry ()
 

Static Public Member Functions

static KoShapeRegistryinstance ()
 

Public Attributes

QHash< QPair< QString, QString >, QMultiMap< int, KoShapeFactoryBase * > > factoryMap
 

Private Member Functions

 KoShapeRegistry (const KoShapeRegistry &)
 
KoShapeRegistry operator= (const KoShapeRegistry &)
 
- Private Member Functions inherited from Private
 Private (KisCanvas2 *c)
 

Private Attributes

Private *const d
 
- Private Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 

Detailed Description

This singleton class keeps a register of all available flake shapes, or rather, of the factories that applications can use to create flake shape objects.

Definition at line 34 of file KoShapeRegistry.cpp.

Constructor & Destructor Documentation

◆ KoShapeRegistry() [1/2]

KoShapeRegistry::KoShapeRegistry ( )

Definition at line 44 of file KoShapeRegistry.cpp.

45 : d(new Private())
46{
47}
Private *const d

◆ ~KoShapeRegistry()

KoShapeRegistry::~KoShapeRegistry ( )
override

Definition at line 49 of file KoShapeRegistry.cpp.

50{
51 qDeleteAll(doubleEntries());
52 qDeleteAll(values());
53 delete d;
54}
QList< KoShapeFactoryBase * > doubleEntries() const
QList< KoShapeFactoryBase * > values() const

References d, KoGenericRegistry< KoShapeFactoryBase * >::doubleEntries(), and KoGenericRegistry< KoShapeFactoryBase * >::values().

◆ KoShapeRegistry() [2/2]

KoShapeRegistry::KoShapeRegistry ( const KoShapeRegistry & )
private

Member Function Documentation

◆ addFactory()

void KoShapeRegistry::addFactory ( KoShapeFactoryBase * factory)

Add shape factory for a shape that is not a plugin This can be used also if you want to have a shape only in one application

Parameters
factoryThe factory of the shape

Definition at line 89 of file KoShapeRegistry.cpp.

90{
91 add(factory);
92 d->insertFactory(factory);
93}
void add(KoShapeFactoryBase * item)

References KoGenericRegistry< KoShapeFactoryBase * >::add(), and d.

◆ factoriesForElement()

QList< KoShapeFactoryBase * > KoShapeRegistry::factoriesForElement ( const QString & nameSpace,
const QString & elementName )

Returns a list of shape factories supporting the specified xml element.

Parameters
nameSpacethe namespace of the xml element, see KoXmlNS for valid namespaces
elementNamethe tag name of the element
Returns
the list of shape factories supporting the specified xml element

Definition at line 129 of file KoShapeRegistry.cpp.

130{
131 // Pair of namespace, tagname
132 QPair<QString, QString> p = QPair<QString, QString>(nameSpace, elementName);
133
134 QMultiMap<int, KoShapeFactoryBase*> priorityMap = d->factoryMap.value(p);
135 QList<KoShapeFactoryBase*> shapeFactories;
136 // sort list by priority
137 Q_FOREACH (KoShapeFactoryBase *f, priorityMap.values()) {
138 shapeFactories.prepend(f);
139 }
140
141 return shapeFactories;
142}
const Params2D p

References d, and p.

◆ init()

void KoShapeRegistry::init ( KoShapeRegistry * q)

◆ insertFactory()

void KoShapeRegistry::insertFactory ( KoShapeFactoryBase * factory)

◆ instance()

KoShapeRegistry * KoShapeRegistry::instance ( )
static

Return an instance of the KoShapeRegistry Creates an instance if that has never happened before and returns the singleton instance.

Definition at line 81 of file KoShapeRegistry.cpp.

82{
83 if (!s_instance.exists()) {
84 s_instance->d->init(s_instance);
85 }
86 return s_instance;
87}

References d.

◆ operator=()

KoShapeRegistry KoShapeRegistry::operator= ( const KoShapeRegistry & )
private

Member Data Documentation

◆ d

Private* const KoShapeRegistry::d
private

Definition at line 59 of file KoShapeRegistry.h.

◆ factoryMap

QHash<QPair<QString, QString>, QMultiMap<int, KoShapeFactoryBase*> > KoShapeRegistry::factoryMap

Definition at line 41 of file KoShapeRegistry.cpp.


The documentation for this class was generated from the following files: