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