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