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