-rw-r--r-- | kabc/address.cpp | 27 | ||||
-rw-r--r-- | kabc/address.h | 2 | ||||
-rw-r--r-- | kabc/addressee.cpp | 25 | ||||
-rw-r--r-- | kabc/addressee.h | 4 |
4 files changed, 58 insertions, 0 deletions
diff --git a/kabc/address.cpp b/kabc/address.cpp index 5ffe511..6151f9e 100644 --- a/kabc/address.cpp +++ b/kabc/address.cpp | |||
@@ -56,96 +56,123 @@ Address::Address( int type ) : | |||
56 | 56 | ||
57 | bool Address::operator==( const Address &a ) const | 57 | bool Address::operator==( const Address &a ) const |
58 | { | 58 | { |
59 | if ( mPostOfficeBox != a.mPostOfficeBox ) return false; | 59 | if ( mPostOfficeBox != a.mPostOfficeBox ) return false; |
60 | if ( mExtended != a.mExtended ) return false; | 60 | if ( mExtended != a.mExtended ) return false; |
61 | if ( mStreet != a.mStreet ) return false; | 61 | if ( mStreet != a.mStreet ) return false; |
62 | if ( mLocality != a.mLocality ) return false; | 62 | if ( mLocality != a.mLocality ) return false; |
63 | if ( mRegion != a.mRegion ) return false; | 63 | if ( mRegion != a.mRegion ) return false; |
64 | if ( mPostalCode != a.mPostalCode ) return false; | 64 | if ( mPostalCode != a.mPostalCode ) return false; |
65 | if ( mCountry != a.mCountry ) return false; | 65 | if ( mCountry != a.mCountry ) return false; |
66 | if ( mLabel != a.mLabel ) return false; | 66 | if ( mLabel != a.mLabel ) return false; |
67 | 67 | ||
68 | return true; | 68 | return true; |
69 | } | 69 | } |
70 | 70 | ||
71 | bool Address::operator!=( const Address &a ) const | 71 | bool Address::operator!=( const Address &a ) const |
72 | { | 72 | { |
73 | return !( a == *this ); | 73 | return !( a == *this ); |
74 | } | 74 | } |
75 | 75 | ||
76 | bool Address::isEmpty() const | 76 | bool Address::isEmpty() const |
77 | { | 77 | { |
78 | if ( mPostOfficeBox.isEmpty() && | 78 | if ( mPostOfficeBox.isEmpty() && |
79 | mExtended.isEmpty() && | 79 | mExtended.isEmpty() && |
80 | mStreet.isEmpty() && | 80 | mStreet.isEmpty() && |
81 | mLocality.isEmpty() && | 81 | mLocality.isEmpty() && |
82 | mRegion.isEmpty() && | 82 | mRegion.isEmpty() && |
83 | mPostalCode.isEmpty() && | 83 | mPostalCode.isEmpty() && |
84 | mCountry.isEmpty() && | 84 | mCountry.isEmpty() && |
85 | mLabel.isEmpty() ) { | 85 | mLabel.isEmpty() ) { |
86 | return true; | 86 | return true; |
87 | } | 87 | } |
88 | return false; | 88 | return false; |
89 | } | 89 | } |
90 | 90 | ||
91 | QStringList Address::asList() | 91 | QStringList Address::asList() |
92 | { | 92 | { |
93 | QStringList result; | 93 | QStringList result; |
94 | if ( ! mPostOfficeBox.isEmpty() )result.append(mPostOfficeBox); | 94 | if ( ! mPostOfficeBox.isEmpty() )result.append(mPostOfficeBox); |
95 | if ( ! mExtended.isEmpty())result.append(mExtended); | 95 | if ( ! mExtended.isEmpty())result.append(mExtended); |
96 | if ( ! mStreet.isEmpty())result.append(mStreet); | 96 | if ( ! mStreet.isEmpty())result.append(mStreet); |
97 | if ( ! mLocality.isEmpty() )result.append(mLocality); | 97 | if ( ! mLocality.isEmpty() )result.append(mLocality); |
98 | if ( ! mRegion.isEmpty())result.append(mRegion); | 98 | if ( ! mRegion.isEmpty())result.append(mRegion); |
99 | if ( ! mPostalCode.isEmpty())result.append(mPostalCode); | 99 | if ( ! mPostalCode.isEmpty())result.append(mPostalCode); |
100 | if ( ! mCountry.isEmpty())result.append(mCountry); | 100 | if ( ! mCountry.isEmpty())result.append(mCountry); |
101 | if ( ! mLabel.isEmpty() )result.append(mLabel); | 101 | if ( ! mLabel.isEmpty() )result.append(mLabel); |
102 | return result; | 102 | return result; |
103 | } | 103 | } |
104 | |||
105 | bool Address::matchAddress( QRegExp* re ) const | ||
106 | { | ||
107 | |||
108 | #if QT_VERSION >= 0x030000 | ||
109 | if (re->search( mPostOfficeBox ) == 0) return true; | ||
110 | if (re->search( mExtended ) == 0) return true; | ||
111 | if (re->search( mStreet ) == 0) return true; | ||
112 | if (re->search( mLocality ) == 0) return true; | ||
113 | if (re->search( mRegion ) == 0) return true; | ||
114 | if (re->search( mPostalCode ) == 0) return true; | ||
115 | if (re->search( mCountry ) == 0) return true; | ||
116 | if (re->search( mLabel ) == 0) return true; | ||
117 | #else | ||
118 | if (re->match( mPostOfficeBox ) == 0) return true; | ||
119 | if (re->match( mExtended ) == 0) return true; | ||
120 | if (re->match( mStreet ) == 0) return true; | ||
121 | if (re->match( mLocality ) == 0) return true; | ||
122 | if (re->match( mRegion ) == 0) return true; | ||
123 | if (re->match( mPostalCode ) == 0) return true; | ||
124 | if (re->match( mCountry ) == 0) return true; | ||
125 | if (re->match( mLabel ) == 0) return true; | ||
126 | #endif | ||
127 | |||
128 | return false; | ||
129 | } | ||
130 | |||
104 | void Address::clear() | 131 | void Address::clear() |
105 | { | 132 | { |
106 | *this = Address(); | 133 | *this = Address(); |
107 | } | 134 | } |
108 | 135 | ||
109 | void Address::setId( const QString &id ) | 136 | void Address::setId( const QString &id ) |
110 | { | 137 | { |
111 | mEmpty = false; | 138 | mEmpty = false; |
112 | 139 | ||
113 | mId = id; | 140 | mId = id; |
114 | } | 141 | } |
115 | 142 | ||
116 | QString Address::id() const | 143 | QString Address::id() const |
117 | { | 144 | { |
118 | return mId; | 145 | return mId; |
119 | } | 146 | } |
120 | 147 | ||
121 | void Address::setType( int type ) | 148 | void Address::setType( int type ) |
122 | { | 149 | { |
123 | mEmpty = false; | 150 | mEmpty = false; |
124 | 151 | ||
125 | mType = type; | 152 | mType = type; |
126 | } | 153 | } |
127 | 154 | ||
128 | int Address::type() const | 155 | int Address::type() const |
129 | { | 156 | { |
130 | return mType; | 157 | return mType; |
131 | } | 158 | } |
132 | 159 | ||
133 | QString Address::typeLabel() const | 160 | QString Address::typeLabel() const |
134 | { | 161 | { |
135 | QString label; | 162 | QString label; |
136 | bool first = true; | 163 | bool first = true; |
137 | 164 | ||
138 | TypeList list = typeList(); | 165 | TypeList list = typeList(); |
139 | 166 | ||
140 | TypeList::Iterator it; | 167 | TypeList::Iterator it; |
141 | for ( it = list.begin(); it != list.end(); ++it ) { | 168 | for ( it = list.begin(); it != list.end(); ++it ) { |
142 | if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { | 169 | if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { |
143 | label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); | 170 | label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); |
144 | if ( first ) | 171 | if ( first ) |
145 | first = false; | 172 | first = false; |
146 | } | 173 | } |
147 | } | 174 | } |
148 | 175 | ||
149 | return label; | 176 | return label; |
150 | } | 177 | } |
151 | 178 | ||
diff --git a/kabc/address.h b/kabc/address.h index 37dd851..38ad20b 100644 --- a/kabc/address.h +++ b/kabc/address.h | |||
@@ -1,145 +1,147 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #ifndef KABC_ADDRESS_H | 28 | #ifndef KABC_ADDRESS_H |
29 | #define KABC_ADDRESS_H | 29 | #define KABC_ADDRESS_H |
30 | 30 | ||
31 | #include <qmap.h> | 31 | #include <qmap.h> |
32 | #include <qstring.h> | 32 | #include <qstring.h> |
33 | #include <qregexp.h> | ||
33 | #include <qstringlist.h> | 34 | #include <qstringlist.h> |
34 | #include <qvaluelist.h> | 35 | #include <qvaluelist.h> |
35 | 36 | ||
36 | // template tags for address formatting localization | 37 | // template tags for address formatting localization |
37 | #define KABC_FMTTAG_realname QString("%n") | 38 | #define KABC_FMTTAG_realname QString("%n") |
38 | #define KABC_FMTTAG_REALNAME QString("%N") | 39 | #define KABC_FMTTAG_REALNAME QString("%N") |
39 | #define KABC_FMTTAG_company QString("%cm") | 40 | #define KABC_FMTTAG_company QString("%cm") |
40 | #define KABC_FMTTAG_COMPANY QString("%CM") | 41 | #define KABC_FMTTAG_COMPANY QString("%CM") |
41 | #define KABC_FMTTAG_pobox QString("%p") | 42 | #define KABC_FMTTAG_pobox QString("%p") |
42 | #define KABC_FMTTAG_street QString("%s") | 43 | #define KABC_FMTTAG_street QString("%s") |
43 | #define KABC_FMTTAG_STREET QString("%S") | 44 | #define KABC_FMTTAG_STREET QString("%S") |
44 | #define KABC_FMTTAG_zipcode QString("%z") | 45 | #define KABC_FMTTAG_zipcode QString("%z") |
45 | #define KABC_FMTTAG_location QString("%l") | 46 | #define KABC_FMTTAG_location QString("%l") |
46 | #define KABC_FMTTAG_LOCATION QString("%L") | 47 | #define KABC_FMTTAG_LOCATION QString("%L") |
47 | #define KABC_FMTTAG_region QString("%r") | 48 | #define KABC_FMTTAG_region QString("%r") |
48 | #define KABC_FMTTAG_REGION QString("%R") | 49 | #define KABC_FMTTAG_REGION QString("%R") |
49 | #define KABC_FMTTAG_newline QString("\\n") | 50 | #define KABC_FMTTAG_newline QString("\\n") |
50 | #define KABC_FMTTAG_condcomma QString("%,") | 51 | #define KABC_FMTTAG_condcomma QString("%,") |
51 | #define KABC_FMTTAG_condwhite QString("%w") | 52 | #define KABC_FMTTAG_condwhite QString("%w") |
52 | #define KABC_FMTTAG_purgeempty QString("%0") | 53 | #define KABC_FMTTAG_purgeempty QString("%0") |
53 | 54 | ||
54 | namespace KABC { | 55 | namespace KABC { |
55 | 56 | ||
56 | /** | 57 | /** |
57 | @short Postal address information. | 58 | @short Postal address information. |
58 | 59 | ||
59 | This class represents information about a postal address. | 60 | This class represents information about a postal address. |
60 | */ | 61 | */ |
61 | class Address | 62 | class Address |
62 | { | 63 | { |
63 | friend QDataStream &operator<<( QDataStream &, const Address & ); | 64 | friend QDataStream &operator<<( QDataStream &, const Address & ); |
64 | friend QDataStream &operator>>( QDataStream &, Address & ); | 65 | friend QDataStream &operator>>( QDataStream &, Address & ); |
65 | 66 | ||
66 | public: | 67 | public: |
67 | /** | 68 | /** |
68 | List of addresses. | 69 | List of addresses. |
69 | */ | 70 | */ |
70 | typedef QValueList<Address> List; | 71 | typedef QValueList<Address> List; |
71 | typedef QValueList<int> TypeList; | 72 | typedef QValueList<int> TypeList; |
72 | 73 | ||
73 | /** | 74 | /** |
74 | Address types: | 75 | Address types: |
75 | 76 | ||
76 | @li @p Dom - domestic | 77 | @li @p Dom - domestic |
77 | @li @p Intl - international | 78 | @li @p Intl - international |
78 | @li @p Postal - postal | 79 | @li @p Postal - postal |
79 | @li @p Parcel - parcel | 80 | @li @p Parcel - parcel |
80 | @li @p Home - home address | 81 | @li @p Home - home address |
81 | @li @p Work - address at work | 82 | @li @p Work - address at work |
82 | @li @p Pref - preferred address | 83 | @li @p Pref - preferred address |
83 | */ | 84 | */ |
84 | enum Type { Dom = 1, Intl = 2, Postal = 4, Parcel = 8, Home = 16, Work = 32, | 85 | enum Type { Dom = 1, Intl = 2, Postal = 4, Parcel = 8, Home = 16, Work = 32, |
85 | Pref = 64 }; | 86 | Pref = 64 }; |
86 | 87 | ||
87 | /** | 88 | /** |
88 | Constructor that creates an empty Address, which is initialized | 89 | Constructor that creates an empty Address, which is initialized |
89 | with a unique id (see @ref id()). | 90 | with a unique id (see @ref id()). |
90 | */ | 91 | */ |
91 | Address(); | 92 | Address(); |
92 | 93 | ||
93 | /** | 94 | /** |
94 | This is like @ref Address() just above, with the difference | 95 | This is like @ref Address() just above, with the difference |
95 | that you can specify the type. | 96 | that you can specify the type. |
96 | */ | 97 | */ |
97 | Address( int ); | 98 | Address( int ); |
99 | bool matchAddress( QRegExp* searchExp ) const; | ||
98 | 100 | ||
99 | bool operator==( const Address & ) const; | 101 | bool operator==( const Address & ) const; |
100 | bool operator!=( const Address & ) const; | 102 | bool operator!=( const Address & ) const; |
101 | 103 | ||
102 | /** | 104 | /** |
103 | Returns true, if the address is empty. | 105 | Returns true, if the address is empty. |
104 | */ | 106 | */ |
105 | bool isEmpty() const; | 107 | bool isEmpty() const; |
106 | 108 | ||
107 | /** | 109 | /** |
108 | Clears all entries of the address. | 110 | Clears all entries of the address. |
109 | */ | 111 | */ |
110 | void clear(); | 112 | void clear(); |
111 | QStringList asList(); | 113 | QStringList asList(); |
112 | 114 | ||
113 | /** | 115 | /** |
114 | Sets the unique id. | 116 | Sets the unique id. |
115 | */ | 117 | */ |
116 | void setId( const QString & ); | 118 | void setId( const QString & ); |
117 | 119 | ||
118 | /* | 120 | /* |
119 | Returns the unique id. | 121 | Returns the unique id. |
120 | */ | 122 | */ |
121 | QString id() const; | 123 | QString id() const; |
122 | 124 | ||
123 | /** | 125 | /** |
124 | Sets the type of address. See enum for definiton of types. | 126 | Sets the type of address. See enum for definiton of types. |
125 | 127 | ||
126 | @param type type, can be a bitwise or of multiple types. | 128 | @param type type, can be a bitwise or of multiple types. |
127 | */ | 129 | */ |
128 | void setType( int type ); | 130 | void setType( int type ); |
129 | 131 | ||
130 | /** | 132 | /** |
131 | Returns the type of address. Can be a bitwise or of multiple types. | 133 | Returns the type of address. Can be a bitwise or of multiple types. |
132 | */ | 134 | */ |
133 | int type() const; | 135 | int type() const; |
134 | 136 | ||
135 | /** | 137 | /** |
136 | Returns a translated string of all types the address has. | 138 | Returns a translated string of all types the address has. |
137 | */ | 139 | */ |
138 | QString typeLabel() const; | 140 | QString typeLabel() const; |
139 | 141 | ||
140 | /** | 142 | /** |
141 | Sets the post office box. | 143 | Sets the post office box. |
142 | */ | 144 | */ |
143 | void setPostOfficeBox( const QString & ); | 145 | void setPostOfficeBox( const QString & ); |
144 | 146 | ||
145 | /** | 147 | /** |
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 155ce24..7e1e414 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -261,97 +261,122 @@ void Addressee::computeCsum(const QString &dev) | |||
261 | KABC::PhoneNumber::List phoneNumbers; | 261 | KABC::PhoneNumber::List phoneNumbers; |
262 | KABC::PhoneNumber::List::Iterator phoneIter; | 262 | KABC::PhoneNumber::List::Iterator phoneIter; |
263 | 263 | ||
264 | QStringList t; | 264 | QStringList t; |
265 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 265 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
266 | ++phoneIter ) | 266 | ++phoneIter ) |
267 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 267 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
268 | t.sort(); | 268 | t.sort(); |
269 | uint iii; | 269 | uint iii; |
270 | for ( iii = 0; iii < t.count(); ++iii) | 270 | for ( iii = 0; iii < t.count(); ++iii) |
271 | l.append( t[iii] ); | 271 | l.append( t[iii] ); |
272 | t = mData->emails; | 272 | t = mData->emails; |
273 | t.sort(); | 273 | t.sort(); |
274 | for ( iii = 0; iii < t.count(); ++iii) | 274 | for ( iii = 0; iii < t.count(); ++iii) |
275 | l.append( t[iii] ); | 275 | l.append( t[iii] ); |
276 | t = mData->categories; | 276 | t = mData->categories; |
277 | t.sort(); | 277 | t.sort(); |
278 | for ( iii = 0; iii < t.count(); ++iii) | 278 | for ( iii = 0; iii < t.count(); ++iii) |
279 | l.append( t[iii] ); | 279 | l.append( t[iii] ); |
280 | t = mData->custom; | 280 | t = mData->custom; |
281 | t.sort(); | 281 | t.sort(); |
282 | for ( iii = 0; iii < t.count(); ++iii) | 282 | for ( iii = 0; iii < t.count(); ++iii) |
283 | if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { | 283 | if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { |
284 | int find = t[iii].find (':')+1; | 284 | int find = t[iii].find (':')+1; |
285 | //qDebug("lennnn %d %d ", find, t[iii].length()); | 285 | //qDebug("lennnn %d %d ", find, t[iii].length()); |
286 | if ( find < t[iii].length()) | 286 | if ( find < t[iii].length()) |
287 | l.append( t[iii] ); | 287 | l.append( t[iii] ); |
288 | 288 | ||
289 | } | 289 | } |
290 | KABC::Address::List::Iterator addressIter; | 290 | KABC::Address::List::Iterator addressIter; |
291 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 291 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
292 | ++addressIter ) { | 292 | ++addressIter ) { |
293 | t = (*addressIter).asList(); | 293 | t = (*addressIter).asList(); |
294 | t.sort(); | 294 | t.sort(); |
295 | for ( iii = 0; iii < t.count(); ++iii) | 295 | for ( iii = 0; iii < t.count(); ++iii) |
296 | l.append( t[iii] ); | 296 | l.append( t[iii] ); |
297 | } | 297 | } |
298 | uint cs = getCsum4List(l); | 298 | uint cs = getCsum4List(l); |
299 | 299 | ||
300 | #if 0 | 300 | #if 0 |
301 | for ( iii = 0; iii < l.count(); ++iii) | 301 | for ( iii = 0; iii < l.count(); ++iii) |
302 | qDebug("%d***%s***",iii,l[iii].latin1()); | 302 | qDebug("%d***%s***",iii,l[iii].latin1()); |
303 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 303 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
304 | #endif | 304 | #endif |
305 | 305 | ||
306 | 306 | ||
307 | setCsum( dev, QString::number (cs )); | 307 | setCsum( dev, QString::number (cs )); |
308 | } | 308 | } |
309 | bool Addressee::matchAddress( QRegExp* re ) const | ||
310 | { | ||
311 | KABC::Address::List::Iterator addressIter; | ||
312 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | ||
313 | ++addressIter ) { | ||
314 | if ( (*addressIter).matchAddress( re ) ) | ||
315 | return true; | ||
316 | } | ||
317 | return false; | ||
318 | } | ||
319 | bool Addressee::matchPhoneNumber( QRegExp* re ) const | ||
320 | { | ||
321 | KABC::PhoneNumber::List::Iterator phoneIter; | ||
322 | |||
323 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); ++phoneIter ) { | ||
324 | #if QT_VERSION >= 0x030000 | ||
325 | if (re->search( (*phoneIter).number() ) == 0) | ||
326 | #else | ||
327 | if (re->match( (*phoneIter).number() ) == 0) | ||
328 | #endif | ||
329 | return true; | ||
309 | 330 | ||
331 | } | ||
332 | return false; | ||
333 | |||
334 | } | ||
310 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | 335 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) |
311 | { | 336 | { |
312 | // merge all standard non-outlook fields. | 337 | // merge all standard non-outlook fields. |
313 | //if isSubSet (e.g. mobile phone sync) merge all fields | 338 | //if isSubSet (e.g. mobile phone sync) merge all fields |
314 | 339 | ||
315 | detach(); | 340 | detach(); |
316 | if ( isSubSet ) { | 341 | if ( isSubSet ) { |
317 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 342 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
318 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 343 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
319 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 344 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
320 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 345 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
321 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 346 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
322 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 347 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
323 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 348 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
324 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 349 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
325 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 350 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
326 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 351 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
327 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 352 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
328 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 353 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
329 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 354 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
330 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 355 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
331 | if ( !mData->birthday.isValid() ) | 356 | if ( !mData->birthday.isValid() ) |
332 | if ( ad.mData->birthday.isValid()) | 357 | if ( ad.mData->birthday.isValid()) |
333 | mData->birthday = ad.mData->birthday; | 358 | mData->birthday = ad.mData->birthday; |
334 | 359 | ||
335 | } | 360 | } |
336 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 361 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
337 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 362 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
338 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 363 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
339 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 364 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
340 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 365 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
341 | QStringList t; | 366 | QStringList t; |
342 | QStringList tAD; | 367 | QStringList tAD; |
343 | uint iii; | 368 | uint iii; |
344 | 369 | ||
345 | // ********** phone numbers | 370 | // ********** phone numbers |
346 | if ( isSubSet ) { | 371 | if ( isSubSet ) { |
347 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 372 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
348 | PhoneNumber::List::Iterator phoneItAD; | 373 | PhoneNumber::List::Iterator phoneItAD; |
349 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 374 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
350 | bool found = false; | 375 | bool found = false; |
351 | PhoneNumber::List::Iterator it; | 376 | PhoneNumber::List::Iterator it; |
352 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 377 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
353 | if ( ( *phoneItAD ).contains( (*it) ) ) { | 378 | if ( ( *phoneItAD ).contains( (*it) ) ) { |
354 | found = true; | 379 | found = true; |
355 | (*it).setType( ( *phoneItAD ).type() ); | 380 | (*it).setType( ( *phoneItAD ).type() ); |
356 | (*it).setNumber( ( *phoneItAD ).number() ); | 381 | (*it).setNumber( ( *phoneItAD ).number() ); |
357 | break; | 382 | break; |
diff --git a/kabc/addressee.h b/kabc/addressee.h index a2fbcf5..d1c07cb 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -1,81 +1,82 @@ | |||
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 | #ifndef KABC_ADDRESSEE_H | 29 | #ifndef KABC_ADDRESSEE_H |
30 | #define KABC_ADDRESSEE_H | 30 | #define KABC_ADDRESSEE_H |
31 | 31 | ||
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <qstring.h> | 33 | #include <qstring.h> |
34 | #include <qregexp.h> | ||
34 | #include <qstringlist.h> | 35 | #include <qstringlist.h> |
35 | #include <qvaluelist.h> | 36 | #include <qvaluelist.h> |
36 | 37 | ||
37 | #include <ksharedptr.h> | 38 | #include <ksharedptr.h> |
38 | #include <kurl.h> | 39 | #include <kurl.h> |
39 | 40 | ||
40 | #include "address.h" | 41 | #include "address.h" |
41 | #include "agent.h" | 42 | #include "agent.h" |
42 | #include "geo.h" | 43 | #include "geo.h" |
43 | #include "key.h" | 44 | #include "key.h" |
44 | #include "phonenumber.h" | 45 | #include "phonenumber.h" |
45 | #include "picture.h" | 46 | #include "picture.h" |
46 | #include "secrecy.h" | 47 | #include "secrecy.h" |
47 | #include "sound.h" | 48 | #include "sound.h" |
48 | #include "timezone.h" | 49 | #include "timezone.h" |
49 | 50 | ||
50 | namespace KABC { | 51 | namespace KABC { |
51 | 52 | ||
52 | class Resource; | 53 | class Resource; |
53 | 54 | ||
54 | /** | 55 | /** |
55 | @short address book entry | 56 | @short address book entry |
56 | 57 | ||
57 | This class represents an entry in the address book. | 58 | This class represents an entry in the address book. |
58 | 59 | ||
59 | The data of this class is implicitly shared. You can pass this class by value. | 60 | The data of this class is implicitly shared. You can pass this class by value. |
60 | 61 | ||
61 | If you need the name of a field for presenting it to the user you should use | 62 | If you need the name of a field for presenting it to the user you should use |
62 | the functions ending in Label(). They return a translated string which can be | 63 | the functions ending in Label(). They return a translated string which can be |
63 | used as label for the corresponding field. | 64 | used as label for the corresponding field. |
64 | 65 | ||
65 | About the name fields: | 66 | About the name fields: |
66 | 67 | ||
67 | givenName() is the first name and familyName() the last name. In some | 68 | givenName() is the first name and familyName() the last name. In some |
68 | countries the family name comes first, that's the reason for the | 69 | countries the family name comes first, that's the reason for the |
69 | naming. formattedName() is the full name with the correct formatting. | 70 | naming. formattedName() is the full name with the correct formatting. |
70 | It is used as an override, when the correct formatting can't be generated | 71 | It is used as an override, when the correct formatting can't be generated |
71 | from the other name fields automatically. | 72 | from the other name fields automatically. |
72 | 73 | ||
73 | realName() returns a fully formatted name(). It uses formattedName, if set, | 74 | realName() returns a fully formatted name(). It uses formattedName, if set, |
74 | otherwise it constucts the name from the name fields. As fallback, if | 75 | otherwise it constucts the name from the name fields. As fallback, if |
75 | nothing else is set it uses name(). | 76 | nothing else is set it uses name(). |
76 | 77 | ||
77 | name() is the NAME type of RFC2426. It can be used as internal name for the | 78 | name() is the NAME type of RFC2426. It can be used as internal name for the |
78 | data enty, but shouldn't be used for displaying the data to the user. | 79 | data enty, but shouldn't be used for displaying the data to the user. |
79 | */ | 80 | */ |
80 | class Addressee | 81 | class Addressee |
81 | { | 82 | { |
@@ -605,96 +606,99 @@ class Addressee | |||
605 | addressee it is not duplicated. | 606 | addressee it is not duplicated. |
606 | 607 | ||
607 | @param email Email address | 608 | @param email Email address |
608 | @param preferred Set to true, if this is the preferred email address of | 609 | @param preferred Set to true, if this is the preferred email address of |
609 | the addressee. | 610 | the addressee. |
610 | */ | 611 | */ |
611 | void insertEmail( const QString &email, bool preferred=false ); | 612 | void insertEmail( const QString &email, bool preferred=false ); |
612 | 613 | ||
613 | /** | 614 | /** |
614 | Remove email address. If the email address doesn't exist, nothing happens. | 615 | Remove email address. If the email address doesn't exist, nothing happens. |
615 | */ | 616 | */ |
616 | void removeEmail( const QString &email ); | 617 | void removeEmail( const QString &email ); |
617 | 618 | ||
618 | /** | 619 | /** |
619 | Return preferred email address. This is the first email address or the | 620 | Return preferred email address. This is the first email address or the |
620 | last one added with @ref insertEmail() with a set preferred parameter. | 621 | last one added with @ref insertEmail() with a set preferred parameter. |
621 | */ | 622 | */ |
622 | QString preferredEmail() const; | 623 | QString preferredEmail() const; |
623 | 624 | ||
624 | /** | 625 | /** |
625 | Return list of all email addresses. | 626 | Return list of all email addresses. |
626 | */ | 627 | */ |
627 | QStringList emails() const; | 628 | QStringList emails() const; |
628 | 629 | ||
629 | /** | 630 | /** |
630 | Set the emails to @param. | 631 | Set the emails to @param. |
631 | The first email address gets the preferred one! | 632 | The first email address gets the preferred one! |
632 | @param list The list of email addresses. | 633 | @param list The list of email addresses. |
633 | */ | 634 | */ |
634 | void setEmails( const QStringList& list); | 635 | void setEmails( const QStringList& list); |
635 | 636 | ||
636 | /** | 637 | /** |
637 | Insert a phone number. If a phone number with the same id already exists | 638 | Insert a phone number. If a phone number with the same id already exists |
638 | in this addressee it is not duplicated. | 639 | in this addressee it is not duplicated. |
639 | */ | 640 | */ |
640 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); | 641 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); |
641 | 642 | ||
642 | /** | 643 | /** |
643 | Remove phone number. If no phone number with the given id exists for this | 644 | Remove phone number. If no phone number with the given id exists for this |
644 | addresse nothing happens. | 645 | addresse nothing happens. |
645 | */ | 646 | */ |
646 | void removePhoneNumber( const PhoneNumber &phoneNumber ); | 647 | void removePhoneNumber( const PhoneNumber &phoneNumber ); |
647 | 648 | ||
648 | /** | 649 | /** |
649 | Return phone number, which matches the given type. | 650 | Return phone number, which matches the given type. |
650 | */ | 651 | */ |
651 | PhoneNumber phoneNumber( int type ) const; | 652 | PhoneNumber phoneNumber( int type ) const; |
652 | 653 | ||
654 | bool matchPhoneNumber( QRegExp* searchExp ) const; | ||
655 | bool matchAddress( QRegExp* searchExp ) const; | ||
656 | |||
653 | /** | 657 | /** |
654 | Return list of all phone numbers. | 658 | Return list of all phone numbers. |
655 | */ | 659 | */ |
656 | PhoneNumber::List phoneNumbers() const; | 660 | PhoneNumber::List phoneNumbers() const; |
657 | 661 | ||
658 | /** | 662 | /** |
659 | Return list of phone numbers with a special type. | 663 | Return list of phone numbers with a special type. |
660 | */ | 664 | */ |
661 | PhoneNumber::List phoneNumbers( int type ) const; | 665 | PhoneNumber::List phoneNumbers( int type ) const; |
662 | 666 | ||
663 | /** | 667 | /** |
664 | Return phone number with the given id. | 668 | Return phone number with the given id. |
665 | */ | 669 | */ |
666 | PhoneNumber findPhoneNumber( const QString &id ) const; | 670 | PhoneNumber findPhoneNumber( const QString &id ) const; |
667 | 671 | ||
668 | /** | 672 | /** |
669 | Insert a key. If a key with the same id already exists | 673 | Insert a key. If a key with the same id already exists |
670 | in this addressee it is not duplicated. | 674 | in this addressee it is not duplicated. |
671 | */ | 675 | */ |
672 | void insertKey( const Key &key ); | 676 | void insertKey( const Key &key ); |
673 | 677 | ||
674 | /** | 678 | /** |
675 | Remove a key. If no key with the given id exists for this | 679 | Remove a key. If no key with the given id exists for this |
676 | addresse nothing happens. | 680 | addresse nothing happens. |
677 | */ | 681 | */ |
678 | void removeKey( const Key &key ); | 682 | void removeKey( const Key &key ); |
679 | 683 | ||
680 | /** | 684 | /** |
681 | Return key, which matches the given type. | 685 | Return key, which matches the given type. |
682 | If @p type == Key::Custom you can specify a string | 686 | If @p type == Key::Custom you can specify a string |
683 | that should match. If you leave the string empty, the first | 687 | that should match. If you leave the string empty, the first |
684 | key with a custom value is returned. | 688 | key with a custom value is returned. |
685 | */ | 689 | */ |
686 | Key key( int type, QString customTypeString = QString::null ) const; | 690 | Key key( int type, QString customTypeString = QString::null ) const; |
687 | 691 | ||
688 | /** | 692 | /** |
689 | Return list of all keys. | 693 | Return list of all keys. |
690 | */ | 694 | */ |
691 | Key::List keys() const; | 695 | Key::List keys() const; |
692 | 696 | ||
693 | /** | 697 | /** |
694 | Set the list of keys | 698 | Set the list of keys |
695 | @param keys The keys to be set. | 699 | @param keys The keys to be set. |
696 | */ | 700 | */ |
697 | void setKeys( const Key::List& keys); | 701 | void setKeys( const Key::List& keys); |
698 | 702 | ||
699 | /** | 703 | /** |
700 | Return list of keys with a special type. | 704 | Return list of keys with a special type. |