Diffstat (limited to 'libopie2/opiepim/private/opimcontactsortvector.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiepim/private/opimcontactsortvector.cpp | 14 |
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 | |||
@@ -19,90 +19,104 @@ | |||
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "opimcontactsortvector.h" | 30 | #include "opimcontactsortvector.h" |
31 | #include <opie2/ocontactaccess.h> | 31 | #include <opie2/ocontactaccess.h> |
32 | 32 | ||
33 | namespace Opie { | 33 | namespace Opie { |
34 | namespace Internal { | 34 | namespace Internal { |
35 | OPimContactSortVector::OPimContactSortVector( uint size, bool asc, int sort ) | 35 | OPimContactSortVector::OPimContactSortVector( uint size, bool asc, int sort ) |
36 | : OPimSortVector<OPimContact>( size, asc, sort ) {} | 36 | : OPimSortVector<OPimContact>( size, asc, sort ) {} |
37 | 37 | ||
38 | int OPimContactSortVector::compareItems( const OPimContact& left, | 38 | int OPimContactSortVector::compareItems( const OPimContact& left, |
39 | const OPimContact& right ) { | 39 | const OPimContact& right ) { |
40 | if ( left.uid() == right.uid() ) | 40 | if ( left.uid() == right.uid() ) |
41 | return 0; | 41 | return 0; |
42 | 42 | ||
43 | bool soTitle, soSummary, soFirstName, soMiddleName, soSuffix, soEmail, | 43 | bool soTitle, soSummary, soFirstName, soMiddleName, soSuffix, soEmail, |
44 | soNick, soFileAs, soAnni, soBirth, soGender; | 44 | soNick, soFileAs, soAnni, soBirth, soGender; |
45 | soTitle = soSummary = soFirstName = soMiddleName = soSuffix = soEmail = | 45 | soTitle = soSummary = soFirstName = soMiddleName = soSuffix = soEmail = |
46 | soNick = soFileAs = soAnni = soBirth = soGender = false; | 46 | soNick = soFileAs = soAnni = soBirth = soGender = false; |
47 | int ret = 0; | 47 | int ret = 0; |
48 | bool asc = sortAscending(); | 48 | bool asc = sortAscending(); |
49 | 49 | ||
50 | switch( sortOrder() ) { | 50 | switch( sortOrder() ) { |
51 | case OPimContactAccess::SortSummary: | 51 | case OPimContactAccess::SortSummary: |
52 | ret = testString( left.fileAs(), right.fileAs() ); | 52 | ret = testString( left.fileAs(), right.fileAs() ); |
53 | soSummary = true; | 53 | soSummary = true; |
54 | break; | 54 | break; |
55 | case OPimContactAccess::SortTitle: | 55 | case OPimContactAccess::SortTitle: |
56 | ret = testString( left.title(), right.title() ); | 56 | ret = testString( left.title(), right.title() ); |
57 | soTitle = true; | 57 | soTitle = true; |
58 | break; | 58 | break; |
59 | case OPimContactAccess::SortFirstName: | 59 | case OPimContactAccess::SortFirstName: |
60 | ret = testString( left.firstName(), right.firstName() ); | 60 | ret = testString( left.firstName(), right.firstName() ); |
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() ); |
73 | soEmail = true; | 76 | soEmail = true; |
74 | break; | 77 | break; |
75 | case OPimContactAccess::SortNickname: | 78 | case OPimContactAccess::SortNickname: |
76 | ret = testString( left.nickname(), right.nickname() ); | 79 | ret = testString( left.nickname(), right.nickname() ); |
77 | soNick = true; | 80 | soNick = true; |
78 | break; | 81 | break; |
79 | case OPimContactAccess::SortFileAsName: | 82 | case OPimContactAccess::SortFileAsName: |
80 | ret = testString( left.fileAs(), right.fileAs() ); | 83 | ret = testString( left.fileAs(), right.fileAs() ); |
81 | soFileAs = true; | 84 | soFileAs = true; |
82 | break; | 85 | break; |
83 | case OPimContactAccess::SortAnniversary: | 86 | case OPimContactAccess::SortAnniversary: |
84 | ret = testDate( left.anniversary(), right.anniversary() ); | 87 | ret = testDate( left.anniversary(), right.anniversary() ); |
85 | soAnni = true; | 88 | soAnni = true; |
86 | break; | 89 | break; |
87 | case OPimContactAccess::SortByDate: | 90 | case OPimContactAccess::SortByDate: |
88 | case OPimContactAccess::SortBirthday: | 91 | case OPimContactAccess::SortBirthday: |
89 | ret = testDate( left.birthday(), right.birthday() ); | 92 | ret = testDate( left.birthday(), right.birthday() ); |
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 | ||
102 | // Maybe differentiate as in OPimTodoSortVector ### FIXME | 116 | // Maybe differentiate as in OPimTodoSortVector ### FIXME |
103 | // if( ret ) | 117 | // if( ret ) |
104 | return ret; | 118 | return ret; |
105 | } | 119 | } |
106 | 120 | ||
107 | } | 121 | } |
108 | } | 122 | } |