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