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 <qvaluelist.h>
00026 
00027 #include "addressee.h"
00028 
00029 namespace KABC {
00030 
00031 class Field;
00032 class SortField;
00033 class SortMode;
00034 
00044 namespace SortingTraits
00045 {
00046 
00047 class KABC_EXPORT Uid
00048 {
00049   public:
00050     static bool eq( const Addressee &, const Addressee & );
00051     static bool lt( const Addressee &, const Addressee & );
00052 };
00053 
00054 class KABC_EXPORT Name
00055 {
00056   public:
00057     static bool eq( const Addressee &, const Addressee & );
00058     static bool lt( const Addressee &, const Addressee & );
00059 };
00060 
00061 class KABC_EXPORT FormattedName
00062 {
00063   public:
00064     static bool eq( const Addressee &, const Addressee & );
00065     static bool lt( const Addressee &, const Addressee & );
00066 };
00067 
00068 class KABC_EXPORT FamilyName // fallback to given name
00069 {
00070   public:
00071     static bool eq( const Addressee &, const Addressee & );
00072     static bool lt( const Addressee &, const Addressee & );
00073 };
00074 
00075 class KABC_EXPORT GivenName  // fallback to family name
00076 {
00077   public:
00078     static bool eq( const Addressee &, const Addressee & );
00079     static bool lt( const Addressee &, const Addressee & );
00080 };
00081 
00082 }
00083 
00087 typedef enum { Uid, Name, FormattedName, FamilyName, GivenName } SortingCriterion;
00088 
00112 class KABC_EXPORT AddresseeList : public QValueList<Addressee>
00113 {
00114   public:
00115     AddresseeList();
00116     ~AddresseeList();
00117     AddresseeList( const AddresseeList & );
00118     AddresseeList( const QValueList<Addressee> & );
00119 
00123     void dump() const;
00124 
00130     void setReverseSorting( bool r = true ) { mReverseSorting = r; }
00131 
00136     bool reverseSorting() const { return mReverseSorting; }
00137 
00142     void sortBy( SortingCriterion c );
00143 
00149     void sortByField( Field *field = 0 );
00150 
00156     void sortByMode( SortMode *mode = 0 );
00157 
00167     void sort();
00168 
00196     template<class Trait> void sortByTrait();
00197 
00202     SortingCriterion sortingCriterion() const { return mActiveSortingCriterion; }
00203 
00211     Field* sortingField() const;
00212 
00213   private:
00214     bool mReverseSorting;
00215     SortingCriterion mActiveSortingCriterion;
00216     //KDE 4.0 - add a d-pointer here!
00217 };
00218 
00219 }
00220 
00221 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys