-rw-r--r-- | kabc/addressee.cpp | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 0157721..3a2dc5f 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,1326 +1,1333 @@ | |||
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( const Addressee& ad ) | 276 | void Addressee::mergeContact( const Addressee& ad ) |
277 | { | 277 | { |
278 | 278 | ||
279 | detach(); | 279 | detach(); |
280 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 280 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
281 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 281 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
282 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 282 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
283 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 283 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
284 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 284 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
285 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 285 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
286 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 286 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
287 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 287 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
288 | if ( !mData->birthday.isValid() ) | 288 | if ( !mData->birthday.isValid() ) |
289 | if ( ad.mData->birthday.isValid()) | 289 | if ( ad.mData->birthday.isValid()) |
290 | mData->birthday = ad.mData->birthday; | 290 | mData->birthday = ad.mData->birthday; |
291 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 291 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
292 | #if 0 | 292 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
293 | if ( !mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 293 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
294 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 294 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
295 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 295 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
296 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 296 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
297 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 297 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
298 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 298 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
299 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 299 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
300 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 300 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
301 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 301 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
302 | #endif | 302 | |
303 | // pending: | ||
304 | // merging phonenumbers | ||
305 | // merging addresses | ||
306 | // merging emails; | ||
307 | // merging categories; | ||
308 | // merging custom; | ||
309 | // merging keys | ||
303 | } | 310 | } |
304 | 311 | ||
305 | void Addressee::removeID(const QString &prof) | 312 | void Addressee::removeID(const QString &prof) |
306 | { | 313 | { |
307 | detach(); | 314 | detach(); |
308 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 315 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
309 | 316 | ||
310 | } | 317 | } |
311 | void Addressee::setID( const QString & prof , const QString & id ) | 318 | void Addressee::setID( const QString & prof , const QString & id ) |
312 | { | 319 | { |
313 | detach(); | 320 | detach(); |
314 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 321 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
315 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 322 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
316 | } | 323 | } |
317 | void Addressee::setTempSyncStat( int id ) | 324 | void Addressee::setTempSyncStat( int id ) |
318 | { | 325 | { |
319 | if ( mData->mTempSyncStat == id ) return; | 326 | if ( mData->mTempSyncStat == id ) return; |
320 | detach(); | 327 | detach(); |
321 | mData->mTempSyncStat = id; | 328 | mData->mTempSyncStat = id; |
322 | } | 329 | } |
323 | int Addressee::tempSyncStat() const | 330 | int Addressee::tempSyncStat() const |
324 | { | 331 | { |
325 | return mData->mTempSyncStat; | 332 | return mData->mTempSyncStat; |
326 | } | 333 | } |
327 | 334 | ||
328 | QString Addressee::getID( const QString & prof) | 335 | QString Addressee::getID( const QString & prof) |
329 | { | 336 | { |
330 | return KIdManager::getId ( mData->mExternalId, prof ); | 337 | return KIdManager::getId ( mData->mExternalId, prof ); |
331 | } | 338 | } |
332 | 339 | ||
333 | void Addressee::setCsum( const QString & prof , const QString & id ) | 340 | void Addressee::setCsum( const QString & prof , const QString & id ) |
334 | { | 341 | { |
335 | detach(); | 342 | detach(); |
336 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 343 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
337 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 344 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
338 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 345 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
339 | } | 346 | } |
340 | 347 | ||
341 | QString Addressee::getCsum( const QString & prof) | 348 | QString Addressee::getCsum( const QString & prof) |
342 | { | 349 | { |
343 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 350 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
344 | } | 351 | } |
345 | 352 | ||
346 | void Addressee::setIDStr( const QString & s ) | 353 | void Addressee::setIDStr( const QString & s ) |
347 | { | 354 | { |
348 | detach(); | 355 | detach(); |
349 | mData->mExternalId = s; | 356 | mData->mExternalId = s; |
350 | } | 357 | } |
351 | 358 | ||
352 | QString Addressee::IDStr() const | 359 | QString Addressee::IDStr() const |
353 | { | 360 | { |
354 | return mData->mExternalId; | 361 | return mData->mExternalId; |
355 | } | 362 | } |
356 | 363 | ||
357 | void Addressee::setExternalUID( const QString &id ) | 364 | void Addressee::setExternalUID( const QString &id ) |
358 | { | 365 | { |
359 | if ( id == mData->externalUID ) return; | 366 | if ( id == mData->externalUID ) return; |
360 | detach(); | 367 | detach(); |
361 | mData->empty = false; | 368 | mData->empty = false; |
362 | mData->externalUID = id; | 369 | mData->externalUID = id; |
363 | } | 370 | } |
364 | 371 | ||
365 | QString Addressee::externalUID() const | 372 | QString Addressee::externalUID() const |
366 | { | 373 | { |
367 | return mData->externalUID; | 374 | return mData->externalUID; |
368 | } | 375 | } |
369 | 376 | ||
370 | void Addressee::setUid( const QString &id ) | 377 | void Addressee::setUid( const QString &id ) |
371 | { | 378 | { |
372 | if ( id == mData->uid ) return; | 379 | if ( id == mData->uid ) return; |
373 | detach(); | 380 | detach(); |
374 | mData->empty = false; | 381 | mData->empty = false; |
375 | mData->uid = id; | 382 | mData->uid = id; |
376 | } | 383 | } |
377 | 384 | ||
378 | QString Addressee::uid() const | 385 | QString Addressee::uid() const |
379 | { | 386 | { |
380 | if ( mData->uid.isEmpty() ) | 387 | if ( mData->uid.isEmpty() ) |
381 | mData->uid = KApplication::randomString( 10 ); | 388 | mData->uid = KApplication::randomString( 10 ); |
382 | 389 | ||
383 | return mData->uid; | 390 | return mData->uid; |
384 | } | 391 | } |
385 | 392 | ||
386 | QString Addressee::uidLabel() | 393 | QString Addressee::uidLabel() |
387 | { | 394 | { |
388 | return i18n("Unique Identifier"); | 395 | return i18n("Unique Identifier"); |
389 | } | 396 | } |
390 | 397 | ||
391 | void Addressee::setName( const QString &name ) | 398 | void Addressee::setName( const QString &name ) |
392 | { | 399 | { |
393 | if ( name == mData->name ) return; | 400 | if ( name == mData->name ) return; |
394 | detach(); | 401 | detach(); |
395 | mData->empty = false; | 402 | mData->empty = false; |
396 | mData->name = name; | 403 | mData->name = name; |
397 | } | 404 | } |
398 | 405 | ||
399 | QString Addressee::name() const | 406 | QString Addressee::name() const |
400 | { | 407 | { |
401 | return mData->name; | 408 | return mData->name; |
402 | } | 409 | } |
403 | 410 | ||
404 | QString Addressee::nameLabel() | 411 | QString Addressee::nameLabel() |
405 | { | 412 | { |
406 | return i18n("Name"); | 413 | return i18n("Name"); |
407 | } | 414 | } |
408 | 415 | ||
409 | 416 | ||
410 | void Addressee::setFormattedName( const QString &formattedName ) | 417 | void Addressee::setFormattedName( const QString &formattedName ) |
411 | { | 418 | { |
412 | if ( formattedName == mData->formattedName ) return; | 419 | if ( formattedName == mData->formattedName ) return; |
413 | detach(); | 420 | detach(); |
414 | mData->empty = false; | 421 | mData->empty = false; |
415 | mData->formattedName = formattedName; | 422 | mData->formattedName = formattedName; |
416 | } | 423 | } |
417 | 424 | ||
418 | QString Addressee::formattedName() const | 425 | QString Addressee::formattedName() const |
419 | { | 426 | { |
420 | return mData->formattedName; | 427 | return mData->formattedName; |
421 | } | 428 | } |
422 | 429 | ||
423 | QString Addressee::formattedNameLabel() | 430 | QString Addressee::formattedNameLabel() |
424 | { | 431 | { |
425 | return i18n("Formatted Name"); | 432 | return i18n("Formatted Name"); |
426 | } | 433 | } |
427 | 434 | ||
428 | 435 | ||
429 | void Addressee::setFamilyName( const QString &familyName ) | 436 | void Addressee::setFamilyName( const QString &familyName ) |
430 | { | 437 | { |
431 | if ( familyName == mData->familyName ) return; | 438 | if ( familyName == mData->familyName ) return; |
432 | detach(); | 439 | detach(); |
433 | mData->empty = false; | 440 | mData->empty = false; |
434 | mData->familyName = familyName; | 441 | mData->familyName = familyName; |
435 | } | 442 | } |
436 | 443 | ||
437 | QString Addressee::familyName() const | 444 | QString Addressee::familyName() const |
438 | { | 445 | { |
439 | return mData->familyName; | 446 | return mData->familyName; |
440 | } | 447 | } |
441 | 448 | ||
442 | QString Addressee::familyNameLabel() | 449 | QString Addressee::familyNameLabel() |
443 | { | 450 | { |
444 | return i18n("Family Name"); | 451 | return i18n("Family Name"); |
445 | } | 452 | } |
446 | 453 | ||
447 | 454 | ||
448 | void Addressee::setGivenName( const QString &givenName ) | 455 | void Addressee::setGivenName( const QString &givenName ) |
449 | { | 456 | { |
450 | if ( givenName == mData->givenName ) return; | 457 | if ( givenName == mData->givenName ) return; |
451 | detach(); | 458 | detach(); |
452 | mData->empty = false; | 459 | mData->empty = false; |
453 | mData->givenName = givenName; | 460 | mData->givenName = givenName; |
454 | } | 461 | } |
455 | 462 | ||
456 | QString Addressee::givenName() const | 463 | QString Addressee::givenName() const |
457 | { | 464 | { |
458 | return mData->givenName; | 465 | return mData->givenName; |
459 | } | 466 | } |
460 | 467 | ||
461 | QString Addressee::givenNameLabel() | 468 | QString Addressee::givenNameLabel() |
462 | { | 469 | { |
463 | return i18n("Given Name"); | 470 | return i18n("Given Name"); |
464 | } | 471 | } |
465 | 472 | ||
466 | 473 | ||
467 | void Addressee::setAdditionalName( const QString &additionalName ) | 474 | void Addressee::setAdditionalName( const QString &additionalName ) |
468 | { | 475 | { |
469 | if ( additionalName == mData->additionalName ) return; | 476 | if ( additionalName == mData->additionalName ) return; |
470 | detach(); | 477 | detach(); |
471 | mData->empty = false; | 478 | mData->empty = false; |
472 | mData->additionalName = additionalName; | 479 | mData->additionalName = additionalName; |
473 | } | 480 | } |
474 | 481 | ||
475 | QString Addressee::additionalName() const | 482 | QString Addressee::additionalName() const |
476 | { | 483 | { |
477 | return mData->additionalName; | 484 | return mData->additionalName; |
478 | } | 485 | } |
479 | 486 | ||
480 | QString Addressee::additionalNameLabel() | 487 | QString Addressee::additionalNameLabel() |
481 | { | 488 | { |
482 | return i18n("Additional Names"); | 489 | return i18n("Additional Names"); |
483 | } | 490 | } |
484 | 491 | ||
485 | 492 | ||
486 | void Addressee::setPrefix( const QString &prefix ) | 493 | void Addressee::setPrefix( const QString &prefix ) |
487 | { | 494 | { |
488 | if ( prefix == mData->prefix ) return; | 495 | if ( prefix == mData->prefix ) return; |
489 | detach(); | 496 | detach(); |
490 | mData->empty = false; | 497 | mData->empty = false; |
491 | mData->prefix = prefix; | 498 | mData->prefix = prefix; |
492 | } | 499 | } |
493 | 500 | ||
494 | QString Addressee::prefix() const | 501 | QString Addressee::prefix() const |
495 | { | 502 | { |
496 | return mData->prefix; | 503 | return mData->prefix; |
497 | } | 504 | } |
498 | 505 | ||
499 | QString Addressee::prefixLabel() | 506 | QString Addressee::prefixLabel() |
500 | { | 507 | { |
501 | return i18n("Honorific Prefixes"); | 508 | return i18n("Honorific Prefixes"); |
502 | } | 509 | } |
503 | 510 | ||
504 | 511 | ||
505 | void Addressee::setSuffix( const QString &suffix ) | 512 | void Addressee::setSuffix( const QString &suffix ) |
506 | { | 513 | { |
507 | if ( suffix == mData->suffix ) return; | 514 | if ( suffix == mData->suffix ) return; |
508 | detach(); | 515 | detach(); |
509 | mData->empty = false; | 516 | mData->empty = false; |
510 | mData->suffix = suffix; | 517 | mData->suffix = suffix; |
511 | } | 518 | } |
512 | 519 | ||
513 | QString Addressee::suffix() const | 520 | QString Addressee::suffix() const |
514 | { | 521 | { |
515 | return mData->suffix; | 522 | return mData->suffix; |
516 | } | 523 | } |
517 | 524 | ||
518 | QString Addressee::suffixLabel() | 525 | QString Addressee::suffixLabel() |
519 | { | 526 | { |
520 | return i18n("Honorific Suffixes"); | 527 | return i18n("Honorific Suffixes"); |
521 | } | 528 | } |
522 | 529 | ||
523 | 530 | ||
524 | void Addressee::setNickName( const QString &nickName ) | 531 | void Addressee::setNickName( const QString &nickName ) |
525 | { | 532 | { |
526 | if ( nickName == mData->nickName ) return; | 533 | if ( nickName == mData->nickName ) return; |
527 | detach(); | 534 | detach(); |
528 | mData->empty = false; | 535 | mData->empty = false; |
529 | mData->nickName = nickName; | 536 | mData->nickName = nickName; |
530 | } | 537 | } |
531 | 538 | ||
532 | QString Addressee::nickName() const | 539 | QString Addressee::nickName() const |
533 | { | 540 | { |
534 | return mData->nickName; | 541 | return mData->nickName; |
535 | } | 542 | } |
536 | 543 | ||
537 | QString Addressee::nickNameLabel() | 544 | QString Addressee::nickNameLabel() |
538 | { | 545 | { |
539 | return i18n("Nick Name"); | 546 | return i18n("Nick Name"); |
540 | } | 547 | } |
541 | 548 | ||
542 | 549 | ||
543 | void Addressee::setBirthday( const QDateTime &birthday ) | 550 | void Addressee::setBirthday( const QDateTime &birthday ) |
544 | { | 551 | { |
545 | if ( birthday == mData->birthday ) return; | 552 | if ( birthday == mData->birthday ) return; |
546 | detach(); | 553 | detach(); |
547 | mData->empty = false; | 554 | mData->empty = false; |
548 | mData->birthday = birthday; | 555 | mData->birthday = birthday; |
549 | } | 556 | } |
550 | 557 | ||
551 | QDateTime Addressee::birthday() const | 558 | QDateTime Addressee::birthday() const |
552 | { | 559 | { |
553 | return mData->birthday; | 560 | return mData->birthday; |
554 | } | 561 | } |
555 | 562 | ||
556 | QString Addressee::birthdayLabel() | 563 | QString Addressee::birthdayLabel() |
557 | { | 564 | { |
558 | return i18n("Birthday"); | 565 | return i18n("Birthday"); |
559 | } | 566 | } |
560 | 567 | ||
561 | 568 | ||
562 | QString Addressee::homeAddressStreetLabel() | 569 | QString Addressee::homeAddressStreetLabel() |
563 | { | 570 | { |
564 | return i18n("Home Address Street"); | 571 | return i18n("Home Address Street"); |
565 | } | 572 | } |
566 | 573 | ||
567 | 574 | ||
568 | QString Addressee::homeAddressLocalityLabel() | 575 | QString Addressee::homeAddressLocalityLabel() |
569 | { | 576 | { |
570 | return i18n("Home Address Locality"); | 577 | return i18n("Home Address Locality"); |
571 | } | 578 | } |
572 | 579 | ||
573 | 580 | ||
574 | QString Addressee::homeAddressRegionLabel() | 581 | QString Addressee::homeAddressRegionLabel() |
575 | { | 582 | { |
576 | return i18n("Home Address Region"); | 583 | return i18n("Home Address Region"); |
577 | } | 584 | } |
578 | 585 | ||
579 | 586 | ||
580 | QString Addressee::homeAddressPostalCodeLabel() | 587 | QString Addressee::homeAddressPostalCodeLabel() |
581 | { | 588 | { |
582 | return i18n("Home Address Postal Code"); | 589 | return i18n("Home Address Postal Code"); |
583 | } | 590 | } |
584 | 591 | ||
585 | 592 | ||
586 | QString Addressee::homeAddressCountryLabel() | 593 | QString Addressee::homeAddressCountryLabel() |
587 | { | 594 | { |
588 | return i18n("Home Address Country"); | 595 | return i18n("Home Address Country"); |
589 | } | 596 | } |
590 | 597 | ||
591 | 598 | ||
592 | QString Addressee::homeAddressLabelLabel() | 599 | QString Addressee::homeAddressLabelLabel() |
593 | { | 600 | { |
594 | return i18n("Home Address Label"); | 601 | return i18n("Home Address Label"); |
595 | } | 602 | } |
596 | 603 | ||
597 | 604 | ||
598 | QString Addressee::businessAddressStreetLabel() | 605 | QString Addressee::businessAddressStreetLabel() |
599 | { | 606 | { |
600 | return i18n("Business Address Street"); | 607 | return i18n("Business Address Street"); |
601 | } | 608 | } |
602 | 609 | ||
603 | 610 | ||
604 | QString Addressee::businessAddressLocalityLabel() | 611 | QString Addressee::businessAddressLocalityLabel() |
605 | { | 612 | { |
606 | return i18n("Business Address Locality"); | 613 | return i18n("Business Address Locality"); |
607 | } | 614 | } |
608 | 615 | ||
609 | 616 | ||
610 | QString Addressee::businessAddressRegionLabel() | 617 | QString Addressee::businessAddressRegionLabel() |
611 | { | 618 | { |
612 | return i18n("Business Address Region"); | 619 | return i18n("Business Address Region"); |
613 | } | 620 | } |
614 | 621 | ||
615 | 622 | ||
616 | QString Addressee::businessAddressPostalCodeLabel() | 623 | QString Addressee::businessAddressPostalCodeLabel() |
617 | { | 624 | { |
618 | return i18n("Business Address Postal Code"); | 625 | return i18n("Business Address Postal Code"); |
619 | } | 626 | } |
620 | 627 | ||
621 | 628 | ||
622 | QString Addressee::businessAddressCountryLabel() | 629 | QString Addressee::businessAddressCountryLabel() |
623 | { | 630 | { |
624 | return i18n("Business Address Country"); | 631 | return i18n("Business Address Country"); |
625 | } | 632 | } |
626 | 633 | ||
627 | 634 | ||
628 | QString Addressee::businessAddressLabelLabel() | 635 | QString Addressee::businessAddressLabelLabel() |
629 | { | 636 | { |
630 | return i18n("Business Address Label"); | 637 | return i18n("Business Address Label"); |
631 | } | 638 | } |
632 | 639 | ||
633 | 640 | ||
634 | QString Addressee::homePhoneLabel() | 641 | QString Addressee::homePhoneLabel() |
635 | { | 642 | { |
636 | return i18n("Home Phone"); | 643 | return i18n("Home Phone"); |
637 | } | 644 | } |
638 | 645 | ||
639 | 646 | ||
640 | QString Addressee::businessPhoneLabel() | 647 | QString Addressee::businessPhoneLabel() |
641 | { | 648 | { |
642 | return i18n("Business Phone"); | 649 | return i18n("Business Phone"); |
643 | } | 650 | } |
644 | 651 | ||
645 | 652 | ||
646 | QString Addressee::mobilePhoneLabel() | 653 | QString Addressee::mobilePhoneLabel() |
647 | { | 654 | { |
648 | return i18n("Mobile Phone"); | 655 | return i18n("Mobile Phone"); |
649 | } | 656 | } |
650 | 657 | ||
651 | 658 | ||
652 | QString Addressee::homeFaxLabel() | 659 | QString Addressee::homeFaxLabel() |
653 | { | 660 | { |
654 | return i18n("Home Fax"); | 661 | return i18n("Home Fax"); |
655 | } | 662 | } |
656 | 663 | ||
657 | 664 | ||
658 | QString Addressee::businessFaxLabel() | 665 | QString Addressee::businessFaxLabel() |
659 | { | 666 | { |
660 | return i18n("Business Fax"); | 667 | return i18n("Business Fax"); |
661 | } | 668 | } |
662 | 669 | ||
663 | 670 | ||
664 | QString Addressee::carPhoneLabel() | 671 | QString Addressee::carPhoneLabel() |
665 | { | 672 | { |
666 | return i18n("Car Phone"); | 673 | return i18n("Car Phone"); |
667 | } | 674 | } |
668 | 675 | ||
669 | 676 | ||
670 | QString Addressee::isdnLabel() | 677 | QString Addressee::isdnLabel() |
671 | { | 678 | { |
672 | return i18n("ISDN"); | 679 | return i18n("ISDN"); |
673 | } | 680 | } |
674 | 681 | ||
675 | 682 | ||
676 | QString Addressee::pagerLabel() | 683 | QString Addressee::pagerLabel() |
677 | { | 684 | { |
678 | return i18n("Pager"); | 685 | return i18n("Pager"); |
679 | } | 686 | } |
680 | 687 | ||
681 | QString Addressee::sipLabel() | 688 | QString Addressee::sipLabel() |
682 | { | 689 | { |
683 | return i18n("SIP"); | 690 | return i18n("SIP"); |
684 | } | 691 | } |
685 | 692 | ||
686 | QString Addressee::emailLabel() | 693 | QString Addressee::emailLabel() |
687 | { | 694 | { |
688 | return i18n("Email Address"); | 695 | return i18n("Email Address"); |
689 | } | 696 | } |
690 | 697 | ||
691 | 698 | ||
692 | void Addressee::setMailer( const QString &mailer ) | 699 | void Addressee::setMailer( const QString &mailer ) |
693 | { | 700 | { |
694 | if ( mailer == mData->mailer ) return; | 701 | if ( mailer == mData->mailer ) return; |
695 | detach(); | 702 | detach(); |
696 | mData->empty = false; | 703 | mData->empty = false; |
697 | mData->mailer = mailer; | 704 | mData->mailer = mailer; |
698 | } | 705 | } |
699 | 706 | ||
700 | QString Addressee::mailer() const | 707 | QString Addressee::mailer() const |
701 | { | 708 | { |
702 | return mData->mailer; | 709 | return mData->mailer; |
703 | } | 710 | } |
704 | 711 | ||
705 | QString Addressee::mailerLabel() | 712 | QString Addressee::mailerLabel() |
706 | { | 713 | { |
707 | return i18n("Mail Client"); | 714 | return i18n("Mail Client"); |
708 | } | 715 | } |
709 | 716 | ||
710 | 717 | ||
711 | void Addressee::setTimeZone( const TimeZone &timeZone ) | 718 | void Addressee::setTimeZone( const TimeZone &timeZone ) |
712 | { | 719 | { |
713 | if ( timeZone == mData->timeZone ) return; | 720 | if ( timeZone == mData->timeZone ) return; |
714 | detach(); | 721 | detach(); |
715 | mData->empty = false; | 722 | mData->empty = false; |
716 | mData->timeZone = timeZone; | 723 | mData->timeZone = timeZone; |
717 | } | 724 | } |
718 | 725 | ||
719 | TimeZone Addressee::timeZone() const | 726 | TimeZone Addressee::timeZone() const |
720 | { | 727 | { |
721 | return mData->timeZone; | 728 | return mData->timeZone; |
722 | } | 729 | } |
723 | 730 | ||
724 | QString Addressee::timeZoneLabel() | 731 | QString Addressee::timeZoneLabel() |
725 | { | 732 | { |
726 | return i18n("Time Zone"); | 733 | return i18n("Time Zone"); |
727 | } | 734 | } |
728 | 735 | ||
729 | 736 | ||
730 | void Addressee::setGeo( const Geo &geo ) | 737 | void Addressee::setGeo( const Geo &geo ) |
731 | { | 738 | { |
732 | if ( geo == mData->geo ) return; | 739 | if ( geo == mData->geo ) return; |
733 | detach(); | 740 | detach(); |
734 | mData->empty = false; | 741 | mData->empty = false; |
735 | mData->geo = geo; | 742 | mData->geo = geo; |
736 | } | 743 | } |
737 | 744 | ||
738 | Geo Addressee::geo() const | 745 | Geo Addressee::geo() const |
739 | { | 746 | { |
740 | return mData->geo; | 747 | return mData->geo; |
741 | } | 748 | } |
742 | 749 | ||
743 | QString Addressee::geoLabel() | 750 | QString Addressee::geoLabel() |
744 | { | 751 | { |
745 | return i18n("Geographic Position"); | 752 | return i18n("Geographic Position"); |
746 | } | 753 | } |
747 | 754 | ||
748 | 755 | ||
749 | void Addressee::setTitle( const QString &title ) | 756 | void Addressee::setTitle( const QString &title ) |
750 | { | 757 | { |
751 | if ( title == mData->title ) return; | 758 | if ( title == mData->title ) return; |
752 | detach(); | 759 | detach(); |
753 | mData->empty = false; | 760 | mData->empty = false; |
754 | mData->title = title; | 761 | mData->title = title; |
755 | } | 762 | } |
756 | 763 | ||
757 | QString Addressee::title() const | 764 | QString Addressee::title() const |
758 | { | 765 | { |
759 | return mData->title; | 766 | return mData->title; |
760 | } | 767 | } |
761 | 768 | ||
762 | QString Addressee::titleLabel() | 769 | QString Addressee::titleLabel() |
763 | { | 770 | { |
764 | return i18n("Title"); | 771 | return i18n("Title"); |
765 | } | 772 | } |
766 | 773 | ||
767 | 774 | ||
768 | void Addressee::setRole( const QString &role ) | 775 | void Addressee::setRole( const QString &role ) |
769 | { | 776 | { |
770 | if ( role == mData->role ) return; | 777 | if ( role == mData->role ) return; |
771 | detach(); | 778 | detach(); |
772 | mData->empty = false; | 779 | mData->empty = false; |
773 | mData->role = role; | 780 | mData->role = role; |
774 | } | 781 | } |
775 | 782 | ||
776 | QString Addressee::role() const | 783 | QString Addressee::role() const |
777 | { | 784 | { |
778 | return mData->role; | 785 | return mData->role; |
779 | } | 786 | } |
780 | 787 | ||
781 | QString Addressee::roleLabel() | 788 | QString Addressee::roleLabel() |
782 | { | 789 | { |
783 | return i18n("Role"); | 790 | return i18n("Role"); |
784 | } | 791 | } |
785 | 792 | ||
786 | 793 | ||
787 | void Addressee::setOrganization( const QString &organization ) | 794 | void Addressee::setOrganization( const QString &organization ) |
788 | { | 795 | { |
789 | if ( organization == mData->organization ) return; | 796 | if ( organization == mData->organization ) return; |
790 | detach(); | 797 | detach(); |
791 | mData->empty = false; | 798 | mData->empty = false; |
792 | mData->organization = organization; | 799 | mData->organization = organization; |
793 | } | 800 | } |
794 | 801 | ||
795 | QString Addressee::organization() const | 802 | QString Addressee::organization() const |
796 | { | 803 | { |
797 | return mData->organization; | 804 | return mData->organization; |
798 | } | 805 | } |
799 | 806 | ||
800 | QString Addressee::organizationLabel() | 807 | QString Addressee::organizationLabel() |
801 | { | 808 | { |
802 | return i18n("Organization"); | 809 | return i18n("Organization"); |
803 | } | 810 | } |
804 | 811 | ||
805 | 812 | ||
806 | void Addressee::setNote( const QString ¬e ) | 813 | void Addressee::setNote( const QString ¬e ) |
807 | { | 814 | { |
808 | if ( note == mData->note ) return; | 815 | if ( note == mData->note ) return; |
809 | detach(); | 816 | detach(); |
810 | mData->empty = false; | 817 | mData->empty = false; |
811 | mData->note = note; | 818 | mData->note = note; |
812 | } | 819 | } |
813 | 820 | ||
814 | QString Addressee::note() const | 821 | QString Addressee::note() const |
815 | { | 822 | { |
816 | return mData->note; | 823 | return mData->note; |
817 | } | 824 | } |
818 | 825 | ||
819 | QString Addressee::noteLabel() | 826 | QString Addressee::noteLabel() |
820 | { | 827 | { |
821 | return i18n("Note"); | 828 | return i18n("Note"); |
822 | } | 829 | } |
823 | 830 | ||
824 | 831 | ||
825 | void Addressee::setProductId( const QString &productId ) | 832 | void Addressee::setProductId( const QString &productId ) |
826 | { | 833 | { |
827 | if ( productId == mData->productId ) return; | 834 | if ( productId == mData->productId ) return; |
828 | detach(); | 835 | detach(); |
829 | mData->empty = false; | 836 | mData->empty = false; |
830 | mData->productId = productId; | 837 | mData->productId = productId; |
831 | } | 838 | } |
832 | 839 | ||
833 | QString Addressee::productId() const | 840 | QString Addressee::productId() const |
834 | { | 841 | { |
835 | return mData->productId; | 842 | return mData->productId; |
836 | } | 843 | } |
837 | 844 | ||
838 | QString Addressee::productIdLabel() | 845 | QString Addressee::productIdLabel() |
839 | { | 846 | { |
840 | return i18n("Product Identifier"); | 847 | return i18n("Product Identifier"); |
841 | } | 848 | } |
842 | 849 | ||
843 | 850 | ||
844 | void Addressee::setRevision( const QDateTime &revision ) | 851 | void Addressee::setRevision( const QDateTime &revision ) |
845 | { | 852 | { |
846 | if ( revision == mData->revision ) return; | 853 | if ( revision == mData->revision ) return; |
847 | detach(); | 854 | detach(); |
848 | mData->empty = false; | 855 | mData->empty = false; |
849 | mData->revision = revision; | 856 | mData->revision = revision; |
850 | } | 857 | } |
851 | 858 | ||
852 | QDateTime Addressee::revision() const | 859 | QDateTime Addressee::revision() const |
853 | { | 860 | { |
854 | return mData->revision; | 861 | return mData->revision; |
855 | } | 862 | } |
856 | 863 | ||
857 | QString Addressee::revisionLabel() | 864 | QString Addressee::revisionLabel() |
858 | { | 865 | { |
859 | return i18n("Revision Date"); | 866 | return i18n("Revision Date"); |
860 | } | 867 | } |
861 | 868 | ||
862 | 869 | ||
863 | void Addressee::setSortString( const QString &sortString ) | 870 | void Addressee::setSortString( const QString &sortString ) |
864 | { | 871 | { |
865 | if ( sortString == mData->sortString ) return; | 872 | if ( sortString == mData->sortString ) return; |
866 | detach(); | 873 | detach(); |
867 | mData->empty = false; | 874 | mData->empty = false; |
868 | mData->sortString = sortString; | 875 | mData->sortString = sortString; |
869 | } | 876 | } |
870 | 877 | ||
871 | QString Addressee::sortString() const | 878 | QString Addressee::sortString() const |
872 | { | 879 | { |
873 | return mData->sortString; | 880 | return mData->sortString; |
874 | } | 881 | } |
875 | 882 | ||
876 | QString Addressee::sortStringLabel() | 883 | QString Addressee::sortStringLabel() |
877 | { | 884 | { |
878 | return i18n("Sort String"); | 885 | return i18n("Sort String"); |
879 | } | 886 | } |
880 | 887 | ||
881 | 888 | ||
882 | void Addressee::setUrl( const KURL &url ) | 889 | void Addressee::setUrl( const KURL &url ) |
883 | { | 890 | { |
884 | if ( url == mData->url ) return; | 891 | if ( url == mData->url ) return; |
885 | detach(); | 892 | detach(); |
886 | mData->empty = false; | 893 | mData->empty = false; |
887 | mData->url = url; | 894 | mData->url = url; |
888 | } | 895 | } |
889 | 896 | ||
890 | KURL Addressee::url() const | 897 | KURL Addressee::url() const |
891 | { | 898 | { |
892 | return mData->url; | 899 | return mData->url; |
893 | } | 900 | } |
894 | 901 | ||
895 | QString Addressee::urlLabel() | 902 | QString Addressee::urlLabel() |
896 | { | 903 | { |
897 | return i18n("URL"); | 904 | return i18n("URL"); |
898 | } | 905 | } |
899 | 906 | ||
900 | 907 | ||
901 | void Addressee::setSecrecy( const Secrecy &secrecy ) | 908 | void Addressee::setSecrecy( const Secrecy &secrecy ) |
902 | { | 909 | { |
903 | if ( secrecy == mData->secrecy ) return; | 910 | if ( secrecy == mData->secrecy ) return; |
904 | detach(); | 911 | detach(); |
905 | mData->empty = false; | 912 | mData->empty = false; |
906 | mData->secrecy = secrecy; | 913 | mData->secrecy = secrecy; |
907 | } | 914 | } |
908 | 915 | ||
909 | Secrecy Addressee::secrecy() const | 916 | Secrecy Addressee::secrecy() const |
910 | { | 917 | { |
911 | return mData->secrecy; | 918 | return mData->secrecy; |
912 | } | 919 | } |
913 | 920 | ||
914 | QString Addressee::secrecyLabel() | 921 | QString Addressee::secrecyLabel() |
915 | { | 922 | { |
916 | return i18n("Security Class"); | 923 | return i18n("Security Class"); |
917 | } | 924 | } |
918 | 925 | ||
919 | 926 | ||
920 | void Addressee::setLogo( const Picture &logo ) | 927 | void Addressee::setLogo( const Picture &logo ) |
921 | { | 928 | { |
922 | if ( logo == mData->logo ) return; | 929 | if ( logo == mData->logo ) return; |
923 | detach(); | 930 | detach(); |
924 | mData->empty = false; | 931 | mData->empty = false; |
925 | mData->logo = logo; | 932 | mData->logo = logo; |
926 | } | 933 | } |
927 | 934 | ||
928 | Picture Addressee::logo() const | 935 | Picture Addressee::logo() const |
929 | { | 936 | { |
930 | return mData->logo; | 937 | return mData->logo; |
931 | } | 938 | } |
932 | 939 | ||
933 | QString Addressee::logoLabel() | 940 | QString Addressee::logoLabel() |
934 | { | 941 | { |
935 | return i18n("Logo"); | 942 | return i18n("Logo"); |
936 | } | 943 | } |
937 | 944 | ||
938 | 945 | ||
939 | void Addressee::setPhoto( const Picture &photo ) | 946 | void Addressee::setPhoto( const Picture &photo ) |
940 | { | 947 | { |
941 | if ( photo == mData->photo ) return; | 948 | if ( photo == mData->photo ) return; |
942 | detach(); | 949 | detach(); |
943 | mData->empty = false; | 950 | mData->empty = false; |
944 | mData->photo = photo; | 951 | mData->photo = photo; |
945 | } | 952 | } |
946 | 953 | ||
947 | Picture Addressee::photo() const | 954 | Picture Addressee::photo() const |
948 | { | 955 | { |
949 | return mData->photo; | 956 | return mData->photo; |
950 | } | 957 | } |
951 | 958 | ||
952 | QString Addressee::photoLabel() | 959 | QString Addressee::photoLabel() |
953 | { | 960 | { |
954 | return i18n("Photo"); | 961 | return i18n("Photo"); |
955 | } | 962 | } |
956 | 963 | ||
957 | 964 | ||
958 | void Addressee::setSound( const Sound &sound ) | 965 | void Addressee::setSound( const Sound &sound ) |
959 | { | 966 | { |
960 | if ( sound == mData->sound ) return; | 967 | if ( sound == mData->sound ) return; |
961 | detach(); | 968 | detach(); |
962 | mData->empty = false; | 969 | mData->empty = false; |
963 | mData->sound = sound; | 970 | mData->sound = sound; |
964 | } | 971 | } |
965 | 972 | ||
966 | Sound Addressee::sound() const | 973 | Sound Addressee::sound() const |
967 | { | 974 | { |
968 | return mData->sound; | 975 | return mData->sound; |
969 | } | 976 | } |
970 | 977 | ||
971 | QString Addressee::soundLabel() | 978 | QString Addressee::soundLabel() |
972 | { | 979 | { |
973 | return i18n("Sound"); | 980 | return i18n("Sound"); |
974 | } | 981 | } |
975 | 982 | ||
976 | 983 | ||
977 | void Addressee::setAgent( const Agent &agent ) | 984 | void Addressee::setAgent( const Agent &agent ) |
978 | { | 985 | { |
979 | if ( agent == mData->agent ) return; | 986 | if ( agent == mData->agent ) return; |
980 | detach(); | 987 | detach(); |
981 | mData->empty = false; | 988 | mData->empty = false; |
982 | mData->agent = agent; | 989 | mData->agent = agent; |
983 | } | 990 | } |
984 | 991 | ||
985 | Agent Addressee::agent() const | 992 | Agent Addressee::agent() const |
986 | { | 993 | { |
987 | return mData->agent; | 994 | return mData->agent; |
988 | } | 995 | } |
989 | 996 | ||
990 | QString Addressee::agentLabel() | 997 | QString Addressee::agentLabel() |
991 | { | 998 | { |
992 | return i18n("Agent"); | 999 | return i18n("Agent"); |
993 | } | 1000 | } |
994 | 1001 | ||
995 | 1002 | ||
996 | 1003 | ||
997 | void Addressee::setNameFromString( const QString &str ) | 1004 | void Addressee::setNameFromString( const QString &str ) |
998 | { | 1005 | { |
999 | setFormattedName( str ); | 1006 | setFormattedName( str ); |
1000 | setName( str ); | 1007 | setName( str ); |
1001 | 1008 | ||
1002 | static bool first = true; | 1009 | static bool first = true; |
1003 | static QStringList titles; | 1010 | static QStringList titles; |
1004 | static QStringList suffixes; | 1011 | static QStringList suffixes; |
1005 | static QStringList prefixes; | 1012 | static QStringList prefixes; |
1006 | 1013 | ||
1007 | if ( first ) { | 1014 | if ( first ) { |
1008 | first = false; | 1015 | first = false; |
1009 | titles += i18n( "Dr." ); | 1016 | titles += i18n( "Dr." ); |
1010 | titles += i18n( "Miss" ); | 1017 | titles += i18n( "Miss" ); |
1011 | titles += i18n( "Mr." ); | 1018 | titles += i18n( "Mr." ); |
1012 | titles += i18n( "Mrs." ); | 1019 | titles += i18n( "Mrs." ); |
1013 | titles += i18n( "Ms." ); | 1020 | titles += i18n( "Ms." ); |
1014 | titles += i18n( "Prof." ); | 1021 | titles += i18n( "Prof." ); |
1015 | 1022 | ||
1016 | suffixes += i18n( "I" ); | 1023 | suffixes += i18n( "I" ); |
1017 | suffixes += i18n( "II" ); | 1024 | suffixes += i18n( "II" ); |
1018 | suffixes += i18n( "III" ); | 1025 | suffixes += i18n( "III" ); |
1019 | suffixes += i18n( "Jr." ); | 1026 | suffixes += i18n( "Jr." ); |
1020 | suffixes += i18n( "Sr." ); | 1027 | suffixes += i18n( "Sr." ); |
1021 | 1028 | ||
1022 | prefixes += "van"; | 1029 | prefixes += "van"; |
1023 | prefixes += "von"; | 1030 | prefixes += "von"; |
1024 | prefixes += "de"; | 1031 | prefixes += "de"; |
1025 | 1032 | ||
1026 | KConfig config( locateLocal( "config", "kabcrc") ); | 1033 | KConfig config( locateLocal( "config", "kabcrc") ); |
1027 | config.setGroup( "General" ); | 1034 | config.setGroup( "General" ); |
1028 | titles += config.readListEntry( "Prefixes" ); | 1035 | titles += config.readListEntry( "Prefixes" ); |
1029 | titles.remove( "" ); | 1036 | titles.remove( "" ); |
1030 | prefixes += config.readListEntry( "Inclusions" ); | 1037 | prefixes += config.readListEntry( "Inclusions" ); |
1031 | prefixes.remove( "" ); | 1038 | prefixes.remove( "" ); |
1032 | suffixes += config.readListEntry( "Suffixes" ); | 1039 | suffixes += config.readListEntry( "Suffixes" ); |
1033 | suffixes.remove( "" ); | 1040 | suffixes.remove( "" ); |
1034 | } | 1041 | } |
1035 | 1042 | ||
1036 | // clear all name parts | 1043 | // clear all name parts |
1037 | setPrefix( "" ); | 1044 | setPrefix( "" ); |
1038 | setGivenName( "" ); | 1045 | setGivenName( "" ); |
1039 | setAdditionalName( "" ); | 1046 | setAdditionalName( "" ); |
1040 | setFamilyName( "" ); | 1047 | setFamilyName( "" ); |
1041 | setSuffix( "" ); | 1048 | setSuffix( "" ); |
1042 | 1049 | ||
1043 | if ( str.isEmpty() ) | 1050 | if ( str.isEmpty() ) |
1044 | return; | 1051 | return; |
1045 | 1052 | ||
1046 | int i = str.find(','); | 1053 | int i = str.find(','); |
1047 | if( i < 0 ) { | 1054 | if( i < 0 ) { |
1048 | QStringList parts = QStringList::split( " ", str ); | 1055 | QStringList parts = QStringList::split( " ", str ); |
1049 | int leftOffset = 0; | 1056 | int leftOffset = 0; |
1050 | int rightOffset = parts.count() - 1; | 1057 | int rightOffset = parts.count() - 1; |
1051 | 1058 | ||
1052 | QString suffix; | 1059 | QString suffix; |
1053 | while ( rightOffset >= 0 ) { | 1060 | while ( rightOffset >= 0 ) { |
1054 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1061 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1055 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1062 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1056 | rightOffset--; | 1063 | rightOffset--; |
1057 | } else | 1064 | } else |
1058 | break; | 1065 | break; |
1059 | } | 1066 | } |
1060 | setSuffix( suffix ); | 1067 | setSuffix( suffix ); |
1061 | 1068 | ||
1062 | if ( rightOffset < 0 ) | 1069 | if ( rightOffset < 0 ) |
1063 | return; | 1070 | return; |
1064 | 1071 | ||
1065 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1072 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1066 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1073 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1067 | rightOffset--; | 1074 | rightOffset--; |
1068 | } else | 1075 | } else |
1069 | setFamilyName( parts[ rightOffset ] ); | 1076 | setFamilyName( parts[ rightOffset ] ); |
1070 | 1077 | ||
1071 | QString prefix; | 1078 | QString prefix; |
1072 | while ( leftOffset < rightOffset ) { | 1079 | while ( leftOffset < rightOffset ) { |
1073 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1080 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1074 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1081 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1075 | leftOffset++; | 1082 | leftOffset++; |
1076 | } else | 1083 | } else |
1077 | break; | 1084 | break; |
1078 | } | 1085 | } |
1079 | setPrefix( prefix ); | 1086 | setPrefix( prefix ); |
1080 | 1087 | ||
1081 | if ( leftOffset < rightOffset ) { | 1088 | if ( leftOffset < rightOffset ) { |
1082 | setGivenName( parts[ leftOffset ] ); | 1089 | setGivenName( parts[ leftOffset ] ); |
1083 | leftOffset++; | 1090 | leftOffset++; |
1084 | } | 1091 | } |
1085 | 1092 | ||
1086 | QString additionalName; | 1093 | QString additionalName; |
1087 | while ( leftOffset < rightOffset ) { | 1094 | while ( leftOffset < rightOffset ) { |
1088 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1095 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1089 | leftOffset++; | 1096 | leftOffset++; |
1090 | } | 1097 | } |
1091 | setAdditionalName( additionalName ); | 1098 | setAdditionalName( additionalName ); |
1092 | } else { | 1099 | } else { |
1093 | QString part1 = str.left( i ); | 1100 | QString part1 = str.left( i ); |
1094 | QString part2 = str.mid( i + 1 ); | 1101 | QString part2 = str.mid( i + 1 ); |
1095 | 1102 | ||
1096 | QStringList parts = QStringList::split( " ", part1 ); | 1103 | QStringList parts = QStringList::split( " ", part1 ); |
1097 | int leftOffset = 0; | 1104 | int leftOffset = 0; |
1098 | int rightOffset = parts.count() - 1; | 1105 | int rightOffset = parts.count() - 1; |
1099 | 1106 | ||
1100 | QString suffix; | 1107 | QString suffix; |
1101 | while ( rightOffset >= 0 ) { | 1108 | while ( rightOffset >= 0 ) { |
1102 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1109 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1103 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1110 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1104 | rightOffset--; | 1111 | rightOffset--; |
1105 | } else | 1112 | } else |
1106 | break; | 1113 | break; |
1107 | } | 1114 | } |
1108 | setSuffix( suffix ); | 1115 | setSuffix( suffix ); |
1109 | 1116 | ||
1110 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1117 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1111 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1118 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1112 | rightOffset--; | 1119 | rightOffset--; |
1113 | } else | 1120 | } else |
1114 | setFamilyName( parts[ rightOffset ] ); | 1121 | setFamilyName( parts[ rightOffset ] ); |
1115 | 1122 | ||
1116 | QString prefix; | 1123 | QString prefix; |
1117 | while ( leftOffset < rightOffset ) { | 1124 | while ( leftOffset < rightOffset ) { |
1118 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1125 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1119 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1126 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1120 | leftOffset++; | 1127 | leftOffset++; |
1121 | } else | 1128 | } else |
1122 | break; | 1129 | break; |
1123 | } | 1130 | } |
1124 | 1131 | ||
1125 | parts = QStringList::split( " ", part2 ); | 1132 | parts = QStringList::split( " ", part2 ); |
1126 | 1133 | ||
1127 | leftOffset = 0; | 1134 | leftOffset = 0; |
1128 | rightOffset = parts.count(); | 1135 | rightOffset = parts.count(); |
1129 | 1136 | ||
1130 | while ( leftOffset < rightOffset ) { | 1137 | while ( leftOffset < rightOffset ) { |
1131 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1138 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1132 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1139 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1133 | leftOffset++; | 1140 | leftOffset++; |
1134 | } else | 1141 | } else |
1135 | break; | 1142 | break; |
1136 | } | 1143 | } |
1137 | setPrefix( prefix ); | 1144 | setPrefix( prefix ); |
1138 | 1145 | ||
1139 | if ( leftOffset < rightOffset ) { | 1146 | if ( leftOffset < rightOffset ) { |
1140 | setGivenName( parts[ leftOffset ] ); | 1147 | setGivenName( parts[ leftOffset ] ); |
1141 | leftOffset++; | 1148 | leftOffset++; |
1142 | } | 1149 | } |
1143 | 1150 | ||
1144 | QString additionalName; | 1151 | QString additionalName; |
1145 | while ( leftOffset < rightOffset ) { | 1152 | while ( leftOffset < rightOffset ) { |
1146 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1153 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1147 | leftOffset++; | 1154 | leftOffset++; |
1148 | } | 1155 | } |
1149 | setAdditionalName( additionalName ); | 1156 | setAdditionalName( additionalName ); |
1150 | } | 1157 | } |
1151 | } | 1158 | } |
1152 | 1159 | ||
1153 | QString Addressee::realName() const | 1160 | QString Addressee::realName() const |
1154 | { | 1161 | { |
1155 | if ( !formattedName().isEmpty() ) | 1162 | if ( !formattedName().isEmpty() ) |
1156 | return formattedName(); | 1163 | return formattedName(); |
1157 | 1164 | ||
1158 | QString n = assembledName(); | 1165 | QString n = assembledName(); |
1159 | 1166 | ||
1160 | if ( n.isEmpty() ) | 1167 | if ( n.isEmpty() ) |
1161 | n = name(); | 1168 | n = name(); |
1162 | 1169 | ||
1163 | return n; | 1170 | return n; |
1164 | } | 1171 | } |
1165 | 1172 | ||
1166 | QString Addressee::assembledName() const | 1173 | QString Addressee::assembledName() const |
1167 | { | 1174 | { |
1168 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + | 1175 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + |
1169 | familyName() + " " + suffix(); | 1176 | familyName() + " " + suffix(); |
1170 | 1177 | ||
1171 | return name.simplifyWhiteSpace(); | 1178 | return name.simplifyWhiteSpace(); |
1172 | } | 1179 | } |
1173 | 1180 | ||
1174 | QString Addressee::fullEmail( const QString &email ) const | 1181 | QString Addressee::fullEmail( const QString &email ) const |
1175 | { | 1182 | { |
1176 | QString e; | 1183 | QString e; |
1177 | if ( email.isNull() ) { | 1184 | if ( email.isNull() ) { |
1178 | e = preferredEmail(); | 1185 | e = preferredEmail(); |
1179 | } else { | 1186 | } else { |
1180 | e = email; | 1187 | e = email; |
1181 | } | 1188 | } |
1182 | if ( e.isEmpty() ) return QString::null; | 1189 | if ( e.isEmpty() ) return QString::null; |
1183 | 1190 | ||
1184 | QString text; | 1191 | QString text; |
1185 | if ( realName().isEmpty() ) | 1192 | if ( realName().isEmpty() ) |
1186 | text = e; | 1193 | text = e; |
1187 | else | 1194 | else |
1188 | text = assembledName() + " <" + e + ">"; | 1195 | text = assembledName() + " <" + e + ">"; |
1189 | 1196 | ||
1190 | return text; | 1197 | return text; |
1191 | } | 1198 | } |
1192 | 1199 | ||
1193 | void Addressee::insertEmail( const QString &email, bool preferred ) | 1200 | void Addressee::insertEmail( const QString &email, bool preferred ) |
1194 | { | 1201 | { |
1195 | detach(); | 1202 | detach(); |
1196 | 1203 | ||
1197 | QStringList::Iterator it = mData->emails.find( email ); | 1204 | QStringList::Iterator it = mData->emails.find( email ); |
1198 | 1205 | ||
1199 | if ( it != mData->emails.end() ) { | 1206 | if ( it != mData->emails.end() ) { |
1200 | if ( !preferred || it == mData->emails.begin() ) return; | 1207 | if ( !preferred || it == mData->emails.begin() ) return; |
1201 | mData->emails.remove( it ); | 1208 | mData->emails.remove( it ); |
1202 | mData->emails.prepend( email ); | 1209 | mData->emails.prepend( email ); |
1203 | } else { | 1210 | } else { |
1204 | if ( preferred ) { | 1211 | if ( preferred ) { |
1205 | mData->emails.prepend( email ); | 1212 | mData->emails.prepend( email ); |
1206 | } else { | 1213 | } else { |
1207 | mData->emails.append( email ); | 1214 | mData->emails.append( email ); |
1208 | } | 1215 | } |
1209 | } | 1216 | } |
1210 | } | 1217 | } |
1211 | 1218 | ||
1212 | void Addressee::removeEmail( const QString &email ) | 1219 | void Addressee::removeEmail( const QString &email ) |
1213 | { | 1220 | { |
1214 | detach(); | 1221 | detach(); |
1215 | 1222 | ||
1216 | QStringList::Iterator it = mData->emails.find( email ); | 1223 | QStringList::Iterator it = mData->emails.find( email ); |
1217 | if ( it == mData->emails.end() ) return; | 1224 | if ( it == mData->emails.end() ) return; |
1218 | 1225 | ||
1219 | mData->emails.remove( it ); | 1226 | mData->emails.remove( it ); |
1220 | } | 1227 | } |
1221 | 1228 | ||
1222 | QString Addressee::preferredEmail() const | 1229 | QString Addressee::preferredEmail() const |
1223 | { | 1230 | { |
1224 | if ( mData->emails.count() == 0 ) return QString::null; | 1231 | if ( mData->emails.count() == 0 ) return QString::null; |
1225 | else return mData->emails.first(); | 1232 | else return mData->emails.first(); |
1226 | } | 1233 | } |
1227 | 1234 | ||
1228 | QStringList Addressee::emails() const | 1235 | QStringList Addressee::emails() const |
1229 | { | 1236 | { |
1230 | return mData->emails; | 1237 | return mData->emails; |
1231 | } | 1238 | } |
1232 | void Addressee::setEmails( const QStringList& emails ) { | 1239 | void Addressee::setEmails( const QStringList& emails ) { |
1233 | detach(); | 1240 | detach(); |
1234 | mData->emails = emails; | 1241 | mData->emails = emails; |
1235 | } | 1242 | } |
1236 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) | 1243 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) |
1237 | { | 1244 | { |
1238 | detach(); | 1245 | detach(); |
1239 | mData->empty = false; | 1246 | mData->empty = false; |
1240 | 1247 | ||
1241 | PhoneNumber::List::Iterator it; | 1248 | PhoneNumber::List::Iterator it; |
1242 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1249 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1243 | if ( (*it).id() == phoneNumber.id() ) { | 1250 | if ( (*it).id() == phoneNumber.id() ) { |
1244 | *it = phoneNumber; | 1251 | *it = phoneNumber; |
1245 | return; | 1252 | return; |
1246 | } | 1253 | } |
1247 | } | 1254 | } |
1248 | mData->phoneNumbers.append( phoneNumber ); | 1255 | mData->phoneNumbers.append( phoneNumber ); |
1249 | } | 1256 | } |
1250 | 1257 | ||
1251 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) | 1258 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) |
1252 | { | 1259 | { |
1253 | detach(); | 1260 | detach(); |
1254 | 1261 | ||
1255 | PhoneNumber::List::Iterator it; | 1262 | PhoneNumber::List::Iterator it; |
1256 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1263 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1257 | if ( (*it).id() == phoneNumber.id() ) { | 1264 | if ( (*it).id() == phoneNumber.id() ) { |
1258 | mData->phoneNumbers.remove( it ); | 1265 | mData->phoneNumbers.remove( it ); |
1259 | return; | 1266 | return; |
1260 | } | 1267 | } |
1261 | } | 1268 | } |
1262 | } | 1269 | } |
1263 | 1270 | ||
1264 | PhoneNumber Addressee::phoneNumber( int type ) const | 1271 | PhoneNumber Addressee::phoneNumber( int type ) const |
1265 | { | 1272 | { |
1266 | PhoneNumber phoneNumber( "", type ); | 1273 | PhoneNumber phoneNumber( "", type ); |
1267 | PhoneNumber::List::ConstIterator it; | 1274 | PhoneNumber::List::ConstIterator it; |
1268 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1275 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1269 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1276 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1270 | if ( (*it).type() & PhoneNumber::Pref ) | 1277 | if ( (*it).type() & PhoneNumber::Pref ) |
1271 | return (*it); | 1278 | return (*it); |
1272 | else if ( phoneNumber.number().isEmpty() ) | 1279 | else if ( phoneNumber.number().isEmpty() ) |
1273 | phoneNumber = (*it); | 1280 | phoneNumber = (*it); |
1274 | } | 1281 | } |
1275 | } | 1282 | } |
1276 | 1283 | ||
1277 | return phoneNumber; | 1284 | return phoneNumber; |
1278 | } | 1285 | } |
1279 | 1286 | ||
1280 | PhoneNumber::List Addressee::phoneNumbers() const | 1287 | PhoneNumber::List Addressee::phoneNumbers() const |
1281 | { | 1288 | { |
1282 | return mData->phoneNumbers; | 1289 | return mData->phoneNumbers; |
1283 | } | 1290 | } |
1284 | 1291 | ||
1285 | PhoneNumber::List Addressee::phoneNumbers( int type ) const | 1292 | PhoneNumber::List Addressee::phoneNumbers( int type ) const |
1286 | { | 1293 | { |
1287 | PhoneNumber::List list; | 1294 | PhoneNumber::List list; |
1288 | 1295 | ||
1289 | PhoneNumber::List::ConstIterator it; | 1296 | PhoneNumber::List::ConstIterator it; |
1290 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1297 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1291 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1298 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1292 | list.append( *it ); | 1299 | list.append( *it ); |
1293 | } | 1300 | } |
1294 | } | 1301 | } |
1295 | return list; | 1302 | return list; |
1296 | } | 1303 | } |
1297 | 1304 | ||
1298 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const | 1305 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const |
1299 | { | 1306 | { |
1300 | PhoneNumber::List::ConstIterator it; | 1307 | PhoneNumber::List::ConstIterator it; |
1301 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1308 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1302 | if ( (*it).id() == id ) { | 1309 | if ( (*it).id() == id ) { |
1303 | return *it; | 1310 | return *it; |
1304 | } | 1311 | } |
1305 | } | 1312 | } |
1306 | return PhoneNumber(); | 1313 | return PhoneNumber(); |
1307 | } | 1314 | } |
1308 | 1315 | ||
1309 | void Addressee::insertKey( const Key &key ) | 1316 | void Addressee::insertKey( const Key &key ) |
1310 | { | 1317 | { |
1311 | detach(); | 1318 | detach(); |
1312 | mData->empty = false; | 1319 | mData->empty = false; |
1313 | 1320 | ||
1314 | Key::List::Iterator it; | 1321 | Key::List::Iterator it; |
1315 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1322 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1316 | if ( (*it).id() == key.id() ) { | 1323 | if ( (*it).id() == key.id() ) { |
1317 | *it = key; | 1324 | *it = key; |
1318 | return; | 1325 | return; |
1319 | } | 1326 | } |
1320 | } | 1327 | } |
1321 | mData->keys.append( key ); | 1328 | mData->keys.append( key ); |
1322 | } | 1329 | } |
1323 | 1330 | ||
1324 | void Addressee::removeKey( const Key &key ) | 1331 | void Addressee::removeKey( const Key &key ) |
1325 | { | 1332 | { |
1326 | detach(); | 1333 | detach(); |