summaryrefslogtreecommitdiff
authordrw <drw>2005-03-15 18:20:46 (UTC)
committer drw <drw>2005-03-15 18:20:46 (UTC)
commite0a3ecfb3981cbc6fa413b08b123685a6c2632d1 (patch) (unidiff)
tree04e9592ba48c5a25a8ffd474cec923c2bfdfa9bd
parent90d940ea8244140b25552bb8a28eacb7d3db01e8 (diff)
downloadopie-e0a3ecfb3981cbc6fa413b08b123685a6c2632d1.zip
opie-e0a3ecfb3981cbc6fa413b08b123685a6c2632d1.tar.gz
opie-e0a3ecfb3981cbc6fa413b08b123685a6c2632d1.tar.bz2
Fix addressbook sort by implementing sorting by 'File As' name
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/private/opimcontactsortvector.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/libopie2/opiepim/private/opimcontactsortvector.cpp b/libopie2/opiepim/private/opimcontactsortvector.cpp
index 9e186fe..8c7d5ca 100644
--- a/libopie2/opiepim/private/opimcontactsortvector.cpp
+++ b/libopie2/opiepim/private/opimcontactsortvector.cpp
@@ -1,104 +1,108 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) 2004 Holger Freyther <freyther@handhelds.org> 3 Copyright (C) 2004 Holger Freyther <freyther@handhelds.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
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
33namespace Opie { 33namespace Opie {
34namespace Internal { 34namespace Internal {
35OPimContactSortVector::OPimContactSortVector( uint size, bool asc, int sort ) 35OPimContactSortVector::OPimContactSortVector( uint size, bool asc, int sort )
36 : OPimSortVector<OPimContact>( size, asc, sort ) {} 36 : OPimSortVector<OPimContact>( size, asc, sort ) {}
37 37
38int OPimContactSortVector::compareItems( const OPimContact& left, 38int 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, 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 = 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::SortSuffix: 67 case OPimContactAccess::SortSuffix:
68 ret = testString( left.suffix(), right.suffix() ); 68 ret = testString( left.suffix(), right.suffix() );
69 soSuffix = true; 69 soSuffix = true;
70 break; 70 break;
71 case OPimContactAccess::SortEmail: 71 case OPimContactAccess::SortEmail:
72 ret = testString( left.defaultEmail(), right.defaultEmail() ); 72 ret = testString( left.defaultEmail(), right.defaultEmail() );
73 soEmail = true; 73 soEmail = true;
74 break; 74 break;
75 case OPimContactAccess::SortNickname: 75 case OPimContactAccess::SortNickname:
76 ret = testString( left.nickname(), right.nickname() ); 76 ret = testString( left.nickname(), right.nickname() );
77 soNick = true; 77 soNick = true;
78 break; 78 break;
79 case OPimContactAccess::SortFileAsName:
80 ret = testString( left.fileAs(), right.fileAs() );
81 soFileAs = true;
82 break;
79 case OPimContactAccess::SortAnniversary: 83 case OPimContactAccess::SortAnniversary:
80 ret = testDate( left.anniversary(), right.anniversary() ); 84 ret = testDate( left.anniversary(), right.anniversary() );
81 soAnni = true; 85 soAnni = true;
82 break; 86 break;
83 case OPimContactAccess::SortByDate: 87 case OPimContactAccess::SortByDate:
84 case OPimContactAccess::SortBirthday: 88 case OPimContactAccess::SortBirthday:
85 ret = testDate( left.birthday(), right.birthday() ); 89 ret = testDate( left.birthday(), right.birthday() );
86 soBirth = true; 90 soBirth = true;
87 break; 91 break;
88 case OPimContactAccess::SortGender: 92 case OPimContactAccess::SortGender:
89 ret = testString( left.gender(), right.gender() ); 93 ret = testString( left.gender(), right.gender() );
90 soGender = true; 94 soGender = true;
91 break; 95 break;
92 } 96 }
93 97
94 /* twist to honor ascending/descending setting as QVector only sorts ascending*/ 98 /* twist to honor ascending/descending setting as QVector only sorts ascending*/
95 if ( !asc ) 99 if ( !asc )
96 ret *= -1; 100 ret *= -1;
97 101
98 // Maybe differentiate as in OPimTodoSortVector ### FIXME 102 // Maybe differentiate as in OPimTodoSortVector ### FIXME
99 // if( ret ) 103 // if( ret )
100 return ret; 104 return ret;
101} 105}
102 106
103} 107}
104} 108}