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