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