-rw-r--r-- | kabc/addressee.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 40877ef..a660a9d 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,1324 +1,1327 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <kconfig.h> | 29 | #include <kconfig.h> |
30 | 30 | ||
31 | #include <ksharedptr.h> | 31 | #include <ksharedptr.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <kapplication.h> | 33 | #include <kapplication.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kidmanager.h> | 35 | #include <kidmanager.h> |
36 | //US | 36 | //US |
37 | #include <kstandarddirs.h> | 37 | #include <kstandarddirs.h> |
38 | #include <libkcal/syncdefines.h> | 38 | #include <libkcal/syncdefines.h> |
39 | 39 | ||
40 | //US #include "resource.h" | 40 | //US #include "resource.h" |
41 | #include "addressee.h" | 41 | #include "addressee.h" |
42 | 42 | ||
43 | using namespace KABC; | 43 | using namespace KABC; |
44 | 44 | ||
45 | static bool matchBinaryPattern( int value, int pattern ); | 45 | static bool matchBinaryPattern( int value, int pattern ); |
46 | static bool matchBinaryPatternA( int value, int pattern ); | 46 | static bool matchBinaryPatternA( int value, int pattern ); |
47 | static bool matchBinaryPatternP( int value, int pattern ); | 47 | static bool matchBinaryPatternP( int value, int pattern ); |
48 | 48 | ||
49 | struct Addressee::AddresseeData : public KShared | 49 | struct Addressee::AddresseeData : public KShared |
50 | { | 50 | { |
51 | QString uid; | 51 | QString uid; |
52 | QString name; | 52 | QString name; |
53 | QString formattedName; | 53 | QString formattedName; |
54 | QString familyName; | 54 | QString familyName; |
55 | QString givenName; | 55 | QString givenName; |
56 | QString additionalName; | 56 | QString additionalName; |
57 | QString prefix; | 57 | QString prefix; |
58 | QString suffix; | 58 | QString suffix; |
59 | QString nickName; | 59 | QString nickName; |
60 | QDateTime birthday; | 60 | QDateTime birthday; |
61 | QString mailer; | 61 | QString mailer; |
62 | TimeZone timeZone; | 62 | TimeZone timeZone; |
63 | Geo geo; | 63 | Geo geo; |
64 | QString title; | 64 | QString title; |
65 | QString role; | 65 | QString role; |
66 | QString organization; | 66 | QString organization; |
67 | QString note; | 67 | QString note; |
68 | QString productId; | 68 | QString productId; |
69 | QDateTime revision; | 69 | QDateTime revision; |
70 | QString sortString; | 70 | QString sortString; |
71 | QString externalUID; | 71 | QString externalUID; |
72 | QString originalExternalUID; | 72 | QString originalExternalUID; |
73 | KURL url; | 73 | KURL url; |
74 | Secrecy secrecy; | 74 | Secrecy secrecy; |
75 | Picture logo; | 75 | Picture logo; |
76 | Picture photo; | 76 | Picture photo; |
77 | Sound sound; | 77 | Sound sound; |
78 | Agent agent; | 78 | Agent agent; |
79 | QString mExternalId; | 79 | QString mExternalId; |
80 | PhoneNumber::List phoneNumbers; | 80 | PhoneNumber::List phoneNumbers; |
81 | Address::List addresses; | 81 | Address::List addresses; |
82 | Key::List keys; | 82 | Key::List keys; |
83 | QStringList emails; | 83 | QStringList emails; |
84 | QStringList categories; | 84 | QStringList categories; |
85 | QStringList custom; | 85 | QStringList custom; |
86 | int mTempSyncStat; | 86 | int mTempSyncStat; |
87 | Resource *resource; | 87 | Resource *resource; |
88 | 88 | ||
89 | bool empty :1; | 89 | bool empty :1; |
90 | bool changed :1; | 90 | bool changed :1; |
91 | bool tagged :1; | 91 | bool tagged :1; |
92 | }; | 92 | }; |
93 | 93 | ||
94 | Addressee::Addressee() | 94 | Addressee::Addressee() |
95 | { | 95 | { |
96 | mData = new AddresseeData; | 96 | mData = new AddresseeData; |
97 | mData->empty = true; | 97 | mData->empty = true; |
98 | mData->changed = false; | 98 | mData->changed = false; |
99 | mData->resource = 0; | 99 | mData->resource = 0; |
100 | mData->mExternalId = ":"; | 100 | mData->mExternalId = ":"; |
101 | mData->revision = QDateTime ( QDate( 2003,1,1)); | 101 | mData->revision = QDateTime ( QDate( 2003,1,1)); |
102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
103 | } | 103 | } |
104 | 104 | ||
105 | Addressee::~Addressee() | 105 | Addressee::~Addressee() |
106 | { | 106 | { |
107 | } | 107 | } |
108 | 108 | ||
109 | Addressee::Addressee( const Addressee &a ) | 109 | Addressee::Addressee( const Addressee &a ) |
110 | { | 110 | { |
111 | mData = a.mData; | 111 | mData = a.mData; |
112 | } | 112 | } |
113 | 113 | ||
114 | Addressee &Addressee::operator=( const Addressee &a ) | 114 | Addressee &Addressee::operator=( const Addressee &a ) |
115 | { | 115 | { |
116 | mData = a.mData; | 116 | mData = a.mData; |
117 | return (*this); | 117 | return (*this); |
118 | } | 118 | } |
119 | 119 | ||
120 | Addressee Addressee::copy() | 120 | Addressee Addressee::copy() |
121 | { | 121 | { |
122 | Addressee a; | 122 | Addressee a; |
123 | *(a.mData) = *mData; | 123 | *(a.mData) = *mData; |
124 | return a; | 124 | return a; |
125 | } | 125 | } |
126 | 126 | ||
127 | void Addressee::detach() | 127 | void Addressee::detach() |
128 | { | 128 | { |
129 | if ( mData.count() == 1 ) return; | 129 | if ( mData.count() == 1 ) return; |
130 | *this = copy(); | 130 | *this = copy(); |
131 | } | 131 | } |
132 | 132 | ||
133 | bool Addressee::operator==( const Addressee &a ) const | 133 | bool Addressee::operator==( const Addressee &a ) const |
134 | { | 134 | { |
135 | if ( uid() != a.uid() ) return false; | 135 | if ( uid() != a.uid() ) return false; |
136 | if ( mData->name != a.mData->name ) return false; | 136 | if ( mData->name != a.mData->name ) return false; |
137 | if ( mData->formattedName != a.mData->formattedName ) return false; | 137 | if ( mData->formattedName != a.mData->formattedName ) return false; |
138 | if ( mData->familyName != a.mData->familyName ) return false; | 138 | if ( mData->familyName != a.mData->familyName ) return false; |
139 | if ( mData->givenName != a.mData->givenName ) return false; | 139 | if ( mData->givenName != a.mData->givenName ) return false; |
140 | if ( mData->additionalName != a.mData->additionalName ) return false; | 140 | if ( mData->additionalName != a.mData->additionalName ) return false; |
141 | if ( mData->prefix != a.mData->prefix ) return false; | 141 | if ( mData->prefix != a.mData->prefix ) return false; |
142 | if ( mData->suffix != a.mData->suffix ) return false; | 142 | if ( mData->suffix != a.mData->suffix ) return false; |
143 | if ( mData->nickName != a.mData->nickName ) return false; | 143 | if ( mData->nickName != a.mData->nickName ) return false; |
144 | if ( mData->birthday != a.mData->birthday ) return false; | 144 | if ( mData->birthday != a.mData->birthday ) return false; |
145 | if ( mData->mailer != a.mData->mailer ) return false; | 145 | if ( mData->mailer != a.mData->mailer ) return false; |
146 | if ( mData->timeZone != a.mData->timeZone ) return false; | 146 | if ( mData->timeZone != a.mData->timeZone ) return false; |
147 | if ( mData->geo != a.mData->geo ) return false; | 147 | if ( mData->geo != a.mData->geo ) return false; |
148 | if ( mData->title != a.mData->title ) return false; | 148 | if ( mData->title != a.mData->title ) return false; |
149 | if ( mData->role != a.mData->role ) return false; | 149 | if ( mData->role != a.mData->role ) return false; |
150 | if ( mData->organization != a.mData->organization ) return false; | 150 | if ( mData->organization != a.mData->organization ) return false; |
151 | if ( mData->note != a.mData->note ) return false; | 151 | if ( mData->note != a.mData->note ) return false; |
152 | if ( mData->productId != a.mData->productId ) return false; | 152 | if ( mData->productId != a.mData->productId ) return false; |
153 | //if ( mData->revision != a.mData->revision ) return false; | 153 | //if ( mData->revision != a.mData->revision ) return false; |
154 | if ( mData->sortString != a.mData->sortString ) return false; | 154 | if ( mData->sortString != a.mData->sortString ) return false; |
155 | if ( mData->secrecy != a.mData->secrecy ) return false; | 155 | if ( mData->secrecy != a.mData->secrecy ) return false; |
156 | if ( mData->logo != a.mData->logo ) return false; | 156 | if ( mData->logo != a.mData->logo ) return false; |
157 | if ( mData->photo != a.mData->photo ) return false; | 157 | if ( mData->photo != a.mData->photo ) return false; |
158 | if ( mData->sound != a.mData->sound ) return false; | 158 | if ( mData->sound != a.mData->sound ) return false; |
159 | if ( mData->agent != a.mData->agent ) return false; | 159 | if ( mData->agent != a.mData->agent ) return false; |
160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
161 | ( mData->url != a.mData->url ) ) return false; | 161 | ( mData->url != a.mData->url ) ) return false; |
162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
163 | if ( mData->addresses != a.mData->addresses ) return false; | 163 | if ( mData->addresses != a.mData->addresses ) return false; |
164 | if ( mData->keys != a.mData->keys ) return false; | 164 | if ( mData->keys != a.mData->keys ) return false; |
165 | if ( mData->emails != a.mData->emails ) return false; | 165 | if ( mData->emails != a.mData->emails ) return false; |
166 | if ( mData->categories != a.mData->categories ) return false; | 166 | if ( mData->categories != a.mData->categories ) return false; |
167 | if ( mData->custom != a.mData->custom ) return false; | 167 | if ( mData->custom != a.mData->custom ) return false; |
168 | 168 | ||
169 | return true; | 169 | return true; |
170 | } | 170 | } |
171 | 171 | ||
172 | bool Addressee::operator!=( const Addressee &a ) const | 172 | bool Addressee::operator!=( const Addressee &a ) const |
173 | { | 173 | { |
174 | return !( a == *this ); | 174 | return !( a == *this ); |
175 | } | 175 | } |
176 | 176 | ||
177 | bool Addressee::isEmpty() const | 177 | bool Addressee::isEmpty() const |
178 | { | 178 | { |
179 | return mData->empty; | 179 | return mData->empty; |
180 | } | 180 | } |
181 | ulong Addressee::getCsum4List( const QStringList & attList) | 181 | ulong Addressee::getCsum4List( const QStringList & attList) |
182 | { | 182 | { |
183 | int max = attList.count(); | 183 | int max = attList.count(); |
184 | ulong cSum = 0; | 184 | ulong cSum = 0; |
185 | int j,k,i; | 185 | int j,k,i; |
186 | int add; | 186 | int add; |
187 | for ( i = 0; i < max ; ++i ) { | 187 | for ( i = 0; i < max ; ++i ) { |
188 | QString s = attList[i]; | 188 | QString s = attList[i]; |
189 | if ( ! s.isEmpty() ){ | 189 | if ( ! s.isEmpty() ){ |
190 | j = s.length(); | 190 | j = s.length(); |
191 | for ( k = 0; k < j; ++k ) { | 191 | for ( k = 0; k < j; ++k ) { |
192 | int mul = k +1; | 192 | int mul = k +1; |
193 | add = s[k].unicode (); | 193 | add = s[k].unicode (); |
194 | if ( k < 16 ) | 194 | if ( k < 16 ) |
195 | mul = mul * mul; | 195 | mul = mul * mul; |
196 | int ii = i+1; | 196 | int ii = i+1; |
197 | add = add * mul *ii*ii*ii; | 197 | add = add * mul *ii*ii*ii; |
198 | cSum += add; | 198 | cSum += add; |
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | } | 202 | } |
203 | //QString dump = attList.join(","); | 203 | //QString dump = attList.join(","); |
204 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 204 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
205 | 205 | ||
206 | return cSum; | 206 | return cSum; |
207 | 207 | ||
208 | } | 208 | } |
209 | void Addressee::computeCsum(const QString &dev) | 209 | void Addressee::computeCsum(const QString &dev) |
210 | { | 210 | { |
211 | QStringList l; | 211 | QStringList l; |
212 | if ( !mData->name.isEmpty() ) l.append(mData->name); | 212 | if ( !mData->name.isEmpty() ) l.append(mData->name); |
213 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 213 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
216 | if ( !mData->additionalName ) l.append( mData->additionalName ); | 216 | if ( !mData->additionalName ) l.append( mData->additionalName ); |
217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
231 | // if ( !mData->logo.isEmpty() ) l.append( ); | 231 | // if ( !mData->logo.isEmpty() ) l.append( ); |
232 | //if ( !mData->photo.isEmpty() ) l.append( ); | 232 | //if ( !mData->photo.isEmpty() ) l.append( ); |
233 | //if ( !mData->sound.isEmpty() ) l.append( ); | 233 | //if ( !mData->sound.isEmpty() ) l.append( ); |
234 | //if ( !mData->agent.isEmpty() ) l.append( ); | 234 | //if ( !mData->agent.isEmpty() ) l.append( ); |
235 | if ( mData->url.isValid() ) | 235 | if ( mData->url.isValid() ) |
236 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); | 236 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); |
237 | KABC::PhoneNumber::List phoneNumbers; | 237 | KABC::PhoneNumber::List phoneNumbers; |
238 | KABC::PhoneNumber::List::Iterator phoneIter; | 238 | KABC::PhoneNumber::List::Iterator phoneIter; |
239 | 239 | ||
240 | QStringList t; | 240 | QStringList t; |
241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
242 | ++phoneIter ) | 242 | ++phoneIter ) |
243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
244 | t.sort(); | 244 | t.sort(); |
245 | uint iii; | 245 | uint iii; |
246 | for ( iii = 0; iii < t.count(); ++iii) | 246 | for ( iii = 0; iii < t.count(); ++iii) |
247 | l.append( t[iii] ); | 247 | l.append( t[iii] ); |
248 | t = mData->emails; | 248 | t = mData->emails; |
249 | t.sort(); | 249 | t.sort(); |
250 | for ( iii = 0; iii < t.count(); ++iii) | 250 | for ( iii = 0; iii < t.count(); ++iii) |
251 | l.append( t[iii] ); | 251 | l.append( t[iii] ); |
252 | t = mData->categories; | 252 | t = mData->categories; |
253 | t.sort(); | 253 | t.sort(); |
254 | for ( iii = 0; iii < t.count(); ++iii) | 254 | for ( iii = 0; iii < t.count(); ++iii) |
255 | l.append( t[iii] ); | 255 | l.append( t[iii] ); |
256 | t = mData->custom; | 256 | t = mData->custom; |
257 | t.sort(); | 257 | t.sort(); |
258 | for ( iii = 0; iii < t.count(); ++iii) | 258 | for ( iii = 0; iii < t.count(); ++iii) |
259 | l.append( t[iii] ); | 259 | l.append( t[iii] ); |
260 | KABC::Address::List::Iterator addressIter; | 260 | KABC::Address::List::Iterator addressIter; |
261 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 261 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
262 | ++addressIter ) { | 262 | ++addressIter ) { |
263 | t = (*addressIter).asList(); | 263 | t = (*addressIter).asList(); |
264 | t.sort(); | 264 | t.sort(); |
265 | for ( iii = 0; iii < t.count(); ++iii) | 265 | for ( iii = 0; iii < t.count(); ++iii) |
266 | l.append( t[iii] ); | 266 | l.append( t[iii] ); |
267 | } | 267 | } |
268 | uint cs = getCsum4List(l); | 268 | uint cs = getCsum4List(l); |
269 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 269 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
270 | setCsum( dev, QString::number (cs )); | 270 | setCsum( dev, QString::number (cs )); |
271 | } | 271 | } |
272 | 272 | ||
273 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | 273 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) |
274 | { | 274 | { |
275 | 275 | ||
276 | detach(); | 276 | detach(); |
277 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 277 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
278 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 278 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
279 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 279 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
280 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 280 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
281 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 281 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
282 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 282 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
283 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 283 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
284 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 284 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
285 | if ( !mData->birthday.isValid() ) | 285 | if ( !mData->birthday.isValid() ) |
286 | if ( ad.mData->birthday.isValid()) | 286 | if ( ad.mData->birthday.isValid()) |
287 | mData->birthday = ad.mData->birthday; | 287 | mData->birthday = ad.mData->birthday; |
288 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 288 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
289 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 289 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
290 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 290 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
291 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 291 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
292 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 292 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
293 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 293 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
294 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 294 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
295 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 295 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
296 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 296 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
297 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 297 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
298 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 298 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
299 | QStringList t; | 299 | QStringList t; |
300 | QStringList tAD; | 300 | QStringList tAD; |
301 | uint iii; | 301 | uint iii; |
302 | 302 | ||
303 | // ********** phone numbers | 303 | // ********** phone numbers |
304 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 304 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
305 | PhoneNumber::List::Iterator phoneItAD; | 305 | PhoneNumber::List::Iterator phoneItAD; |
306 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 306 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
307 | bool found = false; | 307 | bool found = false; |
308 | PhoneNumber::List::Iterator it; | 308 | PhoneNumber::List::Iterator it; |
309 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 309 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
310 | if ( ( *phoneItAD ).contains( (*it) ) ) { | 310 | if ( ( *phoneItAD ).contains( (*it) ) ) { |
311 | found = true; | 311 | found = true; |
312 | (*it).setType( ( *phoneItAD ).type() ); | 312 | (*it).setType( ( *phoneItAD ).type() ); |
313 | (*it).setNumber( ( *phoneItAD ).number() ); | 313 | (*it).setNumber( ( *phoneItAD ).number() ); |
314 | break; | 314 | break; |
315 | } | 315 | } |
316 | } | 316 | } |
317 | if ( isSubSet && ! found ) | 317 | if ( isSubSet && ! found ) |
318 | mData->phoneNumbers.append( *phoneItAD ); | 318 | mData->phoneNumbers.append( *phoneItAD ); |
319 | } | 319 | } |
320 | if ( isSubSet ) { | 320 | if ( isSubSet ) { |
321 | // ************* emails; | 321 | // ************* emails; |
322 | t = mData->emails; | 322 | t = mData->emails; |
323 | tAD = ad.mData->emails; | 323 | tAD = ad.mData->emails; |
324 | for ( iii = 0; iii < tAD.count(); ++iii) | 324 | for ( iii = 0; iii < tAD.count(); ++iii) |
325 | if ( !t.contains(tAD[iii] ) ) | 325 | if ( !t.contains(tAD[iii] ) ) |
326 | mData->emails.append( tAD[iii] ); | 326 | mData->emails.append( tAD[iii] ); |
327 | } | 327 | } |
328 | 328 | ||
329 | // ************* categories; | 329 | // ************* categories; |
330 | t = mData->categories; | 330 | t = mData->categories; |
331 | tAD = ad.mData->categories; | 331 | tAD = ad.mData->categories; |
332 | for ( iii = 0; iii < tAD.count(); ++iii) | 332 | for ( iii = 0; iii < tAD.count(); ++iii) |
333 | if ( !t.contains(tAD[iii] ) ) | 333 | if ( !t.contains(tAD[iii] ) ) |
334 | mData->categories.append( tAD[iii] ); | 334 | mData->categories.append( tAD[iii] ); |
335 | QStringList::ConstIterator it; | 335 | QStringList::ConstIterator it; |
336 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { | 336 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { |
337 | QString qualifiedName = (*it).left( (*it).find( ":" )); | 337 | QString qualifiedName = (*it).left( (*it).find( ":" )); |
338 | bool found = false; | 338 | bool found = false; |
339 | QStringList::ConstIterator itL; | 339 | QStringList::ConstIterator itL; |
340 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { | 340 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { |
341 | if ( (*itL).startsWith( qualifiedName ) ) { | 341 | if ( (*itL).startsWith( qualifiedName ) ) { |
342 | found = true; | 342 | found = true; |
343 | break; | 343 | break; |
344 | } | 344 | } |
345 | } | 345 | } |
346 | if ( ! found ) { | 346 | if ( ! found ) { |
347 | mData->custom.append( *it ); | 347 | mData->custom.append( *it ); |
348 | } | 348 | } |
349 | } | 349 | } |
350 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; | 350 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; |
351 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; | 351 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; |
352 | if ( !mData->sound.isIntern() ) { | 352 | if ( !mData->sound.isIntern() ) { |
353 | if ( mData->sound.url().isEmpty() ) { | 353 | if ( mData->sound.url().isEmpty() ) { |
354 | mData->sound = ad.mData->sound; | 354 | mData->sound = ad.mData->sound; |
355 | } | 355 | } |
356 | } | 356 | } |
357 | if ( !mData->agent.isIntern() ) { | 357 | if ( !mData->agent.isIntern() ) { |
358 | if ( mData->agent.url().isEmpty() ) { | 358 | if ( mData->agent.url().isEmpty() ) { |
359 | mData->agent = ad.mData->agent; | 359 | mData->agent = ad.mData->agent; |
360 | } | 360 | } |
361 | } | 361 | } |
362 | { | 362 | { |
363 | Key::List::Iterator itA; | 363 | Key::List::Iterator itA; |
364 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { | 364 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { |
365 | bool found = false; | 365 | bool found = false; |
366 | Key::List::Iterator it; | 366 | Key::List::Iterator it; |
367 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 367 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
368 | if ( (*it) == (*itA)) { | 368 | if ( (*it) == (*itA)) { |
369 | found = true; | 369 | found = true; |
370 | break; | 370 | break; |
371 | 371 | ||
372 | } | 372 | } |
373 | } | 373 | } |
374 | if ( ! found ) { | 374 | if ( ! found ) { |
375 | mData->keys.append( *itA ); | 375 | mData->keys.append( *itA ); |
376 | } | 376 | } |
377 | } | 377 | } |
378 | } | 378 | } |
379 | KABC::Address::List::Iterator addressIterA; | 379 | KABC::Address::List::Iterator addressIterA; |
380 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { | 380 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { |
381 | bool found = false; | 381 | bool found = false; |
382 | KABC::Address::List::Iterator addressIter; | 382 | KABC::Address::List::Iterator addressIter; |
383 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 383 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
384 | ++addressIter ) { | 384 | ++addressIter ) { |
385 | if ( (*addressIter) == (*addressIterA)) { | 385 | if ( (*addressIter) == (*addressIterA)) { |
386 | found = true; | 386 | found = true; |
387 | (*addressIter).setType( (*addressIterA).type() ); | 387 | (*addressIter).setType( (*addressIterA).type() ); |
388 | break; | 388 | break; |
389 | } | 389 | } |
390 | 390 | ||
391 | } | 391 | } |
392 | if ( isSubSet && ! found ) { | 392 | if ( isSubSet && ! found ) { |
393 | mData->addresses.append( *addressIterA ); | 393 | mData->addresses.append( *addressIterA ); |
394 | } | 394 | } |
395 | } | 395 | } |
396 | //qDebug("merge contact %s ", ad.uid().latin1()); | 396 | //qDebug("merge contact %s ", ad.uid().latin1()); |
397 | setUid( ad.uid() ); | 397 | setUid( ad.uid() ); |
398 | setRevision( ad.revision() ); | 398 | setRevision( ad.revision() ); |
399 | } | 399 | } |
400 | 400 | ||
401 | bool Addressee::removeVoice() | 401 | bool Addressee::removeVoice() |
402 | { | 402 | { |
403 | PhoneNumber::List phoneN = phoneNumbers(); | 403 | PhoneNumber::List phoneN = phoneNumbers(); |
404 | PhoneNumber::List::Iterator phoneIt; | 404 | PhoneNumber::List::Iterator phoneIt; |
405 | bool found = false; | 405 | bool found = false; |
406 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 406 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
407 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 407 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
408 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 408 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
409 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 409 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
410 | insertPhoneNumber( (*phoneIt) ); | 410 | insertPhoneNumber( (*phoneIt) ); |
411 | found = true; | 411 | found = true; |
412 | } | 412 | } |
413 | } | 413 | } |
414 | 414 | ||
415 | } | 415 | } |
416 | return found; | 416 | return found; |
417 | } | 417 | } |
418 | 418 | ||
419 | bool Addressee::containsAdr(const Addressee& ad ) | 419 | bool Addressee::containsAdr(const Addressee& ad ) |
420 | { | 420 | { |
421 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; | 421 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; |
422 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; | 422 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; |
423 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; | 423 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; |
424 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; | 424 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; |
425 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; | 425 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; |
426 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; | 426 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; |
427 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; | 427 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; |
428 | 428 | ||
429 | // compare phone numbers | 429 | // compare phone numbers |
430 | PhoneNumber::List phoneN = ad.phoneNumbers(); | 430 | PhoneNumber::List phoneN = ad.phoneNumbers(); |
431 | PhoneNumber::List::Iterator phoneIt; | 431 | PhoneNumber::List::Iterator phoneIt; |
432 | bool found = false; | 432 | bool found = false; |
433 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 433 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
434 | bool found = false; | 434 | bool found = false; |
435 | PhoneNumber::List phoneL = ad.phoneNumbers(); | 435 | PhoneNumber::List phoneL = ad.phoneNumbers(); |
436 | PhoneNumber::List::Iterator phoneItL; | 436 | PhoneNumber::List::Iterator phoneItL; |
437 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { | 437 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { |
438 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { | 438 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { |
439 | found = true; | 439 | found = true; |
440 | break; | 440 | break; |
441 | } | 441 | } |
442 | } | 442 | } |
443 | if ( ! found ) | 443 | if ( ! found ) |
444 | return false; | 444 | return false; |
445 | } | 445 | } |
446 | return true; | 446 | return true; |
447 | 447 | ||
448 | } | 448 | } |
449 | void Addressee::simplifyAddresses() | 449 | void Addressee::simplifyAddresses() |
450 | { | 450 | { |
451 | 451 | ||
452 | 452 | ||
453 | Address::List list; | 453 | Address::List list; |
454 | Address::List::Iterator it; | 454 | Address::List::Iterator it; |
455 | Address::List::Iterator it2; | 455 | Address::List::Iterator it2; |
456 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 456 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
457 | it2 = it; | 457 | it2 = it; |
458 | ++it2; | 458 | ++it2; |
459 | for( ; it2 != mData->addresses.end(); ++it2 ) { | 459 | for( ; it2 != mData->addresses.end(); ++it2 ) { |
460 | if ( (*it) == (*it2) ) { | 460 | if ( (*it) == (*it2) ) { |
461 | list.append( *it ); | 461 | list.append( *it ); |
462 | break; | 462 | break; |
463 | } | 463 | } |
464 | } | 464 | } |
465 | } | 465 | } |
466 | for( it = list.begin(); it != list.end(); ++it ) { | 466 | for( it = list.begin(); it != list.end(); ++it ) { |
467 | removeAddress( (*it) ); | 467 | removeAddress( (*it) ); |
468 | } | 468 | } |
469 | 469 | ||
470 | list.clear(); | 470 | list.clear(); |
471 | int max = 2; | 471 | int max = 2; |
472 | if ( mData->url.isValid() ) | 472 | if ( mData->url.isValid() ) |
473 | max = 1; | 473 | max = 1; |
474 | if ( mData->addresses.count() <= max ) return ; | 474 | if ( mData->addresses.count() <= max ) return ; |
475 | int count = 0; | 475 | int count = 0; |
476 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 476 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
477 | if ( count >= max ) | 477 | if ( count >= max ) |
478 | list.append( *it ); | 478 | list.append( *it ); |
479 | ++count; | 479 | ++count; |
480 | } | 480 | } |
481 | for( it = list.begin(); it != list.end(); ++it ) { | 481 | for( it = list.begin(); it != list.end(); ++it ) { |
482 | removeAddress( (*it) ); | 482 | removeAddress( (*it) ); |
483 | } | 483 | } |
484 | } | 484 | } |
485 | 485 | ||
486 | // removes all emails but the first | 486 | // removes all emails but the first |
487 | // needed by phone sync | 487 | // needed by phone sync |
488 | void Addressee::simplifyEmails() | 488 | void Addressee::simplifyEmails() |
489 | { | 489 | { |
490 | if ( mData->emails.count() == 0 ) return ; | 490 | if ( mData->emails.count() == 0 ) return ; |
491 | QString email = mData->emails.first(); | 491 | QString email = mData->emails.first(); |
492 | detach(); | 492 | detach(); |
493 | mData->emails.clear(); | 493 | mData->emails.clear(); |
494 | mData->emails.append( email ); | 494 | mData->emails.append( email ); |
495 | } | 495 | } |
496 | 496 | ||
497 | void Addressee::simplifyPhoneNumbers() | 497 | void Addressee::simplifyPhoneNumbers() |
498 | { | 498 | { |
499 | int max = 4; | 499 | int max = 4; |
500 | int inList = mData->phoneNumbers.count(); | 500 | int inList = mData->phoneNumbers.count(); |
501 | KABC::PhoneNumber::List removeNumbers; | 501 | KABC::PhoneNumber::List removeNumbers; |
502 | KABC::PhoneNumber::List::Iterator phoneIter; | 502 | KABC::PhoneNumber::List::Iterator phoneIter; |
503 | if ( inList > max ) { | 503 | if ( inList > max ) { |
504 | // delete non-preferred numbers | 504 | // delete non-preferred numbers |
505 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 505 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
506 | ++phoneIter ) { | 506 | ++phoneIter ) { |
507 | if ( inList > max ) { | 507 | if ( inList > max ) { |
508 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { | 508 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { |
509 | removeNumbers.append( ( *phoneIter ) ); | 509 | removeNumbers.append( ( *phoneIter ) ); |
510 | --inList; | 510 | --inList; |
511 | } | 511 | } |
512 | } else | 512 | } else |
513 | break; | 513 | break; |
514 | } | 514 | } |
515 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 515 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
516 | ++phoneIter ) { | 516 | ++phoneIter ) { |
517 | removePhoneNumber(( *phoneIter )); | 517 | removePhoneNumber(( *phoneIter )); |
518 | } | 518 | } |
519 | // delete preferred numbers | 519 | // delete preferred numbers |
520 | if ( inList > max ) { | 520 | if ( inList > max ) { |
521 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 521 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
522 | ++phoneIter ) { | 522 | ++phoneIter ) { |
523 | if ( inList > max ) { | 523 | if ( inList > max ) { |
524 | removeNumbers.append( ( *phoneIter ) ); | 524 | removeNumbers.append( ( *phoneIter ) ); |
525 | --inList; | 525 | --inList; |
526 | } else | 526 | } else |
527 | break; | 527 | break; |
528 | } | 528 | } |
529 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 529 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
530 | ++phoneIter ) { | 530 | ++phoneIter ) { |
531 | removePhoneNumber(( *phoneIter )); | 531 | removePhoneNumber(( *phoneIter )); |
532 | } | 532 | } |
533 | } | 533 | } |
534 | } | 534 | } |
535 | // remove non-numeric characters | 535 | // remove non-numeric characters |
536 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 536 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
537 | ++phoneIter ) { | 537 | ++phoneIter ) { |
538 | if ( ! ( *phoneIter ).simplifyNumber() ) | 538 | if ( ! ( *phoneIter ).simplifyNumber() ) |
539 | removeNumbers.append( ( *phoneIter ) ); | 539 | removeNumbers.append( ( *phoneIter ) ); |
540 | } | 540 | } |
541 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 541 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
542 | ++phoneIter ) { | 542 | ++phoneIter ) { |
543 | removePhoneNumber(( *phoneIter )); | 543 | removePhoneNumber(( *phoneIter )); |
544 | } | 544 | } |
545 | } | 545 | } |
546 | void Addressee::simplifyPhoneNumberTypes() | 546 | void Addressee::simplifyPhoneNumberTypes() |
547 | { | 547 | { |
548 | KABC::PhoneNumber::List::Iterator phoneIter; | 548 | KABC::PhoneNumber::List::Iterator phoneIter; |
549 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 549 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
550 | ++phoneIter ) | 550 | ++phoneIter ) |
551 | ( *phoneIter ).simplifyType(); | 551 | ( *phoneIter ).simplifyType(); |
552 | } | 552 | } |
553 | void Addressee::removeID(const QString &prof) | 553 | void Addressee::removeID(const QString &prof) |
554 | { | 554 | { |
555 | detach(); | 555 | detach(); |
556 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 556 | if ( prof.isEmpty() ) |
557 | mData->mExternalId = ":"; | ||
558 | else | ||
559 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | ||
557 | 560 | ||
558 | } | 561 | } |
559 | void Addressee::setID( const QString & prof , const QString & id ) | 562 | void Addressee::setID( const QString & prof , const QString & id ) |
560 | { | 563 | { |
561 | detach(); | 564 | detach(); |
562 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 565 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
563 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 566 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
564 | } | 567 | } |
565 | void Addressee::setTempSyncStat( int id ) | 568 | void Addressee::setTempSyncStat( int id ) |
566 | { | 569 | { |
567 | if ( mData->mTempSyncStat == id ) return; | 570 | if ( mData->mTempSyncStat == id ) return; |
568 | detach(); | 571 | detach(); |
569 | mData->mTempSyncStat = id; | 572 | mData->mTempSyncStat = id; |
570 | } | 573 | } |
571 | int Addressee::tempSyncStat() const | 574 | int Addressee::tempSyncStat() const |
572 | { | 575 | { |
573 | return mData->mTempSyncStat; | 576 | return mData->mTempSyncStat; |
574 | } | 577 | } |
575 | 578 | ||
576 | QString Addressee::getID( const QString & prof) | 579 | QString Addressee::getID( const QString & prof) |
577 | { | 580 | { |
578 | return KIdManager::getId ( mData->mExternalId, prof ); | 581 | return KIdManager::getId ( mData->mExternalId, prof ); |
579 | } | 582 | } |
580 | 583 | ||
581 | void Addressee::setCsum( const QString & prof , const QString & id ) | 584 | void Addressee::setCsum( const QString & prof , const QString & id ) |
582 | { | 585 | { |
583 | detach(); | 586 | detach(); |
584 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 587 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
585 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 588 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
586 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 589 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
587 | } | 590 | } |
588 | 591 | ||
589 | QString Addressee::getCsum( const QString & prof) | 592 | QString Addressee::getCsum( const QString & prof) |
590 | { | 593 | { |
591 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 594 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
592 | } | 595 | } |
593 | 596 | ||
594 | void Addressee::setIDStr( const QString & s ) | 597 | void Addressee::setIDStr( const QString & s ) |
595 | { | 598 | { |
596 | detach(); | 599 | detach(); |
597 | mData->mExternalId = s; | 600 | mData->mExternalId = s; |
598 | } | 601 | } |
599 | 602 | ||
600 | QString Addressee::IDStr() const | 603 | QString Addressee::IDStr() const |
601 | { | 604 | { |
602 | return mData->mExternalId; | 605 | return mData->mExternalId; |
603 | } | 606 | } |
604 | 607 | ||
605 | void Addressee::setExternalUID( const QString &id ) | 608 | void Addressee::setExternalUID( const QString &id ) |
606 | { | 609 | { |
607 | if ( id == mData->externalUID ) return; | 610 | if ( id == mData->externalUID ) return; |
608 | detach(); | 611 | detach(); |
609 | mData->empty = false; | 612 | mData->empty = false; |
610 | mData->externalUID = id; | 613 | mData->externalUID = id; |
611 | } | 614 | } |
612 | 615 | ||
613 | QString Addressee::externalUID() const | 616 | QString Addressee::externalUID() const |
614 | { | 617 | { |
615 | return mData->externalUID; | 618 | return mData->externalUID; |
616 | } | 619 | } |
617 | void Addressee::setOriginalExternalUID( const QString &id ) | 620 | void Addressee::setOriginalExternalUID( const QString &id ) |
618 | { | 621 | { |
619 | if ( id == mData->originalExternalUID ) return; | 622 | if ( id == mData->originalExternalUID ) return; |
620 | detach(); | 623 | detach(); |
621 | mData->empty = false; | 624 | mData->empty = false; |
622 | //qDebug("*******Set orig uid %s ", id.latin1()); | 625 | //qDebug("*******Set orig uid %s ", id.latin1()); |
623 | mData->originalExternalUID = id; | 626 | mData->originalExternalUID = id; |
624 | } | 627 | } |
625 | 628 | ||
626 | QString Addressee::originalExternalUID() const | 629 | QString Addressee::originalExternalUID() const |
627 | { | 630 | { |
628 | return mData->originalExternalUID; | 631 | return mData->originalExternalUID; |
629 | } | 632 | } |
630 | 633 | ||
631 | void Addressee::setUid( const QString &id ) | 634 | void Addressee::setUid( const QString &id ) |
632 | { | 635 | { |
633 | if ( id == mData->uid ) return; | 636 | if ( id == mData->uid ) return; |
634 | detach(); | 637 | detach(); |
635 | //qDebug("****setuid %s ", id.latin1()); | 638 | //qDebug("****setuid %s ", id.latin1()); |
636 | mData->empty = false; | 639 | mData->empty = false; |
637 | mData->uid = id; | 640 | mData->uid = id; |
638 | } | 641 | } |
639 | 642 | ||
640 | QString Addressee::uid() const | 643 | QString Addressee::uid() const |
641 | { | 644 | { |
642 | if ( mData->uid.isEmpty() ) | 645 | if ( mData->uid.isEmpty() ) |
643 | mData->uid = KApplication::randomString( 10 ); | 646 | mData->uid = KApplication::randomString( 10 ); |
644 | 647 | ||
645 | return mData->uid; | 648 | return mData->uid; |
646 | } | 649 | } |
647 | 650 | ||
648 | QString Addressee::uidLabel() | 651 | QString Addressee::uidLabel() |
649 | { | 652 | { |
650 | return i18n("Unique Identifier"); | 653 | return i18n("Unique Identifier"); |
651 | } | 654 | } |
652 | 655 | ||
653 | void Addressee::setName( const QString &name ) | 656 | void Addressee::setName( const QString &name ) |
654 | { | 657 | { |
655 | if ( name == mData->name ) return; | 658 | if ( name == mData->name ) return; |
656 | detach(); | 659 | detach(); |
657 | mData->empty = false; | 660 | mData->empty = false; |
658 | mData->name = name; | 661 | mData->name = name; |
659 | } | 662 | } |
660 | 663 | ||
661 | QString Addressee::name() const | 664 | QString Addressee::name() const |
662 | { | 665 | { |
663 | return mData->name; | 666 | return mData->name; |
664 | } | 667 | } |
665 | 668 | ||
666 | QString Addressee::nameLabel() | 669 | QString Addressee::nameLabel() |
667 | { | 670 | { |
668 | return i18n("Name"); | 671 | return i18n("Name"); |
669 | } | 672 | } |
670 | 673 | ||
671 | 674 | ||
672 | void Addressee::setFormattedName( const QString &formattedName ) | 675 | void Addressee::setFormattedName( const QString &formattedName ) |
673 | { | 676 | { |
674 | if ( formattedName == mData->formattedName ) return; | 677 | if ( formattedName == mData->formattedName ) return; |
675 | detach(); | 678 | detach(); |
676 | mData->empty = false; | 679 | mData->empty = false; |
677 | mData->formattedName = formattedName; | 680 | mData->formattedName = formattedName; |
678 | } | 681 | } |
679 | 682 | ||
680 | QString Addressee::formattedName() const | 683 | QString Addressee::formattedName() const |
681 | { | 684 | { |
682 | return mData->formattedName; | 685 | return mData->formattedName; |
683 | } | 686 | } |
684 | 687 | ||
685 | QString Addressee::formattedNameLabel() | 688 | QString Addressee::formattedNameLabel() |
686 | { | 689 | { |
687 | return i18n("Formatted Name"); | 690 | return i18n("Formatted Name"); |
688 | } | 691 | } |
689 | 692 | ||
690 | 693 | ||
691 | void Addressee::setFamilyName( const QString &familyName ) | 694 | void Addressee::setFamilyName( const QString &familyName ) |
692 | { | 695 | { |
693 | if ( familyName == mData->familyName ) return; | 696 | if ( familyName == mData->familyName ) return; |
694 | detach(); | 697 | detach(); |
695 | mData->empty = false; | 698 | mData->empty = false; |
696 | mData->familyName = familyName; | 699 | mData->familyName = familyName; |
697 | } | 700 | } |
698 | 701 | ||
699 | QString Addressee::familyName() const | 702 | QString Addressee::familyName() const |
700 | { | 703 | { |
701 | return mData->familyName; | 704 | return mData->familyName; |
702 | } | 705 | } |
703 | 706 | ||
704 | QString Addressee::familyNameLabel() | 707 | QString Addressee::familyNameLabel() |
705 | { | 708 | { |
706 | return i18n("Family Name"); | 709 | return i18n("Family Name"); |
707 | } | 710 | } |
708 | 711 | ||
709 | 712 | ||
710 | void Addressee::setGivenName( const QString &givenName ) | 713 | void Addressee::setGivenName( const QString &givenName ) |
711 | { | 714 | { |
712 | if ( givenName == mData->givenName ) return; | 715 | if ( givenName == mData->givenName ) return; |
713 | detach(); | 716 | detach(); |
714 | mData->empty = false; | 717 | mData->empty = false; |
715 | mData->givenName = givenName; | 718 | mData->givenName = givenName; |
716 | } | 719 | } |
717 | 720 | ||
718 | QString Addressee::givenName() const | 721 | QString Addressee::givenName() const |
719 | { | 722 | { |
720 | return mData->givenName; | 723 | return mData->givenName; |
721 | } | 724 | } |
722 | 725 | ||
723 | QString Addressee::givenNameLabel() | 726 | QString Addressee::givenNameLabel() |
724 | { | 727 | { |
725 | return i18n("Given Name"); | 728 | return i18n("Given Name"); |
726 | } | 729 | } |
727 | 730 | ||
728 | 731 | ||
729 | void Addressee::setAdditionalName( const QString &additionalName ) | 732 | void Addressee::setAdditionalName( const QString &additionalName ) |
730 | { | 733 | { |
731 | if ( additionalName == mData->additionalName ) return; | 734 | if ( additionalName == mData->additionalName ) return; |
732 | detach(); | 735 | detach(); |
733 | mData->empty = false; | 736 | mData->empty = false; |
734 | mData->additionalName = additionalName; | 737 | mData->additionalName = additionalName; |
735 | } | 738 | } |
736 | 739 | ||
737 | QString Addressee::additionalName() const | 740 | QString Addressee::additionalName() const |
738 | { | 741 | { |
739 | return mData->additionalName; | 742 | return mData->additionalName; |
740 | } | 743 | } |
741 | 744 | ||
742 | QString Addressee::additionalNameLabel() | 745 | QString Addressee::additionalNameLabel() |
743 | { | 746 | { |
744 | return i18n("Additional Names"); | 747 | return i18n("Additional Names"); |
745 | } | 748 | } |
746 | 749 | ||
747 | 750 | ||
748 | void Addressee::setPrefix( const QString &prefix ) | 751 | void Addressee::setPrefix( const QString &prefix ) |
749 | { | 752 | { |
750 | if ( prefix == mData->prefix ) return; | 753 | if ( prefix == mData->prefix ) return; |
751 | detach(); | 754 | detach(); |
752 | mData->empty = false; | 755 | mData->empty = false; |
753 | mData->prefix = prefix; | 756 | mData->prefix = prefix; |
754 | } | 757 | } |
755 | 758 | ||
756 | QString Addressee::prefix() const | 759 | QString Addressee::prefix() const |
757 | { | 760 | { |
758 | return mData->prefix; | 761 | return mData->prefix; |
759 | } | 762 | } |
760 | 763 | ||
761 | QString Addressee::prefixLabel() | 764 | QString Addressee::prefixLabel() |
762 | { | 765 | { |
763 | return i18n("Honorific Prefixes"); | 766 | return i18n("Honorific Prefixes"); |
764 | } | 767 | } |
765 | 768 | ||
766 | 769 | ||
767 | void Addressee::setSuffix( const QString &suffix ) | 770 | void Addressee::setSuffix( const QString &suffix ) |
768 | { | 771 | { |
769 | if ( suffix == mData->suffix ) return; | 772 | if ( suffix == mData->suffix ) return; |
770 | detach(); | 773 | detach(); |
771 | mData->empty = false; | 774 | mData->empty = false; |
772 | mData->suffix = suffix; | 775 | mData->suffix = suffix; |
773 | } | 776 | } |
774 | 777 | ||
775 | QString Addressee::suffix() const | 778 | QString Addressee::suffix() const |
776 | { | 779 | { |
777 | return mData->suffix; | 780 | return mData->suffix; |
778 | } | 781 | } |
779 | 782 | ||
780 | QString Addressee::suffixLabel() | 783 | QString Addressee::suffixLabel() |
781 | { | 784 | { |
782 | return i18n("Honorific Suffixes"); | 785 | return i18n("Honorific Suffixes"); |
783 | } | 786 | } |
784 | 787 | ||
785 | 788 | ||
786 | void Addressee::setNickName( const QString &nickName ) | 789 | void Addressee::setNickName( const QString &nickName ) |
787 | { | 790 | { |
788 | if ( nickName == mData->nickName ) return; | 791 | if ( nickName == mData->nickName ) return; |
789 | detach(); | 792 | detach(); |
790 | mData->empty = false; | 793 | mData->empty = false; |
791 | mData->nickName = nickName; | 794 | mData->nickName = nickName; |
792 | } | 795 | } |
793 | 796 | ||
794 | QString Addressee::nickName() const | 797 | QString Addressee::nickName() const |
795 | { | 798 | { |
796 | return mData->nickName; | 799 | return mData->nickName; |
797 | } | 800 | } |
798 | 801 | ||
799 | QString Addressee::nickNameLabel() | 802 | QString Addressee::nickNameLabel() |
800 | { | 803 | { |
801 | return i18n("Nick Name"); | 804 | return i18n("Nick Name"); |
802 | } | 805 | } |
803 | 806 | ||
804 | 807 | ||
805 | void Addressee::setBirthday( const QDateTime &birthday ) | 808 | void Addressee::setBirthday( const QDateTime &birthday ) |
806 | { | 809 | { |
807 | if ( birthday == mData->birthday ) return; | 810 | if ( birthday == mData->birthday ) return; |
808 | detach(); | 811 | detach(); |
809 | mData->empty = false; | 812 | mData->empty = false; |
810 | mData->birthday = birthday; | 813 | mData->birthday = birthday; |
811 | } | 814 | } |
812 | 815 | ||
813 | QDateTime Addressee::birthday() const | 816 | QDateTime Addressee::birthday() const |
814 | { | 817 | { |
815 | return mData->birthday; | 818 | return mData->birthday; |
816 | } | 819 | } |
817 | 820 | ||
818 | QString Addressee::birthdayLabel() | 821 | QString Addressee::birthdayLabel() |
819 | { | 822 | { |
820 | return i18n("Birthday"); | 823 | return i18n("Birthday"); |
821 | } | 824 | } |
822 | 825 | ||
823 | 826 | ||
824 | QString Addressee::homeAddressStreetLabel() | 827 | QString Addressee::homeAddressStreetLabel() |
825 | { | 828 | { |
826 | return i18n("Home Address Street"); | 829 | return i18n("Home Address Street"); |
827 | } | 830 | } |
828 | 831 | ||
829 | 832 | ||
830 | QString Addressee::homeAddressLocalityLabel() | 833 | QString Addressee::homeAddressLocalityLabel() |
831 | { | 834 | { |
832 | return i18n("Home Address Locality"); | 835 | return i18n("Home Address Locality"); |
833 | } | 836 | } |
834 | 837 | ||
835 | 838 | ||
836 | QString Addressee::homeAddressRegionLabel() | 839 | QString Addressee::homeAddressRegionLabel() |
837 | { | 840 | { |
838 | return i18n("Home Address Region"); | 841 | return i18n("Home Address Region"); |
839 | } | 842 | } |
840 | 843 | ||
841 | 844 | ||
842 | QString Addressee::homeAddressPostalCodeLabel() | 845 | QString Addressee::homeAddressPostalCodeLabel() |
843 | { | 846 | { |
844 | return i18n("Home Address Postal Code"); | 847 | return i18n("Home Address Postal Code"); |
845 | } | 848 | } |
846 | 849 | ||
847 | 850 | ||
848 | QString Addressee::homeAddressCountryLabel() | 851 | QString Addressee::homeAddressCountryLabel() |
849 | { | 852 | { |
850 | return i18n("Home Address Country"); | 853 | return i18n("Home Address Country"); |
851 | } | 854 | } |
852 | 855 | ||
853 | 856 | ||
854 | QString Addressee::homeAddressLabelLabel() | 857 | QString Addressee::homeAddressLabelLabel() |
855 | { | 858 | { |
856 | return i18n("Home Address Label"); | 859 | return i18n("Home Address Label"); |
857 | } | 860 | } |
858 | 861 | ||
859 | 862 | ||
860 | QString Addressee::businessAddressStreetLabel() | 863 | QString Addressee::businessAddressStreetLabel() |
861 | { | 864 | { |
862 | return i18n("Business Address Street"); | 865 | return i18n("Business Address Street"); |
863 | } | 866 | } |
864 | 867 | ||
865 | 868 | ||
866 | QString Addressee::businessAddressLocalityLabel() | 869 | QString Addressee::businessAddressLocalityLabel() |
867 | { | 870 | { |
868 | return i18n("Business Address Locality"); | 871 | return i18n("Business Address Locality"); |
869 | } | 872 | } |
870 | 873 | ||
871 | 874 | ||
872 | QString Addressee::businessAddressRegionLabel() | 875 | QString Addressee::businessAddressRegionLabel() |
873 | { | 876 | { |
874 | return i18n("Business Address Region"); | 877 | return i18n("Business Address Region"); |
875 | } | 878 | } |
876 | 879 | ||
877 | 880 | ||
878 | QString Addressee::businessAddressPostalCodeLabel() | 881 | QString Addressee::businessAddressPostalCodeLabel() |
879 | { | 882 | { |
880 | return i18n("Business Address Postal Code"); | 883 | return i18n("Business Address Postal Code"); |
881 | } | 884 | } |
882 | 885 | ||
883 | 886 | ||
884 | QString Addressee::businessAddressCountryLabel() | 887 | QString Addressee::businessAddressCountryLabel() |
885 | { | 888 | { |
886 | return i18n("Business Address Country"); | 889 | return i18n("Business Address Country"); |
887 | } | 890 | } |
888 | 891 | ||
889 | 892 | ||
890 | QString Addressee::businessAddressLabelLabel() | 893 | QString Addressee::businessAddressLabelLabel() |
891 | { | 894 | { |
892 | return i18n("Business Address Label"); | 895 | return i18n("Business Address Label"); |
893 | } | 896 | } |
894 | 897 | ||
895 | 898 | ||
896 | QString Addressee::homePhoneLabel() | 899 | QString Addressee::homePhoneLabel() |
897 | { | 900 | { |
898 | return i18n("Home Phone"); | 901 | return i18n("Home Phone"); |
899 | } | 902 | } |
900 | 903 | ||
901 | 904 | ||
902 | QString Addressee::businessPhoneLabel() | 905 | QString Addressee::businessPhoneLabel() |
903 | { | 906 | { |
904 | return i18n("Business Phone"); | 907 | return i18n("Business Phone"); |
905 | } | 908 | } |
906 | 909 | ||
907 | 910 | ||
908 | QString Addressee::mobilePhoneLabel() | 911 | QString Addressee::mobilePhoneLabel() |
909 | { | 912 | { |
910 | return i18n("Mobile Phone"); | 913 | return i18n("Mobile Phone"); |
911 | } | 914 | } |
912 | 915 | ||
913 | 916 | ||
914 | QString Addressee::homeFaxLabel() | 917 | QString Addressee::homeFaxLabel() |
915 | { | 918 | { |
916 | return i18n("Home Fax"); | 919 | return i18n("Home Fax"); |
917 | } | 920 | } |
918 | 921 | ||
919 | 922 | ||
920 | QString Addressee::businessFaxLabel() | 923 | QString Addressee::businessFaxLabel() |
921 | { | 924 | { |
922 | return i18n("Business Fax"); | 925 | return i18n("Business Fax"); |
923 | } | 926 | } |
924 | 927 | ||
925 | 928 | ||
926 | QString Addressee::carPhoneLabel() | 929 | QString Addressee::carPhoneLabel() |
927 | { | 930 | { |
928 | return i18n("Car Phone"); | 931 | return i18n("Car Phone"); |
929 | } | 932 | } |
930 | 933 | ||
931 | 934 | ||
932 | QString Addressee::isdnLabel() | 935 | QString Addressee::isdnLabel() |
933 | { | 936 | { |
934 | return i18n("ISDN"); | 937 | return i18n("ISDN"); |
935 | } | 938 | } |
936 | 939 | ||
937 | 940 | ||
938 | QString Addressee::pagerLabel() | 941 | QString Addressee::pagerLabel() |
939 | { | 942 | { |
940 | return i18n("Pager"); | 943 | return i18n("Pager"); |
941 | } | 944 | } |
942 | 945 | ||
943 | QString Addressee::sipLabel() | 946 | QString Addressee::sipLabel() |
944 | { | 947 | { |
945 | return i18n("SIP"); | 948 | return i18n("SIP"); |
946 | } | 949 | } |
947 | 950 | ||
948 | QString Addressee::emailLabel() | 951 | QString Addressee::emailLabel() |
949 | { | 952 | { |
950 | return i18n("Email Address"); | 953 | return i18n("Email Address"); |
951 | } | 954 | } |
952 | 955 | ||
953 | 956 | ||
954 | void Addressee::setMailer( const QString &mailer ) | 957 | void Addressee::setMailer( const QString &mailer ) |
955 | { | 958 | { |
956 | if ( mailer == mData->mailer ) return; | 959 | if ( mailer == mData->mailer ) return; |
957 | detach(); | 960 | detach(); |
958 | mData->empty = false; | 961 | mData->empty = false; |
959 | mData->mailer = mailer; | 962 | mData->mailer = mailer; |
960 | } | 963 | } |
961 | 964 | ||
962 | QString Addressee::mailer() const | 965 | QString Addressee::mailer() const |
963 | { | 966 | { |
964 | return mData->mailer; | 967 | return mData->mailer; |
965 | } | 968 | } |
966 | 969 | ||
967 | QString Addressee::mailerLabel() | 970 | QString Addressee::mailerLabel() |
968 | { | 971 | { |
969 | return i18n("Mail Client"); | 972 | return i18n("Mail Client"); |
970 | } | 973 | } |
971 | 974 | ||
972 | 975 | ||
973 | void Addressee::setTimeZone( const TimeZone &timeZone ) | 976 | void Addressee::setTimeZone( const TimeZone &timeZone ) |
974 | { | 977 | { |
975 | if ( timeZone == mData->timeZone ) return; | 978 | if ( timeZone == mData->timeZone ) return; |
976 | detach(); | 979 | detach(); |
977 | mData->empty = false; | 980 | mData->empty = false; |
978 | mData->timeZone = timeZone; | 981 | mData->timeZone = timeZone; |
979 | } | 982 | } |
980 | 983 | ||
981 | TimeZone Addressee::timeZone() const | 984 | TimeZone Addressee::timeZone() const |
982 | { | 985 | { |
983 | return mData->timeZone; | 986 | return mData->timeZone; |
984 | } | 987 | } |
985 | 988 | ||
986 | QString Addressee::timeZoneLabel() | 989 | QString Addressee::timeZoneLabel() |
987 | { | 990 | { |
988 | return i18n("Time Zone"); | 991 | return i18n("Time Zone"); |
989 | } | 992 | } |
990 | 993 | ||
991 | 994 | ||
992 | void Addressee::setGeo( const Geo &geo ) | 995 | void Addressee::setGeo( const Geo &geo ) |
993 | { | 996 | { |
994 | if ( geo == mData->geo ) return; | 997 | if ( geo == mData->geo ) return; |
995 | detach(); | 998 | detach(); |
996 | mData->empty = false; | 999 | mData->empty = false; |
997 | mData->geo = geo; | 1000 | mData->geo = geo; |
998 | } | 1001 | } |
999 | 1002 | ||
1000 | Geo Addressee::geo() const | 1003 | Geo Addressee::geo() const |
1001 | { | 1004 | { |
1002 | return mData->geo; | 1005 | return mData->geo; |
1003 | } | 1006 | } |
1004 | 1007 | ||
1005 | QString Addressee::geoLabel() | 1008 | QString Addressee::geoLabel() |
1006 | { | 1009 | { |
1007 | return i18n("Geographic Position"); | 1010 | return i18n("Geographic Position"); |
1008 | } | 1011 | } |
1009 | 1012 | ||
1010 | 1013 | ||
1011 | void Addressee::setTitle( const QString &title ) | 1014 | void Addressee::setTitle( const QString &title ) |
1012 | { | 1015 | { |
1013 | if ( title == mData->title ) return; | 1016 | if ( title == mData->title ) return; |
1014 | detach(); | 1017 | detach(); |
1015 | mData->empty = false; | 1018 | mData->empty = false; |
1016 | mData->title = title; | 1019 | mData->title = title; |
1017 | } | 1020 | } |
1018 | 1021 | ||
1019 | QString Addressee::title() const | 1022 | QString Addressee::title() const |
1020 | { | 1023 | { |
1021 | return mData->title; | 1024 | return mData->title; |
1022 | } | 1025 | } |
1023 | 1026 | ||
1024 | QString Addressee::titleLabel() | 1027 | QString Addressee::titleLabel() |
1025 | { | 1028 | { |
1026 | return i18n("Title"); | 1029 | return i18n("Title"); |
1027 | } | 1030 | } |
1028 | 1031 | ||
1029 | 1032 | ||
1030 | void Addressee::setRole( const QString &role ) | 1033 | void Addressee::setRole( const QString &role ) |
1031 | { | 1034 | { |
1032 | if ( role == mData->role ) return; | 1035 | if ( role == mData->role ) return; |
1033 | detach(); | 1036 | detach(); |
1034 | mData->empty = false; | 1037 | mData->empty = false; |
1035 | mData->role = role; | 1038 | mData->role = role; |
1036 | } | 1039 | } |
1037 | 1040 | ||
1038 | QString Addressee::role() const | 1041 | QString Addressee::role() const |
1039 | { | 1042 | { |
1040 | return mData->role; | 1043 | return mData->role; |
1041 | } | 1044 | } |
1042 | 1045 | ||
1043 | QString Addressee::roleLabel() | 1046 | QString Addressee::roleLabel() |
1044 | { | 1047 | { |
1045 | return i18n("Role"); | 1048 | return i18n("Role"); |
1046 | } | 1049 | } |
1047 | 1050 | ||
1048 | 1051 | ||
1049 | void Addressee::setOrganization( const QString &organization ) | 1052 | void Addressee::setOrganization( const QString &organization ) |
1050 | { | 1053 | { |
1051 | if ( organization == mData->organization ) return; | 1054 | if ( organization == mData->organization ) return; |
1052 | detach(); | 1055 | detach(); |
1053 | mData->empty = false; | 1056 | mData->empty = false; |
1054 | mData->organization = organization; | 1057 | mData->organization = organization; |
1055 | } | 1058 | } |
1056 | 1059 | ||
1057 | QString Addressee::organization() const | 1060 | QString Addressee::organization() const |
1058 | { | 1061 | { |
1059 | return mData->organization; | 1062 | return mData->organization; |
1060 | } | 1063 | } |
1061 | 1064 | ||
1062 | QString Addressee::organizationLabel() | 1065 | QString Addressee::organizationLabel() |
1063 | { | 1066 | { |
1064 | return i18n("Organization"); | 1067 | return i18n("Organization"); |
1065 | } | 1068 | } |
1066 | 1069 | ||
1067 | 1070 | ||
1068 | void Addressee::setNote( const QString ¬e ) | 1071 | void Addressee::setNote( const QString ¬e ) |
1069 | { | 1072 | { |
1070 | if ( note == mData->note ) return; | 1073 | if ( note == mData->note ) return; |
1071 | detach(); | 1074 | detach(); |
1072 | mData->empty = false; | 1075 | mData->empty = false; |
1073 | mData->note = note; | 1076 | mData->note = note; |
1074 | } | 1077 | } |
1075 | 1078 | ||
1076 | QString Addressee::note() const | 1079 | QString Addressee::note() const |
1077 | { | 1080 | { |
1078 | return mData->note; | 1081 | return mData->note; |
1079 | } | 1082 | } |
1080 | 1083 | ||
1081 | QString Addressee::noteLabel() | 1084 | QString Addressee::noteLabel() |
1082 | { | 1085 | { |
1083 | return i18n("Note"); | 1086 | return i18n("Note"); |
1084 | } | 1087 | } |
1085 | 1088 | ||
1086 | 1089 | ||
1087 | void Addressee::setProductId( const QString &productId ) | 1090 | void Addressee::setProductId( const QString &productId ) |
1088 | { | 1091 | { |
1089 | if ( productId == mData->productId ) return; | 1092 | if ( productId == mData->productId ) return; |
1090 | detach(); | 1093 | detach(); |
1091 | mData->empty = false; | 1094 | mData->empty = false; |
1092 | mData->productId = productId; | 1095 | mData->productId = productId; |
1093 | } | 1096 | } |
1094 | 1097 | ||
1095 | QString Addressee::productId() const | 1098 | QString Addressee::productId() const |
1096 | { | 1099 | { |
1097 | return mData->productId; | 1100 | return mData->productId; |
1098 | } | 1101 | } |
1099 | 1102 | ||
1100 | QString Addressee::productIdLabel() | 1103 | QString Addressee::productIdLabel() |
1101 | { | 1104 | { |
1102 | return i18n("Product Identifier"); | 1105 | return i18n("Product Identifier"); |
1103 | } | 1106 | } |
1104 | 1107 | ||
1105 | 1108 | ||
1106 | void Addressee::setRevision( const QDateTime &revision ) | 1109 | void Addressee::setRevision( const QDateTime &revision ) |
1107 | { | 1110 | { |
1108 | if ( revision == mData->revision ) return; | 1111 | if ( revision == mData->revision ) return; |
1109 | detach(); | 1112 | detach(); |
1110 | mData->empty = false; | 1113 | mData->empty = false; |
1111 | mData->revision = revision; | 1114 | mData->revision = revision; |
1112 | } | 1115 | } |
1113 | 1116 | ||
1114 | QDateTime Addressee::revision() const | 1117 | QDateTime Addressee::revision() const |
1115 | { | 1118 | { |
1116 | return mData->revision; | 1119 | return mData->revision; |
1117 | } | 1120 | } |
1118 | 1121 | ||
1119 | QString Addressee::revisionLabel() | 1122 | QString Addressee::revisionLabel() |
1120 | { | 1123 | { |
1121 | return i18n("Revision Date"); | 1124 | return i18n("Revision Date"); |
1122 | } | 1125 | } |
1123 | 1126 | ||
1124 | 1127 | ||
1125 | void Addressee::setSortString( const QString &sortString ) | 1128 | void Addressee::setSortString( const QString &sortString ) |
1126 | { | 1129 | { |
1127 | if ( sortString == mData->sortString ) return; | 1130 | if ( sortString == mData->sortString ) return; |
1128 | detach(); | 1131 | detach(); |
1129 | mData->empty = false; | 1132 | mData->empty = false; |
1130 | mData->sortString = sortString; | 1133 | mData->sortString = sortString; |
1131 | } | 1134 | } |
1132 | 1135 | ||
1133 | QString Addressee::sortString() const | 1136 | QString Addressee::sortString() const |
1134 | { | 1137 | { |
1135 | return mData->sortString; | 1138 | return mData->sortString; |
1136 | } | 1139 | } |
1137 | 1140 | ||
1138 | QString Addressee::sortStringLabel() | 1141 | QString Addressee::sortStringLabel() |
1139 | { | 1142 | { |
1140 | return i18n("Sort String"); | 1143 | return i18n("Sort String"); |
1141 | } | 1144 | } |
1142 | 1145 | ||
1143 | 1146 | ||
1144 | void Addressee::setUrl( const KURL &url ) | 1147 | void Addressee::setUrl( const KURL &url ) |
1145 | { | 1148 | { |
1146 | if ( url == mData->url ) return; | 1149 | if ( url == mData->url ) return; |
1147 | detach(); | 1150 | detach(); |
1148 | mData->empty = false; | 1151 | mData->empty = false; |
1149 | mData->url = url; | 1152 | mData->url = url; |
1150 | } | 1153 | } |
1151 | 1154 | ||
1152 | KURL Addressee::url() const | 1155 | KURL Addressee::url() const |
1153 | { | 1156 | { |
1154 | return mData->url; | 1157 | return mData->url; |
1155 | } | 1158 | } |
1156 | 1159 | ||
1157 | QString Addressee::urlLabel() | 1160 | QString Addressee::urlLabel() |
1158 | { | 1161 | { |
1159 | return i18n("URL"); | 1162 | return i18n("URL"); |
1160 | } | 1163 | } |
1161 | 1164 | ||
1162 | 1165 | ||
1163 | void Addressee::setSecrecy( const Secrecy &secrecy ) | 1166 | void Addressee::setSecrecy( const Secrecy &secrecy ) |
1164 | { | 1167 | { |
1165 | if ( secrecy == mData->secrecy ) return; | 1168 | if ( secrecy == mData->secrecy ) return; |
1166 | detach(); | 1169 | detach(); |
1167 | mData->empty = false; | 1170 | mData->empty = false; |
1168 | mData->secrecy = secrecy; | 1171 | mData->secrecy = secrecy; |
1169 | } | 1172 | } |
1170 | 1173 | ||
1171 | Secrecy Addressee::secrecy() const | 1174 | Secrecy Addressee::secrecy() const |
1172 | { | 1175 | { |
1173 | return mData->secrecy; | 1176 | return mData->secrecy; |
1174 | } | 1177 | } |
1175 | 1178 | ||
1176 | QString Addressee::secrecyLabel() | 1179 | QString Addressee::secrecyLabel() |
1177 | { | 1180 | { |
1178 | return i18n("Security Class"); | 1181 | return i18n("Security Class"); |
1179 | } | 1182 | } |
1180 | 1183 | ||
1181 | 1184 | ||
1182 | void Addressee::setLogo( const Picture &logo ) | 1185 | void Addressee::setLogo( const Picture &logo ) |
1183 | { | 1186 | { |
1184 | if ( logo == mData->logo ) return; | 1187 | if ( logo == mData->logo ) return; |
1185 | detach(); | 1188 | detach(); |
1186 | mData->empty = false; | 1189 | mData->empty = false; |
1187 | mData->logo = logo; | 1190 | mData->logo = logo; |
1188 | } | 1191 | } |
1189 | 1192 | ||
1190 | Picture Addressee::logo() const | 1193 | Picture Addressee::logo() const |
1191 | { | 1194 | { |
1192 | return mData->logo; | 1195 | return mData->logo; |
1193 | } | 1196 | } |
1194 | 1197 | ||
1195 | QString Addressee::logoLabel() | 1198 | QString Addressee::logoLabel() |
1196 | { | 1199 | { |
1197 | return i18n("Logo"); | 1200 | return i18n("Logo"); |
1198 | } | 1201 | } |
1199 | 1202 | ||
1200 | 1203 | ||
1201 | void Addressee::setPhoto( const Picture &photo ) | 1204 | void Addressee::setPhoto( const Picture &photo ) |
1202 | { | 1205 | { |
1203 | if ( photo == mData->photo ) return; | 1206 | if ( photo == mData->photo ) return; |
1204 | detach(); | 1207 | detach(); |
1205 | mData->empty = false; | 1208 | mData->empty = false; |
1206 | mData->photo = photo; | 1209 | mData->photo = photo; |
1207 | } | 1210 | } |
1208 | 1211 | ||
1209 | Picture Addressee::photo() const | 1212 | Picture Addressee::photo() const |
1210 | { | 1213 | { |
1211 | return mData->photo; | 1214 | return mData->photo; |
1212 | } | 1215 | } |
1213 | 1216 | ||
1214 | QString Addressee::photoLabel() | 1217 | QString Addressee::photoLabel() |
1215 | { | 1218 | { |
1216 | return i18n("Photo"); | 1219 | return i18n("Photo"); |
1217 | } | 1220 | } |
1218 | 1221 | ||
1219 | 1222 | ||
1220 | void Addressee::setSound( const Sound &sound ) | 1223 | void Addressee::setSound( const Sound &sound ) |
1221 | { | 1224 | { |
1222 | if ( sound == mData->sound ) return; | 1225 | if ( sound == mData->sound ) return; |
1223 | detach(); | 1226 | detach(); |
1224 | mData->empty = false; | 1227 | mData->empty = false; |
1225 | mData->sound = sound; | 1228 | mData->sound = sound; |
1226 | } | 1229 | } |
1227 | 1230 | ||
1228 | Sound Addressee::sound() const | 1231 | Sound Addressee::sound() const |
1229 | { | 1232 | { |
1230 | return mData->sound; | 1233 | return mData->sound; |
1231 | } | 1234 | } |
1232 | 1235 | ||
1233 | QString Addressee::soundLabel() | 1236 | QString Addressee::soundLabel() |
1234 | { | 1237 | { |
1235 | return i18n("Sound"); | 1238 | return i18n("Sound"); |
1236 | } | 1239 | } |
1237 | 1240 | ||
1238 | 1241 | ||
1239 | void Addressee::setAgent( const Agent &agent ) | 1242 | void Addressee::setAgent( const Agent &agent ) |
1240 | { | 1243 | { |
1241 | if ( agent == mData->agent ) return; | 1244 | if ( agent == mData->agent ) return; |
1242 | detach(); | 1245 | detach(); |
1243 | mData->empty = false; | 1246 | mData->empty = false; |
1244 | mData->agent = agent; | 1247 | mData->agent = agent; |
1245 | } | 1248 | } |
1246 | 1249 | ||
1247 | Agent Addressee::agent() const | 1250 | Agent Addressee::agent() const |
1248 | { | 1251 | { |
1249 | return mData->agent; | 1252 | return mData->agent; |
1250 | } | 1253 | } |
1251 | 1254 | ||
1252 | QString Addressee::agentLabel() | 1255 | QString Addressee::agentLabel() |
1253 | { | 1256 | { |
1254 | return i18n("Agent"); | 1257 | return i18n("Agent"); |
1255 | } | 1258 | } |
1256 | 1259 | ||
1257 | 1260 | ||
1258 | 1261 | ||
1259 | void Addressee::setNameFromString( const QString &str ) | 1262 | void Addressee::setNameFromString( const QString &str ) |
1260 | { | 1263 | { |
1261 | setFormattedName( str ); | 1264 | setFormattedName( str ); |
1262 | setName( str ); | 1265 | setName( str ); |
1263 | 1266 | ||
1264 | static bool first = true; | 1267 | static bool first = true; |
1265 | static QStringList titles; | 1268 | static QStringList titles; |
1266 | static QStringList suffixes; | 1269 | static QStringList suffixes; |
1267 | static QStringList prefixes; | 1270 | static QStringList prefixes; |
1268 | 1271 | ||
1269 | if ( first ) { | 1272 | if ( first ) { |
1270 | first = false; | 1273 | first = false; |
1271 | titles += i18n( "Dr." ); | 1274 | titles += i18n( "Dr." ); |
1272 | titles += i18n( "Miss" ); | 1275 | titles += i18n( "Miss" ); |
1273 | titles += i18n( "Mr." ); | 1276 | titles += i18n( "Mr." ); |
1274 | titles += i18n( "Mrs." ); | 1277 | titles += i18n( "Mrs." ); |
1275 | titles += i18n( "Ms." ); | 1278 | titles += i18n( "Ms." ); |
1276 | titles += i18n( "Prof." ); | 1279 | titles += i18n( "Prof." ); |
1277 | 1280 | ||
1278 | suffixes += i18n( "I" ); | 1281 | suffixes += i18n( "I" ); |
1279 | suffixes += i18n( "II" ); | 1282 | suffixes += i18n( "II" ); |
1280 | suffixes += i18n( "III" ); | 1283 | suffixes += i18n( "III" ); |
1281 | suffixes += i18n( "Jr." ); | 1284 | suffixes += i18n( "Jr." ); |
1282 | suffixes += i18n( "Sr." ); | 1285 | suffixes += i18n( "Sr." ); |
1283 | 1286 | ||
1284 | prefixes += "van"; | 1287 | prefixes += "van"; |
1285 | prefixes += "von"; | 1288 | prefixes += "von"; |
1286 | prefixes += "de"; | 1289 | prefixes += "de"; |
1287 | 1290 | ||
1288 | KConfig config( locateLocal( "config", "kabcrc") ); | 1291 | KConfig config( locateLocal( "config", "kabcrc") ); |
1289 | config.setGroup( "General" ); | 1292 | config.setGroup( "General" ); |
1290 | titles += config.readListEntry( "Prefixes" ); | 1293 | titles += config.readListEntry( "Prefixes" ); |
1291 | titles.remove( "" ); | 1294 | titles.remove( "" ); |
1292 | prefixes += config.readListEntry( "Inclusions" ); | 1295 | prefixes += config.readListEntry( "Inclusions" ); |
1293 | prefixes.remove( "" ); | 1296 | prefixes.remove( "" ); |
1294 | suffixes += config.readListEntry( "Suffixes" ); | 1297 | suffixes += config.readListEntry( "Suffixes" ); |
1295 | suffixes.remove( "" ); | 1298 | suffixes.remove( "" ); |
1296 | } | 1299 | } |
1297 | 1300 | ||
1298 | // clear all name parts | 1301 | // clear all name parts |
1299 | setPrefix( "" ); | 1302 | setPrefix( "" ); |
1300 | setGivenName( "" ); | 1303 | setGivenName( "" ); |
1301 | setAdditionalName( "" ); | 1304 | setAdditionalName( "" ); |
1302 | setFamilyName( "" ); | 1305 | setFamilyName( "" ); |
1303 | setSuffix( "" ); | 1306 | setSuffix( "" ); |
1304 | 1307 | ||
1305 | if ( str.isEmpty() ) | 1308 | if ( str.isEmpty() ) |
1306 | return; | 1309 | return; |
1307 | 1310 | ||
1308 | int i = str.find(','); | 1311 | int i = str.find(','); |
1309 | if( i < 0 ) { | 1312 | if( i < 0 ) { |
1310 | QStringList parts = QStringList::split( " ", str ); | 1313 | QStringList parts = QStringList::split( " ", str ); |
1311 | int leftOffset = 0; | 1314 | int leftOffset = 0; |
1312 | int rightOffset = parts.count() - 1; | 1315 | int rightOffset = parts.count() - 1; |
1313 | 1316 | ||
1314 | QString suffix; | 1317 | QString suffix; |
1315 | while ( rightOffset >= 0 ) { | 1318 | while ( rightOffset >= 0 ) { |
1316 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1319 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1317 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1320 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1318 | rightOffset--; | 1321 | rightOffset--; |
1319 | } else | 1322 | } else |
1320 | break; | 1323 | break; |
1321 | } | 1324 | } |
1322 | setSuffix( suffix ); | 1325 | setSuffix( suffix ); |
1323 | 1326 | ||
1324 | if ( rightOffset < 0 ) | 1327 | if ( rightOffset < 0 ) |