20 #include "attributefactory.h"
22 #include "collectionquotaattribute.h"
23 #include "collectionrightsattribute_p.h"
24 #include "entitydisplayattribute.h"
25 #include "entityhiddenattribute.h"
26 #include "indexpolicyattribute.h"
27 #include "persistentsearchattribute.h"
28 #include "entitydeletedattribute.h"
29 #include "tagattribute.h"
30 #include "entityannotationsattribute.h"
34 #include <QtCore/QHash>
36 using namespace Akonadi;
58 return new DefaultAttribute(mType, mValue);
80 StaticAttributeFactory()
82 , initialized(false) {}
90 AttributeFactory::registerAttribute<CollectionQuotaAttribute>();
91 AttributeFactory::registerAttribute<CollectionRightsAttribute>();
92 AttributeFactory::registerAttribute<EntityDisplayAttribute>();
93 AttributeFactory::registerAttribute<EntityHiddenAttribute>();
94 AttributeFactory::registerAttribute<IndexPolicyAttribute>();
95 AttributeFactory::registerAttribute<PersistentSearchAttribute>();
96 AttributeFactory::registerAttribute<EntityDeletedAttribute>();
97 AttributeFactory::registerAttribute<EntityAnnotationsAttribute>();
98 AttributeFactory::registerAttribute<TagAttribute>();
103 K_GLOBAL_STATIC(StaticAttributeFactory, s_attributeInstance)
107 using Akonadi::Internal::s_attributeInstance;
112 class AttributeFactory::Private
120 s_attributeInstance->init();
121 return s_attributeInstance;
124 AttributeFactory::AttributeFactory()
129 AttributeFactory::~ AttributeFactory()
131 qDeleteAll(d->attributes);
140 if (it != d->attributes.end()) {
142 d->attributes.erase(it);
144 d->attributes.insert(attr->
type(), attr);
149 Attribute *attr =
self()->d->attributes.value(type);
151 return attr->
clone();
153 return new Internal::DefaultAttribute(type);
Provides the functionality of registering and creating arbitrary entity attributes.
Provides interface for custom attributes for Entity.
static void registerAttribute()
Registers a custom attribute of type T.
iterator find(const Key &key)
static Attribute * createAttribute(const QByteArray &type)
Creates an entity attribute object of the given type.
bool contains(char ch) const
virtual Attribute * clone() const =0
Creates a copy of this attribute.
virtual QByteArray type() const =0
Returns the type of the attribute.