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