author | zautrix <zautrix> | 2005-04-08 10:54:05 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-08 10:54:05 (UTC) |
commit | 59fb8a0ac35bf3b81f1c4e2e4fc6b61356d064ef (patch) (unidiff) | |
tree | ab604082029c081fa8725c5535a51a23bb963ef2 /kabc/addressee.cpp | |
parent | c82f9b40f6023dc7b39ac555cba8c4c313f15ca8 (diff) | |
download | kdepimpi-59fb8a0ac35bf3b81f1c4e2e4fc6b61356d064ef.zip kdepimpi-59fb8a0ac35bf3b81f1c4e2e4fc6b61356d064ef.tar.gz kdepimpi-59fb8a0ac35bf3b81f1c4e2e4fc6b61356d064ef.tar.bz2 |
fixes
-rw-r--r-- | kabc/addressee.cpp | 17 |
1 files changed, 0 insertions, 17 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 7f592e9..155ce24 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,2222 +1,2205 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@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 <kconfig.h> | 29 | #include <kconfig.h> |
30 | 30 | ||
31 | #include <ksharedptr.h> | 31 | #include <ksharedptr.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <kapplication.h> | 33 | #include <kapplication.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kidmanager.h> | 35 | #include <kidmanager.h> |
36 | //US | 36 | //US |
37 | #include <kstandarddirs.h> | 37 | #include <kstandarddirs.h> |
38 | #include <libkcal/syncdefines.h> | 38 | #include <libkcal/syncdefines.h> |
39 | 39 | ||
40 | //US #include "resource.h" | 40 | //US #include "resource.h" |
41 | #include "addressee.h" | 41 | #include "addressee.h" |
42 | 42 | ||
43 | using namespace KABC; | 43 | using namespace KABC; |
44 | 44 | ||
45 | static bool matchBinaryPattern( int value, int pattern ); | 45 | static bool matchBinaryPattern( int value, int pattern ); |
46 | static bool matchBinaryPatternA( int value, int pattern ); | 46 | static bool matchBinaryPatternA( int value, int pattern ); |
47 | static bool matchBinaryPatternP( int value, int pattern ); | 47 | static bool matchBinaryPatternP( int value, int pattern ); |
48 | 48 | ||
49 | struct Addressee::AddresseeData : public KShared | 49 | struct Addressee::AddresseeData : public KShared |
50 | { | 50 | { |
51 | QString uid; | 51 | QString uid; |
52 | QString name; | 52 | QString name; |
53 | QString formattedName; | 53 | QString formattedName; |
54 | QString defaultFormattedName; | ||
55 | QString familyName; | 54 | QString familyName; |
56 | QString givenName; | 55 | QString givenName; |
57 | QString additionalName; | 56 | QString additionalName; |
58 | QString prefix; | 57 | QString prefix; |
59 | QString suffix; | 58 | QString suffix; |
60 | QString nickName; | 59 | QString nickName; |
61 | QDateTime birthday; | 60 | QDateTime birthday; |
62 | QString mailer; | 61 | QString mailer; |
63 | TimeZone timeZone; | 62 | TimeZone timeZone; |
64 | Geo geo; | 63 | Geo geo; |
65 | QString title; | 64 | QString title; |
66 | QString role; | 65 | QString role; |
67 | QString organization; | 66 | QString organization; |
68 | QString note; | 67 | QString note; |
69 | QString productId; | 68 | QString productId; |
70 | QDateTime revision; | 69 | QDateTime revision; |
71 | QString sortString; | 70 | QString sortString; |
72 | QString externalUID; | 71 | QString externalUID; |
73 | QString originalExternalUID; | 72 | QString originalExternalUID; |
74 | KURL url; | 73 | KURL url; |
75 | Secrecy secrecy; | 74 | Secrecy secrecy; |
76 | Picture logo; | 75 | Picture logo; |
77 | Picture photo; | 76 | Picture photo; |
78 | Sound sound; | 77 | Sound sound; |
79 | Agent agent; | 78 | Agent agent; |
80 | QString mExternalId; | 79 | QString mExternalId; |
81 | PhoneNumber::List phoneNumbers; | 80 | PhoneNumber::List phoneNumbers; |
82 | Address::List addresses; | 81 | Address::List addresses; |
83 | Key::List keys; | 82 | Key::List keys; |
84 | QStringList emails; | 83 | QStringList emails; |
85 | QStringList categories; | 84 | QStringList categories; |
86 | QStringList custom; | 85 | QStringList custom; |
87 | int mTempSyncStat; | 86 | int mTempSyncStat; |
88 | Resource *resource; | 87 | Resource *resource; |
89 | 88 | ||
90 | bool empty :1; | 89 | bool empty :1; |
91 | bool changed :1; | 90 | bool changed :1; |
92 | bool tagged :1; | 91 | bool tagged :1; |
93 | }; | 92 | }; |
94 | 93 | ||
95 | Addressee::Addressee() | 94 | Addressee::Addressee() |
96 | { | 95 | { |
97 | mData = new AddresseeData; | 96 | mData = new AddresseeData; |
98 | mData->empty = true; | 97 | mData->empty = true; |
99 | mData->changed = false; | 98 | mData->changed = false; |
100 | mData->resource = 0; | 99 | mData->resource = 0; |
101 | mData->mExternalId = ":"; | 100 | mData->mExternalId = ":"; |
102 | mData->revision = QDateTime ( QDate( 2003,1,1)); | 101 | mData->revision = QDateTime ( QDate( 2003,1,1)); |
103 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
104 | } | 103 | } |
105 | 104 | ||
106 | Addressee::~Addressee() | 105 | Addressee::~Addressee() |
107 | { | 106 | { |
108 | } | 107 | } |
109 | 108 | ||
110 | Addressee::Addressee( const Addressee &a ) | 109 | Addressee::Addressee( const Addressee &a ) |
111 | { | 110 | { |
112 | mData = a.mData; | 111 | mData = a.mData; |
113 | } | 112 | } |
114 | 113 | ||
115 | Addressee &Addressee::operator=( const Addressee &a ) | 114 | Addressee &Addressee::operator=( const Addressee &a ) |
116 | { | 115 | { |
117 | mData = a.mData; | 116 | mData = a.mData; |
118 | return (*this); | 117 | return (*this); |
119 | } | 118 | } |
120 | 119 | ||
121 | Addressee Addressee::copy() | 120 | Addressee Addressee::copy() |
122 | { | 121 | { |
123 | Addressee a; | 122 | Addressee a; |
124 | *(a.mData) = *mData; | 123 | *(a.mData) = *mData; |
125 | return a; | 124 | return a; |
126 | } | 125 | } |
127 | 126 | ||
128 | void Addressee::detach() | 127 | void Addressee::detach() |
129 | { | 128 | { |
130 | if ( mData.count() == 1 ) return; | 129 | if ( mData.count() == 1 ) return; |
131 | *this = copy(); | 130 | *this = copy(); |
132 | } | 131 | } |
133 | 132 | ||
134 | bool Addressee::operator==( const Addressee &a ) const | 133 | bool Addressee::operator==( const Addressee &a ) const |
135 | { | 134 | { |
136 | if ( uid() != a.uid() ) return false; | 135 | if ( uid() != a.uid() ) return false; |
137 | if ( mData->name != a.mData->name ) return false; | 136 | if ( mData->name != a.mData->name ) return false; |
138 | if ( mData->formattedName != a.mData->formattedName ) return false; | 137 | if ( mData->formattedName != a.mData->formattedName ) return false; |
139 | if ( mData->familyName != a.mData->familyName ) return false; | 138 | if ( mData->familyName != a.mData->familyName ) return false; |
140 | if ( mData->givenName != a.mData->givenName ) return false; | 139 | if ( mData->givenName != a.mData->givenName ) return false; |
141 | if ( mData->additionalName != a.mData->additionalName ) return false; | 140 | if ( mData->additionalName != a.mData->additionalName ) return false; |
142 | if ( mData->prefix != a.mData->prefix ) return false; | 141 | if ( mData->prefix != a.mData->prefix ) return false; |
143 | if ( mData->suffix != a.mData->suffix ) return false; | 142 | if ( mData->suffix != a.mData->suffix ) return false; |
144 | if ( mData->nickName != a.mData->nickName ) return false; | 143 | if ( mData->nickName != a.mData->nickName ) return false; |
145 | if ( mData->birthday != a.mData->birthday ) return false; | 144 | if ( mData->birthday != a.mData->birthday ) return false; |
146 | if ( mData->mailer != a.mData->mailer ) return false; | 145 | if ( mData->mailer != a.mData->mailer ) return false; |
147 | if ( mData->timeZone != a.mData->timeZone ) return false; | 146 | if ( mData->timeZone != a.mData->timeZone ) return false; |
148 | if ( mData->geo != a.mData->geo ) return false; | 147 | if ( mData->geo != a.mData->geo ) return false; |
149 | if ( mData->title != a.mData->title ) return false; | 148 | if ( mData->title != a.mData->title ) return false; |
150 | if ( mData->role != a.mData->role ) return false; | 149 | if ( mData->role != a.mData->role ) return false; |
151 | if ( mData->organization != a.mData->organization ) return false; | 150 | if ( mData->organization != a.mData->organization ) return false; |
152 | if ( mData->note != a.mData->note ) return false; | 151 | if ( mData->note != a.mData->note ) return false; |
153 | if ( mData->productId != a.mData->productId ) return false; | 152 | if ( mData->productId != a.mData->productId ) return false; |
154 | //if ( mData->revision != a.mData->revision ) return false; | 153 | //if ( mData->revision != a.mData->revision ) return false; |
155 | if ( mData->sortString != a.mData->sortString ) return false; | 154 | if ( mData->sortString != a.mData->sortString ) return false; |
156 | if ( mData->secrecy != a.mData->secrecy ) return false; | 155 | if ( mData->secrecy != a.mData->secrecy ) return false; |
157 | if ( mData->logo != a.mData->logo ) return false; | 156 | if ( mData->logo != a.mData->logo ) return false; |
158 | if ( mData->photo != a.mData->photo ) return false; | 157 | if ( mData->photo != a.mData->photo ) return false; |
159 | if ( mData->sound != a.mData->sound ) return false; | 158 | if ( mData->sound != a.mData->sound ) return false; |
160 | if ( mData->agent != a.mData->agent ) return false; | 159 | if ( mData->agent != a.mData->agent ) return false; |
161 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
162 | ( mData->url != a.mData->url ) ) return false; | 161 | ( mData->url != a.mData->url ) ) return false; |
163 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
164 | if ( mData->addresses != a.mData->addresses ) return false; | 163 | if ( mData->addresses != a.mData->addresses ) return false; |
165 | if ( mData->keys != a.mData->keys ) return false; | 164 | if ( mData->keys != a.mData->keys ) return false; |
166 | if ( mData->emails != a.mData->emails ) return false; | 165 | if ( mData->emails != a.mData->emails ) return false; |
167 | if ( mData->categories != a.mData->categories ) return false; | 166 | if ( mData->categories != a.mData->categories ) return false; |
168 | if ( mData->custom != a.mData->custom ) return false; | 167 | if ( mData->custom != a.mData->custom ) return false; |
169 | 168 | ||
170 | return true; | 169 | return true; |
171 | } | 170 | } |
172 | 171 | ||
173 | bool Addressee::operator!=( const Addressee &a ) const | 172 | bool Addressee::operator!=( const Addressee &a ) const |
174 | { | 173 | { |
175 | return !( a == *this ); | 174 | return !( a == *this ); |
176 | } | 175 | } |
177 | 176 | ||
178 | bool Addressee::isEmpty() const | 177 | bool Addressee::isEmpty() const |
179 | { | 178 | { |
180 | return mData->empty; | 179 | return mData->empty; |
181 | } | 180 | } |
182 | ulong Addressee::getCsum4List( const QStringList & attList) | 181 | ulong Addressee::getCsum4List( const QStringList & attList) |
183 | { | 182 | { |
184 | int max = attList.count(); | 183 | int max = attList.count(); |
185 | ulong cSum = 0; | 184 | ulong cSum = 0; |
186 | int j,k,i; | 185 | int j,k,i; |
187 | int add; | 186 | int add; |
188 | for ( i = 0; i < max ; ++i ) { | 187 | for ( i = 0; i < max ; ++i ) { |
189 | QString s = attList[i]; | 188 | QString s = attList[i]; |
190 | if ( ! s.isEmpty() ){ | 189 | if ( ! s.isEmpty() ){ |
191 | j = s.length(); | 190 | j = s.length(); |
192 | for ( k = 0; k < j; ++k ) { | 191 | for ( k = 0; k < j; ++k ) { |
193 | int mul = k +1; | 192 | int mul = k +1; |
194 | add = s[k].unicode (); | 193 | add = s[k].unicode (); |
195 | if ( k < 16 ) | 194 | if ( k < 16 ) |
196 | mul = mul * mul; | 195 | mul = mul * mul; |
197 | int ii = i+1; | 196 | int ii = i+1; |
198 | add = add * mul *ii*ii*ii; | 197 | add = add * mul *ii*ii*ii; |
199 | cSum += add; | 198 | cSum += add; |
200 | //qDebug("csum: %d %d %d", i,k,cSum); | 199 | //qDebug("csum: %d %d %d", i,k,cSum); |
201 | } | 200 | } |
202 | } | 201 | } |
203 | 202 | ||
204 | } | 203 | } |
205 | //QString dump = attList.join(","); | 204 | //QString dump = attList.join(","); |
206 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 205 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
207 | 206 | ||
208 | return cSum; | 207 | return cSum; |
209 | 208 | ||
210 | } | 209 | } |
211 | void Addressee::computeCsum(const QString &dev) | 210 | void Addressee::computeCsum(const QString &dev) |
212 | { | 211 | { |
213 | QStringList l; | 212 | QStringList l; |
214 | //if ( !mData->name.isEmpty() ) l.append(mData->name); | 213 | //if ( !mData->name.isEmpty() ) l.append(mData->name); |
215 | //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 214 | //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
216 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 215 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
217 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 216 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
218 | if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); | 217 | if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); |
219 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 218 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
220 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 219 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
221 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 220 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
222 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 221 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
223 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 222 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
224 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 223 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
225 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 224 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
226 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 225 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
227 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 226 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
228 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 227 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
229 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 228 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
230 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 229 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
231 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 230 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
232 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 231 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
233 | if ( !mData->logo.undefined() ) { | 232 | if ( !mData->logo.undefined() ) { |
234 | if ( !mData->logo.isIntern() ) | 233 | if ( !mData->logo.isIntern() ) |
235 | l.append( mData->logo.url() ); | 234 | l.append( mData->logo.url() ); |
236 | else | 235 | else |
237 | l.append( QString::number(mData->logo.data().width()* mData->logo.data().height())); | 236 | l.append( QString::number(mData->logo.data().width()* mData->logo.data().height())); |
238 | } else { | 237 | } else { |
239 | l.append( "nologo"); | 238 | l.append( "nologo"); |
240 | } | 239 | } |
241 | if ( !mData->photo.undefined() ) { | 240 | if ( !mData->photo.undefined() ) { |
242 | if ( !mData->photo.isIntern() ) | 241 | if ( !mData->photo.isIntern() ) |
243 | l.append( mData->photo.url() ); | 242 | l.append( mData->photo.url() ); |
244 | else | 243 | else |
245 | l.append( QString::number(mData->photo.data().width()* mData->photo.data().height())); | 244 | l.append( QString::number(mData->photo.data().width()* mData->photo.data().height())); |
246 | } else { | 245 | } else { |
247 | l.append( "nophoto"); | 246 | l.append( "nophoto"); |
248 | } | 247 | } |
249 | #if 0 | 248 | #if 0 |
250 | if ( !mData->sound.undefined() ) { | 249 | if ( !mData->sound.undefined() ) { |
251 | if ( !mData->sound.isIntern() ) | 250 | if ( !mData->sound.isIntern() ) |
252 | l.append( mData->sound.url() ); | 251 | l.append( mData->sound.url() ); |
253 | else | 252 | else |
254 | l.append( QString(mData->sound.data().with()* mData->sound.data().height())); | 253 | l.append( QString(mData->sound.data().with()* mData->sound.data().height())); |
255 | } else { | 254 | } else { |
256 | l.append( "nosound"); | 255 | l.append( "nosound"); |
257 | } | 256 | } |
258 | #endif | 257 | #endif |
259 | //if ( !mData->agent.isEmpty() ) l.append( ); | 258 | //if ( !mData->agent.isEmpty() ) l.append( ); |
260 | if ( mData->url.isValid() ) | 259 | if ( mData->url.isValid() ) |
261 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); | 260 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); |
262 | KABC::PhoneNumber::List phoneNumbers; | 261 | KABC::PhoneNumber::List phoneNumbers; |
263 | KABC::PhoneNumber::List::Iterator phoneIter; | 262 | KABC::PhoneNumber::List::Iterator phoneIter; |
264 | 263 | ||
265 | QStringList t; | 264 | QStringList t; |
266 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 265 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
267 | ++phoneIter ) | 266 | ++phoneIter ) |
268 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 267 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
269 | t.sort(); | 268 | t.sort(); |
270 | uint iii; | 269 | uint iii; |
271 | for ( iii = 0; iii < t.count(); ++iii) | 270 | for ( iii = 0; iii < t.count(); ++iii) |
272 | l.append( t[iii] ); | 271 | l.append( t[iii] ); |
273 | t = mData->emails; | 272 | t = mData->emails; |
274 | t.sort(); | 273 | t.sort(); |
275 | for ( iii = 0; iii < t.count(); ++iii) | 274 | for ( iii = 0; iii < t.count(); ++iii) |
276 | l.append( t[iii] ); | 275 | l.append( t[iii] ); |
277 | t = mData->categories; | 276 | t = mData->categories; |
278 | t.sort(); | 277 | t.sort(); |
279 | for ( iii = 0; iii < t.count(); ++iii) | 278 | for ( iii = 0; iii < t.count(); ++iii) |
280 | l.append( t[iii] ); | 279 | l.append( t[iii] ); |
281 | t = mData->custom; | 280 | t = mData->custom; |
282 | t.sort(); | 281 | t.sort(); |
283 | for ( iii = 0; iii < t.count(); ++iii) | 282 | for ( iii = 0; iii < t.count(); ++iii) |
284 | if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { | 283 | if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { |
285 | int find = t[iii].find (':')+1; | 284 | int find = t[iii].find (':')+1; |
286 | //qDebug("lennnn %d %d ", find, t[iii].length()); | 285 | //qDebug("lennnn %d %d ", find, t[iii].length()); |
287 | if ( find < t[iii].length()) | 286 | if ( find < t[iii].length()) |
288 | l.append( t[iii] ); | 287 | l.append( t[iii] ); |
289 | 288 | ||
290 | } | 289 | } |
291 | KABC::Address::List::Iterator addressIter; | 290 | KABC::Address::List::Iterator addressIter; |
292 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 291 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
293 | ++addressIter ) { | 292 | ++addressIter ) { |
294 | t = (*addressIter).asList(); | 293 | t = (*addressIter).asList(); |
295 | t.sort(); | 294 | t.sort(); |
296 | for ( iii = 0; iii < t.count(); ++iii) | 295 | for ( iii = 0; iii < t.count(); ++iii) |
297 | l.append( t[iii] ); | 296 | l.append( t[iii] ); |
298 | } | 297 | } |
299 | uint cs = getCsum4List(l); | 298 | uint cs = getCsum4List(l); |
300 | 299 | ||
301 | #if 0 | 300 | #if 0 |
302 | for ( iii = 0; iii < l.count(); ++iii) | 301 | for ( iii = 0; iii < l.count(); ++iii) |
303 | qDebug("%d***%s***",iii,l[iii].latin1()); | 302 | qDebug("%d***%s***",iii,l[iii].latin1()); |
304 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 303 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
305 | #endif | 304 | #endif |
306 | 305 | ||
307 | 306 | ||
308 | setCsum( dev, QString::number (cs )); | 307 | setCsum( dev, QString::number (cs )); |
309 | } | 308 | } |
310 | 309 | ||
311 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | 310 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) |
312 | { | 311 | { |
313 | // merge all standard non-outlook fields. | 312 | // merge all standard non-outlook fields. |
314 | //if isSubSet (e.g. mobile phone sync) merge all fields | 313 | //if isSubSet (e.g. mobile phone sync) merge all fields |
315 | 314 | ||
316 | detach(); | 315 | detach(); |
317 | if ( isSubSet ) { | 316 | if ( isSubSet ) { |
318 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 317 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
319 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 318 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
320 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 319 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
321 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 320 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
322 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 321 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
323 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 322 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
324 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 323 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
325 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 324 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
326 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 325 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
327 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 326 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
328 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 327 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
329 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 328 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
330 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 329 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
331 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 330 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
332 | if ( !mData->birthday.isValid() ) | 331 | if ( !mData->birthday.isValid() ) |
333 | if ( ad.mData->birthday.isValid()) | 332 | if ( ad.mData->birthday.isValid()) |
334 | mData->birthday = ad.mData->birthday; | 333 | mData->birthday = ad.mData->birthday; |
335 | 334 | ||
336 | } | 335 | } |
337 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 336 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
338 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 337 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
339 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 338 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
340 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 339 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
341 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 340 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
342 | QStringList t; | 341 | QStringList t; |
343 | QStringList tAD; | 342 | QStringList tAD; |
344 | uint iii; | 343 | uint iii; |
345 | 344 | ||
346 | // ********** phone numbers | 345 | // ********** phone numbers |
347 | if ( isSubSet ) { | 346 | if ( isSubSet ) { |
348 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 347 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
349 | PhoneNumber::List::Iterator phoneItAD; | 348 | PhoneNumber::List::Iterator phoneItAD; |
350 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 349 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
351 | bool found = false; | 350 | bool found = false; |
352 | PhoneNumber::List::Iterator it; | 351 | PhoneNumber::List::Iterator it; |
353 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 352 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
354 | if ( ( *phoneItAD ).contains( (*it) ) ) { | 353 | if ( ( *phoneItAD ).contains( (*it) ) ) { |
355 | found = true; | 354 | found = true; |
356 | (*it).setType( ( *phoneItAD ).type() ); | 355 | (*it).setType( ( *phoneItAD ).type() ); |
357 | (*it).setNumber( ( *phoneItAD ).number() ); | 356 | (*it).setNumber( ( *phoneItAD ).number() ); |
358 | break; | 357 | break; |
359 | } | 358 | } |
360 | } | 359 | } |
361 | // if ( isSubSet && ! found ) | 360 | // if ( isSubSet && ! found ) |
362 | if ( ! found ) // LR try this one... | 361 | if ( ! found ) // LR try this one... |
363 | mData->phoneNumbers.append( *phoneItAD ); | 362 | mData->phoneNumbers.append( *phoneItAD ); |
364 | } | 363 | } |
365 | } else { | 364 | } else { |
366 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 365 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
367 | PhoneNumber::List::Iterator phoneItAD; | 366 | PhoneNumber::List::Iterator phoneItAD; |
368 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 367 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
369 | bool found = false; | 368 | bool found = false; |
370 | PhoneNumber::List::Iterator it; | 369 | PhoneNumber::List::Iterator it; |
371 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 370 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
372 | if ( ( *phoneItAD ).contains( (*it) ) ) { | 371 | if ( ( *phoneItAD ).contains( (*it) ) ) { |
373 | found = true; | 372 | found = true; |
374 | (*it).setType( ( *phoneItAD ).type() ); | 373 | (*it).setType( ( *phoneItAD ).type() ); |
375 | (*it).setNumber( ( *phoneItAD ).number() ); | 374 | (*it).setNumber( ( *phoneItAD ).number() ); |
376 | break; | 375 | break; |
377 | } | 376 | } |
378 | } | 377 | } |
379 | if ( ! found ) { // append numbers which do not have work or home type | 378 | if ( ! found ) { // append numbers which do not have work or home type |
380 | if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) ) | 379 | if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) ) |
381 | mData->phoneNumbers.append( *phoneItAD ); | 380 | mData->phoneNumbers.append( *phoneItAD ); |
382 | } | 381 | } |
383 | } | 382 | } |
384 | } | 383 | } |
385 | if ( isSubSet ) { | 384 | if ( isSubSet ) { |
386 | // ************* emails; | 385 | // ************* emails; |
387 | t = mData->emails; | 386 | t = mData->emails; |
388 | tAD = ad.mData->emails; | 387 | tAD = ad.mData->emails; |
389 | for ( iii = 0; iii < tAD.count(); ++iii) | 388 | for ( iii = 0; iii < tAD.count(); ++iii) |
390 | if ( !t.contains(tAD[iii] ) ) | 389 | if ( !t.contains(tAD[iii] ) ) |
391 | mData->emails.append( tAD[iii] ); | 390 | mData->emails.append( tAD[iii] ); |
392 | } | 391 | } |
393 | 392 | ||
394 | // ************* categories; | 393 | // ************* categories; |
395 | if ( isSubSet ) { | 394 | if ( isSubSet ) { |
396 | t = mData->categories; | 395 | t = mData->categories; |
397 | tAD = ad.mData->categories; | 396 | tAD = ad.mData->categories; |
398 | for ( iii = 0; iii < tAD.count(); ++iii) | 397 | for ( iii = 0; iii < tAD.count(); ++iii) |
399 | if ( !t.contains(tAD[iii] ) ) | 398 | if ( !t.contains(tAD[iii] ) ) |
400 | mData->categories.append( tAD[iii] ); | 399 | mData->categories.append( tAD[iii] ); |
401 | } | 400 | } |
402 | QStringList::ConstIterator it; | 401 | QStringList::ConstIterator it; |
403 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { | 402 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { |
404 | QString qualifiedName = (*it).left( (*it).find( ":" )); | 403 | QString qualifiedName = (*it).left( (*it).find( ":" )); |
405 | bool found = false; | 404 | bool found = false; |
406 | QStringList::ConstIterator itL; | 405 | QStringList::ConstIterator itL; |
407 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { | 406 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { |
408 | if ( (*itL).startsWith( qualifiedName ) ) { | 407 | if ( (*itL).startsWith( qualifiedName ) ) { |
409 | found = true; | 408 | found = true; |
410 | break; | 409 | break; |
411 | } | 410 | } |
412 | } | 411 | } |
413 | if ( ! found ) { | 412 | if ( ! found ) { |
414 | mData->custom.append( *it ); | 413 | mData->custom.append( *it ); |
415 | } | 414 | } |
416 | } | 415 | } |
417 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; | 416 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; |
418 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; | 417 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; |
419 | if ( !mData->sound.isIntern() ) { | 418 | if ( !mData->sound.isIntern() ) { |
420 | if ( mData->sound.url().isEmpty() ) { | 419 | if ( mData->sound.url().isEmpty() ) { |
421 | mData->sound = ad.mData->sound; | 420 | mData->sound = ad.mData->sound; |
422 | } | 421 | } |
423 | } | 422 | } |
424 | if ( !mData->agent.isIntern() ) { | 423 | if ( !mData->agent.isIntern() ) { |
425 | if ( mData->agent.url().isEmpty() ) { | 424 | if ( mData->agent.url().isEmpty() ) { |
426 | mData->agent = ad.mData->agent; | 425 | mData->agent = ad.mData->agent; |
427 | } | 426 | } |
428 | } | 427 | } |
429 | { | 428 | { |
430 | Key::List::Iterator itA; | 429 | Key::List::Iterator itA; |
431 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { | 430 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { |
432 | bool found = false; | 431 | bool found = false; |
433 | Key::List::Iterator it; | 432 | Key::List::Iterator it; |
434 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 433 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
435 | if ( (*it) == (*itA)) { | 434 | if ( (*it) == (*itA)) { |
436 | found = true; | 435 | found = true; |
437 | break; | 436 | break; |
438 | 437 | ||
439 | } | 438 | } |
440 | } | 439 | } |
441 | if ( ! found ) { | 440 | if ( ! found ) { |
442 | mData->keys.append( *itA ); | 441 | mData->keys.append( *itA ); |
443 | } | 442 | } |
444 | } | 443 | } |
445 | } | 444 | } |
446 | if ( isSubSet ) { | 445 | if ( isSubSet ) { |
447 | KABC::Address::List::Iterator addressIterA; | 446 | KABC::Address::List::Iterator addressIterA; |
448 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { | 447 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { |
449 | bool found = false; | 448 | bool found = false; |
450 | KABC::Address::List::Iterator addressIter; | 449 | KABC::Address::List::Iterator addressIter; |
451 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 450 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
452 | ++addressIter ) { | 451 | ++addressIter ) { |
453 | if ( (*addressIter) == (*addressIterA)) { | 452 | if ( (*addressIter) == (*addressIterA)) { |
454 | found = true; | 453 | found = true; |
455 | (*addressIter).setType( (*addressIterA).type() ); | 454 | (*addressIter).setType( (*addressIterA).type() ); |
456 | break; | 455 | break; |
457 | } | 456 | } |
458 | 457 | ||
459 | } | 458 | } |
460 | if ( isSubSet && ! found ) { | 459 | if ( isSubSet && ! found ) { |
461 | mData->addresses.append( *addressIterA ); | 460 | mData->addresses.append( *addressIterA ); |
462 | } | 461 | } |
463 | } | 462 | } |
464 | } | 463 | } |
465 | //qDebug("merge contact %s ", ad.uid().latin1()); | 464 | //qDebug("merge contact %s ", ad.uid().latin1()); |
466 | setUid( ad.uid() ); | 465 | setUid( ad.uid() ); |
467 | setRevision( ad.revision() ); | 466 | setRevision( ad.revision() ); |
468 | } | 467 | } |
469 | 468 | ||
470 | bool Addressee::removeVoice() | 469 | bool Addressee::removeVoice() |
471 | { | 470 | { |
472 | PhoneNumber::List phoneN = phoneNumbers(); | 471 | PhoneNumber::List phoneN = phoneNumbers(); |
473 | PhoneNumber::List::Iterator phoneIt; | 472 | PhoneNumber::List::Iterator phoneIt; |
474 | bool found = false; | 473 | bool found = false; |
475 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 474 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
476 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 475 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
477 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 476 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
478 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 477 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
479 | insertPhoneNumber( (*phoneIt) ); | 478 | insertPhoneNumber( (*phoneIt) ); |
480 | found = true; | 479 | found = true; |
481 | } | 480 | } |
482 | } | 481 | } |
483 | 482 | ||
484 | } | 483 | } |
485 | return found; | 484 | return found; |
486 | } | 485 | } |
487 | 486 | ||
488 | bool Addressee::containsAdr(const Addressee& ad ) | 487 | bool Addressee::containsAdr(const Addressee& ad ) |
489 | { | 488 | { |
490 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; | 489 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; |
491 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; | 490 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; |
492 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; | 491 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; |
493 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; | 492 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; |
494 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; | 493 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; |
495 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; | 494 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; |
496 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; | 495 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; |
497 | 496 | ||
498 | // compare phone numbers | 497 | // compare phone numbers |
499 | PhoneNumber::List phoneN = ad.phoneNumbers(); | 498 | PhoneNumber::List phoneN = ad.phoneNumbers(); |
500 | PhoneNumber::List::Iterator phoneIt; | 499 | PhoneNumber::List::Iterator phoneIt; |
501 | bool found = false; | 500 | bool found = false; |
502 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 501 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
503 | bool found = false; | 502 | bool found = false; |
504 | PhoneNumber::List phoneL = ad.phoneNumbers(); | 503 | PhoneNumber::List phoneL = ad.phoneNumbers(); |
505 | PhoneNumber::List::Iterator phoneItL; | 504 | PhoneNumber::List::Iterator phoneItL; |
506 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { | 505 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { |
507 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { | 506 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { |
508 | found = true; | 507 | found = true; |
509 | break; | 508 | break; |
510 | } | 509 | } |
511 | } | 510 | } |
512 | if ( ! found ) | 511 | if ( ! found ) |
513 | return false; | 512 | return false; |
514 | } | 513 | } |
515 | return true; | 514 | return true; |
516 | 515 | ||
517 | } | 516 | } |
518 | void Addressee::simplifyAddresses() | 517 | void Addressee::simplifyAddresses() |
519 | { | 518 | { |
520 | 519 | ||
521 | 520 | ||
522 | Address::List list; | 521 | Address::List list; |
523 | Address::List::Iterator it; | 522 | Address::List::Iterator it; |
524 | Address::List::Iterator it2; | 523 | Address::List::Iterator it2; |
525 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 524 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
526 | it2 = it; | 525 | it2 = it; |
527 | ++it2; | 526 | ++it2; |
528 | for( ; it2 != mData->addresses.end(); ++it2 ) { | 527 | for( ; it2 != mData->addresses.end(); ++it2 ) { |
529 | if ( (*it) == (*it2) ) { | 528 | if ( (*it) == (*it2) ) { |
530 | list.append( *it ); | 529 | list.append( *it ); |
531 | break; | 530 | break; |
532 | } | 531 | } |
533 | } | 532 | } |
534 | } | 533 | } |
535 | for( it = list.begin(); it != list.end(); ++it ) { | 534 | for( it = list.begin(); it != list.end(); ++it ) { |
536 | removeAddress( (*it) ); | 535 | removeAddress( (*it) ); |
537 | } | 536 | } |
538 | 537 | ||
539 | list.clear(); | 538 | list.clear(); |
540 | int max = 2; | 539 | int max = 2; |
541 | if ( mData->url.isValid() ) | 540 | if ( mData->url.isValid() ) |
542 | max = 1; | 541 | max = 1; |
543 | if ( mData->addresses.count() <= max ) return ; | 542 | if ( mData->addresses.count() <= max ) return ; |
544 | int count = 0; | 543 | int count = 0; |
545 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 544 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
546 | if ( count >= max ) | 545 | if ( count >= max ) |
547 | list.append( *it ); | 546 | list.append( *it ); |
548 | ++count; | 547 | ++count; |
549 | } | 548 | } |
550 | for( it = list.begin(); it != list.end(); ++it ) { | 549 | for( it = list.begin(); it != list.end(); ++it ) { |
551 | removeAddress( (*it) ); | 550 | removeAddress( (*it) ); |
552 | } | 551 | } |
553 | } | 552 | } |
554 | 553 | ||
555 | // removes all emails but the first | 554 | // removes all emails but the first |
556 | // needed by phone sync | 555 | // needed by phone sync |
557 | void Addressee::simplifyEmails() | 556 | void Addressee::simplifyEmails() |
558 | { | 557 | { |
559 | if ( mData->emails.count() == 0 ) return ; | 558 | if ( mData->emails.count() == 0 ) return ; |
560 | QString email = mData->emails.first(); | 559 | QString email = mData->emails.first(); |
561 | detach(); | 560 | detach(); |
562 | mData->emails.clear(); | 561 | mData->emails.clear(); |
563 | mData->emails.append( email ); | 562 | mData->emails.append( email ); |
564 | } | 563 | } |
565 | 564 | ||
566 | void Addressee::simplifyPhoneNumbers() | 565 | void Addressee::simplifyPhoneNumbers() |
567 | { | 566 | { |
568 | int max = 4; | 567 | int max = 4; |
569 | int inList = mData->phoneNumbers.count(); | 568 | int inList = mData->phoneNumbers.count(); |
570 | KABC::PhoneNumber::List removeNumbers; | 569 | KABC::PhoneNumber::List removeNumbers; |
571 | KABC::PhoneNumber::List::Iterator phoneIter; | 570 | KABC::PhoneNumber::List::Iterator phoneIter; |
572 | if ( inList > max ) { | 571 | if ( inList > max ) { |
573 | // delete non-preferred numbers | 572 | // delete non-preferred numbers |
574 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 573 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
575 | ++phoneIter ) { | 574 | ++phoneIter ) { |
576 | if ( inList > max ) { | 575 | if ( inList > max ) { |
577 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { | 576 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { |
578 | removeNumbers.append( ( *phoneIter ) ); | 577 | removeNumbers.append( ( *phoneIter ) ); |
579 | --inList; | 578 | --inList; |
580 | } | 579 | } |
581 | } else | 580 | } else |
582 | break; | 581 | break; |
583 | } | 582 | } |
584 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 583 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
585 | ++phoneIter ) { | 584 | ++phoneIter ) { |
586 | removePhoneNumber(( *phoneIter )); | 585 | removePhoneNumber(( *phoneIter )); |
587 | } | 586 | } |
588 | // delete preferred numbers | 587 | // delete preferred numbers |
589 | if ( inList > max ) { | 588 | if ( inList > max ) { |
590 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 589 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
591 | ++phoneIter ) { | 590 | ++phoneIter ) { |
592 | if ( inList > max ) { | 591 | if ( inList > max ) { |
593 | removeNumbers.append( ( *phoneIter ) ); | 592 | removeNumbers.append( ( *phoneIter ) ); |
594 | --inList; | 593 | --inList; |
595 | } else | 594 | } else |
596 | break; | 595 | break; |
597 | } | 596 | } |
598 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 597 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
599 | ++phoneIter ) { | 598 | ++phoneIter ) { |
600 | removePhoneNumber(( *phoneIter )); | 599 | removePhoneNumber(( *phoneIter )); |
601 | } | 600 | } |
602 | } | 601 | } |
603 | } | 602 | } |
604 | // remove non-numeric characters | 603 | // remove non-numeric characters |
605 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 604 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
606 | ++phoneIter ) { | 605 | ++phoneIter ) { |
607 | if ( ! ( *phoneIter ).simplifyNumber() ) | 606 | if ( ! ( *phoneIter ).simplifyNumber() ) |
608 | removeNumbers.append( ( *phoneIter ) ); | 607 | removeNumbers.append( ( *phoneIter ) ); |
609 | } | 608 | } |
610 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 609 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
611 | ++phoneIter ) { | 610 | ++phoneIter ) { |
612 | removePhoneNumber(( *phoneIter )); | 611 | removePhoneNumber(( *phoneIter )); |
613 | } | 612 | } |
614 | } | 613 | } |
615 | void Addressee::simplifyPhoneNumberTypes() | 614 | void Addressee::simplifyPhoneNumberTypes() |
616 | { | 615 | { |
617 | KABC::PhoneNumber::List::Iterator phoneIter; | 616 | KABC::PhoneNumber::List::Iterator phoneIter; |
618 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 617 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
619 | ++phoneIter ) | 618 | ++phoneIter ) |
620 | ( *phoneIter ).simplifyType(); | 619 | ( *phoneIter ).simplifyType(); |
621 | } | 620 | } |
622 | void Addressee::removeID(const QString &prof) | 621 | void Addressee::removeID(const QString &prof) |
623 | { | 622 | { |
624 | detach(); | 623 | detach(); |
625 | if ( prof.isEmpty() ) | 624 | if ( prof.isEmpty() ) |
626 | mData->mExternalId = ":"; | 625 | mData->mExternalId = ":"; |
627 | else | 626 | else |
628 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 627 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
629 | 628 | ||
630 | } | 629 | } |
631 | void Addressee::setID( const QString & prof , const QString & id ) | 630 | void Addressee::setID( const QString & prof , const QString & id ) |
632 | { | 631 | { |
633 | detach(); | 632 | detach(); |
634 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 633 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
635 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 634 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
636 | } | 635 | } |
637 | void Addressee::setTempSyncStat( int id ) | 636 | void Addressee::setTempSyncStat( int id ) |
638 | { | 637 | { |
639 | if ( mData->mTempSyncStat == id ) return; | 638 | if ( mData->mTempSyncStat == id ) return; |
640 | detach(); | 639 | detach(); |
641 | mData->mTempSyncStat = id; | 640 | mData->mTempSyncStat = id; |
642 | } | 641 | } |
643 | int Addressee::tempSyncStat() const | 642 | int Addressee::tempSyncStat() const |
644 | { | 643 | { |
645 | return mData->mTempSyncStat; | 644 | return mData->mTempSyncStat; |
646 | } | 645 | } |
647 | 646 | ||
648 | const QString Addressee::getID( const QString & prof) const | 647 | const QString Addressee::getID( const QString & prof) const |
649 | { | 648 | { |
650 | return KIdManager::getId ( mData->mExternalId, prof ); | 649 | return KIdManager::getId ( mData->mExternalId, prof ); |
651 | } | 650 | } |
652 | 651 | ||
653 | void Addressee::setCsum( const QString & prof , const QString & id ) | 652 | void Addressee::setCsum( const QString & prof , const QString & id ) |
654 | { | 653 | { |
655 | detach(); | 654 | detach(); |
656 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 655 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
657 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 656 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
658 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 657 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
659 | } | 658 | } |
660 | 659 | ||
661 | const QString Addressee::getCsum( const QString & prof) const | 660 | const QString Addressee::getCsum( const QString & prof) const |
662 | { | 661 | { |
663 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 662 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
664 | } | 663 | } |
665 | 664 | ||
666 | void Addressee::setIDStr( const QString & s ) | 665 | void Addressee::setIDStr( const QString & s ) |
667 | { | 666 | { |
668 | detach(); | 667 | detach(); |
669 | mData->mExternalId = s; | 668 | mData->mExternalId = s; |
670 | } | 669 | } |
671 | 670 | ||
672 | const QString Addressee::IDStr() const | 671 | const QString Addressee::IDStr() const |
673 | { | 672 | { |
674 | return mData->mExternalId; | 673 | return mData->mExternalId; |
675 | } | 674 | } |
676 | 675 | ||
677 | void Addressee::setExternalUID( const QString &id ) | 676 | void Addressee::setExternalUID( const QString &id ) |
678 | { | 677 | { |
679 | if ( id == mData->externalUID ) return; | 678 | if ( id == mData->externalUID ) return; |
680 | detach(); | 679 | detach(); |
681 | mData->empty = false; | 680 | mData->empty = false; |
682 | mData->externalUID = id; | 681 | mData->externalUID = id; |
683 | } | 682 | } |
684 | 683 | ||
685 | const QString Addressee::externalUID() const | 684 | const QString Addressee::externalUID() const |
686 | { | 685 | { |
687 | return mData->externalUID; | 686 | return mData->externalUID; |
688 | } | 687 | } |
689 | void Addressee::setOriginalExternalUID( const QString &id ) | 688 | void Addressee::setOriginalExternalUID( const QString &id ) |
690 | { | 689 | { |
691 | if ( id == mData->originalExternalUID ) return; | 690 | if ( id == mData->originalExternalUID ) return; |
692 | detach(); | 691 | detach(); |
693 | mData->empty = false; | 692 | mData->empty = false; |
694 | //qDebug("*******Set orig uid %s ", id.latin1()); | 693 | //qDebug("*******Set orig uid %s ", id.latin1()); |
695 | mData->originalExternalUID = id; | 694 | mData->originalExternalUID = id; |
696 | } | 695 | } |
697 | 696 | ||
698 | QString Addressee::originalExternalUID() const | 697 | QString Addressee::originalExternalUID() const |
699 | { | 698 | { |
700 | return mData->originalExternalUID; | 699 | return mData->originalExternalUID; |
701 | } | 700 | } |
702 | 701 | ||
703 | void Addressee::setUid( const QString &id ) | 702 | void Addressee::setUid( const QString &id ) |
704 | { | 703 | { |
705 | if ( id == mData->uid ) return; | 704 | if ( id == mData->uid ) return; |
706 | detach(); | 705 | detach(); |
707 | //qDebug("****setuid %s ", id.latin1()); | 706 | //qDebug("****setuid %s ", id.latin1()); |
708 | mData->empty = false; | 707 | mData->empty = false; |
709 | mData->uid = id; | 708 | mData->uid = id; |
710 | } | 709 | } |
711 | 710 | ||
712 | const QString Addressee::uid() const | 711 | const QString Addressee::uid() const |
713 | { | 712 | { |
714 | if ( mData->uid.isEmpty() ) | 713 | if ( mData->uid.isEmpty() ) |
715 | mData->uid = KApplication::randomString( 10 ); | 714 | mData->uid = KApplication::randomString( 10 ); |
716 | 715 | ||
717 | return mData->uid; | 716 | return mData->uid; |
718 | } | 717 | } |
719 | 718 | ||
720 | QString Addressee::uidLabel() | 719 | QString Addressee::uidLabel() |
721 | { | 720 | { |
722 | return i18n("Unique Identifier"); | 721 | return i18n("Unique Identifier"); |
723 | } | 722 | } |
724 | 723 | ||
725 | void Addressee::setName( const QString &name ) | 724 | void Addressee::setName( const QString &name ) |
726 | { | 725 | { |
727 | if ( name == mData->name ) return; | 726 | if ( name == mData->name ) return; |
728 | detach(); | 727 | detach(); |
729 | mData->empty = false; | 728 | mData->empty = false; |
730 | mData->name = name; | 729 | mData->name = name; |
731 | } | 730 | } |
732 | 731 | ||
733 | QString Addressee::name() const | 732 | QString Addressee::name() const |
734 | { | 733 | { |
735 | return mData->name; | 734 | return mData->name; |
736 | } | 735 | } |
737 | 736 | ||
738 | QString Addressee::nameLabel() | 737 | QString Addressee::nameLabel() |
739 | { | 738 | { |
740 | return i18n("Name"); | 739 | return i18n("Name"); |
741 | } | 740 | } |
742 | 741 | ||
743 | 742 | ||
744 | void Addressee::setFormattedName( const QString &formattedName ) | 743 | void Addressee::setFormattedName( const QString &formattedName ) |
745 | { | 744 | { |
746 | if ( formattedName == mData->formattedName ) return; | 745 | if ( formattedName == mData->formattedName ) return; |
747 | detach(); | 746 | detach(); |
748 | mData->empty = false; | 747 | mData->empty = false; |
749 | mData->formattedName = formattedName; | 748 | mData->formattedName = formattedName; |
750 | } | 749 | } |
751 | void Addressee::setDefaultFormattedName( const QString &formattedName ) | ||
752 | { | ||
753 | if ( formattedName == mData->defaultFormattedName ) return; | ||
754 | detach(); | ||
755 | mData->empty = false; | ||
756 | mData->defaultFormattedName = formattedName; | ||
757 | } | ||
758 | 750 | ||
759 | QString Addressee::formattedName() const | 751 | QString Addressee::formattedName() const |
760 | { | 752 | { |
761 | return mData->formattedName; | 753 | return mData->formattedName; |
762 | } | 754 | } |
763 | QString Addressee::defaultFormattedName() const | ||
764 | { | ||
765 | return mData->defaultFormattedName; | ||
766 | } | ||
767 | 755 | ||
768 | QString Addressee::formattedNameLabel() | 756 | QString Addressee::formattedNameLabel() |
769 | { | 757 | { |
770 | return i18n("Formatted Name"); | 758 | return i18n("Formatted Name"); |
771 | } | 759 | } |
772 | 760 | ||
773 | QString Addressee::defaultFormattedNameLabel() | ||
774 | { | ||
775 | return i18n("Def.Formatted Name"); | ||
776 | } | ||
777 | |||
778 | 761 | ||
779 | void Addressee::setFamilyName( const QString &familyName ) | 762 | void Addressee::setFamilyName( const QString &familyName ) |
780 | { | 763 | { |
781 | if ( familyName == mData->familyName ) return; | 764 | if ( familyName == mData->familyName ) return; |
782 | detach(); | 765 | detach(); |
783 | mData->empty = false; | 766 | mData->empty = false; |
784 | mData->familyName = familyName; | 767 | mData->familyName = familyName; |
785 | } | 768 | } |
786 | 769 | ||
787 | QString Addressee::familyName() const | 770 | QString Addressee::familyName() const |
788 | { | 771 | { |
789 | return mData->familyName; | 772 | return mData->familyName; |
790 | } | 773 | } |
791 | 774 | ||
792 | QString Addressee::familyNameLabel() | 775 | QString Addressee::familyNameLabel() |
793 | { | 776 | { |
794 | return i18n("Family Name"); | 777 | return i18n("Family Name"); |
795 | } | 778 | } |
796 | 779 | ||
797 | 780 | ||
798 | void Addressee::setGivenName( const QString &givenName ) | 781 | void Addressee::setGivenName( const QString &givenName ) |
799 | { | 782 | { |
800 | if ( givenName == mData->givenName ) return; | 783 | if ( givenName == mData->givenName ) return; |
801 | detach(); | 784 | detach(); |
802 | mData->empty = false; | 785 | mData->empty = false; |
803 | mData->givenName = givenName; | 786 | mData->givenName = givenName; |
804 | } | 787 | } |
805 | 788 | ||
806 | QString Addressee::givenName() const | 789 | QString Addressee::givenName() const |
807 | { | 790 | { |
808 | return mData->givenName; | 791 | return mData->givenName; |
809 | } | 792 | } |
810 | 793 | ||
811 | QString Addressee::givenNameLabel() | 794 | QString Addressee::givenNameLabel() |
812 | { | 795 | { |
813 | return i18n("Given Name"); | 796 | return i18n("Given Name"); |
814 | } | 797 | } |
815 | 798 | ||
816 | 799 | ||
817 | void Addressee::setAdditionalName( const QString &additionalName ) | 800 | void Addressee::setAdditionalName( const QString &additionalName ) |
818 | { | 801 | { |
819 | if ( additionalName == mData->additionalName ) return; | 802 | if ( additionalName == mData->additionalName ) return; |
820 | detach(); | 803 | detach(); |
821 | mData->empty = false; | 804 | mData->empty = false; |
822 | mData->additionalName = additionalName; | 805 | mData->additionalName = additionalName; |
823 | } | 806 | } |
824 | 807 | ||
825 | QString Addressee::additionalName() const | 808 | QString Addressee::additionalName() const |
826 | { | 809 | { |
827 | return mData->additionalName; | 810 | return mData->additionalName; |
828 | } | 811 | } |
829 | 812 | ||
830 | QString Addressee::additionalNameLabel() | 813 | QString Addressee::additionalNameLabel() |
831 | { | 814 | { |
832 | return i18n("Additional Names"); | 815 | return i18n("Additional Names"); |
833 | } | 816 | } |
834 | 817 | ||
835 | 818 | ||
836 | void Addressee::setPrefix( const QString &prefix ) | 819 | void Addressee::setPrefix( const QString &prefix ) |
837 | { | 820 | { |
838 | if ( prefix == mData->prefix ) return; | 821 | if ( prefix == mData->prefix ) return; |
839 | detach(); | 822 | detach(); |
840 | mData->empty = false; | 823 | mData->empty = false; |
841 | mData->prefix = prefix; | 824 | mData->prefix = prefix; |
842 | } | 825 | } |
843 | 826 | ||
844 | QString Addressee::prefix() const | 827 | QString Addressee::prefix() const |
845 | { | 828 | { |
846 | return mData->prefix; | 829 | return mData->prefix; |
847 | } | 830 | } |
848 | 831 | ||
849 | QString Addressee::prefixLabel() | 832 | QString Addressee::prefixLabel() |
850 | { | 833 | { |
851 | return i18n("Honorific Prefixes"); | 834 | return i18n("Honorific Prefixes"); |
852 | } | 835 | } |
853 | 836 | ||
854 | 837 | ||
855 | void Addressee::setSuffix( const QString &suffix ) | 838 | void Addressee::setSuffix( const QString &suffix ) |
856 | { | 839 | { |
857 | if ( suffix == mData->suffix ) return; | 840 | if ( suffix == mData->suffix ) return; |
858 | detach(); | 841 | detach(); |
859 | mData->empty = false; | 842 | mData->empty = false; |
860 | mData->suffix = suffix; | 843 | mData->suffix = suffix; |
861 | } | 844 | } |
862 | 845 | ||
863 | QString Addressee::suffix() const | 846 | QString Addressee::suffix() const |
864 | { | 847 | { |
865 | return mData->suffix; | 848 | return mData->suffix; |
866 | } | 849 | } |
867 | 850 | ||
868 | QString Addressee::suffixLabel() | 851 | QString Addressee::suffixLabel() |
869 | { | 852 | { |
870 | return i18n("Honorific Suffixes"); | 853 | return i18n("Honorific Suffixes"); |
871 | } | 854 | } |
872 | 855 | ||
873 | 856 | ||
874 | void Addressee::setNickName( const QString &nickName ) | 857 | void Addressee::setNickName( const QString &nickName ) |
875 | { | 858 | { |
876 | if ( nickName == mData->nickName ) return; | 859 | if ( nickName == mData->nickName ) return; |
877 | detach(); | 860 | detach(); |
878 | mData->empty = false; | 861 | mData->empty = false; |
879 | mData->nickName = nickName; | 862 | mData->nickName = nickName; |
880 | } | 863 | } |
881 | 864 | ||
882 | QString Addressee::nickName() const | 865 | QString Addressee::nickName() const |
883 | { | 866 | { |
884 | return mData->nickName; | 867 | return mData->nickName; |
885 | } | 868 | } |
886 | 869 | ||
887 | QString Addressee::nickNameLabel() | 870 | QString Addressee::nickNameLabel() |
888 | { | 871 | { |
889 | return i18n("Nick Name"); | 872 | return i18n("Nick Name"); |
890 | } | 873 | } |
891 | 874 | ||
892 | 875 | ||
893 | void Addressee::setBirthday( const QDateTime &birthday ) | 876 | void Addressee::setBirthday( const QDateTime &birthday ) |
894 | { | 877 | { |
895 | if ( birthday == mData->birthday ) return; | 878 | if ( birthday == mData->birthday ) return; |
896 | detach(); | 879 | detach(); |
897 | mData->empty = false; | 880 | mData->empty = false; |
898 | mData->birthday = birthday; | 881 | mData->birthday = birthday; |
899 | } | 882 | } |
900 | 883 | ||
901 | QDateTime Addressee::birthday() const | 884 | QDateTime Addressee::birthday() const |
902 | { | 885 | { |
903 | return mData->birthday; | 886 | return mData->birthday; |
904 | } | 887 | } |
905 | 888 | ||
906 | QString Addressee::birthdayLabel() | 889 | QString Addressee::birthdayLabel() |
907 | { | 890 | { |
908 | return i18n("Birthday"); | 891 | return i18n("Birthday"); |
909 | } | 892 | } |
910 | 893 | ||
911 | 894 | ||
912 | QString Addressee::homeAddressStreetLabel() | 895 | QString Addressee::homeAddressStreetLabel() |
913 | { | 896 | { |
914 | return i18n("Home Address Street"); | 897 | return i18n("Home Address Street"); |
915 | } | 898 | } |
916 | 899 | ||
917 | 900 | ||
918 | QString Addressee::homeAddressLocalityLabel() | 901 | QString Addressee::homeAddressLocalityLabel() |
919 | { | 902 | { |
920 | return i18n("Home Address Locality"); | 903 | return i18n("Home Address Locality"); |
921 | } | 904 | } |
922 | 905 | ||
923 | 906 | ||
924 | QString Addressee::homeAddressRegionLabel() | 907 | QString Addressee::homeAddressRegionLabel() |
925 | { | 908 | { |
926 | return i18n("Home Address Region"); | 909 | return i18n("Home Address Region"); |
927 | } | 910 | } |
928 | 911 | ||
929 | 912 | ||
930 | QString Addressee::homeAddressPostalCodeLabel() | 913 | QString Addressee::homeAddressPostalCodeLabel() |
931 | { | 914 | { |
932 | return i18n("Home Address Postal Code"); | 915 | return i18n("Home Address Postal Code"); |
933 | } | 916 | } |
934 | 917 | ||
935 | 918 | ||
936 | QString Addressee::homeAddressCountryLabel() | 919 | QString Addressee::homeAddressCountryLabel() |
937 | { | 920 | { |
938 | return i18n("Home Address Country"); | 921 | return i18n("Home Address Country"); |
939 | } | 922 | } |
940 | 923 | ||
941 | 924 | ||
942 | QString Addressee::homeAddressLabelLabel() | 925 | QString Addressee::homeAddressLabelLabel() |
943 | { | 926 | { |
944 | return i18n("Home Address Label"); | 927 | return i18n("Home Address Label"); |
945 | } | 928 | } |
946 | 929 | ||
947 | 930 | ||
948 | QString Addressee::businessAddressStreetLabel() | 931 | QString Addressee::businessAddressStreetLabel() |
949 | { | 932 | { |
950 | return i18n("Business Address Street"); | 933 | return i18n("Business Address Street"); |
951 | } | 934 | } |
952 | 935 | ||
953 | 936 | ||
954 | QString Addressee::businessAddressLocalityLabel() | 937 | QString Addressee::businessAddressLocalityLabel() |
955 | { | 938 | { |
956 | return i18n("Business Address Locality"); | 939 | return i18n("Business Address Locality"); |
957 | } | 940 | } |
958 | 941 | ||
959 | 942 | ||
960 | QString Addressee::businessAddressRegionLabel() | 943 | QString Addressee::businessAddressRegionLabel() |
961 | { | 944 | { |
962 | return i18n("Business Address Region"); | 945 | return i18n("Business Address Region"); |
963 | } | 946 | } |
964 | 947 | ||
965 | 948 | ||
966 | QString Addressee::businessAddressPostalCodeLabel() | 949 | QString Addressee::businessAddressPostalCodeLabel() |
967 | { | 950 | { |
968 | return i18n("Business Address Postal Code"); | 951 | return i18n("Business Address Postal Code"); |
969 | } | 952 | } |
970 | 953 | ||
971 | 954 | ||
972 | QString Addressee::businessAddressCountryLabel() | 955 | QString Addressee::businessAddressCountryLabel() |
973 | { | 956 | { |
974 | return i18n("Business Address Country"); | 957 | return i18n("Business Address Country"); |
975 | } | 958 | } |
976 | 959 | ||
977 | 960 | ||
978 | QString Addressee::businessAddressLabelLabel() | 961 | QString Addressee::businessAddressLabelLabel() |
979 | { | 962 | { |
980 | return i18n("Business Address Label"); | 963 | return i18n("Business Address Label"); |
981 | } | 964 | } |
982 | 965 | ||
983 | 966 | ||
984 | QString Addressee::homePhoneLabel() | 967 | QString Addressee::homePhoneLabel() |
985 | { | 968 | { |
986 | return i18n("Home Phone"); | 969 | return i18n("Home Phone"); |
987 | } | 970 | } |
988 | 971 | ||
989 | 972 | ||
990 | QString Addressee::businessPhoneLabel() | 973 | QString Addressee::businessPhoneLabel() |
991 | { | 974 | { |
992 | return i18n("Business Phone"); | 975 | return i18n("Business Phone"); |
993 | } | 976 | } |
994 | 977 | ||
995 | 978 | ||
996 | QString Addressee::mobilePhoneLabel() | 979 | QString Addressee::mobilePhoneLabel() |
997 | { | 980 | { |
998 | return i18n("Mobile Phone"); | 981 | return i18n("Mobile Phone"); |
999 | } | 982 | } |
1000 | QString Addressee::mobileWorkPhoneLabel() | 983 | QString Addressee::mobileWorkPhoneLabel() |
1001 | { | 984 | { |
1002 | return i18n("Mobile (work)"); | 985 | return i18n("Mobile (work)"); |
1003 | } | 986 | } |
1004 | QString Addressee::mobileHomePhoneLabel() | 987 | QString Addressee::mobileHomePhoneLabel() |
1005 | { | 988 | { |
1006 | return i18n("Mobile (home)"); | 989 | return i18n("Mobile (home)"); |
1007 | } | 990 | } |
1008 | 991 | ||
1009 | 992 | ||
1010 | QString Addressee::homeFaxLabel() | 993 | QString Addressee::homeFaxLabel() |
1011 | { | 994 | { |
1012 | return i18n("Home Fax"); | 995 | return i18n("Home Fax"); |
1013 | } | 996 | } |
1014 | 997 | ||
1015 | 998 | ||
1016 | QString Addressee::businessFaxLabel() | 999 | QString Addressee::businessFaxLabel() |
1017 | { | 1000 | { |
1018 | return i18n("Business Fax"); | 1001 | return i18n("Business Fax"); |
1019 | } | 1002 | } |
1020 | 1003 | ||
1021 | 1004 | ||
1022 | QString Addressee::carPhoneLabel() | 1005 | QString Addressee::carPhoneLabel() |
1023 | { | 1006 | { |
1024 | return i18n("Car Phone"); | 1007 | return i18n("Car Phone"); |
1025 | } | 1008 | } |
1026 | 1009 | ||
1027 | 1010 | ||
1028 | QString Addressee::isdnLabel() | 1011 | QString Addressee::isdnLabel() |
1029 | { | 1012 | { |
1030 | return i18n("ISDN"); | 1013 | return i18n("ISDN"); |
1031 | } | 1014 | } |
1032 | 1015 | ||
1033 | 1016 | ||
1034 | QString Addressee::pagerLabel() | 1017 | QString Addressee::pagerLabel() |
1035 | { | 1018 | { |
1036 | return i18n("Pager"); | 1019 | return i18n("Pager"); |
1037 | } | 1020 | } |
1038 | 1021 | ||
1039 | QString Addressee::sipLabel() | 1022 | QString Addressee::sipLabel() |
1040 | { | 1023 | { |
1041 | return i18n("SIP"); | 1024 | return i18n("SIP"); |
1042 | } | 1025 | } |
1043 | 1026 | ||
1044 | QString Addressee::emailLabel() | 1027 | QString Addressee::emailLabel() |
1045 | { | 1028 | { |
1046 | return i18n("Email Address"); | 1029 | return i18n("Email Address"); |
1047 | } | 1030 | } |
1048 | 1031 | ||
1049 | 1032 | ||
1050 | void Addressee::setMailer( const QString &mailer ) | 1033 | void Addressee::setMailer( const QString &mailer ) |
1051 | { | 1034 | { |
1052 | if ( mailer == mData->mailer ) return; | 1035 | if ( mailer == mData->mailer ) return; |
1053 | detach(); | 1036 | detach(); |
1054 | mData->empty = false; | 1037 | mData->empty = false; |
1055 | mData->mailer = mailer; | 1038 | mData->mailer = mailer; |
1056 | } | 1039 | } |
1057 | 1040 | ||
1058 | QString Addressee::mailer() const | 1041 | QString Addressee::mailer() const |
1059 | { | 1042 | { |
1060 | return mData->mailer; | 1043 | return mData->mailer; |
1061 | } | 1044 | } |
1062 | 1045 | ||
1063 | QString Addressee::mailerLabel() | 1046 | QString Addressee::mailerLabel() |
1064 | { | 1047 | { |
1065 | return i18n("Mail Client"); | 1048 | return i18n("Mail Client"); |
1066 | } | 1049 | } |
1067 | 1050 | ||
1068 | 1051 | ||
1069 | void Addressee::setTimeZone( const TimeZone &timeZone ) | 1052 | void Addressee::setTimeZone( const TimeZone &timeZone ) |
1070 | { | 1053 | { |
1071 | if ( timeZone == mData->timeZone ) return; | 1054 | if ( timeZone == mData->timeZone ) return; |
1072 | detach(); | 1055 | detach(); |
1073 | mData->empty = false; | 1056 | mData->empty = false; |
1074 | mData->timeZone = timeZone; | 1057 | mData->timeZone = timeZone; |
1075 | } | 1058 | } |
1076 | 1059 | ||
1077 | TimeZone Addressee::timeZone() const | 1060 | TimeZone Addressee::timeZone() const |
1078 | { | 1061 | { |
1079 | return mData->timeZone; | 1062 | return mData->timeZone; |
1080 | } | 1063 | } |
1081 | 1064 | ||
1082 | QString Addressee::timeZoneLabel() | 1065 | QString Addressee::timeZoneLabel() |
1083 | { | 1066 | { |
1084 | return i18n("Time Zone"); | 1067 | return i18n("Time Zone"); |
1085 | } | 1068 | } |
1086 | 1069 | ||
1087 | 1070 | ||
1088 | void Addressee::setGeo( const Geo &geo ) | 1071 | void Addressee::setGeo( const Geo &geo ) |
1089 | { | 1072 | { |
1090 | if ( geo == mData->geo ) return; | 1073 | if ( geo == mData->geo ) return; |
1091 | detach(); | 1074 | detach(); |
1092 | mData->empty = false; | 1075 | mData->empty = false; |
1093 | mData->geo = geo; | 1076 | mData->geo = geo; |
1094 | } | 1077 | } |
1095 | 1078 | ||
1096 | Geo Addressee::geo() const | 1079 | Geo Addressee::geo() const |
1097 | { | 1080 | { |
1098 | return mData->geo; | 1081 | return mData->geo; |
1099 | } | 1082 | } |
1100 | 1083 | ||
1101 | QString Addressee::geoLabel() | 1084 | QString Addressee::geoLabel() |
1102 | { | 1085 | { |
1103 | return i18n("Geographic Position"); | 1086 | return i18n("Geographic Position"); |
1104 | } | 1087 | } |
1105 | 1088 | ||
1106 | 1089 | ||
1107 | void Addressee::setTitle( const QString &title ) | 1090 | void Addressee::setTitle( const QString &title ) |
1108 | { | 1091 | { |
1109 | if ( title == mData->title ) return; | 1092 | if ( title == mData->title ) return; |
1110 | detach(); | 1093 | detach(); |
1111 | mData->empty = false; | 1094 | mData->empty = false; |
1112 | mData->title = title; | 1095 | mData->title = title; |
1113 | } | 1096 | } |
1114 | 1097 | ||
1115 | QString Addressee::title() const | 1098 | QString Addressee::title() const |
1116 | { | 1099 | { |
1117 | return mData->title; | 1100 | return mData->title; |
1118 | } | 1101 | } |
1119 | 1102 | ||
1120 | QString Addressee::titleLabel() | 1103 | QString Addressee::titleLabel() |
1121 | { | 1104 | { |
1122 | return i18n("Title"); | 1105 | return i18n("Title"); |
1123 | } | 1106 | } |
1124 | 1107 | ||
1125 | 1108 | ||
1126 | void Addressee::setRole( const QString &role ) | 1109 | void Addressee::setRole( const QString &role ) |
1127 | { | 1110 | { |
1128 | if ( role == mData->role ) return; | 1111 | if ( role == mData->role ) return; |
1129 | detach(); | 1112 | detach(); |
1130 | mData->empty = false; | 1113 | mData->empty = false; |
1131 | mData->role = role; | 1114 | mData->role = role; |
1132 | } | 1115 | } |
1133 | 1116 | ||
1134 | QString Addressee::role() const | 1117 | QString Addressee::role() const |
1135 | { | 1118 | { |
1136 | return mData->role; | 1119 | return mData->role; |
1137 | } | 1120 | } |
1138 | 1121 | ||
1139 | QString Addressee::roleLabel() | 1122 | QString Addressee::roleLabel() |
1140 | { | 1123 | { |
1141 | return i18n("Role"); | 1124 | return i18n("Role"); |
1142 | } | 1125 | } |
1143 | 1126 | ||
1144 | 1127 | ||
1145 | void Addressee::setOrganization( const QString &organization ) | 1128 | void Addressee::setOrganization( const QString &organization ) |
1146 | { | 1129 | { |
1147 | if ( organization == mData->organization ) return; | 1130 | if ( organization == mData->organization ) return; |
1148 | detach(); | 1131 | detach(); |
1149 | mData->empty = false; | 1132 | mData->empty = false; |
1150 | mData->organization = organization; | 1133 | mData->organization = organization; |
1151 | } | 1134 | } |
1152 | 1135 | ||
1153 | QString Addressee::organization() const | 1136 | QString Addressee::organization() const |
1154 | { | 1137 | { |
1155 | return mData->organization; | 1138 | return mData->organization; |
1156 | } | 1139 | } |
1157 | 1140 | ||
1158 | QString Addressee::organizationLabel() | 1141 | QString Addressee::organizationLabel() |
1159 | { | 1142 | { |
1160 | return i18n("Organization"); | 1143 | return i18n("Organization"); |
1161 | } | 1144 | } |
1162 | 1145 | ||
1163 | 1146 | ||
1164 | void Addressee::setNote( const QString ¬e ) | 1147 | void Addressee::setNote( const QString ¬e ) |
1165 | { | 1148 | { |
1166 | if ( note == mData->note ) return; | 1149 | if ( note == mData->note ) return; |
1167 | detach(); | 1150 | detach(); |
1168 | mData->empty = false; | 1151 | mData->empty = false; |
1169 | mData->note = note; | 1152 | mData->note = note; |
1170 | } | 1153 | } |
1171 | 1154 | ||
1172 | QString Addressee::note() const | 1155 | QString Addressee::note() const |
1173 | { | 1156 | { |
1174 | return mData->note; | 1157 | return mData->note; |
1175 | } | 1158 | } |
1176 | 1159 | ||
1177 | QString Addressee::noteLabel() | 1160 | QString Addressee::noteLabel() |
1178 | { | 1161 | { |
1179 | return i18n("Note"); | 1162 | return i18n("Note"); |
1180 | } | 1163 | } |
1181 | 1164 | ||
1182 | 1165 | ||
1183 | void Addressee::setProductId( const QString &productId ) | 1166 | void Addressee::setProductId( const QString &productId ) |
1184 | { | 1167 | { |
1185 | if ( productId == mData->productId ) return; | 1168 | if ( productId == mData->productId ) return; |
1186 | detach(); | 1169 | detach(); |
1187 | mData->empty = false; | 1170 | mData->empty = false; |
1188 | mData->productId = productId; | 1171 | mData->productId = productId; |
1189 | } | 1172 | } |
1190 | 1173 | ||
1191 | QString Addressee::productId() const | 1174 | QString Addressee::productId() const |
1192 | { | 1175 | { |
1193 | return mData->productId; | 1176 | return mData->productId; |
1194 | } | 1177 | } |
1195 | 1178 | ||
1196 | QString Addressee::productIdLabel() | 1179 | QString Addressee::productIdLabel() |
1197 | { | 1180 | { |
1198 | return i18n("Product Identifier"); | 1181 | return i18n("Product Identifier"); |
1199 | } | 1182 | } |
1200 | 1183 | ||
1201 | 1184 | ||
1202 | void Addressee::setRevision( const QDateTime &revision ) | 1185 | void Addressee::setRevision( const QDateTime &revision ) |
1203 | { | 1186 | { |
1204 | if ( revision == mData->revision ) return; | 1187 | if ( revision == mData->revision ) return; |
1205 | detach(); | 1188 | detach(); |
1206 | mData->empty = false; | 1189 | mData->empty = false; |
1207 | mData->revision = QDateTime( revision.date(), | 1190 | mData->revision = QDateTime( revision.date(), |
1208 | QTime (revision.time().hour(), | 1191 | QTime (revision.time().hour(), |
1209 | revision.time().minute(), | 1192 | revision.time().minute(), |
1210 | revision.time().second())); | 1193 | revision.time().second())); |
1211 | } | 1194 | } |
1212 | 1195 | ||
1213 | QDateTime Addressee::revision() const | 1196 | QDateTime Addressee::revision() const |
1214 | { | 1197 | { |
1215 | return mData->revision; | 1198 | return mData->revision; |
1216 | } | 1199 | } |
1217 | 1200 | ||
1218 | QString Addressee::revisionLabel() | 1201 | QString Addressee::revisionLabel() |
1219 | { | 1202 | { |
1220 | return i18n("Revision Date"); | 1203 | return i18n("Revision Date"); |
1221 | } | 1204 | } |
1222 | 1205 | ||
1223 | 1206 | ||
1224 | void Addressee::setSortString( const QString &sortString ) | 1207 | void Addressee::setSortString( const QString &sortString ) |
1225 | { | 1208 | { |
1226 | if ( sortString == mData->sortString ) return; | 1209 | if ( sortString == mData->sortString ) return; |
1227 | detach(); | 1210 | detach(); |
1228 | mData->empty = false; | 1211 | mData->empty = false; |
1229 | mData->sortString = sortString; | 1212 | mData->sortString = sortString; |
1230 | } | 1213 | } |
1231 | 1214 | ||
1232 | QString Addressee::sortString() const | 1215 | QString Addressee::sortString() const |
1233 | { | 1216 | { |
1234 | return mData->sortString; | 1217 | return mData->sortString; |
1235 | } | 1218 | } |
1236 | 1219 | ||
1237 | QString Addressee::sortStringLabel() | 1220 | QString Addressee::sortStringLabel() |
1238 | { | 1221 | { |
1239 | return i18n("Sort String"); | 1222 | return i18n("Sort String"); |
1240 | } | 1223 | } |
1241 | 1224 | ||
1242 | 1225 | ||
1243 | void Addressee::setUrl( const KURL &url ) | 1226 | void Addressee::setUrl( const KURL &url ) |
1244 | { | 1227 | { |
1245 | if ( url == mData->url ) return; | 1228 | if ( url == mData->url ) return; |
1246 | detach(); | 1229 | detach(); |
1247 | mData->empty = false; | 1230 | mData->empty = false; |
1248 | mData->url = url; | 1231 | mData->url = url; |
1249 | } | 1232 | } |
1250 | 1233 | ||
1251 | KURL Addressee::url() const | 1234 | KURL Addressee::url() const |
1252 | { | 1235 | { |
1253 | return mData->url; | 1236 | return mData->url; |
1254 | } | 1237 | } |
1255 | 1238 | ||
1256 | QString Addressee::urlLabel() | 1239 | QString Addressee::urlLabel() |
1257 | { | 1240 | { |
1258 | return i18n("URL"); | 1241 | return i18n("URL"); |
1259 | } | 1242 | } |
1260 | 1243 | ||
1261 | 1244 | ||
1262 | void Addressee::setSecrecy( const Secrecy &secrecy ) | 1245 | void Addressee::setSecrecy( const Secrecy &secrecy ) |
1263 | { | 1246 | { |
1264 | if ( secrecy == mData->secrecy ) return; | 1247 | if ( secrecy == mData->secrecy ) return; |
1265 | detach(); | 1248 | detach(); |
1266 | mData->empty = false; | 1249 | mData->empty = false; |
1267 | mData->secrecy = secrecy; | 1250 | mData->secrecy = secrecy; |
1268 | } | 1251 | } |
1269 | 1252 | ||
1270 | Secrecy Addressee::secrecy() const | 1253 | Secrecy Addressee::secrecy() const |
1271 | { | 1254 | { |
1272 | return mData->secrecy; | 1255 | return mData->secrecy; |
1273 | } | 1256 | } |
1274 | 1257 | ||
1275 | QString Addressee::secrecyLabel() | 1258 | QString Addressee::secrecyLabel() |
1276 | { | 1259 | { |
1277 | return i18n("Security Class"); | 1260 | return i18n("Security Class"); |
1278 | } | 1261 | } |
1279 | 1262 | ||
1280 | 1263 | ||
1281 | void Addressee::setLogo( const Picture &logo ) | 1264 | void Addressee::setLogo( const Picture &logo ) |
1282 | { | 1265 | { |
1283 | if ( logo == mData->logo ) return; | 1266 | if ( logo == mData->logo ) return; |
1284 | detach(); | 1267 | detach(); |
1285 | mData->empty = false; | 1268 | mData->empty = false; |
1286 | mData->logo = logo; | 1269 | mData->logo = logo; |
1287 | } | 1270 | } |
1288 | 1271 | ||
1289 | Picture Addressee::logo() const | 1272 | Picture Addressee::logo() const |
1290 | { | 1273 | { |
1291 | return mData->logo; | 1274 | return mData->logo; |
1292 | } | 1275 | } |
1293 | 1276 | ||
1294 | QString Addressee::logoLabel() | 1277 | QString Addressee::logoLabel() |
1295 | { | 1278 | { |
1296 | return i18n("Logo"); | 1279 | return i18n("Logo"); |
1297 | } | 1280 | } |
1298 | 1281 | ||
1299 | 1282 | ||
1300 | void Addressee::setPhoto( const Picture &photo ) | 1283 | void Addressee::setPhoto( const Picture &photo ) |
1301 | { | 1284 | { |
1302 | if ( photo == mData->photo ) return; | 1285 | if ( photo == mData->photo ) return; |
1303 | detach(); | 1286 | detach(); |
1304 | mData->empty = false; | 1287 | mData->empty = false; |
1305 | mData->photo = photo; | 1288 | mData->photo = photo; |
1306 | } | 1289 | } |
1307 | 1290 | ||
1308 | Picture Addressee::photo() const | 1291 | Picture Addressee::photo() const |
1309 | { | 1292 | { |
1310 | return mData->photo; | 1293 | return mData->photo; |
1311 | } | 1294 | } |
1312 | 1295 | ||
1313 | QString Addressee::photoLabel() | 1296 | QString Addressee::photoLabel() |
1314 | { | 1297 | { |
1315 | return i18n("Photo"); | 1298 | return i18n("Photo"); |
1316 | } | 1299 | } |
1317 | 1300 | ||
1318 | 1301 | ||
1319 | void Addressee::setSound( const Sound &sound ) | 1302 | void Addressee::setSound( const Sound &sound ) |
1320 | { | 1303 | { |
1321 | if ( sound == mData->sound ) return; | 1304 | if ( sound == mData->sound ) return; |
1322 | detach(); | 1305 | detach(); |
1323 | mData->empty = false; | 1306 | mData->empty = false; |
1324 | mData->sound = sound; | 1307 | mData->sound = sound; |
1325 | } | 1308 | } |
1326 | 1309 | ||
1327 | Sound Addressee::sound() const | 1310 | Sound Addressee::sound() const |
1328 | { | 1311 | { |
1329 | return mData->sound; | 1312 | return mData->sound; |
1330 | } | 1313 | } |
1331 | 1314 | ||
1332 | QString Addressee::soundLabel() | 1315 | QString Addressee::soundLabel() |
1333 | { | 1316 | { |
1334 | return i18n("Sound"); | 1317 | return i18n("Sound"); |
1335 | } | 1318 | } |
1336 | 1319 | ||
1337 | 1320 | ||
1338 | void Addressee::setAgent( const Agent &agent ) | 1321 | void Addressee::setAgent( const Agent &agent ) |
1339 | { | 1322 | { |
1340 | if ( agent == mData->agent ) return; | 1323 | if ( agent == mData->agent ) return; |
1341 | detach(); | 1324 | detach(); |
1342 | mData->empty = false; | 1325 | mData->empty = false; |
1343 | mData->agent = agent; | 1326 | mData->agent = agent; |
1344 | } | 1327 | } |
1345 | 1328 | ||
1346 | Agent Addressee::agent() const | 1329 | Agent Addressee::agent() const |
1347 | { | 1330 | { |
1348 | return mData->agent; | 1331 | return mData->agent; |
1349 | } | 1332 | } |
1350 | 1333 | ||
1351 | QString Addressee::agentLabel() | 1334 | QString Addressee::agentLabel() |
1352 | { | 1335 | { |
1353 | return i18n("Agent"); | 1336 | return i18n("Agent"); |
1354 | } | 1337 | } |
1355 | 1338 | ||
1356 | 1339 | ||
1357 | 1340 | ||
1358 | void Addressee::setNameFromString( const QString &str ) | 1341 | void Addressee::setNameFromString( const QString &str ) |
1359 | { | 1342 | { |
1360 | setFormattedName( str ); | 1343 | setFormattedName( str ); |
1361 | setName( str ); | 1344 | setName( str ); |
1362 | 1345 | ||
1363 | static bool first = true; | 1346 | static bool first = true; |
1364 | static QStringList titles; | 1347 | static QStringList titles; |
1365 | static QStringList suffixes; | 1348 | static QStringList suffixes; |
1366 | static QStringList prefixes; | 1349 | static QStringList prefixes; |
1367 | 1350 | ||
1368 | if ( first ) { | 1351 | if ( first ) { |
1369 | first = false; | 1352 | first = false; |
1370 | titles += i18n( "Dr." ); | 1353 | titles += i18n( "Dr." ); |
1371 | titles += i18n( "Miss" ); | 1354 | titles += i18n( "Miss" ); |
1372 | titles += i18n( "Mr." ); | 1355 | titles += i18n( "Mr." ); |
1373 | titles += i18n( "Mrs." ); | 1356 | titles += i18n( "Mrs." ); |
1374 | titles += i18n( "Ms." ); | 1357 | titles += i18n( "Ms." ); |
1375 | titles += i18n( "Prof." ); | 1358 | titles += i18n( "Prof." ); |
1376 | 1359 | ||
1377 | suffixes += i18n( "I" ); | 1360 | suffixes += i18n( "I" ); |
1378 | suffixes += i18n( "II" ); | 1361 | suffixes += i18n( "II" ); |
1379 | suffixes += i18n( "III" ); | 1362 | suffixes += i18n( "III" ); |
1380 | suffixes += i18n( "Jr." ); | 1363 | suffixes += i18n( "Jr." ); |
1381 | suffixes += i18n( "Sr." ); | 1364 | suffixes += i18n( "Sr." ); |
1382 | 1365 | ||
1383 | prefixes += "van"; | 1366 | prefixes += "van"; |
1384 | prefixes += "von"; | 1367 | prefixes += "von"; |
1385 | prefixes += "de"; | 1368 | prefixes += "de"; |
1386 | 1369 | ||
1387 | KConfig config( locateLocal( "config", "kabcrc") ); | 1370 | KConfig config( locateLocal( "config", "kabcrc") ); |
1388 | config.setGroup( "General" ); | 1371 | config.setGroup( "General" ); |
1389 | titles += config.readListEntry( "Prefixes" ); | 1372 | titles += config.readListEntry( "Prefixes" ); |
1390 | titles.remove( "" ); | 1373 | titles.remove( "" ); |
1391 | prefixes += config.readListEntry( "Inclusions" ); | 1374 | prefixes += config.readListEntry( "Inclusions" ); |
1392 | prefixes.remove( "" ); | 1375 | prefixes.remove( "" ); |
1393 | suffixes += config.readListEntry( "Suffixes" ); | 1376 | suffixes += config.readListEntry( "Suffixes" ); |
1394 | suffixes.remove( "" ); | 1377 | suffixes.remove( "" ); |
1395 | } | 1378 | } |
1396 | 1379 | ||
1397 | // clear all name parts | 1380 | // clear all name parts |
1398 | setPrefix( "" ); | 1381 | setPrefix( "" ); |
1399 | setGivenName( "" ); | 1382 | setGivenName( "" ); |
1400 | setAdditionalName( "" ); | 1383 | setAdditionalName( "" ); |
1401 | setFamilyName( "" ); | 1384 | setFamilyName( "" ); |
1402 | setSuffix( "" ); | 1385 | setSuffix( "" ); |
1403 | 1386 | ||
1404 | if ( str.isEmpty() ) | 1387 | if ( str.isEmpty() ) |
1405 | return; | 1388 | return; |
1406 | 1389 | ||
1407 | int i = str.find(','); | 1390 | int i = str.find(','); |
1408 | if( i < 0 ) { | 1391 | if( i < 0 ) { |
1409 | QStringList parts = QStringList::split( " ", str ); | 1392 | QStringList parts = QStringList::split( " ", str ); |
1410 | int leftOffset = 0; | 1393 | int leftOffset = 0; |
1411 | int rightOffset = parts.count() - 1; | 1394 | int rightOffset = parts.count() - 1; |
1412 | 1395 | ||
1413 | QString suffix; | 1396 | QString suffix; |
1414 | while ( rightOffset >= 0 ) { | 1397 | while ( rightOffset >= 0 ) { |
1415 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1398 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1416 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1399 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1417 | rightOffset--; | 1400 | rightOffset--; |
1418 | } else | 1401 | } else |
1419 | break; | 1402 | break; |
1420 | } | 1403 | } |
1421 | setSuffix( suffix ); | 1404 | setSuffix( suffix ); |
1422 | 1405 | ||
1423 | if ( rightOffset < 0 ) | 1406 | if ( rightOffset < 0 ) |
1424 | return; | 1407 | return; |
1425 | 1408 | ||
1426 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1409 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1427 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1410 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1428 | rightOffset--; | 1411 | rightOffset--; |
1429 | } else | 1412 | } else |
1430 | setFamilyName( parts[ rightOffset ] ); | 1413 | setFamilyName( parts[ rightOffset ] ); |
1431 | 1414 | ||
1432 | QString prefix; | 1415 | QString prefix; |
1433 | while ( leftOffset < rightOffset ) { | 1416 | while ( leftOffset < rightOffset ) { |
1434 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1417 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1435 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1418 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1436 | leftOffset++; | 1419 | leftOffset++; |
1437 | } else | 1420 | } else |
1438 | break; | 1421 | break; |
1439 | } | 1422 | } |
1440 | setPrefix( prefix ); | 1423 | setPrefix( prefix ); |
1441 | 1424 | ||
1442 | if ( leftOffset < rightOffset ) { | 1425 | if ( leftOffset < rightOffset ) { |
1443 | setGivenName( parts[ leftOffset ] ); | 1426 | setGivenName( parts[ leftOffset ] ); |
1444 | leftOffset++; | 1427 | leftOffset++; |
1445 | } | 1428 | } |
1446 | 1429 | ||
1447 | QString additionalName; | 1430 | QString additionalName; |
1448 | while ( leftOffset < rightOffset ) { | 1431 | while ( leftOffset < rightOffset ) { |
1449 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1432 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1450 | leftOffset++; | 1433 | leftOffset++; |
1451 | } | 1434 | } |
1452 | setAdditionalName( additionalName ); | 1435 | setAdditionalName( additionalName ); |
1453 | } else { | 1436 | } else { |
1454 | QString part1 = str.left( i ); | 1437 | QString part1 = str.left( i ); |
1455 | QString part2 = str.mid( i + 1 ); | 1438 | QString part2 = str.mid( i + 1 ); |
1456 | 1439 | ||
1457 | QStringList parts = QStringList::split( " ", part1 ); | 1440 | QStringList parts = QStringList::split( " ", part1 ); |
1458 | int leftOffset = 0; | 1441 | int leftOffset = 0; |
1459 | int rightOffset = parts.count() - 1; | 1442 | int rightOffset = parts.count() - 1; |
1460 | 1443 | ||
1461 | QString suffix; | 1444 | QString suffix; |
1462 | while ( rightOffset >= 0 ) { | 1445 | while ( rightOffset >= 0 ) { |
1463 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1446 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1464 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1447 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1465 | rightOffset--; | 1448 | rightOffset--; |
1466 | } else | 1449 | } else |
1467 | break; | 1450 | break; |
1468 | } | 1451 | } |
1469 | setSuffix( suffix ); | 1452 | setSuffix( suffix ); |
1470 | 1453 | ||
1471 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1454 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1472 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1455 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1473 | rightOffset--; | 1456 | rightOffset--; |
1474 | } else | 1457 | } else |
1475 | setFamilyName( parts[ rightOffset ] ); | 1458 | setFamilyName( parts[ rightOffset ] ); |
1476 | 1459 | ||
1477 | QString prefix; | 1460 | QString prefix; |
1478 | while ( leftOffset < rightOffset ) { | 1461 | while ( leftOffset < rightOffset ) { |
1479 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1462 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1480 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1463 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1481 | leftOffset++; | 1464 | leftOffset++; |
1482 | } else | 1465 | } else |
1483 | break; | 1466 | break; |
1484 | } | 1467 | } |
1485 | 1468 | ||
1486 | parts = QStringList::split( " ", part2 ); | 1469 | parts = QStringList::split( " ", part2 ); |
1487 | 1470 | ||
1488 | leftOffset = 0; | 1471 | leftOffset = 0; |
1489 | rightOffset = parts.count(); | 1472 | rightOffset = parts.count(); |
1490 | 1473 | ||
1491 | while ( leftOffset < rightOffset ) { | 1474 | while ( leftOffset < rightOffset ) { |
1492 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1475 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1493 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1476 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1494 | leftOffset++; | 1477 | leftOffset++; |
1495 | } else | 1478 | } else |
1496 | break; | 1479 | break; |
1497 | } | 1480 | } |
1498 | setPrefix( prefix ); | 1481 | setPrefix( prefix ); |
1499 | 1482 | ||
1500 | if ( leftOffset < rightOffset ) { | 1483 | if ( leftOffset < rightOffset ) { |
1501 | setGivenName( parts[ leftOffset ] ); | 1484 | setGivenName( parts[ leftOffset ] ); |
1502 | leftOffset++; | 1485 | leftOffset++; |
1503 | } | 1486 | } |
1504 | 1487 | ||
1505 | QString additionalName; | 1488 | QString additionalName; |
1506 | while ( leftOffset < rightOffset ) { | 1489 | while ( leftOffset < rightOffset ) { |
1507 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1490 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1508 | leftOffset++; | 1491 | leftOffset++; |
1509 | } | 1492 | } |
1510 | setAdditionalName( additionalName ); | 1493 | setAdditionalName( additionalName ); |
1511 | } | 1494 | } |
1512 | } | 1495 | } |
1513 | 1496 | ||
1514 | QString Addressee::realName() const | 1497 | QString Addressee::realName() const |
1515 | { | 1498 | { |
1516 | if ( !formattedName().isEmpty() ) | 1499 | if ( !formattedName().isEmpty() ) |
1517 | return formattedName(); | 1500 | return formattedName(); |
1518 | 1501 | ||
1519 | QString n = assembledName(); | 1502 | QString n = assembledName(); |
1520 | 1503 | ||
1521 | if ( n.isEmpty() ) | 1504 | if ( n.isEmpty() ) |
1522 | n = name(); | 1505 | n = name(); |
1523 | if ( n.isEmpty() ) | 1506 | if ( n.isEmpty() ) |
1524 | n = organization(); | 1507 | n = organization(); |
1525 | return n; | 1508 | return n; |
1526 | } | 1509 | } |
1527 | 1510 | ||
1528 | QString Addressee::assembledName() const | 1511 | QString Addressee::assembledName() const |
1529 | { | 1512 | { |
1530 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + | 1513 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + |
1531 | familyName() + " " + suffix(); | 1514 | familyName() + " " + suffix(); |
1532 | 1515 | ||
1533 | return name.simplifyWhiteSpace(); | 1516 | return name.simplifyWhiteSpace(); |
1534 | } | 1517 | } |
1535 | 1518 | ||
1536 | QString Addressee::fullEmail( const QString &email ) const | 1519 | QString Addressee::fullEmail( const QString &email ) const |
1537 | { | 1520 | { |
1538 | QString e; | 1521 | QString e; |
1539 | if ( email.isNull() ) { | 1522 | if ( email.isNull() ) { |
1540 | e = preferredEmail(); | 1523 | e = preferredEmail(); |
1541 | } else { | 1524 | } else { |
1542 | e = email; | 1525 | e = email; |
1543 | } | 1526 | } |
1544 | if ( e.isEmpty() ) return QString::null; | 1527 | if ( e.isEmpty() ) return QString::null; |
1545 | 1528 | ||
1546 | QString text; | 1529 | QString text; |
1547 | if ( realName().isEmpty() ) | 1530 | if ( realName().isEmpty() ) |
1548 | text = e; | 1531 | text = e; |
1549 | else | 1532 | else |
1550 | text = assembledName() + " <" + e + ">"; | 1533 | text = assembledName() + " <" + e + ">"; |
1551 | 1534 | ||
1552 | return text; | 1535 | return text; |
1553 | } | 1536 | } |
1554 | 1537 | ||
1555 | void Addressee::insertEmail( const QString &email, bool preferred ) | 1538 | void Addressee::insertEmail( const QString &email, bool preferred ) |
1556 | { | 1539 | { |
1557 | detach(); | 1540 | detach(); |
1558 | 1541 | ||
1559 | QStringList::Iterator it = mData->emails.find( email ); | 1542 | QStringList::Iterator it = mData->emails.find( email ); |
1560 | 1543 | ||
1561 | if ( it != mData->emails.end() ) { | 1544 | if ( it != mData->emails.end() ) { |
1562 | if ( !preferred || it == mData->emails.begin() ) return; | 1545 | if ( !preferred || it == mData->emails.begin() ) return; |
1563 | mData->emails.remove( it ); | 1546 | mData->emails.remove( it ); |
1564 | mData->emails.prepend( email ); | 1547 | mData->emails.prepend( email ); |
1565 | } else { | 1548 | } else { |
1566 | if ( preferred ) { | 1549 | if ( preferred ) { |
1567 | mData->emails.prepend( email ); | 1550 | mData->emails.prepend( email ); |
1568 | } else { | 1551 | } else { |
1569 | mData->emails.append( email ); | 1552 | mData->emails.append( email ); |
1570 | } | 1553 | } |
1571 | } | 1554 | } |
1572 | } | 1555 | } |
1573 | 1556 | ||
1574 | void Addressee::removeEmail( const QString &email ) | 1557 | void Addressee::removeEmail( const QString &email ) |
1575 | { | 1558 | { |
1576 | detach(); | 1559 | detach(); |
1577 | 1560 | ||
1578 | QStringList::Iterator it = mData->emails.find( email ); | 1561 | QStringList::Iterator it = mData->emails.find( email ); |
1579 | if ( it == mData->emails.end() ) return; | 1562 | if ( it == mData->emails.end() ) return; |
1580 | 1563 | ||
1581 | mData->emails.remove( it ); | 1564 | mData->emails.remove( it ); |
1582 | } | 1565 | } |
1583 | 1566 | ||
1584 | QString Addressee::preferredEmail() const | 1567 | QString Addressee::preferredEmail() const |
1585 | { | 1568 | { |
1586 | if ( mData->emails.count() == 0 ) return QString::null; | 1569 | if ( mData->emails.count() == 0 ) return QString::null; |
1587 | else return mData->emails.first(); | 1570 | else return mData->emails.first(); |
1588 | } | 1571 | } |
1589 | 1572 | ||
1590 | QStringList Addressee::emails() const | 1573 | QStringList Addressee::emails() const |
1591 | { | 1574 | { |
1592 | return mData->emails; | 1575 | return mData->emails; |
1593 | } | 1576 | } |
1594 | void Addressee::setEmails( const QStringList& emails ) { | 1577 | void Addressee::setEmails( const QStringList& emails ) { |
1595 | detach(); | 1578 | detach(); |
1596 | mData->emails = emails; | 1579 | mData->emails = emails; |
1597 | } | 1580 | } |
1598 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) | 1581 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) |
1599 | { | 1582 | { |
1600 | detach(); | 1583 | detach(); |
1601 | mData->empty = false; | 1584 | mData->empty = false; |
1602 | 1585 | ||
1603 | PhoneNumber::List::Iterator it; | 1586 | PhoneNumber::List::Iterator it; |
1604 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1587 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1605 | if ( (*it).id() == phoneNumber.id() ) { | 1588 | if ( (*it).id() == phoneNumber.id() ) { |
1606 | *it = phoneNumber; | 1589 | *it = phoneNumber; |
1607 | return; | 1590 | return; |
1608 | } | 1591 | } |
1609 | } | 1592 | } |
1610 | mData->phoneNumbers.append( phoneNumber ); | 1593 | mData->phoneNumbers.append( phoneNumber ); |
1611 | } | 1594 | } |
1612 | 1595 | ||
1613 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) | 1596 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) |
1614 | { | 1597 | { |
1615 | detach(); | 1598 | detach(); |
1616 | 1599 | ||
1617 | PhoneNumber::List::Iterator it; | 1600 | PhoneNumber::List::Iterator it; |
1618 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1601 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1619 | if ( (*it).id() == phoneNumber.id() ) { | 1602 | if ( (*it).id() == phoneNumber.id() ) { |
1620 | mData->phoneNumbers.remove( it ); | 1603 | mData->phoneNumbers.remove( it ); |
1621 | return; | 1604 | return; |
1622 | } | 1605 | } |
1623 | } | 1606 | } |
1624 | } | 1607 | } |
1625 | 1608 | ||
1626 | PhoneNumber Addressee::phoneNumber( int type ) const | 1609 | PhoneNumber Addressee::phoneNumber( int type ) const |
1627 | { | 1610 | { |
1628 | PhoneNumber phoneNumber( "", type ); | 1611 | PhoneNumber phoneNumber( "", type ); |
1629 | PhoneNumber::List::ConstIterator it; | 1612 | PhoneNumber::List::ConstIterator it; |
1630 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1613 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1631 | if ( matchBinaryPatternP( (*it).type(), type ) ) { | 1614 | if ( matchBinaryPatternP( (*it).type(), type ) ) { |
1632 | if ( (*it).type() & PhoneNumber::Pref ) | 1615 | if ( (*it).type() & PhoneNumber::Pref ) |
1633 | return (*it); | 1616 | return (*it); |
1634 | else if ( phoneNumber.number().isEmpty() ) | 1617 | else if ( phoneNumber.number().isEmpty() ) |
1635 | phoneNumber = (*it); | 1618 | phoneNumber = (*it); |
1636 | } | 1619 | } |
1637 | } | 1620 | } |
1638 | 1621 | ||
1639 | return phoneNumber; | 1622 | return phoneNumber; |
1640 | } | 1623 | } |
1641 | 1624 | ||
1642 | PhoneNumber::List Addressee::phoneNumbers() const | 1625 | PhoneNumber::List Addressee::phoneNumbers() const |
1643 | { | 1626 | { |
1644 | return mData->phoneNumbers; | 1627 | return mData->phoneNumbers; |
1645 | } | 1628 | } |
1646 | 1629 | ||
1647 | PhoneNumber::List Addressee::phoneNumbers( int type ) const | 1630 | PhoneNumber::List Addressee::phoneNumbers( int type ) const |
1648 | { | 1631 | { |
1649 | PhoneNumber::List list; | 1632 | PhoneNumber::List list; |
1650 | 1633 | ||
1651 | PhoneNumber::List::ConstIterator it; | 1634 | PhoneNumber::List::ConstIterator it; |
1652 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1635 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1653 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1636 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1654 | list.append( *it ); | 1637 | list.append( *it ); |
1655 | } | 1638 | } |
1656 | } | 1639 | } |
1657 | return list; | 1640 | return list; |
1658 | } | 1641 | } |
1659 | 1642 | ||
1660 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const | 1643 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const |
1661 | { | 1644 | { |
1662 | PhoneNumber::List::ConstIterator it; | 1645 | PhoneNumber::List::ConstIterator it; |
1663 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1646 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1664 | if ( (*it).id() == id ) { | 1647 | if ( (*it).id() == id ) { |
1665 | return *it; | 1648 | return *it; |
1666 | } | 1649 | } |
1667 | } | 1650 | } |
1668 | return PhoneNumber(); | 1651 | return PhoneNumber(); |
1669 | } | 1652 | } |
1670 | 1653 | ||
1671 | void Addressee::insertKey( const Key &key ) | 1654 | void Addressee::insertKey( const Key &key ) |
1672 | { | 1655 | { |
1673 | detach(); | 1656 | detach(); |
1674 | mData->empty = false; | 1657 | mData->empty = false; |
1675 | 1658 | ||
1676 | Key::List::Iterator it; | 1659 | Key::List::Iterator it; |
1677 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1660 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1678 | if ( (*it).id() == key.id() ) { | 1661 | if ( (*it).id() == key.id() ) { |
1679 | *it = key; | 1662 | *it = key; |
1680 | return; | 1663 | return; |
1681 | } | 1664 | } |
1682 | } | 1665 | } |
1683 | mData->keys.append( key ); | 1666 | mData->keys.append( key ); |
1684 | } | 1667 | } |
1685 | 1668 | ||
1686 | void Addressee::removeKey( const Key &key ) | 1669 | void Addressee::removeKey( const Key &key ) |
1687 | { | 1670 | { |
1688 | detach(); | 1671 | detach(); |
1689 | 1672 | ||
1690 | Key::List::Iterator it; | 1673 | Key::List::Iterator it; |
1691 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1674 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1692 | if ( (*it).id() == key.id() ) { | 1675 | if ( (*it).id() == key.id() ) { |
1693 | mData->keys.remove( key ); | 1676 | mData->keys.remove( key ); |
1694 | return; | 1677 | return; |
1695 | } | 1678 | } |
1696 | } | 1679 | } |
1697 | } | 1680 | } |
1698 | 1681 | ||
1699 | Key Addressee::key( int type, QString customTypeString ) const | 1682 | Key Addressee::key( int type, QString customTypeString ) const |
1700 | { | 1683 | { |
1701 | Key::List::ConstIterator it; | 1684 | Key::List::ConstIterator it; |
1702 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1685 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1703 | if ( (*it).type() == type ) { | 1686 | if ( (*it).type() == type ) { |
1704 | if ( type == Key::Custom ) { | 1687 | if ( type == Key::Custom ) { |
1705 | if ( customTypeString.isEmpty() ) { | 1688 | if ( customTypeString.isEmpty() ) { |
1706 | return *it; | 1689 | return *it; |
1707 | } else { | 1690 | } else { |
1708 | if ( (*it).customTypeString() == customTypeString ) | 1691 | if ( (*it).customTypeString() == customTypeString ) |
1709 | return (*it); | 1692 | return (*it); |
1710 | } | 1693 | } |
1711 | } else { | 1694 | } else { |
1712 | return *it; | 1695 | return *it; |
1713 | } | 1696 | } |
1714 | } | 1697 | } |
1715 | } | 1698 | } |
1716 | return Key( QString(), type ); | 1699 | return Key( QString(), type ); |
1717 | } | 1700 | } |
1718 | void Addressee::setKeys( const Key::List& list ) { | 1701 | void Addressee::setKeys( const Key::List& list ) { |
1719 | detach(); | 1702 | detach(); |
1720 | mData->keys = list; | 1703 | mData->keys = list; |
1721 | } | 1704 | } |
1722 | 1705 | ||
1723 | Key::List Addressee::keys() const | 1706 | Key::List Addressee::keys() const |
1724 | { | 1707 | { |
1725 | return mData->keys; | 1708 | return mData->keys; |
1726 | } | 1709 | } |
1727 | 1710 | ||
1728 | Key::List Addressee::keys( int type, QString customTypeString ) const | 1711 | Key::List Addressee::keys( int type, QString customTypeString ) const |
1729 | { | 1712 | { |
1730 | Key::List list; | 1713 | Key::List list; |
1731 | 1714 | ||
1732 | Key::List::ConstIterator it; | 1715 | Key::List::ConstIterator it; |
1733 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1716 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1734 | if ( (*it).type() == type ) { | 1717 | if ( (*it).type() == type ) { |
1735 | if ( type == Key::Custom ) { | 1718 | if ( type == Key::Custom ) { |
1736 | if ( customTypeString.isEmpty() ) { | 1719 | if ( customTypeString.isEmpty() ) { |
1737 | list.append(*it); | 1720 | list.append(*it); |
1738 | } else { | 1721 | } else { |
1739 | if ( (*it).customTypeString() == customTypeString ) | 1722 | if ( (*it).customTypeString() == customTypeString ) |
1740 | list.append(*it); | 1723 | list.append(*it); |
1741 | } | 1724 | } |
1742 | } else { | 1725 | } else { |
1743 | list.append(*it); | 1726 | list.append(*it); |
1744 | } | 1727 | } |
1745 | } | 1728 | } |
1746 | } | 1729 | } |
1747 | return list; | 1730 | return list; |
1748 | } | 1731 | } |
1749 | 1732 | ||
1750 | Key Addressee::findKey( const QString &id ) const | 1733 | Key Addressee::findKey( const QString &id ) const |
1751 | { | 1734 | { |
1752 | Key::List::ConstIterator it; | 1735 | Key::List::ConstIterator it; |
1753 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1736 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1754 | if ( (*it).id() == id ) { | 1737 | if ( (*it).id() == id ) { |
1755 | return *it; | 1738 | return *it; |
1756 | } | 1739 | } |
1757 | } | 1740 | } |
1758 | return Key(); | 1741 | return Key(); |
1759 | } | 1742 | } |
1760 | 1743 | ||
1761 | QString Addressee::asString() const | 1744 | QString Addressee::asString() const |
1762 | { | 1745 | { |
1763 | return "Smith, agent Smith..."; | 1746 | return "Smith, agent Smith..."; |
1764 | } | 1747 | } |
1765 | 1748 | ||
1766 | void Addressee::dump() const | 1749 | void Addressee::dump() const |
1767 | { | 1750 | { |
1768 | return; | 1751 | return; |
1769 | #if 0 | 1752 | #if 0 |
1770 | kdDebug(5700) << "Addressee {" << endl; | 1753 | kdDebug(5700) << "Addressee {" << endl; |
1771 | 1754 | ||
1772 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; | 1755 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; |
1773 | 1756 | ||
1774 | kdDebug(5700) << " Name: '" << name() << "'" << endl; | 1757 | kdDebug(5700) << " Name: '" << name() << "'" << endl; |
1775 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; | 1758 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; |
1776 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; | 1759 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; |
1777 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; | 1760 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; |
1778 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; | 1761 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; |
1779 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; | 1762 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; |
1780 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; | 1763 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; |
1781 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; | 1764 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; |
1782 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; | 1765 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; |
1783 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; | 1766 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; |
1784 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; | 1767 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; |
1785 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; | 1768 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; |
1786 | kdDebug(5700) << " Title: '" << title() << "'" << endl; | 1769 | kdDebug(5700) << " Title: '" << title() << "'" << endl; |
1787 | kdDebug(5700) << " Role: '" << role() << "'" << endl; | 1770 | kdDebug(5700) << " Role: '" << role() << "'" << endl; |
1788 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; | 1771 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; |
1789 | kdDebug(5700) << " Note: '" << note() << "'" << endl; | 1772 | kdDebug(5700) << " Note: '" << note() << "'" << endl; |
1790 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; | 1773 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; |
1791 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; | 1774 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; |
1792 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; | 1775 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; |
1793 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; | 1776 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; |
1794 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; | 1777 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; |
1795 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; | 1778 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; |
1796 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; | 1779 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; |
1797 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; | 1780 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; |
1798 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; | 1781 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; |
1799 | 1782 | ||
1800 | kdDebug(5700) << " Emails {" << endl; | 1783 | kdDebug(5700) << " Emails {" << endl; |
1801 | QStringList e = emails(); | 1784 | QStringList e = emails(); |
1802 | QStringList::ConstIterator it; | 1785 | QStringList::ConstIterator it; |
1803 | for( it = e.begin(); it != e.end(); ++it ) { | 1786 | for( it = e.begin(); it != e.end(); ++it ) { |
1804 | kdDebug(5700) << " " << (*it) << endl; | 1787 | kdDebug(5700) << " " << (*it) << endl; |
1805 | } | 1788 | } |
1806 | kdDebug(5700) << " }" << endl; | 1789 | kdDebug(5700) << " }" << endl; |
1807 | 1790 | ||
1808 | kdDebug(5700) << " PhoneNumbers {" << endl; | 1791 | kdDebug(5700) << " PhoneNumbers {" << endl; |
1809 | PhoneNumber::List p = phoneNumbers(); | 1792 | PhoneNumber::List p = phoneNumbers(); |
1810 | PhoneNumber::List::ConstIterator it2; | 1793 | PhoneNumber::List::ConstIterator it2; |
1811 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { | 1794 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { |
1812 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; | 1795 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; |
1813 | } | 1796 | } |
1814 | kdDebug(5700) << " }" << endl; | 1797 | kdDebug(5700) << " }" << endl; |
1815 | 1798 | ||
1816 | Address::List a = addresses(); | 1799 | Address::List a = addresses(); |
1817 | Address::List::ConstIterator it3; | 1800 | Address::List::ConstIterator it3; |
1818 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { | 1801 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { |
1819 | (*it3).dump(); | 1802 | (*it3).dump(); |
1820 | } | 1803 | } |
1821 | 1804 | ||
1822 | kdDebug(5700) << " Keys {" << endl; | 1805 | kdDebug(5700) << " Keys {" << endl; |
1823 | Key::List k = keys(); | 1806 | Key::List k = keys(); |
1824 | Key::List::ConstIterator it4; | 1807 | Key::List::ConstIterator it4; |
1825 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { | 1808 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { |
1826 | kdDebug(5700) << " Type: " << int((*it4).type()) << | 1809 | kdDebug(5700) << " Type: " << int((*it4).type()) << |
1827 | " Key: " << (*it4).textData() << | 1810 | " Key: " << (*it4).textData() << |
1828 | " CustomString: " << (*it4).customTypeString() << endl; | 1811 | " CustomString: " << (*it4).customTypeString() << endl; |
1829 | } | 1812 | } |
1830 | kdDebug(5700) << " }" << endl; | 1813 | kdDebug(5700) << " }" << endl; |
1831 | 1814 | ||
1832 | kdDebug(5700) << "}" << endl; | 1815 | kdDebug(5700) << "}" << endl; |
1833 | #endif | 1816 | #endif |
1834 | } | 1817 | } |
1835 | 1818 | ||
1836 | 1819 | ||
1837 | void Addressee::insertAddress( const Address &address ) | 1820 | void Addressee::insertAddress( const Address &address ) |
1838 | { | 1821 | { |
1839 | detach(); | 1822 | detach(); |
1840 | mData->empty = false; | 1823 | mData->empty = false; |
1841 | 1824 | ||
1842 | Address::List::Iterator it; | 1825 | Address::List::Iterator it; |
1843 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1826 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1844 | if ( (*it).id() == address.id() ) { | 1827 | if ( (*it).id() == address.id() ) { |
1845 | *it = address; | 1828 | *it = address; |
1846 | return; | 1829 | return; |
1847 | } | 1830 | } |
1848 | } | 1831 | } |
1849 | mData->addresses.append( address ); | 1832 | mData->addresses.append( address ); |
1850 | } | 1833 | } |
1851 | 1834 | ||
1852 | void Addressee::removeAddress( const Address &address ) | 1835 | void Addressee::removeAddress( const Address &address ) |
1853 | { | 1836 | { |
1854 | detach(); | 1837 | detach(); |
1855 | 1838 | ||
1856 | Address::List::Iterator it; | 1839 | Address::List::Iterator it; |
1857 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1840 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1858 | if ( (*it).id() == address.id() ) { | 1841 | if ( (*it).id() == address.id() ) { |
1859 | mData->addresses.remove( it ); | 1842 | mData->addresses.remove( it ); |
1860 | return; | 1843 | return; |
1861 | } | 1844 | } |
1862 | } | 1845 | } |
1863 | } | 1846 | } |
1864 | 1847 | ||
1865 | Address Addressee::address( int type ) const | 1848 | Address Addressee::address( int type ) const |
1866 | { | 1849 | { |
1867 | Address address( type ); | 1850 | Address address( type ); |
1868 | Address::List::ConstIterator it; | 1851 | Address::List::ConstIterator it; |
1869 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1852 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1870 | if ( matchBinaryPatternA( (*it).type(), type ) ) { | 1853 | if ( matchBinaryPatternA( (*it).type(), type ) ) { |
1871 | if ( (*it).type() & Address::Pref ) | 1854 | if ( (*it).type() & Address::Pref ) |
1872 | return (*it); | 1855 | return (*it); |
1873 | else if ( address.isEmpty() ) | 1856 | else if ( address.isEmpty() ) |
1874 | address = (*it); | 1857 | address = (*it); |
1875 | } | 1858 | } |
1876 | } | 1859 | } |
1877 | 1860 | ||
1878 | return address; | 1861 | return address; |
1879 | } | 1862 | } |
1880 | 1863 | ||
1881 | Address::List Addressee::addresses() const | 1864 | Address::List Addressee::addresses() const |
1882 | { | 1865 | { |
1883 | return mData->addresses; | 1866 | return mData->addresses; |
1884 | } | 1867 | } |
1885 | 1868 | ||
1886 | Address::List Addressee::addresses( int type ) const | 1869 | Address::List Addressee::addresses( int type ) const |
1887 | { | 1870 | { |
1888 | Address::List list; | 1871 | Address::List list; |
1889 | 1872 | ||
1890 | Address::List::ConstIterator it; | 1873 | Address::List::ConstIterator it; |
1891 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1874 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1892 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1875 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1893 | list.append( *it ); | 1876 | list.append( *it ); |
1894 | } | 1877 | } |
1895 | } | 1878 | } |
1896 | 1879 | ||
1897 | return list; | 1880 | return list; |
1898 | } | 1881 | } |
1899 | 1882 | ||
1900 | Address Addressee::findAddress( const QString &id ) const | 1883 | Address Addressee::findAddress( const QString &id ) const |
1901 | { | 1884 | { |
1902 | Address::List::ConstIterator it; | 1885 | Address::List::ConstIterator it; |
1903 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1886 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1904 | if ( (*it).id() == id ) { | 1887 | if ( (*it).id() == id ) { |
1905 | return *it; | 1888 | return *it; |
1906 | } | 1889 | } |
1907 | } | 1890 | } |
1908 | return Address(); | 1891 | return Address(); |
1909 | } | 1892 | } |
1910 | 1893 | ||
1911 | void Addressee::insertCategory( const QString &c ) | 1894 | void Addressee::insertCategory( const QString &c ) |
1912 | { | 1895 | { |
1913 | detach(); | 1896 | detach(); |
1914 | mData->empty = false; | 1897 | mData->empty = false; |
1915 | 1898 | ||
1916 | if ( mData->categories.contains( c ) ) return; | 1899 | if ( mData->categories.contains( c ) ) return; |
1917 | 1900 | ||
1918 | mData->categories.append( c ); | 1901 | mData->categories.append( c ); |
1919 | } | 1902 | } |
1920 | 1903 | ||
1921 | void Addressee::removeCategory( const QString &c ) | 1904 | void Addressee::removeCategory( const QString &c ) |
1922 | { | 1905 | { |
1923 | detach(); | 1906 | detach(); |
1924 | 1907 | ||
1925 | QStringList::Iterator it = mData->categories.find( c ); | 1908 | QStringList::Iterator it = mData->categories.find( c ); |
1926 | if ( it == mData->categories.end() ) return; | 1909 | if ( it == mData->categories.end() ) return; |
1927 | 1910 | ||
1928 | mData->categories.remove( it ); | 1911 | mData->categories.remove( it ); |
1929 | } | 1912 | } |
1930 | 1913 | ||
1931 | bool Addressee::hasCategory( const QString &c ) const | 1914 | bool Addressee::hasCategory( const QString &c ) const |
1932 | { | 1915 | { |
1933 | return ( mData->categories.contains( c ) ); | 1916 | return ( mData->categories.contains( c ) ); |
1934 | } | 1917 | } |
1935 | 1918 | ||
1936 | void Addressee::setCategories( const QStringList &c ) | 1919 | void Addressee::setCategories( const QStringList &c ) |
1937 | { | 1920 | { |
1938 | detach(); | 1921 | detach(); |
1939 | mData->empty = false; | 1922 | mData->empty = false; |
1940 | 1923 | ||
1941 | mData->categories = c; | 1924 | mData->categories = c; |
1942 | } | 1925 | } |
1943 | 1926 | ||
1944 | QStringList Addressee::categories() const | 1927 | QStringList Addressee::categories() const |
1945 | { | 1928 | { |
1946 | return mData->categories; | 1929 | return mData->categories; |
1947 | } | 1930 | } |
1948 | 1931 | ||
1949 | void Addressee::insertCustom( const QString &app, const QString &name, | 1932 | void Addressee::insertCustom( const QString &app, const QString &name, |
1950 | const QString &value ) | 1933 | const QString &value ) |
1951 | { | 1934 | { |
1952 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; | 1935 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; |
1953 | 1936 | ||
1954 | detach(); | 1937 | detach(); |
1955 | mData->empty = false; | 1938 | mData->empty = false; |
1956 | 1939 | ||
1957 | QString qualifiedName = app + "-" + name + ":"; | 1940 | QString qualifiedName = app + "-" + name + ":"; |
1958 | 1941 | ||
1959 | QStringList::Iterator it; | 1942 | QStringList::Iterator it; |
1960 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1943 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1961 | if ( (*it).startsWith( qualifiedName ) ) { | 1944 | if ( (*it).startsWith( qualifiedName ) ) { |
1962 | (*it) = qualifiedName + value; | 1945 | (*it) = qualifiedName + value; |
1963 | return; | 1946 | return; |
1964 | } | 1947 | } |
1965 | } | 1948 | } |
1966 | mData->custom.append( qualifiedName + value ); | 1949 | mData->custom.append( qualifiedName + value ); |
1967 | } | 1950 | } |
1968 | 1951 | ||
1969 | void Addressee::removeCustom( const QString &app, const QString &name) | 1952 | void Addressee::removeCustom( const QString &app, const QString &name) |
1970 | { | 1953 | { |
1971 | detach(); | 1954 | detach(); |
1972 | 1955 | ||
1973 | QString qualifiedName = app + "-" + name + ":"; | 1956 | QString qualifiedName = app + "-" + name + ":"; |
1974 | 1957 | ||
1975 | QStringList::Iterator it; | 1958 | QStringList::Iterator it; |
1976 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1959 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1977 | if ( (*it).startsWith( qualifiedName ) ) { | 1960 | if ( (*it).startsWith( qualifiedName ) ) { |
1978 | mData->custom.remove( it ); | 1961 | mData->custom.remove( it ); |
1979 | return; | 1962 | return; |
1980 | } | 1963 | } |
1981 | } | 1964 | } |
1982 | } | 1965 | } |
1983 | 1966 | ||
1984 | QString Addressee::custom( const QString &app, const QString &name ) const | 1967 | QString Addressee::custom( const QString &app, const QString &name ) const |
1985 | { | 1968 | { |
1986 | QString qualifiedName = app + "-" + name + ":"; | 1969 | QString qualifiedName = app + "-" + name + ":"; |
1987 | QString value; | 1970 | QString value; |
1988 | 1971 | ||
1989 | QStringList::ConstIterator it; | 1972 | QStringList::ConstIterator it; |
1990 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1973 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1991 | if ( (*it).startsWith( qualifiedName ) ) { | 1974 | if ( (*it).startsWith( qualifiedName ) ) { |
1992 | value = (*it).mid( (*it).find( ":" ) + 1 ); | 1975 | value = (*it).mid( (*it).find( ":" ) + 1 ); |
1993 | break; | 1976 | break; |
1994 | } | 1977 | } |
1995 | } | 1978 | } |
1996 | 1979 | ||
1997 | return value; | 1980 | return value; |
1998 | } | 1981 | } |
1999 | 1982 | ||
2000 | void Addressee::setCustoms( const QStringList &l ) | 1983 | void Addressee::setCustoms( const QStringList &l ) |
2001 | { | 1984 | { |
2002 | detach(); | 1985 | detach(); |
2003 | mData->empty = false; | 1986 | mData->empty = false; |
2004 | 1987 | ||
2005 | mData->custom = l; | 1988 | mData->custom = l; |
2006 | } | 1989 | } |
2007 | 1990 | ||
2008 | QStringList Addressee::customs() const | 1991 | QStringList Addressee::customs() const |
2009 | { | 1992 | { |
2010 | return mData->custom; | 1993 | return mData->custom; |
2011 | } | 1994 | } |
2012 | 1995 | ||
2013 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, | 1996 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, |
2014 | QString &email) | 1997 | QString &email) |
2015 | { | 1998 | { |
2016 | int startPos, endPos, len; | 1999 | int startPos, endPos, len; |
2017 | QString partA, partB, result; | 2000 | QString partA, partB, result; |
2018 | char endCh = '>'; | 2001 | char endCh = '>'; |
2019 | 2002 | ||
2020 | startPos = rawEmail.find('<'); | 2003 | startPos = rawEmail.find('<'); |
2021 | if (startPos < 0) | 2004 | if (startPos < 0) |
2022 | { | 2005 | { |
2023 | startPos = rawEmail.find('('); | 2006 | startPos = rawEmail.find('('); |
2024 | endCh = ')'; | 2007 | endCh = ')'; |
2025 | } | 2008 | } |
2026 | if (startPos < 0) | 2009 | if (startPos < 0) |
2027 | { | 2010 | { |
2028 | // We couldn't find any separators, so we assume the whole string | 2011 | // We couldn't find any separators, so we assume the whole string |
2029 | // is the email address | 2012 | // is the email address |
2030 | email = rawEmail; | 2013 | email = rawEmail; |
2031 | fullName = ""; | 2014 | fullName = ""; |
2032 | } | 2015 | } |
2033 | else | 2016 | else |
2034 | { | 2017 | { |
2035 | // We have a start position, try to find an end | 2018 | // We have a start position, try to find an end |
2036 | endPos = rawEmail.find(endCh, startPos+1); | 2019 | endPos = rawEmail.find(endCh, startPos+1); |
2037 | 2020 | ||
2038 | if (endPos < 0) | 2021 | if (endPos < 0) |
2039 | { | 2022 | { |
2040 | // We couldn't find the end of the email address. We can only | 2023 | // We couldn't find the end of the email address. We can only |
2041 | // assume the entire string is the email address. | 2024 | // assume the entire string is the email address. |
2042 | email = rawEmail; | 2025 | email = rawEmail; |
2043 | fullName = ""; | 2026 | fullName = ""; |
2044 | } | 2027 | } |
2045 | else | 2028 | else |
2046 | { | 2029 | { |
2047 | // We have a start and end to the email address | 2030 | // We have a start and end to the email address |
2048 | 2031 | ||
2049 | // Grab the name part | 2032 | // Grab the name part |
2050 | fullName = rawEmail.left(startPos).stripWhiteSpace(); | 2033 | fullName = rawEmail.left(startPos).stripWhiteSpace(); |
2051 | 2034 | ||
2052 | // grab the email part | 2035 | // grab the email part |
2053 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); | 2036 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); |
2054 | 2037 | ||
2055 | // Check that we do not have any extra characters on the end of the | 2038 | // Check that we do not have any extra characters on the end of the |
2056 | // strings | 2039 | // strings |
2057 | len = fullName.length(); | 2040 | len = fullName.length(); |
2058 | if (fullName[0]=='"' && fullName[len-1]=='"') | 2041 | if (fullName[0]=='"' && fullName[len-1]=='"') |
2059 | fullName = fullName.mid(1, len-2); | 2042 | fullName = fullName.mid(1, len-2); |
2060 | else if (fullName[0]=='<' && fullName[len-1]=='>') | 2043 | else if (fullName[0]=='<' && fullName[len-1]=='>') |
2061 | fullName = fullName.mid(1, len-2); | 2044 | fullName = fullName.mid(1, len-2); |
2062 | else if (fullName[0]=='(' && fullName[len-1]==')') | 2045 | else if (fullName[0]=='(' && fullName[len-1]==')') |
2063 | fullName = fullName.mid(1, len-2); | 2046 | fullName = fullName.mid(1, len-2); |
2064 | } | 2047 | } |
2065 | } | 2048 | } |
2066 | } | 2049 | } |
2067 | 2050 | ||
2068 | void Addressee::setResource( Resource *resource ) | 2051 | void Addressee::setResource( Resource *resource ) |
2069 | { | 2052 | { |
2070 | detach(); | 2053 | detach(); |
2071 | mData->resource = resource; | 2054 | mData->resource = resource; |
2072 | } | 2055 | } |
2073 | 2056 | ||
2074 | Resource *Addressee::resource() const | 2057 | Resource *Addressee::resource() const |
2075 | { | 2058 | { |
2076 | return mData->resource; | 2059 | return mData->resource; |
2077 | } | 2060 | } |
2078 | 2061 | ||
2079 | //US | 2062 | //US |
2080 | QString Addressee::resourceLabel() | 2063 | QString Addressee::resourceLabel() |
2081 | { | 2064 | { |
2082 | return i18n("Resource"); | 2065 | return i18n("Resource"); |
2083 | } | 2066 | } |
2084 | QString Addressee::categoryLabel() | 2067 | QString Addressee::categoryLabel() |
2085 | { | 2068 | { |
2086 | return i18n("Category"); | 2069 | return i18n("Category"); |
2087 | } | 2070 | } |
2088 | 2071 | ||
2089 | void Addressee::setChanged( bool value ) | 2072 | void Addressee::setChanged( bool value ) |
2090 | { | 2073 | { |
2091 | detach(); | 2074 | detach(); |
2092 | mData->changed = value; | 2075 | mData->changed = value; |
2093 | } | 2076 | } |
2094 | 2077 | ||
2095 | bool Addressee::changed() const | 2078 | bool Addressee::changed() const |
2096 | { | 2079 | { |
2097 | return mData->changed; | 2080 | return mData->changed; |
2098 | } | 2081 | } |
2099 | 2082 | ||
2100 | void Addressee::setTagged( bool value ) | 2083 | void Addressee::setTagged( bool value ) |
2101 | { | 2084 | { |
2102 | detach(); | 2085 | detach(); |
2103 | mData->tagged = value; | 2086 | mData->tagged = value; |
2104 | } | 2087 | } |
2105 | 2088 | ||
2106 | bool Addressee::tagged() const | 2089 | bool Addressee::tagged() const |
2107 | { | 2090 | { |
2108 | return mData->tagged; | 2091 | return mData->tagged; |
2109 | } | 2092 | } |
2110 | 2093 | ||
2111 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) | 2094 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) |
2112 | { | 2095 | { |
2113 | if (!a.mData) return s; | 2096 | if (!a.mData) return s; |
2114 | 2097 | ||
2115 | s << a.uid(); | 2098 | s << a.uid(); |
2116 | 2099 | ||
2117 | s << a.mData->name; | 2100 | s << a.mData->name; |
2118 | s << a.mData->formattedName; | 2101 | s << a.mData->formattedName; |
2119 | s << a.mData->familyName; | 2102 | s << a.mData->familyName; |
2120 | s << a.mData->givenName; | 2103 | s << a.mData->givenName; |
2121 | s << a.mData->additionalName; | 2104 | s << a.mData->additionalName; |
2122 | s << a.mData->prefix; | 2105 | s << a.mData->prefix; |
2123 | s << a.mData->suffix; | 2106 | s << a.mData->suffix; |
2124 | s << a.mData->nickName; | 2107 | s << a.mData->nickName; |
2125 | s << a.mData->birthday; | 2108 | s << a.mData->birthday; |
2126 | s << a.mData->mailer; | 2109 | s << a.mData->mailer; |
2127 | s << a.mData->timeZone; | 2110 | s << a.mData->timeZone; |
2128 | s << a.mData->geo; | 2111 | s << a.mData->geo; |
2129 | s << a.mData->title; | 2112 | s << a.mData->title; |
2130 | s << a.mData->role; | 2113 | s << a.mData->role; |
2131 | s << a.mData->organization; | 2114 | s << a.mData->organization; |
2132 | s << a.mData->note; | 2115 | s << a.mData->note; |
2133 | s << a.mData->productId; | 2116 | s << a.mData->productId; |
2134 | s << a.mData->revision; | 2117 | s << a.mData->revision; |
2135 | s << a.mData->sortString; | 2118 | s << a.mData->sortString; |
2136 | s << a.mData->url; | 2119 | s << a.mData->url; |
2137 | s << a.mData->secrecy; | 2120 | s << a.mData->secrecy; |
2138 | s << a.mData->logo; | 2121 | s << a.mData->logo; |
2139 | s << a.mData->photo; | 2122 | s << a.mData->photo; |
2140 | s << a.mData->sound; | 2123 | s << a.mData->sound; |
2141 | s << a.mData->agent; | 2124 | s << a.mData->agent; |
2142 | s << a.mData->phoneNumbers; | 2125 | s << a.mData->phoneNumbers; |
2143 | s << a.mData->addresses; | 2126 | s << a.mData->addresses; |
2144 | s << a.mData->emails; | 2127 | s << a.mData->emails; |
2145 | s << a.mData->categories; | 2128 | s << a.mData->categories; |
2146 | s << a.mData->custom; | 2129 | s << a.mData->custom; |
2147 | s << a.mData->keys; | 2130 | s << a.mData->keys; |
2148 | return s; | 2131 | return s; |
2149 | } | 2132 | } |
2150 | 2133 | ||
2151 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) | 2134 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) |
2152 | { | 2135 | { |
2153 | if (!a.mData) return s; | 2136 | if (!a.mData) return s; |
2154 | 2137 | ||
2155 | s >> a.mData->uid; | 2138 | s >> a.mData->uid; |
2156 | 2139 | ||
2157 | s >> a.mData->name; | 2140 | s >> a.mData->name; |
2158 | s >> a.mData->formattedName; | 2141 | s >> a.mData->formattedName; |
2159 | s >> a.mData->familyName; | 2142 | s >> a.mData->familyName; |
2160 | s >> a.mData->givenName; | 2143 | s >> a.mData->givenName; |
2161 | s >> a.mData->additionalName; | 2144 | s >> a.mData->additionalName; |
2162 | s >> a.mData->prefix; | 2145 | s >> a.mData->prefix; |
2163 | s >> a.mData->suffix; | 2146 | s >> a.mData->suffix; |
2164 | s >> a.mData->nickName; | 2147 | s >> a.mData->nickName; |
2165 | s >> a.mData->birthday; | 2148 | s >> a.mData->birthday; |
2166 | s >> a.mData->mailer; | 2149 | s >> a.mData->mailer; |
2167 | s >> a.mData->timeZone; | 2150 | s >> a.mData->timeZone; |
2168 | s >> a.mData->geo; | 2151 | s >> a.mData->geo; |
2169 | s >> a.mData->title; | 2152 | s >> a.mData->title; |
2170 | s >> a.mData->role; | 2153 | s >> a.mData->role; |
2171 | s >> a.mData->organization; | 2154 | s >> a.mData->organization; |
2172 | s >> a.mData->note; | 2155 | s >> a.mData->note; |
2173 | s >> a.mData->productId; | 2156 | s >> a.mData->productId; |
2174 | s >> a.mData->revision; | 2157 | s >> a.mData->revision; |
2175 | s >> a.mData->sortString; | 2158 | s >> a.mData->sortString; |
2176 | s >> a.mData->url; | 2159 | s >> a.mData->url; |
2177 | s >> a.mData->secrecy; | 2160 | s >> a.mData->secrecy; |
2178 | s >> a.mData->logo; | 2161 | s >> a.mData->logo; |
2179 | s >> a.mData->photo; | 2162 | s >> a.mData->photo; |
2180 | s >> a.mData->sound; | 2163 | s >> a.mData->sound; |
2181 | s >> a.mData->agent; | 2164 | s >> a.mData->agent; |
2182 | s >> a.mData->phoneNumbers; | 2165 | s >> a.mData->phoneNumbers; |
2183 | s >> a.mData->addresses; | 2166 | s >> a.mData->addresses; |
2184 | s >> a.mData->emails; | 2167 | s >> a.mData->emails; |
2185 | s >> a.mData->categories; | 2168 | s >> a.mData->categories; |
2186 | s >> a.mData->custom; | 2169 | s >> a.mData->custom; |
2187 | s >> a.mData->keys; | 2170 | s >> a.mData->keys; |
2188 | 2171 | ||
2189 | a.mData->empty = false; | 2172 | a.mData->empty = false; |
2190 | 2173 | ||
2191 | return s; | 2174 | return s; |
2192 | } | 2175 | } |
2193 | bool matchBinaryPattern( int value, int pattern ) | 2176 | bool matchBinaryPattern( int value, int pattern ) |
2194 | { | 2177 | { |
2195 | /** | 2178 | /** |
2196 | We want to match all telephonnumbers/addresses which have the bits in the | 2179 | We want to match all telephonnumbers/addresses which have the bits in the |
2197 | pattern set. More are allowed. | 2180 | pattern set. More are allowed. |
2198 | if pattern == 0 we have a special handling, then we want only those with | 2181 | if pattern == 0 we have a special handling, then we want only those with |
2199 | exactly no bit set. | 2182 | exactly no bit set. |
2200 | */ | 2183 | */ |
2201 | if ( pattern == 0 ) | 2184 | if ( pattern == 0 ) |
2202 | return ( value == 0 ); | 2185 | return ( value == 0 ); |
2203 | else | 2186 | else |
2204 | return ( pattern == ( pattern & value ) ); | 2187 | return ( pattern == ( pattern & value ) ); |
2205 | } | 2188 | } |
2206 | 2189 | ||
2207 | bool matchBinaryPatternP( int value, int pattern ) | 2190 | bool matchBinaryPatternP( int value, int pattern ) |
2208 | { | 2191 | { |
2209 | 2192 | ||
2210 | if ( pattern == 0 ) | 2193 | if ( pattern == 0 ) |
2211 | return ( value == 0 ); | 2194 | return ( value == 0 ); |
2212 | else | 2195 | else |
2213 | return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); | 2196 | return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); |
2214 | } | 2197 | } |
2215 | bool matchBinaryPatternA( int value, int pattern ) | 2198 | bool matchBinaryPatternA( int value, int pattern ) |
2216 | { | 2199 | { |
2217 | 2200 | ||
2218 | if ( pattern == 0 ) | 2201 | if ( pattern == 0 ) |
2219 | return ( value == 0 ); | 2202 | return ( value == 0 ); |
2220 | else | 2203 | else |
2221 | return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); | 2204 | return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); |
2222 | } | 2205 | } |