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