00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "opimcontactsortvector.h"
00031 #include <opie2/ocontactaccess.h>
00032
00033 namespace Opie {
00034 namespace Internal {
00035 OPimContactSortVector::OPimContactSortVector( uint size, bool asc, int sort )
00036 : OPimSortVector<OPimContact>( size, asc, sort ) {}
00037
00038 int OPimContactSortVector::compareItems( const OPimContact& left,
00039 const OPimContact& right ) {
00040 if ( left.uid() == right.uid() )
00041 return 0;
00042
00043 bool soTitle, soSummary, soFirstName, soMiddleName, soSuffix, soEmail,
00044 soNick, soFileAs, soAnni, soBirth, soGender;
00045 soTitle = soSummary = soFirstName = soMiddleName = soSuffix = soEmail =
00046 soNick = soFileAs = soAnni = soBirth = soGender = false;
00047 int ret = 0;
00048 bool asc = sortAscending();
00049
00050 switch( sortOrder() ) {
00051 case OPimContactAccess::SortSummary:
00052 ret = testString( left.fileAs(), right.fileAs() );
00053 soSummary = true;
00054 break;
00055 case OPimContactAccess::SortTitle:
00056 ret = testString( left.title(), right.title() );
00057 soTitle = true;
00058 break;
00059 case OPimContactAccess::SortFirstName:
00060 ret = testString( left.firstName(), right.firstName() );
00061 soFirstName = true;
00062 break;
00063 case OPimContactAccess::SortMiddleName:
00064 ret = testString( left.middleName(), right.middleName() );
00065 soMiddleName = true;
00066 break;
00067 case OPimContactAccess::SortSuffix:
00068 ret = testString( left.suffix(), right.suffix() );
00069 soSuffix = true;
00070 break;
00071 case OPimContactAccess::SortEmail:
00072 ret = testString( left.defaultEmail(), right.defaultEmail() );
00073 soEmail = true;
00074 break;
00075 case OPimContactAccess::SortNickname:
00076 ret = testString( left.nickname(), right.nickname() );
00077 soNick = true;
00078 break;
00079 case OPimContactAccess::SortFileAsName:
00080 ret = testString( left.fileAs(), right.fileAs() );
00081 soFileAs = true;
00082 break;
00083 case OPimContactAccess::SortAnniversary:
00084 ret = testDate( left.anniversary(), right.anniversary() );
00085 soAnni = true;
00086 break;
00087 case OPimContactAccess::SortByDate:
00088 case OPimContactAccess::SortBirthday:
00089 ret = testDate( left.birthday(), right.birthday() );
00090 soBirth = true;
00091 break;
00092 case OPimContactAccess::SortGender:
00093 ret = testString( left.gender(), right.gender() );
00094 soGender = true;
00095 break;
00096 }
00097
00098
00099 if ( !asc )
00100 ret *= -1;
00101
00102
00103
00104 return ret;
00105 }
00106
00107 }
00108 }