24 #include <tdeabc/field.h>
26 #include "printsortmode.h"
28 #if KDE_IS_VERSION(3,3,91)
30 PrintSortMode::PrintSortMode( TDEABC::Field *field,
bool ascending )
31 : mSortField( field ), mAscending( ascending )
33 const TDEABC::Field::List fields = TDEABC::Field::allFields();
34 TDEABC::Field::List::ConstIterator it;
35 for ( it = fields.begin(); it != fields.end(); ++it ) {
36 if ( (*it)->label() == TDEABC::Addressee::givenNameLabel() )
37 mGivenNameField = *it;
38 else if ( (*it)->label() == TDEABC::Addressee::familyNameLabel() )
39 mFamilyNameField = *it;
40 else if ( (*it)->label() == TDEABC::Addressee::formattedNameLabel() )
41 mFormattedNameField = *it;
45 bool PrintSortMode::lesser(
const TDEABC::Addressee &first,
46 const TDEABC::Addressee &second )
const
51 int result = TQString::localeAwareCompare( mSortField->value( first ),
52 mSortField->value( second ) );
54 int givenNameResult = TQString::localeAwareCompare( mGivenNameField->value( first ),
55 mGivenNameField->value( second ) );
56 if ( givenNameResult == 0 ) {
57 int familyNameResult = TQString::localeAwareCompare( mFamilyNameField->value( first ),
58 mFamilyNameField->value( second ) );
59 if ( familyNameResult == 0 ) {
60 result = TQString::localeAwareCompare( mFormattedNameField->value( first ),
61 mFormattedNameField->value( second ) );
63 result = familyNameResult;
65 result = givenNameResult;
68 bool lesser = result < 0;