summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp31
-rw-r--r--kaddressbook/imagewidget.cpp5
-rw-r--r--kaddressbook/kabcore.cpp7
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp2
4 files changed, 38 insertions, 7 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index bfcfab5..18b4d58 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1,1048 +1,1073 @@
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/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (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
43using namespace KABC; 43using namespace KABC;
44 44
45static bool matchBinaryPattern( int value, int pattern ); 45static bool matchBinaryPattern( int value, int pattern );
46static bool matchBinaryPatternA( int value, int pattern ); 46static bool matchBinaryPatternA( int value, int pattern );
47static bool matchBinaryPatternP( int value, int pattern ); 47static bool matchBinaryPatternP( int value, int pattern );
48 48
49struct Addressee::AddresseeData : public KShared 49struct Addressee::AddresseeData : public KShared
50{ 50{
51 QString uid; 51 QString uid;
52 QString name; 52 QString name;
53 QString formattedName; 53 QString formattedName;
54 QString familyName; 54 QString familyName;
55 QString givenName; 55 QString givenName;
56 QString additionalName; 56 QString additionalName;
57 QString prefix; 57 QString prefix;
58 QString suffix; 58 QString suffix;
59 QString nickName; 59 QString nickName;
60 QDateTime birthday; 60 QDateTime birthday;
61 QString mailer; 61 QString mailer;
62 TimeZone timeZone; 62 TimeZone timeZone;
63 Geo geo; 63 Geo geo;
64 QString title; 64 QString title;
65 QString role; 65 QString role;
66 QString organization; 66 QString organization;
67 QString note; 67 QString note;
68 QString productId; 68 QString productId;
69 QDateTime revision; 69 QDateTime revision;
70 QString sortString; 70 QString sortString;
71 QString externalUID; 71 QString externalUID;
72 QString originalExternalUID; 72 QString originalExternalUID;
73 KURL url; 73 KURL url;
74 Secrecy secrecy; 74 Secrecy secrecy;
75 Picture logo; 75 Picture logo;
76 Picture photo; 76 Picture photo;
77 Sound sound; 77 Sound sound;
78 Agent agent; 78 Agent agent;
79 QString mExternalId; 79 QString mExternalId;
80 PhoneNumber::List phoneNumbers; 80 PhoneNumber::List phoneNumbers;
81 Address::List addresses; 81 Address::List addresses;
82 Key::List keys; 82 Key::List keys;
83 QStringList emails; 83 QStringList emails;
84 QStringList categories; 84 QStringList categories;
85 QStringList custom; 85 QStringList custom;
86 int mTempSyncStat; 86 int mTempSyncStat;
87 Resource *resource; 87 Resource *resource;
88 88
89 bool empty :1; 89 bool empty :1;
90 bool changed :1; 90 bool changed :1;
91 bool tagged :1; 91 bool tagged :1;
92}; 92};
93 93
94Addressee::Addressee() 94Addressee::Addressee()
95{ 95{
96 mData = new AddresseeData; 96 mData = new AddresseeData;
97 mData->empty = true; 97 mData->empty = true;
98 mData->changed = false; 98 mData->changed = false;
99 mData->resource = 0; 99 mData->resource = 0;
100 mData->mExternalId = ":"; 100 mData->mExternalId = ":";
101 mData->revision = QDateTime ( QDate( 2003,1,1)); 101 mData->revision = QDateTime ( QDate( 2003,1,1));
102 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 102 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
103} 103}
104 104
105Addressee::~Addressee() 105Addressee::~Addressee()
106{ 106{
107} 107}
108 108
109Addressee::Addressee( const Addressee &a ) 109Addressee::Addressee( const Addressee &a )
110{ 110{
111 mData = a.mData; 111 mData = a.mData;
112} 112}
113 113
114Addressee &Addressee::operator=( const Addressee &a ) 114Addressee &Addressee::operator=( const Addressee &a )
115{ 115{
116 mData = a.mData; 116 mData = a.mData;
117 return (*this); 117 return (*this);
118} 118}
119 119
120Addressee Addressee::copy() 120Addressee Addressee::copy()
121{ 121{
122 Addressee a; 122 Addressee a;
123 *(a.mData) = *mData; 123 *(a.mData) = *mData;
124 return a; 124 return a;
125} 125}
126 126
127void Addressee::detach() 127void Addressee::detach()
128{ 128{
129 if ( mData.count() == 1 ) return; 129 if ( mData.count() == 1 ) return;
130 *this = copy(); 130 *this = copy();
131} 131}
132 132
133bool Addressee::operator==( const Addressee &a ) const 133bool Addressee::operator==( const Addressee &a ) const
134{ 134{
135 if ( uid() != a.uid() ) return false; 135 if ( uid() != a.uid() ) return false;
136 if ( mData->name != a.mData->name ) return false; 136 if ( mData->name != a.mData->name ) return false;
137 if ( mData->formattedName != a.mData->formattedName ) return false; 137 if ( mData->formattedName != a.mData->formattedName ) return false;
138 if ( mData->familyName != a.mData->familyName ) return false; 138 if ( mData->familyName != a.mData->familyName ) return false;
139 if ( mData->givenName != a.mData->givenName ) return false; 139 if ( mData->givenName != a.mData->givenName ) return false;
140 if ( mData->additionalName != a.mData->additionalName ) return false; 140 if ( mData->additionalName != a.mData->additionalName ) return false;
141 if ( mData->prefix != a.mData->prefix ) return false; 141 if ( mData->prefix != a.mData->prefix ) return false;
142 if ( mData->suffix != a.mData->suffix ) return false; 142 if ( mData->suffix != a.mData->suffix ) return false;
143 if ( mData->nickName != a.mData->nickName ) return false; 143 if ( mData->nickName != a.mData->nickName ) return false;
144 if ( mData->birthday != a.mData->birthday ) return false; 144 if ( mData->birthday != a.mData->birthday ) return false;
145 if ( mData->mailer != a.mData->mailer ) return false; 145 if ( mData->mailer != a.mData->mailer ) return false;
146 if ( mData->timeZone != a.mData->timeZone ) return false; 146 if ( mData->timeZone != a.mData->timeZone ) return false;
147 if ( mData->geo != a.mData->geo ) return false; 147 if ( mData->geo != a.mData->geo ) return false;
148 if ( mData->title != a.mData->title ) return false; 148 if ( mData->title != a.mData->title ) return false;
149 if ( mData->role != a.mData->role ) return false; 149 if ( mData->role != a.mData->role ) return false;
150 if ( mData->organization != a.mData->organization ) return false; 150 if ( mData->organization != a.mData->organization ) return false;
151 if ( mData->note != a.mData->note ) return false; 151 if ( mData->note != a.mData->note ) return false;
152 if ( mData->productId != a.mData->productId ) return false; 152 if ( mData->productId != a.mData->productId ) return false;
153 //if ( mData->revision != a.mData->revision ) return false; 153 //if ( mData->revision != a.mData->revision ) return false;
154 if ( mData->sortString != a.mData->sortString ) return false; 154 if ( mData->sortString != a.mData->sortString ) return false;
155 if ( mData->secrecy != a.mData->secrecy ) return false; 155 if ( mData->secrecy != a.mData->secrecy ) return false;
156 if ( mData->logo != a.mData->logo ) return false; 156 if ( mData->logo != a.mData->logo ) return false;
157 if ( mData->photo != a.mData->photo ) return false; 157 if ( mData->photo != a.mData->photo ) return false;
158 if ( mData->sound != a.mData->sound ) return false; 158 if ( mData->sound != a.mData->sound ) return false;
159 if ( mData->agent != a.mData->agent ) return false; 159 if ( mData->agent != a.mData->agent ) return false;
160 if ( ( mData->url.isValid() || a.mData->url.isValid() ) && 160 if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
161 ( mData->url != a.mData->url ) ) return false; 161 ( mData->url != a.mData->url ) ) return false;
162 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; 162 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
163 if ( mData->addresses != a.mData->addresses ) return false; 163 if ( mData->addresses != a.mData->addresses ) return false;
164 if ( mData->keys != a.mData->keys ) return false; 164 if ( mData->keys != a.mData->keys ) return false;
165 if ( mData->emails != a.mData->emails ) return false; 165 if ( mData->emails != a.mData->emails ) return false;
166 if ( mData->categories != a.mData->categories ) return false; 166 if ( mData->categories != a.mData->categories ) return false;
167 if ( mData->custom != a.mData->custom ) return false; 167 if ( mData->custom != a.mData->custom ) return false;
168 168
169 return true; 169 return true;
170} 170}
171 171
172bool Addressee::operator!=( const Addressee &a ) const 172bool Addressee::operator!=( const Addressee &a ) const
173{ 173{
174 return !( a == *this ); 174 return !( a == *this );
175} 175}
176 176
177bool Addressee::isEmpty() const 177bool Addressee::isEmpty() const
178{ 178{
179 return mData->empty; 179 return mData->empty;
180} 180}
181ulong Addressee::getCsum4List( const QStringList & attList) 181ulong Addressee::getCsum4List( const QStringList & attList)
182{ 182{
183 int max = attList.count(); 183 int max = attList.count();
184 ulong cSum = 0; 184 ulong cSum = 0;
185 int j,k,i; 185 int j,k,i;
186 int add; 186 int add;
187 for ( i = 0; i < max ; ++i ) { 187 for ( i = 0; i < max ; ++i ) {
188 QString s = attList[i]; 188 QString s = attList[i];
189 if ( ! s.isEmpty() ){ 189 if ( ! s.isEmpty() ){
190 j = s.length(); 190 j = s.length();
191 for ( k = 0; k < j; ++k ) { 191 for ( k = 0; k < j; ++k ) {
192 int mul = k +1; 192 int mul = k +1;
193 add = s[k].unicode (); 193 add = s[k].unicode ();
194 if ( k < 16 ) 194 if ( k < 16 )
195 mul = mul * mul; 195 mul = mul * mul;
196 int ii = i+1; 196 int ii = i+1;
197 add = add * mul *ii*ii*ii; 197 add = add * mul *ii*ii*ii;
198 cSum += add; 198 cSum += add;
199 //qDebug("csum: %d %d %d", i,k,cSum);
199 } 200 }
200 } 201 }
201 202
202 } 203 }
203 //QString dump = attList.join(","); 204 //QString dump = attList.join(",");
204 //qDebug("csum: %d %s", cSum,dump.latin1()); 205 //qDebug("csum: %d %s", cSum,dump.latin1());
205 206
206 return cSum; 207 return cSum;
207 208
208} 209}
209void Addressee::computeCsum(const QString &dev) 210void Addressee::computeCsum(const QString &dev)
210{ 211{
211 QStringList l; 212 QStringList l;
212 //if ( !mData->name.isEmpty() ) l.append(mData->name); 213 //if ( !mData->name.isEmpty() ) l.append(mData->name);
213 //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 214 //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
214 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 215 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
215 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 216 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
216 if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); 217 if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName );
217 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 218 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
218 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 219 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
219 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 220 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
220 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 221 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
221 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 222 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
222 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 223 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
223 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 224 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
224 if ( !mData->title .isEmpty() ) l.append( mData->title ); 225 if ( !mData->title .isEmpty() ) l.append( mData->title );
225 if ( !mData->role.isEmpty() ) l.append( mData->role ); 226 if ( !mData->role.isEmpty() ) l.append( mData->role );
226 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 227 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
227 if ( !mData->note.isEmpty() ) l.append( mData->note ); 228 if ( !mData->note.isEmpty() ) l.append( mData->note );
228 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 229 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
229 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 230 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
230 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 231 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
231 // if ( !mData->logo.isEmpty() ) l.append( ); 232 if ( !mData->logo.undefined() ) {
232 //if ( !mData->photo.isEmpty() ) l.append( ); 233 if ( !mData->logo.isIntern() )
233 //if ( !mData->sound.isEmpty() ) l.append( ); 234 l.append( mData->logo.url() );
235 else
236 l.append( QString::number(mData->logo.data().width()* mData->logo.data().height()));
237 } else {
238 l.append( "nologo");
239 }
240 if ( !mData->photo.undefined() ) {
241 if ( !mData->photo.isIntern() )
242 l.append( mData->photo.url() );
243 else
244 l.append( QString::number(mData->photo.data().width()* mData->photo.data().height()));
245 } else {
246 l.append( "nophoto");
247 }
248#if 0
249 if ( !mData->sound.undefined() ) {
250 if ( !mData->sound.isIntern() )
251 l.append( mData->sound.url() );
252 else
253 l.append( QString(mData->sound.data().with()* mData->sound.data().height()));
254 } else {
255 l.append( "nosound");
256 }
257#endif
234 //if ( !mData->agent.isEmpty() ) l.append( ); 258 //if ( !mData->agent.isEmpty() ) l.append( );
235 if ( mData->url.isValid() ) 259 if ( mData->url.isValid() )
236 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); 260 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() );
237 KABC::PhoneNumber::List phoneNumbers; 261 KABC::PhoneNumber::List phoneNumbers;
238 KABC::PhoneNumber::List::Iterator phoneIter; 262 KABC::PhoneNumber::List::Iterator phoneIter;
239 263
240 QStringList t; 264 QStringList t;
241 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 265 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
242 ++phoneIter ) 266 ++phoneIter )
243 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 267 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
244 t.sort(); 268 t.sort();
245 uint iii; 269 uint iii;
246 for ( iii = 0; iii < t.count(); ++iii) 270 for ( iii = 0; iii < t.count(); ++iii)
247 l.append( t[iii] ); 271 l.append( t[iii] );
248 t = mData->emails; 272 t = mData->emails;
249 t.sort(); 273 t.sort();
250 for ( iii = 0; iii < t.count(); ++iii) 274 for ( iii = 0; iii < t.count(); ++iii)
251 l.append( t[iii] ); 275 l.append( t[iii] );
252 t = mData->categories; 276 t = mData->categories;
253 t.sort(); 277 t.sort();
254 for ( iii = 0; iii < t.count(); ++iii) 278 for ( iii = 0; iii < t.count(); ++iii)
255 l.append( t[iii] ); 279 l.append( t[iii] );
256 t = mData->custom; 280 t = mData->custom;
257 t.sort(); 281 t.sort();
258 for ( iii = 0; iii < t.count(); ++iii) 282 for ( iii = 0; iii < t.count(); ++iii)
259 if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { 283 if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) {
260 int find = t[iii].find (':')+1; 284 int find = t[iii].find (':')+1;
261 //qDebug("lennnn %d %d ", find, t[iii].length()); 285 //qDebug("lennnn %d %d ", find, t[iii].length());
262 if ( find < t[iii].length()) 286 if ( find < t[iii].length())
263 l.append( t[iii] ); 287 l.append( t[iii] );
264 288
265 } 289 }
266 KABC::Address::List::Iterator addressIter; 290 KABC::Address::List::Iterator addressIter;
267 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 291 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
268 ++addressIter ) { 292 ++addressIter ) {
269 t = (*addressIter).asList(); 293 t = (*addressIter).asList();
270 t.sort(); 294 t.sort();
271 for ( iii = 0; iii < t.count(); ++iii) 295 for ( iii = 0; iii < t.count(); ++iii)
272 l.append( t[iii] ); 296 l.append( t[iii] );
273 } 297 }
274 uint cs = getCsum4List(l); 298 uint cs = getCsum4List(l);
275 299
276#if 0 300#if 0
277 for ( iii = 0; iii < l.count(); ++iii) 301 for ( iii = 0; iii < l.count(); ++iii)
278 qDebug("%d***%s***",iii,l[iii].latin1()); 302 qDebug("%d***%s***",iii,l[iii].latin1());
279 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 303 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
280#endif 304#endif
305
281 306
282 setCsum( dev, QString::number (cs )); 307 setCsum( dev, QString::number (cs ));
283} 308}
284 309
285void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) 310void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
286{ 311{
287 // merge all standard non-outlook fields. 312 // merge all standard non-outlook fields.
288 //if isSubSet (e.g. mobile phone sync) merge all fields 313 //if isSubSet (e.g. mobile phone sync) merge all fields
289 314
290 detach(); 315 detach();
291 if ( isSubSet ) { 316 if ( isSubSet ) {
292 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 317 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
293 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 318 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
294 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 319 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
295 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 320 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
296 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 321 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
297 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 322 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
298 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 323 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
299 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 324 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
300 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 325 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
301 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 326 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
302 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 327 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
303 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 328 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
304 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 329 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
305 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 330 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
306 if ( !mData->birthday.isValid() ) 331 if ( !mData->birthday.isValid() )
307 if ( ad.mData->birthday.isValid()) 332 if ( ad.mData->birthday.isValid())
308 mData->birthday = ad.mData->birthday; 333 mData->birthday = ad.mData->birthday;
309 334
310 } 335 }
311 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 336 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
312 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 337 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
313 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 338 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
314 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 339 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
315 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 340 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
316 QStringList t; 341 QStringList t;
317 QStringList tAD; 342 QStringList tAD;
318 uint iii; 343 uint iii;
319 344
320 // ********** phone numbers 345 // ********** phone numbers
321 if ( isSubSet ) { 346 if ( isSubSet ) {
322 PhoneNumber::List phoneAD = ad.phoneNumbers(); 347 PhoneNumber::List phoneAD = ad.phoneNumbers();
323 PhoneNumber::List::Iterator phoneItAD; 348 PhoneNumber::List::Iterator phoneItAD;
324 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 349 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
325 bool found = false; 350 bool found = false;
326 PhoneNumber::List::Iterator it; 351 PhoneNumber::List::Iterator it;
327 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 352 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
328 if ( ( *phoneItAD ).contains( (*it) ) ) { 353 if ( ( *phoneItAD ).contains( (*it) ) ) {
329 found = true; 354 found = true;
330 (*it).setType( ( *phoneItAD ).type() ); 355 (*it).setType( ( *phoneItAD ).type() );
331 (*it).setNumber( ( *phoneItAD ).number() ); 356 (*it).setNumber( ( *phoneItAD ).number() );
332 break; 357 break;
333 } 358 }
334 } 359 }
335 // if ( isSubSet && ! found ) 360 // if ( isSubSet && ! found )
336 if ( ! found ) // LR try this one... 361 if ( ! found ) // LR try this one...
337 mData->phoneNumbers.append( *phoneItAD ); 362 mData->phoneNumbers.append( *phoneItAD );
338 } 363 }
339 } else { 364 } else {
340 PhoneNumber::List phoneAD = ad.phoneNumbers(); 365 PhoneNumber::List phoneAD = ad.phoneNumbers();
341 PhoneNumber::List::Iterator phoneItAD; 366 PhoneNumber::List::Iterator phoneItAD;
342 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 367 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
343 bool found = false; 368 bool found = false;
344 PhoneNumber::List::Iterator it; 369 PhoneNumber::List::Iterator it;
345 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 370 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
346 if ( ( *phoneItAD ).contains( (*it) ) ) { 371 if ( ( *phoneItAD ).contains( (*it) ) ) {
347 found = true; 372 found = true;
348 (*it).setType( ( *phoneItAD ).type() ); 373 (*it).setType( ( *phoneItAD ).type() );
349 (*it).setNumber( ( *phoneItAD ).number() ); 374 (*it).setNumber( ( *phoneItAD ).number() );
350 break; 375 break;
351 } 376 }
352 } 377 }
353 if ( ! found ) { // append numbers which do not have work or home type 378 if ( ! found ) { // append numbers which do not have work or home type
354 if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) ) 379 if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) )
355 mData->phoneNumbers.append( *phoneItAD ); 380 mData->phoneNumbers.append( *phoneItAD );
356 } 381 }
357 } 382 }
358 } 383 }
359 if ( isSubSet ) { 384 if ( isSubSet ) {
360 // ************* emails; 385 // ************* emails;
361 t = mData->emails; 386 t = mData->emails;
362 tAD = ad.mData->emails; 387 tAD = ad.mData->emails;
363 for ( iii = 0; iii < tAD.count(); ++iii) 388 for ( iii = 0; iii < tAD.count(); ++iii)
364 if ( !t.contains(tAD[iii] ) ) 389 if ( !t.contains(tAD[iii] ) )
365 mData->emails.append( tAD[iii] ); 390 mData->emails.append( tAD[iii] );
366 } 391 }
367 392
368 // ************* categories; 393 // ************* categories;
369 if ( isSubSet ) { 394 if ( isSubSet ) {
370 t = mData->categories; 395 t = mData->categories;
371 tAD = ad.mData->categories; 396 tAD = ad.mData->categories;
372 for ( iii = 0; iii < tAD.count(); ++iii) 397 for ( iii = 0; iii < tAD.count(); ++iii)
373 if ( !t.contains(tAD[iii] ) ) 398 if ( !t.contains(tAD[iii] ) )
374 mData->categories.append( tAD[iii] ); 399 mData->categories.append( tAD[iii] );
375 } 400 }
376 QStringList::ConstIterator it; 401 QStringList::ConstIterator it;
377 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { 402 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) {
378 QString qualifiedName = (*it).left( (*it).find( ":" )); 403 QString qualifiedName = (*it).left( (*it).find( ":" ));
379 bool found = false; 404 bool found = false;
380 QStringList::ConstIterator itL; 405 QStringList::ConstIterator itL;
381 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { 406 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) {
382 if ( (*itL).startsWith( qualifiedName ) ) { 407 if ( (*itL).startsWith( qualifiedName ) ) {
383 found = true; 408 found = true;
384 break; 409 break;
385 } 410 }
386 } 411 }
387 if ( ! found ) { 412 if ( ! found ) {
388 mData->custom.append( *it ); 413 mData->custom.append( *it );
389 } 414 }
390 } 415 }
391 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; 416 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo;
392 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; 417 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo;
393 if ( !mData->sound.isIntern() ) { 418 if ( !mData->sound.isIntern() ) {
394 if ( mData->sound.url().isEmpty() ) { 419 if ( mData->sound.url().isEmpty() ) {
395 mData->sound = ad.mData->sound; 420 mData->sound = ad.mData->sound;
396 } 421 }
397 } 422 }
398 if ( !mData->agent.isIntern() ) { 423 if ( !mData->agent.isIntern() ) {
399 if ( mData->agent.url().isEmpty() ) { 424 if ( mData->agent.url().isEmpty() ) {
400 mData->agent = ad.mData->agent; 425 mData->agent = ad.mData->agent;
401 } 426 }
402 } 427 }
403 { 428 {
404 Key::List::Iterator itA; 429 Key::List::Iterator itA;
405 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { 430 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) {
406 bool found = false; 431 bool found = false;
407 Key::List::Iterator it; 432 Key::List::Iterator it;
408 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 433 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
409 if ( (*it) == (*itA)) { 434 if ( (*it) == (*itA)) {
410 found = true; 435 found = true;
411 break; 436 break;
412 437
413 } 438 }
414 } 439 }
415 if ( ! found ) { 440 if ( ! found ) {
416 mData->keys.append( *itA ); 441 mData->keys.append( *itA );
417 } 442 }
418 } 443 }
419 } 444 }
420 if ( isSubSet ) { 445 if ( isSubSet ) {
421 KABC::Address::List::Iterator addressIterA; 446 KABC::Address::List::Iterator addressIterA;
422 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { 447 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) {
423 bool found = false; 448 bool found = false;
424 KABC::Address::List::Iterator addressIter; 449 KABC::Address::List::Iterator addressIter;
425 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 450 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
426 ++addressIter ) { 451 ++addressIter ) {
427 if ( (*addressIter) == (*addressIterA)) { 452 if ( (*addressIter) == (*addressIterA)) {
428 found = true; 453 found = true;
429 (*addressIter).setType( (*addressIterA).type() ); 454 (*addressIter).setType( (*addressIterA).type() );
430 break; 455 break;
431 } 456 }
432 457
433 } 458 }
434 if ( isSubSet && ! found ) { 459 if ( isSubSet && ! found ) {
435 mData->addresses.append( *addressIterA ); 460 mData->addresses.append( *addressIterA );
436 } 461 }
437 } 462 }
438 } 463 }
439 //qDebug("merge contact %s ", ad.uid().latin1()); 464 //qDebug("merge contact %s ", ad.uid().latin1());
440 setUid( ad.uid() ); 465 setUid( ad.uid() );
441 setRevision( ad.revision() ); 466 setRevision( ad.revision() );
442} 467}
443 468
444bool Addressee::removeVoice() 469bool Addressee::removeVoice()
445{ 470{
446 PhoneNumber::List phoneN = phoneNumbers(); 471 PhoneNumber::List phoneN = phoneNumbers();
447 PhoneNumber::List::Iterator phoneIt; 472 PhoneNumber::List::Iterator phoneIt;
448 bool found = false; 473 bool found = false;
449 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 474 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
450 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 475 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
451 if ((*phoneIt).type() - PhoneNumber::Voice ) { 476 if ((*phoneIt).type() - PhoneNumber::Voice ) {
452 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 477 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
453 insertPhoneNumber( (*phoneIt) ); 478 insertPhoneNumber( (*phoneIt) );
454 found = true; 479 found = true;
455 } 480 }
456 } 481 }
457 482
458 } 483 }
459 return found; 484 return found;
460} 485}
461 486
462bool Addressee::containsAdr(const Addressee& ad ) 487bool Addressee::containsAdr(const Addressee& ad )
463{ 488{
464 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; 489 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false;
465 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; 490 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false;
466 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; 491 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ;
467 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; 492 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ;
468 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; 493 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ;
469 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; 494 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ;
470 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; 495 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ;
471 496
472 // compare phone numbers 497 // compare phone numbers
473 PhoneNumber::List phoneN = ad.phoneNumbers(); 498 PhoneNumber::List phoneN = ad.phoneNumbers();
474 PhoneNumber::List::Iterator phoneIt; 499 PhoneNumber::List::Iterator phoneIt;
475 bool found = false; 500 bool found = false;
476 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 501 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
477 bool found = false; 502 bool found = false;
478 PhoneNumber::List phoneL = ad.phoneNumbers(); 503 PhoneNumber::List phoneL = ad.phoneNumbers();
479 PhoneNumber::List::Iterator phoneItL; 504 PhoneNumber::List::Iterator phoneItL;
480 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { 505 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) {
481 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { 506 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) {
482 found = true; 507 found = true;
483 break; 508 break;
484 } 509 }
485 } 510 }
486 if ( ! found ) 511 if ( ! found )
487 return false; 512 return false;
488 } 513 }
489 return true; 514 return true;
490 515
491} 516}
492void Addressee::simplifyAddresses() 517void Addressee::simplifyAddresses()
493{ 518{
494 519
495 520
496 Address::List list; 521 Address::List list;
497 Address::List::Iterator it; 522 Address::List::Iterator it;
498 Address::List::Iterator it2; 523 Address::List::Iterator it2;
499 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 524 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
500 it2 = it; 525 it2 = it;
501 ++it2; 526 ++it2;
502 for( ; it2 != mData->addresses.end(); ++it2 ) { 527 for( ; it2 != mData->addresses.end(); ++it2 ) {
503 if ( (*it) == (*it2) ) { 528 if ( (*it) == (*it2) ) {
504 list.append( *it ); 529 list.append( *it );
505 break; 530 break;
506 } 531 }
507 } 532 }
508 } 533 }
509 for( it = list.begin(); it != list.end(); ++it ) { 534 for( it = list.begin(); it != list.end(); ++it ) {
510 removeAddress( (*it) ); 535 removeAddress( (*it) );
511 } 536 }
512 537
513 list.clear(); 538 list.clear();
514 int max = 2; 539 int max = 2;
515 if ( mData->url.isValid() ) 540 if ( mData->url.isValid() )
516 max = 1; 541 max = 1;
517 if ( mData->addresses.count() <= max ) return ; 542 if ( mData->addresses.count() <= max ) return ;
518 int count = 0; 543 int count = 0;
519 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 544 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
520 if ( count >= max ) 545 if ( count >= max )
521 list.append( *it ); 546 list.append( *it );
522 ++count; 547 ++count;
523 } 548 }
524 for( it = list.begin(); it != list.end(); ++it ) { 549 for( it = list.begin(); it != list.end(); ++it ) {
525 removeAddress( (*it) ); 550 removeAddress( (*it) );
526 } 551 }
527} 552}
528 553
529// removes all emails but the first 554// removes all emails but the first
530// needed by phone sync 555// needed by phone sync
531void Addressee::simplifyEmails() 556void Addressee::simplifyEmails()
532{ 557{
533 if ( mData->emails.count() == 0 ) return ; 558 if ( mData->emails.count() == 0 ) return ;
534 QString email = mData->emails.first(); 559 QString email = mData->emails.first();
535 detach(); 560 detach();
536 mData->emails.clear(); 561 mData->emails.clear();
537 mData->emails.append( email ); 562 mData->emails.append( email );
538} 563}
539 564
540void Addressee::simplifyPhoneNumbers() 565void Addressee::simplifyPhoneNumbers()
541{ 566{
542 int max = 4; 567 int max = 4;
543 int inList = mData->phoneNumbers.count(); 568 int inList = mData->phoneNumbers.count();
544 KABC::PhoneNumber::List removeNumbers; 569 KABC::PhoneNumber::List removeNumbers;
545 KABC::PhoneNumber::List::Iterator phoneIter; 570 KABC::PhoneNumber::List::Iterator phoneIter;
546 if ( inList > max ) { 571 if ( inList > max ) {
547 // delete non-preferred numbers 572 // delete non-preferred numbers
548 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 573 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
549 ++phoneIter ) { 574 ++phoneIter ) {
550 if ( inList > max ) { 575 if ( inList > max ) {
551 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { 576 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) {
552 removeNumbers.append( ( *phoneIter ) ); 577 removeNumbers.append( ( *phoneIter ) );
553 --inList; 578 --inList;
554 } 579 }
555 } else 580 } else
556 break; 581 break;
557 } 582 }
558 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 583 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
559 ++phoneIter ) { 584 ++phoneIter ) {
560 removePhoneNumber(( *phoneIter )); 585 removePhoneNumber(( *phoneIter ));
561 } 586 }
562 // delete preferred numbers 587 // delete preferred numbers
563 if ( inList > max ) { 588 if ( inList > max ) {
564 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 589 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
565 ++phoneIter ) { 590 ++phoneIter ) {
566 if ( inList > max ) { 591 if ( inList > max ) {
567 removeNumbers.append( ( *phoneIter ) ); 592 removeNumbers.append( ( *phoneIter ) );
568 --inList; 593 --inList;
569 } else 594 } else
570 break; 595 break;
571 } 596 }
572 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 597 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
573 ++phoneIter ) { 598 ++phoneIter ) {
574 removePhoneNumber(( *phoneIter )); 599 removePhoneNumber(( *phoneIter ));
575 } 600 }
576 } 601 }
577 } 602 }
578 // remove non-numeric characters 603 // remove non-numeric characters
579 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 604 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
580 ++phoneIter ) { 605 ++phoneIter ) {
581 if ( ! ( *phoneIter ).simplifyNumber() ) 606 if ( ! ( *phoneIter ).simplifyNumber() )
582 removeNumbers.append( ( *phoneIter ) ); 607 removeNumbers.append( ( *phoneIter ) );
583 } 608 }
584 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 609 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
585 ++phoneIter ) { 610 ++phoneIter ) {
586 removePhoneNumber(( *phoneIter )); 611 removePhoneNumber(( *phoneIter ));
587 } 612 }
588} 613}
589void Addressee::simplifyPhoneNumberTypes() 614void Addressee::simplifyPhoneNumberTypes()
590{ 615{
591 KABC::PhoneNumber::List::Iterator phoneIter; 616 KABC::PhoneNumber::List::Iterator phoneIter;
592 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 617 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
593 ++phoneIter ) 618 ++phoneIter )
594 ( *phoneIter ).simplifyType(); 619 ( *phoneIter ).simplifyType();
595} 620}
596void Addressee::removeID(const QString &prof) 621void Addressee::removeID(const QString &prof)
597{ 622{
598 detach(); 623 detach();
599 if ( prof.isEmpty() ) 624 if ( prof.isEmpty() )
600 mData->mExternalId = ":"; 625 mData->mExternalId = ":";
601 else 626 else
602 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 627 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
603 628
604} 629}
605void Addressee::setID( const QString & prof , const QString & id ) 630void Addressee::setID( const QString & prof , const QString & id )
606{ 631{
607 detach(); 632 detach();
608 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 633 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
609 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 634 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
610} 635}
611void Addressee::setTempSyncStat( int id ) 636void Addressee::setTempSyncStat( int id )
612{ 637{
613 if ( mData->mTempSyncStat == id ) return; 638 if ( mData->mTempSyncStat == id ) return;
614 detach(); 639 detach();
615 mData->mTempSyncStat = id; 640 mData->mTempSyncStat = id;
616} 641}
617int Addressee::tempSyncStat() const 642int Addressee::tempSyncStat() const
618{ 643{
619 return mData->mTempSyncStat; 644 return mData->mTempSyncStat;
620} 645}
621 646
622const QString Addressee::getID( const QString & prof) const 647const QString Addressee::getID( const QString & prof) const
623{ 648{
624 return KIdManager::getId ( mData->mExternalId, prof ); 649 return KIdManager::getId ( mData->mExternalId, prof );
625} 650}
626 651
627void Addressee::setCsum( const QString & prof , const QString & id ) 652void Addressee::setCsum( const QString & prof , const QString & id )
628{ 653{
629 detach(); 654 detach();
630 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 655 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
631 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 656 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
632 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 657 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
633} 658}
634 659
635const QString Addressee::getCsum( const QString & prof) const 660const QString Addressee::getCsum( const QString & prof) const
636{ 661{
637 return KIdManager::getCsum ( mData->mExternalId, prof ); 662 return KIdManager::getCsum ( mData->mExternalId, prof );
638} 663}
639 664
640void Addressee::setIDStr( const QString & s ) 665void Addressee::setIDStr( const QString & s )
641{ 666{
642 detach(); 667 detach();
643 mData->mExternalId = s; 668 mData->mExternalId = s;
644} 669}
645 670
646const QString Addressee::IDStr() const 671const QString Addressee::IDStr() const
647{ 672{
648 return mData->mExternalId; 673 return mData->mExternalId;
649} 674}
650 675
651void Addressee::setExternalUID( const QString &id ) 676void Addressee::setExternalUID( const QString &id )
652{ 677{
653 if ( id == mData->externalUID ) return; 678 if ( id == mData->externalUID ) return;
654 detach(); 679 detach();
655 mData->empty = false; 680 mData->empty = false;
656 mData->externalUID = id; 681 mData->externalUID = id;
657} 682}
658 683
659const QString Addressee::externalUID() const 684const QString Addressee::externalUID() const
660{ 685{
661 return mData->externalUID; 686 return mData->externalUID;
662} 687}
663void Addressee::setOriginalExternalUID( const QString &id ) 688void Addressee::setOriginalExternalUID( const QString &id )
664{ 689{
665 if ( id == mData->originalExternalUID ) return; 690 if ( id == mData->originalExternalUID ) return;
666 detach(); 691 detach();
667 mData->empty = false; 692 mData->empty = false;
668 //qDebug("*******Set orig uid %s ", id.latin1()); 693 //qDebug("*******Set orig uid %s ", id.latin1());
669 mData->originalExternalUID = id; 694 mData->originalExternalUID = id;
670} 695}
671 696
672QString Addressee::originalExternalUID() const 697QString Addressee::originalExternalUID() const
673{ 698{
674 return mData->originalExternalUID; 699 return mData->originalExternalUID;
675} 700}
676 701
677void Addressee::setUid( const QString &id ) 702void Addressee::setUid( const QString &id )
678{ 703{
679 if ( id == mData->uid ) return; 704 if ( id == mData->uid ) return;
680 detach(); 705 detach();
681 //qDebug("****setuid %s ", id.latin1()); 706 //qDebug("****setuid %s ", id.latin1());
682 mData->empty = false; 707 mData->empty = false;
683 mData->uid = id; 708 mData->uid = id;
684} 709}
685 710
686const QString Addressee::uid() const 711const QString Addressee::uid() const
687{ 712{
688 if ( mData->uid.isEmpty() ) 713 if ( mData->uid.isEmpty() )
689 mData->uid = KApplication::randomString( 10 ); 714 mData->uid = KApplication::randomString( 10 );
690 715
691 return mData->uid; 716 return mData->uid;
692} 717}
693 718
694QString Addressee::uidLabel() 719QString Addressee::uidLabel()
695{ 720{
696 return i18n("Unique Identifier"); 721 return i18n("Unique Identifier");
697} 722}
698 723
699void Addressee::setName( const QString &name ) 724void Addressee::setName( const QString &name )
700{ 725{
701 if ( name == mData->name ) return; 726 if ( name == mData->name ) return;
702 detach(); 727 detach();
703 mData->empty = false; 728 mData->empty = false;
704 mData->name = name; 729 mData->name = name;
705} 730}
706 731
707QString Addressee::name() const 732QString Addressee::name() const
708{ 733{
709 return mData->name; 734 return mData->name;
710} 735}
711 736
712QString Addressee::nameLabel() 737QString Addressee::nameLabel()
713{ 738{
714 return i18n("Name"); 739 return i18n("Name");
715} 740}
716 741
717 742
718void Addressee::setFormattedName( const QString &formattedName ) 743void Addressee::setFormattedName( const QString &formattedName )
719{ 744{
720 if ( formattedName == mData->formattedName ) return; 745 if ( formattedName == mData->formattedName ) return;
721 detach(); 746 detach();
722 mData->empty = false; 747 mData->empty = false;
723 mData->formattedName = formattedName; 748 mData->formattedName = formattedName;
724} 749}
725 750
726QString Addressee::formattedName() const 751QString Addressee::formattedName() const
727{ 752{
728 return mData->formattedName; 753 return mData->formattedName;
729} 754}
730 755
731QString Addressee::formattedNameLabel() 756QString Addressee::formattedNameLabel()
732{ 757{
733 return i18n("Formatted Name"); 758 return i18n("Formatted Name");
734} 759}
735 760
736 761
737void Addressee::setFamilyName( const QString &familyName ) 762void Addressee::setFamilyName( const QString &familyName )
738{ 763{
739 if ( familyName == mData->familyName ) return; 764 if ( familyName == mData->familyName ) return;
740 detach(); 765 detach();
741 mData->empty = false; 766 mData->empty = false;
742 mData->familyName = familyName; 767 mData->familyName = familyName;
743} 768}
744 769
745QString Addressee::familyName() const 770QString Addressee::familyName() const
746{ 771{
747 return mData->familyName; 772 return mData->familyName;
748} 773}
749 774
750QString Addressee::familyNameLabel() 775QString Addressee::familyNameLabel()
751{ 776{
752 return i18n("Family Name"); 777 return i18n("Family Name");
753} 778}
754 779
755 780
756void Addressee::setGivenName( const QString &givenName ) 781void Addressee::setGivenName( const QString &givenName )
757{ 782{
758 if ( givenName == mData->givenName ) return; 783 if ( givenName == mData->givenName ) return;
759 detach(); 784 detach();
760 mData->empty = false; 785 mData->empty = false;
761 mData->givenName = givenName; 786 mData->givenName = givenName;
762} 787}
763 788
764QString Addressee::givenName() const 789QString Addressee::givenName() const
765{ 790{
766 return mData->givenName; 791 return mData->givenName;
767} 792}
768 793
769QString Addressee::givenNameLabel() 794QString Addressee::givenNameLabel()
770{ 795{
771 return i18n("Given Name"); 796 return i18n("Given Name");
772} 797}
773 798
774 799
775void Addressee::setAdditionalName( const QString &additionalName ) 800void Addressee::setAdditionalName( const QString &additionalName )
776{ 801{
777 if ( additionalName == mData->additionalName ) return; 802 if ( additionalName == mData->additionalName ) return;
778 detach(); 803 detach();
779 mData->empty = false; 804 mData->empty = false;
780 mData->additionalName = additionalName; 805 mData->additionalName = additionalName;
781} 806}
782 807
783QString Addressee::additionalName() const 808QString Addressee::additionalName() const
784{ 809{
785 return mData->additionalName; 810 return mData->additionalName;
786} 811}
787 812
788QString Addressee::additionalNameLabel() 813QString Addressee::additionalNameLabel()
789{ 814{
790 return i18n("Additional Names"); 815 return i18n("Additional Names");
791} 816}
792 817
793 818
794void Addressee::setPrefix( const QString &prefix ) 819void Addressee::setPrefix( const QString &prefix )
795{ 820{
796 if ( prefix == mData->prefix ) return; 821 if ( prefix == mData->prefix ) return;
797 detach(); 822 detach();
798 mData->empty = false; 823 mData->empty = false;
799 mData->prefix = prefix; 824 mData->prefix = prefix;
800} 825}
801 826
802QString Addressee::prefix() const 827QString Addressee::prefix() const
803{ 828{
804 return mData->prefix; 829 return mData->prefix;
805} 830}
806 831
807QString Addressee::prefixLabel() 832QString Addressee::prefixLabel()
808{ 833{
809 return i18n("Honorific Prefixes"); 834 return i18n("Honorific Prefixes");
810} 835}
811 836
812 837
813void Addressee::setSuffix( const QString &suffix ) 838void Addressee::setSuffix( const QString &suffix )
814{ 839{
815 if ( suffix == mData->suffix ) return; 840 if ( suffix == mData->suffix ) return;
816 detach(); 841 detach();
817 mData->empty = false; 842 mData->empty = false;
818 mData->suffix = suffix; 843 mData->suffix = suffix;
819} 844}
820 845
821QString Addressee::suffix() const 846QString Addressee::suffix() const
822{ 847{
823 return mData->suffix; 848 return mData->suffix;
824} 849}
825 850
826QString Addressee::suffixLabel() 851QString Addressee::suffixLabel()
827{ 852{
828 return i18n("Honorific Suffixes"); 853 return i18n("Honorific Suffixes");
829} 854}
830 855
831 856
832void Addressee::setNickName( const QString &nickName ) 857void Addressee::setNickName( const QString &nickName )
833{ 858{
834 if ( nickName == mData->nickName ) return; 859 if ( nickName == mData->nickName ) return;
835 detach(); 860 detach();
836 mData->empty = false; 861 mData->empty = false;
837 mData->nickName = nickName; 862 mData->nickName = nickName;
838} 863}
839 864
840QString Addressee::nickName() const 865QString Addressee::nickName() const
841{ 866{
842 return mData->nickName; 867 return mData->nickName;
843} 868}
844 869
845QString Addressee::nickNameLabel() 870QString Addressee::nickNameLabel()
846{ 871{
847 return i18n("Nick Name"); 872 return i18n("Nick Name");
848} 873}
849 874
850 875
851void Addressee::setBirthday( const QDateTime &birthday ) 876void Addressee::setBirthday( const QDateTime &birthday )
852{ 877{
853 if ( birthday == mData->birthday ) return; 878 if ( birthday == mData->birthday ) return;
854 detach(); 879 detach();
855 mData->empty = false; 880 mData->empty = false;
856 mData->birthday = birthday; 881 mData->birthday = birthday;
857} 882}
858 883
859QDateTime Addressee::birthday() const 884QDateTime Addressee::birthday() const
860{ 885{
861 return mData->birthday; 886 return mData->birthday;
862} 887}
863 888
864QString Addressee::birthdayLabel() 889QString Addressee::birthdayLabel()
865{ 890{
866 return i18n("Birthday"); 891 return i18n("Birthday");
867} 892}
868 893
869 894
870QString Addressee::homeAddressStreetLabel() 895QString Addressee::homeAddressStreetLabel()
871{ 896{
872 return i18n("Home Address Street"); 897 return i18n("Home Address Street");
873} 898}
874 899
875 900
876QString Addressee::homeAddressLocalityLabel() 901QString Addressee::homeAddressLocalityLabel()
877{ 902{
878 return i18n("Home Address Locality"); 903 return i18n("Home Address Locality");
879} 904}
880 905
881 906
882QString Addressee::homeAddressRegionLabel() 907QString Addressee::homeAddressRegionLabel()
883{ 908{
884 return i18n("Home Address Region"); 909 return i18n("Home Address Region");
885} 910}
886 911
887 912
888QString Addressee::homeAddressPostalCodeLabel() 913QString Addressee::homeAddressPostalCodeLabel()
889{ 914{
890 return i18n("Home Address Postal Code"); 915 return i18n("Home Address Postal Code");
891} 916}
892 917
893 918
894QString Addressee::homeAddressCountryLabel() 919QString Addressee::homeAddressCountryLabel()
895{ 920{
896 return i18n("Home Address Country"); 921 return i18n("Home Address Country");
897} 922}
898 923
899 924
900QString Addressee::homeAddressLabelLabel() 925QString Addressee::homeAddressLabelLabel()
901{ 926{
902 return i18n("Home Address Label"); 927 return i18n("Home Address Label");
903} 928}
904 929
905 930
906QString Addressee::businessAddressStreetLabel() 931QString Addressee::businessAddressStreetLabel()
907{ 932{
908 return i18n("Business Address Street"); 933 return i18n("Business Address Street");
909} 934}
910 935
911 936
912QString Addressee::businessAddressLocalityLabel() 937QString Addressee::businessAddressLocalityLabel()
913{ 938{
914 return i18n("Business Address Locality"); 939 return i18n("Business Address Locality");
915} 940}
916 941
917 942
918QString Addressee::businessAddressRegionLabel() 943QString Addressee::businessAddressRegionLabel()
919{ 944{
920 return i18n("Business Address Region"); 945 return i18n("Business Address Region");
921} 946}
922 947
923 948
924QString Addressee::businessAddressPostalCodeLabel() 949QString Addressee::businessAddressPostalCodeLabel()
925{ 950{
926 return i18n("Business Address Postal Code"); 951 return i18n("Business Address Postal Code");
927} 952}
928 953
929 954
930QString Addressee::businessAddressCountryLabel() 955QString Addressee::businessAddressCountryLabel()
931{ 956{
932 return i18n("Business Address Country"); 957 return i18n("Business Address Country");
933} 958}
934 959
935 960
936QString Addressee::businessAddressLabelLabel() 961QString Addressee::businessAddressLabelLabel()
937{ 962{
938 return i18n("Business Address Label"); 963 return i18n("Business Address Label");
939} 964}
940 965
941 966
942QString Addressee::homePhoneLabel() 967QString Addressee::homePhoneLabel()
943{ 968{
944 return i18n("Home Phone"); 969 return i18n("Home Phone");
945} 970}
946 971
947 972
948QString Addressee::businessPhoneLabel() 973QString Addressee::businessPhoneLabel()
949{ 974{
950 return i18n("Business Phone"); 975 return i18n("Business Phone");
951} 976}
952 977
953 978
954QString Addressee::mobilePhoneLabel() 979QString Addressee::mobilePhoneLabel()
955{ 980{
956 return i18n("Mobile Phone"); 981 return i18n("Mobile Phone");
957} 982}
958 983
959 984
960QString Addressee::homeFaxLabel() 985QString Addressee::homeFaxLabel()
961{ 986{
962 return i18n("Home Fax"); 987 return i18n("Home Fax");
963} 988}
964 989
965 990
966QString Addressee::businessFaxLabel() 991QString Addressee::businessFaxLabel()
967{ 992{
968 return i18n("Business Fax"); 993 return i18n("Business Fax");
969} 994}
970 995
971 996
972QString Addressee::carPhoneLabel() 997QString Addressee::carPhoneLabel()
973{ 998{
974 return i18n("Car Phone"); 999 return i18n("Car Phone");
975} 1000}
976 1001
977 1002
978QString Addressee::isdnLabel() 1003QString Addressee::isdnLabel()
979{ 1004{
980 return i18n("ISDN"); 1005 return i18n("ISDN");
981} 1006}
982 1007
983 1008
984QString Addressee::pagerLabel() 1009QString Addressee::pagerLabel()
985{ 1010{
986 return i18n("Pager"); 1011 return i18n("Pager");
987} 1012}
988 1013
989QString Addressee::sipLabel() 1014QString Addressee::sipLabel()
990{ 1015{
991 return i18n("SIP"); 1016 return i18n("SIP");
992} 1017}
993 1018
994QString Addressee::emailLabel() 1019QString Addressee::emailLabel()
995{ 1020{
996 return i18n("Email Address"); 1021 return i18n("Email Address");
997} 1022}
998 1023
999 1024
1000void Addressee::setMailer( const QString &mailer ) 1025void Addressee::setMailer( const QString &mailer )
1001{ 1026{
1002 if ( mailer == mData->mailer ) return; 1027 if ( mailer == mData->mailer ) return;
1003 detach(); 1028 detach();
1004 mData->empty = false; 1029 mData->empty = false;
1005 mData->mailer = mailer; 1030 mData->mailer = mailer;
1006} 1031}
1007 1032
1008QString Addressee::mailer() const 1033QString Addressee::mailer() const
1009{ 1034{
1010 return mData->mailer; 1035 return mData->mailer;
1011} 1036}
1012 1037
1013QString Addressee::mailerLabel() 1038QString Addressee::mailerLabel()
1014{ 1039{
1015 return i18n("Mail Client"); 1040 return i18n("Mail Client");
1016} 1041}
1017 1042
1018 1043
1019void Addressee::setTimeZone( const TimeZone &timeZone ) 1044void Addressee::setTimeZone( const TimeZone &timeZone )
1020{ 1045{
1021 if ( timeZone == mData->timeZone ) return; 1046 if ( timeZone == mData->timeZone ) return;
1022 detach(); 1047 detach();
1023 mData->empty = false; 1048 mData->empty = false;
1024 mData->timeZone = timeZone; 1049 mData->timeZone = timeZone;
1025} 1050}
1026 1051
1027TimeZone Addressee::timeZone() const 1052TimeZone Addressee::timeZone() const
1028{ 1053{
1029 return mData->timeZone; 1054 return mData->timeZone;
1030} 1055}
1031 1056
1032QString Addressee::timeZoneLabel() 1057QString Addressee::timeZoneLabel()
1033{ 1058{
1034 return i18n("Time Zone"); 1059 return i18n("Time Zone");
1035} 1060}
1036 1061
1037 1062
1038void Addressee::setGeo( const Geo &geo ) 1063void Addressee::setGeo( const Geo &geo )
1039{ 1064{
1040 if ( geo == mData->geo ) return; 1065 if ( geo == mData->geo ) return;
1041 detach(); 1066 detach();
1042 mData->empty = false; 1067 mData->empty = false;
1043 mData->geo = geo; 1068 mData->geo = geo;
1044} 1069}
1045 1070
1046Geo Addressee::geo() const 1071Geo Addressee::geo() const
1047{ 1072{
1048 return mData->geo; 1073 return mData->geo;
diff --git a/kaddressbook/imagewidget.cpp b/kaddressbook/imagewidget.cpp
index 1e9743c..d0f52ea 100644
--- a/kaddressbook/imagewidget.cpp
+++ b/kaddressbook/imagewidget.cpp
@@ -1,311 +1,312 @@
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#include <kabc/picture.h> 24#include <kabc/picture.h>
25 25
26#ifndef KAB_EMBEDDED 26#ifndef KAB_EMBEDDED
27#include <kaccelmanager.h> 27#include <kaccelmanager.h>
28#include <kio/netaccess.h> 28#include <kio/netaccess.h>
29#include <kimageio.h> 29#include <kimageio.h>
30#endif //KAB_EMBEDDED 30#endif //KAB_EMBEDDED
31 31
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kdialog.h> 33#include <kdialog.h>
34#include <kiconloader.h> 34#include <kiconloader.h>
35#include <klocale.h> 35#include <klocale.h>
36#include <kurlrequester.h> 36#include <kurlrequester.h>
37#include <kurl.h> 37#include <kurl.h>
38 38
39#include <qcheckbox.h> 39#include <qcheckbox.h>
40#include <qgroupbox.h> 40#include <qgroupbox.h>
41#include <qlabel.h> 41#include <qlabel.h>
42#include <qlayout.h> 42#include <qlayout.h>
43#include <qpixmap.h> 43#include <qpixmap.h>
44#include <qpushbutton.h> 44#include <qpushbutton.h>
45#include <qapplication.h> 45#include <qapplication.h>
46 46
47#include "imagewidget.h" 47#include "imagewidget.h"
48 48
49ImageWidget::ImageWidget( QWidget *parent, const char *name ) 49ImageWidget::ImageWidget( QWidget *parent, const char *name )
50 : QWidget( parent, name ) 50 : QWidget( parent, name )
51{ 51{
52 QGridLayout *topLayout = new QGridLayout( this, 2, 1, KDialog::marginHint(), 52 QGridLayout *topLayout = new QGridLayout( this, 2, 1, KDialog::marginHint(),
53 KDialog::spacingHint() ); 53 KDialog::spacingHint() );
54 54
55 QGroupBox *photoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Photo" ), this ); 55 QGroupBox *photoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Photo" ), this );
56 QGridLayout *boxLayout = new QGridLayout( photoBox->layout(), 3, 2, 56 QGridLayout *boxLayout = new QGridLayout( photoBox->layout(), 3, 2,
57 KDialog::spacingHint() ); 57 KDialog::spacingHint() );
58 boxLayout->setRowStretch( 2, 1 ); 58 boxLayout->setRowStretch( 2, 1 );
59 59
60 mPhotoLabel = new QLabel( photoBox ); 60 mPhotoLabel = new QLabel( photoBox );
61 int fac = 9; 61 int fac = 9;
62 if ( QApplication::desktop()->width() > 320 ) 62 if ( QApplication::desktop()->width() > 320 )
63 fac = 6; 63 fac = 6;
64 mPhotoLabel->setFixedSize( 50*9/fac, 70*9/fac ); 64 mPhotoLabel->setFixedSize( 50*9/fac, 70*9/fac );
65 mPhotoLabel->setScaledContents( true ); 65 mPhotoLabel->setScaledContents( true );
66 mPhotoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 66 mPhotoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken );
67 boxLayout->addMultiCellWidget( mPhotoLabel, 0, 3, 0, 0 ); 67 boxLayout->addMultiCellWidget( mPhotoLabel, 0, 3, 0, 0 );
68 68
69 mPhotoUrl = new KURLRequester( photoBox ); 69 mPhotoUrl = new KURLRequester( photoBox );
70#ifndef KAB_EMBEDDED 70#ifndef KAB_EMBEDDED
71 mPhotoUrl->setFilter( KImageIO::pattern() ); 71 mPhotoUrl->setFilter( KImageIO::pattern() );
72#else //KAB_EMBEDDED 72#else //KAB_EMBEDDED
73//US qDebug("ImageWidget::ImageWidget KImageIO not defined. Does this harm ???"); 73//US qDebug("ImageWidget::ImageWidget KImageIO not defined. Does this harm ???");
74#endif //KAB_EMBEDDED 74#endif //KAB_EMBEDDED
75 75
76 76
77 boxLayout->addWidget( mPhotoUrl, 0, 1 ); 77 boxLayout->addWidget( mPhotoUrl, 0, 1 );
78 QHBox *hb1 = new QHBox ( photoBox ); 78 QHBox *hb1 = new QHBox ( photoBox );
79 mUsePhotoUrl = new QCheckBox( i18n( "Store as URL" ), hb1 ); 79 mUsePhotoUrl = new QCheckBox( i18n( "Store as URL" ), hb1 );
80 mUsePhotoUrl->setEnabled( false ); 80 mUsePhotoUrl->setEnabled( false );
81 boxLayout->addWidget( hb1, 1, 1 ); 81 boxLayout->addWidget( hb1, 1, 1 );
82 82
83 QPushButton * pb = new QPushButton( i18n( "Remove" ), hb1 ); 83 QPushButton * pb = new QPushButton( i18n( "Remove" ), hb1 );
84 connect( pb, SIGNAL( clicked() ),this, SLOT( removePhoto() ) ); 84 connect( pb, SIGNAL( clicked() ),this, SLOT( removePhoto() ) );
85 boxLayout->addWidget( new QLabel( photoBox ), 2, 1 ); 85 boxLayout->addWidget( new QLabel( photoBox ), 2, 1 );
86 86
87 topLayout->addWidget( photoBox, 0, 0 ); 87 topLayout->addWidget( photoBox, 0, 0 );
88 88
89 QGroupBox *logoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Logo" ), this ); 89 QGroupBox *logoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Logo" ), this );
90 boxLayout = new QGridLayout( logoBox->layout(), 3, 2, KDialog::spacingHint() ); 90 boxLayout = new QGridLayout( logoBox->layout(), 3, 2, KDialog::spacingHint() );
91 boxLayout->setRowStretch( 2, 1 ); 91 boxLayout->setRowStretch( 2, 1 );
92 92
93 mLogoLabel = new QLabel( logoBox ); 93 mLogoLabel = new QLabel( logoBox );
94 mLogoLabel->setFixedSize( 50*9/fac, 70*9/fac ); 94 mLogoLabel->setFixedSize( 50*9/fac, 70*9/fac );
95 mLogoLabel->setScaledContents( true ); 95 mLogoLabel->setScaledContents( true );
96 mLogoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 96 mLogoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken );
97 boxLayout->addMultiCellWidget( mLogoLabel, 0, 3, 0, 0 ); 97 boxLayout->addMultiCellWidget( mLogoLabel, 0, 3, 0, 0 );
98 98
99 mLogoUrl = new KURLRequester( logoBox ); 99 mLogoUrl = new KURLRequester( logoBox );
100#ifndef KAB_EMBEDDED 100#ifndef KAB_EMBEDDED
101 mLogoUrl->setFilter( KImageIO::pattern() ); 101 mLogoUrl->setFilter( KImageIO::pattern() );
102#else //KAB_EMBEDDED 102#else //KAB_EMBEDDED
103//US qDebug("ImageWidget::ImageWidget KImageIO not defined 2"); 103//US qDebug("ImageWidget::ImageWidget KImageIO not defined 2");
104#endif //KAB_EMBEDDED 104#endif //KAB_EMBEDDED
105 boxLayout->addWidget( mLogoUrl, 0, 1 ); 105 boxLayout->addWidget( mLogoUrl, 0, 1 );
106 106
107 QHBox *hb2 = new QHBox ( logoBox ); 107 QHBox *hb2 = new QHBox ( logoBox );
108 mUseLogoUrl = new QCheckBox( i18n( "Store as URL" ), hb2 ); 108 mUseLogoUrl = new QCheckBox( i18n( "Store as URL" ), hb2 );
109 mUseLogoUrl->setEnabled( false ); 109 mUseLogoUrl->setEnabled( false );
110 boxLayout->addWidget( hb2, 1, 1 ); 110 boxLayout->addWidget( hb2, 1, 1 );
111 111
112 pb = new QPushButton( i18n( "Remove" ), hb2 ); 112 pb = new QPushButton( i18n( "Remove" ), hb2 );
113 connect( pb, SIGNAL( clicked() ),this, SLOT( removeLogo() ) ); 113 connect( pb, SIGNAL( clicked() ),this, SLOT( removeLogo() ) );
114 boxLayout->addWidget( new QLabel( logoBox ), 2, 1 ); 114 boxLayout->addWidget( new QLabel( logoBox ), 2, 1 );
115 topLayout->addWidget( logoBox, 1, 0 ); 115 topLayout->addWidget( logoBox, 1, 0 );
116 116
117 connect( mPhotoUrl, SIGNAL( textChanged( const QString& ) ), 117 connect( mPhotoUrl, SIGNAL( textChanged( const QString& ) ),
118 SIGNAL( changed() ) ); 118 SIGNAL( changed() ) );
119 connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), 119 connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ),
120 SLOT( loadPhoto() ) ); 120 SLOT( loadPhoto() ) );
121 connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), 121 connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ),
122 SIGNAL( changed() ) ); 122 SIGNAL( changed() ) );
123 connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), 123 connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ),
124 SLOT( updateGUI() ) ); 124 SLOT( updateGUI() ) );
125 connect( mUsePhotoUrl, SIGNAL( toggled( bool ) ), 125 connect( mUsePhotoUrl, SIGNAL( toggled( bool ) ),
126 SIGNAL( changed() ) ); 126 SIGNAL( changed() ) );
127 127
128 connect( mLogoUrl, SIGNAL( textChanged( const QString& ) ), 128 connect( mLogoUrl, SIGNAL( textChanged( const QString& ) ),
129 SIGNAL( changed() ) ); 129 SIGNAL( changed() ) );
130 connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), 130 connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ),
131 SLOT( loadLogo() ) ); 131 SLOT( loadLogo() ) );
132 connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), 132 connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ),
133 SIGNAL( changed() ) ); 133 SIGNAL( changed() ) );
134 connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), 134 connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ),
135 SLOT( updateGUI() ) ); 135 SLOT( updateGUI() ) );
136 connect( mUseLogoUrl, SIGNAL( toggled( bool ) ), 136 connect( mUseLogoUrl, SIGNAL( toggled( bool ) ),
137 SIGNAL( changed() ) ); 137 SIGNAL( changed() ) );
138 138
139#ifndef KAB_EMBEDDED 139#ifndef KAB_EMBEDDED
140 KAcceleratorManager::manage( this ); 140 KAcceleratorManager::manage( this );
141#endif //KAB_EMBEDDED 141#endif //KAB_EMBEDDED
142 142
143} 143}
144 144
145ImageWidget::~ImageWidget() 145ImageWidget::~ImageWidget()
146{ 146{
147} 147}
148 148
149void ImageWidget::setPhoto( const KABC::Picture &photo ) 149void ImageWidget::setPhoto( const KABC::Picture &photo )
150{ 150{
151 bool blocked = signalsBlocked(); 151 bool blocked = signalsBlocked();
152 blockSignals( true ); 152 blockSignals( true );
153 153
154 if ( photo.isIntern() ) { 154 if ( photo.isIntern() ) {
155//US 155//US
156//US mPhotoLabel->setPixmap( photo.data() ); 156//US mPhotoLabel->setPixmap( photo.data() );
157 if (photo.data().isNull() != true) 157 if (photo.data().isNull() != true)
158 { 158 {
159 QPixmap pm; 159 QPixmap pm;
160 pm.convertFromImage(photo.data()); 160 pm.convertFromImage(photo.data());
161 161
162 mPhotoLabel->setPixmap( pm ); 162 mPhotoLabel->setPixmap( pm );
163 } 163 }
164 164
165 mUsePhotoUrl->setChecked( false ); 165 mUsePhotoUrl->setChecked( false );
166 } else { 166 } else {
167 mPhotoUrl->setURL( photo.url() ); 167 mPhotoUrl->setURL( photo.url() );
168 if ( !photo.url().isEmpty() ) 168 if ( !photo.url().isEmpty() )
169 mUsePhotoUrl->setChecked( true ); 169 mUsePhotoUrl->setChecked( true );
170 loadPhoto(); 170 loadPhoto();
171 } 171 }
172 172
173 blockSignals( blocked ); 173 blockSignals( blocked );
174} 174}
175 175
176KABC::Picture ImageWidget::photo() const 176KABC::Picture ImageWidget::photo() const
177{ 177{
178 KABC::Picture photo; 178 KABC::Picture photo;
179 179
180 if ( mUsePhotoUrl->isChecked() ) 180 if ( mUsePhotoUrl->isChecked() )
181 photo.setUrl( mPhotoUrl->url() ); 181 photo.setUrl( mPhotoUrl->url() );
182 else { 182 else {
183 QPixmap *px = mPhotoLabel->pixmap(); 183 QPixmap *px = mPhotoLabel->pixmap();
184 if ( px ) { 184 if ( px ) {
185#ifndef KAB_EMBEDDED 185#ifndef KAB_EMBEDDED
186 if ( px->height() > px->width() ) 186 if ( px->height() > px->width() )
187 photo.setData( px->convertToImage().scaleHeight( 140 ) ); 187 photo.setData( px->convertToImage().scaleHeight( 140 ) );
188 else 188 else
189 photo.setData( px->convertToImage().scaleWidth( 100 ) ); 189 photo.setData( px->convertToImage().scaleWidth( 100 ) );
190#else //KAB_EMBEDDED 190#else //KAB_EMBEDDED
191//US add teh nullcheck 191//US add teh nullcheck
192 if (px->isNull() != true ) 192 if (px->isNull() != true )
193 photo.setData( px->convertToImage() ); 193 photo.setData( px->convertToImage() );
194#endif //KAB_EMBEDDED 194#endif //KAB_EMBEDDED
195 195
196 photo.setType( "PNG" ); 196 photo.setType( "PNG" );
197 } 197 }
198 } 198 }
199 199
200 return photo; 200 return photo;
201} 201}
202 202
203void ImageWidget::setLogo( const KABC::Picture &logo ) 203void ImageWidget::setLogo( const KABC::Picture &logo )
204{ 204{
205 bool blocked = signalsBlocked(); 205 bool blocked = signalsBlocked();
206 blockSignals( true ); 206 blockSignals( true );
207 207
208 if ( logo.isIntern() ) { 208 if ( logo.isIntern() ) {
209//US 209//US
210//US mLogoLabel->setPixmap( logo.data() ); 210//US mLogoLabel->setPixmap( logo.data() );
211 if (logo.data().isNull() != true) 211 if (logo.data().isNull() != true)
212 { 212 {
213 QPixmap pm; 213 QPixmap pm;
214 pm.convertFromImage(logo.data()); 214 pm.convertFromImage(logo.data());
215 mLogoLabel->setPixmap( pm ); 215 mLogoLabel->setPixmap( pm );
216 } 216 }
217 mUseLogoUrl->setChecked( false ); 217 mUseLogoUrl->setChecked( false );
218 } else { 218 } else {
219 mLogoUrl->setURL( logo.url() ); 219 mLogoUrl->setURL( logo.url() );
220 if ( !logo.url().isEmpty() ) 220 if ( !logo.url().isEmpty() )
221 mUseLogoUrl->setChecked( true ); 221 mUseLogoUrl->setChecked( true );
222 loadLogo(); 222 loadLogo();
223 } 223 }
224 224
225 blockSignals( blocked ); 225 blockSignals( blocked );
226} 226}
227 227
228KABC::Picture ImageWidget::logo() const 228KABC::Picture ImageWidget::logo() const
229{ 229{
230 KABC::Picture logo; 230 KABC::Picture logo;
231 231
232 if ( mUseLogoUrl->isChecked() ) 232 if ( mUseLogoUrl->isChecked() )
233 logo.setUrl( mLogoUrl->url() ); 233 logo.setUrl( mLogoUrl->url() );
234 else { 234 else {
235 QPixmap *px = mLogoLabel->pixmap(); 235 QPixmap *px = mLogoLabel->pixmap();
236 if ( px ) { 236 if ( px ) {
237#ifndef KAB_EMBEDDED 237#ifndef KAB_EMBEDDED
238 if ( px->height() > px->width() ) 238 if ( px->height() > px->width() )
239 logo.setData( px->convertToImage().scaleHeight( 140 ) ); 239 logo.setData( px->convertToImage().scaleHeight( 140 ) );
240 else 240 else
241 logo.setData( px->convertToImage().scaleWidth( 100 ) ); 241 logo.setData( px->convertToImage().scaleWidth( 100 ) );
242#else //KAB_EMBEDDED 242#else //KAB_EMBEDDED
243 logo.setData( px->convertToImage() ); 243 if (px->isNull() != true )
244 logo.setData( px->convertToImage() );
244#endif //KAB_EMBEDDED 245#endif //KAB_EMBEDDED
245 246
246 logo.setType( "PNG" ); 247 logo.setType( "PNG" );
247 248
248 } 249 }
249 } 250 }
250 return logo; 251 return logo;
251} 252}
252void ImageWidget::removePhoto() 253void ImageWidget::removePhoto()
253{ 254{
254 setPhoto(KABC::Picture() ); 255 setPhoto(KABC::Picture() );
255} 256}
256 257
257void ImageWidget::removeLogo() 258void ImageWidget::removeLogo()
258{ 259{
259 setLogo(KABC::Picture() ); 260 setLogo(KABC::Picture() );
260} 261}
261 262
262void ImageWidget::loadPhoto() 263void ImageWidget::loadPhoto()
263{ 264{
264 mPhotoLabel->setPixmap( loadPixmap( mPhotoUrl->url() ) ); 265 mPhotoLabel->setPixmap( loadPixmap( mPhotoUrl->url() ) );
265} 266}
266 267
267void ImageWidget::loadLogo() 268void ImageWidget::loadLogo()
268{ 269{
269 mLogoLabel->setPixmap( loadPixmap( mLogoUrl->url() ) ); 270 mLogoLabel->setPixmap( loadPixmap( mLogoUrl->url() ) );
270} 271}
271 272
272void ImageWidget::updateGUI() 273void ImageWidget::updateGUI()
273{ 274{
274 KURLRequester *ptr = (KURLRequester*)sender(); 275 KURLRequester *ptr = (KURLRequester*)sender();
275 276
276 277
277 if ( ptr == mPhotoUrl ) 278 if ( ptr == mPhotoUrl )
278 mUsePhotoUrl->setEnabled( true ); 279 mUsePhotoUrl->setEnabled( true );
279 else if ( ptr == mLogoUrl ) 280 else if ( ptr == mLogoUrl )
280 mUseLogoUrl->setEnabled( true ); 281 mUseLogoUrl->setEnabled( true );
281} 282}
282 283
283QPixmap ImageWidget::loadPixmap( const KURL &url ) 284QPixmap ImageWidget::loadPixmap( const KURL &url )
284{ 285{
285 QString tempFile; 286 QString tempFile;
286 QPixmap pixmap; 287 QPixmap pixmap;
287 288
288 if ( url.isEmpty() ) 289 if ( url.isEmpty() )
289 return pixmap; 290 return pixmap;
290 291
291 if ( url.isLocalFile() ) 292 if ( url.isLocalFile() )
292 pixmap = QPixmap( url.path() ); 293 pixmap = QPixmap( url.path() );
293 else 294 else
294 { 295 {
295#ifndef KAB_EMBEDDED 296#ifndef KAB_EMBEDDED
296 if ( KIO::NetAccess::download( url, tempFile ) ) { 297 if ( KIO::NetAccess::download( url, tempFile ) ) {
297 pixmap = QPixmap( tempFile ); 298 pixmap = QPixmap( tempFile );
298 KIO::NetAccess::removeTempFile( tempFile ); 299 KIO::NetAccess::removeTempFile( tempFile );
299 } 300 }
300#else //KAB_EMBEDDED 301#else //KAB_EMBEDDED
301 qDebug("ImageWidget::loadPixmap : only local pixmaps are allowed"); 302 qDebug("ImageWidget::loadPixmap : only local pixmaps are allowed");
302#endif //KAB_EMBEDDED 303#endif //KAB_EMBEDDED
303 304
304 } 305 }
305 306
306 return pixmap; 307 return pixmap;
307} 308}
308 309
309#ifndef KAB_EMBEDDED 310#ifndef KAB_EMBEDDED
310#include "imagewidget.moc" 311#include "imagewidget.moc"
311#endif //KAB_EMBEDDED 312#endif //KAB_EMBEDDED
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index d970ff1..e88706e 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -423,2893 +423,2898 @@ KABCore::~KABCore()
423 if ( infrared ) 423 if ( infrared )
424 delete infrared; 424 delete infrared;
425#endif 425#endif
426} 426}
427void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 427void KABCore::receive( const QCString& cmsg, const QByteArray& data )
428{ 428{
429 qDebug("KA: QCOP message received: %s ", cmsg.data() ); 429 qDebug("KA: QCOP message received: %s ", cmsg.data() );
430 if ( cmsg == "setDocument(QString)" ) { 430 if ( cmsg == "setDocument(QString)" ) {
431 QDataStream stream( data, IO_ReadOnly ); 431 QDataStream stream( data, IO_ReadOnly );
432 QString fileName; 432 QString fileName;
433 stream >> fileName; 433 stream >> fileName;
434 recieve( fileName ); 434 recieve( fileName );
435 return; 435 return;
436 } 436 }
437} 437}
438void KABCore::toggleBeamReceive( ) 438void KABCore::toggleBeamReceive( )
439{ 439{
440 if ( mBRdisabled ) 440 if ( mBRdisabled )
441 return; 441 return;
442#ifndef DESKTOP_VERSION 442#ifndef DESKTOP_VERSION
443 if ( infrared ) { 443 if ( infrared ) {
444 qDebug("AB disable BeamReceive "); 444 qDebug("AB disable BeamReceive ");
445 delete infrared; 445 delete infrared;
446 infrared = 0; 446 infrared = 0;
447 mActionBR->setChecked(false); 447 mActionBR->setChecked(false);
448 return; 448 return;
449 } 449 }
450 qDebug("AB enable BeamReceive "); 450 qDebug("AB enable BeamReceive ");
451 mActionBR->setChecked(true); 451 mActionBR->setChecked(true);
452 452
453 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 453 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
454 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 454 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
455#endif 455#endif
456} 456}
457 457
458 458
459void KABCore::disableBR(bool b) 459void KABCore::disableBR(bool b)
460{ 460{
461#ifndef DESKTOP_VERSION 461#ifndef DESKTOP_VERSION
462 if ( b ) { 462 if ( b ) {
463 if ( infrared ) { 463 if ( infrared ) {
464 toggleBeamReceive( ); 464 toggleBeamReceive( );
465 } 465 }
466 mBRdisabled = true; 466 mBRdisabled = true;
467 } else { 467 } else {
468 if ( mBRdisabled ) { 468 if ( mBRdisabled ) {
469 mBRdisabled = false; 469 mBRdisabled = false;
470 //toggleBeamReceive( ); 470 //toggleBeamReceive( );
471 } 471 }
472 } 472 }
473#endif 473#endif
474 474
475} 475}
476void KABCore::recieve( QString fn ) 476void KABCore::recieve( QString fn )
477{ 477{
478 //qDebug("KABCore::recieve "); 478 //qDebug("KABCore::recieve ");
479 int count = mAddressBook->importFromFile( fn, true ); 479 int count = mAddressBook->importFromFile( fn, true );
480 if ( count ) 480 if ( count )
481 setModified( true ); 481 setModified( true );
482 mViewManager->refreshView(); 482 mViewManager->refreshView();
483 message(i18n("%1 contact(s) received!").arg( count )); 483 message(i18n("%1 contact(s) received!").arg( count ));
484 topLevelWidget()->showMaximized(); 484 topLevelWidget()->showMaximized();
485 topLevelWidget()->raise(); 485 topLevelWidget()->raise();
486} 486}
487void KABCore::restoreSettings() 487void KABCore::restoreSettings()
488{ 488{
489 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 489 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
490 490
491 bool state; 491 bool state;
492 492
493 if (mMultipleViewsAtOnce) 493 if (mMultipleViewsAtOnce)
494 state = KABPrefs::instance()->mDetailsPageVisible; 494 state = KABPrefs::instance()->mDetailsPageVisible;
495 else 495 else
496 state = false; 496 state = false;
497 497
498 mActionDetails->setChecked( state ); 498 mActionDetails->setChecked( state );
499 setDetailsVisible( state ); 499 setDetailsVisible( state );
500 500
501 state = KABPrefs::instance()->mJumpButtonBarVisible; 501 state = KABPrefs::instance()->mJumpButtonBarVisible;
502 502
503 mActionJumpBar->setChecked( state ); 503 mActionJumpBar->setChecked( state );
504 setJumpButtonBarVisible( state ); 504 setJumpButtonBarVisible( state );
505/*US 505/*US
506 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 506 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
507 if ( splitterSize.count() == 0 ) { 507 if ( splitterSize.count() == 0 ) {
508 splitterSize.append( width() / 2 ); 508 splitterSize.append( width() / 2 );
509 splitterSize.append( width() / 2 ); 509 splitterSize.append( width() / 2 );
510 } 510 }
511 mMiniSplitter->setSizes( splitterSize ); 511 mMiniSplitter->setSizes( splitterSize );
512 if ( mExtensionBarSplitter ) { 512 if ( mExtensionBarSplitter ) {
513 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 513 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
514 if ( splitterSize.count() == 0 ) { 514 if ( splitterSize.count() == 0 ) {
515 splitterSize.append( width() / 2 ); 515 splitterSize.append( width() / 2 );
516 splitterSize.append( width() / 2 ); 516 splitterSize.append( width() / 2 );
517 } 517 }
518 mExtensionBarSplitter->setSizes( splitterSize ); 518 mExtensionBarSplitter->setSizes( splitterSize );
519 519
520 } 520 }
521*/ 521*/
522 mViewManager->restoreSettings(); 522 mViewManager->restoreSettings();
523 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 523 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
524 mExtensionManager->restoreSettings(); 524 mExtensionManager->restoreSettings();
525#ifdef DESKTOP_VERSION 525#ifdef DESKTOP_VERSION
526 int wid = width(); 526 int wid = width();
527 if ( wid < 10 ) 527 if ( wid < 10 )
528 wid = 400; 528 wid = 400;
529#else 529#else
530 int wid = QApplication::desktop()->width(); 530 int wid = QApplication::desktop()->width();
531 if ( wid < 640 ) 531 if ( wid < 640 )
532 wid = QApplication::desktop()->height(); 532 wid = QApplication::desktop()->height();
533#endif 533#endif
534 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 534 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
535 if ( true /*splitterSize.count() == 0*/ ) { 535 if ( true /*splitterSize.count() == 0*/ ) {
536 splitterSize.append( wid / 2 ); 536 splitterSize.append( wid / 2 );
537 splitterSize.append( wid / 2 ); 537 splitterSize.append( wid / 2 );
538 } 538 }
539 mMiniSplitter->setSizes( splitterSize ); 539 mMiniSplitter->setSizes( splitterSize );
540 if ( mExtensionBarSplitter ) { 540 if ( mExtensionBarSplitter ) {
541 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 541 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
542 if ( true /*splitterSize.count() == 0*/ ) { 542 if ( true /*splitterSize.count() == 0*/ ) {
543 splitterSize.append( wid / 2 ); 543 splitterSize.append( wid / 2 );
544 splitterSize.append( wid / 2 ); 544 splitterSize.append( wid / 2 );
545 } 545 }
546 mExtensionBarSplitter->setSizes( splitterSize ); 546 mExtensionBarSplitter->setSizes( splitterSize );
547 547
548 } 548 }
549 549
550 550
551} 551}
552 552
553void KABCore::saveSettings() 553void KABCore::saveSettings()
554{ 554{
555 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 555 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
556 if ( mExtensionBarSplitter ) 556 if ( mExtensionBarSplitter )
557 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 557 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
558 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 558 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
559 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 559 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
560#ifndef KAB_EMBEDDED 560#ifndef KAB_EMBEDDED
561 561
562 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 562 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
563 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 563 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
564#endif //KAB_EMBEDDED 564#endif //KAB_EMBEDDED
565 mExtensionManager->saveSettings(); 565 mExtensionManager->saveSettings();
566 mViewManager->saveSettings(); 566 mViewManager->saveSettings();
567 567
568 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 568 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
569 KABPrefs::instance()->writeConfig(); 569 KABPrefs::instance()->writeConfig();
570 qDebug("KABCore::saveSettings() "); 570 qDebug("KABCore::saveSettings() ");
571} 571}
572 572
573KABC::AddressBook *KABCore::addressBook() const 573KABC::AddressBook *KABCore::addressBook() const
574{ 574{
575 return mAddressBook; 575 return mAddressBook;
576} 576}
577 577
578KConfig *KABCore::config() 578KConfig *KABCore::config()
579{ 579{
580#ifndef KAB_EMBEDDED 580#ifndef KAB_EMBEDDED
581 return KABPrefs::instance()->config(); 581 return KABPrefs::instance()->config();
582#else //KAB_EMBEDDED 582#else //KAB_EMBEDDED
583 return KABPrefs::instance()->getConfig(); 583 return KABPrefs::instance()->getConfig();
584#endif //KAB_EMBEDDED 584#endif //KAB_EMBEDDED
585} 585}
586 586
587KActionCollection *KABCore::actionCollection() const 587KActionCollection *KABCore::actionCollection() const
588{ 588{
589 return mGUIClient->actionCollection(); 589 return mGUIClient->actionCollection();
590} 590}
591 591
592KABC::Field *KABCore::currentSearchField() const 592KABC::Field *KABCore::currentSearchField() const
593{ 593{
594 if (mIncSearchWidget) 594 if (mIncSearchWidget)
595 return mIncSearchWidget->currentField(); 595 return mIncSearchWidget->currentField();
596 else 596 else
597 return 0; 597 return 0;
598} 598}
599 599
600QStringList KABCore::selectedUIDs() const 600QStringList KABCore::selectedUIDs() const
601{ 601{
602 return mViewManager->selectedUids(); 602 return mViewManager->selectedUids();
603} 603}
604 604
605KABC::Resource *KABCore::requestResource( QWidget *parent ) 605KABC::Resource *KABCore::requestResource( QWidget *parent )
606{ 606{
607 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 607 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
608 608
609 QPtrList<KRES::Resource> kresResources; 609 QPtrList<KRES::Resource> kresResources;
610 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 610 QPtrListIterator<KABC::Resource> resIt( kabcResources );
611 KABC::Resource *resource; 611 KABC::Resource *resource;
612 while ( ( resource = resIt.current() ) != 0 ) { 612 while ( ( resource = resIt.current() ) != 0 ) {
613 ++resIt; 613 ++resIt;
614 if ( !resource->readOnly() ) { 614 if ( !resource->readOnly() ) {
615 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 615 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
616 if ( res ) 616 if ( res )
617 kresResources.append( res ); 617 kresResources.append( res );
618 } 618 }
619 } 619 }
620 620
621 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 621 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
622 return static_cast<KABC::Resource*>( res ); 622 return static_cast<KABC::Resource*>( res );
623} 623}
624 624
625#ifndef KAB_EMBEDDED 625#ifndef KAB_EMBEDDED
626KAboutData *KABCore::createAboutData() 626KAboutData *KABCore::createAboutData()
627#else //KAB_EMBEDDED 627#else //KAB_EMBEDDED
628void KABCore::createAboutData() 628void KABCore::createAboutData()
629#endif //KAB_EMBEDDED 629#endif //KAB_EMBEDDED
630{ 630{
631#ifndef KAB_EMBEDDED 631#ifndef KAB_EMBEDDED
632 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 632 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
633 "3.1", I18N_NOOP( "The KDE Address Book" ), 633 "3.1", I18N_NOOP( "The KDE Address Book" ),
634 KAboutData::License_GPL_V2, 634 KAboutData::License_GPL_V2,
635 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 635 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
636 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 636 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
637 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 637 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
638 about->addAuthor( "Cornelius Schumacher", 638 about->addAuthor( "Cornelius Schumacher",
639 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 639 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
640 "schumacher@kde.org" ); 640 "schumacher@kde.org" );
641 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 641 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
642 "mpilone@slac.com" ); 642 "mpilone@slac.com" );
643 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 643 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
644 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 644 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
645 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 645 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
646 "michel@klaralvdalens-datakonsult.se" ); 646 "michel@klaralvdalens-datakonsult.se" );
647 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 647 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
648 "hansen@kde.org" ); 648 "hansen@kde.org" );
649 649
650 return about; 650 return about;
651#endif //KAB_EMBEDDED 651#endif //KAB_EMBEDDED
652 652
653 QString version; 653 QString version;
654#include <../version> 654#include <../version>
655 QMessageBox::about( this, "About KAddressbook/Pi", 655 QMessageBox::about( this, "About KAddressbook/Pi",
656 "KAddressbook/Platform-independent\n" 656 "KAddressbook/Platform-independent\n"
657 "(KA/Pi) " +version + " - " + 657 "(KA/Pi) " +version + " - " +
658#ifdef DESKTOP_VERSION 658#ifdef DESKTOP_VERSION
659 "Desktop Edition\n" 659 "Desktop Edition\n"
660#else 660#else
661 "PDA-Edition\n" 661 "PDA-Edition\n"
662 "for: Zaurus 5500 / 7x0 / 8x0\n" 662 "for: Zaurus 5500 / 7x0 / 8x0\n"
663#endif 663#endif
664 664
665 "(c) 2004 Ulf Schenk\n" 665 "(c) 2004 Ulf Schenk\n"
666 "(c) 2004 Lutz Rogowski\n" 666 "(c) 2004 Lutz Rogowski\n"
667 "(c) 1997-2003, The KDE PIM Team\n" 667 "(c) 1997-2003, The KDE PIM Team\n"
668 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 668 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
669 "Don Sanders Original author\n" 669 "Don Sanders Original author\n"
670 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 670 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
671 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 671 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
672 "Greg Stern DCOP interface\n" 672 "Greg Stern DCOP interface\n"
673 "Mark Westcot Contact pinning\n" 673 "Mark Westcot Contact pinning\n"
674 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 674 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
675 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 675 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
676#ifdef _WIN32_ 676#ifdef _WIN32_
677 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 677 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
678#endif 678#endif
679 ); 679 );
680} 680}
681 681
682void KABCore::setContactSelected( const QString &uid ) 682void KABCore::setContactSelected( const QString &uid )
683{ 683{
684 KABC::Addressee addr = mAddressBook->findByUid( uid ); 684 KABC::Addressee addr = mAddressBook->findByUid( uid );
685 if ( !mDetails->isHidden() ) 685 if ( !mDetails->isHidden() )
686 mDetails->setAddressee( addr ); 686 mDetails->setAddressee( addr );
687 687
688 if ( !addr.isEmpty() ) { 688 if ( !addr.isEmpty() ) {
689 emit contactSelected( addr.formattedName() ); 689 emit contactSelected( addr.formattedName() );
690 KABC::Picture pic = addr.photo(); 690 KABC::Picture pic = addr.photo();
691 if ( pic.isIntern() ) { 691 if ( pic.isIntern() ) {
692//US emit contactSelected( pic.data() ); 692//US emit contactSelected( pic.data() );
693//US instead use: 693//US instead use:
694 QPixmap px; 694 QPixmap px;
695 if (pic.data().isNull() != true) 695 if (pic.data().isNull() != true)
696 { 696 {
697 px.convertFromImage(pic.data()); 697 px.convertFromImage(pic.data());
698 } 698 }
699 699
700 emit contactSelected( px ); 700 emit contactSelected( px );
701 } 701 }
702 } 702 }
703 703
704 704
705 mExtensionManager->setSelectionChanged(); 705 mExtensionManager->setSelectionChanged();
706 706
707 // update the actions 707 // update the actions
708 bool selected = !uid.isEmpty(); 708 bool selected = !uid.isEmpty();
709 709
710 if ( mReadWrite ) { 710 if ( mReadWrite ) {
711 mActionCut->setEnabled( selected ); 711 mActionCut->setEnabled( selected );
712 mActionPaste->setEnabled( selected ); 712 mActionPaste->setEnabled( selected );
713 } 713 }
714 714
715 mActionCopy->setEnabled( selected ); 715 mActionCopy->setEnabled( selected );
716 mActionDelete->setEnabled( selected ); 716 mActionDelete->setEnabled( selected );
717 mActionEditAddressee->setEnabled( selected ); 717 mActionEditAddressee->setEnabled( selected );
718 mActionMail->setEnabled( selected ); 718 mActionMail->setEnabled( selected );
719 mActionMailVCard->setEnabled( selected ); 719 mActionMailVCard->setEnabled( selected );
720 //if (mActionBeam) 720 //if (mActionBeam)
721 //mActionBeam->setEnabled( selected ); 721 //mActionBeam->setEnabled( selected );
722 mActionWhoAmI->setEnabled( selected ); 722 mActionWhoAmI->setEnabled( selected );
723} 723}
724 724
725void KABCore::sendMail() 725void KABCore::sendMail()
726{ 726{
727 sendMail( mViewManager->selectedEmails().join( ", " ) ); 727 sendMail( mViewManager->selectedEmails().join( ", " ) );
728} 728}
729 729
730void KABCore::sendMail( const QString& emaillist ) 730void KABCore::sendMail( const QString& emaillist )
731{ 731{
732 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 732 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
733 if (emaillist.contains(",") > 0) 733 if (emaillist.contains(",") > 0)
734 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 734 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
735 else 735 else
736 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 736 ExternalAppHandler::instance()->mailToOneContact( emaillist );
737} 737}
738 738
739 739
740 740
741void KABCore::mailVCard() 741void KABCore::mailVCard()
742{ 742{
743 QStringList uids = mViewManager->selectedUids(); 743 QStringList uids = mViewManager->selectedUids();
744 if ( !uids.isEmpty() ) 744 if ( !uids.isEmpty() )
745 mailVCard( uids ); 745 mailVCard( uids );
746} 746}
747 747
748void KABCore::mailVCard( const QStringList& uids ) 748void KABCore::mailVCard( const QStringList& uids )
749{ 749{
750 QStringList urls; 750 QStringList urls;
751 751
752// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 752// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
753 753
754 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 754 QString dirName = "/tmp/" + KApplication::randomString( 8 );
755 755
756 756
757 757
758 QDir().mkdir( dirName, true ); 758 QDir().mkdir( dirName, true );
759 759
760 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 760 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
761 KABC::Addressee a = mAddressBook->findByUid( *it ); 761 KABC::Addressee a = mAddressBook->findByUid( *it );
762 762
763 if ( a.isEmpty() ) 763 if ( a.isEmpty() )
764 continue; 764 continue;
765 765
766 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 766 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
767 767
768 QString fileName = dirName + "/" + name; 768 QString fileName = dirName + "/" + name;
769 769
770 QFile outFile(fileName); 770 QFile outFile(fileName);
771 771
772 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 772 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
773 KABC::VCardConverter converter; 773 KABC::VCardConverter converter;
774 QString vcard; 774 QString vcard;
775 775
776 converter.addresseeToVCard( a, vcard ); 776 converter.addresseeToVCard( a, vcard );
777 777
778 QTextStream t( &outFile ); // use a text stream 778 QTextStream t( &outFile ); // use a text stream
779 t.setEncoding( QTextStream::UnicodeUTF8 ); 779 t.setEncoding( QTextStream::UnicodeUTF8 );
780 t << vcard; 780 t << vcard;
781 781
782 outFile.close(); 782 outFile.close();
783 783
784 urls.append( fileName ); 784 urls.append( fileName );
785 } 785 }
786 } 786 }
787 787
788 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 788 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
789 789
790 790
791/*US 791/*US
792 kapp->invokeMailer( QString::null, QString::null, QString::null, 792 kapp->invokeMailer( QString::null, QString::null, QString::null,
793 QString::null, // subject 793 QString::null, // subject
794 QString::null, // body 794 QString::null, // body
795 QString::null, 795 QString::null,
796 urls ); // attachments 796 urls ); // attachments
797*/ 797*/
798 798
799} 799}
800 800
801/** 801/**
802 Beams the "WhoAmI contact. 802 Beams the "WhoAmI contact.
803*/ 803*/
804void KABCore::beamMySelf() 804void KABCore::beamMySelf()
805{ 805{
806 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 806 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
807 if (!a.isEmpty()) 807 if (!a.isEmpty())
808 { 808 {
809 QStringList uids; 809 QStringList uids;
810 uids << a.uid(); 810 uids << a.uid();
811 811
812 beamVCard(uids); 812 beamVCard(uids);
813 } else { 813 } else {
814 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 814 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
815 815
816 816
817 } 817 }
818} 818}
819void KABCore::updateMainWindow() 819void KABCore::updateMainWindow()
820{ 820{
821 821
822 mMainWindow->showMaximized(); 822 mMainWindow->showMaximized();
823 mMainWindow->update(); 823 mMainWindow->update();
824} 824}
825void KABCore::resizeEvent(QResizeEvent* e ) 825void KABCore::resizeEvent(QResizeEvent* e )
826{ 826{
827 if ( !mMiniSplitter ) 827 if ( !mMiniSplitter )
828 return; 828 return;
829 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); 829 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) ");
830 if ( QApplication::desktop()->width() >= 480 ) { 830 if ( QApplication::desktop()->width() >= 480 ) {
831 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 831 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480
832 if ( mMiniSplitter->orientation() == Qt::Vertical ) { 832 if ( mMiniSplitter->orientation() == Qt::Vertical ) {
833 mMiniSplitter->setOrientation( Qt::Horizontal); 833 mMiniSplitter->setOrientation( Qt::Horizontal);
834 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 834 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
835 if ( QApplication::desktop()->width() <= 640 ) { 835 if ( QApplication::desktop()->width() <= 640 ) {
836 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 836 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
837 mViewManager->getFilterAction()->setComboWidth( 150 ); 837 mViewManager->getFilterAction()->setComboWidth( 150 );
838 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 838 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
839 } 839 }
840 } 840 }
841 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 841 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640
842 if ( mMiniSplitter->orientation() == Qt::Horizontal ) { 842 if ( mMiniSplitter->orientation() == Qt::Horizontal ) {
843 mMiniSplitter->setOrientation( Qt::Vertical ); 843 mMiniSplitter->setOrientation( Qt::Vertical );
844 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 844 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
845 if ( QApplication::desktop()->width() <= 640 ) { 845 if ( QApplication::desktop()->width() <= 640 ) {
846 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 846 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
847 mMainWindow->showMinimized(); 847 mMainWindow->showMinimized();
848 mViewManager->getFilterAction()->setComboWidth( 0 ); 848 mViewManager->getFilterAction()->setComboWidth( 0 );
849 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 849 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
850 } 850 }
851 } 851 }
852 } 852 }
853 } 853 }
854 854
855} 855}
856void KABCore::export2phone() 856void KABCore::export2phone()
857{ 857{
858 858
859 QStringList uids; 859 QStringList uids;
860 XXPortSelectDialog dlg( this, false, this ); 860 XXPortSelectDialog dlg( this, false, this );
861 if ( dlg.exec() ) 861 if ( dlg.exec() )
862 uids = dlg.uids(); 862 uids = dlg.uids();
863 else 863 else
864 return; 864 return;
865 if ( uids.isEmpty() ) 865 if ( uids.isEmpty() )
866 return; 866 return;
867 // qDebug("count %d ", uids.count()); 867 // qDebug("count %d ", uids.count());
868 868
869 KAex2phonePrefs ex2phone; 869 KAex2phonePrefs ex2phone;
870 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 870 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
871 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 871 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
872 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 872 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
873 873
874 if ( !ex2phone.exec() ) { 874 if ( !ex2phone.exec() ) {
875 return; 875 return;
876 } 876 }
877 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 877 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
878 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 878 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
879 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 879 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
880 880
881 881
882 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 882 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
883 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 883 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
884 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 884 KPimGlobalPrefs::instance()->mEx2PhoneModel );
885 885
886 QString fileName = getPhoneFile(); 886 QString fileName = getPhoneFile();
887 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 887 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
888 return; 888 return;
889 889
890 message(i18n("Exporting to phone...")); 890 message(i18n("Exporting to phone..."));
891 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 891 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
892 892
893} 893}
894QString KABCore::getPhoneFile() 894QString KABCore::getPhoneFile()
895{ 895{
896#ifdef DESKTOP_VERSION 896#ifdef DESKTOP_VERSION
897 return locateLocal("tmp", "phonefile.vcf"); 897 return locateLocal("tmp", "phonefile.vcf");
898#else 898#else
899 return "/tmp/phonefile.vcf"; 899 return "/tmp/phonefile.vcf";
900#endif 900#endif
901 901
902} 902}
903void KABCore::writeToPhone( ) 903void KABCore::writeToPhone( )
904{ 904{
905 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 905 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
906 message(i18n("Export to phone finished!")); 906 message(i18n("Export to phone finished!"));
907 else 907 else
908 qDebug(i18n("Error exporting to phone")); 908 qDebug(i18n("Error exporting to phone"));
909} 909}
910void KABCore::beamVCard() 910void KABCore::beamVCard()
911{ 911{
912 QStringList uids; 912 QStringList uids;
913 XXPortSelectDialog dlg( this, false, this ); 913 XXPortSelectDialog dlg( this, false, this );
914 if ( dlg.exec() ) 914 if ( dlg.exec() )
915 uids = dlg.uids(); 915 uids = dlg.uids();
916 else 916 else
917 return; 917 return;
918 if ( uids.isEmpty() ) 918 if ( uids.isEmpty() )
919 return; 919 return;
920 beamVCard( uids ); 920 beamVCard( uids );
921} 921}
922 922
923 923
924void KABCore::beamVCard(const QStringList& uids) 924void KABCore::beamVCard(const QStringList& uids)
925{ 925{
926 926
927 // LR: we should use the /tmp dir on the Zaurus, 927 // LR: we should use the /tmp dir on the Zaurus,
928 // because: /tmp = RAM, (HOME)/kdepim = flash memory 928 // because: /tmp = RAM, (HOME)/kdepim = flash memory
929 929
930#ifdef DESKTOP_VERSION 930#ifdef DESKTOP_VERSION
931 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 931 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
932#else 932#else
933 QString fileName = "/tmp/kapibeamfile.vcf"; 933 QString fileName = "/tmp/kapibeamfile.vcf";
934#endif 934#endif
935 935
936 KABC::VCardConverter converter; 936 KABC::VCardConverter converter;
937 QString description; 937 QString description;
938 QString datastream; 938 QString datastream;
939 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 939 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
940 KABC::Addressee a = mAddressBook->findByUid( *it ); 940 KABC::Addressee a = mAddressBook->findByUid( *it );
941 941
942 if ( a.isEmpty() ) 942 if ( a.isEmpty() )
943 continue; 943 continue;
944 944
945 if (description.isEmpty()) 945 if (description.isEmpty())
946 description = a.formattedName(); 946 description = a.formattedName();
947 947
948 QString vcard; 948 QString vcard;
949 converter.addresseeToVCard( a, vcard ); 949 converter.addresseeToVCard( a, vcard );
950 int start = 0; 950 int start = 0;
951 int next; 951 int next;
952 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 952 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
953 int semi = vcard.find(";", next); 953 int semi = vcard.find(";", next);
954 int dopp = vcard.find(":", next); 954 int dopp = vcard.find(":", next);
955 int sep; 955 int sep;
956 if ( semi < dopp && semi >= 0 ) 956 if ( semi < dopp && semi >= 0 )
957 sep = semi ; 957 sep = semi ;
958 else 958 else
959 sep = dopp; 959 sep = dopp;
960 datastream +=vcard.mid( start, next - start); 960 datastream +=vcard.mid( start, next - start);
961 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 961 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
962 start = sep; 962 start = sep;
963 } 963 }
964 datastream += vcard.mid( start,vcard.length() ); 964 datastream += vcard.mid( start,vcard.length() );
965 } 965 }
966#ifndef DESKTOP_VERSION 966#ifndef DESKTOP_VERSION
967 QFile outFile(fileName); 967 QFile outFile(fileName);
968 if ( outFile.open(IO_WriteOnly) ) { 968 if ( outFile.open(IO_WriteOnly) ) {
969 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 969 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
970 QTextStream t( &outFile ); // use a text stream 970 QTextStream t( &outFile ); // use a text stream
971 //t.setEncoding( QTextStream::UnicodeUTF8 ); 971 //t.setEncoding( QTextStream::UnicodeUTF8 );
972 t.setEncoding( QTextStream::Latin1 ); 972 t.setEncoding( QTextStream::Latin1 );
973 t <<datastream.latin1(); 973 t <<datastream.latin1();
974 outFile.close(); 974 outFile.close();
975 Ir *ir = new Ir( this ); 975 Ir *ir = new Ir( this );
976 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 976 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
977 ir->send( fileName, description, "text/x-vCard" ); 977 ir->send( fileName, description, "text/x-vCard" );
978 } else { 978 } else {
979 qDebug("Error open temp beam file "); 979 qDebug("Error open temp beam file ");
980 return; 980 return;
981 } 981 }
982#endif 982#endif
983 983
984} 984}
985 985
986void KABCore::beamDone( Ir *ir ) 986void KABCore::beamDone( Ir *ir )
987{ 987{
988#ifndef DESKTOP_VERSION 988#ifndef DESKTOP_VERSION
989 delete ir; 989 delete ir;
990#endif 990#endif
991 topLevelWidget()->raise(); 991 topLevelWidget()->raise();
992 message( i18n("Beaming finished!") ); 992 message( i18n("Beaming finished!") );
993} 993}
994 994
995 995
996void KABCore::browse( const QString& url ) 996void KABCore::browse( const QString& url )
997{ 997{
998#ifndef KAB_EMBEDDED 998#ifndef KAB_EMBEDDED
999 kapp->invokeBrowser( url ); 999 kapp->invokeBrowser( url );
1000#else //KAB_EMBEDDED 1000#else //KAB_EMBEDDED
1001 qDebug("KABCore::browse must be fixed"); 1001 qDebug("KABCore::browse must be fixed");
1002#endif //KAB_EMBEDDED 1002#endif //KAB_EMBEDDED
1003} 1003}
1004 1004
1005void KABCore::selectAllContacts() 1005void KABCore::selectAllContacts()
1006{ 1006{
1007 mViewManager->setSelected( QString::null, true ); 1007 mViewManager->setSelected( QString::null, true );
1008} 1008}
1009 1009
1010void KABCore::deleteContacts() 1010void KABCore::deleteContacts()
1011{ 1011{
1012 QStringList uidList = mViewManager->selectedUids(); 1012 QStringList uidList = mViewManager->selectedUids();
1013 deleteContacts( uidList ); 1013 deleteContacts( uidList );
1014} 1014}
1015 1015
1016void KABCore::deleteContacts( const QStringList &uids ) 1016void KABCore::deleteContacts( const QStringList &uids )
1017{ 1017{
1018 if ( uids.count() > 0 ) { 1018 if ( uids.count() > 0 ) {
1019 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 1019 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
1020 UndoStack::instance()->push( command ); 1020 UndoStack::instance()->push( command );
1021 RedoStack::instance()->clear(); 1021 RedoStack::instance()->clear();
1022 1022
1023 // now if we deleted anything, refresh 1023 // now if we deleted anything, refresh
1024 setContactSelected( QString::null ); 1024 setContactSelected( QString::null );
1025 setModified( true ); 1025 setModified( true );
1026 } 1026 }
1027} 1027}
1028 1028
1029void KABCore::copyContacts() 1029void KABCore::copyContacts()
1030{ 1030{
1031 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1031 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1032 1032
1033 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 1033 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
1034 1034
1035 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 1035 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
1036 1036
1037 QClipboard *cb = QApplication::clipboard(); 1037 QClipboard *cb = QApplication::clipboard();
1038 cb->setText( clipText ); 1038 cb->setText( clipText );
1039} 1039}
1040 1040
1041void KABCore::cutContacts() 1041void KABCore::cutContacts()
1042{ 1042{
1043 QStringList uidList = mViewManager->selectedUids(); 1043 QStringList uidList = mViewManager->selectedUids();
1044 1044
1045//US if ( uidList.size() > 0 ) { 1045//US if ( uidList.size() > 0 ) {
1046 if ( uidList.count() > 0 ) { 1046 if ( uidList.count() > 0 ) {
1047 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 1047 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
1048 UndoStack::instance()->push( command ); 1048 UndoStack::instance()->push( command );
1049 RedoStack::instance()->clear(); 1049 RedoStack::instance()->clear();
1050 1050
1051 setModified( true ); 1051 setModified( true );
1052 } 1052 }
1053} 1053}
1054 1054
1055void KABCore::pasteContacts() 1055void KABCore::pasteContacts()
1056{ 1056{
1057 QClipboard *cb = QApplication::clipboard(); 1057 QClipboard *cb = QApplication::clipboard();
1058 1058
1059 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 1059 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
1060 1060
1061 pasteContacts( list ); 1061 pasteContacts( list );
1062} 1062}
1063 1063
1064void KABCore::pasteContacts( KABC::Addressee::List &list ) 1064void KABCore::pasteContacts( KABC::Addressee::List &list )
1065{ 1065{
1066 KABC::Resource *resource = requestResource( this ); 1066 KABC::Resource *resource = requestResource( this );
1067 KABC::Addressee::List::Iterator it; 1067 KABC::Addressee::List::Iterator it;
1068 for ( it = list.begin(); it != list.end(); ++it ) 1068 for ( it = list.begin(); it != list.end(); ++it )
1069 (*it).setResource( resource ); 1069 (*it).setResource( resource );
1070 1070
1071 PwPasteCommand *command = new PwPasteCommand( this, list ); 1071 PwPasteCommand *command = new PwPasteCommand( this, list );
1072 UndoStack::instance()->push( command ); 1072 UndoStack::instance()->push( command );
1073 RedoStack::instance()->clear(); 1073 RedoStack::instance()->clear();
1074 1074
1075 setModified( true ); 1075 setModified( true );
1076} 1076}
1077 1077
1078void KABCore::setWhoAmI() 1078void KABCore::setWhoAmI()
1079{ 1079{
1080 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1080 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1081 1081
1082 if ( addrList.count() > 1 ) { 1082 if ( addrList.count() > 1 ) {
1083 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 1083 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
1084 return; 1084 return;
1085 } 1085 }
1086 1086
1087 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 1087 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
1088 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 1088 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
1089 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 1089 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
1090} 1090}
1091void KABCore::editCategories() 1091void KABCore::editCategories()
1092{ 1092{
1093 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); 1093 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1094 dlg.exec(); 1094 dlg.exec();
1095} 1095}
1096void KABCore::setCategories() 1096void KABCore::setCategories()
1097{ 1097{
1098 1098
1099 QStringList uids; 1099 QStringList uids;
1100 XXPortSelectDialog dlgx( this, false, this ); 1100 XXPortSelectDialog dlgx( this, false, this );
1101 if ( dlgx.exec() ) 1101 if ( dlgx.exec() )
1102 uids = dlgx.uids(); 1102 uids = dlgx.uids();
1103 else 1103 else
1104 return; 1104 return;
1105 if ( uids.isEmpty() ) 1105 if ( uids.isEmpty() )
1106 return; 1106 return;
1107 // qDebug("count %d ", uids.count()); 1107 // qDebug("count %d ", uids.count());
1108 1108
1109 1109
1110 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1110 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
1111 if ( !dlg.exec() ) { 1111 if ( !dlg.exec() ) {
1112 message( i18n("Setting categories cancelled") ); 1112 message( i18n("Setting categories cancelled") );
1113 return; 1113 return;
1114 } 1114 }
1115 bool merge = false; 1115 bool merge = false;
1116 QString msg = i18n( "Merge with existing categories?" ); 1116 QString msg = i18n( "Merge with existing categories?" );
1117 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1117 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
1118 merge = true; 1118 merge = true;
1119 1119
1120 message( i18n("Setting categories ... please wait!") ); 1120 message( i18n("Setting categories ... please wait!") );
1121 QStringList categories = dlg.selectedCategories(); 1121 QStringList categories = dlg.selectedCategories();
1122 1122
1123 //QStringList uids = mViewManager->selectedUids(); 1123 //QStringList uids = mViewManager->selectedUids();
1124 QStringList::Iterator it; 1124 QStringList::Iterator it;
1125 for ( it = uids.begin(); it != uids.end(); ++it ) { 1125 for ( it = uids.begin(); it != uids.end(); ++it ) {
1126 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1126 KABC::Addressee addr = mAddressBook->findByUid( *it );
1127 if ( !addr.isEmpty() ) { 1127 if ( !addr.isEmpty() ) {
1128 if ( !merge ) 1128 if ( !merge )
1129 addr.setCategories( categories ); 1129 addr.setCategories( categories );
1130 else { 1130 else {
1131 QStringList addrCategories = addr.categories(); 1131 QStringList addrCategories = addr.categories();
1132 QStringList::Iterator catIt; 1132 QStringList::Iterator catIt;
1133 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1133 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1134 if ( !addrCategories.contains( *catIt ) ) 1134 if ( !addrCategories.contains( *catIt ) )
1135 addrCategories.append( *catIt ); 1135 addrCategories.append( *catIt );
1136 } 1136 }
1137 addr.setCategories( addrCategories ); 1137 addr.setCategories( addrCategories );
1138 } 1138 }
1139 mAddressBook->insertAddressee( addr ); 1139 mAddressBook->insertAddressee( addr );
1140 } 1140 }
1141 } 1141 }
1142 1142
1143 if ( uids.count() > 0 ) 1143 if ( uids.count() > 0 )
1144 setModified( true ); 1144 setModified( true );
1145 message( i18n("Setting categories completed!") ); 1145 message( i18n("Setting categories completed!") );
1146} 1146}
1147 1147
1148void KABCore::setSearchFields( const KABC::Field::List &fields ) 1148void KABCore::setSearchFields( const KABC::Field::List &fields )
1149{ 1149{
1150 mIncSearchWidget->setFields( fields ); 1150 mIncSearchWidget->setFields( fields );
1151} 1151}
1152 1152
1153void KABCore::incrementalSearch( const QString& text ) 1153void KABCore::incrementalSearch( const QString& text )
1154{ 1154{
1155 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1155 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1156} 1156}
1157 1157
1158void KABCore::setModified() 1158void KABCore::setModified()
1159{ 1159{
1160 setModified( true ); 1160 setModified( true );
1161} 1161}
1162 1162
1163void KABCore::setModifiedWOrefresh() 1163void KABCore::setModifiedWOrefresh()
1164{ 1164{
1165 // qDebug("KABCore::setModifiedWOrefresh() "); 1165 // qDebug("KABCore::setModifiedWOrefresh() ");
1166 mModified = true; 1166 mModified = true;
1167 mActionSave->setEnabled( mModified ); 1167 mActionSave->setEnabled( mModified );
1168 1168
1169 1169
1170} 1170}
1171void KABCore::setModified( bool modified ) 1171void KABCore::setModified( bool modified )
1172{ 1172{
1173 mModified = modified; 1173 mModified = modified;
1174 mActionSave->setEnabled( mModified ); 1174 mActionSave->setEnabled( mModified );
1175 1175
1176 if ( modified ) 1176 if ( modified )
1177 mJumpButtonBar->recreateButtons(); 1177 mJumpButtonBar->recreateButtons();
1178 1178
1179 mViewManager->refreshView(); 1179 mViewManager->refreshView();
1180 1180
1181} 1181}
1182 1182
1183bool KABCore::modified() const 1183bool KABCore::modified() const
1184{ 1184{
1185 return mModified; 1185 return mModified;
1186} 1186}
1187 1187
1188void KABCore::contactModified( const KABC::Addressee &addr ) 1188void KABCore::contactModified( const KABC::Addressee &addr )
1189{ 1189{
1190 addrModified( addr ); 1190 addrModified( addr );
1191#if 0 // debug only
1192 KABC::Addressee ad = addr;
1193 ad.computeCsum( "123");
1194#endif
1191} 1195}
1192 1196
1193void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) 1197void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails )
1194{ 1198{
1195 1199
1196 Command *command = 0; 1200 Command *command = 0;
1197 QString uid; 1201 QString uid;
1198 1202
1199 // check if it exists already 1203 // check if it exists already
1200 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1204 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1201 if ( origAddr.isEmpty() ) 1205 if ( origAddr.isEmpty() )
1202 command = new PwNewCommand( mAddressBook, addr ); 1206 command = new PwNewCommand( mAddressBook, addr );
1203 else { 1207 else {
1204 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1208 command = new PwEditCommand( mAddressBook, origAddr, addr );
1205 uid = addr.uid(); 1209 uid = addr.uid();
1206 } 1210 }
1207 1211
1208 UndoStack::instance()->push( command ); 1212 UndoStack::instance()->push( command );
1209 RedoStack::instance()->clear(); 1213 RedoStack::instance()->clear();
1210 if ( updateDetails ) 1214 if ( updateDetails )
1211 mDetails->setAddressee( addr ); 1215 mDetails->setAddressee( addr );
1212 setModified( true ); 1216 setModified( true );
1213} 1217}
1214 1218
1215void KABCore::newContact() 1219void KABCore::newContact()
1216{ 1220{
1217 1221
1218 1222
1219 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1223 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1220 1224
1221 QPtrList<KRES::Resource> kresResources; 1225 QPtrList<KRES::Resource> kresResources;
1222 QPtrListIterator<KABC::Resource> it( kabcResources ); 1226 QPtrListIterator<KABC::Resource> it( kabcResources );
1223 KABC::Resource *resource; 1227 KABC::Resource *resource;
1224 while ( ( resource = it.current() ) != 0 ) { 1228 while ( ( resource = it.current() ) != 0 ) {
1225 ++it; 1229 ++it;
1226 if ( !resource->readOnly() ) { 1230 if ( !resource->readOnly() ) {
1227 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1231 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1228 if ( res ) 1232 if ( res )
1229 kresResources.append( res ); 1233 kresResources.append( res );
1230 } 1234 }
1231 } 1235 }
1232 1236
1233 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1237 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1234 resource = static_cast<KABC::Resource*>( res ); 1238 resource = static_cast<KABC::Resource*>( res );
1235 1239
1236 if ( resource ) { 1240 if ( resource ) {
1237 KABC::Addressee addr; 1241 KABC::Addressee addr;
1238 addr.setResource( resource ); 1242 addr.setResource( resource );
1239 mEditorDialog->setAddressee( addr ); 1243 mEditorDialog->setAddressee( addr );
1240 KApplication::execDialog ( mEditorDialog ); 1244 KApplication::execDialog ( mEditorDialog );
1241 1245
1242 } else 1246 } else
1243 return; 1247 return;
1244 1248
1245 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1249 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1246 1250
1247 1251
1248} 1252}
1249 1253
1250void KABCore::addEmail( QString aStr ) 1254void KABCore::addEmail( QString aStr )
1251{ 1255{
1252#ifndef KAB_EMBEDDED 1256#ifndef KAB_EMBEDDED
1253 QString fullName, email; 1257 QString fullName, email;
1254 1258
1255 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1259 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1256 1260
1257 // Try to lookup the addressee matching the email address 1261 // Try to lookup the addressee matching the email address
1258 bool found = false; 1262 bool found = false;
1259 QStringList emailList; 1263 QStringList emailList;
1260 KABC::AddressBook::Iterator it; 1264 KABC::AddressBook::Iterator it;
1261 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1265 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1262 emailList = (*it).emails(); 1266 emailList = (*it).emails();
1263 if ( emailList.contains( email ) > 0 ) { 1267 if ( emailList.contains( email ) > 0 ) {
1264 found = true; 1268 found = true;
1265 (*it).setNameFromString( fullName ); 1269 (*it).setNameFromString( fullName );
1266 editContact( (*it).uid() ); 1270 editContact( (*it).uid() );
1267 } 1271 }
1268 } 1272 }
1269 1273
1270 if ( !found ) { 1274 if ( !found ) {
1271 KABC::Addressee addr; 1275 KABC::Addressee addr;
1272 addr.setNameFromString( fullName ); 1276 addr.setNameFromString( fullName );
1273 addr.insertEmail( email, true ); 1277 addr.insertEmail( email, true );
1274 1278
1275 mAddressBook->insertAddressee( addr ); 1279 mAddressBook->insertAddressee( addr );
1276 mViewManager->refreshView( addr.uid() ); 1280 mViewManager->refreshView( addr.uid() );
1277 editContact( addr.uid() ); 1281 editContact( addr.uid() );
1278 } 1282 }
1279#else //KAB_EMBEDDED 1283#else //KAB_EMBEDDED
1280 qDebug("KABCore::addEmail finsih method"); 1284 qDebug("KABCore::addEmail finsih method");
1281#endif //KAB_EMBEDDED 1285#endif //KAB_EMBEDDED
1282} 1286}
1283 1287
1284void KABCore::importVCard( const KURL &url, bool showPreview ) 1288void KABCore::importVCard( const KURL &url, bool showPreview )
1285{ 1289{
1286 mXXPortManager->importVCard( url, showPreview ); 1290 mXXPortManager->importVCard( url, showPreview );
1287} 1291}
1288void KABCore::importFromOL() 1292void KABCore::importFromOL()
1289{ 1293{
1290#ifdef _WIN32_ 1294#ifdef _WIN32_
1291 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1295 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1292 idgl->exec(); 1296 idgl->exec();
1293 KABC::Addressee::List list = idgl->getAddressList(); 1297 KABC::Addressee::List list = idgl->getAddressList();
1294 if ( list.count() > 0 ) { 1298 if ( list.count() > 0 ) {
1295 KABC::Addressee::List listNew; 1299 KABC::Addressee::List listNew;
1296 KABC::Addressee::List listExisting; 1300 KABC::Addressee::List listExisting;
1297 KABC::Addressee::List::Iterator it; 1301 KABC::Addressee::List::Iterator it;
1298 KABC::AddressBook::Iterator iter; 1302 KABC::AddressBook::Iterator iter;
1299 for ( it = list.begin(); it != list.end(); ++it ) { 1303 for ( it = list.begin(); it != list.end(); ++it ) {
1300 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1304 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1301 listNew.append( (*it) ); 1305 listNew.append( (*it) );
1302 else 1306 else
1303 listExisting.append( (*it) ); 1307 listExisting.append( (*it) );
1304 } 1308 }
1305 if ( listExisting.count() > 0 ) 1309 if ( listExisting.count() > 0 )
1306 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1310 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1307 if ( listNew.count() > 0 ) { 1311 if ( listNew.count() > 0 ) {
1308 pasteWithNewUid = false; 1312 pasteWithNewUid = false;
1309 pasteContacts( listNew ); 1313 pasteContacts( listNew );
1310 pasteWithNewUid = true; 1314 pasteWithNewUid = true;
1311 } 1315 }
1312 } 1316 }
1313 delete idgl; 1317 delete idgl;
1314#endif 1318#endif
1315} 1319}
1316 1320
1317void KABCore::importVCard( const QString &vCard, bool showPreview ) 1321void KABCore::importVCard( const QString &vCard, bool showPreview )
1318{ 1322{
1319 mXXPortManager->importVCard( vCard, showPreview ); 1323 mXXPortManager->importVCard( vCard, showPreview );
1320} 1324}
1321 1325
1322//US added a second method without defaultparameter 1326//US added a second method without defaultparameter
1323void KABCore::editContact2() { 1327void KABCore::editContact2() {
1324 editContact( QString::null ); 1328 editContact( QString::null );
1325} 1329}
1326 1330
1327void KABCore::editContact( const QString &uid ) 1331void KABCore::editContact( const QString &uid )
1328{ 1332{
1329 1333
1330 if ( mExtensionManager->isQuickEditVisible() ) 1334 if ( mExtensionManager->isQuickEditVisible() )
1331 return; 1335 return;
1332 1336
1333 // First, locate the contact entry 1337 // First, locate the contact entry
1334 QString localUID = uid; 1338 QString localUID = uid;
1335 if ( localUID.isNull() ) { 1339 if ( localUID.isNull() ) {
1336 QStringList uidList = mViewManager->selectedUids(); 1340 QStringList uidList = mViewManager->selectedUids();
1337 if ( uidList.count() > 0 ) 1341 if ( uidList.count() > 0 )
1338 localUID = *( uidList.at( 0 ) ); 1342 localUID = *( uidList.at( 0 ) );
1339 } 1343 }
1340 1344
1341 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1345 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1342 if ( !addr.isEmpty() ) { 1346 if ( !addr.isEmpty() ) {
1343 mEditorDialog->setAddressee( addr ); 1347 mEditorDialog->setAddressee( addr );
1344 KApplication::execDialog ( mEditorDialog ); 1348 KApplication::execDialog ( mEditorDialog );
1345 } 1349 }
1346} 1350}
1347 1351
1348/** 1352/**
1349 Shows or edits the detail view for the given uid. If the uid is QString::null, 1353 Shows or edits the detail view for the given uid. If the uid is QString::null,
1350 the method will try to find a selected addressee in the view. 1354 the method will try to find a selected addressee in the view.
1351 */ 1355 */
1352void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1356void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1353{ 1357{
1354 if ( mMultipleViewsAtOnce ) 1358 if ( mMultipleViewsAtOnce )
1355 { 1359 {
1356 editContact( uid ); 1360 editContact( uid );
1357 } 1361 }
1358 else 1362 else
1359 { 1363 {
1360 setDetailsVisible( true ); 1364 setDetailsVisible( true );
1361 mActionDetails->setChecked(true); 1365 mActionDetails->setChecked(true);
1362 } 1366 }
1363 1367
1364} 1368}
1365 1369
1366void KABCore::save() 1370void KABCore::save()
1367{ 1371{
1368 if (syncManager->blockSave()) 1372 if (syncManager->blockSave())
1369 return; 1373 return;
1370 if ( !mModified ) 1374 if ( !mModified )
1371 return; 1375 return;
1372 1376
1373 syncManager->setBlockSave(true); 1377 syncManager->setBlockSave(true);
1374 QString text = i18n( "There was an error while attempting to save\n the " 1378 QString text = i18n( "There was an error while attempting to save\n the "
1375 "address book. Please check that some \nother application is " 1379 "address book. Please check that some \nother application is "
1376 "not using it. " ); 1380 "not using it. " );
1377 message(i18n("Saving ... please wait! "), false); 1381 message(i18n("Saving ... please wait! "), false);
1378 //qApp->processEvents(); 1382 //qApp->processEvents();
1379#ifndef KAB_EMBEDDED 1383#ifndef KAB_EMBEDDED
1380 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1384 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1381 if ( !b || !b->save() ) { 1385 if ( !b || !b->save() ) {
1382 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1386 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1383 } 1387 }
1384#else //KAB_EMBEDDED 1388#else //KAB_EMBEDDED
1385 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1389 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1386 if ( !b || !b->save() ) { 1390 if ( !b || !b->save() ) {
1387 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1391 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1388 } 1392 }
1389#endif //KAB_EMBEDDED 1393#endif //KAB_EMBEDDED
1390 1394
1391 message(i18n("Addressbook saved!")); 1395 message(i18n("Addressbook saved!"));
1392 setModified( false ); 1396 setModified( false );
1393 syncManager->setBlockSave(false); 1397 syncManager->setBlockSave(false);
1394} 1398}
1395 1399
1396 1400
1397void KABCore::undo() 1401void KABCore::undo()
1398{ 1402{
1399 UndoStack::instance()->undo(); 1403 UndoStack::instance()->undo();
1400 1404
1401 // Refresh the view 1405 // Refresh the view
1402 mViewManager->refreshView(); 1406 mViewManager->refreshView();
1403} 1407}
1404 1408
1405void KABCore::redo() 1409void KABCore::redo()
1406{ 1410{
1407 RedoStack::instance()->redo(); 1411 RedoStack::instance()->redo();
1408 1412
1409 // Refresh the view 1413 // Refresh the view
1410 mViewManager->refreshView(); 1414 mViewManager->refreshView();
1411} 1415}
1412 1416
1413void KABCore::setJumpButtonBarVisible( bool visible ) 1417void KABCore::setJumpButtonBarVisible( bool visible )
1414{ 1418{
1415 if (mMultipleViewsAtOnce) 1419 if (mMultipleViewsAtOnce)
1416 { 1420 {
1417 if ( visible ) 1421 if ( visible )
1418 mJumpButtonBar->show(); 1422 mJumpButtonBar->show();
1419 else 1423 else
1420 mJumpButtonBar->hide(); 1424 mJumpButtonBar->hide();
1421 } 1425 }
1422 else 1426 else
1423 { 1427 {
1424 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1428 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1425 if (mViewManager->isVisible()) 1429 if (mViewManager->isVisible())
1426 { 1430 {
1427 if ( visible ) 1431 if ( visible )
1428 mJumpButtonBar->show(); 1432 mJumpButtonBar->show();
1429 else 1433 else
1430 mJumpButtonBar->hide(); 1434 mJumpButtonBar->hide();
1431 } 1435 }
1432 else 1436 else
1433 { 1437 {
1434 mJumpButtonBar->hide(); 1438 mJumpButtonBar->hide();
1435 } 1439 }
1436 } 1440 }
1437} 1441}
1438 1442
1439 1443
1440void KABCore::setDetailsToState() 1444void KABCore::setDetailsToState()
1441{ 1445{
1442 setDetailsVisible( mActionDetails->isChecked() ); 1446 setDetailsVisible( mActionDetails->isChecked() );
1443} 1447}
1444void KABCore::setDetailsToggle() 1448void KABCore::setDetailsToggle()
1445{ 1449{
1446 mActionDetails->setChecked( !mActionDetails->isChecked() ); 1450 mActionDetails->setChecked( !mActionDetails->isChecked() );
1447 setDetailsToState(); 1451 setDetailsToState();
1448} 1452}
1449 1453
1450 1454
1451 1455
1452void KABCore::setDetailsVisible( bool visible ) 1456void KABCore::setDetailsVisible( bool visible )
1453{ 1457{
1454 if (visible && mDetails->isHidden()) 1458 if (visible && mDetails->isHidden())
1455 { 1459 {
1456 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1460 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1457 if ( addrList.count() > 0 ) 1461 if ( addrList.count() > 0 )
1458 mDetails->setAddressee( addrList[ 0 ] ); 1462 mDetails->setAddressee( addrList[ 0 ] );
1459 } 1463 }
1460 1464
1461 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1465 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1462 // the listview and the detailview. We do that by changing the splitbar size. 1466 // the listview and the detailview. We do that by changing the splitbar size.
1463 if (mMultipleViewsAtOnce) 1467 if (mMultipleViewsAtOnce)
1464 { 1468 {
1465 if ( visible ) 1469 if ( visible )
1466 mDetails->show(); 1470 mDetails->show();
1467 else 1471 else
1468 mDetails->hide(); 1472 mDetails->hide();
1469 } 1473 }
1470 else 1474 else
1471 { 1475 {
1472 if ( visible ) { 1476 if ( visible ) {
1473 mViewManager->hide(); 1477 mViewManager->hide();
1474 mDetails->show(); 1478 mDetails->show();
1475 mIncSearchWidget->setFocus(); 1479 mIncSearchWidget->setFocus();
1476 } 1480 }
1477 else { 1481 else {
1478 mViewManager->show(); 1482 mViewManager->show();
1479 mDetails->hide(); 1483 mDetails->hide();
1480 mViewManager->setFocusAV(); 1484 mViewManager->setFocusAV();
1481 } 1485 }
1482 setJumpButtonBarVisible( !visible ); 1486 setJumpButtonBarVisible( !visible );
1483 } 1487 }
1484 1488
1485} 1489}
1486 1490
1487void KABCore::extensionChanged( int id ) 1491void KABCore::extensionChanged( int id )
1488{ 1492{
1489 //change the details view only for non desktop systems 1493 //change the details view only for non desktop systems
1490#ifndef DESKTOP_VERSION 1494#ifndef DESKTOP_VERSION
1491 1495
1492 if (id == 0) 1496 if (id == 0)
1493 { 1497 {
1494 //the user disabled the extension. 1498 //the user disabled the extension.
1495 1499
1496 if (mMultipleViewsAtOnce) 1500 if (mMultipleViewsAtOnce)
1497 { // enable detailsview again 1501 { // enable detailsview again
1498 setDetailsVisible( true ); 1502 setDetailsVisible( true );
1499 mActionDetails->setChecked( true ); 1503 mActionDetails->setChecked( true );
1500 } 1504 }
1501 else 1505 else
1502 { //go back to the listview 1506 { //go back to the listview
1503 setDetailsVisible( false ); 1507 setDetailsVisible( false );
1504 mActionDetails->setChecked( false ); 1508 mActionDetails->setChecked( false );
1505 mActionDetails->setEnabled(true); 1509 mActionDetails->setEnabled(true);
1506 } 1510 }
1507 1511
1508 } 1512 }
1509 else 1513 else
1510 { 1514 {
1511 //the user enabled the extension. 1515 //the user enabled the extension.
1512 setDetailsVisible( false ); 1516 setDetailsVisible( false );
1513 mActionDetails->setChecked( false ); 1517 mActionDetails->setChecked( false );
1514 1518
1515 if (!mMultipleViewsAtOnce) 1519 if (!mMultipleViewsAtOnce)
1516 { 1520 {
1517 mActionDetails->setEnabled(false); 1521 mActionDetails->setEnabled(false);
1518 } 1522 }
1519 1523
1520 mExtensionManager->setSelectionChanged(); 1524 mExtensionManager->setSelectionChanged();
1521 1525
1522 } 1526 }
1523 1527
1524#endif// DESKTOP_VERSION 1528#endif// DESKTOP_VERSION
1525 1529
1526} 1530}
1527 1531
1528 1532
1529void KABCore::extensionModified( const KABC::Addressee::List &list ) 1533void KABCore::extensionModified( const KABC::Addressee::List &list )
1530{ 1534{
1531 1535
1532 if ( list.count() != 0 ) { 1536 if ( list.count() != 0 ) {
1533 KABC::Addressee::List::ConstIterator it; 1537 KABC::Addressee::List::ConstIterator it;
1534 for ( it = list.begin(); it != list.end(); ++it ) 1538 for ( it = list.begin(); it != list.end(); ++it )
1535 mAddressBook->insertAddressee( *it ); 1539 mAddressBook->insertAddressee( *it );
1536 if ( list.count() > 1 ) 1540 if ( list.count() > 1 )
1537 setModified(); 1541 setModified();
1538 else 1542 else
1539 setModifiedWOrefresh(); 1543 setModifiedWOrefresh();
1540 } 1544 }
1541 if ( list.count() == 0 ) 1545 if ( list.count() == 0 )
1542 mViewManager->refreshView(); 1546 mViewManager->refreshView();
1543 else 1547 else
1544 mViewManager->refreshView( list[ 0 ].uid() ); 1548 mViewManager->refreshView( list[ 0 ].uid() );
1545 1549
1546 1550
1547 1551
1548} 1552}
1549 1553
1550QString KABCore::getNameByPhone( const QString &phone ) 1554QString KABCore::getNameByPhone( const QString &phone )
1551{ 1555{
1552#ifndef KAB_EMBEDDED 1556#ifndef KAB_EMBEDDED
1553 QRegExp r( "[/*/-/ ]" ); 1557 QRegExp r( "[/*/-/ ]" );
1554 QString localPhone( phone ); 1558 QString localPhone( phone );
1555 1559
1556 bool found = false; 1560 bool found = false;
1557 QString ownerName = ""; 1561 QString ownerName = "";
1558 KABC::AddressBook::Iterator iter; 1562 KABC::AddressBook::Iterator iter;
1559 KABC::PhoneNumber::List::Iterator phoneIter; 1563 KABC::PhoneNumber::List::Iterator phoneIter;
1560 KABC::PhoneNumber::List phoneList; 1564 KABC::PhoneNumber::List phoneList;
1561 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1565 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1562 phoneList = (*iter).phoneNumbers(); 1566 phoneList = (*iter).phoneNumbers();
1563 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1567 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1564 ++phoneIter) { 1568 ++phoneIter) {
1565 // Get rid of separator chars so just the numbers are compared. 1569 // Get rid of separator chars so just the numbers are compared.
1566 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1570 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1567 ownerName = (*iter).formattedName(); 1571 ownerName = (*iter).formattedName();
1568 found = true; 1572 found = true;
1569 } 1573 }
1570 } 1574 }
1571 } 1575 }
1572 1576
1573 return ownerName; 1577 return ownerName;
1574#else //KAB_EMBEDDED 1578#else //KAB_EMBEDDED
1575 qDebug("KABCore::getNameByPhone finsih method"); 1579 qDebug("KABCore::getNameByPhone finsih method");
1576 return ""; 1580 return "";
1577#endif //KAB_EMBEDDED 1581#endif //KAB_EMBEDDED
1578 1582
1579} 1583}
1580 1584
1581void KABCore::openConfigDialog() 1585void KABCore::openConfigDialog()
1582{ 1586{
1583 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1587 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1584 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1588 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1585 ConfigureDialog->addModule(kabcfg ); 1589 ConfigureDialog->addModule(kabcfg );
1586 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1590 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1587 ConfigureDialog->addModule(kdelibcfg ); 1591 ConfigureDialog->addModule(kdelibcfg );
1588 1592
1589 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1593 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1590 this, SLOT( configurationChanged() ) ); 1594 this, SLOT( configurationChanged() ) );
1591 connect( ConfigureDialog, SIGNAL( okClicked() ), 1595 connect( ConfigureDialog, SIGNAL( okClicked() ),
1592 this, SLOT( configurationChanged() ) ); 1596 this, SLOT( configurationChanged() ) );
1593 saveSettings(); 1597 saveSettings();
1594#ifndef DESKTOP_VERSION 1598#ifndef DESKTOP_VERSION
1595 ConfigureDialog->showMaximized(); 1599 ConfigureDialog->showMaximized();
1596#endif 1600#endif
1597 if ( ConfigureDialog->exec() ) 1601 if ( ConfigureDialog->exec() )
1598 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1602 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1599 delete ConfigureDialog; 1603 delete ConfigureDialog;
1600} 1604}
1601 1605
1602void KABCore::openLDAPDialog() 1606void KABCore::openLDAPDialog()
1603{ 1607{
1604#ifndef KAB_EMBEDDED 1608#ifndef KAB_EMBEDDED
1605 if ( !mLdapSearchDialog ) { 1609 if ( !mLdapSearchDialog ) {
1606 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1610 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1607 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1611 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1608 SLOT( refreshView() ) ); 1612 SLOT( refreshView() ) );
1609 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1613 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1610 SLOT( setModified() ) ); 1614 SLOT( setModified() ) );
1611 } else 1615 } else
1612 mLdapSearchDialog->restoreSettings(); 1616 mLdapSearchDialog->restoreSettings();
1613 1617
1614 if ( mLdapSearchDialog->isOK() ) 1618 if ( mLdapSearchDialog->isOK() )
1615 mLdapSearchDialog->exec(); 1619 mLdapSearchDialog->exec();
1616#else //KAB_EMBEDDED 1620#else //KAB_EMBEDDED
1617 qDebug("KABCore::openLDAPDialog() finsih method"); 1621 qDebug("KABCore::openLDAPDialog() finsih method");
1618#endif //KAB_EMBEDDED 1622#endif //KAB_EMBEDDED
1619} 1623}
1620 1624
1621void KABCore::print() 1625void KABCore::print()
1622{ 1626{
1623#ifndef KAB_EMBEDDED 1627#ifndef KAB_EMBEDDED
1624 KPrinter printer; 1628 KPrinter printer;
1625 if ( !printer.setup( this ) ) 1629 if ( !printer.setup( this ) )
1626 return; 1630 return;
1627 1631
1628 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1632 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1629 mViewManager->selectedUids(), this ); 1633 mViewManager->selectedUids(), this );
1630 1634
1631 wizard.exec(); 1635 wizard.exec();
1632#else //KAB_EMBEDDED 1636#else //KAB_EMBEDDED
1633 qDebug("KABCore::print() finsih method"); 1637 qDebug("KABCore::print() finsih method");
1634#endif //KAB_EMBEDDED 1638#endif //KAB_EMBEDDED
1635 1639
1636} 1640}
1637 1641
1638 1642
1639void KABCore::addGUIClient( KXMLGUIClient *client ) 1643void KABCore::addGUIClient( KXMLGUIClient *client )
1640{ 1644{
1641 if ( mGUIClient ) 1645 if ( mGUIClient )
1642 mGUIClient->insertChildClient( client ); 1646 mGUIClient->insertChildClient( client );
1643 else 1647 else
1644 KMessageBox::error( this, "no KXMLGUICLient"); 1648 KMessageBox::error( this, "no KXMLGUICLient");
1645} 1649}
1646 1650
1647 1651
1648void KABCore::configurationChanged() 1652void KABCore::configurationChanged()
1649{ 1653{
1650 mExtensionManager->reconfigure(); 1654 mExtensionManager->reconfigure();
1651} 1655}
1652 1656
1653void KABCore::addressBookChanged() 1657void KABCore::addressBookChanged()
1654{ 1658{
1655/*US 1659/*US
1656 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1660 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1657 while ( it.current() ) { 1661 while ( it.current() ) {
1658 if ( it.current()->dirty() ) { 1662 if ( it.current()->dirty() ) {
1659 QString text = i18n( "Data has been changed externally. Unsaved " 1663 QString text = i18n( "Data has been changed externally. Unsaved "
1660 "changes will be lost." ); 1664 "changes will be lost." );
1661 KMessageBox::information( this, text ); 1665 KMessageBox::information( this, text );
1662 } 1666 }
1663 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1667 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1664 ++it; 1668 ++it;
1665 } 1669 }
1666*/ 1670*/
1667 if (mEditorDialog) 1671 if (mEditorDialog)
1668 { 1672 {
1669 if (mEditorDialog->dirty()) 1673 if (mEditorDialog->dirty())
1670 { 1674 {
1671 QString text = i18n( "Data has been changed externally. Unsaved " 1675 QString text = i18n( "Data has been changed externally. Unsaved "
1672 "changes will be lost." ); 1676 "changes will be lost." );
1673 KMessageBox::information( this, text ); 1677 KMessageBox::information( this, text );
1674 } 1678 }
1675 QString currentuid = mEditorDialog->addressee().uid(); 1679 QString currentuid = mEditorDialog->addressee().uid();
1676 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1680 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1677 } 1681 }
1678 mViewManager->refreshView(); 1682 mViewManager->refreshView();
1679 1683
1680 1684
1681} 1685}
1682 1686
1683AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1687AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1684 const char *name ) 1688 const char *name )
1685{ 1689{
1686 1690
1687 if ( mEditorDialog == 0 ) { 1691 if ( mEditorDialog == 0 ) {
1688 mEditorDialog = new AddresseeEditorDialog( this, parent, 1692 mEditorDialog = new AddresseeEditorDialog( this, parent,
1689 name ? name : "editorDialog" ); 1693 name ? name : "editorDialog" );
1690 1694
1691 1695
1692 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1696 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1693 SLOT( contactModified( const KABC::Addressee& ) ) ); 1697 SLOT( contactModified( const KABC::Addressee& ) ) );
1694 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1698 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1695 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1699 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1696 } 1700 }
1697 1701
1698 return mEditorDialog; 1702 return mEditorDialog;
1699} 1703}
1700 1704
1701void KABCore::slotEditorDestroyed( const QString &uid ) 1705void KABCore::slotEditorDestroyed( const QString &uid )
1702{ 1706{
1703 //mEditorDict.remove( uid ); 1707 //mEditorDict.remove( uid );
1704} 1708}
1705 1709
1706void KABCore::initGUI() 1710void KABCore::initGUI()
1707{ 1711{
1708#ifndef KAB_EMBEDDED 1712#ifndef KAB_EMBEDDED
1709 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1713 QHBoxLayout *topLayout = new QHBoxLayout( this );
1710 topLayout->setSpacing( KDialogBase::spacingHint() ); 1714 topLayout->setSpacing( KDialogBase::spacingHint() );
1711 1715
1712 mExtensionBarSplitter = new QSplitter( this ); 1716 mExtensionBarSplitter = new QSplitter( this );
1713 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1717 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1714 1718
1715 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1719 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1716 1720
1717 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1721 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1718 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1722 mIncSearchWidget = new IncSearchWidget( viewSpace );
1719 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1723 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1720 SLOT( incrementalSearch( const QString& ) ) ); 1724 SLOT( incrementalSearch( const QString& ) ) );
1721 1725
1722 mViewManager = new ViewManager( this, viewSpace ); 1726 mViewManager = new ViewManager( this, viewSpace );
1723 viewSpace->setStretchFactor( mViewManager, 1 ); 1727 viewSpace->setStretchFactor( mViewManager, 1 );
1724 1728
1725 mDetails = new ViewContainer( mDetailsSplitter ); 1729 mDetails = new ViewContainer( mDetailsSplitter );
1726 1730
1727 mJumpButtonBar = new JumpButtonBar( this, this ); 1731 mJumpButtonBar = new JumpButtonBar( this, this );
1728 1732
1729 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1733 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1730 1734
1731 topLayout->addWidget( mExtensionBarSplitter ); 1735 topLayout->addWidget( mExtensionBarSplitter );
1732 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1736 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1733 topLayout->addWidget( mJumpButtonBar ); 1737 topLayout->addWidget( mJumpButtonBar );
1734 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1738 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1735 1739
1736 mXXPortManager = new XXPortManager( this, this ); 1740 mXXPortManager = new XXPortManager( this, this );
1737 1741
1738#else //KAB_EMBEDDED 1742#else //KAB_EMBEDDED
1739 //US initialize viewMenu before settingup viewmanager. 1743 //US initialize viewMenu before settingup viewmanager.
1740 // Viewmanager needs this menu to plugin submenues. 1744 // Viewmanager needs this menu to plugin submenues.
1741 viewMenu = new QPopupMenu( this ); 1745 viewMenu = new QPopupMenu( this );
1742 settingsMenu = new QPopupMenu( this ); 1746 settingsMenu = new QPopupMenu( this );
1743 //filterMenu = new QPopupMenu( this ); 1747 //filterMenu = new QPopupMenu( this );
1744 ImportMenu = new QPopupMenu( this ); 1748 ImportMenu = new QPopupMenu( this );
1745 ExportMenu = new QPopupMenu( this ); 1749 ExportMenu = new QPopupMenu( this );
1746 syncMenu = new QPopupMenu( this ); 1750 syncMenu = new QPopupMenu( this );
1747 changeMenu= new QPopupMenu( this ); 1751 changeMenu= new QPopupMenu( this );
1748 beamMenu= new QPopupMenu( this ); 1752 beamMenu= new QPopupMenu( this );
1749 1753
1750//US since we have no splitter for the embedded system, setup 1754//US since we have no splitter for the embedded system, setup
1751// a layout with two frames. One left and one right. 1755// a layout with two frames. One left and one right.
1752 1756
1753 QBoxLayout *topLayout; 1757 QBoxLayout *topLayout;
1754 1758
1755 // = new QHBoxLayout( this ); 1759 // = new QHBoxLayout( this );
1756// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1760// QBoxLayout *topLayout = (QBoxLayout*)layout();
1757 1761
1758// QWidget *mainBox = new QWidget( this ); 1762// QWidget *mainBox = new QWidget( this );
1759// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1763// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1760 1764
1761#ifdef DESKTOP_VERSION 1765#ifdef DESKTOP_VERSION
1762 topLayout = new QHBoxLayout( this ); 1766 topLayout = new QHBoxLayout( this );
1763 1767
1764 1768
1765 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1769 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1766 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1770 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1767 1771
1768 topLayout->addWidget(mMiniSplitter ); 1772 topLayout->addWidget(mMiniSplitter );
1769 1773
1770 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1774 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1771 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1775 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1772 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1776 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1773 mDetails = new ViewContainer( mMiniSplitter ); 1777 mDetails = new ViewContainer( mMiniSplitter );
1774 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1778 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1775#else 1779#else
1776 if ( QApplication::desktop()->width() > 480 ) { 1780 if ( QApplication::desktop()->width() > 480 ) {
1777 topLayout = new QHBoxLayout( this ); 1781 topLayout = new QHBoxLayout( this );
1778 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1782 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1779 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1783 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1780 } else { 1784 } else {
1781 1785
1782 topLayout = new QHBoxLayout( this ); 1786 topLayout = new QHBoxLayout( this );
1783 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1787 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1784 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1788 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1785 } 1789 }
1786 1790
1787 topLayout->addWidget(mMiniSplitter ); 1791 topLayout->addWidget(mMiniSplitter );
1788 mViewManager = new ViewManager( this, mMiniSplitter ); 1792 mViewManager = new ViewManager( this, mMiniSplitter );
1789 mDetails = new ViewContainer( mMiniSplitter ); 1793 mDetails = new ViewContainer( mMiniSplitter );
1790 1794
1791 1795
1792 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1796 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1793#endif 1797#endif
1794 //eh->hide(); 1798 //eh->hide();
1795 // topLayout->addWidget(mExtensionManager ); 1799 // topLayout->addWidget(mExtensionManager );
1796 1800
1797 1801
1798/*US 1802/*US
1799#ifndef KAB_NOSPLITTER 1803#ifndef KAB_NOSPLITTER
1800 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1804 QHBoxLayout *topLayout = new QHBoxLayout( this );
1801//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1805//US topLayout->setSpacing( KDialogBase::spacingHint() );
1802 topLayout->setSpacing( 10 ); 1806 topLayout->setSpacing( 10 );
1803 1807
1804 mDetailsSplitter = new QSplitter( this ); 1808 mDetailsSplitter = new QSplitter( this );
1805 1809
1806 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1810 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1807 1811
1808 mViewManager = new ViewManager( this, viewSpace ); 1812 mViewManager = new ViewManager( this, viewSpace );
1809 viewSpace->setStretchFactor( mViewManager, 1 ); 1813 viewSpace->setStretchFactor( mViewManager, 1 );
1810 1814
1811 mDetails = new ViewContainer( mDetailsSplitter ); 1815 mDetails = new ViewContainer( mDetailsSplitter );
1812 1816
1813 topLayout->addWidget( mDetailsSplitter ); 1817 topLayout->addWidget( mDetailsSplitter );
1814 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1818 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1815#else //KAB_NOSPLITTER 1819#else //KAB_NOSPLITTER
1816 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1820 QHBoxLayout *topLayout = new QHBoxLayout( this );
1817//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1821//US topLayout->setSpacing( KDialogBase::spacingHint() );
1818 topLayout->setSpacing( 10 ); 1822 topLayout->setSpacing( 10 );
1819 1823
1820// mDetailsSplitter = new QSplitter( this ); 1824// mDetailsSplitter = new QSplitter( this );
1821 1825
1822 QVBox *viewSpace = new QVBox( this ); 1826 QVBox *viewSpace = new QVBox( this );
1823 1827
1824 mViewManager = new ViewManager( this, viewSpace ); 1828 mViewManager = new ViewManager( this, viewSpace );
1825 viewSpace->setStretchFactor( mViewManager, 1 ); 1829 viewSpace->setStretchFactor( mViewManager, 1 );
1826 1830
1827 mDetails = new ViewContainer( this ); 1831 mDetails = new ViewContainer( this );
1828 1832
1829 topLayout->addWidget( viewSpace ); 1833 topLayout->addWidget( viewSpace );
1830// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1834// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1831 topLayout->addWidget( mDetails ); 1835 topLayout->addWidget( mDetails );
1832#endif //KAB_NOSPLITTER 1836#endif //KAB_NOSPLITTER
1833*/ 1837*/
1834 1838
1835 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1839 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1836 syncManager->setBlockSave(false); 1840 syncManager->setBlockSave(false);
1837 1841
1838 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1842 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1839 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1843 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1840 QString sync_file = sentSyncFile(); 1844 QString sync_file = sentSyncFile();
1841 qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); 1845 qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1());
1842 syncManager->setDefaultFileName( sync_file ); 1846 syncManager->setDefaultFileName( sync_file );
1843 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1847 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1844 1848
1845#endif //KAB_EMBEDDED 1849#endif //KAB_EMBEDDED
1846 initActions(); 1850 initActions();
1847 1851
1848#ifdef KAB_EMBEDDED 1852#ifdef KAB_EMBEDDED
1849 addActionsManually(); 1853 addActionsManually();
1850 //US make sure the export and import menues are initialized before creating the xxPortManager. 1854 //US make sure the export and import menues are initialized before creating the xxPortManager.
1851 mXXPortManager = new XXPortManager( this, this ); 1855 mXXPortManager = new XXPortManager( this, this );
1852 1856
1853 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1857 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1854 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1858 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1855 // mActionQuit->plug ( mMainWindow->toolBar()); 1859 // mActionQuit->plug ( mMainWindow->toolBar());
1856 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1860 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1857 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1861 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1858 // mIncSearchWidget->hide(); 1862 // mIncSearchWidget->hide();
1859 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1863 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1860 SLOT( incrementalSearch( const QString& ) ) ); 1864 SLOT( incrementalSearch( const QString& ) ) );
1861 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1865 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1862 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1866 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1863 1867
1864 mJumpButtonBar = new JumpButtonBar( this, this ); 1868 mJumpButtonBar = new JumpButtonBar( this, this );
1865 1869
1866 topLayout->addWidget( mJumpButtonBar ); 1870 topLayout->addWidget( mJumpButtonBar );
1867//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1871//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1868 1872
1869// mMainWindow->getIconToolBar()->raise(); 1873// mMainWindow->getIconToolBar()->raise();
1870 1874
1871#endif //KAB_EMBEDDED 1875#endif //KAB_EMBEDDED
1872 1876
1873} 1877}
1874void KABCore::initActions() 1878void KABCore::initActions()
1875{ 1879{
1876//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1880//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1877 1881
1878#ifndef KAB_EMBEDDED 1882#ifndef KAB_EMBEDDED
1879 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1883 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1880 SLOT( clipboardDataChanged() ) ); 1884 SLOT( clipboardDataChanged() ) );
1881#endif //KAB_EMBEDDED 1885#endif //KAB_EMBEDDED
1882 1886
1883 // file menu 1887 // file menu
1884 1888
1885 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1889 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1886 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1890 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1887 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, 1891 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager,
1888 SLOT( printView() ), actionCollection(), "kaddressbook_print" ); 1892 SLOT( printView() ), actionCollection(), "kaddressbook_print" );
1889 1893
1890 1894
1891 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, 1895 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails,
1892 SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); 1896 SLOT( printView() ), actionCollection(), "kaddressbook_print2" );
1893 1897
1894 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1898 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1895 SLOT( save() ), actionCollection(), "file_sync" ); 1899 SLOT( save() ), actionCollection(), "file_sync" );
1896 1900
1897 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1901 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1898 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1902 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1899 1903
1900 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1904 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1901 this, SLOT( mailVCard() ), 1905 this, SLOT( mailVCard() ),
1902 actionCollection(), "file_mail_vcard"); 1906 actionCollection(), "file_mail_vcard");
1903 1907
1904 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, 1908 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this,
1905 SLOT( export2phone() ), actionCollection(), 1909 SLOT( export2phone() ), actionCollection(),
1906 "kaddressbook_ex2phone" ); 1910 "kaddressbook_ex2phone" );
1907 1911
1908 mActionBeamVCard = 0; 1912 mActionBeamVCard = 0;
1909 mActionBeam = 0; 1913 mActionBeam = 0;
1910 1914
1911#ifndef DESKTOP_VERSION 1915#ifndef DESKTOP_VERSION
1912 if ( Ir::supported() ) { 1916 if ( Ir::supported() ) {
1913 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, 1917 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this,
1914 SLOT( beamVCard() ), actionCollection(), 1918 SLOT( beamVCard() ), actionCollection(),
1915 "kaddressbook_beam_vcard" ); 1919 "kaddressbook_beam_vcard" );
1916 1920
1917 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1921 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1918 SLOT( beamMySelf() ), actionCollection(), 1922 SLOT( beamMySelf() ), actionCollection(),
1919 "kaddressbook_beam_myself" ); 1923 "kaddressbook_beam_myself" );
1920 } 1924 }
1921#endif 1925#endif
1922 1926
1923 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1927 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1924 this, SLOT( editContact2() ), 1928 this, SLOT( editContact2() ),
1925 actionCollection(), "file_properties" ); 1929 actionCollection(), "file_properties" );
1926 1930
1927#ifdef KAB_EMBEDDED 1931#ifdef KAB_EMBEDDED
1928 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1932 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1929 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1933 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1930 mMainWindow, SLOT( exit() ), 1934 mMainWindow, SLOT( exit() ),
1931 actionCollection(), "quit" ); 1935 actionCollection(), "quit" );
1932#endif //KAB_EMBEDDED 1936#endif //KAB_EMBEDDED
1933 1937
1934 // edit menu 1938 // edit menu
1935 if ( mIsPart ) { 1939 if ( mIsPart ) {
1936 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1940 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1937 SLOT( copyContacts() ), actionCollection(), 1941 SLOT( copyContacts() ), actionCollection(),
1938 "kaddressbook_copy" ); 1942 "kaddressbook_copy" );
1939 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1943 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1940 SLOT( cutContacts() ), actionCollection(), 1944 SLOT( cutContacts() ), actionCollection(),
1941 "kaddressbook_cut" ); 1945 "kaddressbook_cut" );
1942 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1946 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1943 SLOT( pasteContacts() ), actionCollection(), 1947 SLOT( pasteContacts() ), actionCollection(),
1944 "kaddressbook_paste" ); 1948 "kaddressbook_paste" );
1945 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1949 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1946 SLOT( selectAllContacts() ), actionCollection(), 1950 SLOT( selectAllContacts() ), actionCollection(),
1947 "kaddressbook_select_all" ); 1951 "kaddressbook_select_all" );
1948 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1952 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1949 SLOT( undo() ), actionCollection(), 1953 SLOT( undo() ), actionCollection(),
1950 "kaddressbook_undo" ); 1954 "kaddressbook_undo" );
1951 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1955 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1952 this, SLOT( redo() ), actionCollection(), 1956 this, SLOT( redo() ), actionCollection(),
1953 "kaddressbook_redo" ); 1957 "kaddressbook_redo" );
1954 } else { 1958 } else {
1955 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1959 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1956 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1960 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1957 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1961 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1958 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1962 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1959 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1963 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1960 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1964 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1961 } 1965 }
1962 1966
1963 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1967 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1964 Key_Delete, this, SLOT( deleteContacts() ), 1968 Key_Delete, this, SLOT( deleteContacts() ),
1965 actionCollection(), "edit_delete" ); 1969 actionCollection(), "edit_delete" );
1966 1970
1967 mActionUndo->setEnabled( false ); 1971 mActionUndo->setEnabled( false );
1968 mActionRedo->setEnabled( false ); 1972 mActionRedo->setEnabled( false );
1969 1973
1970 // settings menu 1974 // settings menu
1971#ifdef KAB_EMBEDDED 1975#ifdef KAB_EMBEDDED
1972//US special menuentry to configure the addressbook resources. On KDE 1976//US special menuentry to configure the addressbook resources. On KDE
1973// you do that through the control center !!! 1977// you do that through the control center !!!
1974 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1978 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1975 SLOT( configureResources() ), actionCollection(), 1979 SLOT( configureResources() ), actionCollection(),
1976 "kaddressbook_configure_resources" ); 1980 "kaddressbook_configure_resources" );
1977#endif //KAB_EMBEDDED 1981#endif //KAB_EMBEDDED
1978 1982
1979 if ( mIsPart ) { 1983 if ( mIsPart ) {
1980 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1984 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1981 SLOT( openConfigDialog() ), actionCollection(), 1985 SLOT( openConfigDialog() ), actionCollection(),
1982 "kaddressbook_configure" ); 1986 "kaddressbook_configure" );
1983 1987
1984 //US not implemented yet 1988 //US not implemented yet
1985 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1989 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1986 // this, SLOT( configureKeyBindings() ), actionCollection(), 1990 // this, SLOT( configureKeyBindings() ), actionCollection(),
1987 // "kaddressbook_configure_shortcuts" ); 1991 // "kaddressbook_configure_shortcuts" );
1988#ifdef KAB_EMBEDDED 1992#ifdef KAB_EMBEDDED
1989 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1993 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1990 mActionConfigureToolbars->setEnabled( false ); 1994 mActionConfigureToolbars->setEnabled( false );
1991#endif //KAB_EMBEDDED 1995#endif //KAB_EMBEDDED
1992 1996
1993 } else { 1997 } else {
1994 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1998 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1995 1999
1996 //US not implemented yet 2000 //US not implemented yet
1997 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 2001 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1998 } 2002 }
1999 2003
2000 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 2004 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
2001 actionCollection(), "options_show_jump_bar" ); 2005 actionCollection(), "options_show_jump_bar" );
2002 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 2006 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
2003 2007
2004 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 2008 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
2005 actionCollection(), "options_show_details" ); 2009 actionCollection(), "options_show_details" );
2006 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 2010 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
2007 2011
2008 2012
2009 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 2013 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
2010 SLOT( toggleBeamReceive() ), actionCollection(), 2014 SLOT( toggleBeamReceive() ), actionCollection(),
2011 "kaddressbook_beam_rec" ); 2015 "kaddressbook_beam_rec" );
2012 2016
2013 2017
2014 // misc 2018 // misc
2015 // only enable LDAP lookup if we can handle the protocol 2019 // only enable LDAP lookup if we can handle the protocol
2016#ifndef KAB_EMBEDDED 2020#ifndef KAB_EMBEDDED
2017 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 2021 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
2018 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 2022 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
2019 this, SLOT( openLDAPDialog() ), actionCollection(), 2023 this, SLOT( openLDAPDialog() ), actionCollection(),
2020 "ldap_lookup" ); 2024 "ldap_lookup" );
2021 } 2025 }
2022#else //KAB_EMBEDDED 2026#else //KAB_EMBEDDED
2023 //qDebug("KABCore::initActions() LDAP has to be implemented"); 2027 //qDebug("KABCore::initActions() LDAP has to be implemented");
2024#endif //KAB_EMBEDDED 2028#endif //KAB_EMBEDDED
2025 2029
2026 2030
2027 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 2031 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
2028 SLOT( setWhoAmI() ), actionCollection(), 2032 SLOT( setWhoAmI() ), actionCollection(),
2029 "set_personal" ); 2033 "set_personal" );
2030 2034
2031 2035
2032 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 2036 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
2033 SLOT( setCategories() ), actionCollection(), 2037 SLOT( setCategories() ), actionCollection(),
2034 "edit_set_categories" ); 2038 "edit_set_categories" );
2035 mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, 2039 mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this,
2036 SLOT( editCategories() ), actionCollection(), 2040 SLOT( editCategories() ), actionCollection(),
2037 "edit__categories" ); 2041 "edit__categories" );
2038 2042
2039 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 2043 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
2040 SLOT( removeVoice() ), actionCollection(), 2044 SLOT( removeVoice() ), actionCollection(),
2041 "remove_voice" ); 2045 "remove_voice" );
2042 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, 2046 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this,
2043 SLOT( setFormattedName() ), actionCollection(), 2047 SLOT( setFormattedName() ), actionCollection(),
2044 "set_formatted" ); 2048 "set_formatted" );
2045 2049
2046 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, 2050 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this,
2047 SLOT( manageCategories() ), actionCollection(), 2051 SLOT( manageCategories() ), actionCollection(),
2048 "remove_voice" ); 2052 "remove_voice" );
2049 2053
2050 2054
2051 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 2055 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
2052 SLOT( importFromOL() ), actionCollection(), 2056 SLOT( importFromOL() ), actionCollection(),
2053 "import_OL" ); 2057 "import_OL" );
2054#ifdef KAB_EMBEDDED 2058#ifdef KAB_EMBEDDED
2055 mActionLicence = new KAction( i18n( "Licence" ), 0, 2059 mActionLicence = new KAction( i18n( "Licence" ), 0,
2056 this, SLOT( showLicence() ), actionCollection(), 2060 this, SLOT( showLicence() ), actionCollection(),
2057 "licence_about_data" ); 2061 "licence_about_data" );
2058 mActionFaq = new KAction( i18n( "Faq" ), 0, 2062 mActionFaq = new KAction( i18n( "Faq" ), 0,
2059 this, SLOT( faq() ), actionCollection(), 2063 this, SLOT( faq() ), actionCollection(),
2060 "faq_about_data" ); 2064 "faq_about_data" );
2061 mActionWN = new KAction( i18n( "What's New?" ), 0, 2065 mActionWN = new KAction( i18n( "What's New?" ), 0,
2062 this, SLOT( whatsnew() ), actionCollection(), 2066 this, SLOT( whatsnew() ), actionCollection(),
2063 "wn" ); 2067 "wn" );
2064 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 2068 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
2065 this, SLOT( synchowto() ), actionCollection(), 2069 this, SLOT( synchowto() ), actionCollection(),
2066 "sync" ); 2070 "sync" );
2067 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, 2071 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0,
2068 this, SLOT( kdesynchowto() ), actionCollection(), 2072 this, SLOT( kdesynchowto() ), actionCollection(),
2069 "kdesync" ); 2073 "kdesync" );
2070 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, 2074 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0,
2071 this, SLOT( multisynchowto() ), actionCollection(), 2075 this, SLOT( multisynchowto() ), actionCollection(),
2072 "multisync" ); 2076 "multisync" );
2073 2077
2074 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 2078 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
2075 this, SLOT( createAboutData() ), actionCollection(), 2079 this, SLOT( createAboutData() ), actionCollection(),
2076 "kaddressbook_about_data" ); 2080 "kaddressbook_about_data" );
2077#endif //KAB_EMBEDDED 2081#endif //KAB_EMBEDDED
2078 2082
2079 clipboardDataChanged(); 2083 clipboardDataChanged();
2080 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2084 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2081 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2085 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2082} 2086}
2083 2087
2084//US we need this function, to plug all actions into the correct menues. 2088//US we need this function, to plug all actions into the correct menues.
2085// KDE uses a XML format to plug the actions, but we work her without this overhead. 2089// KDE uses a XML format to plug the actions, but we work her without this overhead.
2086void KABCore::addActionsManually() 2090void KABCore::addActionsManually()
2087{ 2091{
2088//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 2092//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
2089 2093
2090#ifdef KAB_EMBEDDED 2094#ifdef KAB_EMBEDDED
2091 QPopupMenu *fileMenu = new QPopupMenu( this ); 2095 QPopupMenu *fileMenu = new QPopupMenu( this );
2092 QPopupMenu *editMenu = new QPopupMenu( this ); 2096 QPopupMenu *editMenu = new QPopupMenu( this );
2093 QPopupMenu *helpMenu = new QPopupMenu( this ); 2097 QPopupMenu *helpMenu = new QPopupMenu( this );
2094 2098
2095 KToolBar* tb = mMainWindow->toolBar(); 2099 KToolBar* tb = mMainWindow->toolBar();
2096 2100
2097#ifndef DESKTOP_VERSION 2101#ifndef DESKTOP_VERSION
2098 if ( KABPrefs::instance()->mFullMenuBarVisible ) { 2102 if ( KABPrefs::instance()->mFullMenuBarVisible ) {
2099#endif 2103#endif
2100 QMenuBar* mb = mMainWindow->menuBar(); 2104 QMenuBar* mb = mMainWindow->menuBar();
2101 2105
2102 //US setup menubar. 2106 //US setup menubar.
2103 //Disable the following block if you do not want to have a menubar. 2107 //Disable the following block if you do not want to have a menubar.
2104 mb->insertItem( i18n("&File"), fileMenu ); 2108 mb->insertItem( i18n("&File"), fileMenu );
2105 mb->insertItem( i18n("&Edit"), editMenu ); 2109 mb->insertItem( i18n("&Edit"), editMenu );
2106 mb->insertItem( i18n("&View"), viewMenu ); 2110 mb->insertItem( i18n("&View"), viewMenu );
2107 mb->insertItem( i18n("&Settings"), settingsMenu ); 2111 mb->insertItem( i18n("&Settings"), settingsMenu );
2108 mb->insertItem( i18n("Synchronize"), syncMenu ); 2112 mb->insertItem( i18n("Synchronize"), syncMenu );
2109 //mb->insertItem( i18n("&Change"), changeMenu ); 2113 //mb->insertItem( i18n("&Change"), changeMenu );
2110 mb->insertItem( i18n("&Help"), helpMenu ); 2114 mb->insertItem( i18n("&Help"), helpMenu );
2111 mIncSearchWidget = new IncSearchWidget( tb ); 2115 mIncSearchWidget = new IncSearchWidget( tb );
2112 // tb->insertWidget(-1, 0, mIncSearchWidget); 2116 // tb->insertWidget(-1, 0, mIncSearchWidget);
2113#ifndef DESKTOP_VERSION 2117#ifndef DESKTOP_VERSION
2114 } else { 2118 } else {
2115 //US setup toolbar 2119 //US setup toolbar
2116 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 2120 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
2117 QPopupMenu *popupBarTB = new QPopupMenu( this ); 2121 QPopupMenu *popupBarTB = new QPopupMenu( this );
2118 menuBarTB->insertItem( "ME", popupBarTB); 2122 menuBarTB->insertItem( "ME", popupBarTB);
2119 tb->insertWidget(-1, 0, menuBarTB); 2123 tb->insertWidget(-1, 0, menuBarTB);
2120 mIncSearchWidget = new IncSearchWidget( tb ); 2124 mIncSearchWidget = new IncSearchWidget( tb );
2121 2125
2122 tb->enableMoving(false); 2126 tb->enableMoving(false);
2123 popupBarTB->insertItem( i18n("&File"), fileMenu ); 2127 popupBarTB->insertItem( i18n("&File"), fileMenu );
2124 popupBarTB->insertItem( i18n("&Edit"), editMenu ); 2128 popupBarTB->insertItem( i18n("&Edit"), editMenu );
2125 popupBarTB->insertItem( i18n("&View"), viewMenu ); 2129 popupBarTB->insertItem( i18n("&View"), viewMenu );
2126 popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); 2130 popupBarTB->insertItem( i18n("&Settings"), settingsMenu );
2127 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 2131 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
2128 mViewManager->getFilterAction()->plug ( popupBarTB); 2132 mViewManager->getFilterAction()->plug ( popupBarTB);
2129 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); 2133 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu );
2130 popupBarTB->insertItem( i18n("&Help"), helpMenu ); 2134 popupBarTB->insertItem( i18n("&Help"), helpMenu );
2131 if (QApplication::desktop()->width() > 320 ) { 2135 if (QApplication::desktop()->width() > 320 ) {
2132 // mViewManager->getFilterAction()->plug ( tb); 2136 // mViewManager->getFilterAction()->plug ( tb);
2133 } 2137 }
2134 } 2138 }
2135#endif 2139#endif
2136 // mActionQuit->plug ( mMainWindow->toolBar()); 2140 // mActionQuit->plug ( mMainWindow->toolBar());
2137 2141
2138 2142
2139 2143
2140 //US Now connect the actions with the menue entries. 2144 //US Now connect the actions with the menue entries.
2141#ifdef DESKTOP_VERSION 2145#ifdef DESKTOP_VERSION
2142 mActionPrint->plug( fileMenu ); 2146 mActionPrint->plug( fileMenu );
2143 mActionPrintDetails->plug( fileMenu ); 2147 mActionPrintDetails->plug( fileMenu );
2144 fileMenu->insertSeparator(); 2148 fileMenu->insertSeparator();
2145#endif 2149#endif
2146 mActionMail->plug( fileMenu ); 2150 mActionMail->plug( fileMenu );
2147 fileMenu->insertSeparator(); 2151 fileMenu->insertSeparator();
2148 2152
2149 mActionNewContact->plug( fileMenu ); 2153 mActionNewContact->plug( fileMenu );
2150 mActionNewContact->plug( tb ); 2154 mActionNewContact->plug( tb );
2151 2155
2152 mActionEditAddressee->plug( fileMenu ); 2156 mActionEditAddressee->plug( fileMenu );
2153 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 2157 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
2154 // (!KABPrefs::instance()->mMultipleViewsAtOnce )) 2158 // (!KABPrefs::instance()->mMultipleViewsAtOnce ))
2155 mActionEditAddressee->plug( tb ); 2159 mActionEditAddressee->plug( tb );
2156 2160
2157 fileMenu->insertSeparator(); 2161 fileMenu->insertSeparator();
2158 mActionSave->plug( fileMenu ); 2162 mActionSave->plug( fileMenu );
2159 fileMenu->insertItem( "&Import", ImportMenu ); 2163 fileMenu->insertItem( "&Import", ImportMenu );
2160 fileMenu->insertItem( "&Export", ExportMenu ); 2164 fileMenu->insertItem( "&Export", ExportMenu );
2161 fileMenu->insertItem( i18n("&Change"), changeMenu ); 2165 fileMenu->insertItem( i18n("&Change"), changeMenu );
2162#ifndef DESKTOP_VERSION 2166#ifndef DESKTOP_VERSION
2163 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); 2167 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu );
2164#endif 2168#endif
2165#if 0 2169#if 0
2166 // PENDING fix MailVCard 2170 // PENDING fix MailVCard
2167 fileMenu->insertSeparator(); 2171 fileMenu->insertSeparator();
2168 mActionMailVCard->plug( fileMenu ); 2172 mActionMailVCard->plug( fileMenu );
2169#endif 2173#endif
2170#ifndef DESKTOP_VERSION 2174#ifndef DESKTOP_VERSION
2171 if ( Ir::supported() ) mActionBR->plug( beamMenu ); 2175 if ( Ir::supported() ) mActionBR->plug( beamMenu );
2172 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); 2176 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu );
2173 if ( Ir::supported() ) mActionBeam->plug( beamMenu ); 2177 if ( Ir::supported() ) mActionBeam->plug( beamMenu );
2174#endif 2178#endif
2175 fileMenu->insertSeparator(); 2179 fileMenu->insertSeparator();
2176 mActionQuit->plug( fileMenu ); 2180 mActionQuit->plug( fileMenu );
2177#ifdef _WIN32_ 2181#ifdef _WIN32_
2178 mActionImportOL->plug( ImportMenu ); 2182 mActionImportOL->plug( ImportMenu );
2179#endif 2183#endif
2180 // edit menu 2184 // edit menu
2181 mActionUndo->plug( editMenu ); 2185 mActionUndo->plug( editMenu );
2182 mActionRedo->plug( editMenu ); 2186 mActionRedo->plug( editMenu );
2183 editMenu->insertSeparator(); 2187 editMenu->insertSeparator();
2184 mActionCut->plug( editMenu ); 2188 mActionCut->plug( editMenu );
2185 mActionCopy->plug( editMenu ); 2189 mActionCopy->plug( editMenu );
2186 mActionPaste->plug( editMenu ); 2190 mActionPaste->plug( editMenu );
2187 mActionDelete->plug( editMenu ); 2191 mActionDelete->plug( editMenu );
2188 editMenu->insertSeparator(); 2192 editMenu->insertSeparator();
2189 mActionSelectAll->plug( editMenu ); 2193 mActionSelectAll->plug( editMenu );
2190 2194
2191 mActionSetFormattedName->plug( changeMenu ); 2195 mActionSetFormattedName->plug( changeMenu );
2192 mActionRemoveVoice->plug( changeMenu ); 2196 mActionRemoveVoice->plug( changeMenu );
2193 // settings menu 2197 // settings menu
2194//US special menuentry to configure the addressbook resources. On KDE 2198//US special menuentry to configure the addressbook resources. On KDE
2195// you do that through the control center !!! 2199// you do that through the control center !!!
2196 mActionConfigResources->plug( settingsMenu ); 2200 mActionConfigResources->plug( settingsMenu );
2197 settingsMenu->insertSeparator(); 2201 settingsMenu->insertSeparator();
2198 2202
2199 mActionConfigKAddressbook->plug( settingsMenu ); 2203 mActionConfigKAddressbook->plug( settingsMenu );
2200 2204
2201 if ( mIsPart ) { 2205 if ( mIsPart ) {
2202 //US not implemented yet 2206 //US not implemented yet
2203 //mActionConfigShortcuts->plug( settingsMenu ); 2207 //mActionConfigShortcuts->plug( settingsMenu );
2204 //mActionConfigureToolbars->plug( settingsMenu ); 2208 //mActionConfigureToolbars->plug( settingsMenu );
2205 2209
2206 } else { 2210 } else {
2207 //US not implemented yet 2211 //US not implemented yet
2208 //mActionKeyBindings->plug( settingsMenu ); 2212 //mActionKeyBindings->plug( settingsMenu );
2209 } 2213 }
2210 2214
2211 settingsMenu->insertSeparator(); 2215 settingsMenu->insertSeparator();
2212 2216
2213 mActionJumpBar->plug( settingsMenu ); 2217 mActionJumpBar->plug( settingsMenu );
2214 mActionDetails->plug( settingsMenu ); 2218 mActionDetails->plug( settingsMenu );
2215 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2219 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2216 mActionDetails->plug( tb ); 2220 mActionDetails->plug( tb );
2217 settingsMenu->insertSeparator(); 2221 settingsMenu->insertSeparator();
2218#ifndef DESKTOP_VERSION 2222#ifndef DESKTOP_VERSION
2219 if ( Ir::supported() ) mActionBR->plug(settingsMenu ); 2223 if ( Ir::supported() ) mActionBR->plug(settingsMenu );
2220#endif 2224#endif
2221 settingsMenu->insertSeparator(); 2225 settingsMenu->insertSeparator();
2222 2226
2223 mActionWhoAmI->plug( settingsMenu ); 2227 mActionWhoAmI->plug( settingsMenu );
2224 mActionEditCategories->plug( settingsMenu ); 2228 mActionEditCategories->plug( settingsMenu );
2225 mActionEditCategories->plug( changeMenu ); 2229 mActionEditCategories->plug( changeMenu );
2226 mActionCategories->plug( changeMenu ); 2230 mActionCategories->plug( changeMenu );
2227 mActionManageCategories->plug( changeMenu ); 2231 mActionManageCategories->plug( changeMenu );
2228 2232
2229 mActionCategories->plug( settingsMenu ); 2233 mActionCategories->plug( settingsMenu );
2230 mActionManageCategories->plug( settingsMenu ); 2234 mActionManageCategories->plug( settingsMenu );
2231 2235
2232 2236
2233 mActionWN->plug( helpMenu ); 2237 mActionWN->plug( helpMenu );
2234 mActionSyncHowto->plug( helpMenu ); 2238 mActionSyncHowto->plug( helpMenu );
2235 mActionKdeSyncHowto->plug( helpMenu ); 2239 mActionKdeSyncHowto->plug( helpMenu );
2236 mActionMultiSyncHowto->plug( helpMenu ); 2240 mActionMultiSyncHowto->plug( helpMenu );
2237 mActionFaq->plug( helpMenu ); 2241 mActionFaq->plug( helpMenu );
2238 mActionLicence->plug( helpMenu ); 2242 mActionLicence->plug( helpMenu );
2239 mActionAboutKAddressbook->plug( helpMenu ); 2243 mActionAboutKAddressbook->plug( helpMenu );
2240 2244
2241 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2245 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2242 2246
2243 mActionSave->plug( tb ); 2247 mActionSave->plug( tb );
2244 mViewManager->getFilterAction()->plug ( tb); 2248 mViewManager->getFilterAction()->plug ( tb);
2245 //LR hide filteraction on started in 480x640 2249 //LR hide filteraction on started in 480x640
2246 if (QApplication::desktop()->width() == 480 ) { 2250 if (QApplication::desktop()->width() == 480 ) {
2247 mViewManager->getFilterAction()->setComboWidth( 0 ); 2251 mViewManager->getFilterAction()->setComboWidth( 0 );
2248 } 2252 }
2249 mActionUndo->plug( tb ); 2253 mActionUndo->plug( tb );
2250 mActionDelete->plug( tb ); 2254 mActionDelete->plug( tb );
2251 mActionRedo->plug( tb ); 2255 mActionRedo->plug( tb );
2252 } else { 2256 } else {
2253 mActionSave->plug( tb ); 2257 mActionSave->plug( tb );
2254 tb->enableMoving(false); 2258 tb->enableMoving(false);
2255 } 2259 }
2256 //mActionQuit->plug ( tb ); 2260 //mActionQuit->plug ( tb );
2257 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2261 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2258 2262
2259 //US link the searchwidget first to this. 2263 //US link the searchwidget first to this.
2260 // The real linkage to the toolbar happens later. 2264 // The real linkage to the toolbar happens later.
2261//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2265//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2262//US tb->insertItem( mIncSearchWidget ); 2266//US tb->insertItem( mIncSearchWidget );
2263/*US 2267/*US
2264 mIncSearchWidget = new IncSearchWidget( tb ); 2268 mIncSearchWidget = new IncSearchWidget( tb );
2265 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2269 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2266 SLOT( incrementalSearch( const QString& ) ) ); 2270 SLOT( incrementalSearch( const QString& ) ) );
2267 2271
2268 mJumpButtonBar = new JumpButtonBar( this, this ); 2272 mJumpButtonBar = new JumpButtonBar( this, this );
2269 2273
2270//US topLayout->addWidget( mJumpButtonBar ); 2274//US topLayout->addWidget( mJumpButtonBar );
2271 this->layout()->add( mJumpButtonBar ); 2275 this->layout()->add( mJumpButtonBar );
2272*/ 2276*/
2273 2277
2274#endif //KAB_EMBEDDED 2278#endif //KAB_EMBEDDED
2275 2279
2276 mActionExport2phone->plug( ExportMenu ); 2280 mActionExport2phone->plug( ExportMenu );
2277 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2281 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2278 syncManager->fillSyncMenu(); 2282 syncManager->fillSyncMenu();
2279 2283
2280} 2284}
2281void KABCore::showLicence() 2285void KABCore::showLicence()
2282{ 2286{
2283 KApplication::showLicence(); 2287 KApplication::showLicence();
2284} 2288}
2285 2289
2286void KABCore::manageCategories( ) 2290void KABCore::manageCategories( )
2287{ 2291{
2288 KABCatPrefs* cp = new KABCatPrefs(); 2292 KABCatPrefs* cp = new KABCatPrefs();
2289 cp->show(); 2293 cp->show();
2290 int w =cp->sizeHint().width() ; 2294 int w =cp->sizeHint().width() ;
2291 int h = cp->sizeHint().height() ; 2295 int h = cp->sizeHint().height() ;
2292 int dw = QApplication::desktop()->width(); 2296 int dw = QApplication::desktop()->width();
2293 int dh = QApplication::desktop()->height(); 2297 int dh = QApplication::desktop()->height();
2294 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2298 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2295 if ( !cp->exec() ) { 2299 if ( !cp->exec() ) {
2296 delete cp; 2300 delete cp;
2297 return; 2301 return;
2298 } 2302 }
2299 int count = 0; 2303 int count = 0;
2300 int cc = 0; 2304 int cc = 0;
2301 message( i18n("Please wait, processing categories...")); 2305 message( i18n("Please wait, processing categories..."));
2302 if ( cp->addCat() ) { 2306 if ( cp->addCat() ) {
2303 KABC::AddressBook::Iterator it; 2307 KABC::AddressBook::Iterator it;
2304 QStringList catList = KABPrefs::instance()->mCustomCategories; 2308 QStringList catList = KABPrefs::instance()->mCustomCategories;
2305 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2309 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2306 ++cc; 2310 ++cc;
2307 if ( cc %10 == 0) 2311 if ( cc %10 == 0)
2308 message(i18n("Processing contact #%1").arg(cc)); 2312 message(i18n("Processing contact #%1").arg(cc));
2309 QStringList catIncList = (*it).categories(); 2313 QStringList catIncList = (*it).categories();
2310 int i; 2314 int i;
2311 for( i = 0; i< catIncList.count(); ++i ) { 2315 for( i = 0; i< catIncList.count(); ++i ) {
2312 if ( !catList.contains (catIncList[i])) { 2316 if ( !catList.contains (catIncList[i])) {
2313 catList.append( catIncList[i] ); 2317 catList.append( catIncList[i] );
2314 //qDebug("add cat %s ", catIncList[i].latin1()); 2318 //qDebug("add cat %s ", catIncList[i].latin1());
2315 ++count; 2319 ++count;
2316 } 2320 }
2317 } 2321 }
2318 } 2322 }
2319 catList.sort(); 2323 catList.sort();
2320 KABPrefs::instance()->mCustomCategories = catList; 2324 KABPrefs::instance()->mCustomCategories = catList;
2321 KABPrefs::instance()->writeConfig(); 2325 KABPrefs::instance()->writeConfig();
2322 message(QString::number( count )+ i18n(" categories added to list! ")); 2326 message(QString::number( count )+ i18n(" categories added to list! "));
2323 } else { 2327 } else {
2324 QStringList catList = KABPrefs::instance()->mCustomCategories; 2328 QStringList catList = KABPrefs::instance()->mCustomCategories;
2325 QStringList catIncList; 2329 QStringList catIncList;
2326 QStringList newCatList; 2330 QStringList newCatList;
2327 KABC::AddressBook::Iterator it; 2331 KABC::AddressBook::Iterator it;
2328 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2332 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2329 ++cc; 2333 ++cc;
2330 if ( cc %10 == 0) 2334 if ( cc %10 == 0)
2331 message(i18n("Processing contact #%1").arg(cc)); 2335 message(i18n("Processing contact #%1").arg(cc));
2332 QStringList catIncList = (*it).categories(); 2336 QStringList catIncList = (*it).categories();
2333 int i; 2337 int i;
2334 if ( catIncList.count() ) { 2338 if ( catIncList.count() ) {
2335 newCatList.clear(); 2339 newCatList.clear();
2336 for( i = 0; i< catIncList.count(); ++i ) { 2340 for( i = 0; i< catIncList.count(); ++i ) {
2337 if ( catList.contains (catIncList[i])) { 2341 if ( catList.contains (catIncList[i])) {
2338 newCatList.append( catIncList[i] ); 2342 newCatList.append( catIncList[i] );
2339 } 2343 }
2340 } 2344 }
2341 newCatList.sort(); 2345 newCatList.sort();
2342 (*it).setCategories( newCatList ); 2346 (*it).setCategories( newCatList );
2343 mAddressBook->insertAddressee( (*it) ); 2347 mAddressBook->insertAddressee( (*it) );
2344 } 2348 }
2345 } 2349 }
2346 setModified( true ); 2350 setModified( true );
2347 mViewManager->refreshView(); 2351 mViewManager->refreshView();
2348 message( i18n("Removing categories done!")); 2352 message( i18n("Removing categories done!"));
2349 } 2353 }
2350 delete cp; 2354 delete cp;
2351} 2355}
2352void KABCore::removeVoice() 2356void KABCore::removeVoice()
2353{ 2357{
2354 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 ) 2358 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 )
2355 return; 2359 return;
2356 XXPortSelectDialog dlg( this, false, this ); 2360 XXPortSelectDialog dlg( this, false, this );
2357 if ( !dlg.exec() ) 2361 if ( !dlg.exec() )
2358 return; 2362 return;
2359 mAddressBook->setUntagged(); 2363 mAddressBook->setUntagged();
2360 dlg.tagSelected(); 2364 dlg.tagSelected();
2361 message(i18n("Removing voice..."), false ); 2365 message(i18n("Removing voice..."), false );
2362 KABC::AddressBook::Iterator it; 2366 KABC::AddressBook::Iterator it;
2363 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2367 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2364 if ( (*it).tagged() ) { 2368 if ( (*it).tagged() ) {
2365 (*it).removeVoice(); 2369 (*it).removeVoice();
2366 } 2370 }
2367 } 2371 }
2368 message(i18n("Refreshing view...") ); 2372 message(i18n("Refreshing view...") );
2369 qApp->processEvents(); 2373 qApp->processEvents();
2370 mViewManager->refreshView( "" ); 2374 mViewManager->refreshView( "" );
2371 Addressee add; 2375 Addressee add;
2372 mDetails->setAddressee( add ); 2376 mDetails->setAddressee( add );
2373 message(i18n("Remove voice completed!") ); 2377 message(i18n("Remove voice completed!") );
2374 2378
2375 2379
2376 2380
2377} 2381}
2378 2382
2379void KABCore::setFormattedName() 2383void KABCore::setFormattedName()
2380{ 2384{
2381 KABFormatPrefs setpref; 2385 KABFormatPrefs setpref;
2382 if ( !setpref.exec() ) { 2386 if ( !setpref.exec() ) {
2383 return; 2387 return;
2384 } 2388 }
2385 XXPortSelectDialog dlg( this, false, this ); 2389 XXPortSelectDialog dlg( this, false, this );
2386 if ( !dlg.exec() ) 2390 if ( !dlg.exec() )
2387 return; 2391 return;
2388 mAddressBook->setUntagged(); 2392 mAddressBook->setUntagged();
2389 dlg.tagSelected(); 2393 dlg.tagSelected();
2390 int count = 0; 2394 int count = 0;
2391 KABC::AddressBook::Iterator it; 2395 KABC::AddressBook::Iterator it;
2392 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2396 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2393 if ( (*it).tagged() ) { 2397 if ( (*it).tagged() ) {
2394 ++count; 2398 ++count;
2395 if ( count %10 == 0 ) 2399 if ( count %10 == 0 )
2396 message(i18n("Changing contact #%1").arg( count ) ); 2400 message(i18n("Changing contact #%1").arg( count ) );
2397 qApp->processEvents(); 2401 qApp->processEvents();
2398 QString fName; 2402 QString fName;
2399 if ( setpref.simple->isChecked() ) 2403 if ( setpref.simple->isChecked() )
2400 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); 2404 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName );
2401 else if ( setpref.full->isChecked() ) 2405 else if ( setpref.full->isChecked() )
2402 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); 2406 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName );
2403 else if ( setpref.reverse->isChecked() ) 2407 else if ( setpref.reverse->isChecked() )
2404 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); 2408 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName );
2405 else 2409 else
2406 fName = (*it).organization(); 2410 fName = (*it).organization();
2407 if ( setpref.setCompany->isChecked() ) 2411 if ( setpref.setCompany->isChecked() )
2408 if ( fName.isEmpty() || fName =="," ) 2412 if ( fName.isEmpty() || fName =="," )
2409 fName = (*it).organization(); 2413 fName = (*it).organization();
2410 (*it).setFormattedName( fName ); 2414 (*it).setFormattedName( fName );
2411 } 2415 }
2412 } 2416 }
2413 message(i18n("Refreshing view...") ); 2417 message(i18n("Refreshing view...") );
2414 qApp->processEvents(); 2418 qApp->processEvents();
2415 mViewManager->refreshView( "" ); 2419 mViewManager->refreshView( "" );
2416 Addressee add; 2420 Addressee add;
2417 mDetails->setAddressee( add ); 2421 mDetails->setAddressee( add );
2418 message(i18n("Setting formatted name completed!") ); 2422 message(i18n("Setting formatted name completed!") );
2419} 2423}
2420 2424
2421void KABCore::clipboardDataChanged() 2425void KABCore::clipboardDataChanged()
2422{ 2426{
2423 2427
2424 if ( mReadWrite ) 2428 if ( mReadWrite )
2425 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2429 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2426 2430
2427} 2431}
2428 2432
2429void KABCore::updateActionMenu() 2433void KABCore::updateActionMenu()
2430{ 2434{
2431 UndoStack *undo = UndoStack::instance(); 2435 UndoStack *undo = UndoStack::instance();
2432 RedoStack *redo = RedoStack::instance(); 2436 RedoStack *redo = RedoStack::instance();
2433 2437
2434 if ( undo->isEmpty() ) 2438 if ( undo->isEmpty() )
2435 mActionUndo->setText( i18n( "Undo" ) ); 2439 mActionUndo->setText( i18n( "Undo" ) );
2436 else 2440 else
2437 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2441 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2438 2442
2439 mActionUndo->setEnabled( !undo->isEmpty() ); 2443 mActionUndo->setEnabled( !undo->isEmpty() );
2440 2444
2441 if ( !redo->top() ) 2445 if ( !redo->top() )
2442 mActionRedo->setText( i18n( "Redo" ) ); 2446 mActionRedo->setText( i18n( "Redo" ) );
2443 else 2447 else
2444 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2448 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2445 2449
2446 mActionRedo->setEnabled( !redo->isEmpty() ); 2450 mActionRedo->setEnabled( !redo->isEmpty() );
2447} 2451}
2448 2452
2449void KABCore::configureKeyBindings() 2453void KABCore::configureKeyBindings()
2450{ 2454{
2451#ifndef KAB_EMBEDDED 2455#ifndef KAB_EMBEDDED
2452 KKeyDialog::configure( actionCollection(), true ); 2456 KKeyDialog::configure( actionCollection(), true );
2453#else //KAB_EMBEDDED 2457#else //KAB_EMBEDDED
2454 qDebug("KABCore::configureKeyBindings() not implemented"); 2458 qDebug("KABCore::configureKeyBindings() not implemented");
2455#endif //KAB_EMBEDDED 2459#endif //KAB_EMBEDDED
2456} 2460}
2457 2461
2458#ifdef KAB_EMBEDDED 2462#ifdef KAB_EMBEDDED
2459void KABCore::configureResources() 2463void KABCore::configureResources()
2460{ 2464{
2461 KRES::KCMKResources dlg( this, "" , 0 ); 2465 KRES::KCMKResources dlg( this, "" , 0 );
2462 2466
2463 if ( !dlg.exec() ) 2467 if ( !dlg.exec() )
2464 return; 2468 return;
2465 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2469 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2466} 2470}
2467#endif //KAB_EMBEDDED 2471#endif //KAB_EMBEDDED
2468 2472
2469 2473
2470/* this method will be called through the QCop interface from Ko/Pi to select addresses 2474/* this method will be called through the QCop interface from Ko/Pi to select addresses
2471 * for the attendees list of an event. 2475 * for the attendees list of an event.
2472 */ 2476 */
2473void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2477void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2474{ 2478{
2475 QStringList nameList; 2479 QStringList nameList;
2476 QStringList emailList; 2480 QStringList emailList;
2477 QStringList uidList; 2481 QStringList uidList;
2478 2482
2479 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2483 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2480 uint i=0; 2484 uint i=0;
2481 for (i=0; i < list.count(); i++) 2485 for (i=0; i < list.count(); i++)
2482 { 2486 {
2483 nameList.append(list[i].realName()); 2487 nameList.append(list[i].realName());
2484 emailList.append(list[i].preferredEmail()); 2488 emailList.append(list[i].preferredEmail());
2485 uidList.append(list[i].uid()); 2489 uidList.append(list[i].uid());
2486 } 2490 }
2487 2491
2488 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2492 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2489 2493
2490} 2494}
2491 2495
2492/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2496/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2493 * to put them into the calendar. 2497 * to put them into the calendar.
2494 */ 2498 */
2495void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2499void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2496{ 2500{
2497 // qDebug("KABCore::requestForBirthdayList"); 2501 // qDebug("KABCore::requestForBirthdayList");
2498 QStringList birthdayList; 2502 QStringList birthdayList;
2499 QStringList anniversaryList; 2503 QStringList anniversaryList;
2500 QStringList realNameList; 2504 QStringList realNameList;
2501 QStringList preferredEmailList; 2505 QStringList preferredEmailList;
2502 QStringList assembledNameList; 2506 QStringList assembledNameList;
2503 QStringList uidList; 2507 QStringList uidList;
2504 2508
2505 KABC::AddressBook::Iterator it; 2509 KABC::AddressBook::Iterator it;
2506 2510
2507 int count = 0; 2511 int count = 0;
2508 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2512 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2509 ++count; 2513 ++count;
2510 } 2514 }
2511 QProgressBar bar(count,0 ); 2515 QProgressBar bar(count,0 );
2512 int w = 300; 2516 int w = 300;
2513 if ( QApplication::desktop()->width() < 320 ) 2517 if ( QApplication::desktop()->width() < 320 )
2514 w = 220; 2518 w = 220;
2515 int h = bar.sizeHint().height() ; 2519 int h = bar.sizeHint().height() ;
2516 int dw = QApplication::desktop()->width(); 2520 int dw = QApplication::desktop()->width();
2517 int dh = QApplication::desktop()->height(); 2521 int dh = QApplication::desktop()->height();
2518 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2522 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2519 bar.show(); 2523 bar.show();
2520 bar.setCaption (i18n("Collecting birthdays - close to abort!") ); 2524 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2521 qApp->processEvents(); 2525 qApp->processEvents();
2522 2526
2523 QDate bday; 2527 QDate bday;
2524 QString anni; 2528 QString anni;
2525 QString formattedbday; 2529 QString formattedbday;
2526 2530
2527 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2531 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2528 { 2532 {
2529 if ( ! bar.isVisible() ) 2533 if ( ! bar.isVisible() )
2530 return; 2534 return;
2531 bar.setProgress( count++ ); 2535 bar.setProgress( count++ );
2532 qApp->processEvents(); 2536 qApp->processEvents();
2533 bday = (*it).birthday().date(); 2537 bday = (*it).birthday().date();
2534 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2538 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2535 2539
2536 if ( bday.isValid() || !anni.isEmpty()) 2540 if ( bday.isValid() || !anni.isEmpty())
2537 { 2541 {
2538 if (bday.isValid()) 2542 if (bday.isValid())
2539 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2543 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2540 else 2544 else
2541 formattedbday = "NOTVALID"; 2545 formattedbday = "NOTVALID";
2542 if (anni.isEmpty()) 2546 if (anni.isEmpty())
2543 anni = "INVALID"; 2547 anni = "INVALID";
2544 2548
2545 birthdayList.append(formattedbday); 2549 birthdayList.append(formattedbday);
2546 anniversaryList.append(anni); //should be ISODate 2550 anniversaryList.append(anni); //should be ISODate
2547 realNameList.append((*it).realName()); 2551 realNameList.append((*it).realName());
2548 preferredEmailList.append((*it).preferredEmail()); 2552 preferredEmailList.append((*it).preferredEmail());
2549 assembledNameList.append((*it).assembledName()); 2553 assembledNameList.append((*it).assembledName());
2550 uidList.append((*it).uid()); 2554 uidList.append((*it).uid());
2551 2555
2552 //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() ); 2556 //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() );
2553 } 2557 }
2554 } 2558 }
2555 2559
2556 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2560 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2557 2561
2558} 2562}
2559 2563
2560/* this method will be called through the QCop interface from other apps to show details of a contact. 2564/* this method will be called through the QCop interface from other apps to show details of a contact.
2561 */ 2565 */
2562void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2566void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2563{ 2567{
2564 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2568 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2565 2569
2566 QString foundUid = QString::null; 2570 QString foundUid = QString::null;
2567 if ( ! uid.isEmpty() ) { 2571 if ( ! uid.isEmpty() ) {
2568 Addressee adrr = mAddressBook->findByUid( uid ); 2572 Addressee adrr = mAddressBook->findByUid( uid );
2569 if ( !adrr.isEmpty() ) { 2573 if ( !adrr.isEmpty() ) {
2570 foundUid = uid; 2574 foundUid = uid;
2571 } 2575 }
2572 if ( email == "sendbacklist" ) { 2576 if ( email == "sendbacklist" ) {
2573 //qDebug("ssssssssssssssssssssssend "); 2577 //qDebug("ssssssssssssssssssssssend ");
2574 QStringList nameList; 2578 QStringList nameList;
2575 QStringList emailList; 2579 QStringList emailList;
2576 QStringList uidList; 2580 QStringList uidList;
2577 nameList.append(adrr.realName()); 2581 nameList.append(adrr.realName());
2578 emailList = adrr.emails(); 2582 emailList = adrr.emails();
2579 uidList.append( adrr.preferredEmail()); 2583 uidList.append( adrr.preferredEmail());
2580 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2584 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2581 return; 2585 return;
2582 } 2586 }
2583 2587
2584 } 2588 }
2585 2589
2586 if ( email == "sendbacklist" ) 2590 if ( email == "sendbacklist" )
2587 return; 2591 return;
2588 if (foundUid.isEmpty()) 2592 if (foundUid.isEmpty())
2589 { 2593 {
2590 //find the uid of the person first 2594 //find the uid of the person first
2591 Addressee::List namelist; 2595 Addressee::List namelist;
2592 Addressee::List emaillist; 2596 Addressee::List emaillist;
2593 2597
2594 if (!name.isEmpty()) 2598 if (!name.isEmpty())
2595 namelist = mAddressBook->findByName( name ); 2599 namelist = mAddressBook->findByName( name );
2596 2600
2597 if (!email.isEmpty()) 2601 if (!email.isEmpty())
2598 emaillist = mAddressBook->findByEmail( email ); 2602 emaillist = mAddressBook->findByEmail( email );
2599 //qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2603 //qDebug("count %d %d ", namelist.count(),emaillist.count() );
2600 //check if we have a match in Namelist and Emaillist 2604 //check if we have a match in Namelist and Emaillist
2601 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2605 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2602 foundUid = emaillist[0].uid(); 2606 foundUid = emaillist[0].uid();
2603 } 2607 }
2604 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2608 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2605 foundUid = namelist[0].uid(); 2609 foundUid = namelist[0].uid();
2606 else 2610 else
2607 { 2611 {
2608 for (int i = 0; i < namelist.count(); i++) 2612 for (int i = 0; i < namelist.count(); i++)
2609 { 2613 {
2610 for (int j = 0; j < emaillist.count(); j++) 2614 for (int j = 0; j < emaillist.count(); j++)
2611 { 2615 {
2612 if (namelist[i] == emaillist[j]) 2616 if (namelist[i] == emaillist[j])
2613 { 2617 {
2614 foundUid = namelist[i].uid(); 2618 foundUid = namelist[i].uid();
2615 } 2619 }
2616 } 2620 }
2617 } 2621 }
2618 } 2622 }
2619 } 2623 }
2620 else 2624 else
2621 { 2625 {
2622 foundUid = uid; 2626 foundUid = uid;
2623 } 2627 }
2624 2628
2625 if (!foundUid.isEmpty()) 2629 if (!foundUid.isEmpty())
2626 { 2630 {
2627 2631
2628 // raise Ka/Pi if it is in the background 2632 // raise Ka/Pi if it is in the background
2629#ifndef DESKTOP_VERSION 2633#ifndef DESKTOP_VERSION
2630#ifndef KORG_NODCOP 2634#ifndef KORG_NODCOP
2631 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2635 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2632#endif 2636#endif
2633#endif 2637#endif
2634 2638
2635 mMainWindow->showMaximized(); 2639 mMainWindow->showMaximized();
2636 mMainWindow-> raise(); 2640 mMainWindow-> raise();
2637 2641
2638 mViewManager->setSelected( "", false); 2642 mViewManager->setSelected( "", false);
2639 mViewManager->refreshView( "" ); 2643 mViewManager->refreshView( "" );
2640 mViewManager->setSelected( foundUid, true ); 2644 mViewManager->setSelected( foundUid, true );
2641 mViewManager->refreshView( foundUid ); 2645 mViewManager->refreshView( foundUid );
2642 2646
2643 if ( !mMultipleViewsAtOnce ) 2647 if ( !mMultipleViewsAtOnce )
2644 { 2648 {
2645 setDetailsVisible( true ); 2649 setDetailsVisible( true );
2646 mActionDetails->setChecked(true); 2650 mActionDetails->setChecked(true);
2647 } 2651 }
2648 } 2652 }
2649} 2653}
2650 2654
2651void KABCore::whatsnew() 2655void KABCore::whatsnew()
2652{ 2656{
2653 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2657 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2654} 2658}
2655void KABCore::synchowto() 2659void KABCore::synchowto()
2656{ 2660{
2657 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2661 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2658} 2662}
2659void KABCore::kdesynchowto() 2663void KABCore::kdesynchowto()
2660{ 2664{
2661 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 2665 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
2662} 2666}
2663void KABCore::multisynchowto() 2667void KABCore::multisynchowto()
2664{ 2668{
2665 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 2669 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
2666} 2670}
2667void KABCore::faq() 2671void KABCore::faq()
2668{ 2672{
2669 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2673 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2670} 2674}
2671 2675
2672#include <libkcal/syncdefines.h> 2676#include <libkcal/syncdefines.h>
2673 2677
2674KABC::Addressee KABCore::getLastSyncAddressee() 2678KABC::Addressee KABCore::getLastSyncAddressee()
2675{ 2679{
2676 Addressee lse; 2680 Addressee lse;
2677 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2681 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2678 2682
2679 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2683 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2680 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2684 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2681 if (lse.isEmpty()) { 2685 if (lse.isEmpty()) {
2682 qDebug("Creating new last-syncAddressee "); 2686 qDebug("Creating new last-syncAddressee ");
2683 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2687 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2684 QString sum = ""; 2688 QString sum = "";
2685 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2689 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2686 sum = "E: "; 2690 sum = "E: ";
2687 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2691 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2688 lse.setRevision( mLastAddressbookSync ); 2692 lse.setRevision( mLastAddressbookSync );
2689 lse.setCategories( i18n("SyncEvent") ); 2693 lse.setCategories( i18n("SyncEvent") );
2690 mAddressBook->insertAddressee( lse ); 2694 mAddressBook->insertAddressee( lse );
2691 } 2695 }
2692 return lse; 2696 return lse;
2693} 2697}
2694int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2698int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2695{ 2699{
2696 2700
2697 //void setZaurusId(int id); 2701 //void setZaurusId(int id);
2698 // int zaurusId() const; 2702 // int zaurusId() const;
2699 // void setZaurusUid(int id); 2703 // void setZaurusUid(int id);
2700 // int zaurusUid() const; 2704 // int zaurusUid() const;
2701 // void setZaurusStat(int id); 2705 // void setZaurusStat(int id);
2702 // int zaurusStat() const; 2706 // int zaurusStat() const;
2703 // 0 equal 2707 // 0 equal
2704 // 1 take local 2708 // 1 take local
2705 // 2 take remote 2709 // 2 take remote
2706 // 3 cancel 2710 // 3 cancel
2707 QDateTime lastSync = mLastAddressbookSync; 2711 QDateTime lastSync = mLastAddressbookSync;
2708 QDateTime localMod = local->revision(); 2712 QDateTime localMod = local->revision();
2709 QDateTime remoteMod = remote->revision(); 2713 QDateTime remoteMod = remote->revision();
2710 2714
2711 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2715 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2712 2716
2713 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2717 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2714 bool remCh, locCh; 2718 bool remCh, locCh;
2715 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2719 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2716 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2720 if ( remCh )
2721 qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2717 locCh = ( localMod > mLastAddressbookSync ); 2722 locCh = ( localMod > mLastAddressbookSync );
2718 //qDebug("cahnged rem %d loc %d",remCh, locCh ); 2723 //qDebug("cahnged rem %d loc %d",remCh, locCh );
2719 if ( !remCh && ! locCh ) { 2724 if ( !remCh && ! locCh ) {
2720 //qDebug("both not changed "); 2725 //qDebug("both not changed ");
2721 lastSync = localMod.addDays(1); 2726 lastSync = localMod.addDays(1);
2722 if ( mode <= SYNC_PREF_ASK ) 2727 if ( mode <= SYNC_PREF_ASK )
2723 return 0; 2728 return 0;
2724 } else { 2729 } else {
2725 if ( locCh ) { 2730 if ( locCh ) {
2726 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2731 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2727 lastSync = localMod.addDays( -1 ); 2732 lastSync = localMod.addDays( -1 );
2728 if ( !remCh ) 2733 if ( !remCh )
2729 remoteMod =( lastSync.addDays( -1 ) ); 2734 remoteMod =( lastSync.addDays( -1 ) );
2730 } else { 2735 } else {
2731 //qDebug(" not loc changed "); 2736 //qDebug(" not loc changed ");
2732 lastSync = localMod.addDays( 1 ); 2737 lastSync = localMod.addDays( 1 );
2733 if ( remCh ) { 2738 if ( remCh ) {
2734 //qDebug("rem changed "); 2739 //qDebug("rem changed ");
2735 remoteMod =( lastSync.addDays( 1 ) ); 2740 remoteMod =( lastSync.addDays( 1 ) );
2736 } 2741 }
2737 2742
2738 } 2743 }
2739 } 2744 }
2740 full = true; 2745 full = true;
2741 if ( mode < SYNC_PREF_ASK ) 2746 if ( mode < SYNC_PREF_ASK )
2742 mode = SYNC_PREF_ASK; 2747 mode = SYNC_PREF_ASK;
2743 } else { 2748 } else {
2744 if ( localMod == remoteMod ) 2749 if ( localMod == remoteMod )
2745 return 0; 2750 return 0;
2746 2751
2747 } 2752 }
2748 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); 2753 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec());
2749 //qDebug("lastsync %s ", lastSync.toString().latin1() ); 2754 //qDebug("lastsync %s ", lastSync.toString().latin1() );
2750 //full = true; //debug only 2755 //full = true; //debug only
2751 if ( full ) { 2756 if ( full ) {
2752 bool equ = ( (*local) == (*remote) ); 2757 bool equ = ( (*local) == (*remote) );
2753 if ( equ ) { 2758 if ( equ ) {
2754 //qDebug("equal "); 2759 //qDebug("equal ");
2755 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2760 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2756 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2761 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2757 } 2762 }
2758 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2763 if ( mode < SYNC_PREF_FORCE_LOCAL )
2759 return 0; 2764 return 0;
2760 2765
2761 }//else //debug only 2766 }//else //debug only
2762 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2767 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2763 } 2768 }
2764 int result; 2769 int result;
2765 bool localIsNew; 2770 bool localIsNew;
2766 //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() ); 2771 //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() );
2767 2772
2768 if ( full && mode < SYNC_PREF_NEWEST ) 2773 if ( full && mode < SYNC_PREF_NEWEST )
2769 mode = SYNC_PREF_ASK; 2774 mode = SYNC_PREF_ASK;
2770 2775
2771 switch( mode ) { 2776 switch( mode ) {
2772 case SYNC_PREF_LOCAL: 2777 case SYNC_PREF_LOCAL:
2773 if ( lastSync > remoteMod ) 2778 if ( lastSync > remoteMod )
2774 return 1; 2779 return 1;
2775 if ( lastSync > localMod ) 2780 if ( lastSync > localMod )
2776 return 2; 2781 return 2;
2777 return 1; 2782 return 1;
2778 break; 2783 break;
2779 case SYNC_PREF_REMOTE: 2784 case SYNC_PREF_REMOTE:
2780 if ( lastSync > remoteMod ) 2785 if ( lastSync > remoteMod )
2781 return 1; 2786 return 1;
2782 if ( lastSync > localMod ) 2787 if ( lastSync > localMod )
2783 return 2; 2788 return 2;
2784 return 2; 2789 return 2;
2785 break; 2790 break;
2786 case SYNC_PREF_NEWEST: 2791 case SYNC_PREF_NEWEST:
2787 if ( localMod > remoteMod ) 2792 if ( localMod > remoteMod )
2788 return 1; 2793 return 1;
2789 else 2794 else
2790 return 2; 2795 return 2;
2791 break; 2796 break;
2792 case SYNC_PREF_ASK: 2797 case SYNC_PREF_ASK:
2793 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2798 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2794 if ( lastSync > remoteMod ) 2799 if ( lastSync > remoteMod )
2795 return 1; 2800 return 1;
2796 if ( lastSync > localMod ) { 2801 if ( lastSync > localMod ) {
2797 return 2; 2802 return 2;
2798 } 2803 }
2799 localIsNew = localMod >= remoteMod; 2804 localIsNew = localMod >= remoteMod;
2800 //qDebug("conflict! ************************************** "); 2805 //qDebug("conflict! ************************************** ");
2801 { 2806 {
2802 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2807 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2803 result = acd.executeD(localIsNew); 2808 result = acd.executeD(localIsNew);
2804 return result; 2809 return result;
2805 } 2810 }
2806 break; 2811 break;
2807 case SYNC_PREF_FORCE_LOCAL: 2812 case SYNC_PREF_FORCE_LOCAL:
2808 return 1; 2813 return 1;
2809 break; 2814 break;
2810 case SYNC_PREF_FORCE_REMOTE: 2815 case SYNC_PREF_FORCE_REMOTE:
2811 return 2; 2816 return 2;
2812 break; 2817 break;
2813 2818
2814 default: 2819 default:
2815 // SYNC_PREF_TAKE_BOTH not implemented 2820 // SYNC_PREF_TAKE_BOTH not implemented
2816 break; 2821 break;
2817 } 2822 }
2818 return 0; 2823 return 0;
2819} 2824}
2820 2825
2821 2826
2822bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2827bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2823{ 2828{
2824 bool syncOK = true; 2829 bool syncOK = true;
2825 int addedAddressee = 0; 2830 int addedAddressee = 0;
2826 int addedAddresseeR = 0; 2831 int addedAddresseeR = 0;
2827 int deletedAddresseeR = 0; 2832 int deletedAddresseeR = 0;
2828 int deletedAddresseeL = 0; 2833 int deletedAddresseeL = 0;
2829 int changedLocal = 0; 2834 int changedLocal = 0;
2830 int changedRemote = 0; 2835 int changedRemote = 0;
2831 int filteredIN = 0; 2836 int filteredIN = 0;
2832 int filteredOUT = 0; 2837 int filteredOUT = 0;
2833 2838
2834 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2839 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2835 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2840 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2836 2841
2837 //QPtrList<Addressee> el = local->rawAddressees(); 2842 //QPtrList<Addressee> el = local->rawAddressees();
2838 Addressee addresseeR; 2843 Addressee addresseeR;
2839 QString uid; 2844 QString uid;
2840 int take; 2845 int take;
2841 Addressee addresseeL; 2846 Addressee addresseeL;
2842 Addressee addresseeRSync; 2847 Addressee addresseeRSync;
2843 Addressee addresseeLSync; 2848 Addressee addresseeLSync;
2844 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2849 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2845 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2850 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2846 bool fullDateRange = false; 2851 bool fullDateRange = false;
2847 local->resetTempSyncStat(); 2852 local->resetTempSyncStat();
2848 mLastAddressbookSync = QDateTime::currentDateTime(); 2853 mLastAddressbookSync = QDateTime::currentDateTime();
2849 if ( syncManager->syncWithDesktop() ) { 2854 if ( syncManager->syncWithDesktop() ) {
2850 // remote->removeSyncInfo( QString());//remove all info 2855 // remote->removeSyncInfo( QString());//remove all info
2851 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 2856 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
2852 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 2857 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
2853 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 2858 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
2854 } else { 2859 } else {
2855 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 2860 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
2856 } 2861 }
2857 } 2862 }
2858 QDateTime modifiedCalendar = mLastAddressbookSync; 2863 QDateTime modifiedCalendar = mLastAddressbookSync;
2859 addresseeLSync = getLastSyncAddressee(); 2864 addresseeLSync = getLastSyncAddressee();
2860 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2865 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2861 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2866 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2862 if ( !addresseeR.isEmpty() ) { 2867 if ( !addresseeR.isEmpty() ) {
2863 addresseeRSync = addresseeR; 2868 addresseeRSync = addresseeR;
2864 remote->removeAddressee(addresseeR ); 2869 remote->removeAddressee(addresseeR );
2865 2870
2866 } else { 2871 } else {
2867 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2872 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2868 addresseeRSync = addresseeLSync ; 2873 addresseeRSync = addresseeLSync ;
2869 } else { 2874 } else {
2870 //qDebug("FULLDATE 1"); 2875 //qDebug("FULLDATE 1");
2871 fullDateRange = true; 2876 fullDateRange = true;
2872 Addressee newAdd; 2877 Addressee newAdd;
2873 addresseeRSync = newAdd; 2878 addresseeRSync = newAdd;
2874 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2879 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2875 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2880 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2876 addresseeRSync.setRevision( mLastAddressbookSync ); 2881 addresseeRSync.setRevision( mLastAddressbookSync );
2877 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2882 addresseeRSync.setCategories( i18n("SyncAddressee") );
2878 } 2883 }
2879 } 2884 }
2880 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2885 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2881 // qDebug("FULLDATE 2"); 2886 // qDebug("FULLDATE 2");
2882 fullDateRange = true; 2887 fullDateRange = true;
2883 } 2888 }
2884 if ( ! fullDateRange ) { 2889 if ( ! fullDateRange ) {
2885 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2890 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2886 2891
2887 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2892 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2888 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2893 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2889 fullDateRange = true; 2894 fullDateRange = true;
2890 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2895 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2891 } 2896 }
2892 } 2897 }
2893 // fullDateRange = true; // debug only! 2898 // fullDateRange = true; // debug only!
2894 if ( fullDateRange ) 2899 if ( fullDateRange )
2895 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2900 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2896 else 2901 else
2897 mLastAddressbookSync = addresseeLSync.revision(); 2902 mLastAddressbookSync = addresseeLSync.revision();
2898 // for resyncing if own file has changed 2903 // for resyncing if own file has changed
2899 // PENDING fixme later when implemented 2904 // PENDING fixme later when implemented
2900#if 0 2905#if 0
2901 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2906 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2902 mLastAddressbookSync = loadedFileVersion; 2907 mLastAddressbookSync = loadedFileVersion;
2903 qDebug("setting mLastAddressbookSync "); 2908 qDebug("setting mLastAddressbookSync ");
2904 } 2909 }
2905#endif 2910#endif
2906 2911
2907 2912
2908 // ********** setting filters **************** 2913 // ********** setting filters ****************
2909 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); 2914 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB );
2910 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); 2915 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB );
2911 2916
2912 //qDebug("*************************** "); 2917 //qDebug("*************************** ");
2913 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2918 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2914 QStringList er = remote->uidList(); 2919 QStringList er = remote->uidList();
2915 Addressee inR ;//= er.first(); 2920 Addressee inR ;//= er.first();
2916 Addressee inL; 2921 Addressee inL;
2917 2922
2918 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2923 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2919 2924
2920 int modulo = (er.count()/10)+1; 2925 int modulo = (er.count()/10)+1;
2921 int incCounter = 0; 2926 int incCounter = 0;
2922 while ( incCounter < er.count()) { 2927 while ( incCounter < er.count()) {
2923 if (syncManager->isProgressBarCanceled()) 2928 if (syncManager->isProgressBarCanceled())
2924 return false; 2929 return false;
2925 if ( incCounter % modulo == 0 ) 2930 if ( incCounter % modulo == 0 )
2926 syncManager->showProgressBar(incCounter); 2931 syncManager->showProgressBar(incCounter);
2927 2932
2928 uid = er[ incCounter ]; 2933 uid = er[ incCounter ];
2929 bool skipIncidence = false; 2934 bool skipIncidence = false;
2930 if ( uid.left(19) == QString("last-syncAddressee-") ) 2935 if ( uid.left(19) == QString("last-syncAddressee-") )
2931 skipIncidence = true; 2936 skipIncidence = true;
2932 QString idS,OidS; 2937 QString idS,OidS;
2933 qApp->processEvents(); 2938 qApp->processEvents();
2934 if ( !skipIncidence ) { 2939 if ( !skipIncidence ) {
2935 inL = local->findByUid( uid ); 2940 inL = local->findByUid( uid );
2936 inR = remote->findByUid( uid ); 2941 inR = remote->findByUid( uid );
2937 //inL.setResource( 0 ); 2942 //inL.setResource( 0 );
2938 //inR.setResource( 0 ); 2943 //inR.setResource( 0 );
2939 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2944 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2940 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2945 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2941 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { 2946 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) {
2942 //qDebug("take %d %s ", take, inL.summary().latin1()); 2947 //qDebug("take %d %s ", take, inL.summary().latin1());
2943 if ( take == 3 ) 2948 if ( take == 3 )
2944 return false; 2949 return false;
2945 if ( take == 1 ) {// take local ********************** 2950 if ( take == 1 ) {// take local **********************
2946 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2951 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2947 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2952 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2948 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2953 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2949 local->insertAddressee( inL, false ); 2954 local->insertAddressee( inL, false );
2950 idS = inR.externalUID(); 2955 idS = inR.externalUID();
2951 OidS = inR.originalExternalUID(); 2956 OidS = inR.originalExternalUID();
2952 } 2957 }
2953 else 2958 else
2954 idS = inR.IDStr(); 2959 idS = inR.IDStr();
2955 remote->removeAddressee( inR ); 2960 remote->removeAddressee( inR );
2956 inR = inL; 2961 inR = inL;
2957 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2962 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2958 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2963 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2959 inR.setOriginalExternalUID( OidS ); 2964 inR.setOriginalExternalUID( OidS );
2960 inR.setExternalUID( idS ); 2965 inR.setExternalUID( idS );
2961 if ( syncManager->syncWithDesktop() ) { 2966 if ( syncManager->syncWithDesktop() ) {
2962 inR.setIDStr("changed" ); 2967 inR.setIDStr("changed" );
2963 } 2968 }
2964 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 2969 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
2965 } else { 2970 } else {
2966 inR.setIDStr( idS ); 2971 inR.setIDStr( idS );
2967 } 2972 }
2968 inR.setResource( 0 ); 2973 inR.setResource( 0 );
2969 remote->insertAddressee( inR , false); 2974 remote->insertAddressee( inR , false);
2970 ++changedRemote; 2975 ++changedRemote;
2971 } else { // take == 2 take remote ********************** 2976 } else { // take == 2 take remote **********************
2972 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2977 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2973 if ( inR.revision().date().year() < 2004 ) 2978 if ( inR.revision().date().year() < 2004 )
2974 inR.setRevision( modifiedCalendar ); 2979 inR.setRevision( modifiedCalendar );
2975 } 2980 }
2976 idS = inL.IDStr(); 2981 idS = inL.IDStr();
2977 local->removeAddressee( inL ); 2982 local->removeAddressee( inL );
2978 inL = inR; 2983 inL = inR;
2979 inL.setIDStr( idS ); 2984 inL.setIDStr( idS );
2980 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2985 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2981 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2986 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2982 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2987 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2983 } 2988 }
2984 inL.setResource( 0 ); 2989 inL.setResource( 0 );
2985 local->insertAddressee( inL , false ); 2990 local->insertAddressee( inL , false );
2986 ++changedLocal; 2991 ++changedLocal;
2987 } 2992 }
2988 } 2993 }
2989 } 2994 }
2990 } else { // no conflict ********** add or delete remote 2995 } else { // no conflict ********** add or delete remote
2991 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { 2996 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) {
2992 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2997 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2993 QString des = addresseeLSync.note(); 2998 QString des = addresseeLSync.note();
2994 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2999 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2995 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 3000 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2996 remote->insertAddressee( inR, false ); 3001 remote->insertAddressee( inR, false );
2997 ++deletedAddresseeR; 3002 ++deletedAddresseeR;
2998 } else { 3003 } else {
2999 inR.setRevision( modifiedCalendar ); 3004 inR.setRevision( modifiedCalendar );
3000 remote->insertAddressee( inR, false ); 3005 remote->insertAddressee( inR, false );
3001 inL = inR; 3006 inL = inR;
3002 inL.setIDStr( ":" ); 3007 inL.setIDStr( ":" );
3003 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3008 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3004 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3009 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3005 inL.setResource( 0 ); 3010 inL.setResource( 0 );
3006 local->insertAddressee( inL , false); 3011 local->insertAddressee( inL , false);
3007 ++addedAddressee; 3012 ++addedAddressee;
3008 } 3013 }
3009 } else { 3014 } else {
3010 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 3015 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
3011 inR.setRevision( modifiedCalendar ); 3016 inR.setRevision( modifiedCalendar );
3012 remote->insertAddressee( inR, false ); 3017 remote->insertAddressee( inR, false );
3013 inR.setResource( 0 ); 3018 inR.setResource( 0 );
3014 local->insertAddressee( inR, false ); 3019 local->insertAddressee( inR, false );
3015 ++addedAddressee; 3020 ++addedAddressee;
3016 } else { 3021 } else {
3017 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 3022 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
3018 remote->removeAddressee( inR ); 3023 remote->removeAddressee( inR );
3019 ++deletedAddresseeR; 3024 ++deletedAddresseeR;
3020 } 3025 }
3021 } 3026 }
3022 } else { 3027 } else {
3023 ++filteredIN; 3028 ++filteredIN;
3024 } 3029 }
3025 } 3030 }
3026 } 3031 }
3027 ++incCounter; 3032 ++incCounter;
3028 } 3033 }
3029 er.clear(); 3034 er.clear();
3030 QStringList el = local->uidList(); 3035 QStringList el = local->uidList();
3031 modulo = (el.count()/10)+1; 3036 modulo = (el.count()/10)+1;
3032 3037
3033 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 3038 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
3034 incCounter = 0; 3039 incCounter = 0;
3035 while ( incCounter < el.count()) { 3040 while ( incCounter < el.count()) {
3036 qApp->processEvents(); 3041 qApp->processEvents();
3037 if (syncManager->isProgressBarCanceled()) 3042 if (syncManager->isProgressBarCanceled())
3038 return false; 3043 return false;
3039 if ( incCounter % modulo == 0 ) 3044 if ( incCounter % modulo == 0 )
3040 syncManager->showProgressBar(incCounter); 3045 syncManager->showProgressBar(incCounter);
3041 uid = el[ incCounter ]; 3046 uid = el[ incCounter ];
3042 bool skipIncidence = false; 3047 bool skipIncidence = false;
3043 if ( uid.left(19) == QString("last-syncAddressee-") ) 3048 if ( uid.left(19) == QString("last-syncAddressee-") )
3044 skipIncidence = true; 3049 skipIncidence = true;
3045 if ( !skipIncidence ) { 3050 if ( !skipIncidence ) {
3046 inL = local->findByUid( uid ); 3051 inL = local->findByUid( uid );
3047 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3052 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3048 inR = remote->findByUid( uid ); 3053 inR = remote->findByUid( uid );
3049 if ( inR.isEmpty() ){ 3054 if ( inR.isEmpty() ){
3050 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { 3055 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) {
3051 // no conflict ********** add or delete local 3056 // no conflict ********** add or delete local
3052 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3057 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3053 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 3058 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
3054 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3059 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3055 local->removeAddressee( inL ); 3060 local->removeAddressee( inL );
3056 ++deletedAddresseeL; 3061 ++deletedAddresseeL;
3057 } else { 3062 } else {
3058 if ( ! syncManager->mWriteBackExistingOnly ) { 3063 if ( ! syncManager->mWriteBackExistingOnly ) {
3059 inL.removeID(mCurrentSyncDevice ); 3064 inL.removeID(mCurrentSyncDevice );
3060 ++addedAddresseeR; 3065 ++addedAddresseeR;
3061 inL.setRevision( modifiedCalendar ); 3066 inL.setRevision( modifiedCalendar );
3062 local->insertAddressee( inL, false ); 3067 local->insertAddressee( inL, false );
3063 inR = inL; 3068 inR = inL;
3064 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 3069 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
3065 inR.setResource( 0 ); 3070 inR.setResource( 0 );
3066 remote->insertAddressee( inR, false ); 3071 remote->insertAddressee( inR, false );
3067 } 3072 }
3068 } 3073 }
3069 } else { 3074 } else {
3070 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 3075 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
3071 //qDebug("data %s ", inL.revision().toString().latin1()); 3076 //qDebug("data %s ", inL.revision().toString().latin1());
3072 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3077 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3073 local->removeAddressee( inL ); 3078 local->removeAddressee( inL );
3074 ++deletedAddresseeL; 3079 ++deletedAddresseeL;
3075 } else { 3080 } else {
3076 if ( ! syncManager->mWriteBackExistingOnly ) { 3081 if ( ! syncManager->mWriteBackExistingOnly ) {
3077 ++addedAddresseeR; 3082 ++addedAddresseeR;
3078 inL.setRevision( modifiedCalendar ); 3083 inL.setRevision( modifiedCalendar );
3079 local->insertAddressee( inL, false ); 3084 local->insertAddressee( inL, false );
3080 inR = inL; 3085 inR = inL;
3081 inR.setIDStr( ":" ); 3086 inR.setIDStr( ":" );
3082 inR.setResource( 0 ); 3087 inR.setResource( 0 );
3083 remote->insertAddressee( inR, false ); 3088 remote->insertAddressee( inR, false );
3084 } 3089 }
3085 } 3090 }
3086 } 3091 }
3087 } else { 3092 } else {
3088 ++filteredOUT; 3093 ++filteredOUT;
3089 } 3094 }
3090 } 3095 }
3091 } 3096 }
3092 } 3097 }
3093 ++incCounter; 3098 ++incCounter;
3094 } 3099 }
3095 el.clear(); 3100 el.clear();
3096 syncManager->hideProgressBar(); 3101 syncManager->hideProgressBar();
3097 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 3102 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
3098 // get rid of micro seconds 3103 // get rid of micro seconds
3099 QTime t = mLastAddressbookSync.time(); 3104 QTime t = mLastAddressbookSync.time();
3100 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 3105 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
3101 addresseeLSync.setRevision( mLastAddressbookSync ); 3106 addresseeLSync.setRevision( mLastAddressbookSync );
3102 addresseeRSync.setRevision( mLastAddressbookSync ); 3107 addresseeRSync.setRevision( mLastAddressbookSync );
3103 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 3108 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
3104 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 3109 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
3105 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 3110 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
3106 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 3111 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
3107 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 3112 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
3108 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 3113 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
3109 addresseeRSync.setNote( "" ) ; 3114 addresseeRSync.setNote( "" ) ;
3110 addresseeLSync.setNote( "" ); 3115 addresseeLSync.setNote( "" );
3111 3116
3112 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 3117 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
3113 remote->insertAddressee( addresseeRSync, false ); 3118 remote->insertAddressee( addresseeRSync, false );
3114 local->insertAddressee( addresseeLSync, false ); 3119 local->insertAddressee( addresseeLSync, false );
3115 QString mes; 3120 QString mes;
3116 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 %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); 3121 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 %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT );
3117 qDebug( mes ); 3122 qDebug( mes );
3118 mes = i18n("Local addressbook changed!\n") +mes; 3123 mes = i18n("Local addressbook changed!\n") +mes;
3119 if ( syncManager->mShowSyncSummary ) { 3124 if ( syncManager->mShowSyncSummary ) {
3120 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 3125 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
3121 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 3126 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
3122 qDebug("cancelled "); 3127 qDebug("cancelled ");
3123 return false; 3128 return false;
3124 } 3129 }
3125 } 3130 }
3126 return syncOK; 3131 return syncOK;
3127} 3132}
3128 3133
3129 3134
3130//this is a overwritten callbackmethods from the syncinterface 3135//this is a overwritten callbackmethods from the syncinterface
3131bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 3136bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
3132{ 3137{
3133 3138
3134 //pending prepare addresseeview for output 3139 //pending prepare addresseeview for output
3135 //pending detect, if remote file has REV field. if not switch to external sync 3140 //pending detect, if remote file has REV field. if not switch to external sync
3136 mGlobalSyncMode = SYNC_MODE_NORMAL; 3141 mGlobalSyncMode = SYNC_MODE_NORMAL;
3137 if ( manager != syncManager ) 3142 if ( manager != syncManager )
3138 qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); 3143 qDebug("KABCore::sync:: ERROR! :: manager != syncManager ");
3139 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3144 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3140 3145
3141 AddressBook abLocal(filename,"syncContact"); 3146 AddressBook abLocal(filename,"syncContact");
3142 bool syncOK = false; 3147 bool syncOK = false;
3143 if ( abLocal.load() ) { 3148 if ( abLocal.load() ) {
3144 qDebug("Sync:AB loaded %s,sync mode %d",filename.latin1(), mode ); 3149 qDebug("Sync:AB loaded %s,sync mode %d",filename.latin1(), mode );
3145 bool external = false; 3150 bool external = false;
3146 bool isXML = false; 3151 bool isXML = false;
3147 if ( filename.right(4) == ".xml") { 3152 if ( filename.right(4) == ".xml") {
3148 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3153 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3149 isXML = true; 3154 isXML = true;
3150 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3155 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3151 } else { 3156 } else {
3152 external = !manager->mIsKapiFile; 3157 external = !manager->mIsKapiFile;
3153 if ( external ) { 3158 if ( external ) {
3154 qDebug("Sync:Setting vcf mode to external "); 3159 qDebug("Sync:Setting vcf mode to external ");
3155 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3160 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3156 AddressBook::Iterator it; 3161 AddressBook::Iterator it;
3157 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3162 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3158 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 3163 (*it).setID( mCurrentSyncDevice, (*it).uid() );
3159 (*it).computeCsum( mCurrentSyncDevice ); 3164 (*it).computeCsum( mCurrentSyncDevice );
3160 } 3165 }
3161 } 3166 }
3162 } 3167 }
3163 //AddressBook::Iterator it; 3168 //AddressBook::Iterator it;
3164 //QStringList vcards; 3169 //QStringList vcards;
3165 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3170 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3166 // qDebug("Name %s ", (*it).familyName().latin1()); 3171 // qDebug("Name %s ", (*it).familyName().latin1());
3167 //} 3172 //}
3168 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 3173 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
3169 if ( syncOK ) { 3174 if ( syncOK ) {
3170 if ( syncManager->mWriteBackFile ) 3175 if ( syncManager->mWriteBackFile )
3171 { 3176 {
3172 if ( external ) 3177 if ( external )
3173 abLocal.removeSyncAddressees( !isXML); 3178 abLocal.removeSyncAddressees( !isXML);
3174 qDebug("Sync:Saving remote AB "); 3179 qDebug("Sync:Saving remote AB ");
3175 if ( ! abLocal.saveAB()) 3180 if ( ! abLocal.saveAB())
3176 qDebug("Error writing back AB to file "); 3181 qDebug("Error writing back AB to file ");
3177 if ( external ) { 3182 if ( external ) {
3178 // afterwrite processing 3183 // afterwrite processing
3179 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 3184 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
3180 } 3185 }
3181 } 3186 }
3182 } 3187 }
3183 setModified(); 3188 setModified();
3184 3189
3185 } 3190 }
3186 abLocal.removeResources(); 3191 abLocal.removeResources();
3187 if ( syncOK ) 3192 if ( syncOK )
3188 mViewManager->refreshView(); 3193 mViewManager->refreshView();
3189 return syncOK; 3194 return syncOK;
3190 3195
3191} 3196}
3192void KABCore::removeSyncInfo( QString syncProfile) 3197void KABCore::removeSyncInfo( QString syncProfile)
3193{ 3198{
3194 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3199 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3195 mAddressBook->removeSyncInfo( syncProfile ); 3200 mAddressBook->removeSyncInfo( syncProfile );
3196 setModified(); 3201 setModified();
3197} 3202}
3198 3203
3199 3204
3200//this is a overwritten callbackmethods from the syncinterface 3205//this is a overwritten callbackmethods from the syncinterface
3201bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3206bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3202{ 3207{
3203 if ( resource == "phone" ) 3208 if ( resource == "phone" )
3204 return syncPhone(); 3209 return syncPhone();
3205 disableBR( true ); 3210 disableBR( true );
3206 if ( manager != syncManager ) 3211 if ( manager != syncManager )
3207 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); 3212 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3208 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3213 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3209 3214
3210 AddressBook abLocal( resource,"syncContact"); 3215 AddressBook abLocal( resource,"syncContact");
3211 bool syncOK = false; 3216 bool syncOK = false;
3212 message(i18n("Loading DTM address data..."), false); 3217 message(i18n("Loading DTM address data..."), false);
3213 if ( abLocal.load() ) { 3218 if ( abLocal.load() ) {
3214 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3219 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3215 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3220 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3216 message(i18n("Sync preprocessing..."),false); 3221 message(i18n("Sync preprocessing..."),false);
3217 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3222 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3218 message(i18n("Synchronizing..."),false); 3223 message(i18n("Synchronizing..."),false);
3219 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3224 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3220 if ( syncOK ) { 3225 if ( syncOK ) {
3221 if ( syncManager->mWriteBackFile ) { 3226 if ( syncManager->mWriteBackFile ) {
3222 abLocal.removeSyncAddressees( false ); 3227 abLocal.removeSyncAddressees( false );
3223 message(i18n("Saving DTM address data..."),false); 3228 message(i18n("Saving DTM address data..."),false);
3224 abLocal.saveAB(); 3229 abLocal.saveAB();
3225 message(i18n("Sync postprocessing..."),false); 3230 message(i18n("Sync postprocessing..."),false);
3226 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3231 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3227 } 3232 }
3228 } else 3233 } else
3229 message( i18n("Sync cancelled or failed.") ); 3234 message( i18n("Sync cancelled or failed.") );
3230 setModified(); 3235 setModified();
3231 } 3236 }
3232 abLocal.removeResources(); 3237 abLocal.removeResources();
3233 if ( syncOK ) { 3238 if ( syncOK ) {
3234 mViewManager->refreshView(); 3239 mViewManager->refreshView();
3235 message(i18n("DTM syncing finished.")); 3240 message(i18n("DTM syncing finished."));
3236 } 3241 }
3237 disableBR( false ); 3242 disableBR( false );
3238 return syncOK; 3243 return syncOK;
3239 3244
3240} 3245}
3241void KABCore::message( QString m, bool startTimer) 3246void KABCore::message( QString m, bool startTimer)
3242{ 3247{
3243 topLevelWidget()->setCaption( m ); 3248 topLevelWidget()->setCaption( m );
3244 qApp->processEvents(); 3249 qApp->processEvents();
3245 if ( startTimer ) 3250 if ( startTimer )
3246 mMessageTimer->start( 15000, true ); 3251 mMessageTimer->start( 15000, true );
3247 else 3252 else
3248 mMessageTimer->stop(); 3253 mMessageTimer->stop();
3249} 3254}
3250bool KABCore::syncPhone() 3255bool KABCore::syncPhone()
3251{ 3256{
3252 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3257 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3253 QString fileName = getPhoneFile(); 3258 QString fileName = getPhoneFile();
3254 if ( !PhoneAccess::readFromPhone( fileName) ) { 3259 if ( !PhoneAccess::readFromPhone( fileName) ) {
3255 message(i18n("Phone access failed!")); 3260 message(i18n("Phone access failed!"));
3256 return false; 3261 return false;
3257 } 3262 }
3258 AddressBook abLocal( fileName,"syncContact"); 3263 AddressBook abLocal( fileName,"syncContact");
3259 bool syncOK = false; 3264 bool syncOK = false;
3260 { 3265 {
3261 abLocal.importFromFile( fileName ); 3266 abLocal.importFromFile( fileName );
3262 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3267 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
3263 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3268 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3264 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 3269 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
3265 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3270 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3266 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3271 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3267 if ( syncOK ) { 3272 if ( syncOK ) {
3268 if ( syncManager->mWriteBackFile ) { 3273 if ( syncManager->mWriteBackFile ) {
3269 abLocal.removeSyncAddressees( true ); 3274 abLocal.removeSyncAddressees( true );
3270 abLocal.saveABphone( fileName ); 3275 abLocal.saveABphone( fileName );
3271 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 3276 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
3272 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 3277 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
3273 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3278 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3274 } 3279 }
3275 } 3280 }
3276 setModified(); 3281 setModified();
3277 } 3282 }
3278 abLocal.removeResources(); 3283 abLocal.removeResources();
3279 if ( syncOK ) 3284 if ( syncOK )
3280 mViewManager->refreshView(); 3285 mViewManager->refreshView();
3281 return syncOK; 3286 return syncOK;
3282} 3287}
3283void KABCore::getFile( bool success ) 3288void KABCore::getFile( bool success )
3284{ 3289{
3285 if ( ! success ) { 3290 if ( ! success ) {
3286 message( i18n("Error receiving file. Nothing changed!") ); 3291 message( i18n("Error receiving file. Nothing changed!") );
3287 return; 3292 return;
3288 } 3293 }
3289 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 3294 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
3290 if ( count ) 3295 if ( count )
3291 setModified( true ); 3296 setModified( true );
3292 message( i18n("Pi-Sync successful!") ); 3297 message( i18n("Pi-Sync successful!") );
3293 mViewManager->refreshView(); 3298 mViewManager->refreshView();
3294} 3299}
3295void KABCore::syncFileRequest() 3300void KABCore::syncFileRequest()
3296{ 3301{
3297 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 3302 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
3298 syncManager->slotSyncMenu( 999 ); 3303 syncManager->slotSyncMenu( 999 );
3299 } 3304 }
3300 mAddressBook->export2File( sentSyncFile() ); 3305 mAddressBook->export2File( sentSyncFile() );
3301} 3306}
3302QString KABCore::sentSyncFile() 3307QString KABCore::sentSyncFile()
3303{ 3308{
3304#ifdef DESKTOP_VERSION 3309#ifdef DESKTOP_VERSION
3305 return locateLocal( "tmp", "copysyncab.vcf" ); 3310 return locateLocal( "tmp", "copysyncab.vcf" );
3306#else 3311#else
3307 return QString( "/tmp/copysyncab.vcf" ); 3312 return QString( "/tmp/copysyncab.vcf" );
3308#endif 3313#endif
3309} 3314}
3310 3315
3311void KABCore::setCaptionBack() 3316void KABCore::setCaptionBack()
3312{ 3317{
3313 mMessageTimer->stop(); 3318 mMessageTimer->stop();
3314 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 3319 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
3315} 3320}
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp
index ecd6f05..7022dcb 100644
--- a/kaddressbook/views/kaddressbooktableview.cpp
+++ b/kaddressbook/views/kaddressbooktableview.cpp
@@ -1,473 +1,473 @@
1// $Id$ 1// $Id$
2 2
3#include <qvbox.h> 3#include <qvbox.h>
4#include <qlistbox.h> 4#include <qlistbox.h>
5#include <qwidget.h> 5#include <qwidget.h>
6#include <qfile.h> 6#include <qfile.h>
7#include <qimage.h> 7#include <qimage.h>
8#include <qcombobox.h> 8#include <qcombobox.h>
9#include <qapplication.h> 9#include <qapplication.h>
10#include <qdragobject.h> 10#include <qdragobject.h>
11#include <qevent.h> 11#include <qevent.h>
12#include <qurl.h> 12#include <qurl.h>
13#include <qpixmap.h> 13#include <qpixmap.h>
14 14
15#include <kabc/addressbook.h> 15#include <kabc/addressbook.h>
16#include <kapplication.h> 16#include <kapplication.h>
17#include <kconfig.h> 17#include <kconfig.h>
18#include <kcolorbutton.h> 18#include <kcolorbutton.h>
19#include <kdebug.h> 19#include <kdebug.h>
20#include <kglobal.h> 20#include <kglobal.h>
21#include <kiconloader.h> 21#include <kiconloader.h>
22#include <klineedit.h> 22#include <klineedit.h>
23#include <klocale.h> 23#include <klocale.h>
24#include <kmessagebox.h> 24#include <kmessagebox.h>
25#include <kurl.h> 25#include <kurl.h>
26#include <kurlrequester.h> 26#include <kurlrequester.h>
27 27
28//US#include "configuretableviewdialog.h" 28//US#include "configuretableviewdialog.h"
29#include "contactlistview.h" 29#include "contactlistview.h"
30#include "kabprefs.h" 30#include "kabprefs.h"
31#include "undocmds.h" 31#include "undocmds.h"
32#include "viewmanager.h" 32#include "viewmanager.h"
33 33
34#include <qlayout.h> 34#include <qlayout.h>
35#include <qheader.h> 35#include <qheader.h>
36#include <qregexp.h> 36#include <qregexp.h>
37 37
38#include "kaddressbooktableview.h" 38#include "kaddressbooktableview.h"
39 39
40 40
41KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, 41KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab,
42 QWidget *parent, const char *name ) 42 QWidget *parent, const char *name )
43 : KAddressBookView( ab, parent, name ) 43 : KAddressBookView( ab, parent, name )
44{ 44{
45 mainLayout = new QVBoxLayout( viewWidget(), 2 ); 45 mainLayout = new QVBoxLayout( viewWidget(), 2 );
46 46
47 // The list view will be created when the config is read. 47 // The list view will be created when the config is read.
48 mListView = 0; 48 mListView = 0;
49} 49}
50 50
51KAddressBookTableView::~KAddressBookTableView() 51KAddressBookTableView::~KAddressBookTableView()
52{ 52{
53} 53}
54void KAddressBookTableView::setFocusAV() 54void KAddressBookTableView::setFocusAV()
55{ 55{
56 if ( mListView ) 56 if ( mListView )
57 mListView->setFocus(); 57 mListView->setFocus();
58 58
59} 59}
60void KAddressBookTableView::scrollUP() 60void KAddressBookTableView::scrollUP()
61{ 61{
62 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); 62 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
63 QApplication::postEvent( mListView, ev ); 63 QApplication::postEvent( mListView, ev );
64} 64}
65void KAddressBookTableView::scrollDOWN() 65void KAddressBookTableView::scrollDOWN()
66{ 66{
67 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); 67 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
68 QApplication::postEvent( mListView, ev ); 68 QApplication::postEvent( mListView, ev );
69} 69}
70void KAddressBookTableView::reconstructListView() 70void KAddressBookTableView::reconstructListView()
71{ 71{
72 if (mListView) 72 if (mListView)
73 { 73 {
74 disconnect(mListView, SIGNAL(selectionChanged()), 74 disconnect(mListView, SIGNAL(selectionChanged()),
75 this, SLOT(addresseeSelected())); 75 this, SLOT(addresseeSelected()));
76 disconnect(mListView, SIGNAL(executed(QListViewItem*)), 76 disconnect(mListView, SIGNAL(executed(QListViewItem*)),
77 this, SLOT(addresseeExecuted(QListViewItem*))); 77 this, SLOT(addresseeExecuted(QListViewItem*)));
78 disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 78 disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
79 this, SLOT(addresseeExecuted(QListViewItem*))); 79 this, SLOT(addresseeExecuted(QListViewItem*)));
80 disconnect(mListView, SIGNAL(startAddresseeDrag()), this, 80 disconnect(mListView, SIGNAL(startAddresseeDrag()), this,
81 SIGNAL(startDrag())); 81 SIGNAL(startDrag()));
82 disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), 82 disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)),
83 this, SLOT(addresseeExecuted(QListViewItem*))); 83 this, SLOT(addresseeExecuted(QListViewItem*)));
84 84
85 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 85 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
86 SIGNAL(dropped(QDropEvent*))); 86 SIGNAL(dropped(QDropEvent*)));
87 delete mListView; 87 delete mListView;
88 } 88 }
89 89
90 mListView = new ContactListView( this, addressBook(), viewWidget() ); 90 mListView = new ContactListView( this, addressBook(), viewWidget() );
91 91
92 connect(this, SIGNAL(printView()), 92 connect(this, SIGNAL(printView()),
93 mListView , SLOT(printMe())); 93 mListView , SLOT(printMe()));
94 //US set singleClick manually, because it is no global configparameter in embedded space 94 //US set singleClick manually, because it is no global configparameter in embedded space
95 mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick); 95 mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick);
96 96
97 // Add the columns 97 // Add the columns
98 KABC::Field::List fieldList = fields(); 98 KABC::Field::List fieldList = fields();
99 KABC::Field::List::ConstIterator it; 99 KABC::Field::List::ConstIterator it;
100 100
101 int c = 0; 101 int c = 0;
102 for( it = fieldList.begin(); it != fieldList.end(); ++it ) { 102 for( it = fieldList.begin(); it != fieldList.end(); ++it ) {
103 mListView->addColumn( (*it)->label() ); 103 mListView->addColumn( (*it)->label() );
104 mListView->setColumnWidthMode(c++, QListView::Manual); 104 mListView->setColumnWidthMode(c++, QListView::Manual);
105//US 105//US
106 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); 106 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1());
107 } 107 }
108 108
109 connect(mListView, SIGNAL(selectionChanged()), 109 connect(mListView, SIGNAL(selectionChanged()),
110 this, SLOT(addresseeSelected())); 110 this, SLOT(addresseeSelected()));
111 connect(mListView, SIGNAL(startAddresseeDrag()), this, 111 connect(mListView, SIGNAL(startAddresseeDrag()), this,
112 SIGNAL(startDrag())); 112 SIGNAL(startDrag()));
113 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 113 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
114 SIGNAL(dropped(QDropEvent*))); 114 SIGNAL(dropped(QDropEvent*)));
115 115
116 if (KABPrefs::instance()->mHonorSingleClick) { 116 if (KABPrefs::instance()->mHonorSingleClick) {
117 // qDebug("KAddressBookTableView::reconstructListView single"); 117 // qDebug("KAddressBookTableView::reconstructListView single");
118 connect(mListView, SIGNAL(executed(QListViewItem*)), 118 connect(mListView, SIGNAL(executed(QListViewItem*)),
119 this, SLOT(addresseeExecuted(QListViewItem*))); 119 this, SLOT(addresseeExecuted(QListViewItem*)));
120 } else { 120 } else {
121 // qDebug("KAddressBookTableView::reconstructListView double"); 121 // qDebug("KAddressBookTableView::reconstructListView double");
122 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 122 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
123 this, SLOT(addresseeExecuted(QListViewItem*))); 123 this, SLOT(addresseeExecuted(QListViewItem*)));
124 } 124 }
125 connect(mListView, SIGNAL(returnPressed(QListViewItem*)), 125 connect(mListView, SIGNAL(returnPressed(QListViewItem*)),
126 this, SLOT(addresseeExecuted(QListViewItem*))); 126 this, SLOT(addresseeExecuted(QListViewItem*)));
127 connect(mListView, SIGNAL(signalDelete()), 127 connect(mListView, SIGNAL(signalDelete()),
128 this, SLOT(addresseeDeleted())); 128 this, SLOT(addresseeDeleted()));
129 129
130//US performceimprovement. Refresh is done from the outside 130//US performceimprovement. Refresh is done from the outside
131//US refresh(); 131//US refresh();
132 132
133 mListView->setSorting( 0, true ); 133 mListView->setSorting( 0, true );
134 mainLayout->addWidget( mListView ); 134 mainLayout->addWidget( mListView );
135 mainLayout->activate(); 135 mainLayout->activate();
136 mListView->show(); 136 mListView->show();
137} 137}
138 138
139void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) 139void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field )
140{ 140{
141 mListView->clear(); 141 mListView->clear();
142 if ( s.isEmpty() || s == "*" ) { 142 if ( s.isEmpty() || s == "*" ) {
143 refresh(); 143 refresh();
144 return; 144 return;
145 } 145 }
146 QString pattern = s.lower()+"*"; 146 QString pattern = s.lower()+"*";
147 QRegExp re; 147 QRegExp re;
148 re.setWildcard(true); // most people understand these better. 148 re.setWildcard(true); // most people understand these better.
149 re.setCaseSensitive(false); 149 re.setCaseSensitive(false);
150 re.setPattern( pattern ); 150 re.setPattern( pattern );
151 if (!re.isValid()) 151 if (!re.isValid())
152 return; 152 return;
153 KABC::Addressee::List addresseeList = addressees(); 153 KABC::Addressee::List addresseeList = addressees();
154 KABC::Addressee::List::Iterator it; 154 KABC::Addressee::List::Iterator it;
155 if ( field ) { 155 if ( field ) {
156 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 156 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
157 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 157 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
158 continue; 158 continue;
159#if QT_VERSION >= 300 159#if QT_VERSION >= 300
160 if (re.search(field->value( *it ).lower()) != -1) 160 if (re.search(field->value( *it ).lower()) == 0)
161#else 161#else
162 if (re.match(field->value( *it ).lower()) != -1) 162 if (re.match(field->value( *it ).lower()) != -1)
163#endif 163#endif
164 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 164 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
165 165
166 } 166 }
167 } else { 167 } else {
168 KABC::Field::List fieldList = allFields(); 168 KABC::Field::List fieldList = allFields();
169 KABC::Field::List::ConstIterator fieldIt; 169 KABC::Field::List::ConstIterator fieldIt;
170 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 170 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
171 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 171 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
172 continue; 172 continue;
173 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 173 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
174#if QT_VERSION >= 300 174#if QT_VERSION >= 300
175 if (re.search((*fieldIt)->value( *it ).lower()) != -1) 175 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
176#else 176#else
177 if (re.match((*fieldIt)->value( *it ).lower()) != -1) 177 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
178#endif 178#endif
179 { 179 {
180 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 180 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
181 break; 181 break;
182 } 182 }
183 } 183 }
184 } 184 }
185 } 185 }
186 // Sometimes the background pixmap gets messed up when we add lots 186 // Sometimes the background pixmap gets messed up when we add lots
187 // of items. 187 // of items.
188 mListView->repaint(); 188 mListView->repaint();
189 if ( mListView->firstChild() ) { 189 if ( mListView->firstChild() ) {
190 mListView->setCurrentItem ( mListView->firstChild() ); 190 mListView->setCurrentItem ( mListView->firstChild() );
191 mListView->setSelected ( mListView->firstChild(), true ); 191 mListView->setSelected ( mListView->firstChild(), true );
192 } 192 }
193 else 193 else
194 emit selected(QString::null); 194 emit selected(QString::null);
195 195
196} 196}
197void KAddressBookTableView::writeConfig(KConfig *config) 197void KAddressBookTableView::writeConfig(KConfig *config)
198{ 198{
199 KAddressBookView::writeConfig(config); 199 KAddressBookView::writeConfig(config);
200 200
201 mListView->saveLayout(config, config->group()); 201 mListView->saveLayout(config, config->group());
202} 202}
203 203
204void KAddressBookTableView::readConfig(KConfig *config) 204void KAddressBookTableView::readConfig(KConfig *config)
205{ 205{
206 KAddressBookView::readConfig( config ); 206 KAddressBookView::readConfig( config );
207 // The config could have changed the fields, so we need to reconstruct 207 // The config could have changed the fields, so we need to reconstruct
208 // the listview. 208 // the listview.
209 reconstructListView(); 209 reconstructListView();
210 210
211 // costum colors? 211 // costum colors?
212 if ( config->readBoolEntry( "EnableCustomColors", false ) ) 212 if ( config->readBoolEntry( "EnableCustomColors", false ) )
213 { 213 {
214 QPalette p( mListView->palette() ); 214 QPalette p( mListView->palette() );
215 QColor c = p.color(QPalette::Normal, QColorGroup::Base ); 215 QColor c = p.color(QPalette::Normal, QColorGroup::Base );
216 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); 216 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) );
217 c = p.color(QPalette::Normal, QColorGroup::Text ); 217 c = p.color(QPalette::Normal, QColorGroup::Text );
218 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); 218 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) );
219 c = p.color(QPalette::Normal, QColorGroup::Button ); 219 c = p.color(QPalette::Normal, QColorGroup::Button );
220 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); 220 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) );
221 c = p.color(QPalette::Normal, QColorGroup::ButtonText ); 221 c = p.color(QPalette::Normal, QColorGroup::ButtonText );
222 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); 222 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) );
223 c = p.color(QPalette::Normal, QColorGroup::Highlight ); 223 c = p.color(QPalette::Normal, QColorGroup::Highlight );
224 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); 224 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) );
225 c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); 225 c = p.color(QPalette::Normal, QColorGroup::HighlightedText );
226 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); 226 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) );
227#ifndef KAB_EMBEDDED 227#ifndef KAB_EMBEDDED
228 c = KGlobalSettings::alternateBackgroundColor(); 228 c = KGlobalSettings::alternateBackgroundColor();
229#else //KAB_EMBEDDED 229#else //KAB_EMBEDDED
230 c = QColor(240, 240, 240); 230 c = QColor(240, 240, 240);
231#endif //KAB_EMBEDDED 231#endif //KAB_EMBEDDED
232 c = config->readColorEntry ("AlternatingBackgroundColor", &c); 232 c = config->readColorEntry ("AlternatingBackgroundColor", &c);
233 mListView->setAlternateColor(c); 233 mListView->setAlternateColor(c);
234 234
235 235
236 //US mListView->viewport()->setPalette( p ); 236 //US mListView->viewport()->setPalette( p );
237 mListView->setPalette( p ); 237 mListView->setPalette( p );
238 } 238 }
239 else 239 else
240 { 240 {
241 // needed if turned off during a session. 241 // needed if turned off during a session.
242 //US mListView->viewport()->setPalette( mListView->palette() ); 242 //US mListView->viewport()->setPalette( mListView->palette() );
243 mListView->setPalette( mListView->palette() ); 243 mListView->setPalette( mListView->palette() );
244 } 244 }
245 245
246 //custom fonts? 246 //custom fonts?
247 QFont f( font() ); 247 QFont f( font() );
248 if ( config->readBoolEntry( "EnableCustomFonts", false ) ) 248 if ( config->readBoolEntry( "EnableCustomFonts", false ) )
249 { 249 {
250 mListView->setFont( config->readFontEntry( "TextFont", &f) ); 250 mListView->setFont( config->readFontEntry( "TextFont", &f) );
251 f.setBold( true ); 251 f.setBold( true );
252 //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); 252 //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) );
253 mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); 253 mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) );
254 } 254 }
255 else 255 else
256 { 256 {
257 mListView->setFont( f ); 257 mListView->setFont( f );
258 f.setBold( true ); 258 f.setBold( true );
259 //US mListView->setHeaderFont( f ); 259 //US mListView->setHeaderFont( f );
260 mListView->header()->setFont( f ); 260 mListView->header()->setFont( f );
261 } 261 }
262 262
263 // Set the list view options 263 // Set the list view options
264 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", 264 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground",
265 true)); 265 true));
266 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); 266 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false));
267 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); 267 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true));
268 268
269 if (config->readBoolEntry("Background", false)) 269 if (config->readBoolEntry("Background", false))
270 mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); 270 mListView->setBackgroundPixmap(config->readEntry("BackgroundName"));
271 271
272 // Restore the layout of the listview 272 // Restore the layout of the listview
273 mListView->restoreLayout(config, config->group()); 273 mListView->restoreLayout(config, config->group());
274} 274}
275 275
276void KAddressBookTableView::refresh(QString uid) 276void KAddressBookTableView::refresh(QString uid)
277{ 277{
278 // For now just repopulate. In reality this method should 278 // For now just repopulate. In reality this method should
279 // check the value of uid, and if valid iterate through 279 // check the value of uid, and if valid iterate through
280 // the listview to find the entry, then tell it to refresh. 280 // the listview to find the entry, then tell it to refresh.
281 281
282 if (uid.isNull()) { 282 if (uid.isNull()) {
283 // Clear the list view 283 // Clear the list view
284 QString currentUID, nextUID; 284 QString currentUID, nextUID;
285#ifndef KAB_EMBEDDED 285#ifndef KAB_EMBEDDED
286 ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); 286 ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() );
287#else //KAB_EMBEDDED 287#else //KAB_EMBEDDED
288 ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); 288 ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() );
289#endif //KAB_EMBEDDED 289#endif //KAB_EMBEDDED
290 290
291 if ( currentItem ) { 291 if ( currentItem ) {
292#ifndef KAB_EMBEDDED 292#ifndef KAB_EMBEDDED
293 ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); 293 ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() );
294#else //KAB_EMBEDDED 294#else //KAB_EMBEDDED
295 ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); 295 ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() );
296#endif //KAB_EMBEDDED 296#endif //KAB_EMBEDDED
297 if ( nextItem ) 297 if ( nextItem )
298 nextUID = nextItem->addressee().uid(); 298 nextUID = nextItem->addressee().uid();
299 currentUID = currentItem->addressee().uid(); 299 currentUID = currentItem->addressee().uid();
300 } 300 }
301 301
302 mListView->clear(); 302 mListView->clear();
303 303
304 currentItem = 0; 304 currentItem = 0;
305 KABC::Addressee::List addresseeList = addressees(); 305 KABC::Addressee::List addresseeList = addressees();
306 KABC::Addressee::List::Iterator it; 306 KABC::Addressee::List::Iterator it;
307 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 307 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
308 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 308 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
309 continue; 309 continue;
310 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 310 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
311 if ( (*it).uid() == currentUID ) 311 if ( (*it).uid() == currentUID )
312 currentItem = item; 312 currentItem = item;
313 else if ( (*it).uid() == nextUID && !currentItem ) 313 else if ( (*it).uid() == nextUID && !currentItem )
314 currentItem = item; 314 currentItem = item;
315 } 315 }
316 316
317 // Sometimes the background pixmap gets messed up when we add lots 317 // Sometimes the background pixmap gets messed up when we add lots
318 // of items. 318 // of items.
319 mListView->repaint(); 319 mListView->repaint();
320 320
321 if ( currentItem ) { 321 if ( currentItem ) {
322 mListView->setCurrentItem( currentItem ); 322 mListView->setCurrentItem( currentItem );
323 mListView->ensureItemVisible( currentItem ); 323 mListView->ensureItemVisible( currentItem );
324 } 324 }
325 } else { 325 } else {
326 // Only need to update on entry. Iterate through and try to find it 326 // Only need to update on entry. Iterate through and try to find it
327 ContactListViewItem *ceItem; 327 ContactListViewItem *ceItem;
328 QListViewItemIterator it( mListView ); 328 QListViewItemIterator it( mListView );
329 while ( it.current() ) { 329 while ( it.current() ) {
330#ifndef KAB_EMBEDDED 330#ifndef KAB_EMBEDDED
331 ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); 331 ceItem = dynamic_cast<ContactListViewItem*>( it.current() );
332#else //KAB_EMBEDDED 332#else //KAB_EMBEDDED
333 ceItem = (ContactListViewItem*)( it.current() ); 333 ceItem = (ContactListViewItem*)( it.current() );
334#endif //KAB_EMBEDDED 334#endif //KAB_EMBEDDED
335 335
336 if ( ceItem && ceItem->addressee().uid() == uid ) { 336 if ( ceItem && ceItem->addressee().uid() == uid ) {
337 ceItem->refresh(); 337 ceItem->refresh();
338 return; 338 return;
339 } 339 }
340 ++it; 340 ++it;
341 } 341 }
342 342
343 refresh( QString::null ); 343 refresh( QString::null );
344 } 344 }
345} 345}
346 346
347QStringList KAddressBookTableView::selectedUids() 347QStringList KAddressBookTableView::selectedUids()
348{ 348{
349 QStringList uidList; 349 QStringList uidList;
350 QListViewItem *item; 350 QListViewItem *item;
351 ContactListViewItem *ceItem; 351 ContactListViewItem *ceItem;
352 352
353 for(item = mListView->firstChild(); item; item = item->itemBelow()) 353 for(item = mListView->firstChild(); item; item = item->itemBelow())
354 { 354 {
355 if (mListView->isSelected( item )) 355 if (mListView->isSelected( item ))
356 { 356 {
357#ifndef KAB_EMBEDDED 357#ifndef KAB_EMBEDDED
358 ceItem = dynamic_cast<ContactListViewItem*>(item); 358 ceItem = dynamic_cast<ContactListViewItem*>(item);
359#else //KAB_EMBEDDED 359#else //KAB_EMBEDDED
360 ceItem = (ContactListViewItem*)(item); 360 ceItem = (ContactListViewItem*)(item);
361#endif //KAB_EMBEDDED 361#endif //KAB_EMBEDDED
362 362
363 if (ceItem != 0L) 363 if (ceItem != 0L)
364 uidList << ceItem->addressee().uid(); 364 uidList << ceItem->addressee().uid();
365 } 365 }
366 } 366 }
367 if ( uidList.count() == 0 ) 367 if ( uidList.count() == 0 )
368 if ( mListView->currentItem() ) { 368 if ( mListView->currentItem() ) {
369 ceItem = (ContactListViewItem*)(mListView->currentItem()) ; 369 ceItem = (ContactListViewItem*)(mListView->currentItem()) ;
370 uidList << ceItem->addressee().uid(); 370 uidList << ceItem->addressee().uid();
371 } 371 }
372 372
373 return uidList; 373 return uidList;
374} 374}
375 375
376void KAddressBookTableView::setSelected(QString uid, bool selected) 376void KAddressBookTableView::setSelected(QString uid, bool selected)
377{ 377{
378 QListViewItem *item; 378 QListViewItem *item;
379 ContactListViewItem *ceItem; 379 ContactListViewItem *ceItem;
380 380
381 if (uid.isNull()) 381 if (uid.isNull())
382 { 382 {
383 mListView->selectAll(selected); 383 mListView->selectAll(selected);
384 } 384 }
385 else 385 else
386 { 386 {
387 for(item = mListView->firstChild(); item; item = item->itemBelow()) 387 for(item = mListView->firstChild(); item; item = item->itemBelow())
388 { 388 {
389#ifndef KAB_EMBEDDED 389#ifndef KAB_EMBEDDED
390 ceItem = dynamic_cast<ContactListViewItem*>(item); 390 ceItem = dynamic_cast<ContactListViewItem*>(item);
391#else //KAB_EMBEDDED 391#else //KAB_EMBEDDED
392 ceItem = (ContactListViewItem*)(item); 392 ceItem = (ContactListViewItem*)(item);
393#endif //KAB_EMBEDDED 393#endif //KAB_EMBEDDED
394 394
395 395
396 if ((ceItem != 0L) && (ceItem->addressee().uid() == uid)) 396 if ((ceItem != 0L) && (ceItem->addressee().uid() == uid))
397 { 397 {
398 mListView->setSelected(item, selected); 398 mListView->setSelected(item, selected);
399 399
400 if (selected) 400 if (selected)
401 mListView->ensureItemVisible(item); 401 mListView->ensureItemVisible(item);
402 } 402 }
403 } 403 }
404 } 404 }
405} 405}
406 406
407void KAddressBookTableView::addresseeSelected() 407void KAddressBookTableView::addresseeSelected()
408{ 408{
409 // We need to try to find the first selected item. This might not be the 409 // We need to try to find the first selected item. This might not be the
410 // last selected item, but when QListView is in multiselection mode, 410 // last selected item, but when QListView is in multiselection mode,
411 // there is no way to figure out which one was 411 // there is no way to figure out which one was
412 // selected last. 412 // selected last.
413 QListViewItem *item; 413 QListViewItem *item;
414 bool found =false; 414 bool found =false;
415 for (item = mListView->firstChild(); item && !found; 415 for (item = mListView->firstChild(); item && !found;
416 item = item->nextSibling()) 416 item = item->nextSibling())
417 { 417 {
418 if (item->isSelected()) 418 if (item->isSelected())
419 { 419 {
420 found = true; 420 found = true;
421#ifndef KAB_EMBEDDED 421#ifndef KAB_EMBEDDED
422 ContactListViewItem *ceItem 422 ContactListViewItem *ceItem
423 = dynamic_cast<ContactListViewItem*>(item); 423 = dynamic_cast<ContactListViewItem*>(item);
424#else //KAB_EMBEDDED 424#else //KAB_EMBEDDED
425 ContactListViewItem *ceItem 425 ContactListViewItem *ceItem
426 = (ContactListViewItem*)(item); 426 = (ContactListViewItem*)(item);
427#endif //KAB_EMBEDDED 427#endif //KAB_EMBEDDED
428 428
429 if ( ceItem ) emit selected(ceItem->addressee().uid()); 429 if ( ceItem ) emit selected(ceItem->addressee().uid());
430 } 430 }
431 } 431 }
432 432
433 if (!found) 433 if (!found)
434 emit selected(QString::null); 434 emit selected(QString::null);
435} 435}
436 436
437void KAddressBookTableView::addresseeExecuted(QListViewItem *item) 437void KAddressBookTableView::addresseeExecuted(QListViewItem *item)
438{ 438{
439 if (item) 439 if (item)
440 { 440 {
441#ifndef KAB_EMBEDDED 441#ifndef KAB_EMBEDDED
442 ContactListViewItem *ceItem 442 ContactListViewItem *ceItem
443 = dynamic_cast<ContactListViewItem*>(item); 443 = dynamic_cast<ContactListViewItem*>(item);
444#else //KAB_EMBEDDED 444#else //KAB_EMBEDDED
445 ContactListViewItem *ceItem 445 ContactListViewItem *ceItem
446 = (ContactListViewItem*)(item); 446 = (ContactListViewItem*)(item);
447#endif //KAB_EMBEDDED 447#endif //KAB_EMBEDDED
448 448
449 if (ceItem) 449 if (ceItem)
450 { 450 {
451 emit executed(ceItem->addressee().uid()); 451 emit executed(ceItem->addressee().uid());
452 } 452 }
453 } 453 }
454 else 454 else
455 { 455 {
456 emit executed(QString::null); 456 emit executed(QString::null);
457 } 457 }
458} 458}
459 459
460void KAddressBookTableView::addresseeDeleted() 460void KAddressBookTableView::addresseeDeleted()
461{ 461{
462 462
463 emit deleteRequest(); 463 emit deleteRequest();
464 464
465} 465}
466 466
467 467
468 468
469 469
470 470
471#ifndef KAB_EMBEDDED 471#ifndef KAB_EMBEDDED
472#include "kaddressbooktableview.moc" 472#include "kaddressbooktableview.moc"
473#endif //KAB_EMBEDDED 473#endif //KAB_EMBEDDED