-rw-r--r-- | kabc/addresseelist.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/kabc/addresseelist.cpp b/kabc/addresseelist.cpp index 097e162..e1ba1ce 100644 --- a/kabc/addresseelist.cpp +++ b/kabc/addresseelist.cpp | |||
@@ -1,63 +1,65 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2002 Jost Schenck <jost@schenck.de> | 3 | Copyright (c) 2002 Jost Schenck <jost@schenck.de> |
4 | 2003 Tobias Koenig <tokoe@kde.org> | 4 | 2003 Tobias Koenig <tokoe@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <kdebug.h> | 29 | #include <kdebug.h> |
30 | //US | 30 | //US |
31 | #include <qtl.h> | 31 | #include <q3tl.h> |
32 | //Added by qt3to4: | ||
33 | #include <Q3ValueList> | ||
32 | 34 | ||
33 | 35 | ||
34 | #include "addresseelist.h" | 36 | #include "addresseelist.h" |
35 | #include "field.h" | 37 | #include "field.h" |
36 | 38 | ||
37 | using namespace KABC; | 39 | using namespace KABC; |
38 | 40 | ||
39 | // | 41 | // |
40 | // | 42 | // |
41 | // Traits | 43 | // Traits |
42 | // | 44 | // |
43 | // | 45 | // |
44 | 46 | ||
45 | bool SortingTraits::Uid::eq( const Addressee &a1, const Addressee &a2 ) | 47 | bool SortingTraits::Uid::eq( const Addressee &a1, const Addressee &a2 ) |
46 | { | 48 | { |
47 | // locale awareness doesn't make sense sorting ids | 49 | // locale awareness doesn't make sense sorting ids |
48 | return ( QString::compare( a1.uid(), a2.uid() ) == 0 ); | 50 | return ( QString::compare( a1.uid(), a2.uid() ) == 0 ); |
49 | } | 51 | } |
50 | 52 | ||
51 | bool SortingTraits::Uid::lt( const Addressee &a1, const Addressee &a2 ) | 53 | bool SortingTraits::Uid::lt( const Addressee &a1, const Addressee &a2 ) |
52 | { | 54 | { |
53 | // locale awareness doesn't make sense sorting ids | 55 | // locale awareness doesn't make sense sorting ids |
54 | return ( QString::compare( a1.uid(), a2.uid() ) < 0 ); | 56 | return ( QString::compare( a1.uid(), a2.uid() ) < 0 ); |
55 | } | 57 | } |
56 | 58 | ||
57 | bool SortingTraits::Name::eq( const Addressee &a1, const Addressee &a2 ) | 59 | bool SortingTraits::Name::eq( const Addressee &a1, const Addressee &a2 ) |
58 | { | 60 | { |
59 | //US QString::localeAwareCompare is not available in my distribution. Redefine it to compare | 61 | //US QString::localeAwareCompare is not available in my distribution. Redefine it to compare |
60 | return ( QString::compare( a1.name(), a2.name() ) == 0 ); | 62 | return ( QString::compare( a1.name(), a2.name() ) == 0 ); |
61 | } | 63 | } |
62 | 64 | ||
63 | bool SortingTraits::Name::lt( const Addressee &a1, const Addressee &a2 ) | 65 | bool SortingTraits::Name::lt( const Addressee &a1, const Addressee &a2 ) |
@@ -92,84 +94,84 @@ bool SortingTraits::FamilyName::lt( const Addressee &a1, const Addressee &a2 ) | |||
92 | if ( 0 == family ) { | 94 | if ( 0 == family ) { |
93 | return ( QString::compare( a1.givenName(), a2.givenName() ) < 0 ); | 95 | return ( QString::compare( a1.givenName(), a2.givenName() ) < 0 ); |
94 | } else { | 96 | } else { |
95 | return family < 0; | 97 | return family < 0; |
96 | } | 98 | } |
97 | } | 99 | } |
98 | 100 | ||
99 | bool SortingTraits::GivenName::eq( const Addressee &a1, const Addressee &a2 ) | 101 | bool SortingTraits::GivenName::eq( const Addressee &a1, const Addressee &a2 ) |
100 | { | 102 | { |
101 | //US QString::localeAwareCompare is not available in my distribution. Redefine it to compare | 103 | //US QString::localeAwareCompare is not available in my distribution. Redefine it to compare |
102 | return ( QString::compare( a1.givenName(), a2.givenName() ) == 0 | 104 | return ( QString::compare( a1.givenName(), a2.givenName() ) == 0 |
103 | && QString::compare( a1.familyName(), a2.familyName() ) == 0 ); | 105 | && QString::compare( a1.familyName(), a2.familyName() ) == 0 ); |
104 | } | 106 | } |
105 | 107 | ||
106 | bool SortingTraits::GivenName::lt( const Addressee &a1, const Addressee &a2 ) | 108 | bool SortingTraits::GivenName::lt( const Addressee &a1, const Addressee &a2 ) |
107 | { | 109 | { |
108 | //US QString::localeAwareCompare is not available in my distribution. Redefine it to compare | 110 | //US QString::localeAwareCompare is not available in my distribution. Redefine it to compare |
109 | int given = QString::compare( a1.givenName(), a2.givenName() ); | 111 | int given = QString::compare( a1.givenName(), a2.givenName() ); |
110 | if ( 0 == given ) { | 112 | if ( 0 == given ) { |
111 | return ( QString::compare( a1.familyName(), a2.familyName() ) < 0 ); | 113 | return ( QString::compare( a1.familyName(), a2.familyName() ) < 0 ); |
112 | } else { | 114 | } else { |
113 | return given < 0; | 115 | return given < 0; |
114 | } | 116 | } |
115 | } | 117 | } |
116 | 118 | ||
117 | // | 119 | // |
118 | // | 120 | // |
119 | // AddresseeList | 121 | // AddresseeList |
120 | // | 122 | // |
121 | // | 123 | // |
122 | 124 | ||
123 | AddresseeList::AddresseeList() | 125 | AddresseeList::AddresseeList() |
124 | : QValueList<Addressee>() | 126 | : Q3ValueList<Addressee>() |
125 | { | 127 | { |
126 | mReverseSorting = false; | 128 | mReverseSorting = false; |
127 | mActiveSortingCriterion = FormattedName; | 129 | mActiveSortingCriterion = FormattedName; |
128 | mActiveSortingField = 0; | 130 | mActiveSortingField = 0; |
129 | } | 131 | } |
130 | 132 | ||
131 | AddresseeList::~AddresseeList() | 133 | AddresseeList::~AddresseeList() |
132 | { | 134 | { |
133 | } | 135 | } |
134 | 136 | ||
135 | AddresseeList::AddresseeList( const AddresseeList &l ) | 137 | AddresseeList::AddresseeList( const AddresseeList &l ) |
136 | : QValueList<Addressee>( l ) | 138 | : Q3ValueList<Addressee>( l ) |
137 | { | 139 | { |
138 | mReverseSorting = l.reverseSorting(); | 140 | mReverseSorting = l.reverseSorting(); |
139 | mActiveSortingCriterion = l.sortingCriterion(); | 141 | mActiveSortingCriterion = l.sortingCriterion(); |
140 | } | 142 | } |
141 | 143 | ||
142 | AddresseeList::AddresseeList( const QValueList<Addressee> &l ) | 144 | AddresseeList::AddresseeList( const Q3ValueList<Addressee> &l ) |
143 | : QValueList<Addressee>( l ) | 145 | : Q3ValueList<Addressee>( l ) |
144 | { | 146 | { |
145 | mReverseSorting = false; | 147 | mReverseSorting = false; |
146 | } | 148 | } |
147 | 149 | ||
148 | void AddresseeList::dump() const | 150 | void AddresseeList::dump() const |
149 | { | 151 | { |
150 | kdDebug(5700) << "AddresseeList {" << endl; | 152 | kdDebug(5700) << "AddresseeList {" << endl; |
151 | kdDebug(5700) << "reverse order: " << ( mReverseSorting ? "true" : "false" ) << endl; | 153 | kdDebug(5700) << "reverse order: " << ( mReverseSorting ? "true" : "false" ) << endl; |
152 | 154 | ||
153 | QString crit; | 155 | QString crit; |
154 | if ( Uid == mActiveSortingCriterion ) { | 156 | if ( Uid == mActiveSortingCriterion ) { |
155 | crit = "Uid"; | 157 | crit = "Uid"; |
156 | } else if ( Name == mActiveSortingCriterion ) { | 158 | } else if ( Name == mActiveSortingCriterion ) { |
157 | crit = "Name"; | 159 | crit = "Name"; |
158 | } else if ( FormattedName == mActiveSortingCriterion ) { | 160 | } else if ( FormattedName == mActiveSortingCriterion ) { |
159 | crit = "FormattedName"; | 161 | crit = "FormattedName"; |
160 | } else if ( FamilyName == mActiveSortingCriterion ) { | 162 | } else if ( FamilyName == mActiveSortingCriterion ) { |
161 | crit = "FamilyName"; | 163 | crit = "FamilyName"; |
162 | } else if ( GivenName == mActiveSortingCriterion ) { | 164 | } else if ( GivenName == mActiveSortingCriterion ) { |
163 | crit = "GivenName"; | 165 | crit = "GivenName"; |
164 | } else { | 166 | } else { |
165 | crit = "unknown -- update dump method"; | 167 | crit = "unknown -- update dump method"; |
166 | } | 168 | } |
167 | 169 | ||
168 | kdDebug(5700) << "sorting criterion: " << crit << endl; | 170 | kdDebug(5700) << "sorting criterion: " << crit << endl; |
169 | 171 | ||
170 | //US | 172 | //US |
171 | //US for ( const_iterator it = begin(); it != end(); ++it ) | 173 | //US for ( const_iterator it = begin(); it != end(); ++it ) |
172 | for ( ConstIterator it = begin(); it != end(); ++it ) | 174 | for ( ConstIterator it = begin(); it != end(); ++it ) |
173 | (*it).dump(); | 175 | (*it).dump(); |
174 | 176 | ||
175 | kdDebug(5700) << "}" << endl; | 177 | kdDebug(5700) << "}" << endl; |