author | zautrix <zautrix> | 2004-10-08 20:03:23 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-08 20:03:23 (UTC) |
commit | 10a0e05cc4962d9412a7a5faf3d69a3caf6d1c34 (patch) (unidiff) | |
tree | 3105b985a9dbedd31dff52e14fe667eeff4f9ff4 | |
parent | 13bd085e06b76228321f5a004759fcdf19cca711 (diff) | |
download | kdepimpi-10a0e05cc4962d9412a7a5faf3d69a3caf6d1c34.zip kdepimpi-10a0e05cc4962d9412a7a5faf3d69a3caf6d1c34.tar.gz kdepimpi-10a0e05cc4962d9412a7a5faf3d69a3caf6d1c34.tar.bz2 |
added contact phone support
-rw-r--r-- | kabc/addressee.cpp | 32 | ||||
-rw-r--r-- | kabc/addressee.h | 4 | ||||
-rw-r--r-- | kabc/phonenumber.cpp | 23 | ||||
-rw-r--r-- | kabc/phonenumber.h | 2 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 23 |
5 files changed, 80 insertions, 4 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 25c77f6..e571980 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,1870 +1,1902 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <kconfig.h> | 29 | #include <kconfig.h> |
30 | 30 | ||
31 | #include <ksharedptr.h> | 31 | #include <ksharedptr.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <kapplication.h> | 33 | #include <kapplication.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kidmanager.h> | 35 | #include <kidmanager.h> |
36 | //US | 36 | //US |
37 | #include <kstandarddirs.h> | 37 | #include <kstandarddirs.h> |
38 | #include <libkcal/syncdefines.h> | 38 | #include <libkcal/syncdefines.h> |
39 | 39 | ||
40 | //US #include "resource.h" | 40 | //US #include "resource.h" |
41 | #include "addressee.h" | 41 | #include "addressee.h" |
42 | 42 | ||
43 | using namespace KABC; | 43 | using namespace KABC; |
44 | 44 | ||
45 | static bool matchBinaryPattern( int value, int pattern ); | 45 | static bool matchBinaryPattern( int value, int pattern ); |
46 | static bool matchBinaryPatternA( int value, int pattern ); | 46 | static bool matchBinaryPatternA( int value, int pattern ); |
47 | static bool matchBinaryPatternP( int value, int pattern ); | 47 | static bool matchBinaryPatternP( int value, int pattern ); |
48 | 48 | ||
49 | struct Addressee::AddresseeData : public KShared | 49 | struct Addressee::AddresseeData : public KShared |
50 | { | 50 | { |
51 | QString uid; | 51 | QString uid; |
52 | QString name; | 52 | QString name; |
53 | QString formattedName; | 53 | QString formattedName; |
54 | QString familyName; | 54 | QString familyName; |
55 | QString givenName; | 55 | QString givenName; |
56 | QString additionalName; | 56 | QString additionalName; |
57 | QString prefix; | 57 | QString prefix; |
58 | QString suffix; | 58 | QString suffix; |
59 | QString nickName; | 59 | QString nickName; |
60 | QDateTime birthday; | 60 | QDateTime birthday; |
61 | QString mailer; | 61 | QString mailer; |
62 | TimeZone timeZone; | 62 | TimeZone timeZone; |
63 | Geo geo; | 63 | Geo geo; |
64 | QString title; | 64 | QString title; |
65 | QString role; | 65 | QString role; |
66 | QString organization; | 66 | QString organization; |
67 | QString note; | 67 | QString note; |
68 | QString productId; | 68 | QString productId; |
69 | QDateTime revision; | 69 | QDateTime revision; |
70 | QString sortString; | 70 | QString sortString; |
71 | QString externalUID; | 71 | QString externalUID; |
72 | QString originalExternalUID; | 72 | QString originalExternalUID; |
73 | KURL url; | 73 | KURL url; |
74 | Secrecy secrecy; | 74 | Secrecy secrecy; |
75 | Picture logo; | 75 | Picture logo; |
76 | Picture photo; | 76 | Picture photo; |
77 | Sound sound; | 77 | Sound sound; |
78 | Agent agent; | 78 | Agent agent; |
79 | QString mExternalId; | 79 | QString mExternalId; |
80 | PhoneNumber::List phoneNumbers; | 80 | PhoneNumber::List phoneNumbers; |
81 | Address::List addresses; | 81 | Address::List addresses; |
82 | Key::List keys; | 82 | Key::List keys; |
83 | QStringList emails; | 83 | QStringList emails; |
84 | QStringList categories; | 84 | QStringList categories; |
85 | QStringList custom; | 85 | QStringList custom; |
86 | int mTempSyncStat; | 86 | int mTempSyncStat; |
87 | Resource *resource; | 87 | Resource *resource; |
88 | 88 | ||
89 | bool empty :1; | 89 | bool empty :1; |
90 | bool changed :1; | 90 | bool changed :1; |
91 | }; | 91 | }; |
92 | 92 | ||
93 | Addressee::Addressee() | 93 | Addressee::Addressee() |
94 | { | 94 | { |
95 | mData = new AddresseeData; | 95 | mData = new AddresseeData; |
96 | mData->empty = true; | 96 | mData->empty = true; |
97 | mData->changed = false; | 97 | mData->changed = false; |
98 | mData->resource = 0; | 98 | mData->resource = 0; |
99 | mData->mExternalId = ":"; | 99 | mData->mExternalId = ":"; |
100 | mData->revision = QDateTime ( QDate( 2003,1,1)); | 100 | mData->revision = QDateTime ( QDate( 2003,1,1)); |
101 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 101 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
102 | } | 102 | } |
103 | 103 | ||
104 | Addressee::~Addressee() | 104 | Addressee::~Addressee() |
105 | { | 105 | { |
106 | } | 106 | } |
107 | 107 | ||
108 | Addressee::Addressee( const Addressee &a ) | 108 | Addressee::Addressee( const Addressee &a ) |
109 | { | 109 | { |
110 | mData = a.mData; | 110 | mData = a.mData; |
111 | } | 111 | } |
112 | 112 | ||
113 | Addressee &Addressee::operator=( const Addressee &a ) | 113 | Addressee &Addressee::operator=( const Addressee &a ) |
114 | { | 114 | { |
115 | mData = a.mData; | 115 | mData = a.mData; |
116 | return (*this); | 116 | return (*this); |
117 | } | 117 | } |
118 | 118 | ||
119 | Addressee Addressee::copy() | 119 | Addressee Addressee::copy() |
120 | { | 120 | { |
121 | Addressee a; | 121 | Addressee a; |
122 | *(a.mData) = *mData; | 122 | *(a.mData) = *mData; |
123 | return a; | 123 | return a; |
124 | } | 124 | } |
125 | 125 | ||
126 | void Addressee::detach() | 126 | void Addressee::detach() |
127 | { | 127 | { |
128 | if ( mData.count() == 1 ) return; | 128 | if ( mData.count() == 1 ) return; |
129 | *this = copy(); | 129 | *this = copy(); |
130 | } | 130 | } |
131 | 131 | ||
132 | bool Addressee::operator==( const Addressee &a ) const | 132 | bool Addressee::operator==( const Addressee &a ) const |
133 | { | 133 | { |
134 | if ( uid() != a.uid() ) return false; | 134 | if ( uid() != a.uid() ) return false; |
135 | if ( mData->name != a.mData->name ) return false; | 135 | if ( mData->name != a.mData->name ) return false; |
136 | if ( mData->formattedName != a.mData->formattedName ) return false; | 136 | if ( mData->formattedName != a.mData->formattedName ) return false; |
137 | if ( mData->familyName != a.mData->familyName ) return false; | 137 | if ( mData->familyName != a.mData->familyName ) return false; |
138 | if ( mData->givenName != a.mData->givenName ) return false; | 138 | if ( mData->givenName != a.mData->givenName ) return false; |
139 | if ( mData->additionalName != a.mData->additionalName ) return false; | 139 | if ( mData->additionalName != a.mData->additionalName ) return false; |
140 | if ( mData->prefix != a.mData->prefix ) return false; | 140 | if ( mData->prefix != a.mData->prefix ) return false; |
141 | if ( mData->suffix != a.mData->suffix ) return false; | 141 | if ( mData->suffix != a.mData->suffix ) return false; |
142 | if ( mData->nickName != a.mData->nickName ) return false; | 142 | if ( mData->nickName != a.mData->nickName ) return false; |
143 | if ( mData->birthday != a.mData->birthday ) return false; | 143 | if ( mData->birthday != a.mData->birthday ) return false; |
144 | if ( mData->mailer != a.mData->mailer ) return false; | 144 | if ( mData->mailer != a.mData->mailer ) return false; |
145 | if ( mData->timeZone != a.mData->timeZone ) return false; | 145 | if ( mData->timeZone != a.mData->timeZone ) return false; |
146 | if ( mData->geo != a.mData->geo ) return false; | 146 | if ( mData->geo != a.mData->geo ) return false; |
147 | if ( mData->title != a.mData->title ) return false; | 147 | if ( mData->title != a.mData->title ) return false; |
148 | if ( mData->role != a.mData->role ) return false; | 148 | if ( mData->role != a.mData->role ) return false; |
149 | if ( mData->organization != a.mData->organization ) return false; | 149 | if ( mData->organization != a.mData->organization ) return false; |
150 | if ( mData->note != a.mData->note ) return false; | 150 | if ( mData->note != a.mData->note ) return false; |
151 | if ( mData->productId != a.mData->productId ) return false; | 151 | if ( mData->productId != a.mData->productId ) return false; |
152 | //if ( mData->revision != a.mData->revision ) return false; | 152 | //if ( mData->revision != a.mData->revision ) return false; |
153 | if ( mData->sortString != a.mData->sortString ) return false; | 153 | if ( mData->sortString != a.mData->sortString ) return false; |
154 | if ( mData->secrecy != a.mData->secrecy ) return false; | 154 | if ( mData->secrecy != a.mData->secrecy ) return false; |
155 | if ( mData->logo != a.mData->logo ) return false; | 155 | if ( mData->logo != a.mData->logo ) return false; |
156 | if ( mData->photo != a.mData->photo ) return false; | 156 | if ( mData->photo != a.mData->photo ) return false; |
157 | if ( mData->sound != a.mData->sound ) return false; | 157 | if ( mData->sound != a.mData->sound ) return false; |
158 | if ( mData->agent != a.mData->agent ) return false; | 158 | if ( mData->agent != a.mData->agent ) return false; |
159 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 159 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
160 | ( mData->url != a.mData->url ) ) return false; | 160 | ( mData->url != a.mData->url ) ) return false; |
161 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 161 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
162 | if ( mData->addresses != a.mData->addresses ) return false; | 162 | if ( mData->addresses != a.mData->addresses ) return false; |
163 | if ( mData->keys != a.mData->keys ) return false; | 163 | if ( mData->keys != a.mData->keys ) return false; |
164 | if ( mData->emails != a.mData->emails ) return false; | 164 | if ( mData->emails != a.mData->emails ) return false; |
165 | if ( mData->categories != a.mData->categories ) return false; | 165 | if ( mData->categories != a.mData->categories ) return false; |
166 | if ( mData->custom != a.mData->custom ) return false; | 166 | if ( mData->custom != a.mData->custom ) return false; |
167 | 167 | ||
168 | return true; | 168 | return true; |
169 | } | 169 | } |
170 | 170 | ||
171 | bool Addressee::operator!=( const Addressee &a ) const | 171 | bool Addressee::operator!=( const Addressee &a ) const |
172 | { | 172 | { |
173 | return !( a == *this ); | 173 | return !( a == *this ); |
174 | } | 174 | } |
175 | 175 | ||
176 | bool Addressee::isEmpty() const | 176 | bool Addressee::isEmpty() const |
177 | { | 177 | { |
178 | return mData->empty; | 178 | return mData->empty; |
179 | } | 179 | } |
180 | ulong Addressee::getCsum4List( const QStringList & attList) | 180 | ulong Addressee::getCsum4List( const QStringList & attList) |
181 | { | 181 | { |
182 | int max = attList.count(); | 182 | int max = attList.count(); |
183 | ulong cSum = 0; | 183 | ulong cSum = 0; |
184 | int j,k,i; | 184 | int j,k,i; |
185 | int add; | 185 | int add; |
186 | for ( i = 0; i < max ; ++i ) { | 186 | for ( i = 0; i < max ; ++i ) { |
187 | QString s = attList[i]; | 187 | QString s = attList[i]; |
188 | if ( ! s.isEmpty() ){ | 188 | if ( ! s.isEmpty() ){ |
189 | j = s.length(); | 189 | j = s.length(); |
190 | for ( k = 0; k < j; ++k ) { | 190 | for ( k = 0; k < j; ++k ) { |
191 | int mul = k +1; | 191 | int mul = k +1; |
192 | add = s[k].unicode (); | 192 | add = s[k].unicode (); |
193 | if ( k < 16 ) | 193 | if ( k < 16 ) |
194 | mul = mul * mul; | 194 | mul = mul * mul; |
195 | int ii = i+1; | 195 | int ii = i+1; |
196 | add = add * mul *ii*ii*ii; | 196 | add = add * mul *ii*ii*ii; |
197 | cSum += add; | 197 | cSum += add; |
198 | } | 198 | } |
199 | } | 199 | } |
200 | 200 | ||
201 | } | 201 | } |
202 | //QString dump = attList.join(","); | 202 | //QString dump = attList.join(","); |
203 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 203 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
204 | 204 | ||
205 | return cSum; | 205 | return cSum; |
206 | 206 | ||
207 | } | 207 | } |
208 | void Addressee::computeCsum(const QString &dev) | 208 | void Addressee::computeCsum(const QString &dev) |
209 | { | 209 | { |
210 | QStringList l; | 210 | QStringList l; |
211 | if ( !mData->name.isEmpty() ) l.append(mData->name); | 211 | if ( !mData->name.isEmpty() ) l.append(mData->name); |
212 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 212 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
213 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 213 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
214 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 214 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
215 | if ( !mData->additionalName ) l.append( mData->additionalName ); | 215 | if ( !mData->additionalName ) l.append( mData->additionalName ); |
216 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 216 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
217 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 217 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
218 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 218 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
219 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 219 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
220 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 220 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
221 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 221 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
222 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 222 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
223 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 223 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
224 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 224 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
225 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 225 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
226 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 226 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
227 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 227 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
228 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 228 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
229 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 229 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
230 | // if ( !mData->logo.isEmpty() ) l.append( ); | 230 | // if ( !mData->logo.isEmpty() ) l.append( ); |
231 | //if ( !mData->photo.isEmpty() ) l.append( ); | 231 | //if ( !mData->photo.isEmpty() ) l.append( ); |
232 | //if ( !mData->sound.isEmpty() ) l.append( ); | 232 | //if ( !mData->sound.isEmpty() ) l.append( ); |
233 | //if ( !mData->agent.isEmpty() ) l.append( ); | 233 | //if ( !mData->agent.isEmpty() ) l.append( ); |
234 | //if ( mData->url.isValid() ) l.append( ); | 234 | //if ( mData->url.isValid() ) l.append( ); |
235 | #if 0 | 235 | #if 0 |
236 | if ( !mData->phoneNumbers.isEmpty() ) l.append( ); | 236 | if ( !mData->phoneNumbers.isEmpty() ) l.append( ); |
237 | if ( !mData->addresses.isEmpty() ) l.append( ); | 237 | if ( !mData->addresses.isEmpty() ) l.append( ); |
238 | //if ( !mData->keys.isEmpty() ) l.append( ); | 238 | //if ( !mData->keys.isEmpty() ) l.append( ); |
239 | if ( !mData->emails.isEmpty() ) l.append( ); | 239 | if ( !mData->emails.isEmpty() ) l.append( ); |
240 | if ( !mData->categories .isEmpty() ) l.append( ); | 240 | if ( !mData->categories .isEmpty() ) l.append( ); |
241 | if ( !mData->custom.isEmpty() ) l.append( ); | 241 | if ( !mData->custom.isEmpty() ) l.append( ); |
242 | #endif | 242 | #endif |
243 | KABC::PhoneNumber::List phoneNumbers; | 243 | KABC::PhoneNumber::List phoneNumbers; |
244 | KABC::PhoneNumber::List::Iterator phoneIter; | 244 | KABC::PhoneNumber::List::Iterator phoneIter; |
245 | 245 | ||
246 | QStringList t; | 246 | QStringList t; |
247 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 247 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
248 | ++phoneIter ) | 248 | ++phoneIter ) |
249 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 249 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
250 | t.sort(); | 250 | t.sort(); |
251 | uint iii; | 251 | uint iii; |
252 | for ( iii = 0; iii < t.count(); ++iii) | 252 | for ( iii = 0; iii < t.count(); ++iii) |
253 | l.append( t[iii] ); | 253 | l.append( t[iii] ); |
254 | t = mData->emails; | 254 | t = mData->emails; |
255 | t.sort(); | 255 | t.sort(); |
256 | for ( iii = 0; iii < t.count(); ++iii) | 256 | for ( iii = 0; iii < t.count(); ++iii) |
257 | l.append( t[iii] ); | 257 | l.append( t[iii] ); |
258 | t = mData->categories; | 258 | t = mData->categories; |
259 | t.sort(); | 259 | t.sort(); |
260 | for ( iii = 0; iii < t.count(); ++iii) | 260 | for ( iii = 0; iii < t.count(); ++iii) |
261 | l.append( t[iii] ); | 261 | l.append( t[iii] ); |
262 | t = mData->custom; | 262 | t = mData->custom; |
263 | t.sort(); | 263 | t.sort(); |
264 | for ( iii = 0; iii < t.count(); ++iii) | 264 | for ( iii = 0; iii < t.count(); ++iii) |
265 | l.append( t[iii] ); | 265 | l.append( t[iii] ); |
266 | KABC::Address::List::Iterator addressIter; | 266 | KABC::Address::List::Iterator addressIter; |
267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
268 | ++addressIter ) { | 268 | ++addressIter ) { |
269 | t = (*addressIter).asList(); | 269 | t = (*addressIter).asList(); |
270 | t.sort(); | 270 | t.sort(); |
271 | for ( iii = 0; iii < t.count(); ++iii) | 271 | for ( iii = 0; iii < t.count(); ++iii) |
272 | l.append( t[iii] ); | 272 | l.append( t[iii] ); |
273 | } | 273 | } |
274 | uint cs = getCsum4List(l); | 274 | uint cs = getCsum4List(l); |
275 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 275 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
276 | setCsum( dev, QString::number (cs )); | 276 | setCsum( dev, QString::number (cs )); |
277 | } | 277 | } |
278 | 278 | ||
279 | void Addressee::mergeContact( const Addressee& ad ) | 279 | void Addressee::mergeContact( const Addressee& ad ) |
280 | { | 280 | { |
281 | 281 | ||
282 | detach(); | 282 | detach(); |
283 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 283 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
284 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 284 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
285 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 285 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
286 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 286 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
287 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 287 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
288 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 288 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
289 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 289 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
290 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 290 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
291 | if ( !mData->birthday.isValid() ) | 291 | if ( !mData->birthday.isValid() ) |
292 | if ( ad.mData->birthday.isValid()) | 292 | if ( ad.mData->birthday.isValid()) |
293 | mData->birthday = ad.mData->birthday; | 293 | mData->birthday = ad.mData->birthday; |
294 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 294 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
295 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 295 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
296 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 296 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
297 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 297 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
298 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 298 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
299 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 299 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
300 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 300 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
301 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 301 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
302 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 302 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
303 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 303 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
304 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 304 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
305 | 305 | ||
306 | // pending: | 306 | // pending: |
307 | // merging phonenumbers | 307 | // merging phonenumbers |
308 | // merging addresses | 308 | // merging addresses |
309 | // merging emails; | 309 | // merging emails; |
310 | // merging categories; | 310 | // merging categories; |
311 | // merging custom; | 311 | // merging custom; |
312 | // merging keys | 312 | // merging keys |
313 | qDebug("merge contact %s ", ad.uid().latin1()); | 313 | qDebug("merge contact %s ", ad.uid().latin1()); |
314 | setUid( ad.uid() ); | 314 | setUid( ad.uid() ); |
315 | setRevision( ad.revision() ); | 315 | setRevision( ad.revision() ); |
316 | } | 316 | } |
317 | 317 | ||
318 | // removes all emails but the first | ||
319 | // needed by phone sync | ||
320 | void Addressee::simplifyEmails() | ||
321 | { | ||
322 | if ( mData->emails.count() == 0 ) return ; | ||
323 | QString email = mData->emails.first(); | ||
324 | detach(); | ||
325 | mData->emails.clear(); | ||
326 | mData->emails.append( email ); | ||
327 | } | ||
328 | |||
329 | void Addressee::simplifyPhoneNumbers() | ||
330 | { | ||
331 | KABC::PhoneNumber::List removeNumbers; | ||
332 | KABC::PhoneNumber::List::Iterator phoneIter; | ||
333 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | ||
334 | ++phoneIter ) { | ||
335 | if ( ! ( *phoneIter ).simplifyNumber() ) | ||
336 | removeNumbers.append( ( *phoneIter ) ); | ||
337 | } | ||
338 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | ||
339 | ++phoneIter ) { | ||
340 | removePhoneNumber(( *phoneIter )); | ||
341 | } | ||
342 | } | ||
343 | void Addressee::simplifyPhoneNumberTypes() | ||
344 | { | ||
345 | KABC::PhoneNumber::List::Iterator phoneIter; | ||
346 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | ||
347 | ++phoneIter ) | ||
348 | ( *phoneIter ).simplifyType(); | ||
349 | } | ||
318 | void Addressee::removeID(const QString &prof) | 350 | void Addressee::removeID(const QString &prof) |
319 | { | 351 | { |
320 | detach(); | 352 | detach(); |
321 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 353 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
322 | 354 | ||
323 | } | 355 | } |
324 | void Addressee::setID( const QString & prof , const QString & id ) | 356 | void Addressee::setID( const QString & prof , const QString & id ) |
325 | { | 357 | { |
326 | detach(); | 358 | detach(); |
327 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 359 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
328 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 360 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
329 | } | 361 | } |
330 | void Addressee::setTempSyncStat( int id ) | 362 | void Addressee::setTempSyncStat( int id ) |
331 | { | 363 | { |
332 | if ( mData->mTempSyncStat == id ) return; | 364 | if ( mData->mTempSyncStat == id ) return; |
333 | detach(); | 365 | detach(); |
334 | mData->mTempSyncStat = id; | 366 | mData->mTempSyncStat = id; |
335 | } | 367 | } |
336 | int Addressee::tempSyncStat() const | 368 | int Addressee::tempSyncStat() const |
337 | { | 369 | { |
338 | return mData->mTempSyncStat; | 370 | return mData->mTempSyncStat; |
339 | } | 371 | } |
340 | 372 | ||
341 | QString Addressee::getID( const QString & prof) | 373 | QString Addressee::getID( const QString & prof) |
342 | { | 374 | { |
343 | return KIdManager::getId ( mData->mExternalId, prof ); | 375 | return KIdManager::getId ( mData->mExternalId, prof ); |
344 | } | 376 | } |
345 | 377 | ||
346 | void Addressee::setCsum( const QString & prof , const QString & id ) | 378 | void Addressee::setCsum( const QString & prof , const QString & id ) |
347 | { | 379 | { |
348 | detach(); | 380 | detach(); |
349 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 381 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
350 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 382 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
351 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 383 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
352 | } | 384 | } |
353 | 385 | ||
354 | QString Addressee::getCsum( const QString & prof) | 386 | QString Addressee::getCsum( const QString & prof) |
355 | { | 387 | { |
356 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 388 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
357 | } | 389 | } |
358 | 390 | ||
359 | void Addressee::setIDStr( const QString & s ) | 391 | void Addressee::setIDStr( const QString & s ) |
360 | { | 392 | { |
361 | detach(); | 393 | detach(); |
362 | mData->mExternalId = s; | 394 | mData->mExternalId = s; |
363 | } | 395 | } |
364 | 396 | ||
365 | QString Addressee::IDStr() const | 397 | QString Addressee::IDStr() const |
366 | { | 398 | { |
367 | return mData->mExternalId; | 399 | return mData->mExternalId; |
368 | } | 400 | } |
369 | 401 | ||
370 | void Addressee::setExternalUID( const QString &id ) | 402 | void Addressee::setExternalUID( const QString &id ) |
371 | { | 403 | { |
372 | if ( id == mData->externalUID ) return; | 404 | if ( id == mData->externalUID ) return; |
373 | detach(); | 405 | detach(); |
374 | mData->empty = false; | 406 | mData->empty = false; |
375 | mData->externalUID = id; | 407 | mData->externalUID = id; |
376 | } | 408 | } |
377 | 409 | ||
378 | QString Addressee::externalUID() const | 410 | QString Addressee::externalUID() const |
379 | { | 411 | { |
380 | return mData->externalUID; | 412 | return mData->externalUID; |
381 | } | 413 | } |
382 | void Addressee::setOriginalExternalUID( const QString &id ) | 414 | void Addressee::setOriginalExternalUID( const QString &id ) |
383 | { | 415 | { |
384 | if ( id == mData->originalExternalUID ) return; | 416 | if ( id == mData->originalExternalUID ) return; |
385 | detach(); | 417 | detach(); |
386 | mData->empty = false; | 418 | mData->empty = false; |
387 | //qDebug("*******Set orig uid %s ", id.latin1()); | 419 | //qDebug("*******Set orig uid %s ", id.latin1()); |
388 | mData->originalExternalUID = id; | 420 | mData->originalExternalUID = id; |
389 | } | 421 | } |
390 | 422 | ||
391 | QString Addressee::originalExternalUID() const | 423 | QString Addressee::originalExternalUID() const |
392 | { | 424 | { |
393 | return mData->originalExternalUID; | 425 | return mData->originalExternalUID; |
394 | } | 426 | } |
395 | 427 | ||
396 | void Addressee::setUid( const QString &id ) | 428 | void Addressee::setUid( const QString &id ) |
397 | { | 429 | { |
398 | if ( id == mData->uid ) return; | 430 | if ( id == mData->uid ) return; |
399 | detach(); | 431 | detach(); |
400 | //qDebug("****setuid %s ", id.latin1()); | 432 | //qDebug("****setuid %s ", id.latin1()); |
401 | mData->empty = false; | 433 | mData->empty = false; |
402 | mData->uid = id; | 434 | mData->uid = id; |
403 | } | 435 | } |
404 | 436 | ||
405 | QString Addressee::uid() const | 437 | QString Addressee::uid() const |
406 | { | 438 | { |
407 | if ( mData->uid.isEmpty() ) | 439 | if ( mData->uid.isEmpty() ) |
408 | mData->uid = KApplication::randomString( 10 ); | 440 | mData->uid = KApplication::randomString( 10 ); |
409 | 441 | ||
410 | return mData->uid; | 442 | return mData->uid; |
411 | } | 443 | } |
412 | 444 | ||
413 | QString Addressee::uidLabel() | 445 | QString Addressee::uidLabel() |
414 | { | 446 | { |
415 | return i18n("Unique Identifier"); | 447 | return i18n("Unique Identifier"); |
416 | } | 448 | } |
417 | 449 | ||
418 | void Addressee::setName( const QString &name ) | 450 | void Addressee::setName( const QString &name ) |
419 | { | 451 | { |
420 | if ( name == mData->name ) return; | 452 | if ( name == mData->name ) return; |
421 | detach(); | 453 | detach(); |
422 | mData->empty = false; | 454 | mData->empty = false; |
423 | mData->name = name; | 455 | mData->name = name; |
424 | } | 456 | } |
425 | 457 | ||
426 | QString Addressee::name() const | 458 | QString Addressee::name() const |
427 | { | 459 | { |
428 | return mData->name; | 460 | return mData->name; |
429 | } | 461 | } |
430 | 462 | ||
431 | QString Addressee::nameLabel() | 463 | QString Addressee::nameLabel() |
432 | { | 464 | { |
433 | return i18n("Name"); | 465 | return i18n("Name"); |
434 | } | 466 | } |
435 | 467 | ||
436 | 468 | ||
437 | void Addressee::setFormattedName( const QString &formattedName ) | 469 | void Addressee::setFormattedName( const QString &formattedName ) |
438 | { | 470 | { |
439 | if ( formattedName == mData->formattedName ) return; | 471 | if ( formattedName == mData->formattedName ) return; |
440 | detach(); | 472 | detach(); |
441 | mData->empty = false; | 473 | mData->empty = false; |
442 | mData->formattedName = formattedName; | 474 | mData->formattedName = formattedName; |
443 | } | 475 | } |
444 | 476 | ||
445 | QString Addressee::formattedName() const | 477 | QString Addressee::formattedName() const |
446 | { | 478 | { |
447 | return mData->formattedName; | 479 | return mData->formattedName; |
448 | } | 480 | } |
449 | 481 | ||
450 | QString Addressee::formattedNameLabel() | 482 | QString Addressee::formattedNameLabel() |
451 | { | 483 | { |
452 | return i18n("Formatted Name"); | 484 | return i18n("Formatted Name"); |
453 | } | 485 | } |
454 | 486 | ||
455 | 487 | ||
456 | void Addressee::setFamilyName( const QString &familyName ) | 488 | void Addressee::setFamilyName( const QString &familyName ) |
457 | { | 489 | { |
458 | if ( familyName == mData->familyName ) return; | 490 | if ( familyName == mData->familyName ) return; |
459 | detach(); | 491 | detach(); |
460 | mData->empty = false; | 492 | mData->empty = false; |
461 | mData->familyName = familyName; | 493 | mData->familyName = familyName; |
462 | } | 494 | } |
463 | 495 | ||
464 | QString Addressee::familyName() const | 496 | QString Addressee::familyName() const |
465 | { | 497 | { |
466 | return mData->familyName; | 498 | return mData->familyName; |
467 | } | 499 | } |
468 | 500 | ||
469 | QString Addressee::familyNameLabel() | 501 | QString Addressee::familyNameLabel() |
470 | { | 502 | { |
471 | return i18n("Family Name"); | 503 | return i18n("Family Name"); |
472 | } | 504 | } |
473 | 505 | ||
474 | 506 | ||
475 | void Addressee::setGivenName( const QString &givenName ) | 507 | void Addressee::setGivenName( const QString &givenName ) |
476 | { | 508 | { |
477 | if ( givenName == mData->givenName ) return; | 509 | if ( givenName == mData->givenName ) return; |
478 | detach(); | 510 | detach(); |
479 | mData->empty = false; | 511 | mData->empty = false; |
480 | mData->givenName = givenName; | 512 | mData->givenName = givenName; |
481 | } | 513 | } |
482 | 514 | ||
483 | QString Addressee::givenName() const | 515 | QString Addressee::givenName() const |
484 | { | 516 | { |
485 | return mData->givenName; | 517 | return mData->givenName; |
486 | } | 518 | } |
487 | 519 | ||
488 | QString Addressee::givenNameLabel() | 520 | QString Addressee::givenNameLabel() |
489 | { | 521 | { |
490 | return i18n("Given Name"); | 522 | return i18n("Given Name"); |
491 | } | 523 | } |
492 | 524 | ||
493 | 525 | ||
494 | void Addressee::setAdditionalName( const QString &additionalName ) | 526 | void Addressee::setAdditionalName( const QString &additionalName ) |
495 | { | 527 | { |
496 | if ( additionalName == mData->additionalName ) return; | 528 | if ( additionalName == mData->additionalName ) return; |
497 | detach(); | 529 | detach(); |
498 | mData->empty = false; | 530 | mData->empty = false; |
499 | mData->additionalName = additionalName; | 531 | mData->additionalName = additionalName; |
500 | } | 532 | } |
501 | 533 | ||
502 | QString Addressee::additionalName() const | 534 | QString Addressee::additionalName() const |
503 | { | 535 | { |
504 | return mData->additionalName; | 536 | return mData->additionalName; |
505 | } | 537 | } |
506 | 538 | ||
507 | QString Addressee::additionalNameLabel() | 539 | QString Addressee::additionalNameLabel() |
508 | { | 540 | { |
509 | return i18n("Additional Names"); | 541 | return i18n("Additional Names"); |
510 | } | 542 | } |
511 | 543 | ||
512 | 544 | ||
513 | void Addressee::setPrefix( const QString &prefix ) | 545 | void Addressee::setPrefix( const QString &prefix ) |
514 | { | 546 | { |
515 | if ( prefix == mData->prefix ) return; | 547 | if ( prefix == mData->prefix ) return; |
516 | detach(); | 548 | detach(); |
517 | mData->empty = false; | 549 | mData->empty = false; |
518 | mData->prefix = prefix; | 550 | mData->prefix = prefix; |
519 | } | 551 | } |
520 | 552 | ||
521 | QString Addressee::prefix() const | 553 | QString Addressee::prefix() const |
522 | { | 554 | { |
523 | return mData->prefix; | 555 | return mData->prefix; |
524 | } | 556 | } |
525 | 557 | ||
526 | QString Addressee::prefixLabel() | 558 | QString Addressee::prefixLabel() |
527 | { | 559 | { |
528 | return i18n("Honorific Prefixes"); | 560 | return i18n("Honorific Prefixes"); |
529 | } | 561 | } |
530 | 562 | ||
531 | 563 | ||
532 | void Addressee::setSuffix( const QString &suffix ) | 564 | void Addressee::setSuffix( const QString &suffix ) |
533 | { | 565 | { |
534 | if ( suffix == mData->suffix ) return; | 566 | if ( suffix == mData->suffix ) return; |
535 | detach(); | 567 | detach(); |
536 | mData->empty = false; | 568 | mData->empty = false; |
537 | mData->suffix = suffix; | 569 | mData->suffix = suffix; |
538 | } | 570 | } |
539 | 571 | ||
540 | QString Addressee::suffix() const | 572 | QString Addressee::suffix() const |
541 | { | 573 | { |
542 | return mData->suffix; | 574 | return mData->suffix; |
543 | } | 575 | } |
544 | 576 | ||
545 | QString Addressee::suffixLabel() | 577 | QString Addressee::suffixLabel() |
546 | { | 578 | { |
547 | return i18n("Honorific Suffixes"); | 579 | return i18n("Honorific Suffixes"); |
548 | } | 580 | } |
549 | 581 | ||
550 | 582 | ||
551 | void Addressee::setNickName( const QString &nickName ) | 583 | void Addressee::setNickName( const QString &nickName ) |
552 | { | 584 | { |
553 | if ( nickName == mData->nickName ) return; | 585 | if ( nickName == mData->nickName ) return; |
554 | detach(); | 586 | detach(); |
555 | mData->empty = false; | 587 | mData->empty = false; |
556 | mData->nickName = nickName; | 588 | mData->nickName = nickName; |
557 | } | 589 | } |
558 | 590 | ||
559 | QString Addressee::nickName() const | 591 | QString Addressee::nickName() const |
560 | { | 592 | { |
561 | return mData->nickName; | 593 | return mData->nickName; |
562 | } | 594 | } |
563 | 595 | ||
564 | QString Addressee::nickNameLabel() | 596 | QString Addressee::nickNameLabel() |
565 | { | 597 | { |
566 | return i18n("Nick Name"); | 598 | return i18n("Nick Name"); |
567 | } | 599 | } |
568 | 600 | ||
569 | 601 | ||
570 | void Addressee::setBirthday( const QDateTime &birthday ) | 602 | void Addressee::setBirthday( const QDateTime &birthday ) |
571 | { | 603 | { |
572 | if ( birthday == mData->birthday ) return; | 604 | if ( birthday == mData->birthday ) return; |
573 | detach(); | 605 | detach(); |
574 | mData->empty = false; | 606 | mData->empty = false; |
575 | mData->birthday = birthday; | 607 | mData->birthday = birthday; |
576 | } | 608 | } |
577 | 609 | ||
578 | QDateTime Addressee::birthday() const | 610 | QDateTime Addressee::birthday() const |
579 | { | 611 | { |
580 | return mData->birthday; | 612 | return mData->birthday; |
581 | } | 613 | } |
582 | 614 | ||
583 | QString Addressee::birthdayLabel() | 615 | QString Addressee::birthdayLabel() |
584 | { | 616 | { |
585 | return i18n("Birthday"); | 617 | return i18n("Birthday"); |
586 | } | 618 | } |
587 | 619 | ||
588 | 620 | ||
589 | QString Addressee::homeAddressStreetLabel() | 621 | QString Addressee::homeAddressStreetLabel() |
590 | { | 622 | { |
591 | return i18n("Home Address Street"); | 623 | return i18n("Home Address Street"); |
592 | } | 624 | } |
593 | 625 | ||
594 | 626 | ||
595 | QString Addressee::homeAddressLocalityLabel() | 627 | QString Addressee::homeAddressLocalityLabel() |
596 | { | 628 | { |
597 | return i18n("Home Address Locality"); | 629 | return i18n("Home Address Locality"); |
598 | } | 630 | } |
599 | 631 | ||
600 | 632 | ||
601 | QString Addressee::homeAddressRegionLabel() | 633 | QString Addressee::homeAddressRegionLabel() |
602 | { | 634 | { |
603 | return i18n("Home Address Region"); | 635 | return i18n("Home Address Region"); |
604 | } | 636 | } |
605 | 637 | ||
606 | 638 | ||
607 | QString Addressee::homeAddressPostalCodeLabel() | 639 | QString Addressee::homeAddressPostalCodeLabel() |
608 | { | 640 | { |
609 | return i18n("Home Address Postal Code"); | 641 | return i18n("Home Address Postal Code"); |
610 | } | 642 | } |
611 | 643 | ||
612 | 644 | ||
613 | QString Addressee::homeAddressCountryLabel() | 645 | QString Addressee::homeAddressCountryLabel() |
614 | { | 646 | { |
615 | return i18n("Home Address Country"); | 647 | return i18n("Home Address Country"); |
616 | } | 648 | } |
617 | 649 | ||
618 | 650 | ||
619 | QString Addressee::homeAddressLabelLabel() | 651 | QString Addressee::homeAddressLabelLabel() |
620 | { | 652 | { |
621 | return i18n("Home Address Label"); | 653 | return i18n("Home Address Label"); |
622 | } | 654 | } |
623 | 655 | ||
624 | 656 | ||
625 | QString Addressee::businessAddressStreetLabel() | 657 | QString Addressee::businessAddressStreetLabel() |
626 | { | 658 | { |
627 | return i18n("Business Address Street"); | 659 | return i18n("Business Address Street"); |
628 | } | 660 | } |
629 | 661 | ||
630 | 662 | ||
631 | QString Addressee::businessAddressLocalityLabel() | 663 | QString Addressee::businessAddressLocalityLabel() |
632 | { | 664 | { |
633 | return i18n("Business Address Locality"); | 665 | return i18n("Business Address Locality"); |
634 | } | 666 | } |
635 | 667 | ||
636 | 668 | ||
637 | QString Addressee::businessAddressRegionLabel() | 669 | QString Addressee::businessAddressRegionLabel() |
638 | { | 670 | { |
639 | return i18n("Business Address Region"); | 671 | return i18n("Business Address Region"); |
640 | } | 672 | } |
641 | 673 | ||
642 | 674 | ||
643 | QString Addressee::businessAddressPostalCodeLabel() | 675 | QString Addressee::businessAddressPostalCodeLabel() |
644 | { | 676 | { |
645 | return i18n("Business Address Postal Code"); | 677 | return i18n("Business Address Postal Code"); |
646 | } | 678 | } |
647 | 679 | ||
648 | 680 | ||
649 | QString Addressee::businessAddressCountryLabel() | 681 | QString Addressee::businessAddressCountryLabel() |
650 | { | 682 | { |
651 | return i18n("Business Address Country"); | 683 | return i18n("Business Address Country"); |
652 | } | 684 | } |
653 | 685 | ||
654 | 686 | ||
655 | QString Addressee::businessAddressLabelLabel() | 687 | QString Addressee::businessAddressLabelLabel() |
656 | { | 688 | { |
657 | return i18n("Business Address Label"); | 689 | return i18n("Business Address Label"); |
658 | } | 690 | } |
659 | 691 | ||
660 | 692 | ||
661 | QString Addressee::homePhoneLabel() | 693 | QString Addressee::homePhoneLabel() |
662 | { | 694 | { |
663 | return i18n("Home Phone"); | 695 | return i18n("Home Phone"); |
664 | } | 696 | } |
665 | 697 | ||
666 | 698 | ||
667 | QString Addressee::businessPhoneLabel() | 699 | QString Addressee::businessPhoneLabel() |
668 | { | 700 | { |
669 | return i18n("Business Phone"); | 701 | return i18n("Business Phone"); |
670 | } | 702 | } |
671 | 703 | ||
672 | 704 | ||
673 | QString Addressee::mobilePhoneLabel() | 705 | QString Addressee::mobilePhoneLabel() |
674 | { | 706 | { |
675 | return i18n("Mobile Phone"); | 707 | return i18n("Mobile Phone"); |
676 | } | 708 | } |
677 | 709 | ||
678 | 710 | ||
679 | QString Addressee::homeFaxLabel() | 711 | QString Addressee::homeFaxLabel() |
680 | { | 712 | { |
681 | return i18n("Home Fax"); | 713 | return i18n("Home Fax"); |
682 | } | 714 | } |
683 | 715 | ||
684 | 716 | ||
685 | QString Addressee::businessFaxLabel() | 717 | QString Addressee::businessFaxLabel() |
686 | { | 718 | { |
687 | return i18n("Business Fax"); | 719 | return i18n("Business Fax"); |
688 | } | 720 | } |
689 | 721 | ||
690 | 722 | ||
691 | QString Addressee::carPhoneLabel() | 723 | QString Addressee::carPhoneLabel() |
692 | { | 724 | { |
693 | return i18n("Car Phone"); | 725 | return i18n("Car Phone"); |
694 | } | 726 | } |
695 | 727 | ||
696 | 728 | ||
697 | QString Addressee::isdnLabel() | 729 | QString Addressee::isdnLabel() |
698 | { | 730 | { |
699 | return i18n("ISDN"); | 731 | return i18n("ISDN"); |
700 | } | 732 | } |
701 | 733 | ||
702 | 734 | ||
703 | QString Addressee::pagerLabel() | 735 | QString Addressee::pagerLabel() |
704 | { | 736 | { |
705 | return i18n("Pager"); | 737 | return i18n("Pager"); |
706 | } | 738 | } |
707 | 739 | ||
708 | QString Addressee::sipLabel() | 740 | QString Addressee::sipLabel() |
709 | { | 741 | { |
710 | return i18n("SIP"); | 742 | return i18n("SIP"); |
711 | } | 743 | } |
712 | 744 | ||
713 | QString Addressee::emailLabel() | 745 | QString Addressee::emailLabel() |
714 | { | 746 | { |
715 | return i18n("Email Address"); | 747 | return i18n("Email Address"); |
716 | } | 748 | } |
717 | 749 | ||
718 | 750 | ||
719 | void Addressee::setMailer( const QString &mailer ) | 751 | void Addressee::setMailer( const QString &mailer ) |
720 | { | 752 | { |
721 | if ( mailer == mData->mailer ) return; | 753 | if ( mailer == mData->mailer ) return; |
722 | detach(); | 754 | detach(); |
723 | mData->empty = false; | 755 | mData->empty = false; |
724 | mData->mailer = mailer; | 756 | mData->mailer = mailer; |
725 | } | 757 | } |
726 | 758 | ||
727 | QString Addressee::mailer() const | 759 | QString Addressee::mailer() const |
728 | { | 760 | { |
729 | return mData->mailer; | 761 | return mData->mailer; |
730 | } | 762 | } |
731 | 763 | ||
732 | QString Addressee::mailerLabel() | 764 | QString Addressee::mailerLabel() |
733 | { | 765 | { |
734 | return i18n("Mail Client"); | 766 | return i18n("Mail Client"); |
735 | } | 767 | } |
736 | 768 | ||
737 | 769 | ||
738 | void Addressee::setTimeZone( const TimeZone &timeZone ) | 770 | void Addressee::setTimeZone( const TimeZone &timeZone ) |
739 | { | 771 | { |
740 | if ( timeZone == mData->timeZone ) return; | 772 | if ( timeZone == mData->timeZone ) return; |
741 | detach(); | 773 | detach(); |
742 | mData->empty = false; | 774 | mData->empty = false; |
743 | mData->timeZone = timeZone; | 775 | mData->timeZone = timeZone; |
744 | } | 776 | } |
745 | 777 | ||
746 | TimeZone Addressee::timeZone() const | 778 | TimeZone Addressee::timeZone() const |
747 | { | 779 | { |
748 | return mData->timeZone; | 780 | return mData->timeZone; |
749 | } | 781 | } |
750 | 782 | ||
751 | QString Addressee::timeZoneLabel() | 783 | QString Addressee::timeZoneLabel() |
752 | { | 784 | { |
753 | return i18n("Time Zone"); | 785 | return i18n("Time Zone"); |
754 | } | 786 | } |
755 | 787 | ||
756 | 788 | ||
757 | void Addressee::setGeo( const Geo &geo ) | 789 | void Addressee::setGeo( const Geo &geo ) |
758 | { | 790 | { |
759 | if ( geo == mData->geo ) return; | 791 | if ( geo == mData->geo ) return; |
760 | detach(); | 792 | detach(); |
761 | mData->empty = false; | 793 | mData->empty = false; |
762 | mData->geo = geo; | 794 | mData->geo = geo; |
763 | } | 795 | } |
764 | 796 | ||
765 | Geo Addressee::geo() const | 797 | Geo Addressee::geo() const |
766 | { | 798 | { |
767 | return mData->geo; | 799 | return mData->geo; |
768 | } | 800 | } |
769 | 801 | ||
770 | QString Addressee::geoLabel() | 802 | QString Addressee::geoLabel() |
771 | { | 803 | { |
772 | return i18n("Geographic Position"); | 804 | return i18n("Geographic Position"); |
773 | } | 805 | } |
774 | 806 | ||
775 | 807 | ||
776 | void Addressee::setTitle( const QString &title ) | 808 | void Addressee::setTitle( const QString &title ) |
777 | { | 809 | { |
778 | if ( title == mData->title ) return; | 810 | if ( title == mData->title ) return; |
779 | detach(); | 811 | detach(); |
780 | mData->empty = false; | 812 | mData->empty = false; |
781 | mData->title = title; | 813 | mData->title = title; |
782 | } | 814 | } |
783 | 815 | ||
784 | QString Addressee::title() const | 816 | QString Addressee::title() const |
785 | { | 817 | { |
786 | return mData->title; | 818 | return mData->title; |
787 | } | 819 | } |
788 | 820 | ||
789 | QString Addressee::titleLabel() | 821 | QString Addressee::titleLabel() |
790 | { | 822 | { |
791 | return i18n("Title"); | 823 | return i18n("Title"); |
792 | } | 824 | } |
793 | 825 | ||
794 | 826 | ||
795 | void Addressee::setRole( const QString &role ) | 827 | void Addressee::setRole( const QString &role ) |
796 | { | 828 | { |
797 | if ( role == mData->role ) return; | 829 | if ( role == mData->role ) return; |
798 | detach(); | 830 | detach(); |
799 | mData->empty = false; | 831 | mData->empty = false; |
800 | mData->role = role; | 832 | mData->role = role; |
801 | } | 833 | } |
802 | 834 | ||
803 | QString Addressee::role() const | 835 | QString Addressee::role() const |
804 | { | 836 | { |
805 | return mData->role; | 837 | return mData->role; |
806 | } | 838 | } |
807 | 839 | ||
808 | QString Addressee::roleLabel() | 840 | QString Addressee::roleLabel() |
809 | { | 841 | { |
810 | return i18n("Role"); | 842 | return i18n("Role"); |
811 | } | 843 | } |
812 | 844 | ||
813 | 845 | ||
814 | void Addressee::setOrganization( const QString &organization ) | 846 | void Addressee::setOrganization( const QString &organization ) |
815 | { | 847 | { |
816 | if ( organization == mData->organization ) return; | 848 | if ( organization == mData->organization ) return; |
817 | detach(); | 849 | detach(); |
818 | mData->empty = false; | 850 | mData->empty = false; |
819 | mData->organization = organization; | 851 | mData->organization = organization; |
820 | } | 852 | } |
821 | 853 | ||
822 | QString Addressee::organization() const | 854 | QString Addressee::organization() const |
823 | { | 855 | { |
824 | return mData->organization; | 856 | return mData->organization; |
825 | } | 857 | } |
826 | 858 | ||
827 | QString Addressee::organizationLabel() | 859 | QString Addressee::organizationLabel() |
828 | { | 860 | { |
829 | return i18n("Organization"); | 861 | return i18n("Organization"); |
830 | } | 862 | } |
831 | 863 | ||
832 | 864 | ||
833 | void Addressee::setNote( const QString ¬e ) | 865 | void Addressee::setNote( const QString ¬e ) |
834 | { | 866 | { |
835 | if ( note == mData->note ) return; | 867 | if ( note == mData->note ) return; |
836 | detach(); | 868 | detach(); |
837 | mData->empty = false; | 869 | mData->empty = false; |
838 | mData->note = note; | 870 | mData->note = note; |
839 | } | 871 | } |
840 | 872 | ||
841 | QString Addressee::note() const | 873 | QString Addressee::note() const |
842 | { | 874 | { |
843 | return mData->note; | 875 | return mData->note; |
844 | } | 876 | } |
845 | 877 | ||
846 | QString Addressee::noteLabel() | 878 | QString Addressee::noteLabel() |
847 | { | 879 | { |
848 | return i18n("Note"); | 880 | return i18n("Note"); |
849 | } | 881 | } |
850 | 882 | ||
851 | 883 | ||
852 | void Addressee::setProductId( const QString &productId ) | 884 | void Addressee::setProductId( const QString &productId ) |
853 | { | 885 | { |
854 | if ( productId == mData->productId ) return; | 886 | if ( productId == mData->productId ) return; |
855 | detach(); | 887 | detach(); |
856 | mData->empty = false; | 888 | mData->empty = false; |
857 | mData->productId = productId; | 889 | mData->productId = productId; |
858 | } | 890 | } |
859 | 891 | ||
860 | QString Addressee::productId() const | 892 | QString Addressee::productId() const |
861 | { | 893 | { |
862 | return mData->productId; | 894 | return mData->productId; |
863 | } | 895 | } |
864 | 896 | ||
865 | QString Addressee::productIdLabel() | 897 | QString Addressee::productIdLabel() |
866 | { | 898 | { |
867 | return i18n("Product Identifier"); | 899 | return i18n("Product Identifier"); |
868 | } | 900 | } |
869 | 901 | ||
870 | 902 | ||
871 | void Addressee::setRevision( const QDateTime &revision ) | 903 | void Addressee::setRevision( const QDateTime &revision ) |
872 | { | 904 | { |
873 | if ( revision == mData->revision ) return; | 905 | if ( revision == mData->revision ) return; |
874 | detach(); | 906 | detach(); |
875 | mData->empty = false; | 907 | mData->empty = false; |
876 | mData->revision = revision; | 908 | mData->revision = revision; |
877 | } | 909 | } |
878 | 910 | ||
879 | QDateTime Addressee::revision() const | 911 | QDateTime Addressee::revision() const |
880 | { | 912 | { |
881 | return mData->revision; | 913 | return mData->revision; |
882 | } | 914 | } |
883 | 915 | ||
884 | QString Addressee::revisionLabel() | 916 | QString Addressee::revisionLabel() |
885 | { | 917 | { |
886 | return i18n("Revision Date"); | 918 | return i18n("Revision Date"); |
887 | } | 919 | } |
888 | 920 | ||
889 | 921 | ||
890 | void Addressee::setSortString( const QString &sortString ) | 922 | void Addressee::setSortString( const QString &sortString ) |
891 | { | 923 | { |
892 | if ( sortString == mData->sortString ) return; | 924 | if ( sortString == mData->sortString ) return; |
893 | detach(); | 925 | detach(); |
894 | mData->empty = false; | 926 | mData->empty = false; |
895 | mData->sortString = sortString; | 927 | mData->sortString = sortString; |
896 | } | 928 | } |
897 | 929 | ||
898 | QString Addressee::sortString() const | 930 | QString Addressee::sortString() const |
899 | { | 931 | { |
900 | return mData->sortString; | 932 | return mData->sortString; |
901 | } | 933 | } |
902 | 934 | ||
903 | QString Addressee::sortStringLabel() | 935 | QString Addressee::sortStringLabel() |
904 | { | 936 | { |
905 | return i18n("Sort String"); | 937 | return i18n("Sort String"); |
906 | } | 938 | } |
907 | 939 | ||
908 | 940 | ||
909 | void Addressee::setUrl( const KURL &url ) | 941 | void Addressee::setUrl( const KURL &url ) |
910 | { | 942 | { |
911 | if ( url == mData->url ) return; | 943 | if ( url == mData->url ) return; |
912 | detach(); | 944 | detach(); |
913 | mData->empty = false; | 945 | mData->empty = false; |
914 | mData->url = url; | 946 | mData->url = url; |
915 | } | 947 | } |
916 | 948 | ||
917 | KURL Addressee::url() const | 949 | KURL Addressee::url() const |
918 | { | 950 | { |
919 | return mData->url; | 951 | return mData->url; |
920 | } | 952 | } |
921 | 953 | ||
922 | QString Addressee::urlLabel() | 954 | QString Addressee::urlLabel() |
923 | { | 955 | { |
924 | return i18n("URL"); | 956 | return i18n("URL"); |
925 | } | 957 | } |
926 | 958 | ||
927 | 959 | ||
928 | void Addressee::setSecrecy( const Secrecy &secrecy ) | 960 | void Addressee::setSecrecy( const Secrecy &secrecy ) |
929 | { | 961 | { |
930 | if ( secrecy == mData->secrecy ) return; | 962 | if ( secrecy == mData->secrecy ) return; |
931 | detach(); | 963 | detach(); |
932 | mData->empty = false; | 964 | mData->empty = false; |
933 | mData->secrecy = secrecy; | 965 | mData->secrecy = secrecy; |
934 | } | 966 | } |
935 | 967 | ||
936 | Secrecy Addressee::secrecy() const | 968 | Secrecy Addressee::secrecy() const |
937 | { | 969 | { |
938 | return mData->secrecy; | 970 | return mData->secrecy; |
939 | } | 971 | } |
940 | 972 | ||
941 | QString Addressee::secrecyLabel() | 973 | QString Addressee::secrecyLabel() |
942 | { | 974 | { |
943 | return i18n("Security Class"); | 975 | return i18n("Security Class"); |
944 | } | 976 | } |
945 | 977 | ||
946 | 978 | ||
947 | void Addressee::setLogo( const Picture &logo ) | 979 | void Addressee::setLogo( const Picture &logo ) |
948 | { | 980 | { |
949 | if ( logo == mData->logo ) return; | 981 | if ( logo == mData->logo ) return; |
950 | detach(); | 982 | detach(); |
951 | mData->empty = false; | 983 | mData->empty = false; |
952 | mData->logo = logo; | 984 | mData->logo = logo; |
953 | } | 985 | } |
954 | 986 | ||
955 | Picture Addressee::logo() const | 987 | Picture Addressee::logo() const |
956 | { | 988 | { |
957 | return mData->logo; | 989 | return mData->logo; |
958 | } | 990 | } |
959 | 991 | ||
960 | QString Addressee::logoLabel() | 992 | QString Addressee::logoLabel() |
961 | { | 993 | { |
962 | return i18n("Logo"); | 994 | return i18n("Logo"); |
963 | } | 995 | } |
964 | 996 | ||
965 | 997 | ||
966 | void Addressee::setPhoto( const Picture &photo ) | 998 | void Addressee::setPhoto( const Picture &photo ) |
967 | { | 999 | { |
968 | if ( photo == mData->photo ) return; | 1000 | if ( photo == mData->photo ) return; |
969 | detach(); | 1001 | detach(); |
970 | mData->empty = false; | 1002 | mData->empty = false; |
971 | mData->photo = photo; | 1003 | mData->photo = photo; |
972 | } | 1004 | } |
973 | 1005 | ||
974 | Picture Addressee::photo() const | 1006 | Picture Addressee::photo() const |
975 | { | 1007 | { |
976 | return mData->photo; | 1008 | return mData->photo; |
977 | } | 1009 | } |
978 | 1010 | ||
979 | QString Addressee::photoLabel() | 1011 | QString Addressee::photoLabel() |
980 | { | 1012 | { |
981 | return i18n("Photo"); | 1013 | return i18n("Photo"); |
982 | } | 1014 | } |
983 | 1015 | ||
984 | 1016 | ||
985 | void Addressee::setSound( const Sound &sound ) | 1017 | void Addressee::setSound( const Sound &sound ) |
986 | { | 1018 | { |
987 | if ( sound == mData->sound ) return; | 1019 | if ( sound == mData->sound ) return; |
988 | detach(); | 1020 | detach(); |
989 | mData->empty = false; | 1021 | mData->empty = false; |
990 | mData->sound = sound; | 1022 | mData->sound = sound; |
991 | } | 1023 | } |
992 | 1024 | ||
993 | Sound Addressee::sound() const | 1025 | Sound Addressee::sound() const |
994 | { | 1026 | { |
995 | return mData->sound; | 1027 | return mData->sound; |
996 | } | 1028 | } |
997 | 1029 | ||
998 | QString Addressee::soundLabel() | 1030 | QString Addressee::soundLabel() |
999 | { | 1031 | { |
1000 | return i18n("Sound"); | 1032 | return i18n("Sound"); |
1001 | } | 1033 | } |
1002 | 1034 | ||
1003 | 1035 | ||
1004 | void Addressee::setAgent( const Agent &agent ) | 1036 | void Addressee::setAgent( const Agent &agent ) |
1005 | { | 1037 | { |
1006 | if ( agent == mData->agent ) return; | 1038 | if ( agent == mData->agent ) return; |
1007 | detach(); | 1039 | detach(); |
1008 | mData->empty = false; | 1040 | mData->empty = false; |
1009 | mData->agent = agent; | 1041 | mData->agent = agent; |
1010 | } | 1042 | } |
1011 | 1043 | ||
1012 | Agent Addressee::agent() const | 1044 | Agent Addressee::agent() const |
1013 | { | 1045 | { |
1014 | return mData->agent; | 1046 | return mData->agent; |
1015 | } | 1047 | } |
1016 | 1048 | ||
1017 | QString Addressee::agentLabel() | 1049 | QString Addressee::agentLabel() |
1018 | { | 1050 | { |
1019 | return i18n("Agent"); | 1051 | return i18n("Agent"); |
1020 | } | 1052 | } |
1021 | 1053 | ||
1022 | 1054 | ||
1023 | 1055 | ||
1024 | void Addressee::setNameFromString( const QString &str ) | 1056 | void Addressee::setNameFromString( const QString &str ) |
1025 | { | 1057 | { |
1026 | setFormattedName( str ); | 1058 | setFormattedName( str ); |
1027 | setName( str ); | 1059 | setName( str ); |
1028 | 1060 | ||
1029 | static bool first = true; | 1061 | static bool first = true; |
1030 | static QStringList titles; | 1062 | static QStringList titles; |
1031 | static QStringList suffixes; | 1063 | static QStringList suffixes; |
1032 | static QStringList prefixes; | 1064 | static QStringList prefixes; |
1033 | 1065 | ||
1034 | if ( first ) { | 1066 | if ( first ) { |
1035 | first = false; | 1067 | first = false; |
1036 | titles += i18n( "Dr." ); | 1068 | titles += i18n( "Dr." ); |
1037 | titles += i18n( "Miss" ); | 1069 | titles += i18n( "Miss" ); |
1038 | titles += i18n( "Mr." ); | 1070 | titles += i18n( "Mr." ); |
1039 | titles += i18n( "Mrs." ); | 1071 | titles += i18n( "Mrs." ); |
1040 | titles += i18n( "Ms." ); | 1072 | titles += i18n( "Ms." ); |
1041 | titles += i18n( "Prof." ); | 1073 | titles += i18n( "Prof." ); |
1042 | 1074 | ||
1043 | suffixes += i18n( "I" ); | 1075 | suffixes += i18n( "I" ); |
1044 | suffixes += i18n( "II" ); | 1076 | suffixes += i18n( "II" ); |
1045 | suffixes += i18n( "III" ); | 1077 | suffixes += i18n( "III" ); |
1046 | suffixes += i18n( "Jr." ); | 1078 | suffixes += i18n( "Jr." ); |
1047 | suffixes += i18n( "Sr." ); | 1079 | suffixes += i18n( "Sr." ); |
1048 | 1080 | ||
1049 | prefixes += "van"; | 1081 | prefixes += "van"; |
1050 | prefixes += "von"; | 1082 | prefixes += "von"; |
1051 | prefixes += "de"; | 1083 | prefixes += "de"; |
1052 | 1084 | ||
1053 | KConfig config( locateLocal( "config", "kabcrc") ); | 1085 | KConfig config( locateLocal( "config", "kabcrc") ); |
1054 | config.setGroup( "General" ); | 1086 | config.setGroup( "General" ); |
1055 | titles += config.readListEntry( "Prefixes" ); | 1087 | titles += config.readListEntry( "Prefixes" ); |
1056 | titles.remove( "" ); | 1088 | titles.remove( "" ); |
1057 | prefixes += config.readListEntry( "Inclusions" ); | 1089 | prefixes += config.readListEntry( "Inclusions" ); |
1058 | prefixes.remove( "" ); | 1090 | prefixes.remove( "" ); |
1059 | suffixes += config.readListEntry( "Suffixes" ); | 1091 | suffixes += config.readListEntry( "Suffixes" ); |
1060 | suffixes.remove( "" ); | 1092 | suffixes.remove( "" ); |
1061 | } | 1093 | } |
1062 | 1094 | ||
1063 | // clear all name parts | 1095 | // clear all name parts |
1064 | setPrefix( "" ); | 1096 | setPrefix( "" ); |
1065 | setGivenName( "" ); | 1097 | setGivenName( "" ); |
1066 | setAdditionalName( "" ); | 1098 | setAdditionalName( "" ); |
1067 | setFamilyName( "" ); | 1099 | setFamilyName( "" ); |
1068 | setSuffix( "" ); | 1100 | setSuffix( "" ); |
1069 | 1101 | ||
1070 | if ( str.isEmpty() ) | 1102 | if ( str.isEmpty() ) |
1071 | return; | 1103 | return; |
1072 | 1104 | ||
1073 | int i = str.find(','); | 1105 | int i = str.find(','); |
1074 | if( i < 0 ) { | 1106 | if( i < 0 ) { |
1075 | QStringList parts = QStringList::split( " ", str ); | 1107 | QStringList parts = QStringList::split( " ", str ); |
1076 | int leftOffset = 0; | 1108 | int leftOffset = 0; |
1077 | int rightOffset = parts.count() - 1; | 1109 | int rightOffset = parts.count() - 1; |
1078 | 1110 | ||
1079 | QString suffix; | 1111 | QString suffix; |
1080 | while ( rightOffset >= 0 ) { | 1112 | while ( rightOffset >= 0 ) { |
1081 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1113 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1082 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1114 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1083 | rightOffset--; | 1115 | rightOffset--; |
1084 | } else | 1116 | } else |
1085 | break; | 1117 | break; |
1086 | } | 1118 | } |
1087 | setSuffix( suffix ); | 1119 | setSuffix( suffix ); |
1088 | 1120 | ||
1089 | if ( rightOffset < 0 ) | 1121 | if ( rightOffset < 0 ) |
1090 | return; | 1122 | return; |
1091 | 1123 | ||
1092 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1124 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1093 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1125 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1094 | rightOffset--; | 1126 | rightOffset--; |
1095 | } else | 1127 | } else |
1096 | setFamilyName( parts[ rightOffset ] ); | 1128 | setFamilyName( parts[ rightOffset ] ); |
1097 | 1129 | ||
1098 | QString prefix; | 1130 | QString prefix; |
1099 | while ( leftOffset < rightOffset ) { | 1131 | while ( leftOffset < rightOffset ) { |
1100 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1132 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1101 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1133 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1102 | leftOffset++; | 1134 | leftOffset++; |
1103 | } else | 1135 | } else |
1104 | break; | 1136 | break; |
1105 | } | 1137 | } |
1106 | setPrefix( prefix ); | 1138 | setPrefix( prefix ); |
1107 | 1139 | ||
1108 | if ( leftOffset < rightOffset ) { | 1140 | if ( leftOffset < rightOffset ) { |
1109 | setGivenName( parts[ leftOffset ] ); | 1141 | setGivenName( parts[ leftOffset ] ); |
1110 | leftOffset++; | 1142 | leftOffset++; |
1111 | } | 1143 | } |
1112 | 1144 | ||
1113 | QString additionalName; | 1145 | QString additionalName; |
1114 | while ( leftOffset < rightOffset ) { | 1146 | while ( leftOffset < rightOffset ) { |
1115 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1147 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1116 | leftOffset++; | 1148 | leftOffset++; |
1117 | } | 1149 | } |
1118 | setAdditionalName( additionalName ); | 1150 | setAdditionalName( additionalName ); |
1119 | } else { | 1151 | } else { |
1120 | QString part1 = str.left( i ); | 1152 | QString part1 = str.left( i ); |
1121 | QString part2 = str.mid( i + 1 ); | 1153 | QString part2 = str.mid( i + 1 ); |
1122 | 1154 | ||
1123 | QStringList parts = QStringList::split( " ", part1 ); | 1155 | QStringList parts = QStringList::split( " ", part1 ); |
1124 | int leftOffset = 0; | 1156 | int leftOffset = 0; |
1125 | int rightOffset = parts.count() - 1; | 1157 | int rightOffset = parts.count() - 1; |
1126 | 1158 | ||
1127 | QString suffix; | 1159 | QString suffix; |
1128 | while ( rightOffset >= 0 ) { | 1160 | while ( rightOffset >= 0 ) { |
1129 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1161 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1130 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1162 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1131 | rightOffset--; | 1163 | rightOffset--; |
1132 | } else | 1164 | } else |
1133 | break; | 1165 | break; |
1134 | } | 1166 | } |
1135 | setSuffix( suffix ); | 1167 | setSuffix( suffix ); |
1136 | 1168 | ||
1137 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1169 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1138 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1170 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1139 | rightOffset--; | 1171 | rightOffset--; |
1140 | } else | 1172 | } else |
1141 | setFamilyName( parts[ rightOffset ] ); | 1173 | setFamilyName( parts[ rightOffset ] ); |
1142 | 1174 | ||
1143 | QString prefix; | 1175 | QString prefix; |
1144 | while ( leftOffset < rightOffset ) { | 1176 | while ( leftOffset < rightOffset ) { |
1145 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1177 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1146 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1178 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1147 | leftOffset++; | 1179 | leftOffset++; |
1148 | } else | 1180 | } else |
1149 | break; | 1181 | break; |
1150 | } | 1182 | } |
1151 | 1183 | ||
1152 | parts = QStringList::split( " ", part2 ); | 1184 | parts = QStringList::split( " ", part2 ); |
1153 | 1185 | ||
1154 | leftOffset = 0; | 1186 | leftOffset = 0; |
1155 | rightOffset = parts.count(); | 1187 | rightOffset = parts.count(); |
1156 | 1188 | ||
1157 | while ( leftOffset < rightOffset ) { | 1189 | while ( leftOffset < rightOffset ) { |
1158 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1190 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1159 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1191 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1160 | leftOffset++; | 1192 | leftOffset++; |
1161 | } else | 1193 | } else |
1162 | break; | 1194 | break; |
1163 | } | 1195 | } |
1164 | setPrefix( prefix ); | 1196 | setPrefix( prefix ); |
1165 | 1197 | ||
1166 | if ( leftOffset < rightOffset ) { | 1198 | if ( leftOffset < rightOffset ) { |
1167 | setGivenName( parts[ leftOffset ] ); | 1199 | setGivenName( parts[ leftOffset ] ); |
1168 | leftOffset++; | 1200 | leftOffset++; |
1169 | } | 1201 | } |
1170 | 1202 | ||
1171 | QString additionalName; | 1203 | QString additionalName; |
1172 | while ( leftOffset < rightOffset ) { | 1204 | while ( leftOffset < rightOffset ) { |
1173 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1205 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1174 | leftOffset++; | 1206 | leftOffset++; |
1175 | } | 1207 | } |
1176 | setAdditionalName( additionalName ); | 1208 | setAdditionalName( additionalName ); |
1177 | } | 1209 | } |
1178 | } | 1210 | } |
1179 | 1211 | ||
1180 | QString Addressee::realName() const | 1212 | QString Addressee::realName() const |
1181 | { | 1213 | { |
1182 | if ( !formattedName().isEmpty() ) | 1214 | if ( !formattedName().isEmpty() ) |
1183 | return formattedName(); | 1215 | return formattedName(); |
1184 | 1216 | ||
1185 | QString n = assembledName(); | 1217 | QString n = assembledName(); |
1186 | 1218 | ||
1187 | if ( n.isEmpty() ) | 1219 | if ( n.isEmpty() ) |
1188 | n = name(); | 1220 | n = name(); |
1189 | 1221 | ||
1190 | return n; | 1222 | return n; |
1191 | } | 1223 | } |
1192 | 1224 | ||
1193 | QString Addressee::assembledName() const | 1225 | QString Addressee::assembledName() const |
1194 | { | 1226 | { |
1195 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + | 1227 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + |
1196 | familyName() + " " + suffix(); | 1228 | familyName() + " " + suffix(); |
1197 | 1229 | ||
1198 | return name.simplifyWhiteSpace(); | 1230 | return name.simplifyWhiteSpace(); |
1199 | } | 1231 | } |
1200 | 1232 | ||
1201 | QString Addressee::fullEmail( const QString &email ) const | 1233 | QString Addressee::fullEmail( const QString &email ) const |
1202 | { | 1234 | { |
1203 | QString e; | 1235 | QString e; |
1204 | if ( email.isNull() ) { | 1236 | if ( email.isNull() ) { |
1205 | e = preferredEmail(); | 1237 | e = preferredEmail(); |
1206 | } else { | 1238 | } else { |
1207 | e = email; | 1239 | e = email; |
1208 | } | 1240 | } |
1209 | if ( e.isEmpty() ) return QString::null; | 1241 | if ( e.isEmpty() ) return QString::null; |
1210 | 1242 | ||
1211 | QString text; | 1243 | QString text; |
1212 | if ( realName().isEmpty() ) | 1244 | if ( realName().isEmpty() ) |
1213 | text = e; | 1245 | text = e; |
1214 | else | 1246 | else |
1215 | text = assembledName() + " <" + e + ">"; | 1247 | text = assembledName() + " <" + e + ">"; |
1216 | 1248 | ||
1217 | return text; | 1249 | return text; |
1218 | } | 1250 | } |
1219 | 1251 | ||
1220 | void Addressee::insertEmail( const QString &email, bool preferred ) | 1252 | void Addressee::insertEmail( const QString &email, bool preferred ) |
1221 | { | 1253 | { |
1222 | detach(); | 1254 | detach(); |
1223 | 1255 | ||
1224 | QStringList::Iterator it = mData->emails.find( email ); | 1256 | QStringList::Iterator it = mData->emails.find( email ); |
1225 | 1257 | ||
1226 | if ( it != mData->emails.end() ) { | 1258 | if ( it != mData->emails.end() ) { |
1227 | if ( !preferred || it == mData->emails.begin() ) return; | 1259 | if ( !preferred || it == mData->emails.begin() ) return; |
1228 | mData->emails.remove( it ); | 1260 | mData->emails.remove( it ); |
1229 | mData->emails.prepend( email ); | 1261 | mData->emails.prepend( email ); |
1230 | } else { | 1262 | } else { |
1231 | if ( preferred ) { | 1263 | if ( preferred ) { |
1232 | mData->emails.prepend( email ); | 1264 | mData->emails.prepend( email ); |
1233 | } else { | 1265 | } else { |
1234 | mData->emails.append( email ); | 1266 | mData->emails.append( email ); |
1235 | } | 1267 | } |
1236 | } | 1268 | } |
1237 | } | 1269 | } |
1238 | 1270 | ||
1239 | void Addressee::removeEmail( const QString &email ) | 1271 | void Addressee::removeEmail( const QString &email ) |
1240 | { | 1272 | { |
1241 | detach(); | 1273 | detach(); |
1242 | 1274 | ||
1243 | QStringList::Iterator it = mData->emails.find( email ); | 1275 | QStringList::Iterator it = mData->emails.find( email ); |
1244 | if ( it == mData->emails.end() ) return; | 1276 | if ( it == mData->emails.end() ) return; |
1245 | 1277 | ||
1246 | mData->emails.remove( it ); | 1278 | mData->emails.remove( it ); |
1247 | } | 1279 | } |
1248 | 1280 | ||
1249 | QString Addressee::preferredEmail() const | 1281 | QString Addressee::preferredEmail() const |
1250 | { | 1282 | { |
1251 | if ( mData->emails.count() == 0 ) return QString::null; | 1283 | if ( mData->emails.count() == 0 ) return QString::null; |
1252 | else return mData->emails.first(); | 1284 | else return mData->emails.first(); |
1253 | } | 1285 | } |
1254 | 1286 | ||
1255 | QStringList Addressee::emails() const | 1287 | QStringList Addressee::emails() const |
1256 | { | 1288 | { |
1257 | return mData->emails; | 1289 | return mData->emails; |
1258 | } | 1290 | } |
1259 | void Addressee::setEmails( const QStringList& emails ) { | 1291 | void Addressee::setEmails( const QStringList& emails ) { |
1260 | detach(); | 1292 | detach(); |
1261 | mData->emails = emails; | 1293 | mData->emails = emails; |
1262 | } | 1294 | } |
1263 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) | 1295 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) |
1264 | { | 1296 | { |
1265 | detach(); | 1297 | detach(); |
1266 | mData->empty = false; | 1298 | mData->empty = false; |
1267 | 1299 | ||
1268 | PhoneNumber::List::Iterator it; | 1300 | PhoneNumber::List::Iterator it; |
1269 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1301 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1270 | if ( (*it).id() == phoneNumber.id() ) { | 1302 | if ( (*it).id() == phoneNumber.id() ) { |
1271 | *it = phoneNumber; | 1303 | *it = phoneNumber; |
1272 | return; | 1304 | return; |
1273 | } | 1305 | } |
1274 | } | 1306 | } |
1275 | mData->phoneNumbers.append( phoneNumber ); | 1307 | mData->phoneNumbers.append( phoneNumber ); |
1276 | } | 1308 | } |
1277 | 1309 | ||
1278 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) | 1310 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) |
1279 | { | 1311 | { |
1280 | detach(); | 1312 | detach(); |
1281 | 1313 | ||
1282 | PhoneNumber::List::Iterator it; | 1314 | PhoneNumber::List::Iterator it; |
1283 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1315 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1284 | if ( (*it).id() == phoneNumber.id() ) { | 1316 | if ( (*it).id() == phoneNumber.id() ) { |
1285 | mData->phoneNumbers.remove( it ); | 1317 | mData->phoneNumbers.remove( it ); |
1286 | return; | 1318 | return; |
1287 | } | 1319 | } |
1288 | } | 1320 | } |
1289 | } | 1321 | } |
1290 | 1322 | ||
1291 | PhoneNumber Addressee::phoneNumber( int type ) const | 1323 | PhoneNumber Addressee::phoneNumber( int type ) const |
1292 | { | 1324 | { |
1293 | PhoneNumber phoneNumber( "", type ); | 1325 | PhoneNumber phoneNumber( "", type ); |
1294 | PhoneNumber::List::ConstIterator it; | 1326 | PhoneNumber::List::ConstIterator it; |
1295 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1327 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1296 | if ( matchBinaryPatternP( (*it).type(), type ) ) { | 1328 | if ( matchBinaryPatternP( (*it).type(), type ) ) { |
1297 | if ( (*it).type() & PhoneNumber::Pref ) | 1329 | if ( (*it).type() & PhoneNumber::Pref ) |
1298 | return (*it); | 1330 | return (*it); |
1299 | else if ( phoneNumber.number().isEmpty() ) | 1331 | else if ( phoneNumber.number().isEmpty() ) |
1300 | phoneNumber = (*it); | 1332 | phoneNumber = (*it); |
1301 | } | 1333 | } |
1302 | } | 1334 | } |
1303 | 1335 | ||
1304 | return phoneNumber; | 1336 | return phoneNumber; |
1305 | } | 1337 | } |
1306 | 1338 | ||
1307 | PhoneNumber::List Addressee::phoneNumbers() const | 1339 | PhoneNumber::List Addressee::phoneNumbers() const |
1308 | { | 1340 | { |
1309 | return mData->phoneNumbers; | 1341 | return mData->phoneNumbers; |
1310 | } | 1342 | } |
1311 | 1343 | ||
1312 | PhoneNumber::List Addressee::phoneNumbers( int type ) const | 1344 | PhoneNumber::List Addressee::phoneNumbers( int type ) const |
1313 | { | 1345 | { |
1314 | PhoneNumber::List list; | 1346 | PhoneNumber::List list; |
1315 | 1347 | ||
1316 | PhoneNumber::List::ConstIterator it; | 1348 | PhoneNumber::List::ConstIterator it; |
1317 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1349 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1318 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1350 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1319 | list.append( *it ); | 1351 | list.append( *it ); |
1320 | } | 1352 | } |
1321 | } | 1353 | } |
1322 | return list; | 1354 | return list; |
1323 | } | 1355 | } |
1324 | 1356 | ||
1325 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const | 1357 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const |
1326 | { | 1358 | { |
1327 | PhoneNumber::List::ConstIterator it; | 1359 | PhoneNumber::List::ConstIterator it; |
1328 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1360 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1329 | if ( (*it).id() == id ) { | 1361 | if ( (*it).id() == id ) { |
1330 | return *it; | 1362 | return *it; |
1331 | } | 1363 | } |
1332 | } | 1364 | } |
1333 | return PhoneNumber(); | 1365 | return PhoneNumber(); |
1334 | } | 1366 | } |
1335 | 1367 | ||
1336 | void Addressee::insertKey( const Key &key ) | 1368 | void Addressee::insertKey( const Key &key ) |
1337 | { | 1369 | { |
1338 | detach(); | 1370 | detach(); |
1339 | mData->empty = false; | 1371 | mData->empty = false; |
1340 | 1372 | ||
1341 | Key::List::Iterator it; | 1373 | Key::List::Iterator it; |
1342 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1374 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1343 | if ( (*it).id() == key.id() ) { | 1375 | if ( (*it).id() == key.id() ) { |
1344 | *it = key; | 1376 | *it = key; |
1345 | return; | 1377 | return; |
1346 | } | 1378 | } |
1347 | } | 1379 | } |
1348 | mData->keys.append( key ); | 1380 | mData->keys.append( key ); |
1349 | } | 1381 | } |
1350 | 1382 | ||
1351 | void Addressee::removeKey( const Key &key ) | 1383 | void Addressee::removeKey( const Key &key ) |
1352 | { | 1384 | { |
1353 | detach(); | 1385 | detach(); |
1354 | 1386 | ||
1355 | Key::List::Iterator it; | 1387 | Key::List::Iterator it; |
1356 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1388 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1357 | if ( (*it).id() == key.id() ) { | 1389 | if ( (*it).id() == key.id() ) { |
1358 | mData->keys.remove( key ); | 1390 | mData->keys.remove( key ); |
1359 | return; | 1391 | return; |
1360 | } | 1392 | } |
1361 | } | 1393 | } |
1362 | } | 1394 | } |
1363 | 1395 | ||
1364 | Key Addressee::key( int type, QString customTypeString ) const | 1396 | Key Addressee::key( int type, QString customTypeString ) const |
1365 | { | 1397 | { |
1366 | Key::List::ConstIterator it; | 1398 | Key::List::ConstIterator it; |
1367 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1399 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1368 | if ( (*it).type() == type ) { | 1400 | if ( (*it).type() == type ) { |
1369 | if ( type == Key::Custom ) { | 1401 | if ( type == Key::Custom ) { |
1370 | if ( customTypeString.isEmpty() ) { | 1402 | if ( customTypeString.isEmpty() ) { |
1371 | return *it; | 1403 | return *it; |
1372 | } else { | 1404 | } else { |
1373 | if ( (*it).customTypeString() == customTypeString ) | 1405 | if ( (*it).customTypeString() == customTypeString ) |
1374 | return (*it); | 1406 | return (*it); |
1375 | } | 1407 | } |
1376 | } else { | 1408 | } else { |
1377 | return *it; | 1409 | return *it; |
1378 | } | 1410 | } |
1379 | } | 1411 | } |
1380 | } | 1412 | } |
1381 | return Key( QString(), type ); | 1413 | return Key( QString(), type ); |
1382 | } | 1414 | } |
1383 | void Addressee::setKeys( const Key::List& list ) { | 1415 | void Addressee::setKeys( const Key::List& list ) { |
1384 | detach(); | 1416 | detach(); |
1385 | mData->keys = list; | 1417 | mData->keys = list; |
1386 | } | 1418 | } |
1387 | 1419 | ||
1388 | Key::List Addressee::keys() const | 1420 | Key::List Addressee::keys() const |
1389 | { | 1421 | { |
1390 | return mData->keys; | 1422 | return mData->keys; |
1391 | } | 1423 | } |
1392 | 1424 | ||
1393 | Key::List Addressee::keys( int type, QString customTypeString ) const | 1425 | Key::List Addressee::keys( int type, QString customTypeString ) const |
1394 | { | 1426 | { |
1395 | Key::List list; | 1427 | Key::List list; |
1396 | 1428 | ||
1397 | Key::List::ConstIterator it; | 1429 | Key::List::ConstIterator it; |
1398 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1430 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1399 | if ( (*it).type() == type ) { | 1431 | if ( (*it).type() == type ) { |
1400 | if ( type == Key::Custom ) { | 1432 | if ( type == Key::Custom ) { |
1401 | if ( customTypeString.isEmpty() ) { | 1433 | if ( customTypeString.isEmpty() ) { |
1402 | list.append(*it); | 1434 | list.append(*it); |
1403 | } else { | 1435 | } else { |
1404 | if ( (*it).customTypeString() == customTypeString ) | 1436 | if ( (*it).customTypeString() == customTypeString ) |
1405 | list.append(*it); | 1437 | list.append(*it); |
1406 | } | 1438 | } |
1407 | } else { | 1439 | } else { |
1408 | list.append(*it); | 1440 | list.append(*it); |
1409 | } | 1441 | } |
1410 | } | 1442 | } |
1411 | } | 1443 | } |
1412 | return list; | 1444 | return list; |
1413 | } | 1445 | } |
1414 | 1446 | ||
1415 | Key Addressee::findKey( const QString &id ) const | 1447 | Key Addressee::findKey( const QString &id ) const |
1416 | { | 1448 | { |
1417 | Key::List::ConstIterator it; | 1449 | Key::List::ConstIterator it; |
1418 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1450 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1419 | if ( (*it).id() == id ) { | 1451 | if ( (*it).id() == id ) { |
1420 | return *it; | 1452 | return *it; |
1421 | } | 1453 | } |
1422 | } | 1454 | } |
1423 | return Key(); | 1455 | return Key(); |
1424 | } | 1456 | } |
1425 | 1457 | ||
1426 | QString Addressee::asString() const | 1458 | QString Addressee::asString() const |
1427 | { | 1459 | { |
1428 | return "Smith, agent Smith..."; | 1460 | return "Smith, agent Smith..."; |
1429 | } | 1461 | } |
1430 | 1462 | ||
1431 | void Addressee::dump() const | 1463 | void Addressee::dump() const |
1432 | { | 1464 | { |
1433 | return; | 1465 | return; |
1434 | kdDebug(5700) << "Addressee {" << endl; | 1466 | kdDebug(5700) << "Addressee {" << endl; |
1435 | 1467 | ||
1436 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; | 1468 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; |
1437 | 1469 | ||
1438 | kdDebug(5700) << " Name: '" << name() << "'" << endl; | 1470 | kdDebug(5700) << " Name: '" << name() << "'" << endl; |
1439 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; | 1471 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; |
1440 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; | 1472 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; |
1441 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; | 1473 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; |
1442 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; | 1474 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; |
1443 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; | 1475 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; |
1444 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; | 1476 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; |
1445 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; | 1477 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; |
1446 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; | 1478 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; |
1447 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; | 1479 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; |
1448 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; | 1480 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; |
1449 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; | 1481 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; |
1450 | kdDebug(5700) << " Title: '" << title() << "'" << endl; | 1482 | kdDebug(5700) << " Title: '" << title() << "'" << endl; |
1451 | kdDebug(5700) << " Role: '" << role() << "'" << endl; | 1483 | kdDebug(5700) << " Role: '" << role() << "'" << endl; |
1452 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; | 1484 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; |
1453 | kdDebug(5700) << " Note: '" << note() << "'" << endl; | 1485 | kdDebug(5700) << " Note: '" << note() << "'" << endl; |
1454 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; | 1486 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; |
1455 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; | 1487 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; |
1456 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; | 1488 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; |
1457 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; | 1489 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; |
1458 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; | 1490 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; |
1459 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; | 1491 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; |
1460 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; | 1492 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; |
1461 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; | 1493 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; |
1462 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; | 1494 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; |
1463 | 1495 | ||
1464 | kdDebug(5700) << " Emails {" << endl; | 1496 | kdDebug(5700) << " Emails {" << endl; |
1465 | QStringList e = emails(); | 1497 | QStringList e = emails(); |
1466 | QStringList::ConstIterator it; | 1498 | QStringList::ConstIterator it; |
1467 | for( it = e.begin(); it != e.end(); ++it ) { | 1499 | for( it = e.begin(); it != e.end(); ++it ) { |
1468 | kdDebug(5700) << " " << (*it) << endl; | 1500 | kdDebug(5700) << " " << (*it) << endl; |
1469 | } | 1501 | } |
1470 | kdDebug(5700) << " }" << endl; | 1502 | kdDebug(5700) << " }" << endl; |
1471 | 1503 | ||
1472 | kdDebug(5700) << " PhoneNumbers {" << endl; | 1504 | kdDebug(5700) << " PhoneNumbers {" << endl; |
1473 | PhoneNumber::List p = phoneNumbers(); | 1505 | PhoneNumber::List p = phoneNumbers(); |
1474 | PhoneNumber::List::ConstIterator it2; | 1506 | PhoneNumber::List::ConstIterator it2; |
1475 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { | 1507 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { |
1476 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; | 1508 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; |
1477 | } | 1509 | } |
1478 | kdDebug(5700) << " }" << endl; | 1510 | kdDebug(5700) << " }" << endl; |
1479 | 1511 | ||
1480 | Address::List a = addresses(); | 1512 | Address::List a = addresses(); |
1481 | Address::List::ConstIterator it3; | 1513 | Address::List::ConstIterator it3; |
1482 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { | 1514 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { |
1483 | (*it3).dump(); | 1515 | (*it3).dump(); |
1484 | } | 1516 | } |
1485 | 1517 | ||
1486 | kdDebug(5700) << " Keys {" << endl; | 1518 | kdDebug(5700) << " Keys {" << endl; |
1487 | Key::List k = keys(); | 1519 | Key::List k = keys(); |
1488 | Key::List::ConstIterator it4; | 1520 | Key::List::ConstIterator it4; |
1489 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { | 1521 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { |
1490 | kdDebug(5700) << " Type: " << int((*it4).type()) << | 1522 | kdDebug(5700) << " Type: " << int((*it4).type()) << |
1491 | " Key: " << (*it4).textData() << | 1523 | " Key: " << (*it4).textData() << |
1492 | " CustomString: " << (*it4).customTypeString() << endl; | 1524 | " CustomString: " << (*it4).customTypeString() << endl; |
1493 | } | 1525 | } |
1494 | kdDebug(5700) << " }" << endl; | 1526 | kdDebug(5700) << " }" << endl; |
1495 | 1527 | ||
1496 | kdDebug(5700) << "}" << endl; | 1528 | kdDebug(5700) << "}" << endl; |
1497 | } | 1529 | } |
1498 | 1530 | ||
1499 | 1531 | ||
1500 | void Addressee::insertAddress( const Address &address ) | 1532 | void Addressee::insertAddress( const Address &address ) |
1501 | { | 1533 | { |
1502 | detach(); | 1534 | detach(); |
1503 | mData->empty = false; | 1535 | mData->empty = false; |
1504 | 1536 | ||
1505 | Address::List::Iterator it; | 1537 | Address::List::Iterator it; |
1506 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1538 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1507 | if ( (*it).id() == address.id() ) { | 1539 | if ( (*it).id() == address.id() ) { |
1508 | *it = address; | 1540 | *it = address; |
1509 | return; | 1541 | return; |
1510 | } | 1542 | } |
1511 | } | 1543 | } |
1512 | mData->addresses.append( address ); | 1544 | mData->addresses.append( address ); |
1513 | } | 1545 | } |
1514 | 1546 | ||
1515 | void Addressee::removeAddress( const Address &address ) | 1547 | void Addressee::removeAddress( const Address &address ) |
1516 | { | 1548 | { |
1517 | detach(); | 1549 | detach(); |
1518 | 1550 | ||
1519 | Address::List::Iterator it; | 1551 | Address::List::Iterator it; |
1520 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1552 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1521 | if ( (*it).id() == address.id() ) { | 1553 | if ( (*it).id() == address.id() ) { |
1522 | mData->addresses.remove( it ); | 1554 | mData->addresses.remove( it ); |
1523 | return; | 1555 | return; |
1524 | } | 1556 | } |
1525 | } | 1557 | } |
1526 | } | 1558 | } |
1527 | 1559 | ||
1528 | Address Addressee::address( int type ) const | 1560 | Address Addressee::address( int type ) const |
1529 | { | 1561 | { |
1530 | Address address( type ); | 1562 | Address address( type ); |
1531 | Address::List::ConstIterator it; | 1563 | Address::List::ConstIterator it; |
1532 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1564 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1533 | if ( matchBinaryPatternA( (*it).type(), type ) ) { | 1565 | if ( matchBinaryPatternA( (*it).type(), type ) ) { |
1534 | if ( (*it).type() & Address::Pref ) | 1566 | if ( (*it).type() & Address::Pref ) |
1535 | return (*it); | 1567 | return (*it); |
1536 | else if ( address.isEmpty() ) | 1568 | else if ( address.isEmpty() ) |
1537 | address = (*it); | 1569 | address = (*it); |
1538 | } | 1570 | } |
1539 | } | 1571 | } |
1540 | 1572 | ||
1541 | return address; | 1573 | return address; |
1542 | } | 1574 | } |
1543 | 1575 | ||
1544 | Address::List Addressee::addresses() const | 1576 | Address::List Addressee::addresses() const |
1545 | { | 1577 | { |
1546 | return mData->addresses; | 1578 | return mData->addresses; |
1547 | } | 1579 | } |
1548 | 1580 | ||
1549 | Address::List Addressee::addresses( int type ) const | 1581 | Address::List Addressee::addresses( int type ) const |
1550 | { | 1582 | { |
1551 | Address::List list; | 1583 | Address::List list; |
1552 | 1584 | ||
1553 | Address::List::ConstIterator it; | 1585 | Address::List::ConstIterator it; |
1554 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1586 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1555 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1587 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1556 | list.append( *it ); | 1588 | list.append( *it ); |
1557 | } | 1589 | } |
1558 | } | 1590 | } |
1559 | 1591 | ||
1560 | return list; | 1592 | return list; |
1561 | } | 1593 | } |
1562 | 1594 | ||
1563 | Address Addressee::findAddress( const QString &id ) const | 1595 | Address Addressee::findAddress( const QString &id ) const |
1564 | { | 1596 | { |
1565 | Address::List::ConstIterator it; | 1597 | Address::List::ConstIterator it; |
1566 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1598 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1567 | if ( (*it).id() == id ) { | 1599 | if ( (*it).id() == id ) { |
1568 | return *it; | 1600 | return *it; |
1569 | } | 1601 | } |
1570 | } | 1602 | } |
1571 | return Address(); | 1603 | return Address(); |
1572 | } | 1604 | } |
1573 | 1605 | ||
1574 | void Addressee::insertCategory( const QString &c ) | 1606 | void Addressee::insertCategory( const QString &c ) |
1575 | { | 1607 | { |
1576 | detach(); | 1608 | detach(); |
1577 | mData->empty = false; | 1609 | mData->empty = false; |
1578 | 1610 | ||
1579 | if ( mData->categories.contains( c ) ) return; | 1611 | if ( mData->categories.contains( c ) ) return; |
1580 | 1612 | ||
1581 | mData->categories.append( c ); | 1613 | mData->categories.append( c ); |
1582 | } | 1614 | } |
1583 | 1615 | ||
1584 | void Addressee::removeCategory( const QString &c ) | 1616 | void Addressee::removeCategory( const QString &c ) |
1585 | { | 1617 | { |
1586 | detach(); | 1618 | detach(); |
1587 | 1619 | ||
1588 | QStringList::Iterator it = mData->categories.find( c ); | 1620 | QStringList::Iterator it = mData->categories.find( c ); |
1589 | if ( it == mData->categories.end() ) return; | 1621 | if ( it == mData->categories.end() ) return; |
1590 | 1622 | ||
1591 | mData->categories.remove( it ); | 1623 | mData->categories.remove( it ); |
1592 | } | 1624 | } |
1593 | 1625 | ||
1594 | bool Addressee::hasCategory( const QString &c ) const | 1626 | bool Addressee::hasCategory( const QString &c ) const |
1595 | { | 1627 | { |
1596 | return ( mData->categories.contains( c ) ); | 1628 | return ( mData->categories.contains( c ) ); |
1597 | } | 1629 | } |
1598 | 1630 | ||
1599 | void Addressee::setCategories( const QStringList &c ) | 1631 | void Addressee::setCategories( const QStringList &c ) |
1600 | { | 1632 | { |
1601 | detach(); | 1633 | detach(); |
1602 | mData->empty = false; | 1634 | mData->empty = false; |
1603 | 1635 | ||
1604 | mData->categories = c; | 1636 | mData->categories = c; |
1605 | } | 1637 | } |
1606 | 1638 | ||
1607 | QStringList Addressee::categories() const | 1639 | QStringList Addressee::categories() const |
1608 | { | 1640 | { |
1609 | return mData->categories; | 1641 | return mData->categories; |
1610 | } | 1642 | } |
1611 | 1643 | ||
1612 | void Addressee::insertCustom( const QString &app, const QString &name, | 1644 | void Addressee::insertCustom( const QString &app, const QString &name, |
1613 | const QString &value ) | 1645 | const QString &value ) |
1614 | { | 1646 | { |
1615 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; | 1647 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; |
1616 | 1648 | ||
1617 | detach(); | 1649 | detach(); |
1618 | mData->empty = false; | 1650 | mData->empty = false; |
1619 | 1651 | ||
1620 | QString qualifiedName = app + "-" + name + ":"; | 1652 | QString qualifiedName = app + "-" + name + ":"; |
1621 | 1653 | ||
1622 | QStringList::Iterator it; | 1654 | QStringList::Iterator it; |
1623 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1655 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1624 | if ( (*it).startsWith( qualifiedName ) ) { | 1656 | if ( (*it).startsWith( qualifiedName ) ) { |
1625 | (*it) = qualifiedName + value; | 1657 | (*it) = qualifiedName + value; |
1626 | return; | 1658 | return; |
1627 | } | 1659 | } |
1628 | } | 1660 | } |
1629 | mData->custom.append( qualifiedName + value ); | 1661 | mData->custom.append( qualifiedName + value ); |
1630 | } | 1662 | } |
1631 | 1663 | ||
1632 | void Addressee::removeCustom( const QString &app, const QString &name) | 1664 | void Addressee::removeCustom( const QString &app, const QString &name) |
1633 | { | 1665 | { |
1634 | detach(); | 1666 | detach(); |
1635 | 1667 | ||
1636 | QString qualifiedName = app + "-" + name + ":"; | 1668 | QString qualifiedName = app + "-" + name + ":"; |
1637 | 1669 | ||
1638 | QStringList::Iterator it; | 1670 | QStringList::Iterator it; |
1639 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1671 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1640 | if ( (*it).startsWith( qualifiedName ) ) { | 1672 | if ( (*it).startsWith( qualifiedName ) ) { |
1641 | mData->custom.remove( it ); | 1673 | mData->custom.remove( it ); |
1642 | return; | 1674 | return; |
1643 | } | 1675 | } |
1644 | } | 1676 | } |
1645 | } | 1677 | } |
1646 | 1678 | ||
1647 | QString Addressee::custom( const QString &app, const QString &name ) const | 1679 | QString Addressee::custom( const QString &app, const QString &name ) const |
1648 | { | 1680 | { |
1649 | QString qualifiedName = app + "-" + name + ":"; | 1681 | QString qualifiedName = app + "-" + name + ":"; |
1650 | QString value; | 1682 | QString value; |
1651 | 1683 | ||
1652 | QStringList::ConstIterator it; | 1684 | QStringList::ConstIterator it; |
1653 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1685 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1654 | if ( (*it).startsWith( qualifiedName ) ) { | 1686 | if ( (*it).startsWith( qualifiedName ) ) { |
1655 | value = (*it).mid( (*it).find( ":" ) + 1 ); | 1687 | value = (*it).mid( (*it).find( ":" ) + 1 ); |
1656 | break; | 1688 | break; |
1657 | } | 1689 | } |
1658 | } | 1690 | } |
1659 | 1691 | ||
1660 | return value; | 1692 | return value; |
1661 | } | 1693 | } |
1662 | 1694 | ||
1663 | void Addressee::setCustoms( const QStringList &l ) | 1695 | void Addressee::setCustoms( const QStringList &l ) |
1664 | { | 1696 | { |
1665 | detach(); | 1697 | detach(); |
1666 | mData->empty = false; | 1698 | mData->empty = false; |
1667 | 1699 | ||
1668 | mData->custom = l; | 1700 | mData->custom = l; |
1669 | } | 1701 | } |
1670 | 1702 | ||
1671 | QStringList Addressee::customs() const | 1703 | QStringList Addressee::customs() const |
1672 | { | 1704 | { |
1673 | return mData->custom; | 1705 | return mData->custom; |
1674 | } | 1706 | } |
1675 | 1707 | ||
1676 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, | 1708 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, |
1677 | QString &email) | 1709 | QString &email) |
1678 | { | 1710 | { |
1679 | int startPos, endPos, len; | 1711 | int startPos, endPos, len; |
1680 | QString partA, partB, result; | 1712 | QString partA, partB, result; |
1681 | char endCh = '>'; | 1713 | char endCh = '>'; |
1682 | 1714 | ||
1683 | startPos = rawEmail.find('<'); | 1715 | startPos = rawEmail.find('<'); |
1684 | if (startPos < 0) | 1716 | if (startPos < 0) |
1685 | { | 1717 | { |
1686 | startPos = rawEmail.find('('); | 1718 | startPos = rawEmail.find('('); |
1687 | endCh = ')'; | 1719 | endCh = ')'; |
1688 | } | 1720 | } |
1689 | if (startPos < 0) | 1721 | if (startPos < 0) |
1690 | { | 1722 | { |
1691 | // We couldn't find any separators, so we assume the whole string | 1723 | // We couldn't find any separators, so we assume the whole string |
1692 | // is the email address | 1724 | // is the email address |
1693 | email = rawEmail; | 1725 | email = rawEmail; |
1694 | fullName = ""; | 1726 | fullName = ""; |
1695 | } | 1727 | } |
1696 | else | 1728 | else |
1697 | { | 1729 | { |
1698 | // We have a start position, try to find an end | 1730 | // We have a start position, try to find an end |
1699 | endPos = rawEmail.find(endCh, startPos+1); | 1731 | endPos = rawEmail.find(endCh, startPos+1); |
1700 | 1732 | ||
1701 | if (endPos < 0) | 1733 | if (endPos < 0) |
1702 | { | 1734 | { |
1703 | // We couldn't find the end of the email address. We can only | 1735 | // We couldn't find the end of the email address. We can only |
1704 | // assume the entire string is the email address. | 1736 | // assume the entire string is the email address. |
1705 | email = rawEmail; | 1737 | email = rawEmail; |
1706 | fullName = ""; | 1738 | fullName = ""; |
1707 | } | 1739 | } |
1708 | else | 1740 | else |
1709 | { | 1741 | { |
1710 | // We have a start and end to the email address | 1742 | // We have a start and end to the email address |
1711 | 1743 | ||
1712 | // Grab the name part | 1744 | // Grab the name part |
1713 | fullName = rawEmail.left(startPos).stripWhiteSpace(); | 1745 | fullName = rawEmail.left(startPos).stripWhiteSpace(); |
1714 | 1746 | ||
1715 | // grab the email part | 1747 | // grab the email part |
1716 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); | 1748 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); |
1717 | 1749 | ||
1718 | // Check that we do not have any extra characters on the end of the | 1750 | // Check that we do not have any extra characters on the end of the |
1719 | // strings | 1751 | // strings |
1720 | len = fullName.length(); | 1752 | len = fullName.length(); |
1721 | if (fullName[0]=='"' && fullName[len-1]=='"') | 1753 | if (fullName[0]=='"' && fullName[len-1]=='"') |
1722 | fullName = fullName.mid(1, len-2); | 1754 | fullName = fullName.mid(1, len-2); |
1723 | else if (fullName[0]=='<' && fullName[len-1]=='>') | 1755 | else if (fullName[0]=='<' && fullName[len-1]=='>') |
1724 | fullName = fullName.mid(1, len-2); | 1756 | fullName = fullName.mid(1, len-2); |
1725 | else if (fullName[0]=='(' && fullName[len-1]==')') | 1757 | else if (fullName[0]=='(' && fullName[len-1]==')') |
1726 | fullName = fullName.mid(1, len-2); | 1758 | fullName = fullName.mid(1, len-2); |
1727 | } | 1759 | } |
1728 | } | 1760 | } |
1729 | } | 1761 | } |
1730 | 1762 | ||
1731 | void Addressee::setResource( Resource *resource ) | 1763 | void Addressee::setResource( Resource *resource ) |
1732 | { | 1764 | { |
1733 | detach(); | 1765 | detach(); |
1734 | mData->resource = resource; | 1766 | mData->resource = resource; |
1735 | } | 1767 | } |
1736 | 1768 | ||
1737 | Resource *Addressee::resource() const | 1769 | Resource *Addressee::resource() const |
1738 | { | 1770 | { |
1739 | return mData->resource; | 1771 | return mData->resource; |
1740 | } | 1772 | } |
1741 | 1773 | ||
1742 | //US | 1774 | //US |
1743 | QString Addressee::resourceLabel() | 1775 | QString Addressee::resourceLabel() |
1744 | { | 1776 | { |
1745 | return i18n("Resource"); | 1777 | return i18n("Resource"); |
1746 | } | 1778 | } |
1747 | 1779 | ||
1748 | void Addressee::setChanged( bool value ) | 1780 | void Addressee::setChanged( bool value ) |
1749 | { | 1781 | { |
1750 | detach(); | 1782 | detach(); |
1751 | mData->changed = value; | 1783 | mData->changed = value; |
1752 | } | 1784 | } |
1753 | 1785 | ||
1754 | bool Addressee::changed() const | 1786 | bool Addressee::changed() const |
1755 | { | 1787 | { |
1756 | return mData->changed; | 1788 | return mData->changed; |
1757 | } | 1789 | } |
1758 | 1790 | ||
1759 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) | 1791 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) |
1760 | { | 1792 | { |
1761 | if (!a.mData) return s; | 1793 | if (!a.mData) return s; |
1762 | 1794 | ||
1763 | s << a.uid(); | 1795 | s << a.uid(); |
1764 | 1796 | ||
1765 | s << a.mData->name; | 1797 | s << a.mData->name; |
1766 | s << a.mData->formattedName; | 1798 | s << a.mData->formattedName; |
1767 | s << a.mData->familyName; | 1799 | s << a.mData->familyName; |
1768 | s << a.mData->givenName; | 1800 | s << a.mData->givenName; |
1769 | s << a.mData->additionalName; | 1801 | s << a.mData->additionalName; |
1770 | s << a.mData->prefix; | 1802 | s << a.mData->prefix; |
1771 | s << a.mData->suffix; | 1803 | s << a.mData->suffix; |
1772 | s << a.mData->nickName; | 1804 | s << a.mData->nickName; |
1773 | s << a.mData->birthday; | 1805 | s << a.mData->birthday; |
1774 | s << a.mData->mailer; | 1806 | s << a.mData->mailer; |
1775 | s << a.mData->timeZone; | 1807 | s << a.mData->timeZone; |
1776 | s << a.mData->geo; | 1808 | s << a.mData->geo; |
1777 | s << a.mData->title; | 1809 | s << a.mData->title; |
1778 | s << a.mData->role; | 1810 | s << a.mData->role; |
1779 | s << a.mData->organization; | 1811 | s << a.mData->organization; |
1780 | s << a.mData->note; | 1812 | s << a.mData->note; |
1781 | s << a.mData->productId; | 1813 | s << a.mData->productId; |
1782 | s << a.mData->revision; | 1814 | s << a.mData->revision; |
1783 | s << a.mData->sortString; | 1815 | s << a.mData->sortString; |
1784 | s << a.mData->url; | 1816 | s << a.mData->url; |
1785 | s << a.mData->secrecy; | 1817 | s << a.mData->secrecy; |
1786 | s << a.mData->logo; | 1818 | s << a.mData->logo; |
1787 | s << a.mData->photo; | 1819 | s << a.mData->photo; |
1788 | s << a.mData->sound; | 1820 | s << a.mData->sound; |
1789 | s << a.mData->agent; | 1821 | s << a.mData->agent; |
1790 | s << a.mData->phoneNumbers; | 1822 | s << a.mData->phoneNumbers; |
1791 | s << a.mData->addresses; | 1823 | s << a.mData->addresses; |
1792 | s << a.mData->emails; | 1824 | s << a.mData->emails; |
1793 | s << a.mData->categories; | 1825 | s << a.mData->categories; |
1794 | s << a.mData->custom; | 1826 | s << a.mData->custom; |
1795 | s << a.mData->keys; | 1827 | s << a.mData->keys; |
1796 | return s; | 1828 | return s; |
1797 | } | 1829 | } |
1798 | 1830 | ||
1799 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) | 1831 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) |
1800 | { | 1832 | { |
1801 | if (!a.mData) return s; | 1833 | if (!a.mData) return s; |
1802 | 1834 | ||
1803 | s >> a.mData->uid; | 1835 | s >> a.mData->uid; |
1804 | 1836 | ||
1805 | s >> a.mData->name; | 1837 | s >> a.mData->name; |
1806 | s >> a.mData->formattedName; | 1838 | s >> a.mData->formattedName; |
1807 | s >> a.mData->familyName; | 1839 | s >> a.mData->familyName; |
1808 | s >> a.mData->givenName; | 1840 | s >> a.mData->givenName; |
1809 | s >> a.mData->additionalName; | 1841 | s >> a.mData->additionalName; |
1810 | s >> a.mData->prefix; | 1842 | s >> a.mData->prefix; |
1811 | s >> a.mData->suffix; | 1843 | s >> a.mData->suffix; |
1812 | s >> a.mData->nickName; | 1844 | s >> a.mData->nickName; |
1813 | s >> a.mData->birthday; | 1845 | s >> a.mData->birthday; |
1814 | s >> a.mData->mailer; | 1846 | s >> a.mData->mailer; |
1815 | s >> a.mData->timeZone; | 1847 | s >> a.mData->timeZone; |
1816 | s >> a.mData->geo; | 1848 | s >> a.mData->geo; |
1817 | s >> a.mData->title; | 1849 | s >> a.mData->title; |
1818 | s >> a.mData->role; | 1850 | s >> a.mData->role; |
1819 | s >> a.mData->organization; | 1851 | s >> a.mData->organization; |
1820 | s >> a.mData->note; | 1852 | s >> a.mData->note; |
1821 | s >> a.mData->productId; | 1853 | s >> a.mData->productId; |
1822 | s >> a.mData->revision; | 1854 | s >> a.mData->revision; |
1823 | s >> a.mData->sortString; | 1855 | s >> a.mData->sortString; |
1824 | s >> a.mData->url; | 1856 | s >> a.mData->url; |
1825 | s >> a.mData->secrecy; | 1857 | s >> a.mData->secrecy; |
1826 | s >> a.mData->logo; | 1858 | s >> a.mData->logo; |
1827 | s >> a.mData->photo; | 1859 | s >> a.mData->photo; |
1828 | s >> a.mData->sound; | 1860 | s >> a.mData->sound; |
1829 | s >> a.mData->agent; | 1861 | s >> a.mData->agent; |
1830 | s >> a.mData->phoneNumbers; | 1862 | s >> a.mData->phoneNumbers; |
1831 | s >> a.mData->addresses; | 1863 | s >> a.mData->addresses; |
1832 | s >> a.mData->emails; | 1864 | s >> a.mData->emails; |
1833 | s >> a.mData->categories; | 1865 | s >> a.mData->categories; |
1834 | s >> a.mData->custom; | 1866 | s >> a.mData->custom; |
1835 | s >> a.mData->keys; | 1867 | s >> a.mData->keys; |
1836 | 1868 | ||
1837 | a.mData->empty = false; | 1869 | a.mData->empty = false; |
1838 | 1870 | ||
1839 | return s; | 1871 | return s; |
1840 | } | 1872 | } |
1841 | bool matchBinaryPattern( int value, int pattern ) | 1873 | bool matchBinaryPattern( int value, int pattern ) |
1842 | { | 1874 | { |
1843 | /** | 1875 | /** |
1844 | We want to match all telephonnumbers/addresses which have the bits in the | 1876 | We want to match all telephonnumbers/addresses which have the bits in the |
1845 | pattern set. More are allowed. | 1877 | pattern set. More are allowed. |
1846 | if pattern == 0 we have a special handling, then we want only those with | 1878 | if pattern == 0 we have a special handling, then we want only those with |
1847 | exactly no bit set. | 1879 | exactly no bit set. |
1848 | */ | 1880 | */ |
1849 | if ( pattern == 0 ) | 1881 | if ( pattern == 0 ) |
1850 | return ( value == 0 ); | 1882 | return ( value == 0 ); |
1851 | else | 1883 | else |
1852 | return ( pattern == ( pattern & value ) ); | 1884 | return ( pattern == ( pattern & value ) ); |
1853 | } | 1885 | } |
1854 | 1886 | ||
1855 | bool matchBinaryPatternP( int value, int pattern ) | 1887 | bool matchBinaryPatternP( int value, int pattern ) |
1856 | { | 1888 | { |
1857 | 1889 | ||
1858 | if ( pattern == 0 ) | 1890 | if ( pattern == 0 ) |
1859 | return ( value == 0 ); | 1891 | return ( value == 0 ); |
1860 | else | 1892 | else |
1861 | return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); | 1893 | return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); |
1862 | } | 1894 | } |
1863 | bool matchBinaryPatternA( int value, int pattern ) | 1895 | bool matchBinaryPatternA( int value, int pattern ) |
1864 | { | 1896 | { |
1865 | 1897 | ||
1866 | if ( pattern == 0 ) | 1898 | if ( pattern == 0 ) |
1867 | return ( value == 0 ); | 1899 | return ( value == 0 ); |
1868 | else | 1900 | else |
1869 | return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); | 1901 | return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); |
1870 | } | 1902 | } |
diff --git a/kabc/addressee.h b/kabc/addressee.h index 8baa888..4cafa86 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -1,843 +1,847 @@ | |||
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 <qstringlist.h> | 34 | #include <qstringlist.h> |
35 | #include <qvaluelist.h> | 35 | #include <qvaluelist.h> |
36 | 36 | ||
37 | #include <ksharedptr.h> | 37 | #include <ksharedptr.h> |
38 | #include <kurl.h> | 38 | #include <kurl.h> |
39 | 39 | ||
40 | #include "address.h" | 40 | #include "address.h" |
41 | #include "agent.h" | 41 | #include "agent.h" |
42 | #include "geo.h" | 42 | #include "geo.h" |
43 | #include "key.h" | 43 | #include "key.h" |
44 | #include "phonenumber.h" | 44 | #include "phonenumber.h" |
45 | #include "picture.h" | 45 | #include "picture.h" |
46 | #include "secrecy.h" | 46 | #include "secrecy.h" |
47 | #include "sound.h" | 47 | #include "sound.h" |
48 | #include "timezone.h" | 48 | #include "timezone.h" |
49 | 49 | ||
50 | namespace KABC { | 50 | namespace KABC { |
51 | 51 | ||
52 | class Resource; | 52 | class Resource; |
53 | 53 | ||
54 | /** | 54 | /** |
55 | @short address book entry | 55 | @short address book entry |
56 | 56 | ||
57 | This class represents an entry in the address book. | 57 | This class represents an entry in the address book. |
58 | 58 | ||
59 | The data of this class is implicitly shared. You can pass this class by value. | 59 | The data of this class is implicitly shared. You can pass this class by value. |
60 | 60 | ||
61 | If you need the name of a field for presenting it to the user you should use | 61 | 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 | 62 | the functions ending in Label(). They return a translated string which can be |
63 | used as label for the corresponding field. | 63 | used as label for the corresponding field. |
64 | 64 | ||
65 | About the name fields: | 65 | About the name fields: |
66 | 66 | ||
67 | givenName() is the first name and familyName() the last name. In some | 67 | 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 | 68 | countries the family name comes first, that's the reason for the |
69 | naming. formattedName() is the full name with the correct formatting. | 69 | 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 | 70 | It is used as an override, when the correct formatting can't be generated |
71 | from the other name fields automatically. | 71 | from the other name fields automatically. |
72 | 72 | ||
73 | realName() returns a fully formatted name(). It uses formattedName, if set, | 73 | realName() returns a fully formatted name(). It uses formattedName, if set, |
74 | otherwise it constucts the name from the name fields. As fallback, if | 74 | otherwise it constucts the name from the name fields. As fallback, if |
75 | nothing else is set it uses name(). | 75 | nothing else is set it uses name(). |
76 | 76 | ||
77 | name() is the NAME type of RFC2426. It can be used as internal name for the | 77 | 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. | 78 | data enty, but shouldn't be used for displaying the data to the user. |
79 | */ | 79 | */ |
80 | class Addressee | 80 | class Addressee |
81 | { | 81 | { |
82 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); | 82 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); |
83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); | 83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); |
84 | 84 | ||
85 | public: | 85 | public: |
86 | typedef QValueList<Addressee> List; | 86 | typedef QValueList<Addressee> List; |
87 | 87 | ||
88 | /** | 88 | /** |
89 | Construct an empty address book entry. | 89 | Construct an empty address book entry. |
90 | */ | 90 | */ |
91 | Addressee(); | 91 | Addressee(); |
92 | ~Addressee(); | 92 | ~Addressee(); |
93 | 93 | ||
94 | Addressee( const Addressee & ); | 94 | Addressee( const Addressee & ); |
95 | Addressee &operator=( const Addressee & ); | 95 | Addressee &operator=( const Addressee & ); |
96 | 96 | ||
97 | bool operator==( const Addressee & ) const; | 97 | bool operator==( const Addressee & ) const; |
98 | bool operator!=( const Addressee & ) const; | 98 | bool operator!=( const Addressee & ) const; |
99 | // sync stuff | 99 | // sync stuff |
100 | void setTempSyncStat(int id); | 100 | void setTempSyncStat(int id); |
101 | int tempSyncStat() const; | 101 | int tempSyncStat() const; |
102 | void setIDStr( const QString & ); | 102 | void setIDStr( const QString & ); |
103 | QString IDStr() const; | 103 | QString IDStr() const; |
104 | void setID( const QString &, const QString & ); | 104 | void setID( const QString &, const QString & ); |
105 | QString getID( const QString & ); | 105 | QString getID( const QString & ); |
106 | void setCsum( const QString &, const QString & ); | 106 | void setCsum( const QString &, const QString & ); |
107 | QString getCsum( const QString & ); | 107 | QString getCsum( const QString & ); |
108 | void removeID(const QString &); | 108 | void removeID(const QString &); |
109 | void computeCsum(const QString &dev); | 109 | void computeCsum(const QString &dev); |
110 | ulong getCsum4List( const QStringList & attList); | 110 | ulong getCsum4List( const QStringList & attList); |
111 | /** | 111 | /** |
112 | Return, if the address book entry is empty. | 112 | Return, if the address book entry is empty. |
113 | */ | 113 | */ |
114 | bool isEmpty() const; | 114 | bool isEmpty() const; |
115 | void setExternalUID( const QString &id ); | 115 | void setExternalUID( const QString &id ); |
116 | QString externalUID() const; | 116 | QString externalUID() const; |
117 | void setOriginalExternalUID( const QString &id ); | 117 | void setOriginalExternalUID( const QString &id ); |
118 | QString originalExternalUID() const; | 118 | QString originalExternalUID() const; |
119 | void mergeContact( const Addressee& ad ); | 119 | void mergeContact( const Addressee& ad ); |
120 | void simplifyEmails(); | ||
121 | void simplifyPhoneNumbers(); | ||
122 | void simplifyPhoneNumberTypes(); | ||
123 | |||
120 | /** | 124 | /** |
121 | Set unique identifier. | 125 | Set unique identifier. |
122 | */ | 126 | */ |
123 | void setUid( const QString &uid ); | 127 | void setUid( const QString &uid ); |
124 | /** | 128 | /** |
125 | Return unique identifier. | 129 | Return unique identifier. |
126 | */ | 130 | */ |
127 | QString uid() const; | 131 | QString uid() const; |
128 | /** | 132 | /** |
129 | Return translated label for uid field. | 133 | Return translated label for uid field. |
130 | */ | 134 | */ |
131 | static QString uidLabel(); | 135 | static QString uidLabel(); |
132 | 136 | ||
133 | /** | 137 | /** |
134 | Set name. | 138 | Set name. |
135 | */ | 139 | */ |
136 | void setName( const QString &name ); | 140 | void setName( const QString &name ); |
137 | /** | 141 | /** |
138 | Return name. | 142 | Return name. |
139 | */ | 143 | */ |
140 | QString name() const; | 144 | QString name() const; |
141 | /** | 145 | /** |
142 | Return translated label for name field. | 146 | Return translated label for name field. |
143 | */ | 147 | */ |
144 | static QString nameLabel(); | 148 | static QString nameLabel(); |
145 | 149 | ||
146 | /** | 150 | /** |
147 | Set formatted name. | 151 | Set formatted name. |
148 | */ | 152 | */ |
149 | void setFormattedName( const QString &formattedName ); | 153 | void setFormattedName( const QString &formattedName ); |
150 | /** | 154 | /** |
151 | Return formatted name. | 155 | Return formatted name. |
152 | */ | 156 | */ |
153 | QString formattedName() const; | 157 | QString formattedName() const; |
154 | /** | 158 | /** |
155 | Return translated label for formattedName field. | 159 | Return translated label for formattedName field. |
156 | */ | 160 | */ |
157 | static QString formattedNameLabel(); | 161 | static QString formattedNameLabel(); |
158 | 162 | ||
159 | /** | 163 | /** |
160 | Set family name. | 164 | Set family name. |
161 | */ | 165 | */ |
162 | void setFamilyName( const QString &familyName ); | 166 | void setFamilyName( const QString &familyName ); |
163 | /** | 167 | /** |
164 | Return family name. | 168 | Return family name. |
165 | */ | 169 | */ |
166 | QString familyName() const; | 170 | QString familyName() const; |
167 | /** | 171 | /** |
168 | Return translated label for familyName field. | 172 | Return translated label for familyName field. |
169 | */ | 173 | */ |
170 | static QString familyNameLabel(); | 174 | static QString familyNameLabel(); |
171 | 175 | ||
172 | /** | 176 | /** |
173 | Set given name. | 177 | Set given name. |
174 | */ | 178 | */ |
175 | void setGivenName( const QString &givenName ); | 179 | void setGivenName( const QString &givenName ); |
176 | /** | 180 | /** |
177 | Return given name. | 181 | Return given name. |
178 | */ | 182 | */ |
179 | QString givenName() const; | 183 | QString givenName() const; |
180 | /** | 184 | /** |
181 | Return translated label for givenName field. | 185 | Return translated label for givenName field. |
182 | */ | 186 | */ |
183 | static QString givenNameLabel(); | 187 | static QString givenNameLabel(); |
184 | 188 | ||
185 | /** | 189 | /** |
186 | Set additional names. | 190 | Set additional names. |
187 | */ | 191 | */ |
188 | void setAdditionalName( const QString &additionalName ); | 192 | void setAdditionalName( const QString &additionalName ); |
189 | /** | 193 | /** |
190 | Return additional names. | 194 | Return additional names. |
191 | */ | 195 | */ |
192 | QString additionalName() const; | 196 | QString additionalName() const; |
193 | /** | 197 | /** |
194 | Return translated label for additionalName field. | 198 | Return translated label for additionalName field. |
195 | */ | 199 | */ |
196 | static QString additionalNameLabel(); | 200 | static QString additionalNameLabel(); |
197 | 201 | ||
198 | /** | 202 | /** |
199 | Set honorific prefixes. | 203 | Set honorific prefixes. |
200 | */ | 204 | */ |
201 | void setPrefix( const QString &prefix ); | 205 | void setPrefix( const QString &prefix ); |
202 | /** | 206 | /** |
203 | Return honorific prefixes. | 207 | Return honorific prefixes. |
204 | */ | 208 | */ |
205 | QString prefix() const; | 209 | QString prefix() const; |
206 | /** | 210 | /** |
207 | Return translated label for prefix field. | 211 | Return translated label for prefix field. |
208 | */ | 212 | */ |
209 | static QString prefixLabel(); | 213 | static QString prefixLabel(); |
210 | 214 | ||
211 | /** | 215 | /** |
212 | Set honorific suffixes. | 216 | Set honorific suffixes. |
213 | */ | 217 | */ |
214 | void setSuffix( const QString &suffix ); | 218 | void setSuffix( const QString &suffix ); |
215 | /** | 219 | /** |
216 | Return honorific suffixes. | 220 | Return honorific suffixes. |
217 | */ | 221 | */ |
218 | QString suffix() const; | 222 | QString suffix() const; |
219 | /** | 223 | /** |
220 | Return translated label for suffix field. | 224 | Return translated label for suffix field. |
221 | */ | 225 | */ |
222 | static QString suffixLabel(); | 226 | static QString suffixLabel(); |
223 | 227 | ||
224 | /** | 228 | /** |
225 | Set nick name. | 229 | Set nick name. |
226 | */ | 230 | */ |
227 | void setNickName( const QString &nickName ); | 231 | void setNickName( const QString &nickName ); |
228 | /** | 232 | /** |
229 | Return nick name. | 233 | Return nick name. |
230 | */ | 234 | */ |
231 | QString nickName() const; | 235 | QString nickName() const; |
232 | /** | 236 | /** |
233 | Return translated label for nickName field. | 237 | Return translated label for nickName field. |
234 | */ | 238 | */ |
235 | static QString nickNameLabel(); | 239 | static QString nickNameLabel(); |
236 | 240 | ||
237 | /** | 241 | /** |
238 | Set birthday. | 242 | Set birthday. |
239 | */ | 243 | */ |
240 | void setBirthday( const QDateTime &birthday ); | 244 | void setBirthday( const QDateTime &birthday ); |
241 | /** | 245 | /** |
242 | Return birthday. | 246 | Return birthday. |
243 | */ | 247 | */ |
244 | QDateTime birthday() const; | 248 | QDateTime birthday() const; |
245 | /** | 249 | /** |
246 | Return translated label for birthday field. | 250 | Return translated label for birthday field. |
247 | */ | 251 | */ |
248 | static QString birthdayLabel(); | 252 | static QString birthdayLabel(); |
249 | 253 | ||
250 | /** | 254 | /** |
251 | Return translated label for homeAddressStreet field. | 255 | Return translated label for homeAddressStreet field. |
252 | */ | 256 | */ |
253 | static QString homeAddressStreetLabel(); | 257 | static QString homeAddressStreetLabel(); |
254 | 258 | ||
255 | /** | 259 | /** |
256 | Return translated label for homeAddressLocality field. | 260 | Return translated label for homeAddressLocality field. |
257 | */ | 261 | */ |
258 | static QString homeAddressLocalityLabel(); | 262 | static QString homeAddressLocalityLabel(); |
259 | 263 | ||
260 | /** | 264 | /** |
261 | Return translated label for homeAddressRegion field. | 265 | Return translated label for homeAddressRegion field. |
262 | */ | 266 | */ |
263 | static QString homeAddressRegionLabel(); | 267 | static QString homeAddressRegionLabel(); |
264 | 268 | ||
265 | /** | 269 | /** |
266 | Return translated label for homeAddressPostalCode field. | 270 | Return translated label for homeAddressPostalCode field. |
267 | */ | 271 | */ |
268 | static QString homeAddressPostalCodeLabel(); | 272 | static QString homeAddressPostalCodeLabel(); |
269 | 273 | ||
270 | /** | 274 | /** |
271 | Return translated label for homeAddressCountry field. | 275 | Return translated label for homeAddressCountry field. |
272 | */ | 276 | */ |
273 | static QString homeAddressCountryLabel(); | 277 | static QString homeAddressCountryLabel(); |
274 | 278 | ||
275 | /** | 279 | /** |
276 | Return translated label for homeAddressLabel field. | 280 | Return translated label for homeAddressLabel field. |
277 | */ | 281 | */ |
278 | static QString homeAddressLabelLabel(); | 282 | static QString homeAddressLabelLabel(); |
279 | 283 | ||
280 | /** | 284 | /** |
281 | Return translated label for businessAddressStreet field. | 285 | Return translated label for businessAddressStreet field. |
282 | */ | 286 | */ |
283 | static QString businessAddressStreetLabel(); | 287 | static QString businessAddressStreetLabel(); |
284 | 288 | ||
285 | /** | 289 | /** |
286 | Return translated label for businessAddressLocality field. | 290 | Return translated label for businessAddressLocality field. |
287 | */ | 291 | */ |
288 | static QString businessAddressLocalityLabel(); | 292 | static QString businessAddressLocalityLabel(); |
289 | 293 | ||
290 | /** | 294 | /** |
291 | Return translated label for businessAddressRegion field. | 295 | Return translated label for businessAddressRegion field. |
292 | */ | 296 | */ |
293 | static QString businessAddressRegionLabel(); | 297 | static QString businessAddressRegionLabel(); |
294 | 298 | ||
295 | /** | 299 | /** |
296 | Return translated label for businessAddressPostalCode field. | 300 | Return translated label for businessAddressPostalCode field. |
297 | */ | 301 | */ |
298 | static QString businessAddressPostalCodeLabel(); | 302 | static QString businessAddressPostalCodeLabel(); |
299 | 303 | ||
300 | /** | 304 | /** |
301 | Return translated label for businessAddressCountry field. | 305 | Return translated label for businessAddressCountry field. |
302 | */ | 306 | */ |
303 | static QString businessAddressCountryLabel(); | 307 | static QString businessAddressCountryLabel(); |
304 | 308 | ||
305 | /** | 309 | /** |
306 | Return translated label for businessAddressLabel field. | 310 | Return translated label for businessAddressLabel field. |
307 | */ | 311 | */ |
308 | static QString businessAddressLabelLabel(); | 312 | static QString businessAddressLabelLabel(); |
309 | 313 | ||
310 | /** | 314 | /** |
311 | Return translated label for homePhone field. | 315 | Return translated label for homePhone field. |
312 | */ | 316 | */ |
313 | static QString homePhoneLabel(); | 317 | static QString homePhoneLabel(); |
314 | 318 | ||
315 | /** | 319 | /** |
316 | Return translated label for businessPhone field. | 320 | Return translated label for businessPhone field. |
317 | */ | 321 | */ |
318 | static QString businessPhoneLabel(); | 322 | static QString businessPhoneLabel(); |
319 | 323 | ||
320 | /** | 324 | /** |
321 | Return translated label for mobilePhone field. | 325 | Return translated label for mobilePhone field. |
322 | */ | 326 | */ |
323 | static QString mobilePhoneLabel(); | 327 | static QString mobilePhoneLabel(); |
324 | 328 | ||
325 | /** | 329 | /** |
326 | Return translated label for homeFax field. | 330 | Return translated label for homeFax field. |
327 | */ | 331 | */ |
328 | static QString homeFaxLabel(); | 332 | static QString homeFaxLabel(); |
329 | 333 | ||
330 | /** | 334 | /** |
331 | Return translated label for businessFax field. | 335 | Return translated label for businessFax field. |
332 | */ | 336 | */ |
333 | static QString businessFaxLabel(); | 337 | static QString businessFaxLabel(); |
334 | 338 | ||
335 | /** | 339 | /** |
336 | Return translated label for carPhone field. | 340 | Return translated label for carPhone field. |
337 | */ | 341 | */ |
338 | static QString carPhoneLabel(); | 342 | static QString carPhoneLabel(); |
339 | 343 | ||
340 | /** | 344 | /** |
341 | Return translated label for isdn field. | 345 | Return translated label for isdn field. |
342 | */ | 346 | */ |
343 | static QString isdnLabel(); | 347 | static QString isdnLabel(); |
344 | 348 | ||
345 | /** | 349 | /** |
346 | Return translated label for pager field. | 350 | Return translated label for pager field. |
347 | */ | 351 | */ |
348 | static QString pagerLabel(); | 352 | static QString pagerLabel(); |
349 | 353 | ||
350 | /** | 354 | /** |
351 | Return translated label for sip field. | 355 | Return translated label for sip field. |
352 | */ | 356 | */ |
353 | static QString sipLabel(); | 357 | static QString sipLabel(); |
354 | 358 | ||
355 | /** | 359 | /** |
356 | Return translated label for email field. | 360 | Return translated label for email field. |
357 | */ | 361 | */ |
358 | static QString emailLabel(); | 362 | static QString emailLabel(); |
359 | 363 | ||
360 | /** | 364 | /** |
361 | Set mail client. | 365 | Set mail client. |
362 | */ | 366 | */ |
363 | void setMailer( const QString &mailer ); | 367 | void setMailer( const QString &mailer ); |
364 | /** | 368 | /** |
365 | Return mail client. | 369 | Return mail client. |
366 | */ | 370 | */ |
367 | QString mailer() const; | 371 | QString mailer() const; |
368 | /** | 372 | /** |
369 | Return translated label for mailer field. | 373 | Return translated label for mailer field. |
370 | */ | 374 | */ |
371 | static QString mailerLabel(); | 375 | static QString mailerLabel(); |
372 | 376 | ||
373 | /** | 377 | /** |
374 | Set time zone. | 378 | Set time zone. |
375 | */ | 379 | */ |
376 | void setTimeZone( const TimeZone &timeZone ); | 380 | void setTimeZone( const TimeZone &timeZone ); |
377 | /** | 381 | /** |
378 | Return time zone. | 382 | Return time zone. |
379 | */ | 383 | */ |
380 | TimeZone timeZone() const; | 384 | TimeZone timeZone() const; |
381 | /** | 385 | /** |
382 | Return translated label for timeZone field. | 386 | Return translated label for timeZone field. |
383 | */ | 387 | */ |
384 | static QString timeZoneLabel(); | 388 | static QString timeZoneLabel(); |
385 | 389 | ||
386 | /** | 390 | /** |
387 | Set geographic position. | 391 | Set geographic position. |
388 | */ | 392 | */ |
389 | void setGeo( const Geo &geo ); | 393 | void setGeo( const Geo &geo ); |
390 | /** | 394 | /** |
391 | Return geographic position. | 395 | Return geographic position. |
392 | */ | 396 | */ |
393 | Geo geo() const; | 397 | Geo geo() const; |
394 | /** | 398 | /** |
395 | Return translated label for geo field. | 399 | Return translated label for geo field. |
396 | */ | 400 | */ |
397 | static QString geoLabel(); | 401 | static QString geoLabel(); |
398 | 402 | ||
399 | /** | 403 | /** |
400 | Set title. | 404 | Set title. |
401 | */ | 405 | */ |
402 | void setTitle( const QString &title ); | 406 | void setTitle( const QString &title ); |
403 | /** | 407 | /** |
404 | Return title. | 408 | Return title. |
405 | */ | 409 | */ |
406 | QString title() const; | 410 | QString title() const; |
407 | /** | 411 | /** |
408 | Return translated label for title field. | 412 | Return translated label for title field. |
409 | */ | 413 | */ |
410 | static QString titleLabel(); | 414 | static QString titleLabel(); |
411 | 415 | ||
412 | /** | 416 | /** |
413 | Set role. | 417 | Set role. |
414 | */ | 418 | */ |
415 | void setRole( const QString &role ); | 419 | void setRole( const QString &role ); |
416 | /** | 420 | /** |
417 | Return role. | 421 | Return role. |
418 | */ | 422 | */ |
419 | QString role() const; | 423 | QString role() const; |
420 | /** | 424 | /** |
421 | Return translated label for role field. | 425 | Return translated label for role field. |
422 | */ | 426 | */ |
423 | static QString roleLabel(); | 427 | static QString roleLabel(); |
424 | 428 | ||
425 | /** | 429 | /** |
426 | Set organization. | 430 | Set organization. |
427 | */ | 431 | */ |
428 | void setOrganization( const QString &organization ); | 432 | void setOrganization( const QString &organization ); |
429 | /** | 433 | /** |
430 | Return organization. | 434 | Return organization. |
431 | */ | 435 | */ |
432 | QString organization() const; | 436 | QString organization() const; |
433 | /** | 437 | /** |
434 | Return translated label for organization field. | 438 | Return translated label for organization field. |
435 | */ | 439 | */ |
436 | static QString organizationLabel(); | 440 | static QString organizationLabel(); |
437 | 441 | ||
438 | /** | 442 | /** |
439 | Set note. | 443 | Set note. |
440 | */ | 444 | */ |
441 | void setNote( const QString ¬e ); | 445 | void setNote( const QString ¬e ); |
442 | /** | 446 | /** |
443 | Return note. | 447 | Return note. |
444 | */ | 448 | */ |
445 | QString note() const; | 449 | QString note() const; |
446 | /** | 450 | /** |
447 | Return translated label for note field. | 451 | Return translated label for note field. |
448 | */ | 452 | */ |
449 | static QString noteLabel(); | 453 | static QString noteLabel(); |
450 | 454 | ||
451 | /** | 455 | /** |
452 | Set product identifier. | 456 | Set product identifier. |
453 | */ | 457 | */ |
454 | void setProductId( const QString &productId ); | 458 | void setProductId( const QString &productId ); |
455 | /** | 459 | /** |
456 | Return product identifier. | 460 | Return product identifier. |
457 | */ | 461 | */ |
458 | QString productId() const; | 462 | QString productId() const; |
459 | /** | 463 | /** |
460 | Return translated label for productId field. | 464 | Return translated label for productId field. |
461 | */ | 465 | */ |
462 | static QString productIdLabel(); | 466 | static QString productIdLabel(); |
463 | 467 | ||
464 | /** | 468 | /** |
465 | Set revision date. | 469 | Set revision date. |
466 | */ | 470 | */ |
467 | void setRevision( const QDateTime &revision ); | 471 | void setRevision( const QDateTime &revision ); |
468 | /** | 472 | /** |
469 | Return revision date. | 473 | Return revision date. |
470 | */ | 474 | */ |
471 | QDateTime revision() const; | 475 | QDateTime revision() const; |
472 | /** | 476 | /** |
473 | Return translated label for revision field. | 477 | Return translated label for revision field. |
474 | */ | 478 | */ |
475 | static QString revisionLabel(); | 479 | static QString revisionLabel(); |
476 | 480 | ||
477 | /** | 481 | /** |
478 | Set sort string. | 482 | Set sort string. |
479 | */ | 483 | */ |
480 | void setSortString( const QString &sortString ); | 484 | void setSortString( const QString &sortString ); |
481 | /** | 485 | /** |
482 | Return sort string. | 486 | Return sort string. |
483 | */ | 487 | */ |
484 | QString sortString() const; | 488 | QString sortString() const; |
485 | /** | 489 | /** |
486 | Return translated label for sortString field. | 490 | Return translated label for sortString field. |
487 | */ | 491 | */ |
488 | static QString sortStringLabel(); | 492 | static QString sortStringLabel(); |
489 | 493 | ||
490 | /** | 494 | /** |
491 | Set URL. | 495 | Set URL. |
492 | */ | 496 | */ |
493 | void setUrl( const KURL &url ); | 497 | void setUrl( const KURL &url ); |
494 | /** | 498 | /** |
495 | Return URL. | 499 | Return URL. |
496 | */ | 500 | */ |
497 | KURL url() const; | 501 | KURL url() const; |
498 | /** | 502 | /** |
499 | Return translated label for url field. | 503 | Return translated label for url field. |
500 | */ | 504 | */ |
501 | static QString urlLabel(); | 505 | static QString urlLabel(); |
502 | 506 | ||
503 | /** | 507 | /** |
504 | Set security class. | 508 | Set security class. |
505 | */ | 509 | */ |
506 | void setSecrecy( const Secrecy &secrecy ); | 510 | void setSecrecy( const Secrecy &secrecy ); |
507 | /** | 511 | /** |
508 | Return security class. | 512 | Return security class. |
509 | */ | 513 | */ |
510 | Secrecy secrecy() const; | 514 | Secrecy secrecy() const; |
511 | /** | 515 | /** |
512 | Return translated label for secrecy field. | 516 | Return translated label for secrecy field. |
513 | */ | 517 | */ |
514 | static QString secrecyLabel(); | 518 | static QString secrecyLabel(); |
515 | 519 | ||
516 | /** | 520 | /** |
517 | Set logo. | 521 | Set logo. |
518 | */ | 522 | */ |
519 | void setLogo( const Picture &logo ); | 523 | void setLogo( const Picture &logo ); |
520 | /** | 524 | /** |
521 | Return logo. | 525 | Return logo. |
522 | */ | 526 | */ |
523 | Picture logo() const; | 527 | Picture logo() const; |
524 | /** | 528 | /** |
525 | Return translated label for logo field. | 529 | Return translated label for logo field. |
526 | */ | 530 | */ |
527 | static QString logoLabel(); | 531 | static QString logoLabel(); |
528 | 532 | ||
529 | /** | 533 | /** |
530 | Set photo. | 534 | Set photo. |
531 | */ | 535 | */ |
532 | void setPhoto( const Picture &photo ); | 536 | void setPhoto( const Picture &photo ); |
533 | /** | 537 | /** |
534 | Return photo. | 538 | Return photo. |
535 | */ | 539 | */ |
536 | Picture photo() const; | 540 | Picture photo() const; |
537 | /** | 541 | /** |
538 | Return translated label for photo field. | 542 | Return translated label for photo field. |
539 | */ | 543 | */ |
540 | static QString photoLabel(); | 544 | static QString photoLabel(); |
541 | 545 | ||
542 | /** | 546 | /** |
543 | Set sound. | 547 | Set sound. |
544 | */ | 548 | */ |
545 | void setSound( const Sound &sound ); | 549 | void setSound( const Sound &sound ); |
546 | /** | 550 | /** |
547 | Return sound. | 551 | Return sound. |
548 | */ | 552 | */ |
549 | Sound sound() const; | 553 | Sound sound() const; |
550 | /** | 554 | /** |
551 | Return translated label for sound field. | 555 | Return translated label for sound field. |
552 | */ | 556 | */ |
553 | static QString soundLabel(); | 557 | static QString soundLabel(); |
554 | 558 | ||
555 | /** | 559 | /** |
556 | Set agent. | 560 | Set agent. |
557 | */ | 561 | */ |
558 | void setAgent( const Agent &agent ); | 562 | void setAgent( const Agent &agent ); |
559 | /** | 563 | /** |
560 | Return agent. | 564 | Return agent. |
561 | */ | 565 | */ |
562 | Agent agent() const; | 566 | Agent agent() const; |
563 | /** | 567 | /** |
564 | Return translated label for agent field. | 568 | Return translated label for agent field. |
565 | */ | 569 | */ |
566 | static QString agentLabel(); | 570 | static QString agentLabel(); |
567 | 571 | ||
568 | /** | 572 | /** |
569 | Set name fields by parsing the given string and trying to associate the | 573 | Set name fields by parsing the given string and trying to associate the |
570 | parts of the string with according fields. This function should probably | 574 | parts of the string with according fields. This function should probably |
571 | be a bit more clever. | 575 | be a bit more clever. |
572 | */ | 576 | */ |
573 | void setNameFromString( const QString & ); | 577 | void setNameFromString( const QString & ); |
574 | 578 | ||
575 | /** | 579 | /** |
576 | Return the name of the addressee. This is calculated from all the name | 580 | Return the name of the addressee. This is calculated from all the name |
577 | fields. | 581 | fields. |
578 | */ | 582 | */ |
579 | QString realName() const; | 583 | QString realName() const; |
580 | 584 | ||
581 | /** | 585 | /** |
582 | Return the name that consists of all name parts. | 586 | Return the name that consists of all name parts. |
583 | */ | 587 | */ |
584 | QString assembledName() const; | 588 | QString assembledName() const; |
585 | 589 | ||
586 | /** | 590 | /** |
587 | Return email address including real name. | 591 | Return email address including real name. |
588 | 592 | ||
589 | @param email Email address to be used to construct the full email string. | 593 | @param email Email address to be used to construct the full email string. |
590 | If this is QString::null the preferred email address is used. | 594 | If this is QString::null the preferred email address is used. |
591 | */ | 595 | */ |
592 | QString fullEmail( const QString &email=QString::null ) const; | 596 | QString fullEmail( const QString &email=QString::null ) const; |
593 | 597 | ||
594 | /** | 598 | /** |
595 | Insert an email address. If the email address already exists in this | 599 | Insert an email address. If the email address already exists in this |
596 | addressee it is not duplicated. | 600 | addressee it is not duplicated. |
597 | 601 | ||
598 | @param email Email address | 602 | @param email Email address |
599 | @param preferred Set to true, if this is the preferred email address of | 603 | @param preferred Set to true, if this is the preferred email address of |
600 | the addressee. | 604 | the addressee. |
601 | */ | 605 | */ |
602 | void insertEmail( const QString &email, bool preferred=false ); | 606 | void insertEmail( const QString &email, bool preferred=false ); |
603 | 607 | ||
604 | /** | 608 | /** |
605 | Remove email address. If the email address doesn't exist, nothing happens. | 609 | Remove email address. If the email address doesn't exist, nothing happens. |
606 | */ | 610 | */ |
607 | void removeEmail( const QString &email ); | 611 | void removeEmail( const QString &email ); |
608 | 612 | ||
609 | /** | 613 | /** |
610 | Return preferred email address. This is the first email address or the | 614 | Return preferred email address. This is the first email address or the |
611 | last one added with @ref insertEmail() with a set preferred parameter. | 615 | last one added with @ref insertEmail() with a set preferred parameter. |
612 | */ | 616 | */ |
613 | QString preferredEmail() const; | 617 | QString preferredEmail() const; |
614 | 618 | ||
615 | /** | 619 | /** |
616 | Return list of all email addresses. | 620 | Return list of all email addresses. |
617 | */ | 621 | */ |
618 | QStringList emails() const; | 622 | QStringList emails() const; |
619 | 623 | ||
620 | /** | 624 | /** |
621 | Set the emails to @param. | 625 | Set the emails to @param. |
622 | The first email address gets the preferred one! | 626 | The first email address gets the preferred one! |
623 | @param list The list of email addresses. | 627 | @param list The list of email addresses. |
624 | */ | 628 | */ |
625 | void setEmails( const QStringList& list); | 629 | void setEmails( const QStringList& list); |
626 | 630 | ||
627 | /** | 631 | /** |
628 | Insert a phone number. If a phone number with the same id already exists | 632 | Insert a phone number. If a phone number with the same id already exists |
629 | in this addressee it is not duplicated. | 633 | in this addressee it is not duplicated. |
630 | */ | 634 | */ |
631 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); | 635 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); |
632 | 636 | ||
633 | /** | 637 | /** |
634 | Remove phone number. If no phone number with the given id exists for this | 638 | Remove phone number. If no phone number with the given id exists for this |
635 | addresse nothing happens. | 639 | addresse nothing happens. |
636 | */ | 640 | */ |
637 | void removePhoneNumber( const PhoneNumber &phoneNumber ); | 641 | void removePhoneNumber( const PhoneNumber &phoneNumber ); |
638 | 642 | ||
639 | /** | 643 | /** |
640 | Return phone number, which matches the given type. | 644 | Return phone number, which matches the given type. |
641 | */ | 645 | */ |
642 | PhoneNumber phoneNumber( int type ) const; | 646 | PhoneNumber phoneNumber( int type ) const; |
643 | 647 | ||
644 | /** | 648 | /** |
645 | Return list of all phone numbers. | 649 | Return list of all phone numbers. |
646 | */ | 650 | */ |
647 | PhoneNumber::List phoneNumbers() const; | 651 | PhoneNumber::List phoneNumbers() const; |
648 | 652 | ||
649 | /** | 653 | /** |
650 | Return list of phone numbers with a special type. | 654 | Return list of phone numbers with a special type. |
651 | */ | 655 | */ |
652 | PhoneNumber::List phoneNumbers( int type ) const; | 656 | PhoneNumber::List phoneNumbers( int type ) const; |
653 | 657 | ||
654 | /** | 658 | /** |
655 | Return phone number with the given id. | 659 | Return phone number with the given id. |
656 | */ | 660 | */ |
657 | PhoneNumber findPhoneNumber( const QString &id ) const; | 661 | PhoneNumber findPhoneNumber( const QString &id ) const; |
658 | 662 | ||
659 | /** | 663 | /** |
660 | Insert a key. If a key with the same id already exists | 664 | Insert a key. If a key with the same id already exists |
661 | in this addressee it is not duplicated. | 665 | in this addressee it is not duplicated. |
662 | */ | 666 | */ |
663 | void insertKey( const Key &key ); | 667 | void insertKey( const Key &key ); |
664 | 668 | ||
665 | /** | 669 | /** |
666 | Remove a key. If no key with the given id exists for this | 670 | Remove a key. If no key with the given id exists for this |
667 | addresse nothing happens. | 671 | addresse nothing happens. |
668 | */ | 672 | */ |
669 | void removeKey( const Key &key ); | 673 | void removeKey( const Key &key ); |
670 | 674 | ||
671 | /** | 675 | /** |
672 | Return key, which matches the given type. | 676 | Return key, which matches the given type. |
673 | If @p type == Key::Custom you can specify a string | 677 | If @p type == Key::Custom you can specify a string |
674 | that should match. If you leave the string empty, the first | 678 | that should match. If you leave the string empty, the first |
675 | key with a custom value is returned. | 679 | key with a custom value is returned. |
676 | */ | 680 | */ |
677 | Key key( int type, QString customTypeString = QString::null ) const; | 681 | Key key( int type, QString customTypeString = QString::null ) const; |
678 | 682 | ||
679 | /** | 683 | /** |
680 | Return list of all keys. | 684 | Return list of all keys. |
681 | */ | 685 | */ |
682 | Key::List keys() const; | 686 | Key::List keys() const; |
683 | 687 | ||
684 | /** | 688 | /** |
685 | Set the list of keys | 689 | Set the list of keys |
686 | @param keys The keys to be set. | 690 | @param keys The keys to be set. |
687 | */ | 691 | */ |
688 | void setKeys( const Key::List& keys); | 692 | void setKeys( const Key::List& keys); |
689 | 693 | ||
690 | /** | 694 | /** |
691 | Return list of keys with a special type. | 695 | Return list of keys with a special type. |
692 | If @p type == Key::Custom you can specify a string | 696 | If @p type == Key::Custom you can specify a string |
693 | that should match. If you leave the string empty, all custom | 697 | that should match. If you leave the string empty, all custom |
694 | keys will be returned. | 698 | keys will be returned. |
695 | */ | 699 | */ |
696 | Key::List keys( int type, QString customTypeString = QString::null ) const; | 700 | Key::List keys( int type, QString customTypeString = QString::null ) const; |
697 | 701 | ||
698 | /** | 702 | /** |
699 | Return key with the given id. | 703 | Return key with the given id. |
700 | */ | 704 | */ |
701 | Key findKey( const QString &id ) const; | 705 | Key findKey( const QString &id ) const; |
702 | 706 | ||
703 | /** | 707 | /** |
704 | Insert an address. If an address with the same id already exists | 708 | Insert an address. If an address with the same id already exists |
705 | in this addressee it is not duplicated. | 709 | in this addressee it is not duplicated. |
706 | */ | 710 | */ |
707 | void insertAddress( const Address &address ); | 711 | void insertAddress( const Address &address ); |
708 | 712 | ||
709 | /** | 713 | /** |
710 | Remove address. If no address with the given id exists for this | 714 | Remove address. If no address with the given id exists for this |
711 | addresse nothing happens. | 715 | addresse nothing happens. |
712 | */ | 716 | */ |
713 | void removeAddress( const Address &address ); | 717 | void removeAddress( const Address &address ); |
714 | 718 | ||
715 | /** | 719 | /** |
716 | Return address, which matches the given type. | 720 | Return address, which matches the given type. |
717 | */ | 721 | */ |
718 | Address address( int type ) const; | 722 | Address address( int type ) const; |
719 | 723 | ||
720 | /** | 724 | /** |
721 | Return list of all addresses. | 725 | Return list of all addresses. |
722 | */ | 726 | */ |
723 | Address::List addresses() const; | 727 | Address::List addresses() const; |
724 | 728 | ||
725 | /** | 729 | /** |
726 | Return list of addresses with a special type. | 730 | Return list of addresses with a special type. |
727 | */ | 731 | */ |
728 | Address::List addresses( int type ) const; | 732 | Address::List addresses( int type ) const; |
729 | 733 | ||
730 | /** | 734 | /** |
731 | Return address with the given id. | 735 | Return address with the given id. |
732 | */ | 736 | */ |
733 | Address findAddress( const QString &id ) const; | 737 | Address findAddress( const QString &id ) const; |
734 | 738 | ||
735 | /** | 739 | /** |
736 | Insert category. If the category already exists it is not duplicated. | 740 | Insert category. If the category already exists it is not duplicated. |
737 | */ | 741 | */ |
738 | void insertCategory( const QString & ); | 742 | void insertCategory( const QString & ); |
739 | 743 | ||
740 | /** | 744 | /** |
741 | Remove category. | 745 | Remove category. |
742 | */ | 746 | */ |
743 | void removeCategory( const QString & ); | 747 | void removeCategory( const QString & ); |
744 | 748 | ||
745 | /** | 749 | /** |
746 | Return, if addressee has the given category. | 750 | Return, if addressee has the given category. |
747 | */ | 751 | */ |
748 | bool hasCategory( const QString & ) const; | 752 | bool hasCategory( const QString & ) const; |
749 | 753 | ||
750 | /** | 754 | /** |
751 | Set categories to given value. | 755 | Set categories to given value. |
752 | */ | 756 | */ |
753 | void setCategories( const QStringList & ); | 757 | void setCategories( const QStringList & ); |
754 | 758 | ||
755 | /** | 759 | /** |
756 | Return list of all set categories. | 760 | Return list of all set categories. |
757 | */ | 761 | */ |
758 | QStringList categories() const; | 762 | QStringList categories() const; |
759 | 763 | ||
760 | /** | 764 | /** |
761 | Insert custom entry. The entry is identified by the name of the inserting | 765 | Insert custom entry. The entry is identified by the name of the inserting |
762 | application and a unique name. If an entry with the given app and name | 766 | application and a unique name. If an entry with the given app and name |
763 | already exists its value is replaced with the new given value. | 767 | already exists its value is replaced with the new given value. |
764 | */ | 768 | */ |
765 | void insertCustom( const QString &app, const QString &name, | 769 | void insertCustom( const QString &app, const QString &name, |
766 | const QString &value ); | 770 | const QString &value ); |
767 | 771 | ||
768 | /** | 772 | /** |
769 | Remove custom entry. | 773 | Remove custom entry. |
770 | */ | 774 | */ |
771 | void removeCustom( const QString &app, const QString &name ); | 775 | void removeCustom( const QString &app, const QString &name ); |
772 | 776 | ||
773 | /** | 777 | /** |
774 | Return value of custom entry, identified by app and entry name. | 778 | Return value of custom entry, identified by app and entry name. |
775 | */ | 779 | */ |
776 | QString custom( const QString &app, const QString &name ) const; | 780 | QString custom( const QString &app, const QString &name ) const; |
777 | 781 | ||
778 | /** | 782 | /** |
779 | Set all custom entries. | 783 | Set all custom entries. |
780 | */ | 784 | */ |
781 | void setCustoms( const QStringList & ); | 785 | void setCustoms( const QStringList & ); |
782 | 786 | ||
783 | /** | 787 | /** |
784 | Return list of all custom entries. | 788 | Return list of all custom entries. |
785 | */ | 789 | */ |
786 | QStringList customs() const; | 790 | QStringList customs() const; |
787 | 791 | ||
788 | /** | 792 | /** |
789 | Parse full email address. The result is given back in fullName and email. | 793 | Parse full email address. The result is given back in fullName and email. |
790 | */ | 794 | */ |
791 | static void parseEmailAddress( const QString &rawEmail, QString &fullName, | 795 | static void parseEmailAddress( const QString &rawEmail, QString &fullName, |
792 | QString &email ); | 796 | QString &email ); |
793 | 797 | ||
794 | /** | 798 | /** |
795 | Debug output. | 799 | Debug output. |
796 | */ | 800 | */ |
797 | void dump() const; | 801 | void dump() const; |
798 | 802 | ||
799 | /** | 803 | /** |
800 | Returns string representation of the addressee. | 804 | Returns string representation of the addressee. |
801 | */ | 805 | */ |
802 | QString asString() const; | 806 | QString asString() const; |
803 | 807 | ||
804 | /** | 808 | /** |
805 | Set resource where the addressee is from. | 809 | Set resource where the addressee is from. |
806 | */ | 810 | */ |
807 | void setResource( Resource *resource ); | 811 | void setResource( Resource *resource ); |
808 | 812 | ||
809 | /** | 813 | /** |
810 | Return pointer to resource. | 814 | Return pointer to resource. |
811 | */ | 815 | */ |
812 | Resource *resource() const; | 816 | Resource *resource() const; |
813 | 817 | ||
814 | /** | 818 | /** |
815 | Return resourcelabel. | 819 | Return resourcelabel. |
816 | */ | 820 | */ |
817 | //US | 821 | //US |
818 | static QString resourceLabel(); | 822 | static QString resourceLabel(); |
819 | 823 | ||
820 | /** | 824 | /** |
821 | Mark addressee as changed. | 825 | Mark addressee as changed. |
822 | */ | 826 | */ |
823 | void setChanged( bool value ); | 827 | void setChanged( bool value ); |
824 | 828 | ||
825 | /** | 829 | /** |
826 | Return whether the addressee is changed. | 830 | Return whether the addressee is changed. |
827 | */ | 831 | */ |
828 | bool changed() const; | 832 | bool changed() const; |
829 | 833 | ||
830 | private: | 834 | private: |
831 | Addressee copy(); | 835 | Addressee copy(); |
832 | void detach(); | 836 | void detach(); |
833 | 837 | ||
834 | struct AddresseeData; | 838 | struct AddresseeData; |
835 | mutable KSharedPtr<AddresseeData> mData; | 839 | mutable KSharedPtr<AddresseeData> mData; |
836 | }; | 840 | }; |
837 | 841 | ||
838 | QDataStream &operator<<( QDataStream &, const Addressee & ); | 842 | QDataStream &operator<<( QDataStream &, const Addressee & ); |
839 | QDataStream &operator>>( QDataStream &, Addressee & ); | 843 | QDataStream &operator>>( QDataStream &, Addressee & ); |
840 | 844 | ||
841 | } | 845 | } |
842 | 846 | ||
843 | #endif | 847 | #endif |
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp index 7aeb2ee..e5abc0e 100644 --- a/kabc/phonenumber.cpp +++ b/kabc/phonenumber.cpp | |||
@@ -1,202 +1,225 @@ | |||
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 | #include <kapplication.h> | 28 | #include <kapplication.h> |
29 | #include <klocale.h> | 29 | #include <klocale.h> |
30 | 30 | ||
31 | #include "phonenumber.h" | 31 | #include "phonenumber.h" |
32 | 32 | ||
33 | using namespace KABC; | 33 | using namespace KABC; |
34 | 34 | ||
35 | PhoneNumber::PhoneNumber() : | 35 | PhoneNumber::PhoneNumber() : |
36 | mType( Home ) | 36 | mType( Home ) |
37 | { | 37 | { |
38 | init(); | 38 | init(); |
39 | } | 39 | } |
40 | 40 | ||
41 | PhoneNumber::PhoneNumber( const QString &number, int type ) : | 41 | PhoneNumber::PhoneNumber( const QString &number, int type ) : |
42 | mType( type ), mNumber( number ) | 42 | mType( type ), mNumber( number ) |
43 | { | 43 | { |
44 | init(); | 44 | init(); |
45 | } | 45 | } |
46 | 46 | ||
47 | PhoneNumber::~PhoneNumber() | 47 | PhoneNumber::~PhoneNumber() |
48 | { | 48 | { |
49 | } | 49 | } |
50 | 50 | ||
51 | void PhoneNumber::init() | 51 | void PhoneNumber::init() |
52 | { | 52 | { |
53 | mId = KApplication::randomString( 8 ); | 53 | mId = KApplication::randomString( 8 ); |
54 | } | 54 | } |
55 | 55 | ||
56 | bool PhoneNumber::operator==( const PhoneNumber &p ) const | 56 | bool PhoneNumber::operator==( const PhoneNumber &p ) const |
57 | { | 57 | { |
58 | if ( mNumber != p.mNumber ) return false; | 58 | if ( mNumber != p.mNumber ) return false; |
59 | if ( mType != p.mType ) return false; | 59 | if ( mType != p.mType ) return false; |
60 | 60 | ||
61 | return true; | 61 | return true; |
62 | } | 62 | } |
63 | 63 | ||
64 | bool PhoneNumber::operator!=( const PhoneNumber &p ) const | 64 | bool PhoneNumber::operator!=( const PhoneNumber &p ) const |
65 | { | 65 | { |
66 | return !( p == *this ); | 66 | return !( p == *this ); |
67 | } | 67 | } |
68 | 68 | ||
69 | bool PhoneNumber::simplifyNumber() | ||
70 | { | ||
71 | QString Number; | ||
72 | int i; | ||
73 | Number = mNumber.stripWhiteSpace (); | ||
74 | mNumber = ""; | ||
75 | if ( Number.at(0) == '+' ) | ||
76 | mNumber += "+"; | ||
77 | for ( i = 0; i < Number.length(); ++i) { | ||
78 | if ( Number.at(i).isDigit() ) | ||
79 | mNumber += Number.at(i); | ||
80 | } | ||
81 | return ( mNumber.length() > 0 ); | ||
82 | } | ||
83 | // make cellphone compatible | ||
84 | void PhoneNumber::simplifyType() | ||
85 | { | ||
86 | if ( mType & Fax ) mType = Fax; | ||
87 | else if ( mType & Cell ) mType = Cell; | ||
88 | else if ( mType & Work ) mType = Work ; | ||
89 | else if ( mType & Home ) mType = Home; | ||
90 | else mType = Pref; | ||
91 | } | ||
69 | void PhoneNumber::setId( const QString &id ) | 92 | void PhoneNumber::setId( const QString &id ) |
70 | { | 93 | { |
71 | mId = id; | 94 | mId = id; |
72 | } | 95 | } |
73 | 96 | ||
74 | QString PhoneNumber::id() const | 97 | QString PhoneNumber::id() const |
75 | { | 98 | { |
76 | return mId; | 99 | return mId; |
77 | } | 100 | } |
78 | 101 | ||
79 | void PhoneNumber::setNumber( const QString &number ) | 102 | void PhoneNumber::setNumber( const QString &number ) |
80 | { | 103 | { |
81 | mNumber = number; | 104 | mNumber = number; |
82 | } | 105 | } |
83 | 106 | ||
84 | QString PhoneNumber::number() const | 107 | QString PhoneNumber::number() const |
85 | { | 108 | { |
86 | return mNumber; | 109 | return mNumber; |
87 | } | 110 | } |
88 | 111 | ||
89 | void PhoneNumber::setType( int type ) | 112 | void PhoneNumber::setType( int type ) |
90 | { | 113 | { |
91 | mType = type; | 114 | mType = type; |
92 | } | 115 | } |
93 | 116 | ||
94 | int PhoneNumber::type() const | 117 | int PhoneNumber::type() const |
95 | { | 118 | { |
96 | return mType; | 119 | return mType; |
97 | } | 120 | } |
98 | 121 | ||
99 | QString PhoneNumber::typeLabel() const | 122 | QString PhoneNumber::typeLabel() const |
100 | { | 123 | { |
101 | QString label; | 124 | QString label; |
102 | bool first = true; | 125 | bool first = true; |
103 | 126 | ||
104 | TypeList list = typeList(); | 127 | TypeList list = typeList(); |
105 | 128 | ||
106 | TypeList::Iterator it; | 129 | TypeList::Iterator it; |
107 | for ( it = list.begin(); it != list.end(); ++it ) { | 130 | for ( it = list.begin(); it != list.end(); ++it ) { |
108 | if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { | 131 | if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { |
109 | label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); | 132 | label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); |
110 | if ( first ) | 133 | if ( first ) |
111 | first = false; | 134 | first = false; |
112 | } | 135 | } |
113 | } | 136 | } |
114 | 137 | ||
115 | return label; | 138 | return label; |
116 | } | 139 | } |
117 | 140 | ||
118 | QString PhoneNumber::label() const | 141 | QString PhoneNumber::label() const |
119 | { | 142 | { |
120 | return typeLabel( type() ); | 143 | return typeLabel( type() ); |
121 | } | 144 | } |
122 | 145 | ||
123 | PhoneNumber::TypeList PhoneNumber::typeList() | 146 | PhoneNumber::TypeList PhoneNumber::typeList() |
124 | { | 147 | { |
125 | TypeList list; | 148 | TypeList list; |
126 | 149 | ||
127 | list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video | 150 | list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video |
128 | << Bbs << Modem << Car << Isdn << Pcs << Pager << Sip; | 151 | << Bbs << Modem << Car << Isdn << Pcs << Pager << Sip; |
129 | 152 | ||
130 | return list; | 153 | return list; |
131 | } | 154 | } |
132 | 155 | ||
133 | QString PhoneNumber::label( int type ) | 156 | QString PhoneNumber::label( int type ) |
134 | { | 157 | { |
135 | return typeLabel( type ); | 158 | return typeLabel( type ); |
136 | } | 159 | } |
137 | 160 | ||
138 | QString PhoneNumber::typeLabel( int type ) | 161 | QString PhoneNumber::typeLabel( int type ) |
139 | { | 162 | { |
140 | QString typeString; | 163 | QString typeString; |
141 | 164 | ||
142 | if ((type & Home) == Home) | 165 | if ((type & Home) == Home) |
143 | typeString += i18n("Home"); | 166 | typeString += i18n("Home"); |
144 | else if ((type & Work) == Work) | 167 | else if ((type & Work) == Work) |
145 | typeString += i18n("Work"); | 168 | typeString += i18n("Work"); |
146 | 169 | ||
147 | if (!typeString.isEmpty()) | 170 | if (!typeString.isEmpty()) |
148 | typeString += " "; | 171 | typeString += " "; |
149 | 172 | ||
150 | if ((type & Cell) == Cell) | 173 | if ((type & Cell) == Cell) |
151 | typeString += i18n("Mobile"); | 174 | typeString += i18n("Mobile"); |
152 | else if ((type & Fax) == Fax) | 175 | else if ((type & Fax) == Fax) |
153 | typeString += i18n("Fax"); | 176 | typeString += i18n("Fax"); |
154 | else if ((type & Msg) == Msg) | 177 | else if ((type & Msg) == Msg) |
155 | typeString += i18n("Messenger"); | 178 | typeString += i18n("Messenger"); |
156 | else if ((type & Voice) == Voice) { | 179 | else if ((type & Voice) == Voice) { |
157 | // add nothing in case of the Voice flag | 180 | // add nothing in case of the Voice flag |
158 | // typeString += i18n("Voice"); | 181 | // typeString += i18n("Voice"); |
159 | } | 182 | } |
160 | else if ((type & Video) == Video) | 183 | else if ((type & Video) == Video) |
161 | typeString += i18n("Video"); | 184 | typeString += i18n("Video"); |
162 | else if ((type & Bbs) == Bbs) | 185 | else if ((type & Bbs) == Bbs) |
163 | typeString += i18n("Mailbox"); | 186 | typeString += i18n("Mailbox"); |
164 | else if ((type & Modem) == Modem) | 187 | else if ((type & Modem) == Modem) |
165 | typeString += i18n("Modem"); | 188 | typeString += i18n("Modem"); |
166 | else if ((type & Car) == Car) | 189 | else if ((type & Car) == Car) |
167 | typeString += i18n("Car"); | 190 | typeString += i18n("Car"); |
168 | else if ((type & Isdn) == Isdn) | 191 | else if ((type & Isdn) == Isdn) |
169 | typeString += i18n("ISDN"); | 192 | typeString += i18n("ISDN"); |
170 | else if ((type & Pcs) == Pcs) | 193 | else if ((type & Pcs) == Pcs) |
171 | typeString += i18n("PCS"); | 194 | typeString += i18n("PCS"); |
172 | else if ((type & Pager) == Pager) | 195 | else if ((type & Pager) == Pager) |
173 | typeString += i18n("Pager"); | 196 | typeString += i18n("Pager"); |
174 | else if ((type & Sip) == Sip) | 197 | else if ((type & Sip) == Sip) |
175 | typeString += i18n("SIP"); | 198 | typeString += i18n("SIP"); |
176 | 199 | ||
177 | // add the prefered flag | 200 | // add the prefered flag |
178 | if (!typeString.isEmpty()) | 201 | if (!typeString.isEmpty()) |
179 | typeString += " "; | 202 | typeString += " "; |
180 | 203 | ||
181 | if ((type & Pref) == Pref) | 204 | if ((type & Pref) == Pref) |
182 | typeString += i18n("(p)"); | 205 | typeString += i18n("(p)"); |
183 | 206 | ||
184 | //if we still have no match, return "other" | 207 | //if we still have no match, return "other" |
185 | if (typeString.isEmpty()) | 208 | if (typeString.isEmpty()) |
186 | return i18n("Other"); | 209 | return i18n("Other"); |
187 | 210 | ||
188 | 211 | ||
189 | return typeString; | 212 | return typeString; |
190 | } | 213 | } |
191 | 214 | ||
192 | QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone ) | 215 | QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone ) |
193 | { | 216 | { |
194 | return s << phone.mId << phone.mType << phone.mNumber; | 217 | return s << phone.mId << phone.mType << phone.mNumber; |
195 | } | 218 | } |
196 | 219 | ||
197 | QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone ) | 220 | QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone ) |
198 | { | 221 | { |
199 | s >> phone.mId >> phone.mType >> phone.mNumber; | 222 | s >> phone.mId >> phone.mType >> phone.mNumber; |
200 | 223 | ||
201 | return s; | 224 | return s; |
202 | } | 225 | } |
diff --git a/kabc/phonenumber.h b/kabc/phonenumber.h index 1df344f..410a52f 100644 --- a/kabc/phonenumber.h +++ b/kabc/phonenumber.h | |||
@@ -1,166 +1,168 @@ | |||
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_PHONENUMBER_H | 28 | #ifndef KABC_PHONENUMBER_H |
29 | #define KABC_PHONENUMBER_H | 29 | #define KABC_PHONENUMBER_H |
30 | 30 | ||
31 | #include <qvaluelist.h> | 31 | #include <qvaluelist.h> |
32 | #include <qstring.h> | 32 | #include <qstring.h> |
33 | 33 | ||
34 | namespace KABC { | 34 | namespace KABC { |
35 | 35 | ||
36 | /** | 36 | /** |
37 | @short Phonenumber information. | 37 | @short Phonenumber information. |
38 | 38 | ||
39 | This class provides phone number information. A phone number is classified by | 39 | This class provides phone number information. A phone number is classified by |
40 | a type. The following types are available, it's possible to use multiple types | 40 | a type. The following types are available, it's possible to use multiple types |
41 | @ref Types for a number by combining them through a logical or. | 41 | @ref Types for a number by combining them through a logical or. |
42 | */ | 42 | */ |
43 | class PhoneNumber | 43 | class PhoneNumber |
44 | { | 44 | { |
45 | friend QDataStream &operator<<( QDataStream &, const PhoneNumber & ); | 45 | friend QDataStream &operator<<( QDataStream &, const PhoneNumber & ); |
46 | friend QDataStream &operator>>( QDataStream &, PhoneNumber & ); | 46 | friend QDataStream &operator>>( QDataStream &, PhoneNumber & ); |
47 | 47 | ||
48 | public: | 48 | public: |
49 | typedef QValueList<PhoneNumber> List; | 49 | typedef QValueList<PhoneNumber> List; |
50 | typedef QValueList<int> TypeList; | 50 | typedef QValueList<int> TypeList; |
51 | 51 | ||
52 | /** | 52 | /** |
53 | @li @p Home - Home number | 53 | @li @p Home - Home number |
54 | @li @p Work - Office number | 54 | @li @p Work - Office number |
55 | @li @p Msg - Messaging | 55 | @li @p Msg - Messaging |
56 | @li @p Pref - Preferred number | 56 | @li @p Pref - Preferred number |
57 | @li @p Voice - Voice | 57 | @li @p Voice - Voice |
58 | @li @p Fax - Fax machine | 58 | @li @p Fax - Fax machine |
59 | @li @p Cell - Cell phone | 59 | @li @p Cell - Cell phone |
60 | @li @p Video - Video phone | 60 | @li @p Video - Video phone |
61 | @li @p Bbs - Mailbox | 61 | @li @p Bbs - Mailbox |
62 | @li @p Modem - Modem | 62 | @li @p Modem - Modem |
63 | @li @p Car - Car phone | 63 | @li @p Car - Car phone |
64 | @li @p Isdn - ISDN connection | 64 | @li @p Isdn - ISDN connection |
65 | @li @p Pcs - Personal Communication Service | 65 | @li @p Pcs - Personal Communication Service |
66 | @li @p Pager - Pager | 66 | @li @p Pager - Pager |
67 | @li @p SIP - VoIP | 67 | @li @p SIP - VoIP |
68 | */ | 68 | */ |
69 | enum Types { Home = 1, Work = 2, Msg = 4, Pref = 8, Voice = 16, Fax = 32, | 69 | enum Types { Home = 1, Work = 2, Msg = 4, Pref = 8, Voice = 16, Fax = 32, |
70 | Cell = 64, Video = 128, Bbs = 256, Modem = 512, Car = 1024, | 70 | Cell = 64, Video = 128, Bbs = 256, Modem = 512, Car = 1024, |
71 | Isdn = 2048, Pcs = 4096, Pager = 8192, Sip = 16384 }; | 71 | Isdn = 2048, Pcs = 4096, Pager = 8192, Sip = 16384 }; |
72 | 72 | ||
73 | /** | 73 | /** |
74 | Create an empty phone number object. | 74 | Create an empty phone number object. |
75 | */ | 75 | */ |
76 | PhoneNumber(); | 76 | PhoneNumber(); |
77 | 77 | ||
78 | /** | 78 | /** |
79 | Create a phonenumber object. | 79 | Create a phonenumber object. |
80 | 80 | ||
81 | @param number Number | 81 | @param number Number |
82 | @param type Type as defined in enum. Multiple types can be | 82 | @param type Type as defined in enum. Multiple types can be |
83 | specified by combining them by a logical or. | 83 | specified by combining them by a logical or. |
84 | */ | 84 | */ |
85 | PhoneNumber( const QString &number, int type = Home ); | 85 | PhoneNumber( const QString &number, int type = Home ); |
86 | 86 | ||
87 | /** | 87 | /** |
88 | Destructor. | 88 | Destructor. |
89 | */ | 89 | */ |
90 | ~PhoneNumber(); | 90 | ~PhoneNumber(); |
91 | 91 | ||
92 | bool operator==( const PhoneNumber & ) const; | 92 | bool operator==( const PhoneNumber & ) const; |
93 | bool operator!=( const PhoneNumber & ) const; | 93 | bool operator!=( const PhoneNumber & ) const; |
94 | 94 | ||
95 | /** | 95 | /** |
96 | Sets the unique identifier. | 96 | Sets the unique identifier. |
97 | */ | 97 | */ |
98 | void setId( const QString &id ); | 98 | void setId( const QString &id ); |
99 | 99 | ||
100 | /** | 100 | /** |
101 | Returns the unique identifier. | 101 | Returns the unique identifier. |
102 | */ | 102 | */ |
103 | QString id() const; | 103 | QString id() const; |
104 | 104 | ||
105 | /** | 105 | /** |
106 | Sets the number. | 106 | Sets the number. |
107 | */ | 107 | */ |
108 | void setNumber( const QString & ); | 108 | void setNumber( const QString & ); |
109 | 109 | ||
110 | /** | 110 | /** |
111 | Returns the number. | 111 | Returns the number. |
112 | */ | 112 | */ |
113 | QString number() const; | 113 | QString number() const; |
114 | 114 | ||
115 | /** | 115 | /** |
116 | Sets the type. Multiple types can be specified by combining them by | 116 | Sets the type. Multiple types can be specified by combining them by |
117 | a logical or. | 117 | a logical or. |
118 | */ | 118 | */ |
119 | void setType( int ); | 119 | void setType( int ); |
120 | 120 | ||
121 | /** | 121 | /** |
122 | Returns the type. Can be a multiple types combined by a logical or. | 122 | Returns the type. Can be a multiple types combined by a logical or. |
123 | */ | 123 | */ |
124 | int type() const; | 124 | int type() const; |
125 | 125 | ||
126 | /** | 126 | /** |
127 | Returns a translated string of all types the address has. | 127 | Returns a translated string of all types the address has. |
128 | */ | 128 | */ |
129 | QString typeLabel() const; | 129 | QString typeLabel() const; |
130 | 130 | ||
131 | /** | 131 | /** |
132 | Returns the translated label for phone number depending on its type. | 132 | Returns the translated label for phone number depending on its type. |
133 | */ | 133 | */ |
134 | QString label() const; | 134 | QString label() const; |
135 | 135 | ||
136 | /** | 136 | /** |
137 | Returns a list of all available types | 137 | Returns a list of all available types |
138 | */ | 138 | */ |
139 | static TypeList typeList(); | 139 | static TypeList typeList(); |
140 | 140 | ||
141 | /** | 141 | /** |
142 | Returns the translated label for phone number type. | 142 | Returns the translated label for phone number type. |
143 | */ | 143 | */ |
144 | static QString typeLabel( int type ); | 144 | static QString typeLabel( int type ); |
145 | 145 | ||
146 | /** | 146 | /** |
147 | Returns the translated label for phone number type. | 147 | Returns the translated label for phone number type. |
148 | @obsolete | 148 | @obsolete |
149 | */ | 149 | */ |
150 | static QString label( int type ); | 150 | static QString label( int type ); |
151 | bool simplifyNumber(); | ||
152 | void simplifyType(); | ||
151 | 153 | ||
152 | private: | 154 | private: |
153 | void init(); | 155 | void init(); |
154 | 156 | ||
155 | QString mId; | 157 | QString mId; |
156 | 158 | ||
157 | int mType; | 159 | int mType; |
158 | QString mNumber; | 160 | QString mNumber; |
159 | }; | 161 | }; |
160 | 162 | ||
161 | QDataStream &operator<<( QDataStream &, const PhoneNumber & ); | 163 | QDataStream &operator<<( QDataStream &, const PhoneNumber & ); |
162 | QDataStream &operator>>( QDataStream &, PhoneNumber & ); | 164 | QDataStream &operator>>( QDataStream &, PhoneNumber & ); |
163 | 165 | ||
164 | } | 166 | } |
165 | 167 | ||
166 | #endif | 168 | #endif |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index c5406bf..939296f 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,2886 +1,2901 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook. | 2 | This file is part of KAddressbook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program 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 | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /*s | 24 | /*s |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "kabcore.h" | 31 | #include "kabcore.h" |
32 | 32 | ||
33 | #include <stdaddressbook.h> | 33 | #include <stdaddressbook.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kfiledialog.h> | 35 | #include <kfiledialog.h> |
36 | #include <qtimer.h> | 36 | #include <qtimer.h> |
37 | #include <qlabel.h> | 37 | #include <qlabel.h> |
38 | #include <qregexp.h> | 38 | #include <qregexp.h> |
39 | #include <qlineedit.h> | 39 | #include <qlineedit.h> |
40 | #include <qcheckbox.h> | 40 | #include <qcheckbox.h> |
41 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
42 | #include <qprogressbar.h> | 42 | #include <qprogressbar.h> |
43 | #include <libkdepim/phoneaccess.h> | 43 | #include <libkdepim/phoneaccess.h> |
44 | 44 | ||
45 | #ifndef KAB_EMBEDDED | 45 | #ifndef KAB_EMBEDDED |
46 | #include <qclipboard.h> | 46 | #include <qclipboard.h> |
47 | #include <qdir.h> | 47 | #include <qdir.h> |
48 | #include <qfile.h> | 48 | #include <qfile.h> |
49 | #include <qapplicaton.h> | 49 | #include <qapplicaton.h> |
50 | #include <qprogressbar.h> | 50 | #include <qprogressbar.h> |
51 | #include <qlayout.h> | 51 | #include <qlayout.h> |
52 | #include <qregexp.h> | 52 | #include <qregexp.h> |
53 | #include <qvbox.h> | 53 | #include <qvbox.h> |
54 | #include <kabc/addresseelist.h> | 54 | #include <kabc/addresseelist.h> |
55 | #include <kabc/errorhandler.h> | 55 | #include <kabc/errorhandler.h> |
56 | #include <kabc/resource.h> | 56 | #include <kabc/resource.h> |
57 | #include <kabc/vcardconverter.h> | 57 | #include <kabc/vcardconverter.h> |
58 | #include <kapplication.h> | 58 | #include <kapplication.h> |
59 | #include <kactionclasses.h> | 59 | #include <kactionclasses.h> |
60 | #include <kcmultidialog.h> | 60 | #include <kcmultidialog.h> |
61 | #include <kdebug.h> | 61 | #include <kdebug.h> |
62 | #include <kdeversion.h> | 62 | #include <kdeversion.h> |
63 | #include <kkeydialog.h> | 63 | #include <kkeydialog.h> |
64 | #include <kmessagebox.h> | 64 | #include <kmessagebox.h> |
65 | #include <kprinter.h> | 65 | #include <kprinter.h> |
66 | #include <kprotocolinfo.h> | 66 | #include <kprotocolinfo.h> |
67 | #include <kresources/selectdialog.h> | 67 | #include <kresources/selectdialog.h> |
68 | #include <kstandarddirs.h> | 68 | #include <kstandarddirs.h> |
69 | #include <ktempfile.h> | 69 | #include <ktempfile.h> |
70 | #include <kxmlguiclient.h> | 70 | #include <kxmlguiclient.h> |
71 | #include <kaboutdata.h> | 71 | #include <kaboutdata.h> |
72 | #include <libkdepim/categoryselectdialog.h> | 72 | #include <libkdepim/categoryselectdialog.h> |
73 | 73 | ||
74 | #include "addresseeutil.h" | 74 | #include "addresseeutil.h" |
75 | #include "addresseeeditordialog.h" | 75 | #include "addresseeeditordialog.h" |
76 | #include "extensionmanager.h" | 76 | #include "extensionmanager.h" |
77 | #include "kstdaction.h" | 77 | #include "kstdaction.h" |
78 | #include "kaddressbookservice.h" | 78 | #include "kaddressbookservice.h" |
79 | #include "ldapsearchdialog.h" | 79 | #include "ldapsearchdialog.h" |
80 | #include "printing/printingwizard.h" | 80 | #include "printing/printingwizard.h" |
81 | #else // KAB_EMBEDDED | 81 | #else // KAB_EMBEDDED |
82 | 82 | ||
83 | #include <kapplication.h> | 83 | #include <kapplication.h> |
84 | #include "KDGanttMinimizeSplitter.h" | 84 | #include "KDGanttMinimizeSplitter.h" |
85 | #include "kaddressbookmain.h" | 85 | #include "kaddressbookmain.h" |
86 | #include "kactioncollection.h" | 86 | #include "kactioncollection.h" |
87 | #include "addresseedialog.h" | 87 | #include "addresseedialog.h" |
88 | //US | 88 | //US |
89 | #include <addresseeview.h> | 89 | #include <addresseeview.h> |
90 | 90 | ||
91 | #include <qapp.h> | 91 | #include <qapp.h> |
92 | #include <qmenubar.h> | 92 | #include <qmenubar.h> |
93 | //#include <qtoolbar.h> | 93 | //#include <qtoolbar.h> |
94 | #include <qmessagebox.h> | 94 | #include <qmessagebox.h> |
95 | #include <kdebug.h> | 95 | #include <kdebug.h> |
96 | #include <kiconloader.h> // needed for SmallIcon | 96 | #include <kiconloader.h> // needed for SmallIcon |
97 | #include <kresources/kcmkresources.h> | 97 | #include <kresources/kcmkresources.h> |
98 | #include <ktoolbar.h> | 98 | #include <ktoolbar.h> |
99 | 99 | ||
100 | 100 | ||
101 | //#include <qlabel.h> | 101 | //#include <qlabel.h> |
102 | 102 | ||
103 | 103 | ||
104 | #ifndef DESKTOP_VERSION | 104 | #ifndef DESKTOP_VERSION |
105 | #include <qpe/ir.h> | 105 | #include <qpe/ir.h> |
106 | #include <qpe/qpemenubar.h> | 106 | #include <qpe/qpemenubar.h> |
107 | #include <qtopia/qcopenvelope_qws.h> | 107 | #include <qtopia/qcopenvelope_qws.h> |
108 | #else | 108 | #else |
109 | 109 | ||
110 | #include <qmenubar.h> | 110 | #include <qmenubar.h> |
111 | #endif | 111 | #endif |
112 | 112 | ||
113 | #endif // KAB_EMBEDDED | 113 | #endif // KAB_EMBEDDED |
114 | #include "kcmconfigs/kcmkabconfig.h" | 114 | #include "kcmconfigs/kcmkabconfig.h" |
115 | #include "kcmconfigs/kcmkdepimconfig.h" | 115 | #include "kcmconfigs/kcmkdepimconfig.h" |
116 | #include "kpimglobalprefs.h" | 116 | #include "kpimglobalprefs.h" |
117 | #include "externalapphandler.h" | 117 | #include "externalapphandler.h" |
118 | 118 | ||
119 | 119 | ||
120 | #include <kresources/selectdialog.h> | 120 | #include <kresources/selectdialog.h> |
121 | #include <kmessagebox.h> | 121 | #include <kmessagebox.h> |
122 | 122 | ||
123 | #include <picture.h> | 123 | #include <picture.h> |
124 | #include <resource.h> | 124 | #include <resource.h> |
125 | 125 | ||
126 | //US#include <qsplitter.h> | 126 | //US#include <qsplitter.h> |
127 | #include <qmap.h> | 127 | #include <qmap.h> |
128 | #include <qdir.h> | 128 | #include <qdir.h> |
129 | #include <qfile.h> | 129 | #include <qfile.h> |
130 | #include <qvbox.h> | 130 | #include <qvbox.h> |
131 | #include <qlayout.h> | 131 | #include <qlayout.h> |
132 | #include <qclipboard.h> | 132 | #include <qclipboard.h> |
133 | #include <qtextstream.h> | 133 | #include <qtextstream.h> |
134 | 134 | ||
135 | #include <libkdepim/categoryselectdialog.h> | 135 | #include <libkdepim/categoryselectdialog.h> |
136 | #include <kabc/vcardconverter.h> | 136 | #include <kabc/vcardconverter.h> |
137 | 137 | ||
138 | 138 | ||
139 | #include "addresseeutil.h" | 139 | #include "addresseeutil.h" |
140 | #include "undocmds.h" | 140 | #include "undocmds.h" |
141 | #include "addresseeeditordialog.h" | 141 | #include "addresseeeditordialog.h" |
142 | #include "viewmanager.h" | 142 | #include "viewmanager.h" |
143 | #include "details/detailsviewcontainer.h" | 143 | #include "details/detailsviewcontainer.h" |
144 | #include "kabprefs.h" | 144 | #include "kabprefs.h" |
145 | #include "xxportmanager.h" | 145 | #include "xxportmanager.h" |
146 | #include "incsearchwidget.h" | 146 | #include "incsearchwidget.h" |
147 | #include "jumpbuttonbar.h" | 147 | #include "jumpbuttonbar.h" |
148 | #include "extensionmanager.h" | 148 | #include "extensionmanager.h" |
149 | #include "addresseeconfig.h" | 149 | #include "addresseeconfig.h" |
150 | #include <kcmultidialog.h> | 150 | #include <kcmultidialog.h> |
151 | 151 | ||
152 | #ifdef _WIN32_ | 152 | #ifdef _WIN32_ |
153 | 153 | ||
154 | #include "kaimportoldialog.h" | 154 | #include "kaimportoldialog.h" |
155 | #else | 155 | #else |
156 | #include <unistd.h> | 156 | #include <unistd.h> |
157 | #endif | 157 | #endif |
158 | // sync includes | 158 | // sync includes |
159 | #include <libkdepim/ksyncprofile.h> | 159 | #include <libkdepim/ksyncprofile.h> |
160 | #include <libkdepim/ksyncprefsdialog.h> | 160 | #include <libkdepim/ksyncprefsdialog.h> |
161 | 161 | ||
162 | class KAex2phonePrefs : public QDialog | 162 | class KAex2phonePrefs : public QDialog |
163 | { | 163 | { |
164 | public: | 164 | public: |
165 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 165 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
166 | QDialog( parent, name, true ) | 166 | QDialog( parent, name, true ) |
167 | { | 167 | { |
168 | setCaption( i18n("Export to phone options") ); | 168 | setCaption( i18n("Export to phone options") ); |
169 | QVBoxLayout* lay = new QVBoxLayout( this ); | 169 | QVBoxLayout* lay = new QVBoxLayout( this ); |
170 | lay->setSpacing( 3 ); | 170 | lay->setSpacing( 3 ); |
171 | lay->setMargin( 3 ); | 171 | lay->setMargin( 3 ); |
172 | QLabel *lab; | 172 | QLabel *lab; |
173 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 173 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
174 | lab->setAlignment (AlignHCenter ); | 174 | lab->setAlignment (AlignHCenter ); |
175 | QHBox* temphb; | 175 | QHBox* temphb; |
176 | temphb = new QHBox( this ); | 176 | temphb = new QHBox( this ); |
177 | new QLabel( i18n("I/O device: "), temphb ); | 177 | new QLabel( i18n("I/O device: "), temphb ); |
178 | mPhoneDevice = new QLineEdit( temphb); | 178 | mPhoneDevice = new QLineEdit( temphb); |
179 | lay->addWidget( temphb ); | 179 | lay->addWidget( temphb ); |
180 | temphb = new QHBox( this ); | 180 | temphb = new QHBox( this ); |
181 | new QLabel( i18n("Connection: "), temphb ); | 181 | new QLabel( i18n("Connection: "), temphb ); |
182 | mPhoneConnection = new QLineEdit( temphb); | 182 | mPhoneConnection = new QLineEdit( temphb); |
183 | lay->addWidget( temphb ); | 183 | lay->addWidget( temphb ); |
184 | temphb = new QHBox( this ); | 184 | temphb = new QHBox( this ); |
185 | new QLabel( i18n("Model(opt.): "), temphb ); | 185 | new QLabel( i18n("Model(opt.): "), temphb ); |
186 | mPhoneModel = new QLineEdit( temphb); | 186 | mPhoneModel = new QLineEdit( temphb); |
187 | lay->addWidget( temphb ); | 187 | lay->addWidget( temphb ); |
188 | mWriteToSim= new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); | 188 | mWriteToSim= new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); |
189 | lay->addWidget( mWriteToSim ); | 189 | lay->addWidget( mWriteToSim ); |
190 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); | 190 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); |
191 | lab->setAlignment (AlignHCenter ); | 191 | lab->setAlignment (AlignHCenter ); |
192 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 192 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
193 | lay->addWidget( ok ); | 193 | lay->addWidget( ok ); |
194 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 194 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
195 | lay->addWidget( cancel ); | 195 | lay->addWidget( cancel ); |
196 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 196 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
197 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 197 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
198 | resize( 220, 240 ); | 198 | resize( 220, 240 ); |
199 | 199 | ||
200 | } | 200 | } |
201 | 201 | ||
202 | public: | 202 | public: |
203 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 203 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
204 | QCheckBox* mWriteToSim; | 204 | QCheckBox* mWriteToSim; |
205 | }; | 205 | }; |
206 | 206 | ||
207 | bool pasteWithNewUid = true; | 207 | bool pasteWithNewUid = true; |
208 | 208 | ||
209 | #ifdef KAB_EMBEDDED | 209 | #ifdef KAB_EMBEDDED |
210 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 210 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
211 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 211 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
212 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 212 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
213 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 213 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
214 | #else //KAB_EMBEDDED | 214 | #else //KAB_EMBEDDED |
215 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 215 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
216 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 216 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
217 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 217 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
218 | mReadWrite( readWrite ), mModified( false ) | 218 | mReadWrite( readWrite ), mModified( false ) |
219 | #endif //KAB_EMBEDDED | 219 | #endif //KAB_EMBEDDED |
220 | { | 220 | { |
221 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 221 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
222 | // syncManager->setBlockSave(false); | 222 | // syncManager->setBlockSave(false); |
223 | mExtensionBarSplitter = 0; | 223 | mExtensionBarSplitter = 0; |
224 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 224 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
225 | 225 | ||
226 | mAddressBook = KABC::StdAddressBook::self(); | 226 | mAddressBook = KABC::StdAddressBook::self(); |
227 | KABC::StdAddressBook::setAutomaticSave( false ); | 227 | KABC::StdAddressBook::setAutomaticSave( false ); |
228 | 228 | ||
229 | #ifndef KAB_EMBEDDED | 229 | #ifndef KAB_EMBEDDED |
230 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 230 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
231 | #endif //KAB_EMBEDDED | 231 | #endif //KAB_EMBEDDED |
232 | 232 | ||
233 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 233 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
234 | SLOT( addressBookChanged() ) ); | 234 | SLOT( addressBookChanged() ) ); |
235 | 235 | ||
236 | #if 0 | 236 | #if 0 |
237 | // LP moved to addressbook init method | 237 | // LP moved to addressbook init method |
238 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 238 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
239 | "X-Department", "KADDRESSBOOK" ); | 239 | "X-Department", "KADDRESSBOOK" ); |
240 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 240 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
241 | "X-Profession", "KADDRESSBOOK" ); | 241 | "X-Profession", "KADDRESSBOOK" ); |
242 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 242 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
243 | "X-AssistantsName", "KADDRESSBOOK" ); | 243 | "X-AssistantsName", "KADDRESSBOOK" ); |
244 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 244 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
245 | "X-ManagersName", "KADDRESSBOOK" ); | 245 | "X-ManagersName", "KADDRESSBOOK" ); |
246 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 246 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
247 | "X-SpousesName", "KADDRESSBOOK" ); | 247 | "X-SpousesName", "KADDRESSBOOK" ); |
248 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 248 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
249 | "X-Office", "KADDRESSBOOK" ); | 249 | "X-Office", "KADDRESSBOOK" ); |
250 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 250 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
251 | "X-IMAddress", "KADDRESSBOOK" ); | 251 | "X-IMAddress", "KADDRESSBOOK" ); |
252 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 252 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
253 | "X-Anniversary", "KADDRESSBOOK" ); | 253 | "X-Anniversary", "KADDRESSBOOK" ); |
254 | 254 | ||
255 | //US added this field to become compatible with Opie/qtopia addressbook | 255 | //US added this field to become compatible with Opie/qtopia addressbook |
256 | // values can be "female" or "male" or "". An empty field represents undefined. | 256 | // values can be "female" or "male" or "". An empty field represents undefined. |
257 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 257 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
258 | "X-Gender", "KADDRESSBOOK" ); | 258 | "X-Gender", "KADDRESSBOOK" ); |
259 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 259 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
260 | "X-Children", "KADDRESSBOOK" ); | 260 | "X-Children", "KADDRESSBOOK" ); |
261 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 261 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
262 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 262 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
263 | #endif | 263 | #endif |
264 | initGUI(); | 264 | initGUI(); |
265 | 265 | ||
266 | mIncSearchWidget->setFocus(); | 266 | mIncSearchWidget->setFocus(); |
267 | 267 | ||
268 | 268 | ||
269 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 269 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
270 | SLOT( setContactSelected( const QString& ) ) ); | 270 | SLOT( setContactSelected( const QString& ) ) ); |
271 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 271 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
272 | SLOT( executeContact( const QString& ) ) ); | 272 | SLOT( executeContact( const QString& ) ) ); |
273 | 273 | ||
274 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 274 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
275 | SLOT( deleteContacts( ) ) ); | 275 | SLOT( deleteContacts( ) ) ); |
276 | connect( mViewManager, SIGNAL( modified() ), | 276 | connect( mViewManager, SIGNAL( modified() ), |
277 | SLOT( setModified() ) ); | 277 | SLOT( setModified() ) ); |
278 | 278 | ||
279 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 279 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
280 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); | 280 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); |
281 | 281 | ||
282 | connect( mXXPortManager, SIGNAL( modified() ), | 282 | connect( mXXPortManager, SIGNAL( modified() ), |
283 | SLOT( setModified() ) ); | 283 | SLOT( setModified() ) ); |
284 | 284 | ||
285 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 285 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
286 | SLOT( incrementalSearch( const QString& ) ) ); | 286 | SLOT( incrementalSearch( const QString& ) ) ); |
287 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 287 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
288 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 288 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
289 | 289 | ||
290 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 290 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
291 | SLOT( sendMail( const QString& ) ) ); | 291 | SLOT( sendMail( const QString& ) ) ); |
292 | 292 | ||
293 | 293 | ||
294 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); | 294 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); |
295 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); | 295 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); |
296 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); | 296 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); |
297 | 297 | ||
298 | 298 | ||
299 | #ifndef KAB_EMBEDDED | 299 | #ifndef KAB_EMBEDDED |
300 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 300 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
301 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 301 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
302 | 302 | ||
303 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 303 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
304 | SLOT( browse( const QString& ) ) ); | 304 | SLOT( browse( const QString& ) ) ); |
305 | 305 | ||
306 | 306 | ||
307 | mAddressBookService = new KAddressBookService( this ); | 307 | mAddressBookService = new KAddressBookService( this ); |
308 | 308 | ||
309 | #endif //KAB_EMBEDDED | 309 | #endif //KAB_EMBEDDED |
310 | mEditorDialog = 0; | 310 | mEditorDialog = 0; |
311 | createAddresseeEditorDialog( this ); | 311 | createAddresseeEditorDialog( this ); |
312 | setModified( false ); | 312 | setModified( false ); |
313 | } | 313 | } |
314 | 314 | ||
315 | KABCore::~KABCore() | 315 | KABCore::~KABCore() |
316 | { | 316 | { |
317 | // save(); | 317 | // save(); |
318 | //saveSettings(); | 318 | //saveSettings(); |
319 | //KABPrefs::instance()->writeConfig(); | 319 | //KABPrefs::instance()->writeConfig(); |
320 | delete AddresseeConfig::instance(); | 320 | delete AddresseeConfig::instance(); |
321 | mAddressBook = 0; | 321 | mAddressBook = 0; |
322 | KABC::StdAddressBook::close(); | 322 | KABC::StdAddressBook::close(); |
323 | 323 | ||
324 | delete syncManager; | 324 | delete syncManager; |
325 | } | 325 | } |
326 | 326 | ||
327 | void KABCore::restoreSettings() | 327 | void KABCore::restoreSettings() |
328 | { | 328 | { |
329 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 329 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
330 | 330 | ||
331 | bool state; | 331 | bool state; |
332 | 332 | ||
333 | if (mMultipleViewsAtOnce) | 333 | if (mMultipleViewsAtOnce) |
334 | state = KABPrefs::instance()->mDetailsPageVisible; | 334 | state = KABPrefs::instance()->mDetailsPageVisible; |
335 | else | 335 | else |
336 | state = false; | 336 | state = false; |
337 | 337 | ||
338 | mActionDetails->setChecked( state ); | 338 | mActionDetails->setChecked( state ); |
339 | setDetailsVisible( state ); | 339 | setDetailsVisible( state ); |
340 | 340 | ||
341 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 341 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
342 | 342 | ||
343 | mActionJumpBar->setChecked( state ); | 343 | mActionJumpBar->setChecked( state ); |
344 | setJumpButtonBarVisible( state ); | 344 | setJumpButtonBarVisible( state ); |
345 | /*US | 345 | /*US |
346 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 346 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
347 | if ( splitterSize.count() == 0 ) { | 347 | if ( splitterSize.count() == 0 ) { |
348 | splitterSize.append( width() / 2 ); | 348 | splitterSize.append( width() / 2 ); |
349 | splitterSize.append( width() / 2 ); | 349 | splitterSize.append( width() / 2 ); |
350 | } | 350 | } |
351 | mMiniSplitter->setSizes( splitterSize ); | 351 | mMiniSplitter->setSizes( splitterSize ); |
352 | if ( mExtensionBarSplitter ) { | 352 | if ( mExtensionBarSplitter ) { |
353 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 353 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
354 | if ( splitterSize.count() == 0 ) { | 354 | if ( splitterSize.count() == 0 ) { |
355 | splitterSize.append( width() / 2 ); | 355 | splitterSize.append( width() / 2 ); |
356 | splitterSize.append( width() / 2 ); | 356 | splitterSize.append( width() / 2 ); |
357 | } | 357 | } |
358 | mExtensionBarSplitter->setSizes( splitterSize ); | 358 | mExtensionBarSplitter->setSizes( splitterSize ); |
359 | 359 | ||
360 | } | 360 | } |
361 | */ | 361 | */ |
362 | mViewManager->restoreSettings(); | 362 | mViewManager->restoreSettings(); |
363 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 363 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
364 | mExtensionManager->restoreSettings(); | 364 | mExtensionManager->restoreSettings(); |
365 | #ifdef DESKTOP_VERSION | 365 | #ifdef DESKTOP_VERSION |
366 | int wid = width(); | 366 | int wid = width(); |
367 | if ( wid < 10 ) | 367 | if ( wid < 10 ) |
368 | wid = 400; | 368 | wid = 400; |
369 | #else | 369 | #else |
370 | int wid = QApplication::desktop()->width(); | 370 | int wid = QApplication::desktop()->width(); |
371 | if ( wid < 640 ) | 371 | if ( wid < 640 ) |
372 | wid = QApplication::desktop()->height(); | 372 | wid = QApplication::desktop()->height(); |
373 | #endif | 373 | #endif |
374 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 374 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
375 | if ( true /*splitterSize.count() == 0*/ ) { | 375 | if ( true /*splitterSize.count() == 0*/ ) { |
376 | splitterSize.append( wid / 2 ); | 376 | splitterSize.append( wid / 2 ); |
377 | splitterSize.append( wid / 2 ); | 377 | splitterSize.append( wid / 2 ); |
378 | } | 378 | } |
379 | mMiniSplitter->setSizes( splitterSize ); | 379 | mMiniSplitter->setSizes( splitterSize ); |
380 | if ( mExtensionBarSplitter ) { | 380 | if ( mExtensionBarSplitter ) { |
381 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 381 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
382 | if ( true /*splitterSize.count() == 0*/ ) { | 382 | if ( true /*splitterSize.count() == 0*/ ) { |
383 | splitterSize.append( wid / 2 ); | 383 | splitterSize.append( wid / 2 ); |
384 | splitterSize.append( wid / 2 ); | 384 | splitterSize.append( wid / 2 ); |
385 | } | 385 | } |
386 | mExtensionBarSplitter->setSizes( splitterSize ); | 386 | mExtensionBarSplitter->setSizes( splitterSize ); |
387 | 387 | ||
388 | } | 388 | } |
389 | 389 | ||
390 | 390 | ||
391 | } | 391 | } |
392 | 392 | ||
393 | void KABCore::saveSettings() | 393 | void KABCore::saveSettings() |
394 | { | 394 | { |
395 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 395 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
396 | if ( mExtensionBarSplitter ) | 396 | if ( mExtensionBarSplitter ) |
397 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 397 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
398 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 398 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
399 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 399 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
400 | #ifndef KAB_EMBEDDED | 400 | #ifndef KAB_EMBEDDED |
401 | 401 | ||
402 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 402 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
403 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 403 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
404 | #endif //KAB_EMBEDDED | 404 | #endif //KAB_EMBEDDED |
405 | mExtensionManager->saveSettings(); | 405 | mExtensionManager->saveSettings(); |
406 | mViewManager->saveSettings(); | 406 | mViewManager->saveSettings(); |
407 | 407 | ||
408 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 408 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
409 | } | 409 | } |
410 | 410 | ||
411 | KABC::AddressBook *KABCore::addressBook() const | 411 | KABC::AddressBook *KABCore::addressBook() const |
412 | { | 412 | { |
413 | return mAddressBook; | 413 | return mAddressBook; |
414 | } | 414 | } |
415 | 415 | ||
416 | KConfig *KABCore::config() | 416 | KConfig *KABCore::config() |
417 | { | 417 | { |
418 | #ifndef KAB_EMBEDDED | 418 | #ifndef KAB_EMBEDDED |
419 | return KABPrefs::instance()->config(); | 419 | return KABPrefs::instance()->config(); |
420 | #else //KAB_EMBEDDED | 420 | #else //KAB_EMBEDDED |
421 | return KABPrefs::instance()->getConfig(); | 421 | return KABPrefs::instance()->getConfig(); |
422 | #endif //KAB_EMBEDDED | 422 | #endif //KAB_EMBEDDED |
423 | } | 423 | } |
424 | 424 | ||
425 | KActionCollection *KABCore::actionCollection() const | 425 | KActionCollection *KABCore::actionCollection() const |
426 | { | 426 | { |
427 | return mGUIClient->actionCollection(); | 427 | return mGUIClient->actionCollection(); |
428 | } | 428 | } |
429 | 429 | ||
430 | KABC::Field *KABCore::currentSearchField() const | 430 | KABC::Field *KABCore::currentSearchField() const |
431 | { | 431 | { |
432 | if (mIncSearchWidget) | 432 | if (mIncSearchWidget) |
433 | return mIncSearchWidget->currentField(); | 433 | return mIncSearchWidget->currentField(); |
434 | else | 434 | else |
435 | return 0; | 435 | return 0; |
436 | } | 436 | } |
437 | 437 | ||
438 | QStringList KABCore::selectedUIDs() const | 438 | QStringList KABCore::selectedUIDs() const |
439 | { | 439 | { |
440 | return mViewManager->selectedUids(); | 440 | return mViewManager->selectedUids(); |
441 | } | 441 | } |
442 | 442 | ||
443 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 443 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
444 | { | 444 | { |
445 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 445 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
446 | 446 | ||
447 | QPtrList<KRES::Resource> kresResources; | 447 | QPtrList<KRES::Resource> kresResources; |
448 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 448 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
449 | KABC::Resource *resource; | 449 | KABC::Resource *resource; |
450 | while ( ( resource = resIt.current() ) != 0 ) { | 450 | while ( ( resource = resIt.current() ) != 0 ) { |
451 | ++resIt; | 451 | ++resIt; |
452 | if ( !resource->readOnly() ) { | 452 | if ( !resource->readOnly() ) { |
453 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 453 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
454 | if ( res ) | 454 | if ( res ) |
455 | kresResources.append( res ); | 455 | kresResources.append( res ); |
456 | } | 456 | } |
457 | } | 457 | } |
458 | 458 | ||
459 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 459 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
460 | return static_cast<KABC::Resource*>( res ); | 460 | return static_cast<KABC::Resource*>( res ); |
461 | } | 461 | } |
462 | 462 | ||
463 | #ifndef KAB_EMBEDDED | 463 | #ifndef KAB_EMBEDDED |
464 | KAboutData *KABCore::createAboutData() | 464 | KAboutData *KABCore::createAboutData() |
465 | #else //KAB_EMBEDDED | 465 | #else //KAB_EMBEDDED |
466 | void KABCore::createAboutData() | 466 | void KABCore::createAboutData() |
467 | #endif //KAB_EMBEDDED | 467 | #endif //KAB_EMBEDDED |
468 | { | 468 | { |
469 | #ifndef KAB_EMBEDDED | 469 | #ifndef KAB_EMBEDDED |
470 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 470 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
471 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 471 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
472 | KAboutData::License_GPL_V2, | 472 | KAboutData::License_GPL_V2, |
473 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 473 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
474 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 474 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
475 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 475 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
476 | about->addAuthor( "Cornelius Schumacher", | 476 | about->addAuthor( "Cornelius Schumacher", |
477 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 477 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
478 | "schumacher@kde.org" ); | 478 | "schumacher@kde.org" ); |
479 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 479 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
480 | "mpilone@slac.com" ); | 480 | "mpilone@slac.com" ); |
481 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 481 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
482 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 482 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
483 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 483 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
484 | "michel@klaralvdalens-datakonsult.se" ); | 484 | "michel@klaralvdalens-datakonsult.se" ); |
485 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 485 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
486 | "hansen@kde.org" ); | 486 | "hansen@kde.org" ); |
487 | 487 | ||
488 | return about; | 488 | return about; |
489 | #endif //KAB_EMBEDDED | 489 | #endif //KAB_EMBEDDED |
490 | 490 | ||
491 | QString version; | 491 | QString version; |
492 | #include <../version> | 492 | #include <../version> |
493 | QMessageBox::about( this, "About KAddressbook/Pi", | 493 | QMessageBox::about( this, "About KAddressbook/Pi", |
494 | "KAddressbook/Platform-independent\n" | 494 | "KAddressbook/Platform-independent\n" |
495 | "(KA/Pi) " +version + " - " + | 495 | "(KA/Pi) " +version + " - " + |
496 | #ifdef DESKTOP_VERSION | 496 | #ifdef DESKTOP_VERSION |
497 | "Desktop Edition\n" | 497 | "Desktop Edition\n" |
498 | #else | 498 | #else |
499 | "PDA-Edition\n" | 499 | "PDA-Edition\n" |
500 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 500 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
501 | #endif | 501 | #endif |
502 | 502 | ||
503 | "(c) 2004 Ulf Schenk\n" | 503 | "(c) 2004 Ulf Schenk\n" |
504 | "(c) 2004 Lutz Rogowski\n" | 504 | "(c) 2004 Lutz Rogowski\n" |
505 | "(c) 1997-2003, The KDE PIM Team\n" | 505 | "(c) 1997-2003, The KDE PIM Team\n" |
506 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 506 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
507 | "Don Sanders Original author\n" | 507 | "Don Sanders Original author\n" |
508 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 508 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
509 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 509 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
510 | "Greg Stern DCOP interface\n" | 510 | "Greg Stern DCOP interface\n" |
511 | "Mark Westcot Contact pinning\n" | 511 | "Mark Westcot Contact pinning\n" |
512 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 512 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
513 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 513 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
514 | #ifdef _WIN32_ | 514 | #ifdef _WIN32_ |
515 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 515 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
516 | #endif | 516 | #endif |
517 | ); | 517 | ); |
518 | } | 518 | } |
519 | 519 | ||
520 | void KABCore::setContactSelected( const QString &uid ) | 520 | void KABCore::setContactSelected( const QString &uid ) |
521 | { | 521 | { |
522 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 522 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
523 | if ( !mDetails->isHidden() ) | 523 | if ( !mDetails->isHidden() ) |
524 | mDetails->setAddressee( addr ); | 524 | mDetails->setAddressee( addr ); |
525 | 525 | ||
526 | if ( !addr.isEmpty() ) { | 526 | if ( !addr.isEmpty() ) { |
527 | emit contactSelected( addr.formattedName() ); | 527 | emit contactSelected( addr.formattedName() ); |
528 | KABC::Picture pic = addr.photo(); | 528 | KABC::Picture pic = addr.photo(); |
529 | if ( pic.isIntern() ) { | 529 | if ( pic.isIntern() ) { |
530 | //US emit contactSelected( pic.data() ); | 530 | //US emit contactSelected( pic.data() ); |
531 | //US instead use: | 531 | //US instead use: |
532 | QPixmap px; | 532 | QPixmap px; |
533 | if (pic.data().isNull() != true) | 533 | if (pic.data().isNull() != true) |
534 | { | 534 | { |
535 | px.convertFromImage(pic.data()); | 535 | px.convertFromImage(pic.data()); |
536 | } | 536 | } |
537 | 537 | ||
538 | emit contactSelected( px ); | 538 | emit contactSelected( px ); |
539 | } | 539 | } |
540 | } | 540 | } |
541 | 541 | ||
542 | 542 | ||
543 | mExtensionManager->setSelectionChanged(); | 543 | mExtensionManager->setSelectionChanged(); |
544 | 544 | ||
545 | // update the actions | 545 | // update the actions |
546 | bool selected = !uid.isEmpty(); | 546 | bool selected = !uid.isEmpty(); |
547 | 547 | ||
548 | if ( mReadWrite ) { | 548 | if ( mReadWrite ) { |
549 | mActionCut->setEnabled( selected ); | 549 | mActionCut->setEnabled( selected ); |
550 | mActionPaste->setEnabled( selected ); | 550 | mActionPaste->setEnabled( selected ); |
551 | } | 551 | } |
552 | 552 | ||
553 | mActionCopy->setEnabled( selected ); | 553 | mActionCopy->setEnabled( selected ); |
554 | mActionDelete->setEnabled( selected ); | 554 | mActionDelete->setEnabled( selected ); |
555 | mActionEditAddressee->setEnabled( selected ); | 555 | mActionEditAddressee->setEnabled( selected ); |
556 | mActionMail->setEnabled( selected ); | 556 | mActionMail->setEnabled( selected ); |
557 | mActionMailVCard->setEnabled( selected ); | 557 | mActionMailVCard->setEnabled( selected ); |
558 | //if (mActionBeam) | 558 | //if (mActionBeam) |
559 | //mActionBeam->setEnabled( selected ); | 559 | //mActionBeam->setEnabled( selected ); |
560 | 560 | ||
561 | if (mActionBeamVCard) | 561 | if (mActionBeamVCard) |
562 | mActionBeamVCard->setEnabled( selected ); | 562 | mActionBeamVCard->setEnabled( selected ); |
563 | 563 | ||
564 | mActionExport2phone->setEnabled( selected ); | 564 | mActionExport2phone->setEnabled( selected ); |
565 | mActionWhoAmI->setEnabled( selected ); | 565 | mActionWhoAmI->setEnabled( selected ); |
566 | mActionCategories->setEnabled( selected ); | 566 | mActionCategories->setEnabled( selected ); |
567 | } | 567 | } |
568 | 568 | ||
569 | void KABCore::sendMail() | 569 | void KABCore::sendMail() |
570 | { | 570 | { |
571 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 571 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
572 | } | 572 | } |
573 | 573 | ||
574 | void KABCore::sendMail( const QString& emaillist ) | 574 | void KABCore::sendMail( const QString& emaillist ) |
575 | { | 575 | { |
576 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 576 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
577 | if (emaillist.contains(",") > 0) | 577 | if (emaillist.contains(",") > 0) |
578 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 578 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
579 | else | 579 | else |
580 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 580 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
581 | } | 581 | } |
582 | 582 | ||
583 | 583 | ||
584 | 584 | ||
585 | void KABCore::mailVCard() | 585 | void KABCore::mailVCard() |
586 | { | 586 | { |
587 | QStringList uids = mViewManager->selectedUids(); | 587 | QStringList uids = mViewManager->selectedUids(); |
588 | if ( !uids.isEmpty() ) | 588 | if ( !uids.isEmpty() ) |
589 | mailVCard( uids ); | 589 | mailVCard( uids ); |
590 | } | 590 | } |
591 | 591 | ||
592 | void KABCore::mailVCard( const QStringList& uids ) | 592 | void KABCore::mailVCard( const QStringList& uids ) |
593 | { | 593 | { |
594 | QStringList urls; | 594 | QStringList urls; |
595 | 595 | ||
596 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 596 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
597 | 597 | ||
598 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 598 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
599 | 599 | ||
600 | 600 | ||
601 | 601 | ||
602 | QDir().mkdir( dirName, true ); | 602 | QDir().mkdir( dirName, true ); |
603 | 603 | ||
604 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 604 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
605 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 605 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
606 | 606 | ||
607 | if ( a.isEmpty() ) | 607 | if ( a.isEmpty() ) |
608 | continue; | 608 | continue; |
609 | 609 | ||
610 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 610 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
611 | 611 | ||
612 | QString fileName = dirName + "/" + name; | 612 | QString fileName = dirName + "/" + name; |
613 | 613 | ||
614 | QFile outFile(fileName); | 614 | QFile outFile(fileName); |
615 | 615 | ||
616 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 616 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
617 | KABC::VCardConverter converter; | 617 | KABC::VCardConverter converter; |
618 | QString vcard; | 618 | QString vcard; |
619 | 619 | ||
620 | converter.addresseeToVCard( a, vcard ); | 620 | converter.addresseeToVCard( a, vcard ); |
621 | 621 | ||
622 | QTextStream t( &outFile ); // use a text stream | 622 | QTextStream t( &outFile ); // use a text stream |
623 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 623 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
624 | t << vcard; | 624 | t << vcard; |
625 | 625 | ||
626 | outFile.close(); | 626 | outFile.close(); |
627 | 627 | ||
628 | urls.append( fileName ); | 628 | urls.append( fileName ); |
629 | } | 629 | } |
630 | } | 630 | } |
631 | 631 | ||
632 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 632 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
633 | 633 | ||
634 | 634 | ||
635 | /*US | 635 | /*US |
636 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 636 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
637 | QString::null, // subject | 637 | QString::null, // subject |
638 | QString::null, // body | 638 | QString::null, // body |
639 | QString::null, | 639 | QString::null, |
640 | urls ); // attachments | 640 | urls ); // attachments |
641 | */ | 641 | */ |
642 | 642 | ||
643 | } | 643 | } |
644 | 644 | ||
645 | /** | 645 | /** |
646 | Beams the "WhoAmI contact. | 646 | Beams the "WhoAmI contact. |
647 | */ | 647 | */ |
648 | void KABCore::beamMySelf() | 648 | void KABCore::beamMySelf() |
649 | { | 649 | { |
650 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 650 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
651 | if (!a.isEmpty()) | 651 | if (!a.isEmpty()) |
652 | { | 652 | { |
653 | QStringList uids; | 653 | QStringList uids; |
654 | uids << a.uid(); | 654 | uids << a.uid(); |
655 | 655 | ||
656 | beamVCard(uids); | 656 | beamVCard(uids); |
657 | } else { | 657 | } else { |
658 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 658 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
659 | 659 | ||
660 | 660 | ||
661 | } | 661 | } |
662 | } | 662 | } |
663 | 663 | ||
664 | void KABCore::export2phone() | 664 | void KABCore::export2phone() |
665 | { | 665 | { |
666 | 666 | ||
667 | KAex2phonePrefs ex2phone; | 667 | KAex2phonePrefs ex2phone; |
668 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 668 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
669 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 669 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
670 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 670 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
671 | 671 | ||
672 | if ( !ex2phone.exec() ) { | 672 | if ( !ex2phone.exec() ) { |
673 | return; | 673 | return; |
674 | } | 674 | } |
675 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 675 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
676 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 676 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
677 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 677 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
678 | 678 | ||
679 | 679 | ||
680 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 680 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
681 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 681 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
682 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 682 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
683 | 683 | ||
684 | QStringList uids = mViewManager->selectedUids(); | 684 | QStringList uids = mViewManager->selectedUids(); |
685 | if ( uids.isEmpty() ) | 685 | if ( uids.isEmpty() ) |
686 | return; | 686 | return; |
687 | 687 | ||
688 | #ifdef _WIN32_ | 688 | #ifdef _WIN32_ |
689 | QString fileName = locateLocal("tmp", "tempfile.vcf"); | 689 | QString fileName = locateLocal("tmp", "tempfile.vcf"); |
690 | #else | 690 | #else |
691 | QString fileName = "/tmp/kdepimtemp.vcf"; | 691 | QString fileName = "/tmp/kdepimtemp.vcf"; |
692 | #endif | 692 | #endif |
693 | 693 | ||
694 | KABC::VCardConverter converter; | 694 | KABC::VCardConverter converter; |
695 | QString description; | 695 | QString description; |
696 | QString datastream; | 696 | QString datastream; |
697 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 697 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
698 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 698 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
699 | 699 | ||
700 | if ( a.isEmpty() ) | 700 | if ( a.isEmpty() ) |
701 | continue; | 701 | continue; |
702 | a.simplifyEmails(); | ||
703 | a.simplifyPhoneNumbers(); | ||
704 | a.simplifyPhoneNumberTypes(); | ||
702 | 705 | ||
703 | if (description.isEmpty()) | 706 | if (description.isEmpty()) |
704 | description = a.formattedName(); | 707 | description = a.formattedName(); |
705 | |||
706 | QString vcard; | 708 | QString vcard; |
709 | QString vcardnew; | ||
707 | converter.addresseeToVCard( a, vcard ); | 710 | converter.addresseeToVCard( a, vcard ); |
708 | int start = 0; | 711 | int start = 0; |
709 | int next; | 712 | int next; |
710 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 713 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
711 | int semi = vcard.find(";", next); | 714 | int semi = vcard.find(";", next); |
712 | int dopp = vcard.find(":", next); | 715 | int dopp = vcard.find(":", next); |
713 | int sep; | 716 | int sep; |
714 | if ( semi < dopp && semi >= 0 ) | 717 | if ( semi < dopp && semi >= 0 ) |
715 | sep = semi ; | 718 | sep = semi ; |
716 | else | 719 | else |
717 | sep = dopp; | 720 | sep = dopp; |
718 | datastream +=vcard.mid( start, next - start); | 721 | vcardnew +=vcard.mid( start, next - start); |
719 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 722 | vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); |
720 | start = sep; | 723 | start = sep; |
721 | } | 724 | } |
722 | datastream += vcard.mid( start,vcard.length() ); | 725 | vcardnew += vcard.mid( start,vcard.length() ); |
726 | vcard = ""; | ||
727 | start = 0; | ||
728 | while ( (next = vcardnew.find("ADR", start) )>= 0 ) { | ||
729 | int sep = vcardnew.find(":", next); | ||
730 | vcard +=vcardnew.mid( start, next - start+3); | ||
731 | start = sep; | ||
732 | } | ||
733 | vcard += vcardnew.mid( start,vcardnew.length() ); | ||
734 | vcard.replace ( QRegExp(";;;") , "" ); | ||
735 | vcard.replace ( QRegExp(";;") , "" ); | ||
736 | datastream += vcard; | ||
737 | |||
723 | } | 738 | } |
724 | QFile outFile(fileName); | 739 | QFile outFile(fileName); |
725 | if ( outFile.open(IO_WriteOnly) ) { | 740 | if ( outFile.open(IO_WriteOnly) ) { |
726 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 741 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
727 | QTextStream t( &outFile ); // use a text stream | 742 | QTextStream t( &outFile ); // use a text stream |
728 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 743 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
729 | t <<datastream; | 744 | t <<datastream; |
730 | outFile.close(); | 745 | outFile.close(); |
731 | if ( PhoneAccess::writeToPhone( fileName ) ) | 746 | if ( PhoneAccess::writeToPhone( fileName ) ) |
732 | qDebug("Export okay "); | 747 | qDebug("Export okay "); |
733 | else | 748 | else |
734 | qDebug("Error export contacts "); | 749 | qDebug("Error export contacts "); |
735 | 750 | ||
736 | } else { | 751 | } else { |
737 | qDebug("Error open temp file "); | 752 | qDebug("Error open temp file "); |
738 | return; | 753 | return; |
739 | } | 754 | } |
740 | 755 | ||
741 | 756 | ||
742 | #if 0 | 757 | #if 0 |
743 | 758 | ||
744 | setCaption( i18n("Writing to phone...")); | 759 | setCaption( i18n("Writing to phone...")); |
745 | if ( PhoneFormat::writeToPhone( cal ) ) | 760 | if ( PhoneFormat::writeToPhone( cal ) ) |
746 | setCaption( i18n("Export to phone successful!")); | 761 | setCaption( i18n("Export to phone successful!")); |
747 | else | 762 | else |
748 | setCaption( i18n("Error exporting to phone!")); | 763 | setCaption( i18n("Error exporting to phone!")); |
749 | #endif | 764 | #endif |
750 | 765 | ||
751 | 766 | ||
752 | } | 767 | } |
753 | void KABCore::beamVCard() | 768 | void KABCore::beamVCard() |
754 | { | 769 | { |
755 | QStringList uids = mViewManager->selectedUids(); | 770 | QStringList uids = mViewManager->selectedUids(); |
756 | if ( !uids.isEmpty() ) | 771 | if ( !uids.isEmpty() ) |
757 | beamVCard( uids ); | 772 | beamVCard( uids ); |
758 | } | 773 | } |
759 | 774 | ||
760 | 775 | ||
761 | void KABCore::beamVCard(const QStringList& uids) | 776 | void KABCore::beamVCard(const QStringList& uids) |
762 | { | 777 | { |
763 | /*US | 778 | /*US |
764 | QString beamFilename; | 779 | QString beamFilename; |
765 | Opie::OPimContact c; | 780 | Opie::OPimContact c; |
766 | if ( actionPersonal->isOn() ) { | 781 | if ( actionPersonal->isOn() ) { |
767 | beamFilename = addressbookPersonalVCardName(); | 782 | beamFilename = addressbookPersonalVCardName(); |
768 | if ( !QFile::exists( beamFilename ) ) | 783 | if ( !QFile::exists( beamFilename ) ) |
769 | return; // can't beam a non-existent file | 784 | return; // can't beam a non-existent file |
770 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 785 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
771 | beamFilename ); | 786 | beamFilename ); |
772 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 787 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
773 | Opie::OPimContactAccess::List allList = access->allRecords(); | 788 | Opie::OPimContactAccess::List allList = access->allRecords(); |
774 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first | 789 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first |
775 | c = *it; | 790 | c = *it; |
776 | 791 | ||
777 | delete access; | 792 | delete access; |
778 | } else { | 793 | } else { |
779 | unlink( beamfile ); // delete if exists | 794 | unlink( beamfile ); // delete if exists |
780 | mkdir("/tmp/obex/", 0755); | 795 | mkdir("/tmp/obex/", 0755); |
781 | c = m_abView -> currentEntry(); | 796 | c = m_abView -> currentEntry(); |
782 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 797 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
783 | beamfile ); | 798 | beamfile ); |
784 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 799 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
785 | access->add( c ); | 800 | access->add( c ); |
786 | access->save(); | 801 | access->save(); |
787 | delete access; | 802 | delete access; |
788 | 803 | ||
789 | beamFilename = beamfile; | 804 | beamFilename = beamfile; |
790 | } | 805 | } |
791 | 806 | ||
792 | owarn << "Beaming: " << beamFilename << oendl; | 807 | owarn << "Beaming: " << beamFilename << oendl; |
793 | */ | 808 | */ |
794 | 809 | ||
795 | #if 0 | 810 | #if 0 |
796 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 811 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
797 | 812 | ||
798 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); | 813 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); |
799 | 814 | ||
800 | QString name = "contact.vcf"; | 815 | QString name = "contact.vcf"; |
801 | 816 | ||
802 | QString fileName = dirName + "/" + name; | 817 | QString fileName = dirName + "/" + name; |
803 | #endif | 818 | #endif |
804 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory | 819 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory |
805 | // | 820 | // |
806 | QString fileName = "/tmp/kapibeamfile.vcf"; | 821 | QString fileName = "/tmp/kapibeamfile.vcf"; |
807 | 822 | ||
808 | 823 | ||
809 | //QDir().mkdir( dirName, true ); | 824 | //QDir().mkdir( dirName, true ); |
810 | 825 | ||
811 | 826 | ||
812 | KABC::VCardConverter converter; | 827 | KABC::VCardConverter converter; |
813 | QString description; | 828 | QString description; |
814 | QString datastream; | 829 | QString datastream; |
815 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 830 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
816 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 831 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
817 | 832 | ||
818 | if ( a.isEmpty() ) | 833 | if ( a.isEmpty() ) |
819 | continue; | 834 | continue; |
820 | 835 | ||
821 | if (description.isEmpty()) | 836 | if (description.isEmpty()) |
822 | description = a.formattedName(); | 837 | description = a.formattedName(); |
823 | 838 | ||
824 | QString vcard; | 839 | QString vcard; |
825 | converter.addresseeToVCard( a, vcard ); | 840 | converter.addresseeToVCard( a, vcard ); |
826 | int start = 0; | 841 | int start = 0; |
827 | int next; | 842 | int next; |
828 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 843 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
829 | int semi = vcard.find(";", next); | 844 | int semi = vcard.find(";", next); |
830 | int dopp = vcard.find(":", next); | 845 | int dopp = vcard.find(":", next); |
831 | int sep; | 846 | int sep; |
832 | if ( semi < dopp && semi >= 0 ) | 847 | if ( semi < dopp && semi >= 0 ) |
833 | sep = semi ; | 848 | sep = semi ; |
834 | else | 849 | else |
835 | sep = dopp; | 850 | sep = dopp; |
836 | datastream +=vcard.mid( start, next - start); | 851 | datastream +=vcard.mid( start, next - start); |
837 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 852 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
838 | start = sep; | 853 | start = sep; |
839 | } | 854 | } |
840 | datastream += vcard.mid( start,vcard.length() ); | 855 | datastream += vcard.mid( start,vcard.length() ); |
841 | } | 856 | } |
842 | #ifndef DESKTOP_VERSION | 857 | #ifndef DESKTOP_VERSION |
843 | QFile outFile(fileName); | 858 | QFile outFile(fileName); |
844 | if ( outFile.open(IO_WriteOnly) ) { | 859 | if ( outFile.open(IO_WriteOnly) ) { |
845 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 860 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
846 | QTextStream t( &outFile ); // use a text stream | 861 | QTextStream t( &outFile ); // use a text stream |
847 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 862 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
848 | t <<datastream; | 863 | t <<datastream; |
849 | outFile.close(); | 864 | outFile.close(); |
850 | Ir *ir = new Ir( this ); | 865 | Ir *ir = new Ir( this ); |
851 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 866 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
852 | ir->send( fileName, description, "text/x-vCard" ); | 867 | ir->send( fileName, description, "text/x-vCard" ); |
853 | } else { | 868 | } else { |
854 | qDebug("Error open temp beam file "); | 869 | qDebug("Error open temp beam file "); |
855 | return; | 870 | return; |
856 | } | 871 | } |
857 | #endif | 872 | #endif |
858 | 873 | ||
859 | } | 874 | } |
860 | 875 | ||
861 | void KABCore::beamDone( Ir *ir ) | 876 | void KABCore::beamDone( Ir *ir ) |
862 | { | 877 | { |
863 | #ifndef DESKTOP_VERSION | 878 | #ifndef DESKTOP_VERSION |
864 | delete ir; | 879 | delete ir; |
865 | #endif | 880 | #endif |
866 | } | 881 | } |
867 | 882 | ||
868 | 883 | ||
869 | void KABCore::browse( const QString& url ) | 884 | void KABCore::browse( const QString& url ) |
870 | { | 885 | { |
871 | #ifndef KAB_EMBEDDED | 886 | #ifndef KAB_EMBEDDED |
872 | kapp->invokeBrowser( url ); | 887 | kapp->invokeBrowser( url ); |
873 | #else //KAB_EMBEDDED | 888 | #else //KAB_EMBEDDED |
874 | qDebug("KABCore::browse must be fixed"); | 889 | qDebug("KABCore::browse must be fixed"); |
875 | #endif //KAB_EMBEDDED | 890 | #endif //KAB_EMBEDDED |
876 | } | 891 | } |
877 | 892 | ||
878 | void KABCore::selectAllContacts() | 893 | void KABCore::selectAllContacts() |
879 | { | 894 | { |
880 | mViewManager->setSelected( QString::null, true ); | 895 | mViewManager->setSelected( QString::null, true ); |
881 | } | 896 | } |
882 | 897 | ||
883 | void KABCore::deleteContacts() | 898 | void KABCore::deleteContacts() |
884 | { | 899 | { |
885 | QStringList uidList = mViewManager->selectedUids(); | 900 | QStringList uidList = mViewManager->selectedUids(); |
886 | deleteContacts( uidList ); | 901 | deleteContacts( uidList ); |
887 | } | 902 | } |
888 | 903 | ||
889 | void KABCore::deleteContacts( const QStringList &uids ) | 904 | void KABCore::deleteContacts( const QStringList &uids ) |
890 | { | 905 | { |
891 | if ( uids.count() > 0 ) { | 906 | if ( uids.count() > 0 ) { |
892 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 907 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
893 | UndoStack::instance()->push( command ); | 908 | UndoStack::instance()->push( command ); |
894 | RedoStack::instance()->clear(); | 909 | RedoStack::instance()->clear(); |
895 | 910 | ||
896 | // now if we deleted anything, refresh | 911 | // now if we deleted anything, refresh |
897 | setContactSelected( QString::null ); | 912 | setContactSelected( QString::null ); |
898 | setModified( true ); | 913 | setModified( true ); |
899 | } | 914 | } |
900 | } | 915 | } |
901 | 916 | ||
902 | void KABCore::copyContacts() | 917 | void KABCore::copyContacts() |
903 | { | 918 | { |
904 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 919 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
905 | 920 | ||
906 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 921 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
907 | 922 | ||
908 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 923 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
909 | 924 | ||
910 | QClipboard *cb = QApplication::clipboard(); | 925 | QClipboard *cb = QApplication::clipboard(); |
911 | cb->setText( clipText ); | 926 | cb->setText( clipText ); |
912 | } | 927 | } |
913 | 928 | ||
914 | void KABCore::cutContacts() | 929 | void KABCore::cutContacts() |
915 | { | 930 | { |
916 | QStringList uidList = mViewManager->selectedUids(); | 931 | QStringList uidList = mViewManager->selectedUids(); |
917 | 932 | ||
918 | //US if ( uidList.size() > 0 ) { | 933 | //US if ( uidList.size() > 0 ) { |
919 | if ( uidList.count() > 0 ) { | 934 | if ( uidList.count() > 0 ) { |
920 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 935 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
921 | UndoStack::instance()->push( command ); | 936 | UndoStack::instance()->push( command ); |
922 | RedoStack::instance()->clear(); | 937 | RedoStack::instance()->clear(); |
923 | 938 | ||
924 | setModified( true ); | 939 | setModified( true ); |
925 | } | 940 | } |
926 | } | 941 | } |
927 | 942 | ||
928 | void KABCore::pasteContacts() | 943 | void KABCore::pasteContacts() |
929 | { | 944 | { |
930 | QClipboard *cb = QApplication::clipboard(); | 945 | QClipboard *cb = QApplication::clipboard(); |
931 | 946 | ||
932 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 947 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
933 | 948 | ||
934 | pasteContacts( list ); | 949 | pasteContacts( list ); |
935 | } | 950 | } |
936 | 951 | ||
937 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 952 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
938 | { | 953 | { |
939 | KABC::Resource *resource = requestResource( this ); | 954 | KABC::Resource *resource = requestResource( this ); |
940 | KABC::Addressee::List::Iterator it; | 955 | KABC::Addressee::List::Iterator it; |
941 | for ( it = list.begin(); it != list.end(); ++it ) | 956 | for ( it = list.begin(); it != list.end(); ++it ) |
942 | (*it).setResource( resource ); | 957 | (*it).setResource( resource ); |
943 | 958 | ||
944 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 959 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
945 | UndoStack::instance()->push( command ); | 960 | UndoStack::instance()->push( command ); |
946 | RedoStack::instance()->clear(); | 961 | RedoStack::instance()->clear(); |
947 | 962 | ||
948 | setModified( true ); | 963 | setModified( true ); |
949 | } | 964 | } |
950 | 965 | ||
951 | void KABCore::setWhoAmI() | 966 | void KABCore::setWhoAmI() |
952 | { | 967 | { |
953 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 968 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
954 | 969 | ||
955 | if ( addrList.count() > 1 ) { | 970 | if ( addrList.count() > 1 ) { |
956 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 971 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
957 | return; | 972 | return; |
958 | } | 973 | } |
959 | 974 | ||
960 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 975 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
961 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 976 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
962 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 977 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
963 | } | 978 | } |
964 | 979 | ||
965 | void KABCore::setCategories() | 980 | void KABCore::setCategories() |
966 | { | 981 | { |
967 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 982 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
968 | if ( !dlg.exec() ) | 983 | if ( !dlg.exec() ) |
969 | return; | 984 | return; |
970 | 985 | ||
971 | bool merge = false; | 986 | bool merge = false; |
972 | QString msg = i18n( "Merge with existing categories?" ); | 987 | QString msg = i18n( "Merge with existing categories?" ); |
973 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 988 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
974 | merge = true; | 989 | merge = true; |
975 | 990 | ||
976 | QStringList categories = dlg.selectedCategories(); | 991 | QStringList categories = dlg.selectedCategories(); |
977 | 992 | ||
978 | QStringList uids = mViewManager->selectedUids(); | 993 | QStringList uids = mViewManager->selectedUids(); |
979 | QStringList::Iterator it; | 994 | QStringList::Iterator it; |
980 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 995 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
981 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 996 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
982 | if ( !addr.isEmpty() ) { | 997 | if ( !addr.isEmpty() ) { |
983 | if ( !merge ) | 998 | if ( !merge ) |
984 | addr.setCategories( categories ); | 999 | addr.setCategories( categories ); |
985 | else { | 1000 | else { |
986 | QStringList addrCategories = addr.categories(); | 1001 | QStringList addrCategories = addr.categories(); |
987 | QStringList::Iterator catIt; | 1002 | QStringList::Iterator catIt; |
988 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 1003 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
989 | if ( !addrCategories.contains( *catIt ) ) | 1004 | if ( !addrCategories.contains( *catIt ) ) |
990 | addrCategories.append( *catIt ); | 1005 | addrCategories.append( *catIt ); |
991 | } | 1006 | } |
992 | addr.setCategories( addrCategories ); | 1007 | addr.setCategories( addrCategories ); |
993 | } | 1008 | } |
994 | 1009 | ||
995 | mAddressBook->insertAddressee( addr ); | 1010 | mAddressBook->insertAddressee( addr ); |
996 | } | 1011 | } |
997 | } | 1012 | } |
998 | 1013 | ||
999 | if ( uids.count() > 0 ) | 1014 | if ( uids.count() > 0 ) |
1000 | setModified( true ); | 1015 | setModified( true ); |
1001 | } | 1016 | } |
1002 | 1017 | ||
1003 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 1018 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
1004 | { | 1019 | { |
1005 | mIncSearchWidget->setFields( fields ); | 1020 | mIncSearchWidget->setFields( fields ); |
1006 | } | 1021 | } |
1007 | 1022 | ||
1008 | void KABCore::incrementalSearch( const QString& text ) | 1023 | void KABCore::incrementalSearch( const QString& text ) |
1009 | { | 1024 | { |
1010 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 1025 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
1011 | } | 1026 | } |
1012 | 1027 | ||
1013 | void KABCore::setModified() | 1028 | void KABCore::setModified() |
1014 | { | 1029 | { |
1015 | setModified( true ); | 1030 | setModified( true ); |
1016 | } | 1031 | } |
1017 | 1032 | ||
1018 | void KABCore::setModifiedWOrefresh() | 1033 | void KABCore::setModifiedWOrefresh() |
1019 | { | 1034 | { |
1020 | // qDebug("KABCore::setModifiedWOrefresh() "); | 1035 | // qDebug("KABCore::setModifiedWOrefresh() "); |
1021 | mModified = true; | 1036 | mModified = true; |
1022 | mActionSave->setEnabled( mModified ); | 1037 | mActionSave->setEnabled( mModified ); |
1023 | #ifdef DESKTOP_VERSION | 1038 | #ifdef DESKTOP_VERSION |
1024 | mDetails->refreshView(); | 1039 | mDetails->refreshView(); |
1025 | #endif | 1040 | #endif |
1026 | 1041 | ||
1027 | } | 1042 | } |
1028 | void KABCore::setModified( bool modified ) | 1043 | void KABCore::setModified( bool modified ) |
1029 | { | 1044 | { |
1030 | mModified = modified; | 1045 | mModified = modified; |
1031 | mActionSave->setEnabled( mModified ); | 1046 | mActionSave->setEnabled( mModified ); |
1032 | 1047 | ||
1033 | if ( modified ) | 1048 | if ( modified ) |
1034 | mJumpButtonBar->recreateButtons(); | 1049 | mJumpButtonBar->recreateButtons(); |
1035 | 1050 | ||
1036 | mViewManager->refreshView(); | 1051 | mViewManager->refreshView(); |
1037 | mDetails->refreshView(); | 1052 | mDetails->refreshView(); |
1038 | 1053 | ||
1039 | } | 1054 | } |
1040 | 1055 | ||
1041 | bool KABCore::modified() const | 1056 | bool KABCore::modified() const |
1042 | { | 1057 | { |
1043 | return mModified; | 1058 | return mModified; |
1044 | } | 1059 | } |
1045 | 1060 | ||
1046 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1061 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1047 | { | 1062 | { |
1048 | 1063 | ||
1049 | Command *command = 0; | 1064 | Command *command = 0; |
1050 | QString uid; | 1065 | QString uid; |
1051 | 1066 | ||
1052 | // check if it exists already | 1067 | // check if it exists already |
1053 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1068 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1054 | if ( origAddr.isEmpty() ) | 1069 | if ( origAddr.isEmpty() ) |
1055 | command = new PwNewCommand( mAddressBook, addr ); | 1070 | command = new PwNewCommand( mAddressBook, addr ); |
1056 | else { | 1071 | else { |
1057 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1072 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1058 | uid = addr.uid(); | 1073 | uid = addr.uid(); |
1059 | } | 1074 | } |
1060 | 1075 | ||
1061 | UndoStack::instance()->push( command ); | 1076 | UndoStack::instance()->push( command ); |
1062 | RedoStack::instance()->clear(); | 1077 | RedoStack::instance()->clear(); |
1063 | 1078 | ||
1064 | setModified( true ); | 1079 | setModified( true ); |
1065 | } | 1080 | } |
1066 | 1081 | ||
1067 | void KABCore::newContact() | 1082 | void KABCore::newContact() |
1068 | { | 1083 | { |
1069 | 1084 | ||
1070 | 1085 | ||
1071 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1086 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1072 | 1087 | ||
1073 | QPtrList<KRES::Resource> kresResources; | 1088 | QPtrList<KRES::Resource> kresResources; |
1074 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1089 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1075 | KABC::Resource *resource; | 1090 | KABC::Resource *resource; |
1076 | while ( ( resource = it.current() ) != 0 ) { | 1091 | while ( ( resource = it.current() ) != 0 ) { |
1077 | ++it; | 1092 | ++it; |
1078 | if ( !resource->readOnly() ) { | 1093 | if ( !resource->readOnly() ) { |
1079 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1094 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1080 | if ( res ) | 1095 | if ( res ) |
1081 | kresResources.append( res ); | 1096 | kresResources.append( res ); |
1082 | } | 1097 | } |
1083 | } | 1098 | } |
1084 | 1099 | ||
1085 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1100 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1086 | resource = static_cast<KABC::Resource*>( res ); | 1101 | resource = static_cast<KABC::Resource*>( res ); |
1087 | 1102 | ||
1088 | if ( resource ) { | 1103 | if ( resource ) { |
1089 | KABC::Addressee addr; | 1104 | KABC::Addressee addr; |
1090 | addr.setResource( resource ); | 1105 | addr.setResource( resource ); |
1091 | mEditorDialog->setAddressee( addr ); | 1106 | mEditorDialog->setAddressee( addr ); |
1092 | KApplication::execDialog ( mEditorDialog ); | 1107 | KApplication::execDialog ( mEditorDialog ); |
1093 | 1108 | ||
1094 | } else | 1109 | } else |
1095 | return; | 1110 | return; |
1096 | 1111 | ||
1097 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1112 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1098 | 1113 | ||
1099 | 1114 | ||
1100 | } | 1115 | } |
1101 | 1116 | ||
1102 | void KABCore::addEmail( QString aStr ) | 1117 | void KABCore::addEmail( QString aStr ) |
1103 | { | 1118 | { |
1104 | #ifndef KAB_EMBEDDED | 1119 | #ifndef KAB_EMBEDDED |
1105 | QString fullName, email; | 1120 | QString fullName, email; |
1106 | 1121 | ||
1107 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1122 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1108 | 1123 | ||
1109 | // Try to lookup the addressee matching the email address | 1124 | // Try to lookup the addressee matching the email address |
1110 | bool found = false; | 1125 | bool found = false; |
1111 | QStringList emailList; | 1126 | QStringList emailList; |
1112 | KABC::AddressBook::Iterator it; | 1127 | KABC::AddressBook::Iterator it; |
1113 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1128 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1114 | emailList = (*it).emails(); | 1129 | emailList = (*it).emails(); |
1115 | if ( emailList.contains( email ) > 0 ) { | 1130 | if ( emailList.contains( email ) > 0 ) { |
1116 | found = true; | 1131 | found = true; |
1117 | (*it).setNameFromString( fullName ); | 1132 | (*it).setNameFromString( fullName ); |
1118 | editContact( (*it).uid() ); | 1133 | editContact( (*it).uid() ); |
1119 | } | 1134 | } |
1120 | } | 1135 | } |
1121 | 1136 | ||
1122 | if ( !found ) { | 1137 | if ( !found ) { |
1123 | KABC::Addressee addr; | 1138 | KABC::Addressee addr; |
1124 | addr.setNameFromString( fullName ); | 1139 | addr.setNameFromString( fullName ); |
1125 | addr.insertEmail( email, true ); | 1140 | addr.insertEmail( email, true ); |
1126 | 1141 | ||
1127 | mAddressBook->insertAddressee( addr ); | 1142 | mAddressBook->insertAddressee( addr ); |
1128 | mViewManager->refreshView( addr.uid() ); | 1143 | mViewManager->refreshView( addr.uid() ); |
1129 | editContact( addr.uid() ); | 1144 | editContact( addr.uid() ); |
1130 | } | 1145 | } |
1131 | #else //KAB_EMBEDDED | 1146 | #else //KAB_EMBEDDED |
1132 | qDebug("KABCore::addEmail finsih method"); | 1147 | qDebug("KABCore::addEmail finsih method"); |
1133 | #endif //KAB_EMBEDDED | 1148 | #endif //KAB_EMBEDDED |
1134 | } | 1149 | } |
1135 | 1150 | ||
1136 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1151 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1137 | { | 1152 | { |
1138 | mXXPortManager->importVCard( url, showPreview ); | 1153 | mXXPortManager->importVCard( url, showPreview ); |
1139 | } | 1154 | } |
1140 | void KABCore::importFromOL() | 1155 | void KABCore::importFromOL() |
1141 | { | 1156 | { |
1142 | #ifdef _WIN32_ | 1157 | #ifdef _WIN32_ |
1143 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1158 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1144 | idgl->exec(); | 1159 | idgl->exec(); |
1145 | KABC::Addressee::List list = idgl->getAddressList(); | 1160 | KABC::Addressee::List list = idgl->getAddressList(); |
1146 | if ( list.count() > 0 ) { | 1161 | if ( list.count() > 0 ) { |
1147 | KABC::Addressee::List listNew; | 1162 | KABC::Addressee::List listNew; |
1148 | KABC::Addressee::List listExisting; | 1163 | KABC::Addressee::List listExisting; |
1149 | KABC::Addressee::List::Iterator it; | 1164 | KABC::Addressee::List::Iterator it; |
1150 | KABC::AddressBook::Iterator iter; | 1165 | KABC::AddressBook::Iterator iter; |
1151 | for ( it = list.begin(); it != list.end(); ++it ) { | 1166 | for ( it = list.begin(); it != list.end(); ++it ) { |
1152 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1167 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1153 | listNew.append( (*it) ); | 1168 | listNew.append( (*it) ); |
1154 | else | 1169 | else |
1155 | listExisting.append( (*it) ); | 1170 | listExisting.append( (*it) ); |
1156 | } | 1171 | } |
1157 | if ( listExisting.count() > 0 ) | 1172 | if ( listExisting.count() > 0 ) |
1158 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1173 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1159 | if ( listNew.count() > 0 ) { | 1174 | if ( listNew.count() > 0 ) { |
1160 | pasteWithNewUid = false; | 1175 | pasteWithNewUid = false; |
1161 | pasteContacts( listNew ); | 1176 | pasteContacts( listNew ); |
1162 | pasteWithNewUid = true; | 1177 | pasteWithNewUid = true; |
1163 | } | 1178 | } |
1164 | } | 1179 | } |
1165 | delete idgl; | 1180 | delete idgl; |
1166 | #endif | 1181 | #endif |
1167 | } | 1182 | } |
1168 | 1183 | ||
1169 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1184 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1170 | { | 1185 | { |
1171 | mXXPortManager->importVCard( vCard, showPreview ); | 1186 | mXXPortManager->importVCard( vCard, showPreview ); |
1172 | } | 1187 | } |
1173 | 1188 | ||
1174 | //US added a second method without defaultparameter | 1189 | //US added a second method without defaultparameter |
1175 | void KABCore::editContact2() { | 1190 | void KABCore::editContact2() { |
1176 | editContact( QString::null ); | 1191 | editContact( QString::null ); |
1177 | } | 1192 | } |
1178 | 1193 | ||
1179 | void KABCore::editContact( const QString &uid ) | 1194 | void KABCore::editContact( const QString &uid ) |
1180 | { | 1195 | { |
1181 | 1196 | ||
1182 | if ( mExtensionManager->isQuickEditVisible() ) | 1197 | if ( mExtensionManager->isQuickEditVisible() ) |
1183 | return; | 1198 | return; |
1184 | 1199 | ||
1185 | // First, locate the contact entry | 1200 | // First, locate the contact entry |
1186 | QString localUID = uid; | 1201 | QString localUID = uid; |
1187 | if ( localUID.isNull() ) { | 1202 | if ( localUID.isNull() ) { |
1188 | QStringList uidList = mViewManager->selectedUids(); | 1203 | QStringList uidList = mViewManager->selectedUids(); |
1189 | if ( uidList.count() > 0 ) | 1204 | if ( uidList.count() > 0 ) |
1190 | localUID = *( uidList.at( 0 ) ); | 1205 | localUID = *( uidList.at( 0 ) ); |
1191 | } | 1206 | } |
1192 | 1207 | ||
1193 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1208 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1194 | if ( !addr.isEmpty() ) { | 1209 | if ( !addr.isEmpty() ) { |
1195 | mEditorDialog->setAddressee( addr ); | 1210 | mEditorDialog->setAddressee( addr ); |
1196 | KApplication::execDialog ( mEditorDialog ); | 1211 | KApplication::execDialog ( mEditorDialog ); |
1197 | } | 1212 | } |
1198 | } | 1213 | } |
1199 | 1214 | ||
1200 | /** | 1215 | /** |
1201 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1216 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1202 | the method will try to find a selected addressee in the view. | 1217 | the method will try to find a selected addressee in the view. |
1203 | */ | 1218 | */ |
1204 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1219 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1205 | { | 1220 | { |
1206 | if ( mMultipleViewsAtOnce ) | 1221 | if ( mMultipleViewsAtOnce ) |
1207 | { | 1222 | { |
1208 | editContact( uid ); | 1223 | editContact( uid ); |
1209 | } | 1224 | } |
1210 | else | 1225 | else |
1211 | { | 1226 | { |
1212 | setDetailsVisible( true ); | 1227 | setDetailsVisible( true ); |
1213 | mActionDetails->setChecked(true); | 1228 | mActionDetails->setChecked(true); |
1214 | } | 1229 | } |
1215 | 1230 | ||
1216 | } | 1231 | } |
1217 | 1232 | ||
1218 | void KABCore::save() | 1233 | void KABCore::save() |
1219 | { | 1234 | { |
1220 | if (syncManager->blockSave()) | 1235 | if (syncManager->blockSave()) |
1221 | return; | 1236 | return; |
1222 | if ( !mModified ) | 1237 | if ( !mModified ) |
1223 | return; | 1238 | return; |
1224 | 1239 | ||
1225 | syncManager->setBlockSave(true); | 1240 | syncManager->setBlockSave(true); |
1226 | QString text = i18n( "There was an error while attempting to save\n the " | 1241 | QString text = i18n( "There was an error while attempting to save\n the " |
1227 | "address book. Please check that some \nother application is " | 1242 | "address book. Please check that some \nother application is " |
1228 | "not using it. " ); | 1243 | "not using it. " ); |
1229 | statusMessage(i18n("Saving addressbook ... ")); | 1244 | statusMessage(i18n("Saving addressbook ... ")); |
1230 | #ifndef KAB_EMBEDDED | 1245 | #ifndef KAB_EMBEDDED |
1231 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1246 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1232 | if ( !b || !b->save() ) { | 1247 | if ( !b || !b->save() ) { |
1233 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1248 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1234 | } | 1249 | } |
1235 | #else //KAB_EMBEDDED | 1250 | #else //KAB_EMBEDDED |
1236 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1251 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1237 | if ( !b || !b->save() ) { | 1252 | if ( !b || !b->save() ) { |
1238 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1253 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1239 | } | 1254 | } |
1240 | #endif //KAB_EMBEDDED | 1255 | #endif //KAB_EMBEDDED |
1241 | 1256 | ||
1242 | statusMessage(i18n("Addressbook saved!")); | 1257 | statusMessage(i18n("Addressbook saved!")); |
1243 | setModified( false ); | 1258 | setModified( false ); |
1244 | syncManager->setBlockSave(false); | 1259 | syncManager->setBlockSave(false); |
1245 | } | 1260 | } |
1246 | 1261 | ||
1247 | void KABCore::statusMessage(QString mess , int time ) | 1262 | void KABCore::statusMessage(QString mess , int time ) |
1248 | { | 1263 | { |
1249 | //topLevelWidget()->setCaption( mess ); | 1264 | //topLevelWidget()->setCaption( mess ); |
1250 | // pending setting timer to revome message | 1265 | // pending setting timer to revome message |
1251 | } | 1266 | } |
1252 | void KABCore::undo() | 1267 | void KABCore::undo() |
1253 | { | 1268 | { |
1254 | UndoStack::instance()->undo(); | 1269 | UndoStack::instance()->undo(); |
1255 | 1270 | ||
1256 | // Refresh the view | 1271 | // Refresh the view |
1257 | mViewManager->refreshView(); | 1272 | mViewManager->refreshView(); |
1258 | } | 1273 | } |
1259 | 1274 | ||
1260 | void KABCore::redo() | 1275 | void KABCore::redo() |
1261 | { | 1276 | { |
1262 | RedoStack::instance()->redo(); | 1277 | RedoStack::instance()->redo(); |
1263 | 1278 | ||
1264 | // Refresh the view | 1279 | // Refresh the view |
1265 | mViewManager->refreshView(); | 1280 | mViewManager->refreshView(); |
1266 | } | 1281 | } |
1267 | 1282 | ||
1268 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1283 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1269 | { | 1284 | { |
1270 | if (mMultipleViewsAtOnce) | 1285 | if (mMultipleViewsAtOnce) |
1271 | { | 1286 | { |
1272 | if ( visible ) | 1287 | if ( visible ) |
1273 | mJumpButtonBar->show(); | 1288 | mJumpButtonBar->show(); |
1274 | else | 1289 | else |
1275 | mJumpButtonBar->hide(); | 1290 | mJumpButtonBar->hide(); |
1276 | } | 1291 | } |
1277 | else | 1292 | else |
1278 | { | 1293 | { |
1279 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1294 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1280 | if (mViewManager->isVisible()) | 1295 | if (mViewManager->isVisible()) |
1281 | { | 1296 | { |
1282 | if ( visible ) | 1297 | if ( visible ) |
1283 | mJumpButtonBar->show(); | 1298 | mJumpButtonBar->show(); |
1284 | else | 1299 | else |
1285 | mJumpButtonBar->hide(); | 1300 | mJumpButtonBar->hide(); |
1286 | } | 1301 | } |
1287 | else | 1302 | else |
1288 | { | 1303 | { |
1289 | mJumpButtonBar->hide(); | 1304 | mJumpButtonBar->hide(); |
1290 | } | 1305 | } |
1291 | } | 1306 | } |
1292 | } | 1307 | } |
1293 | 1308 | ||
1294 | 1309 | ||
1295 | void KABCore::setDetailsToState() | 1310 | void KABCore::setDetailsToState() |
1296 | { | 1311 | { |
1297 | setDetailsVisible( mActionDetails->isChecked() ); | 1312 | setDetailsVisible( mActionDetails->isChecked() ); |
1298 | } | 1313 | } |
1299 | 1314 | ||
1300 | 1315 | ||
1301 | 1316 | ||
1302 | void KABCore::setDetailsVisible( bool visible ) | 1317 | void KABCore::setDetailsVisible( bool visible ) |
1303 | { | 1318 | { |
1304 | if (visible && mDetails->isHidden()) | 1319 | if (visible && mDetails->isHidden()) |
1305 | { | 1320 | { |
1306 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1321 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1307 | if ( addrList.count() > 0 ) | 1322 | if ( addrList.count() > 0 ) |
1308 | mDetails->setAddressee( addrList[ 0 ] ); | 1323 | mDetails->setAddressee( addrList[ 0 ] ); |
1309 | } | 1324 | } |
1310 | 1325 | ||
1311 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1326 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1312 | // the listview and the detailview. We do that by changing the splitbar size. | 1327 | // the listview and the detailview. We do that by changing the splitbar size. |
1313 | if (mMultipleViewsAtOnce) | 1328 | if (mMultipleViewsAtOnce) |
1314 | { | 1329 | { |
1315 | if ( visible ) | 1330 | if ( visible ) |
1316 | mDetails->show(); | 1331 | mDetails->show(); |
1317 | else | 1332 | else |
1318 | mDetails->hide(); | 1333 | mDetails->hide(); |
1319 | } | 1334 | } |
1320 | else | 1335 | else |
1321 | { | 1336 | { |
1322 | if ( visible ) { | 1337 | if ( visible ) { |
1323 | mViewManager->hide(); | 1338 | mViewManager->hide(); |
1324 | mDetails->show(); | 1339 | mDetails->show(); |
1325 | } | 1340 | } |
1326 | else { | 1341 | else { |
1327 | mViewManager->show(); | 1342 | mViewManager->show(); |
1328 | mDetails->hide(); | 1343 | mDetails->hide(); |
1329 | } | 1344 | } |
1330 | setJumpButtonBarVisible( !visible ); | 1345 | setJumpButtonBarVisible( !visible ); |
1331 | } | 1346 | } |
1332 | 1347 | ||
1333 | } | 1348 | } |
1334 | 1349 | ||
1335 | void KABCore::extensionChanged( int id ) | 1350 | void KABCore::extensionChanged( int id ) |
1336 | { | 1351 | { |
1337 | //change the details view only for non desktop systems | 1352 | //change the details view only for non desktop systems |
1338 | #ifndef DESKTOP_VERSION | 1353 | #ifndef DESKTOP_VERSION |
1339 | 1354 | ||
1340 | if (id == 0) | 1355 | if (id == 0) |
1341 | { | 1356 | { |
1342 | //the user disabled the extension. | 1357 | //the user disabled the extension. |
1343 | 1358 | ||
1344 | if (mMultipleViewsAtOnce) | 1359 | if (mMultipleViewsAtOnce) |
1345 | { // enable detailsview again | 1360 | { // enable detailsview again |
1346 | setDetailsVisible( true ); | 1361 | setDetailsVisible( true ); |
1347 | mActionDetails->setChecked( true ); | 1362 | mActionDetails->setChecked( true ); |
1348 | } | 1363 | } |
1349 | else | 1364 | else |
1350 | { //go back to the listview | 1365 | { //go back to the listview |
1351 | setDetailsVisible( false ); | 1366 | setDetailsVisible( false ); |
1352 | mActionDetails->setChecked( false ); | 1367 | mActionDetails->setChecked( false ); |
1353 | mActionDetails->setEnabled(true); | 1368 | mActionDetails->setEnabled(true); |
1354 | } | 1369 | } |
1355 | 1370 | ||
1356 | } | 1371 | } |
1357 | else | 1372 | else |
1358 | { | 1373 | { |
1359 | //the user enabled the extension. | 1374 | //the user enabled the extension. |
1360 | setDetailsVisible( false ); | 1375 | setDetailsVisible( false ); |
1361 | mActionDetails->setChecked( false ); | 1376 | mActionDetails->setChecked( false ); |
1362 | 1377 | ||
1363 | if (!mMultipleViewsAtOnce) | 1378 | if (!mMultipleViewsAtOnce) |
1364 | { | 1379 | { |
1365 | mActionDetails->setEnabled(false); | 1380 | mActionDetails->setEnabled(false); |
1366 | } | 1381 | } |
1367 | 1382 | ||
1368 | mExtensionManager->setSelectionChanged(); | 1383 | mExtensionManager->setSelectionChanged(); |
1369 | 1384 | ||
1370 | } | 1385 | } |
1371 | 1386 | ||
1372 | #endif// DESKTOP_VERSION | 1387 | #endif// DESKTOP_VERSION |
1373 | 1388 | ||
1374 | } | 1389 | } |
1375 | 1390 | ||
1376 | 1391 | ||
1377 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1392 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1378 | { | 1393 | { |
1379 | 1394 | ||
1380 | if ( list.count() != 0 ) { | 1395 | if ( list.count() != 0 ) { |
1381 | KABC::Addressee::List::ConstIterator it; | 1396 | KABC::Addressee::List::ConstIterator it; |
1382 | for ( it = list.begin(); it != list.end(); ++it ) | 1397 | for ( it = list.begin(); it != list.end(); ++it ) |
1383 | mAddressBook->insertAddressee( *it ); | 1398 | mAddressBook->insertAddressee( *it ); |
1384 | if ( list.count() > 1 ) | 1399 | if ( list.count() > 1 ) |
1385 | setModified(); | 1400 | setModified(); |
1386 | else | 1401 | else |
1387 | setModifiedWOrefresh(); | 1402 | setModifiedWOrefresh(); |
1388 | } | 1403 | } |
1389 | if ( list.count() == 0 ) | 1404 | if ( list.count() == 0 ) |
1390 | mViewManager->refreshView(); | 1405 | mViewManager->refreshView(); |
1391 | else | 1406 | else |
1392 | mViewManager->refreshView( list[ 0 ].uid() ); | 1407 | mViewManager->refreshView( list[ 0 ].uid() ); |
1393 | 1408 | ||
1394 | 1409 | ||
1395 | 1410 | ||
1396 | } | 1411 | } |
1397 | 1412 | ||
1398 | QString KABCore::getNameByPhone( const QString &phone ) | 1413 | QString KABCore::getNameByPhone( const QString &phone ) |
1399 | { | 1414 | { |
1400 | #ifndef KAB_EMBEDDED | 1415 | #ifndef KAB_EMBEDDED |
1401 | QRegExp r( "[/*/-/ ]" ); | 1416 | QRegExp r( "[/*/-/ ]" ); |
1402 | QString localPhone( phone ); | 1417 | QString localPhone( phone ); |
1403 | 1418 | ||
1404 | bool found = false; | 1419 | bool found = false; |
1405 | QString ownerName = ""; | 1420 | QString ownerName = ""; |
1406 | KABC::AddressBook::Iterator iter; | 1421 | KABC::AddressBook::Iterator iter; |
1407 | KABC::PhoneNumber::List::Iterator phoneIter; | 1422 | KABC::PhoneNumber::List::Iterator phoneIter; |
1408 | KABC::PhoneNumber::List phoneList; | 1423 | KABC::PhoneNumber::List phoneList; |
1409 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1424 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1410 | phoneList = (*iter).phoneNumbers(); | 1425 | phoneList = (*iter).phoneNumbers(); |
1411 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1426 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1412 | ++phoneIter) { | 1427 | ++phoneIter) { |
1413 | // Get rid of separator chars so just the numbers are compared. | 1428 | // Get rid of separator chars so just the numbers are compared. |
1414 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1429 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1415 | ownerName = (*iter).formattedName(); | 1430 | ownerName = (*iter).formattedName(); |
1416 | found = true; | 1431 | found = true; |
1417 | } | 1432 | } |
1418 | } | 1433 | } |
1419 | } | 1434 | } |
1420 | 1435 | ||
1421 | return ownerName; | 1436 | return ownerName; |
1422 | #else //KAB_EMBEDDED | 1437 | #else //KAB_EMBEDDED |
1423 | qDebug("KABCore::getNameByPhone finsih method"); | 1438 | qDebug("KABCore::getNameByPhone finsih method"); |
1424 | return ""; | 1439 | return ""; |
1425 | #endif //KAB_EMBEDDED | 1440 | #endif //KAB_EMBEDDED |
1426 | 1441 | ||
1427 | } | 1442 | } |
1428 | 1443 | ||
1429 | void KABCore::openConfigDialog() | 1444 | void KABCore::openConfigDialog() |
1430 | { | 1445 | { |
1431 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1446 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1432 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1447 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1433 | ConfigureDialog->addModule(kabcfg ); | 1448 | ConfigureDialog->addModule(kabcfg ); |
1434 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1449 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1435 | ConfigureDialog->addModule(kdelibcfg ); | 1450 | ConfigureDialog->addModule(kdelibcfg ); |
1436 | 1451 | ||
1437 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1452 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1438 | this, SLOT( configurationChanged() ) ); | 1453 | this, SLOT( configurationChanged() ) ); |
1439 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1454 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1440 | this, SLOT( configurationChanged() ) ); | 1455 | this, SLOT( configurationChanged() ) ); |
1441 | saveSettings(); | 1456 | saveSettings(); |
1442 | #ifndef DESKTOP_VERSION | 1457 | #ifndef DESKTOP_VERSION |
1443 | ConfigureDialog->showMaximized(); | 1458 | ConfigureDialog->showMaximized(); |
1444 | #endif | 1459 | #endif |
1445 | if ( ConfigureDialog->exec() ) | 1460 | if ( ConfigureDialog->exec() ) |
1446 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1461 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1447 | delete ConfigureDialog; | 1462 | delete ConfigureDialog; |
1448 | } | 1463 | } |
1449 | 1464 | ||
1450 | void KABCore::openLDAPDialog() | 1465 | void KABCore::openLDAPDialog() |
1451 | { | 1466 | { |
1452 | #ifndef KAB_EMBEDDED | 1467 | #ifndef KAB_EMBEDDED |
1453 | if ( !mLdapSearchDialog ) { | 1468 | if ( !mLdapSearchDialog ) { |
1454 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1469 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1455 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1470 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1456 | SLOT( refreshView() ) ); | 1471 | SLOT( refreshView() ) ); |
1457 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1472 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1458 | SLOT( setModified() ) ); | 1473 | SLOT( setModified() ) ); |
1459 | } else | 1474 | } else |
1460 | mLdapSearchDialog->restoreSettings(); | 1475 | mLdapSearchDialog->restoreSettings(); |
1461 | 1476 | ||
1462 | if ( mLdapSearchDialog->isOK() ) | 1477 | if ( mLdapSearchDialog->isOK() ) |
1463 | mLdapSearchDialog->exec(); | 1478 | mLdapSearchDialog->exec(); |
1464 | #else //KAB_EMBEDDED | 1479 | #else //KAB_EMBEDDED |
1465 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1480 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1466 | #endif //KAB_EMBEDDED | 1481 | #endif //KAB_EMBEDDED |
1467 | } | 1482 | } |
1468 | 1483 | ||
1469 | void KABCore::print() | 1484 | void KABCore::print() |
1470 | { | 1485 | { |
1471 | #ifndef KAB_EMBEDDED | 1486 | #ifndef KAB_EMBEDDED |
1472 | KPrinter printer; | 1487 | KPrinter printer; |
1473 | if ( !printer.setup( this ) ) | 1488 | if ( !printer.setup( this ) ) |
1474 | return; | 1489 | return; |
1475 | 1490 | ||
1476 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1491 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1477 | mViewManager->selectedUids(), this ); | 1492 | mViewManager->selectedUids(), this ); |
1478 | 1493 | ||
1479 | wizard.exec(); | 1494 | wizard.exec(); |
1480 | #else //KAB_EMBEDDED | 1495 | #else //KAB_EMBEDDED |
1481 | qDebug("KABCore::print() finsih method"); | 1496 | qDebug("KABCore::print() finsih method"); |
1482 | #endif //KAB_EMBEDDED | 1497 | #endif //KAB_EMBEDDED |
1483 | 1498 | ||
1484 | } | 1499 | } |
1485 | 1500 | ||
1486 | 1501 | ||
1487 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1502 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1488 | { | 1503 | { |
1489 | if ( mGUIClient ) | 1504 | if ( mGUIClient ) |
1490 | mGUIClient->insertChildClient( client ); | 1505 | mGUIClient->insertChildClient( client ); |
1491 | else | 1506 | else |
1492 | KMessageBox::error( this, "no KXMLGUICLient"); | 1507 | KMessageBox::error( this, "no KXMLGUICLient"); |
1493 | } | 1508 | } |
1494 | 1509 | ||
1495 | 1510 | ||
1496 | void KABCore::configurationChanged() | 1511 | void KABCore::configurationChanged() |
1497 | { | 1512 | { |
1498 | mExtensionManager->reconfigure(); | 1513 | mExtensionManager->reconfigure(); |
1499 | } | 1514 | } |
1500 | 1515 | ||
1501 | void KABCore::addressBookChanged() | 1516 | void KABCore::addressBookChanged() |
1502 | { | 1517 | { |
1503 | /*US | 1518 | /*US |
1504 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1519 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1505 | while ( it.current() ) { | 1520 | while ( it.current() ) { |
1506 | if ( it.current()->dirty() ) { | 1521 | if ( it.current()->dirty() ) { |
1507 | QString text = i18n( "Data has been changed externally. Unsaved " | 1522 | QString text = i18n( "Data has been changed externally. Unsaved " |
1508 | "changes will be lost." ); | 1523 | "changes will be lost." ); |
1509 | KMessageBox::information( this, text ); | 1524 | KMessageBox::information( this, text ); |
1510 | } | 1525 | } |
1511 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1526 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1512 | ++it; | 1527 | ++it; |
1513 | } | 1528 | } |
1514 | */ | 1529 | */ |
1515 | if (mEditorDialog) | 1530 | if (mEditorDialog) |
1516 | { | 1531 | { |
1517 | if (mEditorDialog->dirty()) | 1532 | if (mEditorDialog->dirty()) |
1518 | { | 1533 | { |
1519 | QString text = i18n( "Data has been changed externally. Unsaved " | 1534 | QString text = i18n( "Data has been changed externally. Unsaved " |
1520 | "changes will be lost." ); | 1535 | "changes will be lost." ); |
1521 | KMessageBox::information( this, text ); | 1536 | KMessageBox::information( this, text ); |
1522 | } | 1537 | } |
1523 | QString currentuid = mEditorDialog->addressee().uid(); | 1538 | QString currentuid = mEditorDialog->addressee().uid(); |
1524 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1539 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1525 | } | 1540 | } |
1526 | mViewManager->refreshView(); | 1541 | mViewManager->refreshView(); |
1527 | // mDetails->refreshView(); | 1542 | // mDetails->refreshView(); |
1528 | 1543 | ||
1529 | 1544 | ||
1530 | } | 1545 | } |
1531 | 1546 | ||
1532 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1547 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1533 | const char *name ) | 1548 | const char *name ) |
1534 | { | 1549 | { |
1535 | 1550 | ||
1536 | if ( mEditorDialog == 0 ) { | 1551 | if ( mEditorDialog == 0 ) { |
1537 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1552 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1538 | name ? name : "editorDialog" ); | 1553 | name ? name : "editorDialog" ); |
1539 | 1554 | ||
1540 | 1555 | ||
1541 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1556 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1542 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1557 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1543 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1558 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1544 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1559 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1545 | } | 1560 | } |
1546 | 1561 | ||
1547 | return mEditorDialog; | 1562 | return mEditorDialog; |
1548 | } | 1563 | } |
1549 | 1564 | ||
1550 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1565 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1551 | { | 1566 | { |
1552 | //mEditorDict.remove( uid ); | 1567 | //mEditorDict.remove( uid ); |
1553 | } | 1568 | } |
1554 | 1569 | ||
1555 | void KABCore::initGUI() | 1570 | void KABCore::initGUI() |
1556 | { | 1571 | { |
1557 | #ifndef KAB_EMBEDDED | 1572 | #ifndef KAB_EMBEDDED |
1558 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1573 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1559 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1574 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1560 | 1575 | ||
1561 | mExtensionBarSplitter = new QSplitter( this ); | 1576 | mExtensionBarSplitter = new QSplitter( this ); |
1562 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1577 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1563 | 1578 | ||
1564 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1579 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1565 | 1580 | ||
1566 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1581 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1567 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1582 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1568 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1583 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1569 | SLOT( incrementalSearch( const QString& ) ) ); | 1584 | SLOT( incrementalSearch( const QString& ) ) ); |
1570 | 1585 | ||
1571 | mViewManager = new ViewManager( this, viewSpace ); | 1586 | mViewManager = new ViewManager( this, viewSpace ); |
1572 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1587 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1573 | 1588 | ||
1574 | mDetails = new ViewContainer( mDetailsSplitter ); | 1589 | mDetails = new ViewContainer( mDetailsSplitter ); |
1575 | 1590 | ||
1576 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1591 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1577 | 1592 | ||
1578 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1593 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1579 | 1594 | ||
1580 | topLayout->addWidget( mExtensionBarSplitter ); | 1595 | topLayout->addWidget( mExtensionBarSplitter ); |
1581 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1596 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1582 | topLayout->addWidget( mJumpButtonBar ); | 1597 | topLayout->addWidget( mJumpButtonBar ); |
1583 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1598 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1584 | 1599 | ||
1585 | mXXPortManager = new XXPortManager( this, this ); | 1600 | mXXPortManager = new XXPortManager( this, this ); |
1586 | 1601 | ||
1587 | #else //KAB_EMBEDDED | 1602 | #else //KAB_EMBEDDED |
1588 | //US initialize viewMenu before settingup viewmanager. | 1603 | //US initialize viewMenu before settingup viewmanager. |
1589 | // Viewmanager needs this menu to plugin submenues. | 1604 | // Viewmanager needs this menu to plugin submenues. |
1590 | viewMenu = new QPopupMenu( this ); | 1605 | viewMenu = new QPopupMenu( this ); |
1591 | settingsMenu = new QPopupMenu( this ); | 1606 | settingsMenu = new QPopupMenu( this ); |
1592 | //filterMenu = new QPopupMenu( this ); | 1607 | //filterMenu = new QPopupMenu( this ); |
1593 | ImportMenu = new QPopupMenu( this ); | 1608 | ImportMenu = new QPopupMenu( this ); |
1594 | ExportMenu = new QPopupMenu( this ); | 1609 | ExportMenu = new QPopupMenu( this ); |
1595 | syncMenu = new QPopupMenu( this ); | 1610 | syncMenu = new QPopupMenu( this ); |
1596 | changeMenu= new QPopupMenu( this ); | 1611 | changeMenu= new QPopupMenu( this ); |
1597 | 1612 | ||
1598 | //US since we have no splitter for the embedded system, setup | 1613 | //US since we have no splitter for the embedded system, setup |
1599 | // a layout with two frames. One left and one right. | 1614 | // a layout with two frames. One left and one right. |
1600 | 1615 | ||
1601 | QBoxLayout *topLayout; | 1616 | QBoxLayout *topLayout; |
1602 | 1617 | ||
1603 | // = new QHBoxLayout( this ); | 1618 | // = new QHBoxLayout( this ); |
1604 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1619 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1605 | 1620 | ||
1606 | // QWidget *mainBox = new QWidget( this ); | 1621 | // QWidget *mainBox = new QWidget( this ); |
1607 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1622 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1608 | 1623 | ||
1609 | #ifdef DESKTOP_VERSION | 1624 | #ifdef DESKTOP_VERSION |
1610 | topLayout = new QHBoxLayout( this ); | 1625 | topLayout = new QHBoxLayout( this ); |
1611 | 1626 | ||
1612 | 1627 | ||
1613 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1628 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1614 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1629 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1615 | 1630 | ||
1616 | topLayout->addWidget(mMiniSplitter ); | 1631 | topLayout->addWidget(mMiniSplitter ); |
1617 | 1632 | ||
1618 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1633 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1619 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1634 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1620 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1635 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1621 | mDetails = new ViewContainer( mMiniSplitter ); | 1636 | mDetails = new ViewContainer( mMiniSplitter ); |
1622 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1637 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1623 | #else | 1638 | #else |
1624 | if ( QApplication::desktop()->width() > 480 ) { | 1639 | if ( QApplication::desktop()->width() > 480 ) { |
1625 | topLayout = new QHBoxLayout( this ); | 1640 | topLayout = new QHBoxLayout( this ); |
1626 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1641 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1627 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1642 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1628 | } else { | 1643 | } else { |
1629 | 1644 | ||
1630 | topLayout = new QHBoxLayout( this ); | 1645 | topLayout = new QHBoxLayout( this ); |
1631 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1646 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1632 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1647 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1633 | } | 1648 | } |
1634 | 1649 | ||
1635 | topLayout->addWidget(mMiniSplitter ); | 1650 | topLayout->addWidget(mMiniSplitter ); |
1636 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1651 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1637 | mDetails = new ViewContainer( mMiniSplitter ); | 1652 | mDetails = new ViewContainer( mMiniSplitter ); |
1638 | 1653 | ||
1639 | 1654 | ||
1640 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1655 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1641 | #endif | 1656 | #endif |
1642 | //eh->hide(); | 1657 | //eh->hide(); |
1643 | // topLayout->addWidget(mExtensionManager ); | 1658 | // topLayout->addWidget(mExtensionManager ); |
1644 | 1659 | ||
1645 | 1660 | ||
1646 | /*US | 1661 | /*US |
1647 | #ifndef KAB_NOSPLITTER | 1662 | #ifndef KAB_NOSPLITTER |
1648 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1663 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1649 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1664 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1650 | topLayout->setSpacing( 10 ); | 1665 | topLayout->setSpacing( 10 ); |
1651 | 1666 | ||
1652 | mDetailsSplitter = new QSplitter( this ); | 1667 | mDetailsSplitter = new QSplitter( this ); |
1653 | 1668 | ||
1654 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1669 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1655 | 1670 | ||
1656 | mViewManager = new ViewManager( this, viewSpace ); | 1671 | mViewManager = new ViewManager( this, viewSpace ); |
1657 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1672 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1658 | 1673 | ||
1659 | mDetails = new ViewContainer( mDetailsSplitter ); | 1674 | mDetails = new ViewContainer( mDetailsSplitter ); |
1660 | 1675 | ||
1661 | topLayout->addWidget( mDetailsSplitter ); | 1676 | topLayout->addWidget( mDetailsSplitter ); |
1662 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1677 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1663 | #else //KAB_NOSPLITTER | 1678 | #else //KAB_NOSPLITTER |
1664 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1679 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1665 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1680 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1666 | topLayout->setSpacing( 10 ); | 1681 | topLayout->setSpacing( 10 ); |
1667 | 1682 | ||
1668 | // mDetailsSplitter = new QSplitter( this ); | 1683 | // mDetailsSplitter = new QSplitter( this ); |
1669 | 1684 | ||
1670 | QVBox *viewSpace = new QVBox( this ); | 1685 | QVBox *viewSpace = new QVBox( this ); |
1671 | 1686 | ||
1672 | mViewManager = new ViewManager( this, viewSpace ); | 1687 | mViewManager = new ViewManager( this, viewSpace ); |
1673 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1688 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1674 | 1689 | ||
1675 | mDetails = new ViewContainer( this ); | 1690 | mDetails = new ViewContainer( this ); |
1676 | 1691 | ||
1677 | topLayout->addWidget( viewSpace ); | 1692 | topLayout->addWidget( viewSpace ); |
1678 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1693 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1679 | topLayout->addWidget( mDetails ); | 1694 | topLayout->addWidget( mDetails ); |
1680 | #endif //KAB_NOSPLITTER | 1695 | #endif //KAB_NOSPLITTER |
1681 | */ | 1696 | */ |
1682 | 1697 | ||
1683 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1698 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1684 | syncManager->setBlockSave(false); | 1699 | syncManager->setBlockSave(false); |
1685 | 1700 | ||
1686 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 1701 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
1687 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 1702 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
1688 | syncManager->setDefaultFileName( sentSyncFile()); | 1703 | syncManager->setDefaultFileName( sentSyncFile()); |
1689 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | 1704 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); |
1690 | 1705 | ||
1691 | #endif //KAB_EMBEDDED | 1706 | #endif //KAB_EMBEDDED |
1692 | initActions(); | 1707 | initActions(); |
1693 | 1708 | ||
1694 | #ifdef KAB_EMBEDDED | 1709 | #ifdef KAB_EMBEDDED |
1695 | addActionsManually(); | 1710 | addActionsManually(); |
1696 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1711 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1697 | mXXPortManager = new XXPortManager( this, this ); | 1712 | mXXPortManager = new XXPortManager( this, this ); |
1698 | 1713 | ||
1699 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1714 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1700 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1715 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1701 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1716 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1702 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1717 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1703 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1718 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1704 | // mIncSearchWidget->hide(); | 1719 | // mIncSearchWidget->hide(); |
1705 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1720 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1706 | SLOT( incrementalSearch( const QString& ) ) ); | 1721 | SLOT( incrementalSearch( const QString& ) ) ); |
1707 | 1722 | ||
1708 | 1723 | ||
1709 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1724 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1710 | 1725 | ||
1711 | topLayout->addWidget( mJumpButtonBar ); | 1726 | topLayout->addWidget( mJumpButtonBar ); |
1712 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1727 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1713 | 1728 | ||
1714 | // mMainWindow->getIconToolBar()->raise(); | 1729 | // mMainWindow->getIconToolBar()->raise(); |
1715 | 1730 | ||
1716 | #endif //KAB_EMBEDDED | 1731 | #endif //KAB_EMBEDDED |
1717 | 1732 | ||
1718 | } | 1733 | } |
1719 | void KABCore::initActions() | 1734 | void KABCore::initActions() |
1720 | { | 1735 | { |
1721 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1736 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1722 | 1737 | ||
1723 | #ifndef KAB_EMBEDDED | 1738 | #ifndef KAB_EMBEDDED |
1724 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1739 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1725 | SLOT( clipboardDataChanged() ) ); | 1740 | SLOT( clipboardDataChanged() ) ); |
1726 | #endif //KAB_EMBEDDED | 1741 | #endif //KAB_EMBEDDED |
1727 | 1742 | ||
1728 | // file menu | 1743 | // file menu |
1729 | if ( mIsPart ) { | 1744 | if ( mIsPart ) { |
1730 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1745 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1731 | SLOT( sendMail() ), actionCollection(), | 1746 | SLOT( sendMail() ), actionCollection(), |
1732 | "kaddressbook_mail" ); | 1747 | "kaddressbook_mail" ); |
1733 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1748 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1734 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1749 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1735 | 1750 | ||
1736 | } else { | 1751 | } else { |
1737 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1752 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1738 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1753 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1739 | } | 1754 | } |
1740 | 1755 | ||
1741 | 1756 | ||
1742 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1757 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1743 | SLOT( save() ), actionCollection(), "file_sync" ); | 1758 | SLOT( save() ), actionCollection(), "file_sync" ); |
1744 | 1759 | ||
1745 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1760 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1746 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1761 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1747 | 1762 | ||
1748 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1763 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1749 | this, SLOT( mailVCard() ), | 1764 | this, SLOT( mailVCard() ), |
1750 | actionCollection(), "file_mail_vcard"); | 1765 | actionCollection(), "file_mail_vcard"); |
1751 | 1766 | ||
1752 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, | 1767 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, |
1753 | SLOT( export2phone() ), actionCollection(), | 1768 | SLOT( export2phone() ), actionCollection(), |
1754 | "kaddressbook_ex2phone" ); | 1769 | "kaddressbook_ex2phone" ); |
1755 | 1770 | ||
1756 | mActionBeamVCard = 0; | 1771 | mActionBeamVCard = 0; |
1757 | mActionBeam = 0; | 1772 | mActionBeam = 0; |
1758 | 1773 | ||
1759 | #ifndef DESKTOP_VERSION | 1774 | #ifndef DESKTOP_VERSION |
1760 | if ( Ir::supported() ) { | 1775 | if ( Ir::supported() ) { |
1761 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, | 1776 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1762 | SLOT( beamVCard() ), actionCollection(), | 1777 | SLOT( beamVCard() ), actionCollection(), |
1763 | "kaddressbook_beam_vcard" ); | 1778 | "kaddressbook_beam_vcard" ); |
1764 | 1779 | ||
1765 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1780 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1766 | SLOT( beamMySelf() ), actionCollection(), | 1781 | SLOT( beamMySelf() ), actionCollection(), |
1767 | "kaddressbook_beam_myself" ); | 1782 | "kaddressbook_beam_myself" ); |
1768 | } | 1783 | } |
1769 | #endif | 1784 | #endif |
1770 | 1785 | ||
1771 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1786 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1772 | this, SLOT( editContact2() ), | 1787 | this, SLOT( editContact2() ), |
1773 | actionCollection(), "file_properties" ); | 1788 | actionCollection(), "file_properties" ); |
1774 | 1789 | ||
1775 | #ifdef KAB_EMBEDDED | 1790 | #ifdef KAB_EMBEDDED |
1776 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1791 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1777 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1792 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1778 | mMainWindow, SLOT( exit() ), | 1793 | mMainWindow, SLOT( exit() ), |
1779 | actionCollection(), "quit" ); | 1794 | actionCollection(), "quit" ); |
1780 | #endif //KAB_EMBEDDED | 1795 | #endif //KAB_EMBEDDED |
1781 | 1796 | ||
1782 | // edit menu | 1797 | // edit menu |
1783 | if ( mIsPart ) { | 1798 | if ( mIsPart ) { |
1784 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1799 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1785 | SLOT( copyContacts() ), actionCollection(), | 1800 | SLOT( copyContacts() ), actionCollection(), |
1786 | "kaddressbook_copy" ); | 1801 | "kaddressbook_copy" ); |
1787 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1802 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1788 | SLOT( cutContacts() ), actionCollection(), | 1803 | SLOT( cutContacts() ), actionCollection(), |
1789 | "kaddressbook_cut" ); | 1804 | "kaddressbook_cut" ); |
1790 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1805 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1791 | SLOT( pasteContacts() ), actionCollection(), | 1806 | SLOT( pasteContacts() ), actionCollection(), |
1792 | "kaddressbook_paste" ); | 1807 | "kaddressbook_paste" ); |
1793 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1808 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1794 | SLOT( selectAllContacts() ), actionCollection(), | 1809 | SLOT( selectAllContacts() ), actionCollection(), |
1795 | "kaddressbook_select_all" ); | 1810 | "kaddressbook_select_all" ); |
1796 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1811 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1797 | SLOT( undo() ), actionCollection(), | 1812 | SLOT( undo() ), actionCollection(), |
1798 | "kaddressbook_undo" ); | 1813 | "kaddressbook_undo" ); |
1799 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1814 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1800 | this, SLOT( redo() ), actionCollection(), | 1815 | this, SLOT( redo() ), actionCollection(), |
1801 | "kaddressbook_redo" ); | 1816 | "kaddressbook_redo" ); |
1802 | } else { | 1817 | } else { |
1803 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1818 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1804 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1819 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1805 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1820 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1806 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1821 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1807 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1822 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1808 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1823 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1809 | } | 1824 | } |
1810 | 1825 | ||
1811 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1826 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1812 | Key_Delete, this, SLOT( deleteContacts() ), | 1827 | Key_Delete, this, SLOT( deleteContacts() ), |
1813 | actionCollection(), "edit_delete" ); | 1828 | actionCollection(), "edit_delete" ); |
1814 | 1829 | ||
1815 | mActionUndo->setEnabled( false ); | 1830 | mActionUndo->setEnabled( false ); |
1816 | mActionRedo->setEnabled( false ); | 1831 | mActionRedo->setEnabled( false ); |
1817 | 1832 | ||
1818 | // settings menu | 1833 | // settings menu |
1819 | #ifdef KAB_EMBEDDED | 1834 | #ifdef KAB_EMBEDDED |
1820 | //US special menuentry to configure the addressbook resources. On KDE | 1835 | //US special menuentry to configure the addressbook resources. On KDE |
1821 | // you do that through the control center !!! | 1836 | // you do that through the control center !!! |
1822 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1837 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1823 | SLOT( configureResources() ), actionCollection(), | 1838 | SLOT( configureResources() ), actionCollection(), |
1824 | "kaddressbook_configure_resources" ); | 1839 | "kaddressbook_configure_resources" ); |
1825 | #endif //KAB_EMBEDDED | 1840 | #endif //KAB_EMBEDDED |
1826 | 1841 | ||
1827 | if ( mIsPart ) { | 1842 | if ( mIsPart ) { |
1828 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1843 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1829 | SLOT( openConfigDialog() ), actionCollection(), | 1844 | SLOT( openConfigDialog() ), actionCollection(), |
1830 | "kaddressbook_configure" ); | 1845 | "kaddressbook_configure" ); |
1831 | 1846 | ||
1832 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1847 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1833 | this, SLOT( configureKeyBindings() ), actionCollection(), | 1848 | this, SLOT( configureKeyBindings() ), actionCollection(), |
1834 | "kaddressbook_configure_shortcuts" ); | 1849 | "kaddressbook_configure_shortcuts" ); |
1835 | #ifdef KAB_EMBEDDED | 1850 | #ifdef KAB_EMBEDDED |
1836 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1851 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1837 | mActionConfigureToolbars->setEnabled( false ); | 1852 | mActionConfigureToolbars->setEnabled( false ); |
1838 | #endif //KAB_EMBEDDED | 1853 | #endif //KAB_EMBEDDED |
1839 | 1854 | ||
1840 | } else { | 1855 | } else { |
1841 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1856 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1842 | 1857 | ||
1843 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1858 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1844 | } | 1859 | } |
1845 | 1860 | ||
1846 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1861 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1847 | actionCollection(), "options_show_jump_bar" ); | 1862 | actionCollection(), "options_show_jump_bar" ); |
1848 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1863 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1849 | 1864 | ||
1850 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1865 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1851 | actionCollection(), "options_show_details" ); | 1866 | actionCollection(), "options_show_details" ); |
1852 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1867 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1853 | 1868 | ||
1854 | // misc | 1869 | // misc |
1855 | // only enable LDAP lookup if we can handle the protocol | 1870 | // only enable LDAP lookup if we can handle the protocol |
1856 | #ifndef KAB_EMBEDDED | 1871 | #ifndef KAB_EMBEDDED |
1857 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1872 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1858 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1873 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1859 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1874 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1860 | "ldap_lookup" ); | 1875 | "ldap_lookup" ); |
1861 | } | 1876 | } |
1862 | #else //KAB_EMBEDDED | 1877 | #else //KAB_EMBEDDED |
1863 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1878 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1864 | #endif //KAB_EMBEDDED | 1879 | #endif //KAB_EMBEDDED |
1865 | 1880 | ||
1866 | 1881 | ||
1867 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1882 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1868 | SLOT( setWhoAmI() ), actionCollection(), | 1883 | SLOT( setWhoAmI() ), actionCollection(), |
1869 | "set_personal" ); | 1884 | "set_personal" ); |
1870 | 1885 | ||
1871 | 1886 | ||
1872 | 1887 | ||
1873 | 1888 | ||
1874 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1889 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1875 | SLOT( setCategories() ), actionCollection(), | 1890 | SLOT( setCategories() ), actionCollection(), |
1876 | "edit_set_categories" ); | 1891 | "edit_set_categories" ); |
1877 | 1892 | ||
1878 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1893 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1879 | SLOT( removeVoice() ), actionCollection(), | 1894 | SLOT( removeVoice() ), actionCollection(), |
1880 | "remove_voice" ); | 1895 | "remove_voice" ); |
1881 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 1896 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
1882 | SLOT( importFromOL() ), actionCollection(), | 1897 | SLOT( importFromOL() ), actionCollection(), |
1883 | "import_OL" ); | 1898 | "import_OL" ); |
1884 | #ifdef KAB_EMBEDDED | 1899 | #ifdef KAB_EMBEDDED |
1885 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1900 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1886 | this, SLOT( showLicence() ), actionCollection(), | 1901 | this, SLOT( showLicence() ), actionCollection(), |
1887 | "licence_about_data" ); | 1902 | "licence_about_data" ); |
1888 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1903 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
1889 | this, SLOT( faq() ), actionCollection(), | 1904 | this, SLOT( faq() ), actionCollection(), |
1890 | "faq_about_data" ); | 1905 | "faq_about_data" ); |
1891 | 1906 | ||
1892 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1907 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1893 | this, SLOT( createAboutData() ), actionCollection(), | 1908 | this, SLOT( createAboutData() ), actionCollection(), |
1894 | "kaddressbook_about_data" ); | 1909 | "kaddressbook_about_data" ); |
1895 | #endif //KAB_EMBEDDED | 1910 | #endif //KAB_EMBEDDED |
1896 | 1911 | ||
1897 | clipboardDataChanged(); | 1912 | clipboardDataChanged(); |
1898 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1913 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1899 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1914 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1900 | } | 1915 | } |
1901 | 1916 | ||
1902 | //US we need this function, to plug all actions into the correct menues. | 1917 | //US we need this function, to plug all actions into the correct menues. |
1903 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1918 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1904 | void KABCore::addActionsManually() | 1919 | void KABCore::addActionsManually() |
1905 | { | 1920 | { |
1906 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1921 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1907 | 1922 | ||
1908 | #ifdef KAB_EMBEDDED | 1923 | #ifdef KAB_EMBEDDED |
1909 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1924 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1910 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1925 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1911 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1926 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1912 | 1927 | ||
1913 | KToolBar* tb = mMainWindow->toolBar(); | 1928 | KToolBar* tb = mMainWindow->toolBar(); |
1914 | 1929 | ||
1915 | #ifdef DESKTOP_VERSION | 1930 | #ifdef DESKTOP_VERSION |
1916 | QMenuBar* mb = mMainWindow->menuBar(); | 1931 | QMenuBar* mb = mMainWindow->menuBar(); |
1917 | 1932 | ||
1918 | //US setup menubar. | 1933 | //US setup menubar. |
1919 | //Disable the following block if you do not want to have a menubar. | 1934 | //Disable the following block if you do not want to have a menubar. |
1920 | mb->insertItem( "&File", fileMenu ); | 1935 | mb->insertItem( "&File", fileMenu ); |
1921 | mb->insertItem( "&Edit", editMenu ); | 1936 | mb->insertItem( "&Edit", editMenu ); |
1922 | mb->insertItem( "&View", viewMenu ); | 1937 | mb->insertItem( "&View", viewMenu ); |
1923 | mb->insertItem( "&Settings", settingsMenu ); | 1938 | mb->insertItem( "&Settings", settingsMenu ); |
1924 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 1939 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
1925 | mb->insertItem( "&Change selected", changeMenu ); | 1940 | mb->insertItem( "&Change selected", changeMenu ); |
1926 | mb->insertItem( "&Help", helpMenu ); | 1941 | mb->insertItem( "&Help", helpMenu ); |
1927 | mIncSearchWidget = new IncSearchWidget( tb ); | 1942 | mIncSearchWidget = new IncSearchWidget( tb ); |
1928 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1943 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1929 | 1944 | ||
1930 | #else | 1945 | #else |
1931 | //US setup toolbar | 1946 | //US setup toolbar |
1932 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 1947 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
1933 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1948 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1934 | menuBarTB->insertItem( "ME", popupBarTB); | 1949 | menuBarTB->insertItem( "ME", popupBarTB); |
1935 | tb->insertWidget(-1, 0, menuBarTB); | 1950 | tb->insertWidget(-1, 0, menuBarTB); |
1936 | mIncSearchWidget = new IncSearchWidget( tb ); | 1951 | mIncSearchWidget = new IncSearchWidget( tb ); |
1937 | 1952 | ||
1938 | tb->enableMoving(false); | 1953 | tb->enableMoving(false); |
1939 | popupBarTB->insertItem( "&File", fileMenu ); | 1954 | popupBarTB->insertItem( "&File", fileMenu ); |
1940 | popupBarTB->insertItem( "&Edit", editMenu ); | 1955 | popupBarTB->insertItem( "&Edit", editMenu ); |
1941 | popupBarTB->insertItem( "&View", viewMenu ); | 1956 | popupBarTB->insertItem( "&View", viewMenu ); |
1942 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1957 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1943 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 1958 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
1944 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1959 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1945 | popupBarTB->insertItem( "&Change selected", changeMenu ); | 1960 | popupBarTB->insertItem( "&Change selected", changeMenu ); |
1946 | popupBarTB->insertItem( "&Help", helpMenu ); | 1961 | popupBarTB->insertItem( "&Help", helpMenu ); |
1947 | if (QApplication::desktop()->width() > 320 ) { | 1962 | if (QApplication::desktop()->width() > 320 ) { |
1948 | // mViewManager->getFilterAction()->plug ( tb); | 1963 | // mViewManager->getFilterAction()->plug ( tb); |
1949 | } | 1964 | } |
1950 | #endif | 1965 | #endif |
1951 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1966 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1952 | 1967 | ||
1953 | 1968 | ||
1954 | 1969 | ||
1955 | //US Now connect the actions with the menue entries. | 1970 | //US Now connect the actions with the menue entries. |
1956 | mActionPrint->plug( fileMenu ); | 1971 | mActionPrint->plug( fileMenu ); |
1957 | mActionMail->plug( fileMenu ); | 1972 | mActionMail->plug( fileMenu ); |
1958 | fileMenu->insertSeparator(); | 1973 | fileMenu->insertSeparator(); |
1959 | 1974 | ||
1960 | mActionNewContact->plug( fileMenu ); | 1975 | mActionNewContact->plug( fileMenu ); |
1961 | mActionNewContact->plug( tb ); | 1976 | mActionNewContact->plug( tb ); |
1962 | 1977 | ||
1963 | mActionEditAddressee->plug( fileMenu ); | 1978 | mActionEditAddressee->plug( fileMenu ); |
1964 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 1979 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
1965 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 1980 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
1966 | mActionEditAddressee->plug( tb ); | 1981 | mActionEditAddressee->plug( tb ); |
1967 | 1982 | ||
1968 | fileMenu->insertSeparator(); | 1983 | fileMenu->insertSeparator(); |
1969 | mActionSave->plug( fileMenu ); | 1984 | mActionSave->plug( fileMenu ); |
1970 | fileMenu->insertItem( "&Import", ImportMenu ); | 1985 | fileMenu->insertItem( "&Import", ImportMenu ); |
1971 | fileMenu->insertItem( "&Export", ExportMenu ); | 1986 | fileMenu->insertItem( "&Export", ExportMenu ); |
1972 | fileMenu->insertSeparator(); | 1987 | fileMenu->insertSeparator(); |
1973 | mActionMailVCard->plug( fileMenu ); | 1988 | mActionMailVCard->plug( fileMenu ); |
1974 | #ifndef DESKTOP_VERSION | 1989 | #ifndef DESKTOP_VERSION |
1975 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 1990 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
1976 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | 1991 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); |
1977 | #endif | 1992 | #endif |
1978 | fileMenu->insertSeparator(); | 1993 | fileMenu->insertSeparator(); |
1979 | mActionQuit->plug( fileMenu ); | 1994 | mActionQuit->plug( fileMenu ); |
1980 | #ifdef _WIN32_ | 1995 | #ifdef _WIN32_ |
1981 | mActionImportOL->plug( ImportMenu ); | 1996 | mActionImportOL->plug( ImportMenu ); |
1982 | #endif | 1997 | #endif |
1983 | // edit menu | 1998 | // edit menu |
1984 | mActionUndo->plug( editMenu ); | 1999 | mActionUndo->plug( editMenu ); |
1985 | mActionRedo->plug( editMenu ); | 2000 | mActionRedo->plug( editMenu ); |
1986 | editMenu->insertSeparator(); | 2001 | editMenu->insertSeparator(); |
1987 | mActionCut->plug( editMenu ); | 2002 | mActionCut->plug( editMenu ); |
1988 | mActionCopy->plug( editMenu ); | 2003 | mActionCopy->plug( editMenu ); |
1989 | mActionPaste->plug( editMenu ); | 2004 | mActionPaste->plug( editMenu ); |
1990 | mActionDelete->plug( editMenu ); | 2005 | mActionDelete->plug( editMenu ); |
1991 | editMenu->insertSeparator(); | 2006 | editMenu->insertSeparator(); |
1992 | mActionSelectAll->plug( editMenu ); | 2007 | mActionSelectAll->plug( editMenu ); |
1993 | 2008 | ||
1994 | mActionRemoveVoice->plug( changeMenu ); | 2009 | mActionRemoveVoice->plug( changeMenu ); |
1995 | // settings menu | 2010 | // settings menu |
1996 | //US special menuentry to configure the addressbook resources. On KDE | 2011 | //US special menuentry to configure the addressbook resources. On KDE |
1997 | // you do that through the control center !!! | 2012 | // you do that through the control center !!! |
1998 | mActionConfigResources->plug( settingsMenu ); | 2013 | mActionConfigResources->plug( settingsMenu ); |
1999 | settingsMenu->insertSeparator(); | 2014 | settingsMenu->insertSeparator(); |
2000 | 2015 | ||
2001 | mActionConfigKAddressbook->plug( settingsMenu ); | 2016 | mActionConfigKAddressbook->plug( settingsMenu ); |
2002 | 2017 | ||
2003 | if ( mIsPart ) { | 2018 | if ( mIsPart ) { |
2004 | mActionConfigShortcuts->plug( settingsMenu ); | 2019 | mActionConfigShortcuts->plug( settingsMenu ); |
2005 | mActionConfigureToolbars->plug( settingsMenu ); | 2020 | mActionConfigureToolbars->plug( settingsMenu ); |
2006 | 2021 | ||
2007 | } else { | 2022 | } else { |
2008 | mActionKeyBindings->plug( settingsMenu ); | 2023 | mActionKeyBindings->plug( settingsMenu ); |
2009 | } | 2024 | } |
2010 | 2025 | ||
2011 | settingsMenu->insertSeparator(); | 2026 | settingsMenu->insertSeparator(); |
2012 | 2027 | ||
2013 | mActionJumpBar->plug( settingsMenu ); | 2028 | mActionJumpBar->plug( settingsMenu ); |
2014 | mActionDetails->plug( settingsMenu ); | 2029 | mActionDetails->plug( settingsMenu ); |
2015 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2030 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2016 | mActionDetails->plug( tb ); | 2031 | mActionDetails->plug( tb ); |
2017 | settingsMenu->insertSeparator(); | 2032 | settingsMenu->insertSeparator(); |
2018 | 2033 | ||
2019 | mActionWhoAmI->plug( settingsMenu ); | 2034 | mActionWhoAmI->plug( settingsMenu ); |
2020 | mActionCategories->plug( settingsMenu ); | 2035 | mActionCategories->plug( settingsMenu ); |
2021 | 2036 | ||
2022 | mActionLicence->plug( helpMenu ); | 2037 | mActionLicence->plug( helpMenu ); |
2023 | mActionFaq->plug( helpMenu ); | 2038 | mActionFaq->plug( helpMenu ); |
2024 | mActionAboutKAddressbook->plug( helpMenu ); | 2039 | mActionAboutKAddressbook->plug( helpMenu ); |
2025 | 2040 | ||
2026 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2041 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2027 | 2042 | ||
2028 | mActionSave->plug( tb ); | 2043 | mActionSave->plug( tb ); |
2029 | mViewManager->getFilterAction()->plug ( tb); | 2044 | mViewManager->getFilterAction()->plug ( tb); |
2030 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 2045 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
2031 | mActionUndo->plug( tb ); | 2046 | mActionUndo->plug( tb ); |
2032 | mActionDelete->plug( tb ); | 2047 | mActionDelete->plug( tb ); |
2033 | mActionRedo->plug( tb ); | 2048 | mActionRedo->plug( tb ); |
2034 | } | 2049 | } |
2035 | } | 2050 | } |
2036 | //mActionQuit->plug ( tb ); | 2051 | //mActionQuit->plug ( tb ); |
2037 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2052 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2038 | 2053 | ||
2039 | //US link the searchwidget first to this. | 2054 | //US link the searchwidget first to this. |
2040 | // The real linkage to the toolbar happens later. | 2055 | // The real linkage to the toolbar happens later. |
2041 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2056 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2042 | //US tb->insertItem( mIncSearchWidget ); | 2057 | //US tb->insertItem( mIncSearchWidget ); |
2043 | /*US | 2058 | /*US |
2044 | mIncSearchWidget = new IncSearchWidget( tb ); | 2059 | mIncSearchWidget = new IncSearchWidget( tb ); |
2045 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2060 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2046 | SLOT( incrementalSearch( const QString& ) ) ); | 2061 | SLOT( incrementalSearch( const QString& ) ) ); |
2047 | 2062 | ||
2048 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2063 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2049 | 2064 | ||
2050 | //US topLayout->addWidget( mJumpButtonBar ); | 2065 | //US topLayout->addWidget( mJumpButtonBar ); |
2051 | this->layout()->add( mJumpButtonBar ); | 2066 | this->layout()->add( mJumpButtonBar ); |
2052 | */ | 2067 | */ |
2053 | 2068 | ||
2054 | #endif //KAB_EMBEDDED | 2069 | #endif //KAB_EMBEDDED |
2055 | 2070 | ||
2056 | mActionExport2phone->plug( ExportMenu ); | 2071 | mActionExport2phone->plug( ExportMenu ); |
2057 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2072 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2058 | syncManager->fillSyncMenu(); | 2073 | syncManager->fillSyncMenu(); |
2059 | 2074 | ||
2060 | } | 2075 | } |
2061 | void KABCore::showLicence() | 2076 | void KABCore::showLicence() |
2062 | { | 2077 | { |
2063 | KApplication::showLicence(); | 2078 | KApplication::showLicence(); |
2064 | } | 2079 | } |
2065 | void KABCore::removeVoice() | 2080 | void KABCore::removeVoice() |
2066 | { | 2081 | { |
2067 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) | 2082 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) |
2068 | return; | 2083 | return; |
2069 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 2084 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
2070 | KABC::Addressee::List::Iterator it; | 2085 | KABC::Addressee::List::Iterator it; |
2071 | for ( it = list.begin(); it != list.end(); ++it ) { | 2086 | for ( it = list.begin(); it != list.end(); ++it ) { |
2072 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); | 2087 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); |
2073 | PhoneNumber::List::Iterator phoneIt; | 2088 | PhoneNumber::List::Iterator phoneIt; |
2074 | bool found = false; | 2089 | bool found = false; |
2075 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { | 2090 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { |
2076 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 2091 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
2077 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 2092 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
2078 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 2093 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
2079 | (*it).insertPhoneNumber( (*phoneIt) ); | 2094 | (*it).insertPhoneNumber( (*phoneIt) ); |
2080 | found = true; | 2095 | found = true; |
2081 | } | 2096 | } |
2082 | } | 2097 | } |
2083 | 2098 | ||
2084 | } | 2099 | } |
2085 | if ( found ) | 2100 | if ( found ) |
2086 | contactModified((*it) ); | 2101 | contactModified((*it) ); |
2087 | } | 2102 | } |
2088 | } | 2103 | } |
2089 | 2104 | ||
2090 | 2105 | ||
2091 | 2106 | ||
2092 | void KABCore::clipboardDataChanged() | 2107 | void KABCore::clipboardDataChanged() |
2093 | { | 2108 | { |
2094 | 2109 | ||
2095 | if ( mReadWrite ) | 2110 | if ( mReadWrite ) |
2096 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2111 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2097 | 2112 | ||
2098 | } | 2113 | } |
2099 | 2114 | ||
2100 | void KABCore::updateActionMenu() | 2115 | void KABCore::updateActionMenu() |
2101 | { | 2116 | { |
2102 | UndoStack *undo = UndoStack::instance(); | 2117 | UndoStack *undo = UndoStack::instance(); |
2103 | RedoStack *redo = RedoStack::instance(); | 2118 | RedoStack *redo = RedoStack::instance(); |
2104 | 2119 | ||
2105 | if ( undo->isEmpty() ) | 2120 | if ( undo->isEmpty() ) |
2106 | mActionUndo->setText( i18n( "Undo" ) ); | 2121 | mActionUndo->setText( i18n( "Undo" ) ); |
2107 | else | 2122 | else |
2108 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2123 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2109 | 2124 | ||
2110 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2125 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2111 | 2126 | ||
2112 | if ( !redo->top() ) | 2127 | if ( !redo->top() ) |
2113 | mActionRedo->setText( i18n( "Redo" ) ); | 2128 | mActionRedo->setText( i18n( "Redo" ) ); |
2114 | else | 2129 | else |
2115 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2130 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2116 | 2131 | ||
2117 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2132 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2118 | } | 2133 | } |
2119 | 2134 | ||
2120 | void KABCore::configureKeyBindings() | 2135 | void KABCore::configureKeyBindings() |
2121 | { | 2136 | { |
2122 | #ifndef KAB_EMBEDDED | 2137 | #ifndef KAB_EMBEDDED |
2123 | KKeyDialog::configure( actionCollection(), true ); | 2138 | KKeyDialog::configure( actionCollection(), true ); |
2124 | #else //KAB_EMBEDDED | 2139 | #else //KAB_EMBEDDED |
2125 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2140 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2126 | #endif //KAB_EMBEDDED | 2141 | #endif //KAB_EMBEDDED |
2127 | } | 2142 | } |
2128 | 2143 | ||
2129 | #ifdef KAB_EMBEDDED | 2144 | #ifdef KAB_EMBEDDED |
2130 | void KABCore::configureResources() | 2145 | void KABCore::configureResources() |
2131 | { | 2146 | { |
2132 | KRES::KCMKResources dlg( this, "" , 0 ); | 2147 | KRES::KCMKResources dlg( this, "" , 0 ); |
2133 | 2148 | ||
2134 | if ( !dlg.exec() ) | 2149 | if ( !dlg.exec() ) |
2135 | return; | 2150 | return; |
2136 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2151 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2137 | } | 2152 | } |
2138 | #endif //KAB_EMBEDDED | 2153 | #endif //KAB_EMBEDDED |
2139 | 2154 | ||
2140 | 2155 | ||
2141 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2156 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2142 | * for the attendees list of an event. | 2157 | * for the attendees list of an event. |
2143 | */ | 2158 | */ |
2144 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2159 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2145 | { | 2160 | { |
2146 | QStringList nameList; | 2161 | QStringList nameList; |
2147 | QStringList emailList; | 2162 | QStringList emailList; |
2148 | QStringList uidList; | 2163 | QStringList uidList; |
2149 | 2164 | ||
2150 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2165 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2151 | uint i=0; | 2166 | uint i=0; |
2152 | for (i=0; i < list.count(); i++) | 2167 | for (i=0; i < list.count(); i++) |
2153 | { | 2168 | { |
2154 | nameList.append(list[i].realName()); | 2169 | nameList.append(list[i].realName()); |
2155 | emailList.append(list[i].preferredEmail()); | 2170 | emailList.append(list[i].preferredEmail()); |
2156 | uidList.append(list[i].uid()); | 2171 | uidList.append(list[i].uid()); |
2157 | } | 2172 | } |
2158 | 2173 | ||
2159 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2174 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2160 | 2175 | ||
2161 | } | 2176 | } |
2162 | 2177 | ||
2163 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2178 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2164 | * to put them into the calendar. | 2179 | * to put them into the calendar. |
2165 | */ | 2180 | */ |
2166 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2181 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2167 | { | 2182 | { |
2168 | // qDebug("KABCore::requestForBirthdayList"); | 2183 | // qDebug("KABCore::requestForBirthdayList"); |
2169 | QStringList birthdayList; | 2184 | QStringList birthdayList; |
2170 | QStringList anniversaryList; | 2185 | QStringList anniversaryList; |
2171 | QStringList realNameList; | 2186 | QStringList realNameList; |
2172 | QStringList preferredEmailList; | 2187 | QStringList preferredEmailList; |
2173 | QStringList assembledNameList; | 2188 | QStringList assembledNameList; |
2174 | QStringList uidList; | 2189 | QStringList uidList; |
2175 | 2190 | ||
2176 | KABC::AddressBook::Iterator it; | 2191 | KABC::AddressBook::Iterator it; |
2177 | 2192 | ||
2178 | int count = 0; | 2193 | int count = 0; |
2179 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2194 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2180 | ++count; | 2195 | ++count; |
2181 | } | 2196 | } |
2182 | QProgressBar bar(count,0 ); | 2197 | QProgressBar bar(count,0 ); |
2183 | int w = 300; | 2198 | int w = 300; |
2184 | if ( QApplication::desktop()->width() < 320 ) | 2199 | if ( QApplication::desktop()->width() < 320 ) |
2185 | w = 220; | 2200 | w = 220; |
2186 | int h = bar.sizeHint().height() ; | 2201 | int h = bar.sizeHint().height() ; |
2187 | int dw = QApplication::desktop()->width(); | 2202 | int dw = QApplication::desktop()->width(); |
2188 | int dh = QApplication::desktop()->height(); | 2203 | int dh = QApplication::desktop()->height(); |
2189 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2204 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2190 | bar.show(); | 2205 | bar.show(); |
2191 | bar.setCaption (i18n("collecting birthdays - close to abort!") ); | 2206 | bar.setCaption (i18n("collecting birthdays - close to abort!") ); |
2192 | qApp->processEvents(); | 2207 | qApp->processEvents(); |
2193 | 2208 | ||
2194 | QDate bday; | 2209 | QDate bday; |
2195 | QString anni; | 2210 | QString anni; |
2196 | QString formattedbday; | 2211 | QString formattedbday; |
2197 | 2212 | ||
2198 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2213 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2199 | { | 2214 | { |
2200 | if ( ! bar.isVisible() ) | 2215 | if ( ! bar.isVisible() ) |
2201 | return; | 2216 | return; |
2202 | bar.setProgress( count++ ); | 2217 | bar.setProgress( count++ ); |
2203 | qApp->processEvents(); | 2218 | qApp->processEvents(); |
2204 | bday = (*it).birthday().date(); | 2219 | bday = (*it).birthday().date(); |
2205 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2220 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2206 | 2221 | ||
2207 | if ( bday.isValid() || !anni.isEmpty()) | 2222 | if ( bday.isValid() || !anni.isEmpty()) |
2208 | { | 2223 | { |
2209 | if (bday.isValid()) | 2224 | if (bday.isValid()) |
2210 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2225 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2211 | else | 2226 | else |
2212 | formattedbday = "NOTVALID"; | 2227 | formattedbday = "NOTVALID"; |
2213 | if (anni.isEmpty()) | 2228 | if (anni.isEmpty()) |
2214 | anni = "INVALID"; | 2229 | anni = "INVALID"; |
2215 | 2230 | ||
2216 | birthdayList.append(formattedbday); | 2231 | birthdayList.append(formattedbday); |
2217 | anniversaryList.append(anni); //should be ISODate | 2232 | anniversaryList.append(anni); //should be ISODate |
2218 | realNameList.append((*it).realName()); | 2233 | realNameList.append((*it).realName()); |
2219 | preferredEmailList.append((*it).preferredEmail()); | 2234 | preferredEmailList.append((*it).preferredEmail()); |
2220 | assembledNameList.append((*it).assembledName()); | 2235 | assembledNameList.append((*it).assembledName()); |
2221 | uidList.append((*it).uid()); | 2236 | uidList.append((*it).uid()); |
2222 | 2237 | ||
2223 | qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); | 2238 | qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); |
2224 | } | 2239 | } |
2225 | } | 2240 | } |
2226 | 2241 | ||
2227 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2242 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2228 | 2243 | ||
2229 | } | 2244 | } |
2230 | 2245 | ||
2231 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2246 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2232 | */ | 2247 | */ |
2233 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2248 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2234 | { | 2249 | { |
2235 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2250 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2236 | 2251 | ||
2237 | QString foundUid = QString::null; | 2252 | QString foundUid = QString::null; |
2238 | if ( ! uid.isEmpty() ) { | 2253 | if ( ! uid.isEmpty() ) { |
2239 | Addressee adrr = mAddressBook->findByUid( uid ); | 2254 | Addressee adrr = mAddressBook->findByUid( uid ); |
2240 | if ( !adrr.isEmpty() ) { | 2255 | if ( !adrr.isEmpty() ) { |
2241 | foundUid = uid; | 2256 | foundUid = uid; |
2242 | } | 2257 | } |
2243 | if ( email == "sendbacklist" ) { | 2258 | if ( email == "sendbacklist" ) { |
2244 | //qDebug("ssssssssssssssssssssssend "); | 2259 | //qDebug("ssssssssssssssssssssssend "); |
2245 | QStringList nameList; | 2260 | QStringList nameList; |
2246 | QStringList emailList; | 2261 | QStringList emailList; |
2247 | QStringList uidList; | 2262 | QStringList uidList; |
2248 | nameList.append(adrr.realName()); | 2263 | nameList.append(adrr.realName()); |
2249 | emailList = adrr.emails(); | 2264 | emailList = adrr.emails(); |
2250 | uidList.append( adrr.preferredEmail()); | 2265 | uidList.append( adrr.preferredEmail()); |
2251 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2266 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2252 | return; | 2267 | return; |
2253 | } | 2268 | } |
2254 | 2269 | ||
2255 | } | 2270 | } |
2256 | 2271 | ||
2257 | if ( email == "sendbacklist" ) | 2272 | if ( email == "sendbacklist" ) |
2258 | return; | 2273 | return; |
2259 | if (foundUid.isEmpty()) | 2274 | if (foundUid.isEmpty()) |
2260 | { | 2275 | { |
2261 | //find the uid of the person first | 2276 | //find the uid of the person first |
2262 | Addressee::List namelist; | 2277 | Addressee::List namelist; |
2263 | Addressee::List emaillist; | 2278 | Addressee::List emaillist; |
2264 | 2279 | ||
2265 | if (!name.isEmpty()) | 2280 | if (!name.isEmpty()) |
2266 | namelist = mAddressBook->findByName( name ); | 2281 | namelist = mAddressBook->findByName( name ); |
2267 | 2282 | ||
2268 | if (!email.isEmpty()) | 2283 | if (!email.isEmpty()) |
2269 | emaillist = mAddressBook->findByEmail( email ); | 2284 | emaillist = mAddressBook->findByEmail( email ); |
2270 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2285 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2271 | //check if we have a match in Namelist and Emaillist | 2286 | //check if we have a match in Namelist and Emaillist |
2272 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2287 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2273 | foundUid = emaillist[0].uid(); | 2288 | foundUid = emaillist[0].uid(); |
2274 | } | 2289 | } |
2275 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2290 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2276 | foundUid = namelist[0].uid(); | 2291 | foundUid = namelist[0].uid(); |
2277 | else | 2292 | else |
2278 | { | 2293 | { |
2279 | for (int i = 0; i < namelist.count(); i++) | 2294 | for (int i = 0; i < namelist.count(); i++) |
2280 | { | 2295 | { |
2281 | for (int j = 0; j < emaillist.count(); j++) | 2296 | for (int j = 0; j < emaillist.count(); j++) |
2282 | { | 2297 | { |
2283 | if (namelist[i] == emaillist[j]) | 2298 | if (namelist[i] == emaillist[j]) |
2284 | { | 2299 | { |
2285 | foundUid = namelist[i].uid(); | 2300 | foundUid = namelist[i].uid(); |
2286 | } | 2301 | } |
2287 | } | 2302 | } |
2288 | } | 2303 | } |
2289 | } | 2304 | } |
2290 | } | 2305 | } |
2291 | else | 2306 | else |
2292 | { | 2307 | { |
2293 | foundUid = uid; | 2308 | foundUid = uid; |
2294 | } | 2309 | } |
2295 | 2310 | ||
2296 | if (!foundUid.isEmpty()) | 2311 | if (!foundUid.isEmpty()) |
2297 | { | 2312 | { |
2298 | 2313 | ||
2299 | // raise Ka/Pi if it is in the background | 2314 | // raise Ka/Pi if it is in the background |
2300 | #ifndef DESKTOP_VERSION | 2315 | #ifndef DESKTOP_VERSION |
2301 | #ifndef KORG_NODCOP | 2316 | #ifndef KORG_NODCOP |
2302 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2317 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2303 | #endif | 2318 | #endif |
2304 | #endif | 2319 | #endif |
2305 | 2320 | ||
2306 | mMainWindow->showMaximized(); | 2321 | mMainWindow->showMaximized(); |
2307 | mMainWindow-> raise(); | 2322 | mMainWindow-> raise(); |
2308 | 2323 | ||
2309 | mViewManager->setSelected( "", false); | 2324 | mViewManager->setSelected( "", false); |
2310 | mViewManager->refreshView( "" ); | 2325 | mViewManager->refreshView( "" ); |
2311 | mViewManager->setSelected( foundUid, true ); | 2326 | mViewManager->setSelected( foundUid, true ); |
2312 | mViewManager->refreshView( foundUid ); | 2327 | mViewManager->refreshView( foundUid ); |
2313 | 2328 | ||
2314 | if ( !mMultipleViewsAtOnce ) | 2329 | if ( !mMultipleViewsAtOnce ) |
2315 | { | 2330 | { |
2316 | setDetailsVisible( true ); | 2331 | setDetailsVisible( true ); |
2317 | mActionDetails->setChecked(true); | 2332 | mActionDetails->setChecked(true); |
2318 | } | 2333 | } |
2319 | } | 2334 | } |
2320 | } | 2335 | } |
2321 | 2336 | ||
2322 | 2337 | ||
2323 | void KABCore::faq() | 2338 | void KABCore::faq() |
2324 | { | 2339 | { |
2325 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2340 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2326 | } | 2341 | } |
2327 | 2342 | ||
2328 | #include <libkcal/syncdefines.h> | 2343 | #include <libkcal/syncdefines.h> |
2329 | 2344 | ||
2330 | KABC::Addressee KABCore::getLastSyncAddressee() | 2345 | KABC::Addressee KABCore::getLastSyncAddressee() |
2331 | { | 2346 | { |
2332 | Addressee lse; | 2347 | Addressee lse; |
2333 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2348 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2334 | 2349 | ||
2335 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2350 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2336 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2351 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2337 | if (lse.isEmpty()) { | 2352 | if (lse.isEmpty()) { |
2338 | qDebug("Creating new last-syncAddressee "); | 2353 | qDebug("Creating new last-syncAddressee "); |
2339 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2354 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2340 | QString sum = ""; | 2355 | QString sum = ""; |
2341 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2356 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2342 | sum = "E: "; | 2357 | sum = "E: "; |
2343 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2358 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2344 | lse.setRevision( mLastAddressbookSync ); | 2359 | lse.setRevision( mLastAddressbookSync ); |
2345 | lse.setCategories( i18n("SyncEvent") ); | 2360 | lse.setCategories( i18n("SyncEvent") ); |
2346 | mAddressBook->insertAddressee( lse ); | 2361 | mAddressBook->insertAddressee( lse ); |
2347 | } | 2362 | } |
2348 | return lse; | 2363 | return lse; |
2349 | } | 2364 | } |
2350 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2365 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2351 | { | 2366 | { |
2352 | 2367 | ||
2353 | //void setZaurusId(int id); | 2368 | //void setZaurusId(int id); |
2354 | // int zaurusId() const; | 2369 | // int zaurusId() const; |
2355 | // void setZaurusUid(int id); | 2370 | // void setZaurusUid(int id); |
2356 | // int zaurusUid() const; | 2371 | // int zaurusUid() const; |
2357 | // void setZaurusStat(int id); | 2372 | // void setZaurusStat(int id); |
2358 | // int zaurusStat() const; | 2373 | // int zaurusStat() const; |
2359 | // 0 equal | 2374 | // 0 equal |
2360 | // 1 take local | 2375 | // 1 take local |
2361 | // 2 take remote | 2376 | // 2 take remote |
2362 | // 3 cancel | 2377 | // 3 cancel |
2363 | QDateTime lastSync = mLastAddressbookSync; | 2378 | QDateTime lastSync = mLastAddressbookSync; |
2364 | QDateTime localMod = local->revision(); | 2379 | QDateTime localMod = local->revision(); |
2365 | QDateTime remoteMod = remote->revision(); | 2380 | QDateTime remoteMod = remote->revision(); |
2366 | 2381 | ||
2367 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2382 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2368 | 2383 | ||
2369 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2384 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2370 | bool remCh, locCh; | 2385 | bool remCh, locCh; |
2371 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2386 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2372 | 2387 | ||
2373 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2388 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2374 | locCh = ( localMod > mLastAddressbookSync ); | 2389 | locCh = ( localMod > mLastAddressbookSync ); |
2375 | if ( !remCh && ! locCh ) { | 2390 | if ( !remCh && ! locCh ) { |
2376 | //qDebug("both not changed "); | 2391 | //qDebug("both not changed "); |
2377 | lastSync = localMod.addDays(1); | 2392 | lastSync = localMod.addDays(1); |
2378 | if ( mode <= SYNC_PREF_ASK ) | 2393 | if ( mode <= SYNC_PREF_ASK ) |
2379 | return 0; | 2394 | return 0; |
2380 | } else { | 2395 | } else { |
2381 | if ( locCh ) { | 2396 | if ( locCh ) { |
2382 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2397 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2383 | lastSync = localMod.addDays( -1 ); | 2398 | lastSync = localMod.addDays( -1 ); |
2384 | if ( !remCh ) | 2399 | if ( !remCh ) |
2385 | remoteMod =( lastSync.addDays( -1 ) ); | 2400 | remoteMod =( lastSync.addDays( -1 ) ); |
2386 | } else { | 2401 | } else { |
2387 | //qDebug(" not loc changed "); | 2402 | //qDebug(" not loc changed "); |
2388 | lastSync = localMod.addDays( 1 ); | 2403 | lastSync = localMod.addDays( 1 ); |
2389 | if ( remCh ) | 2404 | if ( remCh ) |
2390 | remoteMod =( lastSync.addDays( 1 ) ); | 2405 | remoteMod =( lastSync.addDays( 1 ) ); |
2391 | 2406 | ||
2392 | } | 2407 | } |
2393 | } | 2408 | } |
2394 | full = true; | 2409 | full = true; |
2395 | if ( mode < SYNC_PREF_ASK ) | 2410 | if ( mode < SYNC_PREF_ASK ) |
2396 | mode = SYNC_PREF_ASK; | 2411 | mode = SYNC_PREF_ASK; |
2397 | } else { | 2412 | } else { |
2398 | if ( localMod == remoteMod ) | 2413 | if ( localMod == remoteMod ) |
2399 | return 0; | 2414 | return 0; |
2400 | 2415 | ||
2401 | } | 2416 | } |
2402 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 2417 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
2403 | 2418 | ||
2404 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); | 2419 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); |
2405 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 2420 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
2406 | //full = true; //debug only | 2421 | //full = true; //debug only |
2407 | if ( full ) { | 2422 | if ( full ) { |
2408 | bool equ = ( (*local) == (*remote) ); | 2423 | bool equ = ( (*local) == (*remote) ); |
2409 | if ( equ ) { | 2424 | if ( equ ) { |
2410 | //qDebug("equal "); | 2425 | //qDebug("equal "); |
2411 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2426 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2412 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2427 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2413 | } | 2428 | } |
2414 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2429 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2415 | return 0; | 2430 | return 0; |
2416 | 2431 | ||
2417 | }//else //debug only | 2432 | }//else //debug only |
2418 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2433 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2419 | } | 2434 | } |
2420 | int result; | 2435 | int result; |
2421 | bool localIsNew; | 2436 | bool localIsNew; |
2422 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | 2437 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); |
2423 | 2438 | ||
2424 | if ( full && mode < SYNC_PREF_NEWEST ) | 2439 | if ( full && mode < SYNC_PREF_NEWEST ) |
2425 | mode = SYNC_PREF_ASK; | 2440 | mode = SYNC_PREF_ASK; |
2426 | 2441 | ||
2427 | switch( mode ) { | 2442 | switch( mode ) { |
2428 | case SYNC_PREF_LOCAL: | 2443 | case SYNC_PREF_LOCAL: |
2429 | if ( lastSync > remoteMod ) | 2444 | if ( lastSync > remoteMod ) |
2430 | return 1; | 2445 | return 1; |
2431 | if ( lastSync > localMod ) | 2446 | if ( lastSync > localMod ) |
2432 | return 2; | 2447 | return 2; |
2433 | return 1; | 2448 | return 1; |
2434 | break; | 2449 | break; |
2435 | case SYNC_PREF_REMOTE: | 2450 | case SYNC_PREF_REMOTE: |
2436 | if ( lastSync > remoteMod ) | 2451 | if ( lastSync > remoteMod ) |
2437 | return 1; | 2452 | return 1; |
2438 | if ( lastSync > localMod ) | 2453 | if ( lastSync > localMod ) |
2439 | return 2; | 2454 | return 2; |
2440 | return 2; | 2455 | return 2; |
2441 | break; | 2456 | break; |
2442 | case SYNC_PREF_NEWEST: | 2457 | case SYNC_PREF_NEWEST: |
2443 | if ( localMod > remoteMod ) | 2458 | if ( localMod > remoteMod ) |
2444 | return 1; | 2459 | return 1; |
2445 | else | 2460 | else |
2446 | return 2; | 2461 | return 2; |
2447 | break; | 2462 | break; |
2448 | case SYNC_PREF_ASK: | 2463 | case SYNC_PREF_ASK: |
2449 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2464 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2450 | if ( lastSync > remoteMod ) | 2465 | if ( lastSync > remoteMod ) |
2451 | return 1; | 2466 | return 1; |
2452 | if ( lastSync > localMod ) | 2467 | if ( lastSync > localMod ) |
2453 | return 2; | 2468 | return 2; |
2454 | localIsNew = localMod >= remoteMod; | 2469 | localIsNew = localMod >= remoteMod; |
2455 | //qDebug("conflict! ************************************** "); | 2470 | //qDebug("conflict! ************************************** "); |
2456 | { | 2471 | { |
2457 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2472 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2458 | result = acd.executeD(localIsNew); | 2473 | result = acd.executeD(localIsNew); |
2459 | return result; | 2474 | return result; |
2460 | } | 2475 | } |
2461 | break; | 2476 | break; |
2462 | case SYNC_PREF_FORCE_LOCAL: | 2477 | case SYNC_PREF_FORCE_LOCAL: |
2463 | return 1; | 2478 | return 1; |
2464 | break; | 2479 | break; |
2465 | case SYNC_PREF_FORCE_REMOTE: | 2480 | case SYNC_PREF_FORCE_REMOTE: |
2466 | return 2; | 2481 | return 2; |
2467 | break; | 2482 | break; |
2468 | 2483 | ||
2469 | default: | 2484 | default: |
2470 | // SYNC_PREF_TAKE_BOTH not implemented | 2485 | // SYNC_PREF_TAKE_BOTH not implemented |
2471 | break; | 2486 | break; |
2472 | } | 2487 | } |
2473 | return 0; | 2488 | return 0; |
2474 | } | 2489 | } |
2475 | 2490 | ||
2476 | 2491 | ||
2477 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2492 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2478 | { | 2493 | { |
2479 | bool syncOK = true; | 2494 | bool syncOK = true; |
2480 | int addedAddressee = 0; | 2495 | int addedAddressee = 0; |
2481 | int addedAddresseeR = 0; | 2496 | int addedAddresseeR = 0; |
2482 | int deletedAddresseeR = 0; | 2497 | int deletedAddresseeR = 0; |
2483 | int deletedAddresseeL = 0; | 2498 | int deletedAddresseeL = 0; |
2484 | int changedLocal = 0; | 2499 | int changedLocal = 0; |
2485 | int changedRemote = 0; | 2500 | int changedRemote = 0; |
2486 | 2501 | ||
2487 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2502 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2488 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2503 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2489 | 2504 | ||
2490 | //QPtrList<Addressee> el = local->rawAddressees(); | 2505 | //QPtrList<Addressee> el = local->rawAddressees(); |
2491 | Addressee addresseeR; | 2506 | Addressee addresseeR; |
2492 | QString uid; | 2507 | QString uid; |
2493 | int take; | 2508 | int take; |
2494 | Addressee addresseeL; | 2509 | Addressee addresseeL; |
2495 | Addressee addresseeRSync; | 2510 | Addressee addresseeRSync; |
2496 | Addressee addresseeLSync; | 2511 | Addressee addresseeLSync; |
2497 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2512 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2498 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2513 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2499 | bool fullDateRange = false; | 2514 | bool fullDateRange = false; |
2500 | local->resetTempSyncStat(); | 2515 | local->resetTempSyncStat(); |
2501 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2516 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2502 | QDateTime modifiedCalendar = mLastAddressbookSync;; | 2517 | QDateTime modifiedCalendar = mLastAddressbookSync;; |
2503 | addresseeLSync = getLastSyncAddressee(); | 2518 | addresseeLSync = getLastSyncAddressee(); |
2504 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2519 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2505 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2520 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2506 | if ( !addresseeR.isEmpty() ) { | 2521 | if ( !addresseeR.isEmpty() ) { |
2507 | addresseeRSync = addresseeR; | 2522 | addresseeRSync = addresseeR; |
2508 | remote->removeAddressee(addresseeR ); | 2523 | remote->removeAddressee(addresseeR ); |
2509 | 2524 | ||
2510 | } else { | 2525 | } else { |
2511 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2526 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2512 | addresseeRSync = addresseeLSync ; | 2527 | addresseeRSync = addresseeLSync ; |
2513 | } else { | 2528 | } else { |
2514 | qDebug("FULLDATE 1"); | 2529 | qDebug("FULLDATE 1"); |
2515 | fullDateRange = true; | 2530 | fullDateRange = true; |
2516 | Addressee newAdd; | 2531 | Addressee newAdd; |
2517 | addresseeRSync = newAdd; | 2532 | addresseeRSync = newAdd; |
2518 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2533 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2519 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2534 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2520 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2535 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2521 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2536 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2522 | } | 2537 | } |
2523 | } | 2538 | } |
2524 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2539 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2525 | qDebug("FULLDATE 2"); | 2540 | qDebug("FULLDATE 2"); |
2526 | fullDateRange = true; | 2541 | fullDateRange = true; |
2527 | } | 2542 | } |
2528 | if ( ! fullDateRange ) { | 2543 | if ( ! fullDateRange ) { |
2529 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2544 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2530 | 2545 | ||
2531 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2546 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2532 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2547 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2533 | fullDateRange = true; | 2548 | fullDateRange = true; |
2534 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2549 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2535 | } | 2550 | } |
2536 | } | 2551 | } |
2537 | // fullDateRange = true; // debug only! | 2552 | // fullDateRange = true; // debug only! |
2538 | if ( fullDateRange ) | 2553 | if ( fullDateRange ) |
2539 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2554 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2540 | else | 2555 | else |
2541 | mLastAddressbookSync = addresseeLSync.revision(); | 2556 | mLastAddressbookSync = addresseeLSync.revision(); |
2542 | // for resyncing if own file has changed | 2557 | // for resyncing if own file has changed |
2543 | // PENDING fixme later when implemented | 2558 | // PENDING fixme later when implemented |
2544 | #if 0 | 2559 | #if 0 |
2545 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2560 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2546 | mLastAddressbookSync = loadedFileVersion; | 2561 | mLastAddressbookSync = loadedFileVersion; |
2547 | qDebug("setting mLastAddressbookSync "); | 2562 | qDebug("setting mLastAddressbookSync "); |
2548 | } | 2563 | } |
2549 | #endif | 2564 | #endif |
2550 | 2565 | ||
2551 | //qDebug("*************************** "); | 2566 | //qDebug("*************************** "); |
2552 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2567 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2553 | QStringList er = remote->uidList(); | 2568 | QStringList er = remote->uidList(); |
2554 | Addressee inR ;//= er.first(); | 2569 | Addressee inR ;//= er.first(); |
2555 | Addressee inL; | 2570 | Addressee inL; |
2556 | 2571 | ||
2557 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2572 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2558 | 2573 | ||
2559 | int modulo = (er.count()/10)+1; | 2574 | int modulo = (er.count()/10)+1; |
2560 | int incCounter = 0; | 2575 | int incCounter = 0; |
2561 | while ( incCounter < er.count()) { | 2576 | while ( incCounter < er.count()) { |
2562 | if (syncManager->isProgressBarCanceled()) | 2577 | if (syncManager->isProgressBarCanceled()) |
2563 | return false; | 2578 | return false; |
2564 | if ( incCounter % modulo == 0 ) | 2579 | if ( incCounter % modulo == 0 ) |
2565 | syncManager->showProgressBar(incCounter); | 2580 | syncManager->showProgressBar(incCounter); |
2566 | 2581 | ||
2567 | uid = er[ incCounter ]; | 2582 | uid = er[ incCounter ]; |
2568 | bool skipIncidence = false; | 2583 | bool skipIncidence = false; |
2569 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2584 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2570 | skipIncidence = true; | 2585 | skipIncidence = true; |
2571 | QString idS,OidS; | 2586 | QString idS,OidS; |
2572 | qApp->processEvents(); | 2587 | qApp->processEvents(); |
2573 | if ( !skipIncidence ) { | 2588 | if ( !skipIncidence ) { |
2574 | inL = local->findByUid( uid ); | 2589 | inL = local->findByUid( uid ); |
2575 | inR = remote->findByUid( uid ); | 2590 | inR = remote->findByUid( uid ); |
2576 | //inL.setResource( 0 ); | 2591 | //inL.setResource( 0 ); |
2577 | //inR.setResource( 0 ); | 2592 | //inR.setResource( 0 ); |
2578 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2593 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2579 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2594 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2580 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2595 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2581 | if ( take == 3 ) | 2596 | if ( take == 3 ) |
2582 | return false; | 2597 | return false; |
2583 | if ( take == 1 ) {// take local | 2598 | if ( take == 1 ) {// take local |
2584 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2599 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2585 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2600 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2586 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2601 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2587 | local->insertAddressee( inL, false ); | 2602 | local->insertAddressee( inL, false ); |
2588 | idS = inR.externalUID(); | 2603 | idS = inR.externalUID(); |
2589 | OidS = inR.originalExternalUID(); | 2604 | OidS = inR.originalExternalUID(); |
2590 | } | 2605 | } |
2591 | else | 2606 | else |
2592 | idS = inR.IDStr(); | 2607 | idS = inR.IDStr(); |
2593 | remote->removeAddressee( inR ); | 2608 | remote->removeAddressee( inR ); |
2594 | inR = inL; | 2609 | inR = inL; |
2595 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2610 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2596 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2611 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2597 | inR.setOriginalExternalUID( OidS ); | 2612 | inR.setOriginalExternalUID( OidS ); |
2598 | inR.setExternalUID( idS ); | 2613 | inR.setExternalUID( idS ); |
2599 | } else { | 2614 | } else { |
2600 | inR.setIDStr( idS ); | 2615 | inR.setIDStr( idS ); |
2601 | } | 2616 | } |
2602 | inR.setResource( 0 ); | 2617 | inR.setResource( 0 ); |
2603 | remote->insertAddressee( inR , false); | 2618 | remote->insertAddressee( inR , false); |
2604 | ++changedRemote; | 2619 | ++changedRemote; |
2605 | } else { // take == 2 take remote | 2620 | } else { // take == 2 take remote |
2606 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2621 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2607 | if ( inR.revision().date().year() < 2004 ) | 2622 | if ( inR.revision().date().year() < 2004 ) |
2608 | inR.setRevision( modifiedCalendar ); | 2623 | inR.setRevision( modifiedCalendar ); |
2609 | } | 2624 | } |
2610 | idS = inL.IDStr(); | 2625 | idS = inL.IDStr(); |
2611 | local->removeAddressee( inL ); | 2626 | local->removeAddressee( inL ); |
2612 | inL = inR; | 2627 | inL = inR; |
2613 | inL.setIDStr( idS ); | 2628 | inL.setIDStr( idS ); |
2614 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2629 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2615 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2630 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2616 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2631 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2617 | } | 2632 | } |
2618 | inL.setResource( 0 ); | 2633 | inL.setResource( 0 ); |
2619 | local->insertAddressee( inL , false ); | 2634 | local->insertAddressee( inL , false ); |
2620 | ++changedLocal; | 2635 | ++changedLocal; |
2621 | } | 2636 | } |
2622 | } | 2637 | } |
2623 | } else { // no conflict | 2638 | } else { // no conflict |
2624 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2639 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2625 | QString des = addresseeLSync.note(); | 2640 | QString des = addresseeLSync.note(); |
2626 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2641 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2627 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2642 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2628 | remote->insertAddressee( inR, false ); | 2643 | remote->insertAddressee( inR, false ); |
2629 | ++deletedAddresseeR; | 2644 | ++deletedAddresseeR; |
2630 | } else { | 2645 | } else { |
2631 | inR.setRevision( modifiedCalendar ); | 2646 | inR.setRevision( modifiedCalendar ); |
2632 | remote->insertAddressee( inR, false ); | 2647 | remote->insertAddressee( inR, false ); |
2633 | inL = inR; | 2648 | inL = inR; |
2634 | inL.setResource( 0 ); | 2649 | inL.setResource( 0 ); |
2635 | local->insertAddressee( inL , false); | 2650 | local->insertAddressee( inL , false); |
2636 | ++addedAddressee; | 2651 | ++addedAddressee; |
2637 | } | 2652 | } |
2638 | } else { | 2653 | } else { |
2639 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2654 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2640 | inR.setRevision( modifiedCalendar ); | 2655 | inR.setRevision( modifiedCalendar ); |
2641 | remote->insertAddressee( inR, false ); | 2656 | remote->insertAddressee( inR, false ); |
2642 | inR.setResource( 0 ); | 2657 | inR.setResource( 0 ); |
2643 | local->insertAddressee( inR, false ); | 2658 | local->insertAddressee( inR, false ); |
2644 | ++addedAddressee; | 2659 | ++addedAddressee; |
2645 | } else { | 2660 | } else { |
2646 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2661 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2647 | remote->removeAddressee( inR ); | 2662 | remote->removeAddressee( inR ); |
2648 | ++deletedAddresseeR; | 2663 | ++deletedAddresseeR; |
2649 | } | 2664 | } |
2650 | } | 2665 | } |
2651 | } | 2666 | } |
2652 | } | 2667 | } |
2653 | ++incCounter; | 2668 | ++incCounter; |
2654 | } | 2669 | } |
2655 | er.clear(); | 2670 | er.clear(); |
2656 | QStringList el = local->uidList(); | 2671 | QStringList el = local->uidList(); |
2657 | modulo = (el.count()/10)+1; | 2672 | modulo = (el.count()/10)+1; |
2658 | 2673 | ||
2659 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 2674 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2660 | incCounter = 0; | 2675 | incCounter = 0; |
2661 | while ( incCounter < el.count()) { | 2676 | while ( incCounter < el.count()) { |
2662 | qApp->processEvents(); | 2677 | qApp->processEvents(); |
2663 | if (syncManager->isProgressBarCanceled()) | 2678 | if (syncManager->isProgressBarCanceled()) |
2664 | return false; | 2679 | return false; |
2665 | if ( incCounter % modulo == 0 ) | 2680 | if ( incCounter % modulo == 0 ) |
2666 | syncManager->showProgressBar(incCounter); | 2681 | syncManager->showProgressBar(incCounter); |
2667 | uid = el[ incCounter ]; | 2682 | uid = el[ incCounter ]; |
2668 | bool skipIncidence = false; | 2683 | bool skipIncidence = false; |
2669 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2684 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2670 | skipIncidence = true; | 2685 | skipIncidence = true; |
2671 | if ( !skipIncidence ) { | 2686 | if ( !skipIncidence ) { |
2672 | inL = local->findByUid( uid ); | 2687 | inL = local->findByUid( uid ); |
2673 | inR = remote->findByUid( uid ); | 2688 | inR = remote->findByUid( uid ); |
2674 | if ( inR.isEmpty() ) { | 2689 | if ( inR.isEmpty() ) { |
2675 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2690 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2676 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2691 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2677 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2692 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2678 | local->removeAddressee( inL ); | 2693 | local->removeAddressee( inL ); |
2679 | ++deletedAddresseeL; | 2694 | ++deletedAddresseeL; |
2680 | } else { | 2695 | } else { |
2681 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2696 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2682 | inL.removeID(mCurrentSyncDevice ); | 2697 | inL.removeID(mCurrentSyncDevice ); |
2683 | ++addedAddresseeR; | 2698 | ++addedAddresseeR; |
2684 | inL.setRevision( modifiedCalendar ); | 2699 | inL.setRevision( modifiedCalendar ); |
2685 | local->insertAddressee( inL, false ); | 2700 | local->insertAddressee( inL, false ); |
2686 | inR = inL; | 2701 | inR = inL; |
2687 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 2702 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
2688 | inR.setResource( 0 ); | 2703 | inR.setResource( 0 ); |
2689 | remote->insertAddressee( inR, false ); | 2704 | remote->insertAddressee( inR, false ); |
2690 | } | 2705 | } |
2691 | } | 2706 | } |
2692 | } else { | 2707 | } else { |
2693 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2708 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2694 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2709 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2695 | local->removeAddressee( inL ); | 2710 | local->removeAddressee( inL ); |
2696 | ++deletedAddresseeL; | 2711 | ++deletedAddresseeL; |
2697 | } else { | 2712 | } else { |
2698 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2713 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2699 | ++addedAddresseeR; | 2714 | ++addedAddresseeR; |
2700 | inL.setRevision( modifiedCalendar ); | 2715 | inL.setRevision( modifiedCalendar ); |
2701 | local->insertAddressee( inL, false ); | 2716 | local->insertAddressee( inL, false ); |
2702 | inR = inL; | 2717 | inR = inL; |
2703 | inR.setResource( 0 ); | 2718 | inR.setResource( 0 ); |
2704 | remote->insertAddressee( inR, false ); | 2719 | remote->insertAddressee( inR, false ); |
2705 | } | 2720 | } |
2706 | } | 2721 | } |
2707 | } | 2722 | } |
2708 | } | 2723 | } |
2709 | } | 2724 | } |
2710 | ++incCounter; | 2725 | ++incCounter; |
2711 | } | 2726 | } |
2712 | el.clear(); | 2727 | el.clear(); |
2713 | syncManager->hideProgressBar(); | 2728 | syncManager->hideProgressBar(); |
2714 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2729 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2715 | // get rid of micro seconds | 2730 | // get rid of micro seconds |
2716 | QTime t = mLastAddressbookSync.time(); | 2731 | QTime t = mLastAddressbookSync.time(); |
2717 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2732 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2718 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2733 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2719 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2734 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2720 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2735 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2721 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2736 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2722 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2737 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2723 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2738 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2724 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2739 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2725 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2740 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2726 | addresseeRSync.setNote( "" ) ; | 2741 | addresseeRSync.setNote( "" ) ; |
2727 | addresseeLSync.setNote( "" ); | 2742 | addresseeLSync.setNote( "" ); |
2728 | 2743 | ||
2729 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2744 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2730 | remote->insertAddressee( addresseeRSync, false ); | 2745 | remote->insertAddressee( addresseeRSync, false ); |
2731 | local->insertAddressee( addresseeLSync, false ); | 2746 | local->insertAddressee( addresseeLSync, false ); |
2732 | QString mes; | 2747 | QString mes; |
2733 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); | 2748 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); |
2734 | if ( syncManager->mShowSyncSummary ) { | 2749 | if ( syncManager->mShowSyncSummary ) { |
2735 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2750 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2736 | } | 2751 | } |
2737 | qDebug( mes ); | 2752 | qDebug( mes ); |
2738 | return syncOK; | 2753 | return syncOK; |
2739 | } | 2754 | } |
2740 | 2755 | ||
2741 | 2756 | ||
2742 | //this is a overwritten callbackmethods from the syncinterface | 2757 | //this is a overwritten callbackmethods from the syncinterface |
2743 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 2758 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
2744 | { | 2759 | { |
2745 | 2760 | ||
2746 | //pending prepare addresseeview for output | 2761 | //pending prepare addresseeview for output |
2747 | //pending detect, if remote file has REV field. if not switch to external sync | 2762 | //pending detect, if remote file has REV field. if not switch to external sync |
2748 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2763 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2749 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2764 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2750 | 2765 | ||
2751 | AddressBook abLocal(filename,"syncContact"); | 2766 | AddressBook abLocal(filename,"syncContact"); |
2752 | bool syncOK = false; | 2767 | bool syncOK = false; |
2753 | if ( abLocal.load() ) { | 2768 | if ( abLocal.load() ) { |
2754 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2769 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2755 | bool external = false; | 2770 | bool external = false; |
2756 | bool isXML = false; | 2771 | bool isXML = false; |
2757 | if ( filename.right(4) == ".xml") { | 2772 | if ( filename.right(4) == ".xml") { |
2758 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2773 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2759 | isXML = true; | 2774 | isXML = true; |
2760 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2775 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); |
2761 | } else { | 2776 | } else { |
2762 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2777 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2763 | if ( ! lse.isEmpty() ) { | 2778 | if ( ! lse.isEmpty() ) { |
2764 | if ( lse.familyName().left(4) == "!E: " ) | 2779 | if ( lse.familyName().left(4) == "!E: " ) |
2765 | external = true; | 2780 | external = true; |
2766 | } else { | 2781 | } else { |
2767 | bool found = false; | 2782 | bool found = false; |
2768 | AddressBook::Iterator it; | 2783 | AddressBook::Iterator it; |
2769 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2784 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2770 | if ( (*it).revision().date().year() > 2003 ) { | 2785 | if ( (*it).revision().date().year() > 2003 ) { |
2771 | found = true; | 2786 | found = true; |
2772 | break; | 2787 | break; |
2773 | } | 2788 | } |
2774 | } | 2789 | } |
2775 | external = ! found; | 2790 | external = ! found; |
2776 | } | 2791 | } |
2777 | 2792 | ||
2778 | if ( external ) { | 2793 | if ( external ) { |
2779 | qDebug("Setting vcf mode to external "); | 2794 | qDebug("Setting vcf mode to external "); |
2780 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2795 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2781 | AddressBook::Iterator it; | 2796 | AddressBook::Iterator it; |
2782 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2797 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2783 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2798 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2784 | (*it).computeCsum( mCurrentSyncDevice ); | 2799 | (*it).computeCsum( mCurrentSyncDevice ); |
2785 | } | 2800 | } |
2786 | } | 2801 | } |
2787 | } | 2802 | } |
2788 | //AddressBook::Iterator it; | 2803 | //AddressBook::Iterator it; |
2789 | //QStringList vcards; | 2804 | //QStringList vcards; |
2790 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2805 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2791 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2806 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2792 | //} | 2807 | //} |
2793 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2808 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2794 | if ( syncOK ) { | 2809 | if ( syncOK ) { |
2795 | if ( syncManager->mWriteBackFile ) | 2810 | if ( syncManager->mWriteBackFile ) |
2796 | { | 2811 | { |
2797 | if ( external ) | 2812 | if ( external ) |
2798 | abLocal.removeSyncAddressees( !isXML); | 2813 | abLocal.removeSyncAddressees( !isXML); |
2799 | qDebug("Saving remote AB "); | 2814 | qDebug("Saving remote AB "); |
2800 | abLocal.saveAB(); | 2815 | abLocal.saveAB(); |
2801 | if ( isXML ) { | 2816 | if ( isXML ) { |
2802 | // afterwrite processing | 2817 | // afterwrite processing |
2803 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2818 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2804 | } | 2819 | } |
2805 | } | 2820 | } |
2806 | } | 2821 | } |
2807 | setModified(); | 2822 | setModified(); |
2808 | 2823 | ||
2809 | } | 2824 | } |
2810 | if ( syncOK ) | 2825 | if ( syncOK ) |
2811 | mViewManager->refreshView(); | 2826 | mViewManager->refreshView(); |
2812 | return syncOK; | 2827 | return syncOK; |
2813 | #if 0 | 2828 | #if 0 |
2814 | 2829 | ||
2815 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 2830 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
2816 | getEventViewerDialog()->setSyncMode( true ); | 2831 | getEventViewerDialog()->setSyncMode( true ); |
2817 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 2832 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
2818 | getEventViewerDialog()->setSyncMode( false ); | 2833 | getEventViewerDialog()->setSyncMode( false ); |
2819 | if ( syncOK ) { | 2834 | if ( syncOK ) { |
2820 | if ( KOPrefs::instance()->mWriteBackFile ) | 2835 | if ( KOPrefs::instance()->mWriteBackFile ) |
2821 | { | 2836 | { |
2822 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2837 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
2823 | storage->save(); | 2838 | storage->save(); |
2824 | } | 2839 | } |
2825 | } | 2840 | } |
2826 | setModified(); | 2841 | setModified(); |
2827 | } | 2842 | } |
2828 | 2843 | ||
2829 | #endif | 2844 | #endif |
2830 | } | 2845 | } |
2831 | 2846 | ||
2832 | 2847 | ||
2833 | //this is a overwritten callbackmethods from the syncinterface | 2848 | //this is a overwritten callbackmethods from the syncinterface |
2834 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2849 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2835 | { | 2850 | { |
2836 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2851 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2837 | 2852 | ||
2838 | AddressBook abLocal( resource,"syncContact"); | 2853 | AddressBook abLocal( resource,"syncContact"); |
2839 | bool syncOK = false; | 2854 | bool syncOK = false; |
2840 | if ( abLocal.load() ) { | 2855 | if ( abLocal.load() ) { |
2841 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2856 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2842 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2857 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2843 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2858 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); |
2844 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2859 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2845 | if ( syncOK ) { | 2860 | if ( syncOK ) { |
2846 | if ( syncManager->mWriteBackFile ) { | 2861 | if ( syncManager->mWriteBackFile ) { |
2847 | abLocal.saveAB(); | 2862 | abLocal.saveAB(); |
2848 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2863 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2849 | } | 2864 | } |
2850 | } | 2865 | } |
2851 | setModified(); | 2866 | setModified(); |
2852 | } | 2867 | } |
2853 | if ( syncOK ) | 2868 | if ( syncOK ) |
2854 | mViewManager->refreshView(); | 2869 | mViewManager->refreshView(); |
2855 | return syncOK; | 2870 | return syncOK; |
2856 | 2871 | ||
2857 | } | 2872 | } |
2858 | 2873 | ||
2859 | void KABCore::getFile( bool success ) | 2874 | void KABCore::getFile( bool success ) |
2860 | { | 2875 | { |
2861 | QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); | 2876 | QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); |
2862 | if ( ! success ) { | 2877 | if ( ! success ) { |
2863 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 2878 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
2864 | return; | 2879 | return; |
2865 | } | 2880 | } |
2866 | mAddressBook->importFromFile( sentSyncFile() ); | 2881 | mAddressBook->importFromFile( sentSyncFile() ); |
2867 | topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); | 2882 | topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); |
2868 | mViewManager->refreshView(); | 2883 | mViewManager->refreshView(); |
2869 | } | 2884 | } |
2870 | void KABCore::syncFileRequest() | 2885 | void KABCore::syncFileRequest() |
2871 | { | 2886 | { |
2872 | mAddressBook->export2File( sentSyncFile() ); | 2887 | mAddressBook->export2File( sentSyncFile() ); |
2873 | } | 2888 | } |
2874 | QString KABCore::sentSyncFile() | 2889 | QString KABCore::sentSyncFile() |
2875 | { | 2890 | { |
2876 | #ifdef _WIN32_ | 2891 | #ifdef _WIN32_ |
2877 | return locateLocal( "tmp", "copysyncab.vcf" ); | 2892 | return locateLocal( "tmp", "copysyncab.vcf" ); |
2878 | #else | 2893 | #else |
2879 | return QString( "/tmp/copysyncab.vcf" ); | 2894 | return QString( "/tmp/copysyncab.vcf" ); |
2880 | #endif | 2895 | #endif |
2881 | } | 2896 | } |
2882 | 2897 | ||
2883 | void KABCore::setCaptionBack() | 2898 | void KABCore::setCaptionBack() |
2884 | { | 2899 | { |
2885 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 2900 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
2886 | } | 2901 | } |