contactgroup.h
00001 /* 00002 This file is part of libkabc. 00003 Copyright (c) 2008 Tobias Koenig <tokoe@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef KABC_CONTACTGROUP_H 00022 #define KABC_CONTACTGROUP_H 00023 00024 #include <QtCore/QList> 00025 #include <QtCore/QSharedDataPointer> 00026 #include <QtCore/QMetaType> 00027 00028 #include "kabc_export.h" 00029 00030 class QString; 00031 00032 namespace KABC { 00033 00046 class KABC_EXPORT ContactGroup 00047 { 00048 public: 00049 00053 class KABC_EXPORT ContactReference 00054 { 00055 public: 00059 typedef QList<ContactReference> List; 00060 00064 ContactReference(); 00065 00069 ContactReference( const ContactReference &other ); 00070 00074 ContactReference( const QString &uid ); 00075 00079 ~ContactReference(); 00080 00087 void setUid( const QString &uid ); 00088 00095 QString uid() const; 00096 00100 void setPreferredEmail( const QString &email ); 00101 00106 QString preferredEmail() const; 00107 00116 void insertCustom( const QString &key, const QString &value ); 00117 00121 void removeCustom( const QString &key ); 00122 00127 QString custom( const QString &key ) const; 00128 00132 ContactReference &operator=( const ContactReference & ); 00133 00137 bool operator==( const ContactReference & ) const; 00138 00139 private: 00140 class ContactReferencePrivate; 00141 QSharedDataPointer<ContactReferencePrivate> d; 00142 }; 00143 00147 class KABC_EXPORT ContactGroupReference 00148 { 00149 public: 00153 typedef QList<ContactGroupReference> List; 00154 00158 ContactGroupReference(); 00159 00163 ContactGroupReference( const ContactGroupReference &other ); 00164 00168 ContactGroupReference( const QString &uid ); 00169 00173 ~ContactGroupReference(); 00174 00178 void setUid( const QString &uid ); 00179 00183 QString uid() const; 00184 00193 void insertCustom( const QString &key, const QString &value ); 00194 00198 void removeCustom( const QString &key ); 00199 00204 QString custom( const QString &key ) const; 00205 00209 ContactGroupReference &operator=( const ContactGroupReference & ); 00210 00214 bool operator==( const ContactGroupReference & ) const; 00215 00216 private: 00217 class ContactGroupReferencePrivate; 00218 QSharedDataPointer<ContactGroupReferencePrivate> d; 00219 }; 00220 00224 class KABC_EXPORT Data 00225 { 00226 public: 00230 typedef QList<Data> List; 00231 00235 Data(); 00236 00240 Data( const Data &other ); 00241 00245 Data( const QString &name, const QString &email ); 00246 00250 ~Data(); 00251 00255 void setName( const QString &name ); 00256 00260 QString name() const; 00261 00265 void setEmail( const QString &email ); 00266 00270 QString email() const; 00271 00280 void insertCustom( const QString &key, const QString &value ); 00281 00285 void removeCustom( const QString &key ); 00286 00291 QString custom( const QString &key ) const; 00292 00296 Data &operator=( const Data & ); 00297 00301 bool operator==( const Data & ) const; 00302 00303 private: 00304 class DataPrivate; 00305 QSharedDataPointer<DataPrivate> d; 00306 }; 00307 00311 typedef QList<ContactGroup> List; 00312 00316 ContactGroup(); 00317 00321 ContactGroup( const ContactGroup &other ); 00322 00326 ContactGroup( const QString &name ); 00327 00331 ~ContactGroup(); 00332 00336 void setId( const QString &id ); 00337 00341 QString id() const; 00342 00346 void setName( const QString &name ); 00347 00351 QString name() const; 00352 00357 unsigned int count() const; 00358 00362 unsigned int contactReferenceCount() const; 00363 00367 unsigned int contactGroupReferenceCount() const; 00368 00372 unsigned int dataCount() const; 00373 00377 ContactReference &contactReference( unsigned int index ); 00378 00382 const ContactReference &contactReference( unsigned int index ) const; 00383 00387 ContactGroupReference &contactGroupReference( unsigned int index ); 00388 00392 const ContactGroupReference &contactGroupReference( unsigned int index ) const; 00393 00397 Data &data( unsigned int index ); 00398 00402 const Data &data( unsigned int index ) const; 00403 00407 void append( const ContactReference &reference ); 00408 00412 void append( const ContactGroupReference &reference ); 00413 00417 void append( const Data &data ); 00418 00422 void remove( const ContactReference &reference ); 00423 00427 void remove( const ContactGroupReference &reference ); 00428 00432 void remove( const Data &data ); 00433 00437 void removeAllContactReferences(); 00438 00442 void removeAllContactGroupReferences(); 00443 00447 void removeAllContactData(); 00448 00452 ContactGroup &operator=( const ContactGroup & ); 00453 00457 bool operator==( const ContactGroup & ) const; 00458 00462 static QString mimeType(); 00463 00464 private: 00465 class Private; 00466 QSharedDataPointer<Private> d; 00467 }; 00468 00469 } 00470 00471 #define KABC_CONTACTGROUP_METATYPE_DEFINED 00472 Q_DECLARE_METATYPE( KABC::ContactGroup ) 00473 00474 #endif