summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/private/opimcontactsortvector.cpp
authorpaule <paule>2007-01-13 09:00:15 (UTC)
committer paule <paule>2007-01-13 09:00:15 (UTC)
commit5c03ec2b2d0d6b10f7581b8b447cbcb1935e7e67 (patch) (unidiff)
tree0ae38a54d489376ce3ac7df2441046075fb8cf14 /libopie2/opiepim/private/opimcontactsortvector.cpp
parenta1360b0af73518d97ebe63ad3cd156cd8b57c8b5 (diff)
downloadopie-5c03ec2b2d0d6b10f7581b8b447cbcb1935e7e67.zip
opie-5c03ec2b2d0d6b10f7581b8b447cbcb1935e7e67.tar.gz
opie-5c03ec2b2d0d6b10f7581b8b447cbcb1935e7e67.tar.bz2
Implement default sort functions for contact last name and birthday/anniversary. The latter is required for sorting birthdays/anniversaries correctly on the today screen.
Fixes bug #1760.
Diffstat (limited to 'libopie2/opiepim/private/opimcontactsortvector.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/private/opimcontactsortvector.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/libopie2/opiepim/private/opimcontactsortvector.cpp b/libopie2/opiepim/private/opimcontactsortvector.cpp
index 8c7d5ca..c8de4d1 100644
--- a/libopie2/opiepim/private/opimcontactsortvector.cpp
+++ b/libopie2/opiepim/private/opimcontactsortvector.cpp
@@ -61,12 +61,15 @@ int OPimContactSortVector::compareItems( const OPimContact& left,
61 soFirstName = true; 61 soFirstName = true;
62 break; 62 break;
63 case OPimContactAccess::SortMiddleName: 63 case OPimContactAccess::SortMiddleName:
64 ret = testString( left.middleName(), right.middleName() ); 64 ret = testString( left.middleName(), right.middleName() );
65 soMiddleName = true; 65 soMiddleName = true;
66 break; 66 break;
67 case OPimContactAccess::SortLastName:
68 ret = testString( left.lastName(), right.lastName() );
69 break;
67 case OPimContactAccess::SortSuffix: 70 case OPimContactAccess::SortSuffix:
68 ret = testString( left.suffix(), right.suffix() ); 71 ret = testString( left.suffix(), right.suffix() );
69 soSuffix = true; 72 soSuffix = true;
70 break; 73 break;
71 case OPimContactAccess::SortEmail: 74 case OPimContactAccess::SortEmail:
72 ret = testString( left.defaultEmail(), right.defaultEmail() ); 75 ret = testString( left.defaultEmail(), right.defaultEmail() );
@@ -90,12 +93,23 @@ int OPimContactSortVector::compareItems( const OPimContact& left,
90 soBirth = true; 93 soBirth = true;
91 break; 94 break;
92 case OPimContactAccess::SortGender: 95 case OPimContactAccess::SortGender:
93 ret = testString( left.gender(), right.gender() ); 96 ret = testString( left.gender(), right.gender() );
94 soGender = true; 97 soGender = true;
95 break; 98 break;
99 case OPimContactAccess::SortBirthdayWithoutYear:
100 // This doesn't actually just sort by the date without year,
101 // it actually works out the days until the next occurrence,
102 // which is more useful since it will work correctly when
103 // crossing year boundaries. - Paul Eggleton Dec 2006
104 ret = testDaysUntilNextDate( left.birthday(), right.birthday() );
105 break;
106 case OPimContactAccess::SortAnniversaryWithoutYear:
107 // (as above)
108 ret = testDaysUntilNextDate( left.anniversary(), right.anniversary() );
109 break;
96 } 110 }
97 111
98 /* twist to honor ascending/descending setting as QVector only sorts ascending*/ 112 /* twist to honor ascending/descending setting as QVector only sorts ascending*/
99 if ( !asc ) 113 if ( !asc )
100 ret *= -1; 114 ret *= -1;
101 115