addresseelist.h
00001 /* 00002 This file is part of libkabc. 00003 Copyright (c) 2002 Jost Schenck <jost@schenck.de> 00004 2003 Tobias Koenig <tokoe@kde.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #ifndef KABC_ADDRESSEELIST_H 00023 #define KABC_ADDRESSEELIST_H 00024 00025 #include "kabc_export.h" 00026 #include <QtCore/QSharedDataPointer> 00027 #include <QtCore/QList> 00028 00029 namespace KABC { 00030 00031 class Field; 00032 class SortMode; 00033 class Addressee; 00034 00044 namespace SortingTraits 00045 { 00046 00047 class KABC_EXPORT Uid 00048 { 00049 public: 00053 Uid(); 00054 00058 ~Uid(); 00059 00069 static bool eq( const Addressee &, const Addressee & ); 00070 00080 static bool lt( const Addressee &, const Addressee & ); 00081 00082 private: 00083 class Private; 00084 Private *const d; 00085 }; 00086 00087 class KABC_EXPORT Name 00088 { 00089 public: 00093 Name(); 00094 00098 ~Name(); 00099 00109 static bool eq( const Addressee &, const Addressee & ); 00110 00120 static bool lt( const Addressee &, const Addressee & ); 00121 00122 private: 00123 class Private; 00124 Private *const d; 00125 }; 00126 00127 class KABC_EXPORT FormattedName 00128 { 00129 public: 00133 FormattedName(); 00134 00138 ~FormattedName(); 00139 00149 static bool eq( const Addressee &, const Addressee & ); 00150 00160 static bool lt( const Addressee &, const Addressee & ); 00161 00162 private: 00163 class Private; 00164 Private *const d; 00165 }; 00166 00167 class KABC_EXPORT FamilyName // fallback to given name 00168 { 00169 public: 00173 FamilyName(); 00174 00178 ~FamilyName(); 00179 00190 static bool eq( const Addressee &, const Addressee & ); 00191 00203 static bool lt( const Addressee &, const Addressee & ); 00204 00205 private: 00206 class Private; 00207 Private *const d; 00208 }; 00209 00210 class KABC_EXPORT GivenName // fallback to family name 00211 { 00212 public: 00216 GivenName(); 00217 00221 ~GivenName(); 00222 00233 static bool eq( const Addressee &, const Addressee & ); 00234 00246 static bool lt( const Addressee &, const Addressee & ); 00247 00248 private: 00249 class Private; 00250 Private *const d; 00251 }; 00252 00253 } 00254 00258 typedef enum { 00259 Uid, 00260 Name, 00261 FormattedName, 00262 FamilyName, 00263 GivenName 00264 } SortingCriterion; 00265 00289 class KABC_EXPORT AddresseeList : public QList<Addressee> 00290 { 00291 public: 00295 AddresseeList(); 00296 00300 AddresseeList( const AddresseeList & ); 00301 00305 AddresseeList( const QList<Addressee> & ); 00306 00310 ~AddresseeList(); 00311 00318 AddresseeList &operator=( const AddresseeList &other ); 00319 00326 void setReverseSorting( bool reverseSorting = true ); 00327 00332 bool reverseSorting() const; 00333 00338 void sortBy( SortingCriterion c ); 00339 00345 void sortByField( Field *field = 0 ); 00346 00351 void sortByMode( SortMode *mode = 0 ); 00352 00362 void sort(); 00363 00391 template<class Trait> void sortByTrait(); 00392 00397 SortingCriterion sortingCriterion() const; 00398 00406 Field *sortingField() const; 00407 00411 QString toString() const; 00412 00413 private: 00414 class Private; 00415 QSharedDataPointer<Private> d; 00416 }; 00417 00418 } 00419 00420 #endif