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" 
   32 #include <QtCore/QHash> 
   34 using namespace Akonadi;
 
   45     explicit DefaultAttribute( 
const QByteArray &type, 
const QByteArray &value = QByteArray() ) :
 
   50     QByteArray type()
 const { 
return mType; }
 
   53       return new DefaultAttribute( mType, mValue );
 
   56     QByteArray serialized()
 const { 
return mValue; }
 
   57     void deserialize( 
const QByteArray &data ) { mValue = data; }
 
   60     QByteArray mType, mValue;
 
   77       AttributeFactory::registerAttribute<CollectionQuotaAttribute>();
 
   78       AttributeFactory::registerAttribute<CollectionRightsAttribute>();
 
   79       AttributeFactory::registerAttribute<EntityDisplayAttribute>();
 
   80       AttributeFactory::registerAttribute<EntityHiddenAttribute>();
 
   81       AttributeFactory::registerAttribute<IndexPolicyAttribute>();
 
   82       AttributeFactory::registerAttribute<PersistentSearchAttribute>();
 
   83       AttributeFactory::registerAttribute<EntityDeletedAttribute>();
 
   88 K_GLOBAL_STATIC( StaticAttributeFactory, s_attributeInstance )
 
   92 using Akonadi::Internal::s_attributeInstance;
 
   97 class AttributeFactory::Private
 
  100     QHash<QByteArray, Attribute*> attributes;
 
  105   s_attributeInstance->init();
 
  106   return s_attributeInstance;
 
  109 AttributeFactory::AttributeFactory()
 
  114 AttributeFactory::~ AttributeFactory()
 
  116   qDeleteAll( d->attributes );
 
  123   Q_ASSERT( !attr->
type().contains( 
' ' ) && !attr->
type().contains( 
'\'' ) && !attr->
type().contains( 
'"' ) );
 
  124   QHash<QByteArray, Attribute*>::Iterator it = d->attributes.find( attr->
type() );
 
  125   if ( it != d->attributes.end() ) {
 
  127     d->attributes.erase( it );
 
  129   d->attributes.insert( attr->
type(), attr );
 
  134   Attribute *attr = 
self()->d->attributes.value( type );
 
  136     return attr->
clone();
 
  138   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. 
 
static Attribute * createAttribute(const QByteArray &type)
Creates an entity attribute object of the given type. 
 
virtual Attribute * clone() const =0
Creates a copy of this attribute. 
 
virtual QByteArray type() const =0
Returns the type of the attribute.