24 #include "addresseelist.h"
40 return ( TQString::compare( a1.
uid(), a2.
uid() ) == 0 );
46 return ( TQString::compare( a1.
uid(), a2.
uid() ) < 0 );
51 return ( TQString::localeAwareCompare( a1.name(), a2.name() ) == 0 );
56 return ( TQString::localeAwareCompare( a1.name(), a2.name() ) < 0 );
61 return ( TQString::localeAwareCompare( a1.formattedName(), a2.formattedName() ) == 0 );
66 return ( TQString::localeAwareCompare( a1.formattedName(), a2.formattedName() ) < 0 );
71 return ( TQString::localeAwareCompare( a1.familyName(), a2.familyName() ) == 0
72 && TQString::localeAwareCompare( a1.givenName(), a2.givenName() ) == 0 );
77 int family = TQString::localeAwareCompare( a1.familyName(), a2.familyName() );
79 return ( TQString::localeAwareCompare( a1.givenName(), a2.givenName() ) < 0 );
87 return ( TQString::localeAwareCompare( a1.givenName(), a2.givenName() ) == 0
88 && TQString::localeAwareCompare( a1.familyName(), a2.familyName() ) == 0 );
93 int given = TQString::localeAwareCompare( a1.givenName(), a2.givenName() );
95 return ( TQString::localeAwareCompare( a1.familyName(), a2.familyName() ) < 0 );
107 static Field *sActiveField=0;
109 AddresseeList::AddresseeList()
112 mReverseSorting =
false;
113 mActiveSortingCriterion = FormattedName;
116 AddresseeList::~AddresseeList()
127 AddresseeList::AddresseeList(
const TQValueList<Addressee> &l )
130 mReverseSorting =
false;
133 void AddresseeList::dump()
const
136 kdDebug(5700) <<
"reverse order: " << ( mReverseSorting ?
"true" :
"false" ) <<
endl;
139 if ( Uid == mActiveSortingCriterion ) {
141 }
else if ( Name == mActiveSortingCriterion ) {
143 }
else if ( FormattedName == mActiveSortingCriterion ) {
144 crit =
"FormattedName";
145 }
else if ( FamilyName == mActiveSortingCriterion ) {
147 }
else if ( GivenName == mActiveSortingCriterion ) {
150 crit =
"unknown -- update dump method";
153 kdDebug(5700) <<
"sorting criterion: " << crit <<
endl;
155 for ( const_iterator it = begin(); it != end(); ++it ) {
164 mActiveSortingCriterion = c;
166 sortByTrait<SortingTraits::Uid>();
167 }
else if ( Name == c ) {
168 sortByTrait<SortingTraits::Name>();
169 }
else if ( FormattedName == c ) {
170 sortByTrait<SortingTraits::FormattedName>();
171 }
else if ( FamilyName == c ) {
172 sortByTrait<SortingTraits::FamilyName>();
173 }
else if ( GivenName==c ) {
174 sortByTrait<SortingTraits::GivenName>();
176 kdError(5700) <<
"AddresseeList sorting criterion passed for which a trait is not known. No sorting done." <<
endl;
182 sortBy( mActiveSortingCriterion );
185 template<
class Trait>
197 iterator i1 = begin();
198 iterator endIt = end();
204 while( i1 != endIt ) {
205 iterator j1 = begin();
209 if ( !mReverseSorting && Trait::lt( *j2, *j1 )
210 || mReverseSorting && Trait::lt( *j1, *j2 ) ) {
224 kdWarning(5700) <<
"sortByField called with no active sort field" <<
endl;
228 sActiveField = field;
233 TDEABC::FieldSortMode *mode =
new TDEABC::FieldSortMode( sActiveField, !mReverseSorting );
235 TDEABC::Addressee::setSortMode( mode );
237 TDEABC::Addressee::setSortMode( 0 );
247 TDEABC::Addressee::setSortMode( mode );
249 TDEABC::Addressee::setSortMode( 0 );
a TQValueList of Addressee, with sorting functionality
SortingCriterion sortingCriterion() const
Returns the active sorting criterion, ie the sorting criterion that will be used by a sort call.
void sortByMode(SortMode *mode=0)
Sorts this list by a specific sorting mode.
void sort()
Sorts this list by its active sorting criterion.
void sortByTrait()
Templated sort function.
bool reverseSorting() const
Returns the direction of sorting.
void sortBy(SortingCriterion c)
Sorts this list by a specific criterion.
void sortByField(Field *field=0)
Sorts this list by a specific field.
Field * sortingField() const
Returns the active sorting field, ie a pointer to the Field object which was used for the last sortBy...
TQString uid() const
Return unique identifier.
Sort method for sorting an addressee list.
kndbgstream & endl(kndbgstream &s)
kdbgstream kdWarning(int area=0)
kdbgstream kdError(int area=0)
kdbgstream kdDebug(int area=0)
static data, shared by ALL addressee objects
SortingCriterion
Addressee attribute used for sorting.