22 #include "contactgroup.h"
24 #include <QtCore/QMap>
25 #include <QtCore/QSharedData>
26 #include <QtCore/QString>
27 #include <QtCore/QUuid>
31 class ContactGroup::ContactReference::ContactReferencePrivate :
public QSharedData
34 ContactReferencePrivate()
39 ContactReferencePrivate(
const ContactReferencePrivate &other )
40 : QSharedData( other )
43 mPreferredEmail = other.mPreferredEmail;
44 mCustoms = other.mCustoms;
48 QString mPreferredEmail;
49 QMap<QString, QString> mCustoms;
53 : d( new ContactReferencePrivate )
63 : d( new ContactReferencePrivate )
84 d->mPreferredEmail = email;
89 return d->mPreferredEmail;
94 d->mCustoms.insert( key, value );
99 d->mCustoms.remove( key );
104 return d->mCustoms.value( key );
110 if (
this != &other ) {
119 return d->mUid == other.d->mUid &&
120 d->mPreferredEmail == other.d->mPreferredEmail &&
121 d->mCustoms == other.d->mCustoms;
124 class ContactGroup::ContactGroupReference::ContactGroupReferencePrivate :
public QSharedData
127 ContactGroupReferencePrivate()
132 ContactGroupReferencePrivate(
const ContactGroupReferencePrivate &other )
133 : QSharedData( other )
136 mCustoms = other.mCustoms;
140 QMap<QString, QString> mCustoms;
144 : d( new ContactGroupReferencePrivate )
154 : d( new ContactGroupReferencePrivate )
175 d->mCustoms.insert( key, value );
180 d->mCustoms.remove( key );
185 return d->mCustoms.value( key );
191 if (
this != &other ) {
200 return d->mUid == other.d->mUid &&
201 d->mCustoms == other.d->mCustoms;
204 class ContactGroup::Data::DataPrivate :
public QSharedData
212 DataPrivate(
const DataPrivate &other )
213 : QSharedData( other )
216 mEmail = other.mEmail;
217 mCustoms = other.mCustoms;
222 QMap<QString, QString> mCustoms;
226 : d( new DataPrivate )
236 : d( new DataPrivate )
268 d->mCustoms.insert( key, value );
273 d->mCustoms.remove( key );
278 return d->mCustoms.value( key );
283 if (
this != &other ) {
292 return d->mName == other.d->mName &&
293 d->mEmail == other.d->mEmail &&
294 d->mCustoms == other.d->mCustoms;
297 class ContactGroup::Private :
public QSharedData
302 mIdentifier( QUuid::createUuid().toString() )
306 Private(
const Private &other )
307 : QSharedData( other )
309 mIdentifier = other.mIdentifier;
311 mContactReferences = other.mContactReferences;
312 mContactGroupReferences = other.mContactGroupReferences;
313 mDataObjects = other.mDataObjects;
360 return d->mIdentifier;
365 return d->mContactReferences.count() + d->mDataObjects.count();
370 return d->mContactReferences.count();
375 return d->mContactGroupReferences.count();
380 return d->mDataObjects.count();
385 Q_ASSERT_X( index < (
unsigned int)d->mContactReferences.count(),
386 "contactReference()",
"index out of range" );
388 return d->mContactReferences[ index ];
393 Q_ASSERT_X( index < (
unsigned int)d->mContactReferences.count(),
394 "contactReference()",
"index out of range" );
396 return d->mContactReferences[ index ];
401 Q_ASSERT_X( index < (
unsigned int)d->mContactGroupReferences.count(),
402 "contactGroupReference()",
"index out of range" );
404 return d->mContactGroupReferences[ index ];
408 unsigned int index )
const
410 Q_ASSERT_X( index < (
unsigned int)d->mContactGroupReferences.count(),
411 "contactGroupReference()",
"index out of range" );
413 return d->mContactGroupReferences[ index ];
418 Q_ASSERT_X( index < (
unsigned int)d->mDataObjects.count(),
"data()",
"index out of range" );
420 return d->mDataObjects[ index ];
425 Q_ASSERT_X( index < (
unsigned int)d->mDataObjects.count(),
"data()",
"index out of range" );
427 return d->mDataObjects[ index ];
432 d->mContactReferences.append( reference );
437 d->mContactGroupReferences.append( reference );
442 d->mDataObjects.append( data );
447 d->mContactReferences.removeOne( reference );
452 d->mContactGroupReferences.removeOne( reference );
457 d->mDataObjects.removeOne( data );
462 d->mContactReferences.clear();
467 d->mContactGroupReferences.clear();
472 d->mDataObjects.clear();
477 if (
this != &other ) {
486 return d->mIdentifier == other.d->mIdentifier &&
487 d->mName == other.d->mName &&
488 d->mContactReferences == other.d->mContactReferences &&
489 d->mContactGroupReferences == other.d->mContactGroupReferences &&
490 d->mDataObjects == other.d->mDataObjects;
495 return QLatin1String(
"application/x-vnd.kde.contactgroup" );