summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-09-07 20:33:23 (UTC)
committer zautrix <zautrix>2004-09-07 20:33:23 (UTC)
commit64a8ef1629f523df3006de5cb2b9882a50d96a05 (patch) (unidiff)
treeb931dc5397b4eec926603080b20eddda131999ff
parent9d5c8750ae671e73ec8ebc0a71f30fd30680f2c0 (diff)
downloadkdepimpi-64a8ef1629f523df3006de5cb2b9882a50d96a05.zip
kdepimpi-64a8ef1629f523df3006de5cb2b9882a50d96a05.tar.gz
kdepimpi-64a8ef1629f523df3006de5cb2b9882a50d96a05.tar.bz2
Fixed Kopi-Kapi external app communication
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp2
-rw-r--r--kabc/stdaddressbook.cpp14
-rw-r--r--kaddressbook/kabcore.cpp19
-rw-r--r--korganizer/koeventviewer.cpp50
-rw-r--r--korganizer/mainwindow.cpp2
-rw-r--r--libkdepim/externalapphandler.cpp2
6 files changed, 68 insertions, 21 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index c61b387..47d298a 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -1,646 +1,646 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28/*US 28/*US
29 29
30#include <qfile.h> 30#include <qfile.h>
31#include <qregexp.h> 31#include <qregexp.h>
32#include <qtimer.h> 32#include <qtimer.h>
33 33
34#include <kapplication.h> 34#include <kapplication.h>
35#include <kinstance.h> 35#include <kinstance.h>
36#include <kstandarddirs.h> 36#include <kstandarddirs.h>
37 37
38#include "errorhandler.h" 38#include "errorhandler.h"
39*/ 39*/
40#include <qptrlist.h> 40#include <qptrlist.h>
41 41
42#include <kglobal.h> 42#include <kglobal.h>
43#include <klocale.h> 43#include <klocale.h>
44#include <kdebug.h> 44#include <kdebug.h>
45#include "addressbook.h" 45#include "addressbook.h"
46#include "resource.h" 46#include "resource.h"
47 47
48//US #include "addressbook.moc" 48//US #include "addressbook.moc"
49 49
50using namespace KABC; 50using namespace KABC;
51 51
52struct AddressBook::AddressBookData 52struct AddressBook::AddressBookData
53{ 53{
54 Addressee::List mAddressees; 54 Addressee::List mAddressees;
55 Addressee::List mRemovedAddressees; 55 Addressee::List mRemovedAddressees;
56 Field::List mAllFields; 56 Field::List mAllFields;
57 KConfig *mConfig; 57 KConfig *mConfig;
58 KRES::Manager<Resource> *mManager; 58 KRES::Manager<Resource> *mManager;
59//US ErrorHandler *mErrorHandler; 59//US ErrorHandler *mErrorHandler;
60}; 60};
61 61
62struct AddressBook::Iterator::IteratorData 62struct AddressBook::Iterator::IteratorData
63{ 63{
64 Addressee::List::Iterator mIt; 64 Addressee::List::Iterator mIt;
65}; 65};
66 66
67struct AddressBook::ConstIterator::ConstIteratorData 67struct AddressBook::ConstIterator::ConstIteratorData
68{ 68{
69 Addressee::List::ConstIterator mIt; 69 Addressee::List::ConstIterator mIt;
70}; 70};
71 71
72AddressBook::Iterator::Iterator() 72AddressBook::Iterator::Iterator()
73{ 73{
74 d = new IteratorData; 74 d = new IteratorData;
75} 75}
76 76
77AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) 77AddressBook::Iterator::Iterator( const AddressBook::Iterator &i )
78{ 78{
79 d = new IteratorData; 79 d = new IteratorData;
80 d->mIt = i.d->mIt; 80 d->mIt = i.d->mIt;
81} 81}
82 82
83AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) 83AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i )
84{ 84{
85 if( this == &i ) return *this; // guard against self assignment 85 if( this == &i ) return *this; // guard against self assignment
86 delete d; // delete the old data the Iterator was completely constructed before 86 delete d; // delete the old data the Iterator was completely constructed before
87 d = new IteratorData; 87 d = new IteratorData;
88 d->mIt = i.d->mIt; 88 d->mIt = i.d->mIt;
89 return *this; 89 return *this;
90} 90}
91 91
92AddressBook::Iterator::~Iterator() 92AddressBook::Iterator::~Iterator()
93{ 93{
94 delete d; 94 delete d;
95} 95}
96 96
97const Addressee &AddressBook::Iterator::operator*() const 97const Addressee &AddressBook::Iterator::operator*() const
98{ 98{
99 return *(d->mIt); 99 return *(d->mIt);
100} 100}
101 101
102Addressee &AddressBook::Iterator::operator*() 102Addressee &AddressBook::Iterator::operator*()
103{ 103{
104 return *(d->mIt); 104 return *(d->mIt);
105} 105}
106 106
107Addressee *AddressBook::Iterator::operator->() 107Addressee *AddressBook::Iterator::operator->()
108{ 108{
109 return &(*(d->mIt)); 109 return &(*(d->mIt));
110} 110}
111 111
112AddressBook::Iterator &AddressBook::Iterator::operator++() 112AddressBook::Iterator &AddressBook::Iterator::operator++()
113{ 113{
114 (d->mIt)++; 114 (d->mIt)++;
115 return *this; 115 return *this;
116} 116}
117 117
118AddressBook::Iterator &AddressBook::Iterator::operator++(int) 118AddressBook::Iterator &AddressBook::Iterator::operator++(int)
119{ 119{
120 (d->mIt)++; 120 (d->mIt)++;
121 return *this; 121 return *this;
122} 122}
123 123
124AddressBook::Iterator &AddressBook::Iterator::operator--() 124AddressBook::Iterator &AddressBook::Iterator::operator--()
125{ 125{
126 (d->mIt)--; 126 (d->mIt)--;
127 return *this; 127 return *this;
128} 128}
129 129
130AddressBook::Iterator &AddressBook::Iterator::operator--(int) 130AddressBook::Iterator &AddressBook::Iterator::operator--(int)
131{ 131{
132 (d->mIt)--; 132 (d->mIt)--;
133 return *this; 133 return *this;
134} 134}
135 135
136bool AddressBook::Iterator::operator==( const Iterator &it ) 136bool AddressBook::Iterator::operator==( const Iterator &it )
137{ 137{
138 return ( d->mIt == it.d->mIt ); 138 return ( d->mIt == it.d->mIt );
139} 139}
140 140
141bool AddressBook::Iterator::operator!=( const Iterator &it ) 141bool AddressBook::Iterator::operator!=( const Iterator &it )
142{ 142{
143 return ( d->mIt != it.d->mIt ); 143 return ( d->mIt != it.d->mIt );
144} 144}
145 145
146 146
147AddressBook::ConstIterator::ConstIterator() 147AddressBook::ConstIterator::ConstIterator()
148{ 148{
149 d = new ConstIteratorData; 149 d = new ConstIteratorData;
150} 150}
151 151
152AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) 152AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i )
153{ 153{
154 d = new ConstIteratorData; 154 d = new ConstIteratorData;
155 d->mIt = i.d->mIt; 155 d->mIt = i.d->mIt;
156} 156}
157 157
158AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) 158AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i )
159{ 159{
160 if( this == &i ) return *this; // guard for self assignment 160 if( this == &i ) return *this; // guard for self assignment
161 delete d; // delete the old data because the Iterator was really constructed before 161 delete d; // delete the old data because the Iterator was really constructed before
162 d = new ConstIteratorData; 162 d = new ConstIteratorData;
163 d->mIt = i.d->mIt; 163 d->mIt = i.d->mIt;
164 return *this; 164 return *this;
165} 165}
166 166
167AddressBook::ConstIterator::~ConstIterator() 167AddressBook::ConstIterator::~ConstIterator()
168{ 168{
169 delete d; 169 delete d;
170} 170}
171 171
172const Addressee &AddressBook::ConstIterator::operator*() const 172const Addressee &AddressBook::ConstIterator::operator*() const
173{ 173{
174 return *(d->mIt); 174 return *(d->mIt);
175} 175}
176 176
177const Addressee* AddressBook::ConstIterator::operator->() const 177const Addressee* AddressBook::ConstIterator::operator->() const
178{ 178{
179 return &(*(d->mIt)); 179 return &(*(d->mIt));
180} 180}
181 181
182AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() 182AddressBook::ConstIterator &AddressBook::ConstIterator::operator++()
183{ 183{
184 (d->mIt)++; 184 (d->mIt)++;
185 return *this; 185 return *this;
186} 186}
187 187
188AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) 188AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int)
189{ 189{
190 (d->mIt)++; 190 (d->mIt)++;
191 return *this; 191 return *this;
192} 192}
193 193
194AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() 194AddressBook::ConstIterator &AddressBook::ConstIterator::operator--()
195{ 195{
196 (d->mIt)--; 196 (d->mIt)--;
197 return *this; 197 return *this;
198} 198}
199 199
200AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) 200AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int)
201{ 201{
202 (d->mIt)--; 202 (d->mIt)--;
203 return *this; 203 return *this;
204} 204}
205 205
206bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) 206bool AddressBook::ConstIterator::operator==( const ConstIterator &it )
207{ 207{
208 return ( d->mIt == it.d->mIt ); 208 return ( d->mIt == it.d->mIt );
209} 209}
210 210
211bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) 211bool AddressBook::ConstIterator::operator!=( const ConstIterator &it )
212{ 212{
213 return ( d->mIt != it.d->mIt ); 213 return ( d->mIt != it.d->mIt );
214} 214}
215 215
216 216
217AddressBook::AddressBook() 217AddressBook::AddressBook()
218{ 218{
219 init(0, "contact"); 219 init(0, "contact");
220} 220}
221 221
222AddressBook::AddressBook( const QString &config ) 222AddressBook::AddressBook( const QString &config )
223{ 223{
224 init(config, "contact"); 224 init(config, "contact");
225} 225}
226 226
227AddressBook::AddressBook( const QString &config, const QString &family ) 227AddressBook::AddressBook( const QString &config, const QString &family )
228{ 228{
229 init(config, family); 229 init(config, family);
230 230
231} 231}
232 232
233// the default family is "contact" 233// the default family is "contact"
234void AddressBook::init(const QString &config, const QString &family ) 234void AddressBook::init(const QString &config, const QString &family )
235{ 235{
236 d = new AddressBookData; 236 d = new AddressBookData;
237 if (config != 0) { 237 if (config != 0) {
238 d->mConfig = new KConfig( locateLocal("config", config) ); 238 d->mConfig = new KConfig( locateLocal("config", config) );
239// qDebug("AddressBook::init 1 config=%s",config.latin1() ); 239// qDebug("AddressBook::init 1 config=%s",config.latin1() );
240 } 240 }
241 else { 241 else {
242 d->mConfig = 0; 242 d->mConfig = 0;
243// qDebug("AddressBook::init 1 config=0"); 243// qDebug("AddressBook::init 1 config=0");
244 } 244 }
245 245
246//US d->mErrorHandler = 0; 246//US d->mErrorHandler = 0;
247 d->mManager = new KRES::Manager<Resource>( family, false ); 247 d->mManager = new KRES::Manager<Resource>( family, false );
248 d->mManager->readConfig( d->mConfig ); 248 d->mManager->readConfig( d->mConfig );
249} 249}
250 250
251AddressBook::~AddressBook() 251AddressBook::~AddressBook()
252{ 252{
253 delete d->mConfig; d->mConfig = 0; 253 delete d->mConfig; d->mConfig = 0;
254 delete d->mManager; d->mManager = 0; 254 delete d->mManager; d->mManager = 0;
255//US delete d->mErrorHandler; d->mErrorHandler = 0; 255//US delete d->mErrorHandler; d->mErrorHandler = 0;
256 delete d; d = 0; 256 delete d; d = 0;
257} 257}
258 258
259bool AddressBook::load() 259bool AddressBook::load()
260{ 260{
261 261
262 262
263 clear(); 263 clear();
264 264
265 KRES::Manager<Resource>::ActiveIterator it; 265 KRES::Manager<Resource>::ActiveIterator it;
266 bool ok = true; 266 bool ok = true;
267 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 267 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
268 if ( !(*it)->load() ) { 268 if ( !(*it)->load() ) {
269 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); 269 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) );
270 ok = false; 270 ok = false;
271 } 271 }
272 272
273 // mark all addressees as unchanged 273 // mark all addressees as unchanged
274 Addressee::List::Iterator addrIt; 274 Addressee::List::Iterator addrIt;
275 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) 275 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt )
276 (*addrIt).setChanged( false ); 276 (*addrIt).setChanged( false );
277 277
278 return ok; 278 return ok;
279} 279}
280 280
281bool AddressBook::save( Ticket *ticket ) 281bool AddressBook::save( Ticket *ticket )
282{ 282{
283 kdDebug(5700) << "AddressBook::save()"<< endl; 283 kdDebug(5700) << "AddressBook::save()"<< endl;
284 284
285 if ( ticket->resource() ) { 285 if ( ticket->resource() ) {
286 deleteRemovedAddressees(); 286 deleteRemovedAddressees();
287 287
288 return ticket->resource()->save( ticket ); 288 return ticket->resource()->save( ticket );
289 } 289 }
290 290
291 return false; 291 return false;
292} 292}
293 293
294AddressBook::Iterator AddressBook::begin() 294AddressBook::Iterator AddressBook::begin()
295{ 295{
296 Iterator it = Iterator(); 296 Iterator it = Iterator();
297 it.d->mIt = d->mAddressees.begin(); 297 it.d->mIt = d->mAddressees.begin();
298 return it; 298 return it;
299} 299}
300 300
301AddressBook::ConstIterator AddressBook::begin() const 301AddressBook::ConstIterator AddressBook::begin() const
302{ 302{
303 ConstIterator it = ConstIterator(); 303 ConstIterator it = ConstIterator();
304 it.d->mIt = d->mAddressees.begin(); 304 it.d->mIt = d->mAddressees.begin();
305 return it; 305 return it;
306} 306}
307 307
308AddressBook::Iterator AddressBook::end() 308AddressBook::Iterator AddressBook::end()
309{ 309{
310 Iterator it = Iterator(); 310 Iterator it = Iterator();
311 it.d->mIt = d->mAddressees.end(); 311 it.d->mIt = d->mAddressees.end();
312 return it; 312 return it;
313} 313}
314 314
315AddressBook::ConstIterator AddressBook::end() const 315AddressBook::ConstIterator AddressBook::end() const
316{ 316{
317 ConstIterator it = ConstIterator(); 317 ConstIterator it = ConstIterator();
318 it.d->mIt = d->mAddressees.end(); 318 it.d->mIt = d->mAddressees.end();
319 return it; 319 return it;
320} 320}
321 321
322void AddressBook::clear() 322void AddressBook::clear()
323{ 323{
324 d->mAddressees.clear(); 324 d->mAddressees.clear();
325} 325}
326 326
327Ticket *AddressBook::requestSaveTicket( Resource *resource ) 327Ticket *AddressBook::requestSaveTicket( Resource *resource )
328{ 328{
329 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; 329 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl;
330 330
331 if ( !resource ) 331 if ( !resource )
332 { 332 {
333 qDebug("AddressBook::requestSaveTicket no resource" ); 333 qDebug("AddressBook::requestSaveTicket no resource" );
334 resource = standardResource(); 334 resource = standardResource();
335 } 335 }
336 336
337 KRES::Manager<Resource>::ActiveIterator it; 337 KRES::Manager<Resource>::ActiveIterator it;
338 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 338 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
339 if ( (*it) == resource ) { 339 if ( (*it) == resource ) {
340 if ( (*it)->readOnly() || !(*it)->isOpen() ) 340 if ( (*it)->readOnly() || !(*it)->isOpen() )
341 return 0; 341 return 0;
342 else 342 else
343 return (*it)->requestSaveTicket(); 343 return (*it)->requestSaveTicket();
344 } 344 }
345 } 345 }
346 346
347 return 0; 347 return 0;
348} 348}
349 349
350void AddressBook::insertAddressee( const Addressee &a ) 350void AddressBook::insertAddressee( const Addressee &a )
351{ 351{
352 Addressee::List::Iterator it; 352 Addressee::List::Iterator it;
353 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { 353 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) {
354 if ( a.uid() == (*it).uid() ) { 354 if ( a.uid() == (*it).uid() ) {
355 bool changed = false; 355 bool changed = false;
356 Addressee addr = a; 356 Addressee addr = a;
357 if ( addr != (*it) ) 357 if ( addr != (*it) )
358 changed = true; 358 changed = true;
359 359
360 (*it) = a; 360 (*it) = a;
361 if ( (*it).resource() == 0 ) 361 if ( (*it).resource() == 0 )
362 (*it).setResource( standardResource() ); 362 (*it).setResource( standardResource() );
363 363
364 if ( changed ) { 364 if ( changed ) {
365 (*it).setRevision( QDateTime::currentDateTime() ); 365 (*it).setRevision( QDateTime::currentDateTime() );
366 (*it).setChanged( true ); 366 (*it).setChanged( true );
367 } 367 }
368 368
369 return; 369 return;
370 } 370 }
371 } 371 }
372 d->mAddressees.append( a ); 372 d->mAddressees.append( a );
373 Addressee& addr = d->mAddressees.last(); 373 Addressee& addr = d->mAddressees.last();
374 if ( addr.resource() == 0 ) 374 if ( addr.resource() == 0 )
375 addr.setResource( standardResource() ); 375 addr.setResource( standardResource() );
376 376
377 addr.setChanged( true ); 377 addr.setChanged( true );
378} 378}
379 379
380void AddressBook::removeAddressee( const Addressee &a ) 380void AddressBook::removeAddressee( const Addressee &a )
381{ 381{
382 Iterator it; 382 Iterator it;
383 for ( it = begin(); it != end(); ++it ) { 383 for ( it = begin(); it != end(); ++it ) {
384 if ( a.uid() == (*it).uid() ) { 384 if ( a.uid() == (*it).uid() ) {
385 removeAddressee( it ); 385 removeAddressee( it );
386 return; 386 return;
387 } 387 }
388 } 388 }
389} 389}
390 390
391void AddressBook::removeAddressee( const Iterator &it ) 391void AddressBook::removeAddressee( const Iterator &it )
392{ 392{
393 d->mRemovedAddressees.append( (*it) ); 393 d->mRemovedAddressees.append( (*it) );
394 d->mAddressees.remove( it.d->mIt ); 394 d->mAddressees.remove( it.d->mIt );
395} 395}
396 396
397AddressBook::Iterator AddressBook::find( const Addressee &a ) 397AddressBook::Iterator AddressBook::find( const Addressee &a )
398{ 398{
399 Iterator it; 399 Iterator it;
400 for ( it = begin(); it != end(); ++it ) { 400 for ( it = begin(); it != end(); ++it ) {
401 if ( a.uid() == (*it).uid() ) { 401 if ( a.uid() == (*it).uid() ) {
402 return it; 402 return it;
403 } 403 }
404 } 404 }
405 return end(); 405 return end();
406} 406}
407 407
408Addressee AddressBook::findByUid( const QString &uid ) 408Addressee AddressBook::findByUid( const QString &uid )
409{ 409{
410 Iterator it; 410 Iterator it;
411 for ( it = begin(); it != end(); ++it ) { 411 for ( it = begin(); it != end(); ++it ) {
412 if ( uid == (*it).uid() ) { 412 if ( uid == (*it).uid() ) {
413 return *it; 413 return *it;
414 } 414 }
415 } 415 }
416 return Addressee(); 416 return Addressee();
417} 417}
418 418
419Addressee::List AddressBook::allAddressees() 419Addressee::List AddressBook::allAddressees()
420{ 420{
421 return d->mAddressees; 421 return d->mAddressees;
422} 422}
423 423
424Addressee::List AddressBook::findByName( const QString &name ) 424Addressee::List AddressBook::findByName( const QString &name )
425{ 425{
426 Addressee::List results; 426 Addressee::List results;
427 427
428 Iterator it; 428 Iterator it;
429 for ( it = begin(); it != end(); ++it ) { 429 for ( it = begin(); it != end(); ++it ) {
430 if ( name == (*it).name() ) { 430 if ( name == (*it).realName() ) {
431 results.append( *it ); 431 results.append( *it );
432 } 432 }
433 } 433 }
434 434
435 return results; 435 return results;
436} 436}
437 437
438Addressee::List AddressBook::findByEmail( const QString &email ) 438Addressee::List AddressBook::findByEmail( const QString &email )
439{ 439{
440 Addressee::List results; 440 Addressee::List results;
441 QStringList mailList; 441 QStringList mailList;
442 442
443 Iterator it; 443 Iterator it;
444 for ( it = begin(); it != end(); ++it ) { 444 for ( it = begin(); it != end(); ++it ) {
445 mailList = (*it).emails(); 445 mailList = (*it).emails();
446 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { 446 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) {
447 if ( email == (*ite) ) { 447 if ( email == (*ite) ) {
448 results.append( *it ); 448 results.append( *it );
449 } 449 }
450 } 450 }
451 } 451 }
452 452
453 return results; 453 return results;
454} 454}
455 455
456Addressee::List AddressBook::findByCategory( const QString &category ) 456Addressee::List AddressBook::findByCategory( const QString &category )
457{ 457{
458 Addressee::List results; 458 Addressee::List results;
459 459
460 Iterator it; 460 Iterator it;
461 for ( it = begin(); it != end(); ++it ) { 461 for ( it = begin(); it != end(); ++it ) {
462 if ( (*it).hasCategory( category) ) { 462 if ( (*it).hasCategory( category) ) {
463 results.append( *it ); 463 results.append( *it );
464 } 464 }
465 } 465 }
466 466
467 return results; 467 return results;
468} 468}
469 469
470void AddressBook::dump() const 470void AddressBook::dump() const
471{ 471{
472 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; 472 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl;
473 473
474 ConstIterator it; 474 ConstIterator it;
475 for( it = begin(); it != end(); ++it ) { 475 for( it = begin(); it != end(); ++it ) {
476 (*it).dump(); 476 (*it).dump();
477 } 477 }
478 478
479 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; 479 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl;
480} 480}
481 481
482QString AddressBook::identifier() 482QString AddressBook::identifier()
483{ 483{
484 QStringList identifier; 484 QStringList identifier;
485 485
486 486
487 KRES::Manager<Resource>::ActiveIterator it; 487 KRES::Manager<Resource>::ActiveIterator it;
488 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 488 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
489 if ( !(*it)->identifier().isEmpty() ) 489 if ( !(*it)->identifier().isEmpty() )
490 identifier.append( (*it)->identifier() ); 490 identifier.append( (*it)->identifier() );
491 } 491 }
492 492
493 return identifier.join( ":" ); 493 return identifier.join( ":" );
494} 494}
495 495
496Field::List AddressBook::fields( int category ) 496Field::List AddressBook::fields( int category )
497{ 497{
498 if ( d->mAllFields.isEmpty() ) { 498 if ( d->mAllFields.isEmpty() ) {
499 d->mAllFields = Field::allFields(); 499 d->mAllFields = Field::allFields();
500 } 500 }
501 501
502 if ( category == Field::All ) return d->mAllFields; 502 if ( category == Field::All ) return d->mAllFields;
503 503
504 Field::List result; 504 Field::List result;
505 Field::List::ConstIterator it; 505 Field::List::ConstIterator it;
506 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { 506 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) {
507 if ( (*it)->category() & category ) result.append( *it ); 507 if ( (*it)->category() & category ) result.append( *it );
508 } 508 }
509 509
510 return result; 510 return result;
511} 511}
512 512
513bool AddressBook::addCustomField( const QString &label, int category, 513bool AddressBook::addCustomField( const QString &label, int category,
514 const QString &key, const QString &app ) 514 const QString &key, const QString &app )
515{ 515{
516 if ( d->mAllFields.isEmpty() ) { 516 if ( d->mAllFields.isEmpty() ) {
517 d->mAllFields = Field::allFields(); 517 d->mAllFields = Field::allFields();
518 } 518 }
519//US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; 519//US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app;
520 QString a = app.isNull() ? KGlobal::getAppName() : app; 520 QString a = app.isNull() ? KGlobal::getAppName() : app;
521 521
522 QString k = key.isNull() ? label : key; 522 QString k = key.isNull() ? label : key;
523 523
524 Field *field = Field::createCustomField( label, category, k, a ); 524 Field *field = Field::createCustomField( label, category, k, a );
525 525
526 if ( !field ) return false; 526 if ( !field ) return false;
527 527
528 d->mAllFields.append( field ); 528 d->mAllFields.append( field );
529 529
530 return true; 530 return true;
531} 531}
532 532
533QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) 533QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab )
534{ 534{
535 if (!ab.d) return s; 535 if (!ab.d) return s;
536 536
537 return s << ab.d->mAddressees; 537 return s << ab.d->mAddressees;
538} 538}
539 539
540QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) 540QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab )
541{ 541{
542 if (!ab.d) return s; 542 if (!ab.d) return s;
543 543
544 s >> ab.d->mAddressees; 544 s >> ab.d->mAddressees;
545 545
546 return s; 546 return s;
547} 547}
548 548
549bool AddressBook::addResource( Resource *resource ) 549bool AddressBook::addResource( Resource *resource )
550{ 550{
551 if ( !resource->open() ) { 551 if ( !resource->open() ) {
552 kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; 552 kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl;
553 return false; 553 return false;
554 } 554 }
555 555
556 resource->setAddressBook( this ); 556 resource->setAddressBook( this );
557 557
558 d->mManager->add( resource ); 558 d->mManager->add( resource );
559 return true; 559 return true;
560} 560}
561 561
562bool AddressBook::removeResource( Resource *resource ) 562bool AddressBook::removeResource( Resource *resource )
563{ 563{
564 resource->close(); 564 resource->close();
565 565
566 if ( resource == standardResource() ) 566 if ( resource == standardResource() )
567 d->mManager->setStandardResource( 0 ); 567 d->mManager->setStandardResource( 0 );
568 568
569 resource->setAddressBook( 0 ); 569 resource->setAddressBook( 0 );
570 570
571 d->mManager->remove( resource ); 571 d->mManager->remove( resource );
572 return true; 572 return true;
573} 573}
574 574
575QPtrList<Resource> AddressBook::resources() 575QPtrList<Resource> AddressBook::resources()
576{ 576{
577 QPtrList<Resource> list; 577 QPtrList<Resource> list;
578 578
579// qDebug("AddressBook::resources() 1"); 579// qDebug("AddressBook::resources() 1");
580 580
581 KRES::Manager<Resource>::ActiveIterator it; 581 KRES::Manager<Resource>::ActiveIterator it;
582 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 582 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
583 list.append( *it ); 583 list.append( *it );
584 584
585 return list; 585 return list;
586} 586}
587 587
588/*US 588/*US
589void AddressBook::setErrorHandler( ErrorHandler *handler ) 589void AddressBook::setErrorHandler( ErrorHandler *handler )
590{ 590{
591 delete d->mErrorHandler; 591 delete d->mErrorHandler;
592 d->mErrorHandler = handler; 592 d->mErrorHandler = handler;
593} 593}
594*/ 594*/
595 595
596void AddressBook::error( const QString& msg ) 596void AddressBook::error( const QString& msg )
597{ 597{
598/*US 598/*US
599 if ( !d->mErrorHandler ) // create default error handler 599 if ( !d->mErrorHandler ) // create default error handler
600 d->mErrorHandler = new ConsoleErrorHandler; 600 d->mErrorHandler = new ConsoleErrorHandler;
601 601
602 if ( d->mErrorHandler ) 602 if ( d->mErrorHandler )
603 d->mErrorHandler->error( msg ); 603 d->mErrorHandler->error( msg );
604 else 604 else
605 kdError(5700) << "no error handler defined" << endl; 605 kdError(5700) << "no error handler defined" << endl;
606*/ 606*/
607 kdDebug(5700) << "msg" << endl; 607 kdDebug(5700) << "msg" << endl;
608 qDebug(msg); 608 qDebug(msg);
609} 609}
610 610
611void AddressBook::deleteRemovedAddressees() 611void AddressBook::deleteRemovedAddressees()
612{ 612{
613 Addressee::List::Iterator it; 613 Addressee::List::Iterator it;
614 for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { 614 for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) {
615 Resource *resource = (*it).resource(); 615 Resource *resource = (*it).resource();
616 if ( resource && !resource->readOnly() && resource->isOpen() ) 616 if ( resource && !resource->readOnly() && resource->isOpen() )
617 resource->removeAddressee( *it ); 617 resource->removeAddressee( *it );
618 } 618 }
619 619
620 d->mRemovedAddressees.clear(); 620 d->mRemovedAddressees.clear();
621} 621}
622 622
623void AddressBook::setStandardResource( Resource *resource ) 623void AddressBook::setStandardResource( Resource *resource )
624{ 624{
625// qDebug("AddressBook::setStandardResource 1"); 625// qDebug("AddressBook::setStandardResource 1");
626 d->mManager->setStandardResource( resource ); 626 d->mManager->setStandardResource( resource );
627} 627}
628 628
629Resource *AddressBook::standardResource() 629Resource *AddressBook::standardResource()
630{ 630{
631 return d->mManager->standardResource(); 631 return d->mManager->standardResource();
632} 632}
633 633
634KRES::Manager<Resource> *AddressBook::resourceManager() 634KRES::Manager<Resource> *AddressBook::resourceManager()
635{ 635{
636 return d->mManager; 636 return d->mManager;
637} 637}
638 638
639void AddressBook::cleanUp() 639void AddressBook::cleanUp()
640{ 640{
641 KRES::Manager<Resource>::ActiveIterator it; 641 KRES::Manager<Resource>::ActiveIterator it;
642 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 642 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
643 if ( !(*it)->readOnly() && (*it)->isOpen() ) 643 if ( !(*it)->readOnly() && (*it)->isOpen() )
644 (*it)->cleanUp(); 644 (*it)->cleanUp();
645 } 645 }
646} 646}
diff --git a/kabc/stdaddressbook.cpp b/kabc/stdaddressbook.cpp
index 760820e..9f38f08 100644
--- a/kabc/stdaddressbook.cpp
+++ b/kabc/stdaddressbook.cpp
@@ -1,226 +1,236 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#include <qdir.h> 28#include <qdir.h>
29#include "resource.h" 29#include "resource.h"
30#include <kresources/manager.h> 30#include <kresources/manager.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <klocale.h> 32#include <klocale.h>
33#include <kstaticdeleter.h> 33#include <kstaticdeleter.h>
34#include <kstandarddirs.h> 34#include <kstandarddirs.h>
35 35
36#include "stdaddressbook.h" 36#include "stdaddressbook.h"
37 37
38using namespace KABC; 38using namespace KABC;
39 39
40StdAddressBook *StdAddressBook::mSelf = 0; 40StdAddressBook *StdAddressBook::mSelf = 0;
41bool StdAddressBook::mAutomaticSave = true; 41bool StdAddressBook::mAutomaticSave = true;
42 42
43static KStaticDeleter<StdAddressBook> addressBookDeleter; 43static KStaticDeleter<StdAddressBook> addressBookDeleter;
44 44
45QString StdAddressBook::fileName() 45QString StdAddressBook::fileName()
46{ 46{
47 return locateLocal( "data", "kabc/std.vcf" ); 47 return locateLocal( "data", "kabc/std.vcf" );
48} 48}
49 49
50QString StdAddressBook::directoryName() 50QString StdAddressBook::directoryName()
51{ 51{
52 return locateLocal( "data", "kabc/stdvcf" ); 52 return locateLocal( "data", "kabc/stdvcf" );
53} 53}
54 54
55void StdAddressBook::handleCrash() 55void StdAddressBook::handleCrash()
56{ 56{
57 StdAddressBook::self()->cleanUp(); 57 StdAddressBook::self()->cleanUp();
58} 58}
59 59
60StdAddressBook *StdAddressBook::self() 60StdAddressBook *StdAddressBook::self()
61{ 61{
62 62
63 if ( !mSelf ) 63 if ( !mSelf )
64 { 64 {
65 QString appdir = StdAddressBook::setTempAppDir(); 65 QString appdir = StdAddressBook::setTempAppDir();
66 66 qDebug("****************************************************** ");
67 kdDebug(5700) << "StdAddressBook::self()" << endl; 67 qDebug("****************************************************** ");
68 qDebug("****************************************************** ");
69 qDebug("****************************************************** ");
70 qDebug("****************************************************** ");
68// US im am not sure why I have to use the other format here?? 71// US im am not sure why I have to use the other format here??
69#ifdef KAB_EMBEDDED 72#ifdef KAB_EMBEDDED
70 mSelf = addressBookDeleter.setObject( new StdAddressBook ); 73 mSelf = addressBookDeleter.setObject( new StdAddressBook );
71#else //KAB_EMBEDDED 74#else //KAB_EMBEDDED
72 addressBookDeleter.setObject( mSelf, new StdAddressBook ); 75 addressBookDeleter.setObject( mSelf, new StdAddressBook );
73#endif //KAB_EMBEDDED 76#endif //KAB_EMBEDDED
74 KStandardDirs::setAppDir( appdir ); 77 KStandardDirs::setAppDir( appdir );
75 } 78 }
76 79
77 return mSelf; 80 return mSelf;
78} 81}
79 82
80QString StdAddressBook::setTempAppDir() 83QString StdAddressBook::setTempAppDir()
81{ 84{
82 QString appDIR = KStandardDirs::appDir(); 85 QString appDIR = KStandardDirs::appDir();
83#ifdef DESKTOP_VERSION 86#ifdef DESKTOP_VERSION
84 QString appdir = QDir::homeDirPath(); 87 QString appdir = QDir::homeDirPath();
85 if ( appdir.right(1) == "\\" || appdir.right(1) == "/" ) 88 if ( appdir.right(1) == "\\" || appdir.right(1) == "/" )
86 appdir += "kaddressbook/"; 89 appdir += "kaddressbook/";
87 else 90 else
88 appdir += "/kaddressbook/"; 91 appdir += "/kaddressbook/";
89 KStandardDirs::setAppDir( QDir::convertSeparators( appdir )); 92 KStandardDirs::setAppDir( QDir::convertSeparators( appdir ));
90#else 93#else
91 QString appdir = QDir::homeDirPath() + "/kdepim/apps/kaddressbook"; 94 QString appdir = QDir::homeDirPath() + "/kdepim/apps/kaddressbook";
92 95
93 KStandardDirs::setAppDir( appdir ); 96 KStandardDirs::setAppDir( appdir );
94#endif 97#endif
95 98
96 return appDIR; 99 return appDIR;
97} 100}
98StdAddressBook *StdAddressBook::self( bool onlyFastResources ) 101StdAddressBook *StdAddressBook::self( bool onlyFastResources )
99{ 102{
100 103
101 if ( !mSelf ) 104 if ( !mSelf )
102 { 105 {
106 qDebug("++++++++++++++++++++++++++++++++++++++++++++++++ ");
107 qDebug("++++++++++++++++++++++++++++++++++++++++++++++++ ");
108 qDebug("++++++++++++++++++++++++++++++++++++++++++++++++ ");
109 qDebug("++++++++++++++++++++++++++++++++++++++++++++++++ ");
110 qDebug("++++++++++++++++++++++++++++++++++++++++++++++++ ");
111 qDebug("++++++++++++++++++++++++++++++++++++++++++++++++ ");
112 qDebug("++++++++++++++++++++++++++++++++++++++++++++++++ ");
103 QString appdir =StdAddressBook::setTempAppDir(); 113 QString appdir =StdAddressBook::setTempAppDir();
104#ifdef KAB_EMBEDDED 114#ifdef KAB_EMBEDDED
105 mSelf = addressBookDeleter.setObject( new StdAddressBook( onlyFastResources ) ); 115 mSelf = addressBookDeleter.setObject( new StdAddressBook( onlyFastResources ) );
106#else //KAB_EMBEDDED 116#else //KAB_EMBEDDED
107 addressBookDeleter.setObject( mSelf, new StdAddressBook( onlyFastResources ) ); 117 addressBookDeleter.setObject( mSelf, new StdAddressBook( onlyFastResources ) );
108#endif //KAB_EMBEDDED 118#endif //KAB_EMBEDDED
109 KStandardDirs::setAppDir( appdir ); 119 KStandardDirs::setAppDir( appdir );
110 } 120 }
111 return mSelf; 121 return mSelf;
112} 122}
113 123
114StdAddressBook::StdAddressBook() 124StdAddressBook::StdAddressBook()
115 : AddressBook( "kabcrc" ) 125 : AddressBook( "kabcrc" )
116{ 126{
117 127
118 init( false ); 128 init( false );
119} 129}
120 130
121StdAddressBook::StdAddressBook( bool onlyFastResources ) 131StdAddressBook::StdAddressBook( bool onlyFastResources )
122 : AddressBook( "kabcrc" ) 132 : AddressBook( "kabcrc" )
123{ 133{
124 134
125 init( onlyFastResources ); 135 init( onlyFastResources );
126} 136}
127 137
128StdAddressBook::~StdAddressBook() 138StdAddressBook::~StdAddressBook()
129{ 139{
130 if ( mAutomaticSave ) 140 if ( mAutomaticSave )
131 save(); 141 save();
132} 142}
133 143
134void StdAddressBook::init( bool ) 144void StdAddressBook::init( bool )
135{ 145{
136 KRES::Manager<Resource> *manager = resourceManager(); 146 KRES::Manager<Resource> *manager = resourceManager();
137 KRES::Manager<Resource>::ActiveIterator it; 147 KRES::Manager<Resource>::ActiveIterator it;
138 148
139 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 149 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
140 (*it)->setAddressBook( this ); 150 (*it)->setAddressBook( this );
141 if ( !(*it)->open() ) 151 if ( !(*it)->open() )
142 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); 152 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) );
143 } 153 }
144 154
145 Resource *res = standardResource(); 155 Resource *res = standardResource();
146 if ( !res ) { 156 if ( !res ) {
147 res = manager->createResource( "file" ); 157 res = manager->createResource( "file" );
148 if ( res ) 158 if ( res )
149 { 159 {
150 addResource( res ); 160 addResource( res );
151 } 161 }
152 else 162 else
153 qDebug(" No resource available!!!"); 163 qDebug(" No resource available!!!");
154 } 164 }
155 165
156 setStandardResource( res ); 166 setStandardResource( res );
157 manager->writeConfig(); 167 manager->writeConfig();
158 168
159 load(); 169 load();
160} 170}
161 171
162bool StdAddressBook::save() 172bool StdAddressBook::save()
163{ 173{
164 kdDebug(5700) << "StdAddressBook::save()" << endl; 174 kdDebug(5700) << "StdAddressBook::save()" << endl;
165 175
166 bool ok = true; 176 bool ok = true;
167 AddressBook *ab = self(); 177 AddressBook *ab = self();
168 178
169 ab->deleteRemovedAddressees(); 179 ab->deleteRemovedAddressees();
170 180
171 KRES::Manager<Resource>::ActiveIterator it; 181 KRES::Manager<Resource>::ActiveIterator it;
172 KRES::Manager<Resource> *manager = ab->resourceManager(); 182 KRES::Manager<Resource> *manager = ab->resourceManager();
173 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 183 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
174 if ( !(*it)->readOnly() && (*it)->isOpen() ) { 184 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
175 Ticket *ticket = ab->requestSaveTicket( *it ); 185 Ticket *ticket = ab->requestSaveTicket( *it );
176// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); 186// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
177 if ( !ticket ) { 187 if ( !ticket ) {
178 ab->error( i18n( "Unable to save to resource '%1'. It is locked." ) 188 ab->error( i18n( "Unable to save to resource '%1'. It is locked." )
179 .arg( (*it)->resourceName() ) ); 189 .arg( (*it)->resourceName() ) );
180 return false; 190 return false;
181 } 191 }
182 192
183 if ( !ab->save( ticket ) ) 193 if ( !ab->save( ticket ) )
184 ok = false; 194 ok = false;
185 } 195 }
186 } 196 }
187 197
188 return ok; 198 return ok;
189} 199}
190 200
191void StdAddressBook::close() 201void StdAddressBook::close()
192{ 202{
193//US destructObject is not defined on my system???. Is setObject(0) the same ??? 203//US destructObject is not defined on my system???. Is setObject(0) the same ???
194//US addressBookDeleter.destructObject(); 204//US addressBookDeleter.destructObject();
195 addressBookDeleter.setObject(0); 205 addressBookDeleter.setObject(0);
196 206
197} 207}
198 208
199void StdAddressBook::setAutomaticSave( bool enable ) 209void StdAddressBook::setAutomaticSave( bool enable )
200{ 210{
201 mAutomaticSave = enable; 211 mAutomaticSave = enable;
202} 212}
203 213
204bool StdAddressBook::automaticSave() 214bool StdAddressBook::automaticSave()
205{ 215{
206 return mAutomaticSave; 216 return mAutomaticSave;
207} 217}
208 218
209// should get const for 4.X 219// should get const for 4.X
210Addressee StdAddressBook::whoAmI() 220Addressee StdAddressBook::whoAmI()
211{ 221{
212//US KConfig config( "kabcrc" ); 222//US KConfig config( "kabcrc" );
213 KConfig config( locateLocal("config", "kabcrc") ); 223 KConfig config( locateLocal("config", "kabcrc") );
214 config.setGroup( "General" ); 224 config.setGroup( "General" );
215 225
216 return findByUid( config.readEntry( "WhoAmI" ) ); 226 return findByUid( config.readEntry( "WhoAmI" ) );
217} 227}
218 228
219void StdAddressBook::setWhoAmI( const Addressee &addr ) 229void StdAddressBook::setWhoAmI( const Addressee &addr )
220{ 230{
221//US KConfig config( "kabcrc" ); 231//US KConfig config( "kabcrc" );
222 KConfig config( locateLocal("config", "kabcrc") ); 232 KConfig config( locateLocal("config", "kabcrc") );
223 config.setGroup( "General" ); 233 config.setGroup( "General" );
224 234
225 config.writeEntry( "WhoAmI", addr.uid() ); 235 config.writeEntry( "WhoAmI", addr.uid() );
226} 236}
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 4299ebd..2f9f1df 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,2118 +1,2121 @@
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/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include "kabcore.h" 31#include "kabcore.h"
32 32
33#include <stdaddressbook.h> 33#include <stdaddressbook.h>
34#include <klocale.h> 34#include <klocale.h>
35 35
36#ifndef KAB_EMBEDDED 36#ifndef KAB_EMBEDDED
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qdir.h> 38#include <qdir.h>
39#include <qfile.h> 39#include <qfile.h>
40#include <qapplicaton.h> 40#include <qapplicaton.h>
41#include <qlayout.h> 41#include <qlayout.h>
42#include <qregexp.h> 42#include <qregexp.h>
43#include <qvbox.h> 43#include <qvbox.h>
44#include <kabc/addresseelist.h> 44#include <kabc/addresseelist.h>
45#include <kabc/errorhandler.h> 45#include <kabc/errorhandler.h>
46#include <kabc/resource.h> 46#include <kabc/resource.h>
47#include <kabc/vcardconverter.h> 47#include <kabc/vcardconverter.h>
48#include <kapplication.h> 48#include <kapplication.h>
49#include <kactionclasses.h> 49#include <kactionclasses.h>
50#include <kcmultidialog.h> 50#include <kcmultidialog.h>
51#include <kdebug.h> 51#include <kdebug.h>
52#include <kdeversion.h> 52#include <kdeversion.h>
53#include <kkeydialog.h> 53#include <kkeydialog.h>
54#include <kmessagebox.h> 54#include <kmessagebox.h>
55#include <kprinter.h> 55#include <kprinter.h>
56#include <kprotocolinfo.h> 56#include <kprotocolinfo.h>
57#include <kresources/selectdialog.h> 57#include <kresources/selectdialog.h>
58#include <kstandarddirs.h> 58#include <kstandarddirs.h>
59#include <ktempfile.h> 59#include <ktempfile.h>
60#include <kxmlguiclient.h> 60#include <kxmlguiclient.h>
61#include <kaboutdata.h> 61#include <kaboutdata.h>
62#include <libkdepim/categoryselectdialog.h> 62#include <libkdepim/categoryselectdialog.h>
63 63
64#include "addresseeutil.h" 64#include "addresseeutil.h"
65#include "addresseeeditordialog.h" 65#include "addresseeeditordialog.h"
66#include "extensionmanager.h" 66#include "extensionmanager.h"
67#include "kstdaction.h" 67#include "kstdaction.h"
68#include "kaddressbookservice.h" 68#include "kaddressbookservice.h"
69#include "ldapsearchdialog.h" 69#include "ldapsearchdialog.h"
70#include "printing/printingwizard.h" 70#include "printing/printingwizard.h"
71#else // KAB_EMBEDDED 71#else // KAB_EMBEDDED
72 72
73#include <kapplication.h> 73#include <kapplication.h>
74#include "KDGanttMinimizeSplitter.h" 74#include "KDGanttMinimizeSplitter.h"
75#include "kaddressbookmain.h" 75#include "kaddressbookmain.h"
76#include "kactioncollection.h" 76#include "kactioncollection.h"
77#include "addresseedialog.h" 77#include "addresseedialog.h"
78//US 78//US
79#include <libkdepim/addresseeview.h> 79#include <libkdepim/addresseeview.h>
80 80
81#include <qapp.h> 81#include <qapp.h>
82#include <qmenubar.h> 82#include <qmenubar.h>
83//#include <qtoolbar.h> 83//#include <qtoolbar.h>
84#include <qmessagebox.h> 84#include <qmessagebox.h>
85#include <kdebug.h> 85#include <kdebug.h>
86#include <kiconloader.h> // needed for SmallIcon 86#include <kiconloader.h> // needed for SmallIcon
87#include <kresources/kcmkresources.h> 87#include <kresources/kcmkresources.h>
88#include <ktoolbar.h> 88#include <ktoolbar.h>
89 89
90 90
91//#include <qlabel.h> 91//#include <qlabel.h>
92 92
93 93
94#ifndef DESKTOP_VERSION 94#ifndef DESKTOP_VERSION
95#include <qpe/ir.h> 95#include <qpe/ir.h>
96#include <qtopia/qcopenvelope_qws.h> 96#include <qtopia/qcopenvelope_qws.h>
97#else 97#else
98 98
99#endif 99#endif
100 100
101#endif // KAB_EMBEDDED 101#endif // KAB_EMBEDDED
102#include "kcmconfigs/kcmkabconfig.h" 102#include "kcmconfigs/kcmkabconfig.h"
103#include "kcmconfigs/kcmkdepimconfig.h" 103#include "kcmconfigs/kcmkdepimconfig.h"
104#include "kpimglobalprefs.h" 104#include "kpimglobalprefs.h"
105#include "externalapphandler.h" 105#include "externalapphandler.h"
106 106
107 107
108#include <kresources/selectdialog.h> 108#include <kresources/selectdialog.h>
109#include <kmessagebox.h> 109#include <kmessagebox.h>
110 110
111#include <picture.h> 111#include <picture.h>
112#include <resource.h> 112#include <resource.h>
113 113
114//US#include <qsplitter.h> 114//US#include <qsplitter.h>
115#include <qmap.h> 115#include <qmap.h>
116#include <qdir.h> 116#include <qdir.h>
117#include <qfile.h> 117#include <qfile.h>
118#include <qvbox.h> 118#include <qvbox.h>
119#include <qlayout.h> 119#include <qlayout.h>
120#include <qclipboard.h> 120#include <qclipboard.h>
121#include <qtextstream.h> 121#include <qtextstream.h>
122 122
123#include <libkdepim/categoryselectdialog.h> 123#include <libkdepim/categoryselectdialog.h>
124#include <kabc/vcardconverter.h> 124#include <kabc/vcardconverter.h>
125 125
126 126
127#include "addresseeutil.h" 127#include "addresseeutil.h"
128#include "undocmds.h" 128#include "undocmds.h"
129#include "addresseeeditordialog.h" 129#include "addresseeeditordialog.h"
130#include "viewmanager.h" 130#include "viewmanager.h"
131#include "details/detailsviewcontainer.h" 131#include "details/detailsviewcontainer.h"
132#include "kabprefs.h" 132#include "kabprefs.h"
133#include "xxportmanager.h" 133#include "xxportmanager.h"
134#include "incsearchwidget.h" 134#include "incsearchwidget.h"
135#include "jumpbuttonbar.h" 135#include "jumpbuttonbar.h"
136#include "extensionmanager.h" 136#include "extensionmanager.h"
137#include "addresseeconfig.h" 137#include "addresseeconfig.h"
138#include <kcmultidialog.h> 138#include <kcmultidialog.h>
139 139
140#ifdef _WIN32_ 140#ifdef _WIN32_
141 141
142#include "kaimportoldialog.h" 142#include "kaimportoldialog.h"
143#endif 143#endif
144 144
145bool pasteWithNewUid = true; 145bool pasteWithNewUid = true;
146 146
147#ifdef KAB_EMBEDDED 147#ifdef KAB_EMBEDDED
148KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 148KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
149 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 149 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
150 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 150 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
151 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 151 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
152#else //KAB_EMBEDDED 152#else //KAB_EMBEDDED
153KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 153KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
154 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 154 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
155 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 155 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
156 mReadWrite( readWrite ), mModified( false ) 156 mReadWrite( readWrite ), mModified( false )
157#endif //KAB_EMBEDDED 157#endif //KAB_EMBEDDED
158{ 158{
159 159
160 mExtensionBarSplitter = 0; 160 mExtensionBarSplitter = 0;
161 mIsPart = !parent->inherits( "KAddressBookMain" ); 161 mIsPart = !parent->inherits( "KAddressBookMain" );
162 162
163 mAddressBook = KABC::StdAddressBook::self(); 163 mAddressBook = KABC::StdAddressBook::self();
164 KABC::StdAddressBook::setAutomaticSave( false ); 164 KABC::StdAddressBook::setAutomaticSave( false );
165 165
166#ifndef KAB_EMBEDDED 166#ifndef KAB_EMBEDDED
167 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 167 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
168#endif //KAB_EMBEDDED 168#endif //KAB_EMBEDDED
169 169
170 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 170 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
171 SLOT( addressBookChanged() ) ); 171 SLOT( addressBookChanged() ) );
172 172
173 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 173 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
174 "X-Department", "KADDRESSBOOK" ); 174 "X-Department", "KADDRESSBOOK" );
175 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 175 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
176 "X-Profession", "KADDRESSBOOK" ); 176 "X-Profession", "KADDRESSBOOK" );
177 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 177 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
178 "X-AssistantsName", "KADDRESSBOOK" ); 178 "X-AssistantsName", "KADDRESSBOOK" );
179 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 179 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
180 "X-ManagersName", "KADDRESSBOOK" ); 180 "X-ManagersName", "KADDRESSBOOK" );
181 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 181 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
182 "X-SpousesName", "KADDRESSBOOK" ); 182 "X-SpousesName", "KADDRESSBOOK" );
183 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 183 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
184 "X-Office", "KADDRESSBOOK" ); 184 "X-Office", "KADDRESSBOOK" );
185 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 185 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
186 "X-IMAddress", "KADDRESSBOOK" ); 186 "X-IMAddress", "KADDRESSBOOK" );
187 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 187 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
188 "X-Anniversary", "KADDRESSBOOK" ); 188 "X-Anniversary", "KADDRESSBOOK" );
189 189
190 //US added this field to become compatible with Opie/qtopia addressbook 190 //US added this field to become compatible with Opie/qtopia addressbook
191 // values can be "female" or "male" or "". An empty field represents undefined. 191 // values can be "female" or "male" or "". An empty field represents undefined.
192 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 192 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
193 "X-Gender", "KADDRESSBOOK" ); 193 "X-Gender", "KADDRESSBOOK" );
194 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 194 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
195 "X-Children", "KADDRESSBOOK" ); 195 "X-Children", "KADDRESSBOOK" );
196 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 196 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
197 "X-FreeBusyUrl", "KADDRESSBOOK" ); 197 "X-FreeBusyUrl", "KADDRESSBOOK" );
198 198
199 initGUI(); 199 initGUI();
200 200
201 mIncSearchWidget->setFocus(); 201 mIncSearchWidget->setFocus();
202 202
203 203
204 connect( mViewManager, SIGNAL( selected( const QString& ) ), 204 connect( mViewManager, SIGNAL( selected( const QString& ) ),
205 SLOT( setContactSelected( const QString& ) ) ); 205 SLOT( setContactSelected( const QString& ) ) );
206 connect( mViewManager, SIGNAL( executed( const QString& ) ), 206 connect( mViewManager, SIGNAL( executed( const QString& ) ),
207 SLOT( executeContact( const QString& ) ) ); 207 SLOT( executeContact( const QString& ) ) );
208 208
209 connect( mViewManager, SIGNAL( deleteRequest( ) ), 209 connect( mViewManager, SIGNAL( deleteRequest( ) ),
210 SLOT( deleteContacts( ) ) ); 210 SLOT( deleteContacts( ) ) );
211 connect( mViewManager, SIGNAL( modified() ), 211 connect( mViewManager, SIGNAL( modified() ),
212 SLOT( setModified() ) ); 212 SLOT( setModified() ) );
213 213
214 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 214 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
215 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 215 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
216 216
217 connect( mXXPortManager, SIGNAL( modified() ), 217 connect( mXXPortManager, SIGNAL( modified() ),
218 SLOT( setModified() ) ); 218 SLOT( setModified() ) );
219 219
220 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 220 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
221 SLOT( incrementalSearch( const QString& ) ) ); 221 SLOT( incrementalSearch( const QString& ) ) );
222 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 222 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
223 mJumpButtonBar, SLOT( recreateButtons() ) ); 223 mJumpButtonBar, SLOT( recreateButtons() ) );
224 224
225 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 225 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
226 SLOT( sendMail( const QString& ) ) ); 226 SLOT( sendMail( const QString& ) ) );
227 227
228 228
229 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 229 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
230 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 230 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
231 231
232 232
233#ifndef KAB_EMBEDDED 233#ifndef KAB_EMBEDDED
234 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 234 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
235 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 235 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
236 236
237 connect( mDetails, SIGNAL( browse( const QString& ) ), 237 connect( mDetails, SIGNAL( browse( const QString& ) ),
238 SLOT( browse( const QString& ) ) ); 238 SLOT( browse( const QString& ) ) );
239 239
240 240
241 mAddressBookService = new KAddressBookService( this ); 241 mAddressBookService = new KAddressBookService( this );
242 242
243#endif //KAB_EMBEDDED 243#endif //KAB_EMBEDDED
244 mEditorDialog = 0; 244 mEditorDialog = 0;
245 createAddresseeEditorDialog( this ); 245 createAddresseeEditorDialog( this );
246 setModified( false ); 246 setModified( false );
247} 247}
248 248
249KABCore::~KABCore() 249KABCore::~KABCore()
250{ 250{
251 // save(); 251 // save();
252 //saveSettings(); 252 //saveSettings();
253 //KABPrefs::instance()->writeConfig(); 253 //KABPrefs::instance()->writeConfig();
254 delete AddresseeConfig::instance(); 254 delete AddresseeConfig::instance();
255 mAddressBook = 0; 255 mAddressBook = 0;
256 KABC::StdAddressBook::close(); 256 KABC::StdAddressBook::close();
257} 257}
258 258
259void KABCore::restoreSettings() 259void KABCore::restoreSettings()
260{ 260{
261 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 261 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
262 262
263 bool state; 263 bool state;
264 264
265 if (mMultipleViewsAtOnce) 265 if (mMultipleViewsAtOnce)
266 state = KABPrefs::instance()->mDetailsPageVisible; 266 state = KABPrefs::instance()->mDetailsPageVisible;
267 else 267 else
268 state = false; 268 state = false;
269 269
270 mActionDetails->setChecked( state ); 270 mActionDetails->setChecked( state );
271 setDetailsVisible( state ); 271 setDetailsVisible( state );
272 272
273 state = KABPrefs::instance()->mJumpButtonBarVisible; 273 state = KABPrefs::instance()->mJumpButtonBarVisible;
274 274
275 mActionJumpBar->setChecked( state ); 275 mActionJumpBar->setChecked( state );
276 setJumpButtonBarVisible( state ); 276 setJumpButtonBarVisible( state );
277/*US 277/*US
278 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 278 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
279 if ( splitterSize.count() == 0 ) { 279 if ( splitterSize.count() == 0 ) {
280 splitterSize.append( width() / 2 ); 280 splitterSize.append( width() / 2 );
281 splitterSize.append( width() / 2 ); 281 splitterSize.append( width() / 2 );
282 } 282 }
283 mMiniSplitter->setSizes( splitterSize ); 283 mMiniSplitter->setSizes( splitterSize );
284 if ( mExtensionBarSplitter ) { 284 if ( mExtensionBarSplitter ) {
285 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 285 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
286 if ( splitterSize.count() == 0 ) { 286 if ( splitterSize.count() == 0 ) {
287 splitterSize.append( width() / 2 ); 287 splitterSize.append( width() / 2 );
288 splitterSize.append( width() / 2 ); 288 splitterSize.append( width() / 2 );
289 } 289 }
290 mExtensionBarSplitter->setSizes( splitterSize ); 290 mExtensionBarSplitter->setSizes( splitterSize );
291 291
292 } 292 }
293*/ 293*/
294 mViewManager->restoreSettings(); 294 mViewManager->restoreSettings();
295 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 295 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
296 mExtensionManager->restoreSettings(); 296 mExtensionManager->restoreSettings();
297 297
298 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 298 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
299 if ( splitterSize.count() == 0 ) { 299 if ( splitterSize.count() == 0 ) {
300 splitterSize.append( width() / 2 ); 300 splitterSize.append( width() / 2 );
301 splitterSize.append( width() / 2 ); 301 splitterSize.append( width() / 2 );
302 } 302 }
303 mMiniSplitter->setSizes( splitterSize ); 303 mMiniSplitter->setSizes( splitterSize );
304 if ( mExtensionBarSplitter ) { 304 if ( mExtensionBarSplitter ) {
305 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 305 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
306 if ( splitterSize.count() == 0 ) { 306 if ( splitterSize.count() == 0 ) {
307 splitterSize.append( width() / 2 ); 307 splitterSize.append( width() / 2 );
308 splitterSize.append( width() / 2 ); 308 splitterSize.append( width() / 2 );
309 } 309 }
310 mExtensionBarSplitter->setSizes( splitterSize ); 310 mExtensionBarSplitter->setSizes( splitterSize );
311 311
312 } 312 }
313 313
314 314
315} 315}
316 316
317void KABCore::saveSettings() 317void KABCore::saveSettings()
318{ 318{
319 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 319 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
320 if ( mExtensionBarSplitter ) 320 if ( mExtensionBarSplitter )
321 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 321 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
322 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 322 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
323 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 323 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
324#ifndef KAB_EMBEDDED 324#ifndef KAB_EMBEDDED
325 325
326 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 326 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
327 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 327 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
328#endif //KAB_EMBEDDED 328#endif //KAB_EMBEDDED
329 mExtensionManager->saveSettings(); 329 mExtensionManager->saveSettings();
330 mViewManager->saveSettings(); 330 mViewManager->saveSettings();
331 331
332 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 332 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
333} 333}
334 334
335KABC::AddressBook *KABCore::addressBook() const 335KABC::AddressBook *KABCore::addressBook() const
336{ 336{
337 return mAddressBook; 337 return mAddressBook;
338} 338}
339 339
340KConfig *KABCore::config() 340KConfig *KABCore::config()
341{ 341{
342#ifndef KAB_EMBEDDED 342#ifndef KAB_EMBEDDED
343 return KABPrefs::instance()->config(); 343 return KABPrefs::instance()->config();
344#else //KAB_EMBEDDED 344#else //KAB_EMBEDDED
345 return KABPrefs::instance()->getConfig(); 345 return KABPrefs::instance()->getConfig();
346#endif //KAB_EMBEDDED 346#endif //KAB_EMBEDDED
347} 347}
348 348
349KActionCollection *KABCore::actionCollection() const 349KActionCollection *KABCore::actionCollection() const
350{ 350{
351 return mGUIClient->actionCollection(); 351 return mGUIClient->actionCollection();
352} 352}
353 353
354KABC::Field *KABCore::currentSearchField() const 354KABC::Field *KABCore::currentSearchField() const
355{ 355{
356 if (mIncSearchWidget) 356 if (mIncSearchWidget)
357 return mIncSearchWidget->currentField(); 357 return mIncSearchWidget->currentField();
358 else 358 else
359 return 0; 359 return 0;
360} 360}
361 361
362QStringList KABCore::selectedUIDs() const 362QStringList KABCore::selectedUIDs() const
363{ 363{
364 return mViewManager->selectedUids(); 364 return mViewManager->selectedUids();
365} 365}
366 366
367KABC::Resource *KABCore::requestResource( QWidget *parent ) 367KABC::Resource *KABCore::requestResource( QWidget *parent )
368{ 368{
369 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 369 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
370 370
371 QPtrList<KRES::Resource> kresResources; 371 QPtrList<KRES::Resource> kresResources;
372 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 372 QPtrListIterator<KABC::Resource> resIt( kabcResources );
373 KABC::Resource *resource; 373 KABC::Resource *resource;
374 while ( ( resource = resIt.current() ) != 0 ) { 374 while ( ( resource = resIt.current() ) != 0 ) {
375 ++resIt; 375 ++resIt;
376 if ( !resource->readOnly() ) { 376 if ( !resource->readOnly() ) {
377 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 377 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
378 if ( res ) 378 if ( res )
379 kresResources.append( res ); 379 kresResources.append( res );
380 } 380 }
381 } 381 }
382 382
383 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 383 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
384 return static_cast<KABC::Resource*>( res ); 384 return static_cast<KABC::Resource*>( res );
385} 385}
386 386
387#ifndef KAB_EMBEDDED 387#ifndef KAB_EMBEDDED
388KAboutData *KABCore::createAboutData() 388KAboutData *KABCore::createAboutData()
389#else //KAB_EMBEDDED 389#else //KAB_EMBEDDED
390void KABCore::createAboutData() 390void KABCore::createAboutData()
391#endif //KAB_EMBEDDED 391#endif //KAB_EMBEDDED
392{ 392{
393#ifndef KAB_EMBEDDED 393#ifndef KAB_EMBEDDED
394 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 394 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
395 "3.1", I18N_NOOP( "The KDE Address Book" ), 395 "3.1", I18N_NOOP( "The KDE Address Book" ),
396 KAboutData::License_GPL_V2, 396 KAboutData::License_GPL_V2,
397 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 397 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
398 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 398 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
399 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 399 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
400 about->addAuthor( "Cornelius Schumacher", 400 about->addAuthor( "Cornelius Schumacher",
401 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 401 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
402 "schumacher@kde.org" ); 402 "schumacher@kde.org" );
403 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 403 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
404 "mpilone@slac.com" ); 404 "mpilone@slac.com" );
405 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 405 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
406 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 406 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
407 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 407 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
408 "michel@klaralvdalens-datakonsult.se" ); 408 "michel@klaralvdalens-datakonsult.se" );
409 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 409 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
410 "hansen@kde.org" ); 410 "hansen@kde.org" );
411 411
412 return about; 412 return about;
413#endif //KAB_EMBEDDED 413#endif //KAB_EMBEDDED
414 414
415 QString version; 415 QString version;
416#include <../version> 416#include <../version>
417 QMessageBox::about( this, "About KAddressbook/Pi", 417 QMessageBox::about( this, "About KAddressbook/Pi",
418 "KAddressbook/Platform-independent\n" 418 "KAddressbook/Platform-independent\n"
419 "(KA/Pi) " +version + " - " + 419 "(KA/Pi) " +version + " - " +
420#ifdef DESKTOP_VERSION 420#ifdef DESKTOP_VERSION
421 "Desktop Edition\n" 421 "Desktop Edition\n"
422#else 422#else
423 "PDA-Edition\n" 423 "PDA-Edition\n"
424 "for: Zaurus 5500 / 7x0 / 8x0\n" 424 "for: Zaurus 5500 / 7x0 / 8x0\n"
425#endif 425#endif
426 426
427 "(c) 2004 Ulf Schenk\n" 427 "(c) 2004 Ulf Schenk\n"
428 "(c) 2004 Lutz Rogowski\n" 428 "(c) 2004 Lutz Rogowski\n"
429 "(c) 1997-2003, The KDE PIM Team\n" 429 "(c) 1997-2003, The KDE PIM Team\n"
430 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 430 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
431 "Don Sanders Original author\n" 431 "Don Sanders Original author\n"
432 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 432 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
433 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 433 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
434 "Greg Stern DCOP interface\n" 434 "Greg Stern DCOP interface\n"
435 "Mark Westcot Contact pinning\n" 435 "Mark Westcot Contact pinning\n"
436 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 436 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
437 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 437 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
438#ifdef _WIN32_ 438#ifdef _WIN32_
439 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 439 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
440#endif 440#endif
441 ); 441 );
442} 442}
443 443
444void KABCore::setContactSelected( const QString &uid ) 444void KABCore::setContactSelected( const QString &uid )
445{ 445{
446 KABC::Addressee addr = mAddressBook->findByUid( uid ); 446 KABC::Addressee addr = mAddressBook->findByUid( uid );
447 if ( !mDetails->isHidden() ) 447 if ( !mDetails->isHidden() )
448 mDetails->setAddressee( addr ); 448 mDetails->setAddressee( addr );
449 449
450 if ( !addr.isEmpty() ) { 450 if ( !addr.isEmpty() ) {
451 emit contactSelected( addr.formattedName() ); 451 emit contactSelected( addr.formattedName() );
452 KABC::Picture pic = addr.photo(); 452 KABC::Picture pic = addr.photo();
453 if ( pic.isIntern() ) { 453 if ( pic.isIntern() ) {
454//US emit contactSelected( pic.data() ); 454//US emit contactSelected( pic.data() );
455//US instead use: 455//US instead use:
456 QPixmap px; 456 QPixmap px;
457 if (pic.data().isNull() != true) 457 if (pic.data().isNull() != true)
458 { 458 {
459 px.convertFromImage(pic.data()); 459 px.convertFromImage(pic.data());
460 } 460 }
461 461
462 emit contactSelected( px ); 462 emit contactSelected( px );
463 } 463 }
464 } 464 }
465 465
466 466
467 mExtensionManager->setSelectionChanged(); 467 mExtensionManager->setSelectionChanged();
468 468
469 // update the actions 469 // update the actions
470 bool selected = !uid.isEmpty(); 470 bool selected = !uid.isEmpty();
471 471
472 if ( mReadWrite ) { 472 if ( mReadWrite ) {
473 mActionCut->setEnabled( selected ); 473 mActionCut->setEnabled( selected );
474 mActionPaste->setEnabled( selected ); 474 mActionPaste->setEnabled( selected );
475 } 475 }
476 476
477 mActionCopy->setEnabled( selected ); 477 mActionCopy->setEnabled( selected );
478 mActionDelete->setEnabled( selected ); 478 mActionDelete->setEnabled( selected );
479 mActionEditAddressee->setEnabled( selected ); 479 mActionEditAddressee->setEnabled( selected );
480 mActionMail->setEnabled( selected ); 480 mActionMail->setEnabled( selected );
481 mActionMailVCard->setEnabled( selected ); 481 mActionMailVCard->setEnabled( selected );
482 //if (mActionBeam) 482 //if (mActionBeam)
483 //mActionBeam->setEnabled( selected ); 483 //mActionBeam->setEnabled( selected );
484 484
485 if (mActionBeamVCard) 485 if (mActionBeamVCard)
486 mActionBeamVCard->setEnabled( selected ); 486 mActionBeamVCard->setEnabled( selected );
487 487
488 mActionWhoAmI->setEnabled( selected ); 488 mActionWhoAmI->setEnabled( selected );
489 mActionCategories->setEnabled( selected ); 489 mActionCategories->setEnabled( selected );
490} 490}
491 491
492void KABCore::sendMail() 492void KABCore::sendMail()
493{ 493{
494 sendMail( mViewManager->selectedEmails().join( ", " ) ); 494 sendMail( mViewManager->selectedEmails().join( ", " ) );
495} 495}
496 496
497void KABCore::sendMail( const QString& emaillist ) 497void KABCore::sendMail( const QString& emaillist )
498{ 498{
499 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 499 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
500 if (emaillist.contains(",") > 0) 500 if (emaillist.contains(",") > 0)
501 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 501 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
502 else 502 else
503 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 503 ExternalAppHandler::instance()->mailToOneContact( emaillist );
504} 504}
505 505
506 506
507 507
508void KABCore::mailVCard() 508void KABCore::mailVCard()
509{ 509{
510 QStringList uids = mViewManager->selectedUids(); 510 QStringList uids = mViewManager->selectedUids();
511 if ( !uids.isEmpty() ) 511 if ( !uids.isEmpty() )
512 mailVCard( uids ); 512 mailVCard( uids );
513} 513}
514 514
515void KABCore::mailVCard( const QStringList& uids ) 515void KABCore::mailVCard( const QStringList& uids )
516{ 516{
517 QStringList urls; 517 QStringList urls;
518 518
519// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 519// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
520 520
521 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 521 QString dirName = "/tmp/" + KApplication::randomString( 8 );
522 522
523 523
524 524
525 QDir().mkdir( dirName, true ); 525 QDir().mkdir( dirName, true );
526 526
527 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 527 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
528 KABC::Addressee a = mAddressBook->findByUid( *it ); 528 KABC::Addressee a = mAddressBook->findByUid( *it );
529 529
530 if ( a.isEmpty() ) 530 if ( a.isEmpty() )
531 continue; 531 continue;
532 532
533 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 533 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
534 534
535 QString fileName = dirName + "/" + name; 535 QString fileName = dirName + "/" + name;
536 536
537 QFile outFile(fileName); 537 QFile outFile(fileName);
538 538
539 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 539 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
540 KABC::VCardConverter converter; 540 KABC::VCardConverter converter;
541 QString vcard; 541 QString vcard;
542 542
543 converter.addresseeToVCard( a, vcard ); 543 converter.addresseeToVCard( a, vcard );
544 544
545 QTextStream t( &outFile ); // use a text stream 545 QTextStream t( &outFile ); // use a text stream
546 t.setEncoding( QTextStream::UnicodeUTF8 ); 546 t.setEncoding( QTextStream::UnicodeUTF8 );
547 t << vcard; 547 t << vcard;
548 548
549 outFile.close(); 549 outFile.close();
550 550
551 urls.append( fileName ); 551 urls.append( fileName );
552 } 552 }
553 } 553 }
554 554
555 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 555 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
556 556
557 557
558/*US 558/*US
559 kapp->invokeMailer( QString::null, QString::null, QString::null, 559 kapp->invokeMailer( QString::null, QString::null, QString::null,
560 QString::null, // subject 560 QString::null, // subject
561 QString::null, // body 561 QString::null, // body
562 QString::null, 562 QString::null,
563 urls ); // attachments 563 urls ); // attachments
564*/ 564*/
565 565
566} 566}
567 567
568/** 568/**
569 Beams the "WhoAmI contact. 569 Beams the "WhoAmI contact.
570*/ 570*/
571void KABCore::beamMySelf() 571void KABCore::beamMySelf()
572{ 572{
573 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 573 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
574 if (!a.isEmpty()) 574 if (!a.isEmpty())
575 { 575 {
576 QStringList uids; 576 QStringList uids;
577 uids << a.uid(); 577 uids << a.uid();
578 578
579 beamVCard(uids); 579 beamVCard(uids);
580 } else { 580 } else {
581 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 581 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
582 582
583 583
584 } 584 }
585} 585}
586 586
587void KABCore::beamVCard() 587void KABCore::beamVCard()
588{ 588{
589 QStringList uids = mViewManager->selectedUids(); 589 QStringList uids = mViewManager->selectedUids();
590 if ( !uids.isEmpty() ) 590 if ( !uids.isEmpty() )
591 beamVCard( uids ); 591 beamVCard( uids );
592} 592}
593 593
594 594
595void KABCore::beamVCard(const QStringList& uids) 595void KABCore::beamVCard(const QStringList& uids)
596{ 596{
597/*US 597/*US
598 QString beamFilename; 598 QString beamFilename;
599 Opie::OPimContact c; 599 Opie::OPimContact c;
600 if ( actionPersonal->isOn() ) { 600 if ( actionPersonal->isOn() ) {
601 beamFilename = addressbookPersonalVCardName(); 601 beamFilename = addressbookPersonalVCardName();
602 if ( !QFile::exists( beamFilename ) ) 602 if ( !QFile::exists( beamFilename ) )
603 return; // can't beam a non-existent file 603 return; // can't beam a non-existent file
604 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 604 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
605 beamFilename ); 605 beamFilename );
606 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 606 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
607 Opie::OPimContactAccess::List allList = access->allRecords(); 607 Opie::OPimContactAccess::List allList = access->allRecords();
608 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first 608 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
609 c = *it; 609 c = *it;
610 610
611 delete access; 611 delete access;
612 } else { 612 } else {
613 unlink( beamfile ); // delete if exists 613 unlink( beamfile ); // delete if exists
614 mkdir("/tmp/obex/", 0755); 614 mkdir("/tmp/obex/", 0755);
615 c = m_abView -> currentEntry(); 615 c = m_abView -> currentEntry();
616 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 616 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
617 beamfile ); 617 beamfile );
618 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 618 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
619 access->add( c ); 619 access->add( c );
620 access->save(); 620 access->save();
621 delete access; 621 delete access;
622 622
623 beamFilename = beamfile; 623 beamFilename = beamfile;
624 } 624 }
625 625
626 owarn << "Beaming: " << beamFilename << oendl; 626 owarn << "Beaming: " << beamFilename << oendl;
627*/ 627*/
628 628
629#if 0 629#if 0
630 QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 630 QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
631 631
632 QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); 632 QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
633 633
634 QString name = "contact.vcf"; 634 QString name = "contact.vcf";
635 635
636 QString fileName = dirName + "/" + name; 636 QString fileName = dirName + "/" + name;
637#endif 637#endif
638 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory 638 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory
639 // 639 //
640 QString fileName = "/tmp/kdepimbeamfile"; 640 QString fileName = "/tmp/kdepimbeamfile";
641 641
642 642
643 //QDir().mkdir( dirName, true ); 643 //QDir().mkdir( dirName, true );
644 644
645 QFile outFile(fileName); 645 QFile outFile(fileName);
646 KABC::VCardConverter converter; 646 KABC::VCardConverter converter;
647 QString description; 647 QString description;
648 648
649 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 649 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
650 650
651 QTextStream t( &outFile ); // use a text stream 651 QTextStream t( &outFile ); // use a text stream
652 t.setEncoding( QTextStream::UnicodeUTF8 ); 652 t.setEncoding( QTextStream::UnicodeUTF8 );
653 653
654 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 654 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
655 KABC::Addressee a = mAddressBook->findByUid( *it ); 655 KABC::Addressee a = mAddressBook->findByUid( *it );
656 656
657 if ( a.isEmpty() ) 657 if ( a.isEmpty() )
658 continue; 658 continue;
659 659
660 if (description.isEmpty()) 660 if (description.isEmpty())
661 description = a.formattedName(); 661 description = a.formattedName();
662 662
663 QString vcard; 663 QString vcard;
664 converter.addresseeToVCard( a, vcard ); 664 converter.addresseeToVCard( a, vcard );
665 t << vcard; 665 t << vcard;
666 666
667 } 667 }
668 } else { 668 } else {
669 qDebug("Error open temp beam file "); 669 qDebug("Error open temp beam file ");
670 return; 670 return;
671 } 671 }
672 672
673 outFile.close(); 673 outFile.close();
674 674
675#ifndef DESKTOP_VERSION 675#ifndef DESKTOP_VERSION
676 Ir *ir = new Ir( this ); 676 Ir *ir = new Ir( this );
677 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 677 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
678 ir->send( fileName, description, "text/x-vCard" ); 678 ir->send( fileName, description, "text/x-vCard" );
679#endif 679#endif
680 680
681} 681}
682 682
683void KABCore::beamDone( Ir *ir ) 683void KABCore::beamDone( Ir *ir )
684{ 684{
685#ifndef DESKTOP_VERSION 685#ifndef DESKTOP_VERSION
686 delete ir; 686 delete ir;
687#endif 687#endif
688} 688}
689 689
690 690
691void KABCore::browse( const QString& url ) 691void KABCore::browse( const QString& url )
692{ 692{
693#ifndef KAB_EMBEDDED 693#ifndef KAB_EMBEDDED
694 kapp->invokeBrowser( url ); 694 kapp->invokeBrowser( url );
695#else //KAB_EMBEDDED 695#else //KAB_EMBEDDED
696 qDebug("KABCore::browse must be fixed"); 696 qDebug("KABCore::browse must be fixed");
697#endif //KAB_EMBEDDED 697#endif //KAB_EMBEDDED
698} 698}
699 699
700void KABCore::selectAllContacts() 700void KABCore::selectAllContacts()
701{ 701{
702 mViewManager->setSelected( QString::null, true ); 702 mViewManager->setSelected( QString::null, true );
703} 703}
704 704
705void KABCore::deleteContacts() 705void KABCore::deleteContacts()
706{ 706{
707 QStringList uidList = mViewManager->selectedUids(); 707 QStringList uidList = mViewManager->selectedUids();
708 deleteContacts( uidList ); 708 deleteContacts( uidList );
709} 709}
710 710
711void KABCore::deleteContacts( const QStringList &uids ) 711void KABCore::deleteContacts( const QStringList &uids )
712{ 712{
713 if ( uids.count() > 0 ) { 713 if ( uids.count() > 0 ) {
714 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 714 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
715 UndoStack::instance()->push( command ); 715 UndoStack::instance()->push( command );
716 RedoStack::instance()->clear(); 716 RedoStack::instance()->clear();
717 717
718 // now if we deleted anything, refresh 718 // now if we deleted anything, refresh
719 setContactSelected( QString::null ); 719 setContactSelected( QString::null );
720 setModified( true ); 720 setModified( true );
721 } 721 }
722} 722}
723 723
724void KABCore::copyContacts() 724void KABCore::copyContacts()
725{ 725{
726 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 726 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
727 727
728 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 728 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
729 729
730 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 730 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
731 731
732 QClipboard *cb = QApplication::clipboard(); 732 QClipboard *cb = QApplication::clipboard();
733 cb->setText( clipText ); 733 cb->setText( clipText );
734} 734}
735 735
736void KABCore::cutContacts() 736void KABCore::cutContacts()
737{ 737{
738 QStringList uidList = mViewManager->selectedUids(); 738 QStringList uidList = mViewManager->selectedUids();
739 739
740//US if ( uidList.size() > 0 ) { 740//US if ( uidList.size() > 0 ) {
741 if ( uidList.count() > 0 ) { 741 if ( uidList.count() > 0 ) {
742 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 742 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
743 UndoStack::instance()->push( command ); 743 UndoStack::instance()->push( command );
744 RedoStack::instance()->clear(); 744 RedoStack::instance()->clear();
745 745
746 setModified( true ); 746 setModified( true );
747 } 747 }
748} 748}
749 749
750void KABCore::pasteContacts() 750void KABCore::pasteContacts()
751{ 751{
752 QClipboard *cb = QApplication::clipboard(); 752 QClipboard *cb = QApplication::clipboard();
753 753
754 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 754 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
755 755
756 pasteContacts( list ); 756 pasteContacts( list );
757} 757}
758 758
759void KABCore::pasteContacts( KABC::Addressee::List &list ) 759void KABCore::pasteContacts( KABC::Addressee::List &list )
760{ 760{
761 KABC::Resource *resource = requestResource( this ); 761 KABC::Resource *resource = requestResource( this );
762 KABC::Addressee::List::Iterator it; 762 KABC::Addressee::List::Iterator it;
763 for ( it = list.begin(); it != list.end(); ++it ) 763 for ( it = list.begin(); it != list.end(); ++it )
764 (*it).setResource( resource ); 764 (*it).setResource( resource );
765 765
766 PwPasteCommand *command = new PwPasteCommand( this, list ); 766 PwPasteCommand *command = new PwPasteCommand( this, list );
767 UndoStack::instance()->push( command ); 767 UndoStack::instance()->push( command );
768 RedoStack::instance()->clear(); 768 RedoStack::instance()->clear();
769 769
770 setModified( true ); 770 setModified( true );
771} 771}
772 772
773void KABCore::setWhoAmI() 773void KABCore::setWhoAmI()
774{ 774{
775 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 775 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
776 776
777 if ( addrList.count() > 1 ) { 777 if ( addrList.count() > 1 ) {
778 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 778 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
779 return; 779 return;
780 } 780 }
781 781
782 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 782 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
783 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 783 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
784 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 784 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
785} 785}
786 786
787void KABCore::setCategories() 787void KABCore::setCategories()
788{ 788{
789 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 789 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
790 if ( !dlg.exec() ) 790 if ( !dlg.exec() )
791 return; 791 return;
792 792
793 bool merge = false; 793 bool merge = false;
794 QString msg = i18n( "Merge with existing categories?" ); 794 QString msg = i18n( "Merge with existing categories?" );
795 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 795 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
796 merge = true; 796 merge = true;
797 797
798 QStringList categories = dlg.selectedCategories(); 798 QStringList categories = dlg.selectedCategories();
799 799
800 QStringList uids = mViewManager->selectedUids(); 800 QStringList uids = mViewManager->selectedUids();
801 QStringList::Iterator it; 801 QStringList::Iterator it;
802 for ( it = uids.begin(); it != uids.end(); ++it ) { 802 for ( it = uids.begin(); it != uids.end(); ++it ) {
803 KABC::Addressee addr = mAddressBook->findByUid( *it ); 803 KABC::Addressee addr = mAddressBook->findByUid( *it );
804 if ( !addr.isEmpty() ) { 804 if ( !addr.isEmpty() ) {
805 if ( !merge ) 805 if ( !merge )
806 addr.setCategories( categories ); 806 addr.setCategories( categories );
807 else { 807 else {
808 QStringList addrCategories = addr.categories(); 808 QStringList addrCategories = addr.categories();
809 QStringList::Iterator catIt; 809 QStringList::Iterator catIt;
810 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 810 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
811 if ( !addrCategories.contains( *catIt ) ) 811 if ( !addrCategories.contains( *catIt ) )
812 addrCategories.append( *catIt ); 812 addrCategories.append( *catIt );
813 } 813 }
814 addr.setCategories( addrCategories ); 814 addr.setCategories( addrCategories );
815 } 815 }
816 816
817 mAddressBook->insertAddressee( addr ); 817 mAddressBook->insertAddressee( addr );
818 } 818 }
819 } 819 }
820 820
821 if ( uids.count() > 0 ) 821 if ( uids.count() > 0 )
822 setModified( true ); 822 setModified( true );
823} 823}
824 824
825void KABCore::setSearchFields( const KABC::Field::List &fields ) 825void KABCore::setSearchFields( const KABC::Field::List &fields )
826{ 826{
827 mIncSearchWidget->setFields( fields ); 827 mIncSearchWidget->setFields( fields );
828} 828}
829 829
830void KABCore::incrementalSearch( const QString& text ) 830void KABCore::incrementalSearch( const QString& text )
831{ 831{
832 mViewManager->setSelected( QString::null, false ); 832 mViewManager->setSelected( QString::null, false );
833 833
834 if ( !text.isEmpty() ) { 834 if ( !text.isEmpty() ) {
835 KABC::Field *field = mIncSearchWidget->currentField(); 835 KABC::Field *field = mIncSearchWidget->currentField();
836 QString pattern = text.lower()+"*"; 836 QString pattern = text.lower()+"*";
837 QRegExp re; 837 QRegExp re;
838 re.setWildcard(true); // most people understand these better. 838 re.setWildcard(true); // most people understand these better.
839 re.setCaseSensitive(false); 839 re.setCaseSensitive(false);
840 re.setPattern( pattern ); 840 re.setPattern( pattern );
841 QStringList foundUids; 841 QStringList foundUids;
842 if (!re.isValid()) 842 if (!re.isValid())
843 return; 843 return;
844#if 1 //KDE_VERSION >= 319 844#if 1 //KDE_VERSION >= 319
845 KABC::AddresseeList list( mAddressBook->allAddressees() ); 845 KABC::AddresseeList list( mAddressBook->allAddressees() );
846 if ( field ) { 846 if ( field ) {
847 list.sortByField( field ); 847 list.sortByField( field );
848 KABC::AddresseeList::Iterator it; 848 KABC::AddresseeList::Iterator it;
849 for ( it = list.begin(); it != list.end(); ++it ) { 849 for ( it = list.begin(); it != list.end(); ++it ) {
850 850
851#if QT_VERSION >= 300 851#if QT_VERSION >= 300
852 if (re.search(field->value( *it ).lower()) != -1) 852 if (re.search(field->value( *it ).lower()) != -1)
853#else 853#else
854 if (re.match(field->value( *it ).lower()) != -1) 854 if (re.match(field->value( *it ).lower()) != -1)
855#endif 855#endif
856 { 856 {
857 // if ( field->value( *it ).lower().startsWith( pattern ) ) { 857 // if ( field->value( *it ).lower().startsWith( pattern ) ) {
858 //mViewManager->setSelected( (*it).uid(), true ); 858 //mViewManager->setSelected( (*it).uid(), true );
859 foundUids.append( (*it).uid() ); 859 foundUids.append( (*it).uid() );
860 //return; 860 //return;
861 } 861 }
862 } 862 }
863 } else { 863 } else {
864 KABC::AddresseeList::Iterator it; 864 KABC::AddresseeList::Iterator it;
865 for ( it = list.begin(); it != list.end(); ++it ) { 865 for ( it = list.begin(); it != list.end(); ++it ) {
866 KABC::Field::List fieldList = mIncSearchWidget->fields(); 866 KABC::Field::List fieldList = mIncSearchWidget->fields();
867 KABC::Field::List::ConstIterator fieldIt; 867 KABC::Field::List::ConstIterator fieldIt;
868 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 868 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
869#if QT_VERSION >= 300 869#if QT_VERSION >= 300
870 if (re.search((*fieldIt)->value( *it ).lower()) != -1) 870 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
871#else 871#else
872 if (re.match((*fieldIt)->value( *it ).lower()) != -1) 872 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
873#endif 873#endif
874 { 874 {
875 // if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { 875 // if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) {
876 //mViewManager->setSelected( (*it).uid(), true ); 876 //mViewManager->setSelected( (*it).uid(), true );
877 foundUids.append( (*it).uid() ); 877 foundUids.append( (*it).uid() );
878 //return; 878 //return;
879 } 879 }
880 } 880 }
881 } 881 }
882 } 882 }
883 if ( foundUids.count() > 0 ) 883 if ( foundUids.count() > 0 )
884 mViewManager->setListSelected( foundUids ); 884 mViewManager->setListSelected( foundUids );
885#else 885#else
886 KABC::AddressBook::Iterator it; 886 KABC::AddressBook::Iterator it;
887 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 887 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
888 if ( field ) { 888 if ( field ) {
889 if ( field->value( *it ).lower().startsWith( pattern ) ) { 889 if ( field->value( *it ).lower().startsWith( pattern ) ) {
890 mViewManager->setSelected( (*it).uid(), true ); 890 mViewManager->setSelected( (*it).uid(), true );
891 return; 891 return;
892 } 892 }
893 } else { 893 } else {
894 KABC::Field::List fieldList = mIncSearchWidget->fields(); 894 KABC::Field::List fieldList = mIncSearchWidget->fields();
895 KABC::Field::List::ConstIterator fieldIt; 895 KABC::Field::List::ConstIterator fieldIt;
896 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 896 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
897 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { 897 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) {
898 mViewManager->setSelected( (*it).uid(), true ); 898 mViewManager->setSelected( (*it).uid(), true );
899 return; 899 return;
900 } 900 }
901 } 901 }
902 } 902 }
903 } 903 }
904#endif 904#endif
905 } 905 }
906} 906}
907 907
908void KABCore::setModified() 908void KABCore::setModified()
909{ 909{
910 setModified( true ); 910 setModified( true );
911} 911}
912 912
913void KABCore::setModifiedWOrefresh() 913void KABCore::setModifiedWOrefresh()
914{ 914{
915 // qDebug("KABCore::setModifiedWOrefresh() "); 915 // qDebug("KABCore::setModifiedWOrefresh() ");
916 mModified = true; 916 mModified = true;
917 mActionSave->setEnabled( mModified ); 917 mActionSave->setEnabled( mModified );
918#ifdef DESKTOP_VERSION 918#ifdef DESKTOP_VERSION
919 mDetails->refreshView(); 919 mDetails->refreshView();
920#endif 920#endif
921 921
922} 922}
923void KABCore::setModified( bool modified ) 923void KABCore::setModified( bool modified )
924{ 924{
925 mModified = modified; 925 mModified = modified;
926 mActionSave->setEnabled( mModified ); 926 mActionSave->setEnabled( mModified );
927 927
928 if ( modified ) 928 if ( modified )
929 mJumpButtonBar->recreateButtons(); 929 mJumpButtonBar->recreateButtons();
930 930
931 mViewManager->refreshView(); 931 mViewManager->refreshView();
932 mDetails->refreshView(); 932 mDetails->refreshView();
933 933
934} 934}
935 935
936bool KABCore::modified() const 936bool KABCore::modified() const
937{ 937{
938 return mModified; 938 return mModified;
939} 939}
940 940
941void KABCore::contactModified( const KABC::Addressee &addr ) 941void KABCore::contactModified( const KABC::Addressee &addr )
942{ 942{
943 943
944 Command *command = 0; 944 Command *command = 0;
945 QString uid; 945 QString uid;
946 946
947 // check if it exists already 947 // check if it exists already
948 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 948 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
949 if ( origAddr.isEmpty() ) 949 if ( origAddr.isEmpty() )
950 command = new PwNewCommand( mAddressBook, addr ); 950 command = new PwNewCommand( mAddressBook, addr );
951 else { 951 else {
952 command = new PwEditCommand( mAddressBook, origAddr, addr ); 952 command = new PwEditCommand( mAddressBook, origAddr, addr );
953 uid = addr.uid(); 953 uid = addr.uid();
954 } 954 }
955 955
956 UndoStack::instance()->push( command ); 956 UndoStack::instance()->push( command );
957 RedoStack::instance()->clear(); 957 RedoStack::instance()->clear();
958 958
959 setModified( true ); 959 setModified( true );
960} 960}
961 961
962void KABCore::newContact() 962void KABCore::newContact()
963{ 963{
964 964
965 965
966 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 966 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
967 967
968 QPtrList<KRES::Resource> kresResources; 968 QPtrList<KRES::Resource> kresResources;
969 QPtrListIterator<KABC::Resource> it( kabcResources ); 969 QPtrListIterator<KABC::Resource> it( kabcResources );
970 KABC::Resource *resource; 970 KABC::Resource *resource;
971 while ( ( resource = it.current() ) != 0 ) { 971 while ( ( resource = it.current() ) != 0 ) {
972 ++it; 972 ++it;
973 if ( !resource->readOnly() ) { 973 if ( !resource->readOnly() ) {
974 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 974 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
975 if ( res ) 975 if ( res )
976 kresResources.append( res ); 976 kresResources.append( res );
977 } 977 }
978 } 978 }
979 979
980 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 980 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
981 resource = static_cast<KABC::Resource*>( res ); 981 resource = static_cast<KABC::Resource*>( res );
982 982
983 if ( resource ) { 983 if ( resource ) {
984 KABC::Addressee addr; 984 KABC::Addressee addr;
985 addr.setResource( resource ); 985 addr.setResource( resource );
986 mEditorDialog->setAddressee( addr ); 986 mEditorDialog->setAddressee( addr );
987 KApplication::execDialog ( mEditorDialog ); 987 KApplication::execDialog ( mEditorDialog );
988 988
989 } else 989 } else
990 return; 990 return;
991 991
992 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 992 // mEditorDict.insert( dialog->addressee().uid(), dialog );
993 993
994 994
995} 995}
996 996
997void KABCore::addEmail( QString aStr ) 997void KABCore::addEmail( QString aStr )
998{ 998{
999#ifndef KAB_EMBEDDED 999#ifndef KAB_EMBEDDED
1000 QString fullName, email; 1000 QString fullName, email;
1001 1001
1002 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1002 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1003 1003
1004 // Try to lookup the addressee matching the email address 1004 // Try to lookup the addressee matching the email address
1005 bool found = false; 1005 bool found = false;
1006 QStringList emailList; 1006 QStringList emailList;
1007 KABC::AddressBook::Iterator it; 1007 KABC::AddressBook::Iterator it;
1008 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1008 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1009 emailList = (*it).emails(); 1009 emailList = (*it).emails();
1010 if ( emailList.contains( email ) > 0 ) { 1010 if ( emailList.contains( email ) > 0 ) {
1011 found = true; 1011 found = true;
1012 (*it).setNameFromString( fullName ); 1012 (*it).setNameFromString( fullName );
1013 editContact( (*it).uid() ); 1013 editContact( (*it).uid() );
1014 } 1014 }
1015 } 1015 }
1016 1016
1017 if ( !found ) { 1017 if ( !found ) {
1018 KABC::Addressee addr; 1018 KABC::Addressee addr;
1019 addr.setNameFromString( fullName ); 1019 addr.setNameFromString( fullName );
1020 addr.insertEmail( email, true ); 1020 addr.insertEmail( email, true );
1021 1021
1022 mAddressBook->insertAddressee( addr ); 1022 mAddressBook->insertAddressee( addr );
1023 mViewManager->refreshView( addr.uid() ); 1023 mViewManager->refreshView( addr.uid() );
1024 editContact( addr.uid() ); 1024 editContact( addr.uid() );
1025 } 1025 }
1026#else //KAB_EMBEDDED 1026#else //KAB_EMBEDDED
1027 qDebug("KABCore::addEmail finsih method"); 1027 qDebug("KABCore::addEmail finsih method");
1028#endif //KAB_EMBEDDED 1028#endif //KAB_EMBEDDED
1029} 1029}
1030 1030
1031void KABCore::importVCard( const KURL &url, bool showPreview ) 1031void KABCore::importVCard( const KURL &url, bool showPreview )
1032{ 1032{
1033 mXXPortManager->importVCard( url, showPreview ); 1033 mXXPortManager->importVCard( url, showPreview );
1034} 1034}
1035void KABCore::importFromOL() 1035void KABCore::importFromOL()
1036{ 1036{
1037#ifdef _WIN32_ 1037#ifdef _WIN32_
1038 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1038 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1039 idgl->exec(); 1039 idgl->exec();
1040 KABC::Addressee::List list = idgl->getAddressList(); 1040 KABC::Addressee::List list = idgl->getAddressList();
1041 if ( list.count() > 0 ) { 1041 if ( list.count() > 0 ) {
1042 KABC::Addressee::List listNew; 1042 KABC::Addressee::List listNew;
1043 KABC::Addressee::List listExisting; 1043 KABC::Addressee::List listExisting;
1044 KABC::Addressee::List::Iterator it; 1044 KABC::Addressee::List::Iterator it;
1045 KABC::AddressBook::Iterator iter; 1045 KABC::AddressBook::Iterator iter;
1046 for ( it = list.begin(); it != list.end(); ++it ) { 1046 for ( it = list.begin(); it != list.end(); ++it ) {
1047 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1047 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1048 listNew.append( (*it) ); 1048 listNew.append( (*it) );
1049 else 1049 else
1050 listExisting.append( (*it) ); 1050 listExisting.append( (*it) );
1051 } 1051 }
1052 if ( listExisting.count() > 0 ) 1052 if ( listExisting.count() > 0 )
1053 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1053 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1054 if ( listNew.count() > 0 ) { 1054 if ( listNew.count() > 0 ) {
1055 pasteWithNewUid = false; 1055 pasteWithNewUid = false;
1056 pasteContacts( listNew ); 1056 pasteContacts( listNew );
1057 pasteWithNewUid = true; 1057 pasteWithNewUid = true;
1058 } 1058 }
1059 } 1059 }
1060 delete idgl; 1060 delete idgl;
1061#endif 1061#endif
1062} 1062}
1063 1063
1064void KABCore::importVCard( const QString &vCard, bool showPreview ) 1064void KABCore::importVCard( const QString &vCard, bool showPreview )
1065{ 1065{
1066 mXXPortManager->importVCard( vCard, showPreview ); 1066 mXXPortManager->importVCard( vCard, showPreview );
1067} 1067}
1068 1068
1069//US added a second method without defaultparameter 1069//US added a second method without defaultparameter
1070void KABCore::editContact2() { 1070void KABCore::editContact2() {
1071 editContact( QString::null ); 1071 editContact( QString::null );
1072} 1072}
1073 1073
1074void KABCore::editContact( const QString &uid ) 1074void KABCore::editContact( const QString &uid )
1075{ 1075{
1076 1076
1077 if ( mExtensionManager->isQuickEditVisible() ) 1077 if ( mExtensionManager->isQuickEditVisible() )
1078 return; 1078 return;
1079 1079
1080 // First, locate the contact entry 1080 // First, locate the contact entry
1081 QString localUID = uid; 1081 QString localUID = uid;
1082 if ( localUID.isNull() ) { 1082 if ( localUID.isNull() ) {
1083 QStringList uidList = mViewManager->selectedUids(); 1083 QStringList uidList = mViewManager->selectedUids();
1084 if ( uidList.count() > 0 ) 1084 if ( uidList.count() > 0 )
1085 localUID = *( uidList.at( 0 ) ); 1085 localUID = *( uidList.at( 0 ) );
1086 } 1086 }
1087 1087
1088 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1088 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1089 if ( !addr.isEmpty() ) { 1089 if ( !addr.isEmpty() ) {
1090 mEditorDialog->setAddressee( addr ); 1090 mEditorDialog->setAddressee( addr );
1091 KApplication::execDialog ( mEditorDialog ); 1091 KApplication::execDialog ( mEditorDialog );
1092 } 1092 }
1093} 1093}
1094 1094
1095/** 1095/**
1096 Shows or edits the detail view for the given uid. If the uid is QString::null, 1096 Shows or edits the detail view for the given uid. If the uid is QString::null,
1097 the method will try to find a selected addressee in the view. 1097 the method will try to find a selected addressee in the view.
1098 */ 1098 */
1099void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1099void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1100{ 1100{
1101 if ( mMultipleViewsAtOnce ) 1101 if ( mMultipleViewsAtOnce )
1102 { 1102 {
1103 editContact( uid ); 1103 editContact( uid );
1104 } 1104 }
1105 else 1105 else
1106 { 1106 {
1107 setDetailsVisible( true ); 1107 setDetailsVisible( true );
1108 mActionDetails->setChecked(true); 1108 mActionDetails->setChecked(true);
1109 } 1109 }
1110 1110
1111} 1111}
1112 1112
1113void KABCore::save() 1113void KABCore::save()
1114{ 1114{
1115 if ( !mModified ) 1115 if ( !mModified )
1116 return; 1116 return;
1117 QString text = i18n( "There was an error while attempting to save\n the " 1117 QString text = i18n( "There was an error while attempting to save\n the "
1118 "address book. Please check that some \nother application is " 1118 "address book. Please check that some \nother application is "
1119 "not using it. " ); 1119 "not using it. " );
1120 statusMessage(i18n("Saving addressbook ... ")); 1120 statusMessage(i18n("Saving addressbook ... "));
1121#ifndef KAB_EMBEDDED 1121#ifndef KAB_EMBEDDED
1122 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1122 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1123 if ( !b || !b->save() ) { 1123 if ( !b || !b->save() ) {
1124 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1124 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1125 } 1125 }
1126#else //KAB_EMBEDDED 1126#else //KAB_EMBEDDED
1127 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1127 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1128 if ( !b || !b->save() ) { 1128 if ( !b || !b->save() ) {
1129 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1129 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1130 } 1130 }
1131#endif //KAB_EMBEDDED 1131#endif //KAB_EMBEDDED
1132 1132
1133 statusMessage(i18n("Addressbook saved!")); 1133 statusMessage(i18n("Addressbook saved!"));
1134 setModified( false ); 1134 setModified( false );
1135} 1135}
1136 1136
1137void KABCore::statusMessage(QString mess , int time ) 1137void KABCore::statusMessage(QString mess , int time )
1138{ 1138{
1139 //topLevelWidget()->setCaption( mess ); 1139 //topLevelWidget()->setCaption( mess );
1140 // pending setting timer to revome message 1140 // pending setting timer to revome message
1141} 1141}
1142void KABCore::undo() 1142void KABCore::undo()
1143{ 1143{
1144 UndoStack::instance()->undo(); 1144 UndoStack::instance()->undo();
1145 1145
1146 // Refresh the view 1146 // Refresh the view
1147 mViewManager->refreshView(); 1147 mViewManager->refreshView();
1148} 1148}
1149 1149
1150void KABCore::redo() 1150void KABCore::redo()
1151{ 1151{
1152 RedoStack::instance()->redo(); 1152 RedoStack::instance()->redo();
1153 1153
1154 // Refresh the view 1154 // Refresh the view
1155 mViewManager->refreshView(); 1155 mViewManager->refreshView();
1156} 1156}
1157 1157
1158void KABCore::setJumpButtonBarVisible( bool visible ) 1158void KABCore::setJumpButtonBarVisible( bool visible )
1159{ 1159{
1160 if (mMultipleViewsAtOnce) 1160 if (mMultipleViewsAtOnce)
1161 { 1161 {
1162 if ( visible ) 1162 if ( visible )
1163 mJumpButtonBar->show(); 1163 mJumpButtonBar->show();
1164 else 1164 else
1165 mJumpButtonBar->hide(); 1165 mJumpButtonBar->hide();
1166 } 1166 }
1167 else 1167 else
1168 { 1168 {
1169 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1169 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1170 if (mViewManager->isVisible()) 1170 if (mViewManager->isVisible())
1171 { 1171 {
1172 if ( visible ) 1172 if ( visible )
1173 mJumpButtonBar->show(); 1173 mJumpButtonBar->show();
1174 else 1174 else
1175 mJumpButtonBar->hide(); 1175 mJumpButtonBar->hide();
1176 } 1176 }
1177 else 1177 else
1178 { 1178 {
1179 mJumpButtonBar->hide(); 1179 mJumpButtonBar->hide();
1180 } 1180 }
1181 } 1181 }
1182} 1182}
1183 1183
1184 1184
1185void KABCore::setDetailsToState() 1185void KABCore::setDetailsToState()
1186{ 1186{
1187 setDetailsVisible( mActionDetails->isChecked() ); 1187 setDetailsVisible( mActionDetails->isChecked() );
1188} 1188}
1189 1189
1190 1190
1191 1191
1192void KABCore::setDetailsVisible( bool visible ) 1192void KABCore::setDetailsVisible( bool visible )
1193{ 1193{
1194 if (visible && mDetails->isHidden()) 1194 if (visible && mDetails->isHidden())
1195 { 1195 {
1196 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1196 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1197 if ( addrList.count() > 0 ) 1197 if ( addrList.count() > 0 )
1198 mDetails->setAddressee( addrList[ 0 ] ); 1198 mDetails->setAddressee( addrList[ 0 ] );
1199 } 1199 }
1200 1200
1201 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1201 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1202 // the listview and the detailview. We do that by changing the splitbar size. 1202 // the listview and the detailview. We do that by changing the splitbar size.
1203 if (mMultipleViewsAtOnce) 1203 if (mMultipleViewsAtOnce)
1204 { 1204 {
1205 if ( visible ) 1205 if ( visible )
1206 mDetails->show(); 1206 mDetails->show();
1207 else 1207 else
1208 mDetails->hide(); 1208 mDetails->hide();
1209 } 1209 }
1210 else 1210 else
1211 { 1211 {
1212 if ( visible ) { 1212 if ( visible ) {
1213 mViewManager->hide(); 1213 mViewManager->hide();
1214 mDetails->show(); 1214 mDetails->show();
1215 } 1215 }
1216 else { 1216 else {
1217 mViewManager->show(); 1217 mViewManager->show();
1218 mDetails->hide(); 1218 mDetails->hide();
1219 } 1219 }
1220 setJumpButtonBarVisible( !visible ); 1220 setJumpButtonBarVisible( !visible );
1221 } 1221 }
1222 1222
1223} 1223}
1224 1224
1225void KABCore::extensionChanged( int id ) 1225void KABCore::extensionChanged( int id )
1226{ 1226{
1227 //change the details view only for non desktop systems 1227 //change the details view only for non desktop systems
1228#ifndef DESKTOP_VERSION 1228#ifndef DESKTOP_VERSION
1229 1229
1230 if (id == 0) 1230 if (id == 0)
1231 { 1231 {
1232 //the user disabled the extension. 1232 //the user disabled the extension.
1233 1233
1234 if (mMultipleViewsAtOnce) 1234 if (mMultipleViewsAtOnce)
1235 { // enable detailsview again 1235 { // enable detailsview again
1236 setDetailsVisible( true ); 1236 setDetailsVisible( true );
1237 mActionDetails->setChecked( true ); 1237 mActionDetails->setChecked( true );
1238 } 1238 }
1239 else 1239 else
1240 { //go back to the listview 1240 { //go back to the listview
1241 setDetailsVisible( false ); 1241 setDetailsVisible( false );
1242 mActionDetails->setChecked( false ); 1242 mActionDetails->setChecked( false );
1243 mActionDetails->setEnabled(true); 1243 mActionDetails->setEnabled(true);
1244 } 1244 }
1245 1245
1246 } 1246 }
1247 else 1247 else
1248 { 1248 {
1249 //the user enabled the extension. 1249 //the user enabled the extension.
1250 setDetailsVisible( false ); 1250 setDetailsVisible( false );
1251 mActionDetails->setChecked( false ); 1251 mActionDetails->setChecked( false );
1252 1252
1253 if (!mMultipleViewsAtOnce) 1253 if (!mMultipleViewsAtOnce)
1254 { 1254 {
1255 mActionDetails->setEnabled(false); 1255 mActionDetails->setEnabled(false);
1256 } 1256 }
1257 1257
1258 mExtensionManager->setSelectionChanged(); 1258 mExtensionManager->setSelectionChanged();
1259 1259
1260 } 1260 }
1261 1261
1262#endif// DESKTOP_VERSION 1262#endif// DESKTOP_VERSION
1263 1263
1264} 1264}
1265 1265
1266 1266
1267void KABCore::extensionModified( const KABC::Addressee::List &list ) 1267void KABCore::extensionModified( const KABC::Addressee::List &list )
1268{ 1268{
1269 1269
1270 if ( list.count() != 0 ) { 1270 if ( list.count() != 0 ) {
1271 KABC::Addressee::List::ConstIterator it; 1271 KABC::Addressee::List::ConstIterator it;
1272 for ( it = list.begin(); it != list.end(); ++it ) 1272 for ( it = list.begin(); it != list.end(); ++it )
1273 mAddressBook->insertAddressee( *it ); 1273 mAddressBook->insertAddressee( *it );
1274 if ( list.count() > 1 ) 1274 if ( list.count() > 1 )
1275 setModified(); 1275 setModified();
1276 else 1276 else
1277 setModifiedWOrefresh(); 1277 setModifiedWOrefresh();
1278 } 1278 }
1279 if ( list.count() == 0 ) 1279 if ( list.count() == 0 )
1280 mViewManager->refreshView(); 1280 mViewManager->refreshView();
1281 else 1281 else
1282 mViewManager->refreshView( list[ 0 ].uid() ); 1282 mViewManager->refreshView( list[ 0 ].uid() );
1283 1283
1284 1284
1285 1285
1286} 1286}
1287 1287
1288QString KABCore::getNameByPhone( const QString &phone ) 1288QString KABCore::getNameByPhone( const QString &phone )
1289{ 1289{
1290#ifndef KAB_EMBEDDED 1290#ifndef KAB_EMBEDDED
1291 QRegExp r( "[/*/-/ ]" ); 1291 QRegExp r( "[/*/-/ ]" );
1292 QString localPhone( phone ); 1292 QString localPhone( phone );
1293 1293
1294 bool found = false; 1294 bool found = false;
1295 QString ownerName = ""; 1295 QString ownerName = "";
1296 KABC::AddressBook::Iterator iter; 1296 KABC::AddressBook::Iterator iter;
1297 KABC::PhoneNumber::List::Iterator phoneIter; 1297 KABC::PhoneNumber::List::Iterator phoneIter;
1298 KABC::PhoneNumber::List phoneList; 1298 KABC::PhoneNumber::List phoneList;
1299 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1299 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1300 phoneList = (*iter).phoneNumbers(); 1300 phoneList = (*iter).phoneNumbers();
1301 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1301 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1302 ++phoneIter) { 1302 ++phoneIter) {
1303 // Get rid of separator chars so just the numbers are compared. 1303 // Get rid of separator chars so just the numbers are compared.
1304 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1304 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1305 ownerName = (*iter).formattedName(); 1305 ownerName = (*iter).formattedName();
1306 found = true; 1306 found = true;
1307 } 1307 }
1308 } 1308 }
1309 } 1309 }
1310 1310
1311 return ownerName; 1311 return ownerName;
1312#else //KAB_EMBEDDED 1312#else //KAB_EMBEDDED
1313 qDebug("KABCore::getNameByPhone finsih method"); 1313 qDebug("KABCore::getNameByPhone finsih method");
1314 return ""; 1314 return "";
1315#endif //KAB_EMBEDDED 1315#endif //KAB_EMBEDDED
1316 1316
1317} 1317}
1318 1318
1319void KABCore::openConfigDialog() 1319void KABCore::openConfigDialog()
1320{ 1320{
1321 KABPrefs* kab_prefs = KABPrefs::instance(); 1321 KABPrefs* kab_prefs = KABPrefs::instance();
1322 KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance(); 1322 KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance();
1323 1323
1324 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1324 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1325 KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1325 KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1326 ConfigureDialog->addModule(kabcfg ); 1326 ConfigureDialog->addModule(kabcfg );
1327 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1327 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1328 ConfigureDialog->addModule(kdelibcfg ); 1328 ConfigureDialog->addModule(kdelibcfg );
1329 1329
1330 1330
1331 1331
1332 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1332 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1333 this, SLOT( configurationChanged() ) ); 1333 this, SLOT( configurationChanged() ) );
1334 connect( ConfigureDialog, SIGNAL( okClicked() ), 1334 connect( ConfigureDialog, SIGNAL( okClicked() ),
1335 this, SLOT( configurationChanged() ) ); 1335 this, SLOT( configurationChanged() ) );
1336 saveSettings(); 1336 saveSettings();
1337#ifndef DESKTOP_VERSION 1337#ifndef DESKTOP_VERSION
1338 ConfigureDialog->showMaximized(); 1338 ConfigureDialog->showMaximized();
1339#endif 1339#endif
1340 if ( ConfigureDialog->exec() ) 1340 if ( ConfigureDialog->exec() )
1341 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1341 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1342 delete ConfigureDialog; 1342 delete ConfigureDialog;
1343} 1343}
1344 1344
1345void KABCore::openLDAPDialog() 1345void KABCore::openLDAPDialog()
1346{ 1346{
1347#ifndef KAB_EMBEDDED 1347#ifndef KAB_EMBEDDED
1348 if ( !mLdapSearchDialog ) { 1348 if ( !mLdapSearchDialog ) {
1349 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1349 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1350 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1350 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1351 SLOT( refreshView() ) ); 1351 SLOT( refreshView() ) );
1352 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1352 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1353 SLOT( setModified() ) ); 1353 SLOT( setModified() ) );
1354 } else 1354 } else
1355 mLdapSearchDialog->restoreSettings(); 1355 mLdapSearchDialog->restoreSettings();
1356 1356
1357 if ( mLdapSearchDialog->isOK() ) 1357 if ( mLdapSearchDialog->isOK() )
1358 mLdapSearchDialog->exec(); 1358 mLdapSearchDialog->exec();
1359#else //KAB_EMBEDDED 1359#else //KAB_EMBEDDED
1360 qDebug("KABCore::openLDAPDialog() finsih method"); 1360 qDebug("KABCore::openLDAPDialog() finsih method");
1361#endif //KAB_EMBEDDED 1361#endif //KAB_EMBEDDED
1362} 1362}
1363 1363
1364void KABCore::print() 1364void KABCore::print()
1365{ 1365{
1366#ifndef KAB_EMBEDDED 1366#ifndef KAB_EMBEDDED
1367 KPrinter printer; 1367 KPrinter printer;
1368 if ( !printer.setup( this ) ) 1368 if ( !printer.setup( this ) )
1369 return; 1369 return;
1370 1370
1371 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1371 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1372 mViewManager->selectedUids(), this ); 1372 mViewManager->selectedUids(), this );
1373 1373
1374 wizard.exec(); 1374 wizard.exec();
1375#else //KAB_EMBEDDED 1375#else //KAB_EMBEDDED
1376 qDebug("KABCore::print() finsih method"); 1376 qDebug("KABCore::print() finsih method");
1377#endif //KAB_EMBEDDED 1377#endif //KAB_EMBEDDED
1378 1378
1379} 1379}
1380 1380
1381 1381
1382void KABCore::addGUIClient( KXMLGUIClient *client ) 1382void KABCore::addGUIClient( KXMLGUIClient *client )
1383{ 1383{
1384 if ( mGUIClient ) 1384 if ( mGUIClient )
1385 mGUIClient->insertChildClient( client ); 1385 mGUIClient->insertChildClient( client );
1386 else 1386 else
1387 KMessageBox::error( this, "no KXMLGUICLient"); 1387 KMessageBox::error( this, "no KXMLGUICLient");
1388} 1388}
1389 1389
1390 1390
1391void KABCore::configurationChanged() 1391void KABCore::configurationChanged()
1392{ 1392{
1393 mExtensionManager->reconfigure(); 1393 mExtensionManager->reconfigure();
1394} 1394}
1395 1395
1396void KABCore::addressBookChanged() 1396void KABCore::addressBookChanged()
1397{ 1397{
1398/*US 1398/*US
1399 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1399 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1400 while ( it.current() ) { 1400 while ( it.current() ) {
1401 if ( it.current()->dirty() ) { 1401 if ( it.current()->dirty() ) {
1402 QString text = i18n( "Data has been changed externally. Unsaved " 1402 QString text = i18n( "Data has been changed externally. Unsaved "
1403 "changes will be lost." ); 1403 "changes will be lost." );
1404 KMessageBox::information( this, text ); 1404 KMessageBox::information( this, text );
1405 } 1405 }
1406 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1406 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1407 ++it; 1407 ++it;
1408 } 1408 }
1409*/ 1409*/
1410 if (mEditorDialog) 1410 if (mEditorDialog)
1411 { 1411 {
1412 if (mEditorDialog->dirty()) 1412 if (mEditorDialog->dirty())
1413 { 1413 {
1414 QString text = i18n( "Data has been changed externally. Unsaved " 1414 QString text = i18n( "Data has been changed externally. Unsaved "
1415 "changes will be lost." ); 1415 "changes will be lost." );
1416 KMessageBox::information( this, text ); 1416 KMessageBox::information( this, text );
1417 } 1417 }
1418 QString currentuid = mEditorDialog->addressee().uid(); 1418 QString currentuid = mEditorDialog->addressee().uid();
1419 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1419 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1420 } 1420 }
1421 mViewManager->refreshView(); 1421 mViewManager->refreshView();
1422// mDetails->refreshView(); 1422// mDetails->refreshView();
1423 1423
1424 1424
1425} 1425}
1426 1426
1427AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1427AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1428 const char *name ) 1428 const char *name )
1429{ 1429{
1430 1430
1431 if ( mEditorDialog == 0 ) { 1431 if ( mEditorDialog == 0 ) {
1432 mEditorDialog = new AddresseeEditorDialog( this, parent, 1432 mEditorDialog = new AddresseeEditorDialog( this, parent,
1433 name ? name : "editorDialog" ); 1433 name ? name : "editorDialog" );
1434 1434
1435 1435
1436 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1436 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1437 SLOT( contactModified( const KABC::Addressee& ) ) ); 1437 SLOT( contactModified( const KABC::Addressee& ) ) );
1438 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1438 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1439 // SLOT( slotEditorDestroyed( const QString& ) ) ); 1439 // SLOT( slotEditorDestroyed( const QString& ) ) );
1440 } 1440 }
1441 1441
1442 return mEditorDialog; 1442 return mEditorDialog;
1443} 1443}
1444 1444
1445void KABCore::slotEditorDestroyed( const QString &uid ) 1445void KABCore::slotEditorDestroyed( const QString &uid )
1446{ 1446{
1447 //mEditorDict.remove( uid ); 1447 //mEditorDict.remove( uid );
1448} 1448}
1449 1449
1450void KABCore::initGUI() 1450void KABCore::initGUI()
1451{ 1451{
1452#ifndef KAB_EMBEDDED 1452#ifndef KAB_EMBEDDED
1453 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1453 QHBoxLayout *topLayout = new QHBoxLayout( this );
1454 topLayout->setSpacing( KDialogBase::spacingHint() ); 1454 topLayout->setSpacing( KDialogBase::spacingHint() );
1455 1455
1456 mExtensionBarSplitter = new QSplitter( this ); 1456 mExtensionBarSplitter = new QSplitter( this );
1457 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1457 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1458 1458
1459 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1459 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1460 1460
1461 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1461 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1462 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1462 mIncSearchWidget = new IncSearchWidget( viewSpace );
1463 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1463 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1464 SLOT( incrementalSearch( const QString& ) ) ); 1464 SLOT( incrementalSearch( const QString& ) ) );
1465 1465
1466 mViewManager = new ViewManager( this, viewSpace ); 1466 mViewManager = new ViewManager( this, viewSpace );
1467 viewSpace->setStretchFactor( mViewManager, 1 ); 1467 viewSpace->setStretchFactor( mViewManager, 1 );
1468 1468
1469 mDetails = new ViewContainer( mDetailsSplitter ); 1469 mDetails = new ViewContainer( mDetailsSplitter );
1470 1470
1471 mJumpButtonBar = new JumpButtonBar( this, this ); 1471 mJumpButtonBar = new JumpButtonBar( this, this );
1472 1472
1473 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1473 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1474 1474
1475 topLayout->addWidget( mExtensionBarSplitter ); 1475 topLayout->addWidget( mExtensionBarSplitter );
1476 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1476 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1477 topLayout->addWidget( mJumpButtonBar ); 1477 topLayout->addWidget( mJumpButtonBar );
1478 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1478 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1479 1479
1480 mXXPortManager = new XXPortManager( this, this ); 1480 mXXPortManager = new XXPortManager( this, this );
1481 1481
1482#else //KAB_EMBEDDED 1482#else //KAB_EMBEDDED
1483 //US initialize viewMenu before settingup viewmanager. 1483 //US initialize viewMenu before settingup viewmanager.
1484 // Viewmanager needs this menu to plugin submenues. 1484 // Viewmanager needs this menu to plugin submenues.
1485 viewMenu = new QPopupMenu( this ); 1485 viewMenu = new QPopupMenu( this );
1486 settingsMenu = new QPopupMenu( this ); 1486 settingsMenu = new QPopupMenu( this );
1487 //filterMenu = new QPopupMenu( this ); 1487 //filterMenu = new QPopupMenu( this );
1488 ImportMenu = new QPopupMenu( this ); 1488 ImportMenu = new QPopupMenu( this );
1489 ExportMenu = new QPopupMenu( this ); 1489 ExportMenu = new QPopupMenu( this );
1490 1490
1491 changeMenu= new QPopupMenu( this ); 1491 changeMenu= new QPopupMenu( this );
1492 1492
1493//US since we have no splitter for the embedded system, setup 1493//US since we have no splitter for the embedded system, setup
1494// a layout with two frames. One left and one right. 1494// a layout with two frames. One left and one right.
1495 1495
1496 QBoxLayout *topLayout; 1496 QBoxLayout *topLayout;
1497 1497
1498 // = new QHBoxLayout( this ); 1498 // = new QHBoxLayout( this );
1499// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1499// QBoxLayout *topLayout = (QBoxLayout*)layout();
1500 1500
1501// QWidget *mainBox = new QWidget( this ); 1501// QWidget *mainBox = new QWidget( this );
1502// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1502// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1503 1503
1504#ifdef DESKTOP_VERSION 1504#ifdef DESKTOP_VERSION
1505 topLayout = new QHBoxLayout( this ); 1505 topLayout = new QHBoxLayout( this );
1506 1506
1507 1507
1508 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1508 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1509 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1509 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1510 1510
1511 topLayout->addWidget(mMiniSplitter ); 1511 topLayout->addWidget(mMiniSplitter );
1512 1512
1513 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1513 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1514 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1514 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1515 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1515 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1516 mDetails = new ViewContainer( mMiniSplitter ); 1516 mDetails = new ViewContainer( mMiniSplitter );
1517 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1517 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1518#else 1518#else
1519 if ( QApplication::desktop()->width() > 480 ) { 1519 if ( QApplication::desktop()->width() > 480 ) {
1520 topLayout = new QHBoxLayout( this ); 1520 topLayout = new QHBoxLayout( this );
1521 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1521 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1522 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1522 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1523 } else { 1523 } else {
1524 1524
1525 topLayout = new QHBoxLayout( this ); 1525 topLayout = new QHBoxLayout( this );
1526 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1526 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1527 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1527 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1528 } 1528 }
1529 1529
1530 topLayout->addWidget(mMiniSplitter ); 1530 topLayout->addWidget(mMiniSplitter );
1531 mViewManager = new ViewManager( this, mMiniSplitter ); 1531 mViewManager = new ViewManager( this, mMiniSplitter );
1532 mDetails = new ViewContainer( mMiniSplitter ); 1532 mDetails = new ViewContainer( mMiniSplitter );
1533 1533
1534 1534
1535 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1535 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1536#endif 1536#endif
1537 //eh->hide(); 1537 //eh->hide();
1538 // topLayout->addWidget(mExtensionManager ); 1538 // topLayout->addWidget(mExtensionManager );
1539 1539
1540 1540
1541/*US 1541/*US
1542#ifndef KAB_NOSPLITTER 1542#ifndef KAB_NOSPLITTER
1543 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1543 QHBoxLayout *topLayout = new QHBoxLayout( this );
1544//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1544//US topLayout->setSpacing( KDialogBase::spacingHint() );
1545 topLayout->setSpacing( 10 ); 1545 topLayout->setSpacing( 10 );
1546 1546
1547 mDetailsSplitter = new QSplitter( this ); 1547 mDetailsSplitter = new QSplitter( this );
1548 1548
1549 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1549 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1550 1550
1551 mViewManager = new ViewManager( this, viewSpace ); 1551 mViewManager = new ViewManager( this, viewSpace );
1552 viewSpace->setStretchFactor( mViewManager, 1 ); 1552 viewSpace->setStretchFactor( mViewManager, 1 );
1553 1553
1554 mDetails = new ViewContainer( mDetailsSplitter ); 1554 mDetails = new ViewContainer( mDetailsSplitter );
1555 1555
1556 topLayout->addWidget( mDetailsSplitter ); 1556 topLayout->addWidget( mDetailsSplitter );
1557 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1557 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1558#else //KAB_NOSPLITTER 1558#else //KAB_NOSPLITTER
1559 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1559 QHBoxLayout *topLayout = new QHBoxLayout( this );
1560//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1560//US topLayout->setSpacing( KDialogBase::spacingHint() );
1561 topLayout->setSpacing( 10 ); 1561 topLayout->setSpacing( 10 );
1562 1562
1563// mDetailsSplitter = new QSplitter( this ); 1563// mDetailsSplitter = new QSplitter( this );
1564 1564
1565 QVBox *viewSpace = new QVBox( this ); 1565 QVBox *viewSpace = new QVBox( this );
1566 1566
1567 mViewManager = new ViewManager( this, viewSpace ); 1567 mViewManager = new ViewManager( this, viewSpace );
1568 viewSpace->setStretchFactor( mViewManager, 1 ); 1568 viewSpace->setStretchFactor( mViewManager, 1 );
1569 1569
1570 mDetails = new ViewContainer( this ); 1570 mDetails = new ViewContainer( this );
1571 1571
1572 topLayout->addWidget( viewSpace ); 1572 topLayout->addWidget( viewSpace );
1573// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1573// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1574 topLayout->addWidget( mDetails ); 1574 topLayout->addWidget( mDetails );
1575#endif //KAB_NOSPLITTER 1575#endif //KAB_NOSPLITTER
1576*/ 1576*/
1577 1577
1578 1578
1579#endif //KAB_EMBEDDED 1579#endif //KAB_EMBEDDED
1580 initActions(); 1580 initActions();
1581 1581
1582#ifdef KAB_EMBEDDED 1582#ifdef KAB_EMBEDDED
1583 addActionsManually(); 1583 addActionsManually();
1584 //US make sure the export and import menues are initialized before creating the xxPortManager. 1584 //US make sure the export and import menues are initialized before creating the xxPortManager.
1585 mXXPortManager = new XXPortManager( this, this ); 1585 mXXPortManager = new XXPortManager( this, this );
1586 1586
1587 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1587 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1588 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1588 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1589 // mActionQuit->plug ( mMainWindow->toolBar()); 1589 // mActionQuit->plug ( mMainWindow->toolBar());
1590 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1590 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1591 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1591 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1592 // mIncSearchWidget->hide(); 1592 // mIncSearchWidget->hide();
1593 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1593 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1594 SLOT( incrementalSearch( const QString& ) ) ); 1594 SLOT( incrementalSearch( const QString& ) ) );
1595 1595
1596 1596
1597 mJumpButtonBar = new JumpButtonBar( this, this ); 1597 mJumpButtonBar = new JumpButtonBar( this, this );
1598 1598
1599 topLayout->addWidget( mJumpButtonBar ); 1599 topLayout->addWidget( mJumpButtonBar );
1600//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1600//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1601 1601
1602// mMainWindow->getIconToolBar()->raise(); 1602// mMainWindow->getIconToolBar()->raise();
1603 1603
1604#endif //KAB_EMBEDDED 1604#endif //KAB_EMBEDDED
1605 1605
1606} 1606}
1607void KABCore::initActions() 1607void KABCore::initActions()
1608{ 1608{
1609//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1609//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1610 1610
1611#ifndef KAB_EMBEDDED 1611#ifndef KAB_EMBEDDED
1612 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1612 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1613 SLOT( clipboardDataChanged() ) ); 1613 SLOT( clipboardDataChanged() ) );
1614#endif //KAB_EMBEDDED 1614#endif //KAB_EMBEDDED
1615 1615
1616 // file menu 1616 // file menu
1617 if ( mIsPart ) { 1617 if ( mIsPart ) {
1618 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1618 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1619 SLOT( sendMail() ), actionCollection(), 1619 SLOT( sendMail() ), actionCollection(),
1620 "kaddressbook_mail" ); 1620 "kaddressbook_mail" );
1621 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1621 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1622 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1622 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1623 1623
1624 } else { 1624 } else {
1625 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1625 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1626 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1626 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1627 } 1627 }
1628 1628
1629 1629
1630 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1630 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1631 SLOT( save() ), actionCollection(), "file_sync" ); 1631 SLOT( save() ), actionCollection(), "file_sync" );
1632 1632
1633 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1633 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1634 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1634 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1635 1635
1636 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1636 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1637 this, SLOT( mailVCard() ), 1637 this, SLOT( mailVCard() ),
1638 actionCollection(), "file_mail_vcard"); 1638 actionCollection(), "file_mail_vcard");
1639 1639
1640 mActionBeamVCard = 0; 1640 mActionBeamVCard = 0;
1641 mActionBeam = 0; 1641 mActionBeam = 0;
1642 1642
1643#ifndef DESKTOP_VERSION 1643#ifndef DESKTOP_VERSION
1644 if ( Ir::supported() ) { 1644 if ( Ir::supported() ) {
1645 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, 1645 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this,
1646 SLOT( beamVCard() ), actionCollection(), 1646 SLOT( beamVCard() ), actionCollection(),
1647 "kaddressbook_beam_vcard" ); 1647 "kaddressbook_beam_vcard" );
1648 1648
1649 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1649 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1650 SLOT( beamMySelf() ), actionCollection(), 1650 SLOT( beamMySelf() ), actionCollection(),
1651 "kaddressbook_beam_myself" ); 1651 "kaddressbook_beam_myself" );
1652 } 1652 }
1653#endif 1653#endif
1654 1654
1655 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1655 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1656 this, SLOT( editContact2() ), 1656 this, SLOT( editContact2() ),
1657 actionCollection(), "file_properties" ); 1657 actionCollection(), "file_properties" );
1658 1658
1659#ifdef KAB_EMBEDDED 1659#ifdef KAB_EMBEDDED
1660 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1660 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1661 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1661 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1662 mMainWindow, SLOT( exit() ), 1662 mMainWindow, SLOT( exit() ),
1663 actionCollection(), "quit" ); 1663 actionCollection(), "quit" );
1664#endif //KAB_EMBEDDED 1664#endif //KAB_EMBEDDED
1665 1665
1666 // edit menu 1666 // edit menu
1667 if ( mIsPart ) { 1667 if ( mIsPart ) {
1668 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1668 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1669 SLOT( copyContacts() ), actionCollection(), 1669 SLOT( copyContacts() ), actionCollection(),
1670 "kaddressbook_copy" ); 1670 "kaddressbook_copy" );
1671 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1671 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1672 SLOT( cutContacts() ), actionCollection(), 1672 SLOT( cutContacts() ), actionCollection(),
1673 "kaddressbook_cut" ); 1673 "kaddressbook_cut" );
1674 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1674 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1675 SLOT( pasteContacts() ), actionCollection(), 1675 SLOT( pasteContacts() ), actionCollection(),
1676 "kaddressbook_paste" ); 1676 "kaddressbook_paste" );
1677 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1677 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1678 SLOT( selectAllContacts() ), actionCollection(), 1678 SLOT( selectAllContacts() ), actionCollection(),
1679 "kaddressbook_select_all" ); 1679 "kaddressbook_select_all" );
1680 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1680 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1681 SLOT( undo() ), actionCollection(), 1681 SLOT( undo() ), actionCollection(),
1682 "kaddressbook_undo" ); 1682 "kaddressbook_undo" );
1683 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1683 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1684 this, SLOT( redo() ), actionCollection(), 1684 this, SLOT( redo() ), actionCollection(),
1685 "kaddressbook_redo" ); 1685 "kaddressbook_redo" );
1686 } else { 1686 } else {
1687 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1687 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1688 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1688 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1689 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1689 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1690 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1690 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1691 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1691 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1692 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1692 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1693 } 1693 }
1694 1694
1695 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1695 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1696 Key_Delete, this, SLOT( deleteContacts() ), 1696 Key_Delete, this, SLOT( deleteContacts() ),
1697 actionCollection(), "edit_delete" ); 1697 actionCollection(), "edit_delete" );
1698 1698
1699 mActionUndo->setEnabled( false ); 1699 mActionUndo->setEnabled( false );
1700 mActionRedo->setEnabled( false ); 1700 mActionRedo->setEnabled( false );
1701 1701
1702 // settings menu 1702 // settings menu
1703#ifdef KAB_EMBEDDED 1703#ifdef KAB_EMBEDDED
1704//US special menuentry to configure the addressbook resources. On KDE 1704//US special menuentry to configure the addressbook resources. On KDE
1705// you do that through the control center !!! 1705// you do that through the control center !!!
1706 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1706 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1707 SLOT( configureResources() ), actionCollection(), 1707 SLOT( configureResources() ), actionCollection(),
1708 "kaddressbook_configure_resources" ); 1708 "kaddressbook_configure_resources" );
1709#endif //KAB_EMBEDDED 1709#endif //KAB_EMBEDDED
1710 1710
1711 if ( mIsPart ) { 1711 if ( mIsPart ) {
1712 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1712 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1713 SLOT( openConfigDialog() ), actionCollection(), 1713 SLOT( openConfigDialog() ), actionCollection(),
1714 "kaddressbook_configure" ); 1714 "kaddressbook_configure" );
1715 1715
1716 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1716 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1717 this, SLOT( configureKeyBindings() ), actionCollection(), 1717 this, SLOT( configureKeyBindings() ), actionCollection(),
1718 "kaddressbook_configure_shortcuts" ); 1718 "kaddressbook_configure_shortcuts" );
1719#ifdef KAB_EMBEDDED 1719#ifdef KAB_EMBEDDED
1720 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1720 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1721 mActionConfigureToolbars->setEnabled( false ); 1721 mActionConfigureToolbars->setEnabled( false );
1722#endif //KAB_EMBEDDED 1722#endif //KAB_EMBEDDED
1723 1723
1724 } else { 1724 } else {
1725 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1725 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1726 1726
1727 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1727 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1728 } 1728 }
1729 1729
1730 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1730 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1731 actionCollection(), "options_show_jump_bar" ); 1731 actionCollection(), "options_show_jump_bar" );
1732 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1732 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1733 1733
1734 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 1734 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1735 actionCollection(), "options_show_details" ); 1735 actionCollection(), "options_show_details" );
1736 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1736 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1737 1737
1738 // misc 1738 // misc
1739 // only enable LDAP lookup if we can handle the protocol 1739 // only enable LDAP lookup if we can handle the protocol
1740#ifndef KAB_EMBEDDED 1740#ifndef KAB_EMBEDDED
1741 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1741 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1742 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1742 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1743 this, SLOT( openLDAPDialog() ), actionCollection(), 1743 this, SLOT( openLDAPDialog() ), actionCollection(),
1744 "ldap_lookup" ); 1744 "ldap_lookup" );
1745 } 1745 }
1746#else //KAB_EMBEDDED 1746#else //KAB_EMBEDDED
1747 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1747 //qDebug("KABCore::initActions() LDAP has to be implemented");
1748#endif //KAB_EMBEDDED 1748#endif //KAB_EMBEDDED
1749 1749
1750 1750
1751 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1751 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1752 SLOT( setWhoAmI() ), actionCollection(), 1752 SLOT( setWhoAmI() ), actionCollection(),
1753 "set_personal" ); 1753 "set_personal" );
1754 1754
1755 1755
1756 1756
1757 1757
1758 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1758 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1759 SLOT( setCategories() ), actionCollection(), 1759 SLOT( setCategories() ), actionCollection(),
1760 "edit_set_categories" ); 1760 "edit_set_categories" );
1761 1761
1762 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1762 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1763 SLOT( removeVoice() ), actionCollection(), 1763 SLOT( removeVoice() ), actionCollection(),
1764 "remove_voice" ); 1764 "remove_voice" );
1765 mActionImportOL = new KAction( i18n( "Import from OL..." ), 0, this, 1765 mActionImportOL = new KAction( i18n( "Import from OL..." ), 0, this,
1766 SLOT( importFromOL() ), actionCollection(), 1766 SLOT( importFromOL() ), actionCollection(),
1767 "import_OL" ); 1767 "import_OL" );
1768#ifdef KAB_EMBEDDED 1768#ifdef KAB_EMBEDDED
1769 mActionLicence = new KAction( i18n( "Licence" ), 0, 1769 mActionLicence = new KAction( i18n( "Licence" ), 0,
1770 this, SLOT( showLicence() ), actionCollection(), 1770 this, SLOT( showLicence() ), actionCollection(),
1771 "licence_about_data" ); 1771 "licence_about_data" );
1772 mActionFaq = new KAction( i18n( "Faq" ), 0, 1772 mActionFaq = new KAction( i18n( "Faq" ), 0,
1773 this, SLOT( faq() ), actionCollection(), 1773 this, SLOT( faq() ), actionCollection(),
1774 "faq_about_data" ); 1774 "faq_about_data" );
1775 1775
1776 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 1776 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
1777 this, SLOT( createAboutData() ), actionCollection(), 1777 this, SLOT( createAboutData() ), actionCollection(),
1778 "kaddressbook_about_data" ); 1778 "kaddressbook_about_data" );
1779#endif //KAB_EMBEDDED 1779#endif //KAB_EMBEDDED
1780 1780
1781 clipboardDataChanged(); 1781 clipboardDataChanged();
1782 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1782 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1783 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1783 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1784} 1784}
1785 1785
1786//US we need this function, to plug all actions into the correct menues. 1786//US we need this function, to plug all actions into the correct menues.
1787// KDE uses a XML format to plug the actions, but we work her without this overhead. 1787// KDE uses a XML format to plug the actions, but we work her without this overhead.
1788void KABCore::addActionsManually() 1788void KABCore::addActionsManually()
1789{ 1789{
1790//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1790//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1791 1791
1792#ifdef KAB_EMBEDDED 1792#ifdef KAB_EMBEDDED
1793 QPopupMenu *fileMenu = new QPopupMenu( this ); 1793 QPopupMenu *fileMenu = new QPopupMenu( this );
1794 QPopupMenu *editMenu = new QPopupMenu( this ); 1794 QPopupMenu *editMenu = new QPopupMenu( this );
1795 QPopupMenu *helpMenu = new QPopupMenu( this ); 1795 QPopupMenu *helpMenu = new QPopupMenu( this );
1796 1796
1797 KToolBar* tb = mMainWindow->toolBar(); 1797 KToolBar* tb = mMainWindow->toolBar();
1798 1798
1799#ifdef DESKTOP_VERSION 1799#ifdef DESKTOP_VERSION
1800 QMenuBar* mb = mMainWindow->menuBar(); 1800 QMenuBar* mb = mMainWindow->menuBar();
1801 1801
1802 //US setup menubar. 1802 //US setup menubar.
1803 //Disable the following block if you do not want to have a menubar. 1803 //Disable the following block if you do not want to have a menubar.
1804 mb->insertItem( "&File", fileMenu ); 1804 mb->insertItem( "&File", fileMenu );
1805 mb->insertItem( "&Edit", editMenu ); 1805 mb->insertItem( "&Edit", editMenu );
1806 mb->insertItem( "&View", viewMenu ); 1806 mb->insertItem( "&View", viewMenu );
1807 mb->insertItem( "&Settings", settingsMenu ); 1807 mb->insertItem( "&Settings", settingsMenu );
1808 mb->insertItem( "&Change selected", changeMenu ); 1808 mb->insertItem( "&Change selected", changeMenu );
1809 mb->insertItem( "&Help", helpMenu ); 1809 mb->insertItem( "&Help", helpMenu );
1810 mIncSearchWidget = new IncSearchWidget( tb ); 1810 mIncSearchWidget = new IncSearchWidget( tb );
1811 // tb->insertWidget(-1, 0, mIncSearchWidget); 1811 // tb->insertWidget(-1, 0, mIncSearchWidget);
1812 1812
1813#else 1813#else
1814 //US setup toolbar 1814 //US setup toolbar
1815 QMenuBar *menuBarTB = new QMenuBar( tb ); 1815 QMenuBar *menuBarTB = new QMenuBar( tb );
1816 QPopupMenu *popupBarTB = new QPopupMenu( this ); 1816 QPopupMenu *popupBarTB = new QPopupMenu( this );
1817 menuBarTB->insertItem( "ME", popupBarTB); 1817 menuBarTB->insertItem( "ME", popupBarTB);
1818 tb->insertWidget(-1, 0, menuBarTB); 1818 tb->insertWidget(-1, 0, menuBarTB);
1819 mIncSearchWidget = new IncSearchWidget( tb ); 1819 mIncSearchWidget = new IncSearchWidget( tb );
1820 1820
1821 tb->enableMoving(false); 1821 tb->enableMoving(false);
1822 popupBarTB->insertItem( "&File", fileMenu ); 1822 popupBarTB->insertItem( "&File", fileMenu );
1823 popupBarTB->insertItem( "&Edit", editMenu ); 1823 popupBarTB->insertItem( "&Edit", editMenu );
1824 popupBarTB->insertItem( "&View", viewMenu ); 1824 popupBarTB->insertItem( "&View", viewMenu );
1825 popupBarTB->insertItem( "&Settings", settingsMenu ); 1825 popupBarTB->insertItem( "&Settings", settingsMenu );
1826 mViewManager->getFilterAction()->plug ( popupBarTB); 1826 mViewManager->getFilterAction()->plug ( popupBarTB);
1827 popupBarTB->insertItem( "&Change selected", changeMenu ); 1827 popupBarTB->insertItem( "&Change selected", changeMenu );
1828 popupBarTB->insertItem( "&Help", helpMenu ); 1828 popupBarTB->insertItem( "&Help", helpMenu );
1829 if (QApplication::desktop()->width() > 320 ) { 1829 if (QApplication::desktop()->width() > 320 ) {
1830 // mViewManager->getFilterAction()->plug ( tb); 1830 // mViewManager->getFilterAction()->plug ( tb);
1831 } 1831 }
1832#endif 1832#endif
1833 // mActionQuit->plug ( mMainWindow->toolBar()); 1833 // mActionQuit->plug ( mMainWindow->toolBar());
1834 1834
1835 1835
1836 1836
1837 //US Now connect the actions with the menue entries. 1837 //US Now connect the actions with the menue entries.
1838 mActionPrint->plug( fileMenu ); 1838 mActionPrint->plug( fileMenu );
1839 mActionMail->plug( fileMenu ); 1839 mActionMail->plug( fileMenu );
1840 fileMenu->insertSeparator(); 1840 fileMenu->insertSeparator();
1841 1841
1842 mActionNewContact->plug( fileMenu ); 1842 mActionNewContact->plug( fileMenu );
1843 mActionNewContact->plug( tb ); 1843 mActionNewContact->plug( tb );
1844 1844
1845 mActionEditAddressee->plug( fileMenu ); 1845 mActionEditAddressee->plug( fileMenu );
1846 if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 1846 if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
1847 (!KABPrefs::instance()->mMultipleViewsAtOnce )) 1847 (!KABPrefs::instance()->mMultipleViewsAtOnce ))
1848 mActionEditAddressee->plug( tb ); 1848 mActionEditAddressee->plug( tb );
1849 1849
1850 fileMenu->insertSeparator(); 1850 fileMenu->insertSeparator();
1851 mActionSave->plug( fileMenu ); 1851 mActionSave->plug( fileMenu );
1852 fileMenu->insertItem( "&Import", ImportMenu ); 1852 fileMenu->insertItem( "&Import", ImportMenu );
1853 fileMenu->insertItem( "&Emport", ExportMenu ); 1853 fileMenu->insertItem( "&Emport", ExportMenu );
1854 fileMenu->insertSeparator(); 1854 fileMenu->insertSeparator();
1855 mActionMailVCard->plug( fileMenu ); 1855 mActionMailVCard->plug( fileMenu );
1856#ifndef DESKTOP_VERSION 1856#ifndef DESKTOP_VERSION
1857 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); 1857 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
1858 if ( Ir::supported() ) mActionBeam->plug(fileMenu ); 1858 if ( Ir::supported() ) mActionBeam->plug(fileMenu );
1859#endif 1859#endif
1860 fileMenu->insertSeparator(); 1860 fileMenu->insertSeparator();
1861 mActionQuit->plug( fileMenu ); 1861 mActionQuit->plug( fileMenu );
1862#ifdef _WIN32_ 1862#ifdef _WIN32_
1863 mActionImportOL->plug( ImportMenu ); 1863 mActionImportOL->plug( ImportMenu );
1864#endif 1864#endif
1865 // edit menu 1865 // edit menu
1866 mActionUndo->plug( editMenu ); 1866 mActionUndo->plug( editMenu );
1867 mActionRedo->plug( editMenu ); 1867 mActionRedo->plug( editMenu );
1868 editMenu->insertSeparator(); 1868 editMenu->insertSeparator();
1869 mActionCut->plug( editMenu ); 1869 mActionCut->plug( editMenu );
1870 mActionCopy->plug( editMenu ); 1870 mActionCopy->plug( editMenu );
1871 mActionPaste->plug( editMenu ); 1871 mActionPaste->plug( editMenu );
1872 mActionDelete->plug( editMenu ); 1872 mActionDelete->plug( editMenu );
1873 editMenu->insertSeparator(); 1873 editMenu->insertSeparator();
1874 mActionSelectAll->plug( editMenu ); 1874 mActionSelectAll->plug( editMenu );
1875 1875
1876 mActionRemoveVoice->plug( changeMenu ); 1876 mActionRemoveVoice->plug( changeMenu );
1877 // settings menu 1877 // settings menu
1878//US special menuentry to configure the addressbook resources. On KDE 1878//US special menuentry to configure the addressbook resources. On KDE
1879// you do that through the control center !!! 1879// you do that through the control center !!!
1880 mActionConfigResources->plug( settingsMenu ); 1880 mActionConfigResources->plug( settingsMenu );
1881 settingsMenu->insertSeparator(); 1881 settingsMenu->insertSeparator();
1882 1882
1883 mActionConfigKAddressbook->plug( settingsMenu ); 1883 mActionConfigKAddressbook->plug( settingsMenu );
1884 1884
1885 if ( mIsPart ) { 1885 if ( mIsPart ) {
1886 mActionConfigShortcuts->plug( settingsMenu ); 1886 mActionConfigShortcuts->plug( settingsMenu );
1887 mActionConfigureToolbars->plug( settingsMenu ); 1887 mActionConfigureToolbars->plug( settingsMenu );
1888 1888
1889 } else { 1889 } else {
1890 mActionKeyBindings->plug( settingsMenu ); 1890 mActionKeyBindings->plug( settingsMenu );
1891 } 1891 }
1892 1892
1893 settingsMenu->insertSeparator(); 1893 settingsMenu->insertSeparator();
1894 1894
1895 mActionJumpBar->plug( settingsMenu ); 1895 mActionJumpBar->plug( settingsMenu );
1896 mActionDetails->plug( settingsMenu ); 1896 mActionDetails->plug( settingsMenu );
1897 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 1897 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
1898 mActionDetails->plug( tb ); 1898 mActionDetails->plug( tb );
1899 settingsMenu->insertSeparator(); 1899 settingsMenu->insertSeparator();
1900 1900
1901 mActionWhoAmI->plug( settingsMenu ); 1901 mActionWhoAmI->plug( settingsMenu );
1902 mActionCategories->plug( settingsMenu ); 1902 mActionCategories->plug( settingsMenu );
1903 1903
1904 mActionLicence->plug( helpMenu ); 1904 mActionLicence->plug( helpMenu );
1905 mActionFaq->plug( helpMenu ); 1905 mActionFaq->plug( helpMenu );
1906 mActionAboutKAddressbook->plug( helpMenu ); 1906 mActionAboutKAddressbook->plug( helpMenu );
1907 1907
1908 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 1908 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
1909 1909
1910 mActionSave->plug( tb ); 1910 mActionSave->plug( tb );
1911 mViewManager->getFilterAction()->plug ( tb); 1911 mViewManager->getFilterAction()->plug ( tb);
1912 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 1912 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
1913 mActionUndo->plug( tb ); 1913 mActionUndo->plug( tb );
1914 mActionDelete->plug( tb ); 1914 mActionDelete->plug( tb );
1915 mActionRedo->plug( tb ); 1915 mActionRedo->plug( tb );
1916 } 1916 }
1917 } 1917 }
1918 //mActionQuit->plug ( tb ); 1918 //mActionQuit->plug ( tb );
1919 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 1919 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
1920 1920
1921 //US link the searchwidget first to this. 1921 //US link the searchwidget first to this.
1922 // The real linkage to the toolbar happens later. 1922 // The real linkage to the toolbar happens later.
1923//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 1923//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
1924//US tb->insertItem( mIncSearchWidget ); 1924//US tb->insertItem( mIncSearchWidget );
1925/*US 1925/*US
1926 mIncSearchWidget = new IncSearchWidget( tb ); 1926 mIncSearchWidget = new IncSearchWidget( tb );
1927 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1927 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1928 SLOT( incrementalSearch( const QString& ) ) ); 1928 SLOT( incrementalSearch( const QString& ) ) );
1929 1929
1930 mJumpButtonBar = new JumpButtonBar( this, this ); 1930 mJumpButtonBar = new JumpButtonBar( this, this );
1931 1931
1932//US topLayout->addWidget( mJumpButtonBar ); 1932//US topLayout->addWidget( mJumpButtonBar );
1933 this->layout()->add( mJumpButtonBar ); 1933 this->layout()->add( mJumpButtonBar );
1934*/ 1934*/
1935 1935
1936#endif //KAB_EMBEDDED 1936#endif //KAB_EMBEDDED
1937} 1937}
1938void KABCore::showLicence() 1938void KABCore::showLicence()
1939{ 1939{
1940 KApplication::showLicence(); 1940 KApplication::showLicence();
1941} 1941}
1942void KABCore::removeVoice() 1942void KABCore::removeVoice()
1943{ 1943{
1944 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 ) 1944 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 )
1945 return; 1945 return;
1946 KABC::Addressee::List list = mViewManager->selectedAddressees(); 1946 KABC::Addressee::List list = mViewManager->selectedAddressees();
1947 KABC::Addressee::List::Iterator it; 1947 KABC::Addressee::List::Iterator it;
1948 for ( it = list.begin(); it != list.end(); ++it ) { 1948 for ( it = list.begin(); it != list.end(); ++it ) {
1949 PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); 1949 PhoneNumber::List phoneNumbers = (*it).phoneNumbers();
1950 PhoneNumber::List::Iterator phoneIt; 1950 PhoneNumber::List::Iterator phoneIt;
1951 bool found = false; 1951 bool found = false;
1952 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { 1952 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) {
1953 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 1953 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
1954 if ((*phoneIt).type() - PhoneNumber::Voice ) { 1954 if ((*phoneIt).type() - PhoneNumber::Voice ) {
1955 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 1955 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
1956 (*it).insertPhoneNumber( (*phoneIt) ); 1956 (*it).insertPhoneNumber( (*phoneIt) );
1957 found = true; 1957 found = true;
1958 } 1958 }
1959 } 1959 }
1960 1960
1961 } 1961 }
1962 if ( found ) 1962 if ( found )
1963 contactModified((*it) ); 1963 contactModified((*it) );
1964 } 1964 }
1965} 1965}
1966 1966
1967 1967
1968 1968
1969void KABCore::clipboardDataChanged() 1969void KABCore::clipboardDataChanged()
1970{ 1970{
1971 1971
1972 if ( mReadWrite ) 1972 if ( mReadWrite )
1973 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 1973 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
1974 1974
1975} 1975}
1976 1976
1977void KABCore::updateActionMenu() 1977void KABCore::updateActionMenu()
1978{ 1978{
1979 UndoStack *undo = UndoStack::instance(); 1979 UndoStack *undo = UndoStack::instance();
1980 RedoStack *redo = RedoStack::instance(); 1980 RedoStack *redo = RedoStack::instance();
1981 1981
1982 if ( undo->isEmpty() ) 1982 if ( undo->isEmpty() )
1983 mActionUndo->setText( i18n( "Undo" ) ); 1983 mActionUndo->setText( i18n( "Undo" ) );
1984 else 1984 else
1985 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 1985 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
1986 1986
1987 mActionUndo->setEnabled( !undo->isEmpty() ); 1987 mActionUndo->setEnabled( !undo->isEmpty() );
1988 1988
1989 if ( !redo->top() ) 1989 if ( !redo->top() )
1990 mActionRedo->setText( i18n( "Redo" ) ); 1990 mActionRedo->setText( i18n( "Redo" ) );
1991 else 1991 else
1992 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 1992 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
1993 1993
1994 mActionRedo->setEnabled( !redo->isEmpty() ); 1994 mActionRedo->setEnabled( !redo->isEmpty() );
1995} 1995}
1996 1996
1997void KABCore::configureKeyBindings() 1997void KABCore::configureKeyBindings()
1998{ 1998{
1999#ifndef KAB_EMBEDDED 1999#ifndef KAB_EMBEDDED
2000 KKeyDialog::configure( actionCollection(), true ); 2000 KKeyDialog::configure( actionCollection(), true );
2001#else //KAB_EMBEDDED 2001#else //KAB_EMBEDDED
2002 qDebug("KABCore::configureKeyBindings() not implemented"); 2002 qDebug("KABCore::configureKeyBindings() not implemented");
2003#endif //KAB_EMBEDDED 2003#endif //KAB_EMBEDDED
2004} 2004}
2005 2005
2006#ifdef KAB_EMBEDDED 2006#ifdef KAB_EMBEDDED
2007void KABCore::configureResources() 2007void KABCore::configureResources()
2008{ 2008{
2009 KRES::KCMKResources dlg( this, "" , 0 ); 2009 KRES::KCMKResources dlg( this, "" , 0 );
2010 2010
2011 if ( !dlg.exec() ) 2011 if ( !dlg.exec() )
2012 return; 2012 return;
2013 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2013 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2014} 2014}
2015#endif //KAB_EMBEDDED 2015#endif //KAB_EMBEDDED
2016 2016
2017 2017
2018/* this method will be called through the QCop interface from Ko/Pi to select addresses 2018/* this method will be called through the QCop interface from Ko/Pi to select addresses
2019 * for the attendees list of an event. 2019 * for the attendees list of an event.
2020 */ 2020 */
2021void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2021void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2022{ 2022{
2023 QStringList nameList; 2023 QStringList nameList;
2024 QStringList emailList; 2024 QStringList emailList;
2025 QStringList uidList; 2025 QStringList uidList;
2026 2026
2027 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2027 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2028 uint i=0; 2028 uint i=0;
2029 for (i=0; i < list.count(); i++) 2029 for (i=0; i < list.count(); i++)
2030 { 2030 {
2031 nameList.append(list[i].realName()); 2031 nameList.append(list[i].realName());
2032 emailList.append(list[i].preferredEmail()); 2032 emailList.append(list[i].preferredEmail());
2033 uidList.append(list[i].uid()); 2033 uidList.append(list[i].uid());
2034 } 2034 }
2035 2035
2036 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2036 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2037 2037
2038} 2038}
2039 2039
2040/* this method will be called through the QCop interface from other apps to show details of a contact. 2040/* this method will be called through the QCop interface from other apps to show details of a contact.
2041 */ 2041 */
2042void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2042void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2043{ 2043{
2044// qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2044 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2045 2045
2046 QString foundUid = QString::null; 2046 QString foundUid = QString::null;
2047 if (uid.isEmpty()) 2047 if (uid.isEmpty())
2048 { 2048 {
2049 //find the uid of the person first 2049 //find the uid of the person first
2050 Addressee::List namelist; 2050 Addressee::List namelist;
2051 Addressee::List emaillist; 2051 Addressee::List emaillist;
2052 2052
2053 if (!name.isEmpty()) 2053 if (!name.isEmpty())
2054 namelist = mAddressBook->findByName( name ); 2054 namelist = mAddressBook->findByName( name );
2055 2055
2056 if (!email.isEmpty()) 2056 if (!email.isEmpty())
2057 emaillist = mAddressBook->findByEmail( email ); 2057 emaillist = mAddressBook->findByEmail( email );
2058 2058 qDebug("count %d %d ", namelist.count(),emaillist.count() );
2059 //check if we have a match in Namelist and Emaillist 2059 //check if we have a match in Namelist and Emaillist
2060 if ((namelist.count() == 0) && (emaillist.count() > 0)) 2060 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2061 foundUid == emaillist[0].uid(); 2061 foundUid = emaillist[0].uid();
2062 }
2062 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2063 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2063 foundUid == namelist[0].uid(); 2064 foundUid = namelist[0].uid();
2064 else 2065 else
2065 { 2066 {
2066 for (int i = 0; i < namelist.count(); i++) 2067 for (int i = 0; i < namelist.count(); i++)
2067 { 2068 {
2068 for (int j = 0; j < emaillist.count(); j++) 2069 for (int j = 0; j < emaillist.count(); j++)
2069 { 2070 {
2070 if (namelist[i] == emaillist[j]) 2071 if (namelist[i] == emaillist[j])
2071 { 2072 {
2072 foundUid == namelist[i].uid(); 2073 foundUid = namelist[i].uid();
2073 } 2074 }
2074 } 2075 }
2075 } 2076 }
2076 } 2077 }
2077 } 2078 }
2078 else 2079 else
2079 { 2080 {
2080 foundUid = uid; 2081 foundUid = uid;
2081 } 2082 }
2082 2083
2083 if (!foundUid.isEmpty()) 2084 if (!foundUid.isEmpty())
2084 { 2085 {
2086
2085 // raise Ka/Pi if it is in the background 2087 // raise Ka/Pi if it is in the background
2086#ifndef DESKTOP_VERSION 2088#ifndef DESKTOP_VERSION
2087#ifndef KORG_NODCOP 2089#ifndef KORG_NODCOP
2088 QCopEnvelope e("QPE/Application/kapi", "raise()"); 2090 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2089#endif 2091#endif
2090#endif 2092#endif
2091 2093
2092 mMainWindow->showMaximized(); 2094 mMainWindow->showMaximized();
2095 mMainWindow-> raise();
2093 2096
2094 mViewManager->setSelected( "", false); 2097 mViewManager->setSelected( "", false);
2095 mViewManager->refreshView( "" ); 2098 mViewManager->refreshView( "" );
2096 mViewManager->setSelected( foundUid, true ); 2099 mViewManager->setSelected( foundUid, true );
2097 mViewManager->refreshView( foundUid ); 2100 mViewManager->refreshView( foundUid );
2098 2101
2099 if ( !mMultipleViewsAtOnce ) 2102 if ( !mMultipleViewsAtOnce )
2100 { 2103 {
2101 setDetailsVisible( true ); 2104 setDetailsVisible( true );
2102 mActionDetails->setChecked(true); 2105 mActionDetails->setChecked(true);
2103 } 2106 }
2104 } 2107 }
2105} 2108}
2106 2109
2107 2110
2108void KABCore::faq() 2111void KABCore::faq()
2109{ 2112{
2110 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2113 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2111} 2114}
2112 2115
2113 2116
2114 2117
2115 2118
2116#ifndef KAB_EMBEDDED 2119#ifndef KAB_EMBEDDED
2117#include "kabcore.moc" 2120#include "kabcore.moc"
2118#endif //KAB_EMBEDDED 2121#endif //KAB_EMBEDDED
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index 1f69700..0866939 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -1,541 +1,575 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@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 19
20#include <qcstring.h> 20#include <qcstring.h>
21#include <qwhatsthis.h> 21#include <qwhatsthis.h>
22#include <qdialog.h> 22#include <qdialog.h>
23#include <qapplication.h> 23#include <qapplication.h>
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qlayout.h> 25#include <qlayout.h>
26 26
27#include <klocale.h> 27#include <klocale.h>
28#include <kapplication.h> 28#include <kapplication.h>
29#include <libkcal/event.h> 29#include <libkcal/event.h>
30#include <libkcal/todo.h> 30#include <libkcal/todo.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kiconloader.h> 32#include <kiconloader.h>
33#include <krun.h> 33#include <krun.h>
34#include <kglobal.h> 34#include <kglobal.h>
35#include <kprocess.h> 35#include <kprocess.h>
36#include "koprefs.h" 36#include "koprefs.h"
37 37
38#include <libkdepim/addresseeview.h> 38#include <libkdepim/addresseeview.h>
39#include <kabc/stdaddressbook.h> 39#include <kabc/stdaddressbook.h>
40 40
41#ifndef KORG_NODCOP 41#ifndef KORG_NODCOP
42#include <dcopclient.h> 42#include <dcopclient.h>
43#include "korganizer.h" 43#include "korganizer.h"
44#include "koprefs.h" 44#include "koprefs.h"
45#include "actionmanager.h" 45#include "actionmanager.h"
46#endif 46#endif
47 47
48#include "koeventviewer.h" 48#include "koeventviewer.h"
49#ifndef KORG_NOKABC 49#ifndef KORG_NOKABC
50#include <kabc/stdaddressbook.h> 50#include <kabc/stdaddressbook.h>
51#define size count 51#define size count
52#endif 52#endif
53#ifndef DESKTOP_VERSION 53
54#ifdef DESKTOP_VERSION
55#include <kabc/addresseedialog.h>
56#else //DESKTOP_VERSION
57#include <externalapphandler.h>
54#include <qtopia/qcopenvelope_qws.h> 58#include <qtopia/qcopenvelope_qws.h>
55#endif 59#endif //DESKTOP_VERSION
56 60
57KOEventViewer::KOEventViewer(QWidget *parent,const char *name) 61KOEventViewer::KOEventViewer(QWidget *parent,const char *name)
58 : QTextBrowser(parent,name) 62 : QTextBrowser(parent,name)
59{ 63{
60 mSyncMode = false; 64 mSyncMode = false;
61 mColorMode = 0; 65 mColorMode = 0;
62} 66}
63 67
64KOEventViewer::~KOEventViewer() 68KOEventViewer::~KOEventViewer()
65{ 69{
66} 70}
67 71
68void KOEventViewer::setSource(const QString& n) 72void KOEventViewer::setSource(const QString& n)
69{ 73{
70 74
71 if ( n.left(3) == "uid" ) { 75 if ( n.left(3) == "uid" )
76#ifdef DESKTOP_VERSION
77 {
72 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 78 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
73 KABC::AddressBook::Iterator it; 79 KABC::AddressBook::Iterator it;
74 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 80 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
75 // LR I do not understand, why the uid string is different on zaurus and desktop 81 // LR I do not understand, why the uid string is different on zaurus and desktop
76#ifdef DESKTOP_VERSION
77 QString uid = "uid://"+(*it).uid(); 82 QString uid = "uid://"+(*it).uid();
78#else 83
79 QString uid = "uid:"+(*it).uid();
80#endif
81 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); 84 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1());
82 if (n == uid ) { 85 if (n == uid ) {
83 //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); 86 //qDebug("found %s ",(*it).mobileHomePhone().latin1() );
84 QDialog dia( this,"dia123", true ); 87 QDialog dia( this,"dia123", true );
85 dia.setCaption( i18n("Details of attendee") ); 88 dia.setCaption( i18n("Details of attendee") );
86 QVBoxLayout lay ( &dia ); 89 QVBoxLayout lay ( &dia );
87 KPIM::AddresseeView av ( &dia ); 90 KPIM::AddresseeView av ( &dia );
88 av.setAddressee( (*it) ); 91 av.setAddressee( (*it) );
89 lay.addWidget( &av ); 92 lay.addWidget( &av );
90 if ( QApplication::desktop()->width() < 480 ) 93 if ( QApplication::desktop()->width() < 480 )
91 dia.resize( 220, 240); 94 dia.resize( 220, 240);
92 else { 95 else {
93 dia.resize( 400,400); 96 dia.resize( 400,400);
94 97
95 } 98 }
96 dia.exec(); 99 dia.exec();
97 break; 100 break;
98 } 101 }
99 } 102 }
100 return; 103 return;
101 } 104 }
105#else
106 {
107 QPtrList<Attendee> attendees = mCurrentIncidence->attendees();
108 if (attendees.count()) {
109 Attendee *a;
110 for(a=attendees.first();a;a=attendees.next()) {
111 if ( "uid:"+a->uid() == n ) {
112 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), "");
113 return;
114 }
115 }
116 }
117 return;
118 }
119 //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
120 // the result should now arrive through method insertAttendees
121 //QString uid = "uid:"+(*it).uid();
122#endif
102 if ( n.left(6) == "mailto" ) { 123 if ( n.left(6) == "mailto" ) {
103 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); 124 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1());
104#ifndef DESKTOP_VERSION 125#ifndef DESKTOP_VERSION
105 QCopEnvelope e("QPE/Application/kmpi", "newMail(QString)" ); 126 QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" );
106 e << n.mid(7); 127 e << n.mid(7);
107#endif 128#endif
108 129
109 } 130 }
110 131
111 132
112#ifndef KORG_NODCOP 133#ifndef KORG_NODCOP
113 kdDebug() << "KOEventViewer::setSource(): " << n << endl; 134 kdDebug() << "KOEventViewer::setSource(): " << n << endl;
114 QString tmpStr; 135 QString tmpStr;
115 if (n.startsWith("mailto:")) { 136 if (n.startsWith("mailto:")) {
116 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); 137 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null);
117 //emit showIncidence(n); 138 //emit showIncidence(n);
118 return; 139 return;
119 } else if (n.startsWith("uid:")) { 140 } else if (n.startsWith("uid:")) {
120 DCOPClient *client = KApplication::kApplication()->dcopClient(); 141 DCOPClient *client = KApplication::kApplication()->dcopClient();
121 const QByteArray noParamData; 142 const QByteArray noParamData;
122 const QByteArray paramData; 143 const QByteArray paramData;
123 QByteArray replyData; 144 QByteArray replyData;
124 QCString replyTypeStr; 145 QCString replyTypeStr;
125#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) 146#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData))
126 bool foundAbbrowser = PING_ABBROWSER; 147 bool foundAbbrowser = PING_ABBROWSER;
127 148
128 if (foundAbbrowser) { 149 if (foundAbbrowser) {
129 //KAddressbook is already running, so just DCOP to it to bring up the contact editor 150 //KAddressbook is already running, so just DCOP to it to bring up the contact editor
130 //client->send("kaddressbook","KAddressBookIface", 151 //client->send("kaddressbook","KAddressBookIface",
131 QDataStream arg(paramData, IO_WriteOnly); 152 QDataStream arg(paramData, IO_WriteOnly);
132 arg << n.mid(6); 153 arg << n.mid(6);
133 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); 154 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData);
134 return; 155 return;
135 } else { 156 } else {
136 /* 157 /*
137 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. 158 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater.
138 We start it without its main interface 159 We start it without its main interface
139 */ 160 */
140 KIconLoader* iconLoader = new KIconLoader(); 161 KIconLoader* iconLoader = new KIconLoader();
141 QString iconPath = iconLoader->iconPath("go",KIcon::Small); 162 QString iconPath = iconLoader->iconPath("go",KIcon::Small);
142 ActionManager::setStartedKAddressBook(true); 163 ActionManager::setStartedKAddressBook(true);
143 tmpStr = "kaddressbook --editor-only --uid "; 164 tmpStr = "kaddressbook --editor-only --uid ";
144 tmpStr += KProcess::quote(n.mid(6)); 165 tmpStr += KProcess::quote(n.mid(6));
145 KRun::runCommand(tmpStr,"KAddressBook",iconPath); 166 KRun::runCommand(tmpStr,"KAddressBook",iconPath);
146 return; 167 return;
147 } 168 }
148 } else { 169 } else {
149 //QTextBrowser::setSource(n); 170 //QTextBrowser::setSource(n);
150 } 171 }
151#endif 172#endif
152} 173}
153 174
154void KOEventViewer::addTag(const QString & tag,const QString & text) 175void KOEventViewer::addTag(const QString & tag,const QString & text)
155{ 176{
156 int number=text.contains("\n"); 177 int number=text.contains("\n");
157 QString str = "<" + tag + ">"; 178 QString str = "<" + tag + ">";
158 QString tmpText=text; 179 QString tmpText=text;
159 QString tmpStr=str; 180 QString tmpStr=str;
160 if(number !=-1) 181 if(number !=-1)
161 { 182 {
162 if (number > 0) { 183 if (number > 0) {
163 int pos=0; 184 int pos=0;
164 QString tmp; 185 QString tmp;
165 for(int i=0;i<=number;i++) { 186 for(int i=0;i<=number;i++) {
166 pos=tmpText.find("\n"); 187 pos=tmpText.find("\n");
167 tmp=tmpText.left(pos); 188 tmp=tmpText.left(pos);
168 tmpText=tmpText.right(tmpText.length()-pos-1); 189 tmpText=tmpText.right(tmpText.length()-pos-1);
169 tmpStr+=tmp+"<br>"; 190 tmpStr+=tmp+"<br>";
170 } 191 }
171 } 192 }
172 else tmpStr += tmpText; 193 else tmpStr += tmpText;
173 tmpStr+="</" + tag + ">"; 194 tmpStr+="</" + tag + ">";
174 mText.append(tmpStr); 195 mText.append(tmpStr);
175 } 196 }
176 else 197 else
177 { 198 {
178 str += text + "</" + tag + ">"; 199 str += text + "</" + tag + ">";
179 mText.append(str); 200 mText.append(str);
180 } 201 }
181} 202}
182 203
183void KOEventViewer::setColorMode( int m ) 204void KOEventViewer::setColorMode( int m )
184{ 205{
185 mColorMode = m; 206 mColorMode = m;
186} 207}
187void KOEventViewer::appendEvent(Event *event, int mode ) 208void KOEventViewer::appendEvent(Event *event, int mode )
188{ 209{
189 mMailSubject = ""; 210 mMailSubject = "";
190 mCurrentIncidence = event; 211 mCurrentIncidence = event;
191 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 212 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
192 topLevelWidget()->setCaption(i18n("Event Viewer")); 213 topLevelWidget()->setCaption(i18n("Event Viewer"));
193 if ( mode == 0 ) { 214 if ( mode == 0 ) {
194 addTag("h2",event->summary()); 215 addTag("h2",event->summary());
195 } 216 }
196 else { 217 else {
197 if ( mColorMode == 1 ) { 218 if ( mColorMode == 1 ) {
198 mText +="<font color=\"#00A000\">"; 219 mText +="<font color=\"#00A000\">";
199 } 220 }
200 if ( mColorMode == 2 ) { 221 if ( mColorMode == 2 ) {
201 mText +="<font color=\"#C00000\">"; 222 mText +="<font color=\"#C00000\">";
202 } 223 }
203 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 224 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
204 if ( mode == 1 ) { 225 if ( mode == 1 ) {
205 addTag("h2",i18n( "Local: " ) +event->summary()); 226 addTag("h2",i18n( "Local: " ) +event->summary());
206 } else { 227 } else {
207 addTag("h2",i18n( "Remote: " ) +event->summary()); 228 addTag("h2",i18n( "Remote: " ) +event->summary());
208 } 229 }
209 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 230 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
210 if ( mColorMode ) 231 if ( mColorMode )
211 mText += "</font>"; 232 mText += "</font>";
212 } 233 }
213 mMailSubject += i18n( "Meeting " )+ event->summary(); 234 mMailSubject += i18n( "Meeting " )+ event->summary();
214 if (event->cancelled ()) { 235 if (event->cancelled ()) {
215 mText +="<font color=\"#B00000\">"; 236 mText +="<font color=\"#B00000\">";
216 addTag("i",i18n("This event has been cancelled!")); 237 addTag("i",i18n("This event has been cancelled!"));
217 mText.append("<br>"); 238 mText.append("<br>");
218 mText += "</font>"; 239 mText += "</font>";
219 mMailSubject += i18n("(cancelled)"); 240 mMailSubject += i18n("(cancelled)");
220 } 241 }
221 if (!event->location().isEmpty()) { 242 if (!event->location().isEmpty()) {
222 addTag("b",i18n("Location: ")); 243 addTag("b",i18n("Location: "));
223 mText.append(event->location()+"<br>"); 244 mText.append(event->location()+"<br>");
224 mMailSubject += i18n(" at ") + event->location(); 245 mMailSubject += i18n(" at ") + event->location();
225 } 246 }
226 if (event->doesFloat()) { 247 if (event->doesFloat()) {
227 if (event->isMultiDay()) { 248 if (event->isMultiDay()) {
228 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") 249 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
229 .arg(event->dtStartDateStr(shortDate)) 250 .arg(event->dtStartDateStr(shortDate))
230 .arg(event->dtEndDateStr(shortDate))); 251 .arg(event->dtEndDateStr(shortDate)));
231 } else { 252 } else {
232 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); 253 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
233 } 254 }
234 } else { 255 } else {
235 if (event->isMultiDay()) { 256 if (event->isMultiDay()) {
236 mText.append(i18n("<p><b>From:</b> %1</p> ") 257 mText.append(i18n("<p><b>From:</b> %1</p> ")
237 .arg(event->dtStartStr( shortDate))); 258 .arg(event->dtStartStr( shortDate)));
238 mText.append(i18n("<p><b>To:</b> %1</p>") 259 mText.append(i18n("<p><b>To:</b> %1</p>")
239 .arg(event->dtEndStr(shortDate))); 260 .arg(event->dtEndStr(shortDate)));
240 } else { 261 } else {
241 mText.append(i18n("<p><b>On:</b> %1</p> ") 262 mText.append(i18n("<p><b>On:</b> %1</p> ")
242 .arg(event->dtStartDateStr( shortDate ))); 263 .arg(event->dtStartDateStr( shortDate )));
243 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") 264 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
244 .arg(event->dtStartTimeStr()) 265 .arg(event->dtStartTimeStr())
245 .arg(event->dtEndTimeStr())); 266 .arg(event->dtEndTimeStr()));
246 } 267 }
247 } 268 }
248 269
249 if (event->recurrence()->doesRecur()) { 270 if (event->recurrence()->doesRecur()) {
250 271
251 QString recurText = event->recurrence()->recurrenceText(); 272 QString recurText = event->recurrence()->recurrenceText();
252 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); 273 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
253 bool last; 274 bool last;
254 QDate start = QDate::currentDate(); 275 QDate start = QDate::currentDate();
255 QDate next; 276 QDate next;
256 next = event->recurrence()->getPreviousDate( start , &last ); 277 next = event->recurrence()->getPreviousDate( start , &last );
257 if ( !last ) { 278 if ( !last ) {
258 next = event->recurrence()->getNextDate( start.addDays( - 1 ) ); 279 next = event->recurrence()->getNextDate( start.addDays( - 1 ) );
259 addTag("p",i18n("<b>Next recurrence is on:</b>") ); 280 addTag("p",i18n("<b>Next recurrence is on:</b>") );
260 addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 281 addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
261 QDateTime nextdt = QDateTime( next, event->dtStart().time()); 282 QDateTime nextdt = QDateTime( next, event->dtStart().time());
262 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true ); 283 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true );
263 284
264 } else { 285 } else {
265 addTag("p",i18n("<b>Last recurrence was on:</b>") ); 286 addTag("p",i18n("<b>Last recurrence was on:</b>") );
266 addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 287 addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
267 } 288 }
268 } else { 289 } else {
269 mMailSubject += i18n(" - " )+event->dtStartStr( true ); 290 mMailSubject += i18n(" - " )+event->dtStartStr( true );
270 291
271 } 292 }
272 293
273 294
274 if (event->isAlarmEnabled()) { 295 if (event->isAlarmEnabled()) {
275 Alarm *alarm =event->alarms().first() ; 296 Alarm *alarm =event->alarms().first() ;
276 QDateTime t = alarm->time(); 297 QDateTime t = alarm->time();
277 int min = t.secsTo( event->dtStart() )/60; 298 int min = t.secsTo( event->dtStart() )/60;
278 QString s =i18n("( %1 min before )").arg( min ); 299 QString s =i18n("( %1 min before )").arg( min );
279 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); 300 addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
280 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 301 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
281 //addTag("p",s); 302 //addTag("p",s);
282 } 303 }
283 304
284 addTag("b",i18n("Access: ")); 305 addTag("b",i18n("Access: "));
285 mText.append(event->secrecyStr()+"<br>"); 306 mText.append(event->secrecyStr()+"<br>");
286 if (!event->description().isEmpty()) { 307 if (!event->description().isEmpty()) {
287 addTag("p",i18n("<b>Details: </b>")); 308 addTag("p",i18n("<b>Details: </b>"));
288 addTag("p",event->description()); 309 addTag("p",event->description());
289 } 310 }
290 311
291 formatCategories(event); 312 formatCategories(event);
292 313
293 formatReadOnly(event); 314 formatReadOnly(event);
294 formatAttendees(event); 315 formatAttendees(event);
295 316
296 setText(mText); 317 setText(mText);
297 //QWhatsThis::add(this,mText); 318 //QWhatsThis::add(this,mText);
298 319
299} 320}
300 321
301void KOEventViewer::appendTodo(Todo *event, int mode ) 322void KOEventViewer::appendTodo(Todo *event, int mode )
302{ 323{
303 mMailSubject = ""; 324 mMailSubject = "";
304 mCurrentIncidence = event; 325 mCurrentIncidence = event;
305 topLevelWidget()->setCaption(i18n("Todo Viewer")); 326 topLevelWidget()->setCaption(i18n("Todo Viewer"));
306 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 327 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
307 if (mode == 0 ) 328 if (mode == 0 )
308 addTag("h2",event->summary()); 329 addTag("h2",event->summary());
309 else { 330 else {
310 if ( mColorMode == 1 ) { 331 if ( mColorMode == 1 ) {
311 mText +="<font color=\"#00A000\">"; 332 mText +="<font color=\"#00A000\">";
312 } 333 }
313 if ( mColorMode == 2 ) { 334 if ( mColorMode == 2 ) {
314 mText +="<font color=\"#B00000\">"; 335 mText +="<font color=\"#B00000\">";
315 } 336 }
316 if ( mode == 1 ) { 337 if ( mode == 1 ) {
317 addTag("h2",i18n( "Local: " ) +event->summary()); 338 addTag("h2",i18n( "Local: " ) +event->summary());
318 } else { 339 } else {
319 addTag("h2",i18n( "Remote: " ) +event->summary()); 340 addTag("h2",i18n( "Remote: " ) +event->summary());
320 } 341 }
321 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 342 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
322 if ( mColorMode ) 343 if ( mColorMode )
323 mText += "</font>"; 344 mText += "</font>";
324 } 345 }
325 mMailSubject += i18n( "Todo " )+ event->summary(); 346 mMailSubject += i18n( "Todo " )+ event->summary();
326 if (event->cancelled ()) { 347 if (event->cancelled ()) {
327 mText +="<font color=\"#B00000\">"; 348 mText +="<font color=\"#B00000\">";
328 addTag("i",i18n("This todo has been cancelled!")); 349 addTag("i",i18n("This todo has been cancelled!"));
329 mText.append("<br>"); 350 mText.append("<br>");
330 mText += "</font>"; 351 mText += "</font>";
331 mMailSubject += i18n("(cancelled)"); 352 mMailSubject += i18n("(cancelled)");
332 } 353 }
333 354
334 if (!event->location().isEmpty()) { 355 if (!event->location().isEmpty()) {
335 addTag("b",i18n("Location: ")); 356 addTag("b",i18n("Location: "));
336 mText.append(event->location()+"<br>"); 357 mText.append(event->location()+"<br>");
337 mMailSubject += i18n(" at ") + event->location(); 358 mMailSubject += i18n(" at ") + event->location();
338 } 359 }
339 if (event->hasDueDate()) { 360 if (event->hasDueDate()) {
340 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); 361 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer)));
341 mMailSubject += i18n(" - " )+event->dtDueStr( true ); 362 mMailSubject += i18n(" - " )+event->dtDueStr( true );
342 } 363 }
343 addTag("b",i18n("Access: ")); 364 addTag("b",i18n("Access: "));
344 mText.append(event->secrecyStr()+"<br>"); 365 mText.append(event->secrecyStr()+"<br>");
345 if (!event->description().isEmpty()) { 366 if (!event->description().isEmpty()) {
346 addTag("p",i18n("<b>Details: </b>")); 367 addTag("p",i18n("<b>Details: </b>"));
347 addTag("p",event->description()); 368 addTag("p",event->description());
348 } 369 }
349 370
350 formatCategories(event); 371 formatCategories(event);
351 372
352 mText.append(i18n("<p><b>Priority:</b> %2</p>") 373 mText.append(i18n("<p><b>Priority:</b> %2</p>")
353 .arg(QString::number(event->priority()))); 374 .arg(QString::number(event->priority())));
354 375
355 mText.append(i18n("<p><i>%1 % completed</i></p>") 376 mText.append(i18n("<p><i>%1 % completed</i></p>")
356 .arg(event->percentComplete())); 377 .arg(event->percentComplete()));
357 378
358 formatReadOnly(event); 379 formatReadOnly(event);
359 formatAttendees(event); 380 formatAttendees(event);
360 381
361 setText(mText); 382 setText(mText);
362} 383}
363 384
364void KOEventViewer::formatCategories(Incidence *event) 385void KOEventViewer::formatCategories(Incidence *event)
365{ 386{
366 if (!event->categoriesStr().isEmpty()) { 387 if (!event->categoriesStr().isEmpty()) {
367 if (event->categories().count() == 1) { 388 if (event->categories().count() == 1) {
368 addTag("h3",i18n("Category")); 389 addTag("h3",i18n("Category"));
369 } else { 390 } else {
370 addTag("h3",i18n("Categories")); 391 addTag("h3",i18n("Categories"));
371 } 392 }
372 addTag("p",event->categoriesStr()); 393 addTag("p",event->categoriesStr());
373 } 394 }
374} 395}
375void KOEventViewer::formatAttendees(Incidence *event) 396void KOEventViewer::formatAttendees(Incidence *event)
376{ 397{
377 QPtrList<Attendee> attendees = event->attendees(); 398 QPtrList<Attendee> attendees = event->attendees();
378 if (attendees.count()) { 399 if (attendees.count()) {
379 400
380 401
381 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 402 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
382 addTag("h3",i18n("Organizer")); 403 addTag("h3",i18n("Organizer"));
383 mText.append("<ul><li>"); 404 mText.append("<ul><li>");
384#ifndef KORG_NOKABC 405#ifndef KORG_NOKABC
385 406
407#ifdef DESKTOP_VERSION
386 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 408 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
387 KABC::Addressee::List addressList; 409 KABC::Addressee::List addressList;
388 addressList = add_book->findByEmail(event->organizer()); 410 addressList = add_book->findByEmail(event->organizer());
389 KABC::Addressee o = addressList.first(); 411 KABC::Addressee o = addressList.first();
390 if (!o.isEmpty() && addressList.size()<2) { 412 if (!o.isEmpty() && addressList.size()<2) {
391 mText += "<a href=\"uid:" + o.uid() + "\">"; 413 mText += "<a href=\"uid:" + o.uid() + "\">";
392 mText += o.formattedName(); 414 mText += o.formattedName();
393 mText += "</a>\n"; 415 mText += "</a>\n";
394 } else { 416 } else {
395 mText.append(event->organizer()); 417 mText.append(event->organizer());
396 } 418 }
419#else //DESKTOP_VERSION
420 mText.append(event->organizer());
421#endif //DESKTOP_VERSION
422
423
397#else 424#else
398 mText.append(event->organizer()); 425 mText.append(event->organizer());
399#endif 426#endif
400 427
401 if (iconPath) { 428 if (iconPath) {
402 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 429 mText += " <a href=\"mailto:" + event->organizer() + "\">";
403 mText += "<IMG src=\"" + iconPath + "\">"; 430 mText += "<IMG src=\"" + iconPath + "\">";
404 mText += "</a>\n"; 431 mText += "</a>\n";
405 } 432 }
406 mText.append("</li></ul>"); 433 mText.append("</li></ul>");
407 434
408 addTag("h3",i18n("Attendees")); 435 addTag("h3",i18n("Attendees"));
409 Attendee *a; 436 Attendee *a;
410 mText.append("<ul>"); 437 mText.append("<ul>");
411 for(a=attendees.first();a;a=attendees.next()) { 438 for(a=attendees.first();a;a=attendees.next()) {
412#ifndef KORG_NOKABC 439#ifndef KORG_NOKABC
440#ifdef DESKTOP_VERSION
413 if (a->name().isEmpty()) { 441 if (a->name().isEmpty()) {
414 addressList = add_book->findByEmail(a->email()); 442 addressList = add_book->findByEmail(a->email());
415 KABC::Addressee o = addressList.first(); 443 KABC::Addressee o = addressList.first();
416 if (!o.isEmpty() && addressList.size()<2) { 444 if (!o.isEmpty() && addressList.size()<2) {
417 mText += "<a href=\"uid:" + o.uid() + "\">"; 445 mText += "<a href=\"uid:" + o.uid() + "\">";
418 mText += o.formattedName(); 446 mText += o.formattedName();
419 mText += "</a>\n"; 447 mText += "</a>\n";
420 } else { 448 } else {
421 mText += "<li>"; 449 mText += "<li>";
422 mText.append(a->email()); 450 mText.append(a->email());
423 mText += "\n"; 451 mText += "\n";
424 } 452 }
425 } else { 453 } else {
426 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 454 mText += "<li><a href=\"uid:" + a->uid() + "\">";
427 if (!a->name().isEmpty()) mText += a->name(); 455 if (!a->name().isEmpty()) mText += a->name();
428 else mText += a->email(); 456 else mText += a->email();
429 mText += "</a>\n"; 457 mText += "</a>\n";
430 } 458 }
459#else //DESKTOP_VERSION
460 mText += "<li><a href=\"uid:" + a->uid() + "\">";
461 if (!a->name().isEmpty()) mText += a->name();
462 else mText += a->email();
463 mText += "</a>\n";
464#endif //DESKTOP_VERSION
431#else 465#else
432 //qDebug("nokabc "); 466 //qDebug("nokabc ");
433 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 467 mText += "<li><a href=\"uid:" + a->uid() + "\">";
434 if (!a->name().isEmpty()) mText += a->name(); 468 if (!a->name().isEmpty()) mText += a->name();
435 else mText += a->email(); 469 else mText += a->email();
436 mText += "</a>\n"; 470 mText += "</a>\n";
437#endif 471#endif
438 472
439 473
440 if (!a->email().isEmpty()) { 474 if (!a->email().isEmpty()) {
441 if (iconPath) { 475 if (iconPath) {
442 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; 476 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">";
443 mText += "<IMG src=\"" + iconPath + "\">"; 477 mText += "<IMG src=\"" + iconPath + "\">";
444 mText += "</a>\n"; 478 mText += "</a>\n";
445 } 479 }
446 } 480 }
447 if (a->status() != Attendee::NeedsAction ) 481 if (a->status() != Attendee::NeedsAction )
448 mText +="[" + a->statusStr() + "] "; 482 mText +="[" + a->statusStr() + "] ";
449 if (a->role() == Attendee::Chair ) 483 if (a->role() == Attendee::Chair )
450 mText +="(" + a->roleStr().left(1) + ".)"; 484 mText +="(" + a->roleStr().left(1) + ".)";
451 } 485 }
452 mText.append("</li></ul>"); 486 mText.append("</li></ul>");
453 } 487 }
454 488
455} 489}
456void KOEventViewer::appendJournal(Journal *jour, int mode ) 490void KOEventViewer::appendJournal(Journal *jour, int mode )
457{ 491{
458 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 492 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
459 if (mode == 0 ) 493 if (mode == 0 )
460 addTag("h2",i18n("Journal from: ")); 494 addTag("h2",i18n("Journal from: "));
461 else { 495 else {
462 if ( mode == 1 ) { 496 if ( mode == 1 ) {
463 addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); 497 addTag("h2",i18n( "Local: " ) +i18n("Journal from: "));
464 } else { 498 } else {
465 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); 499 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: "));
466 } 500 }
467 addTag("h3",i18n( "Last modified " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); 501 addTag("h3",i18n( "Last modified " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) );
468 } 502 }
469 topLevelWidget()->setCaption("Journal Viewer"); 503 topLevelWidget()->setCaption("Journal Viewer");
470 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); 504 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer)));
471 if (!jour->description().isEmpty()) { 505 if (!jour->description().isEmpty()) {
472 addTag("p",jour->description()); 506 addTag("p",jour->description());
473 } 507 }
474 setText(mText); 508 setText(mText);
475} 509}
476 510
477void KOEventViewer::formatReadOnly(Incidence *event) 511void KOEventViewer::formatReadOnly(Incidence *event)
478{ 512{
479 if (event->isReadOnly()) { 513 if (event->isReadOnly()) {
480 addTag("p","<em>(" + i18n("read-only") + ")</em>"); 514 addTag("p","<em>(" + i18n("read-only") + ")</em>");
481 } 515 }
482} 516}
483void KOEventViewer::setSyncMode( bool b ) 517void KOEventViewer::setSyncMode( bool b )
484{ 518{
485 mSyncMode = b; 519 mSyncMode = b;
486} 520}
487 521
488 522
489void KOEventViewer::setTodo(Todo *event, bool clearV ) 523void KOEventViewer::setTodo(Todo *event, bool clearV )
490{ 524{
491 if ( clearV ) 525 if ( clearV )
492 clearEvents(); 526 clearEvents();
493 if ( mSyncMode ) { 527 if ( mSyncMode ) {
494 if ( clearV ) 528 if ( clearV )
495 appendTodo(event,1 ); 529 appendTodo(event,1 );
496 else 530 else
497 appendTodo(event,2); 531 appendTodo(event,2);
498 } else 532 } else
499 appendTodo(event); 533 appendTodo(event);
500} 534}
501void KOEventViewer::setJournal(Journal *event, bool clearV ) 535void KOEventViewer::setJournal(Journal *event, bool clearV )
502{ 536{
503 if ( clearV ) 537 if ( clearV )
504 clearEvents(); 538 clearEvents();
505 if ( mSyncMode ) { 539 if ( mSyncMode ) {
506 if ( clearV ) 540 if ( clearV )
507 appendJournal(event, 1); 541 appendJournal(event, 1);
508 else 542 else
509 appendJournal(event, 2); 543 appendJournal(event, 2);
510 } else 544 } else
511 appendJournal(event); 545 appendJournal(event);
512} 546}
513 547
514void KOEventViewer::setEvent(Event *event) 548void KOEventViewer::setEvent(Event *event)
515{ 549{
516 clearEvents(); 550 clearEvents();
517 if ( mSyncMode ) 551 if ( mSyncMode )
518 appendEvent(event, 1); 552 appendEvent(event, 1);
519 else 553 else
520 appendEvent(event); 554 appendEvent(event);
521} 555}
522 556
523void KOEventViewer::addEvent(Event *event) 557void KOEventViewer::addEvent(Event *event)
524{ 558{
525 if ( mSyncMode ) 559 if ( mSyncMode )
526 appendEvent(event, 2); 560 appendEvent(event, 2);
527 else 561 else
528 appendEvent(event); 562 appendEvent(event);
529} 563}
530 564
531void KOEventViewer::clearEvents(bool now) 565void KOEventViewer::clearEvents(bool now)
532{ 566{
533 mText = ""; 567 mText = "";
534 if (now) setText(mText); 568 if (now) setText(mText);
535} 569}
536 570
537void KOEventViewer::addText(QString text) 571void KOEventViewer::addText(QString text)
538{ 572{
539 mText.append(text); 573 mText.append(text);
540 setText(mText); 574 setText(mText);
541} 575}
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index d4fadcb..7978b46 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,2112 +1,2114 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qmessagebox.h> 7#include <qmessagebox.h>
8#include <qlineedit.h> 8#include <qlineedit.h>
9#include <qfile.h> 9#include <qfile.h>
10#include <qdir.h> 10#include <qdir.h>
11#include <qapp.h> 11#include <qapp.h>
12#include <qfileinfo.h> 12#include <qfileinfo.h>
13#include <qlabel.h> 13#include <qlabel.h>
14#include <qmap.h> 14#include <qmap.h>
15#include <qwmatrix.h> 15#include <qwmatrix.h>
16#include <qtextbrowser.h> 16#include <qtextbrowser.h>
17#include <qtextstream.h> 17#include <qtextstream.h>
18#ifndef DESKTOP_VERSION 18#ifndef DESKTOP_VERSION
19#include <qpe/global.h> 19#include <qpe/global.h>
20#include <qpe/qpemenubar.h> 20#include <qpe/qpemenubar.h>
21#include <qpe/qpetoolbar.h> 21#include <qpe/qpetoolbar.h>
22#include <qpe/resource.h> 22#include <qpe/resource.h>
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <qtopia/alarmserver.h> 24#include <qtopia/alarmserver.h>
25#include <qtopia/qcopenvelope_qws.h> 25#include <qtopia/qcopenvelope_qws.h>
26#else 26#else
27#include <qmenubar.h> 27#include <qmenubar.h>
28#include <qtoolbar.h> 28#include <qtoolbar.h>
29#include <qapplication.h> 29#include <qapplication.h>
30//#include <resource.h> 30//#include <resource.h>
31 31
32#endif 32#endif
33#include <libkcal/calendarlocal.h> 33#include <libkcal/calendarlocal.h>
34#include <libkcal/todo.h> 34#include <libkcal/todo.h>
35#include <libkdepim/ksyncprofile.h> 35#include <libkdepim/ksyncprofile.h>
36#include <libkdepim/kincidenceformatter.h> 36#include <libkdepim/kincidenceformatter.h>
37 37
38#include "calendarview.h" 38#include "calendarview.h"
39#include "koviewmanager.h" 39#include "koviewmanager.h"
40#include "datenavigator.h" 40#include "datenavigator.h"
41#include "koagendaview.h" 41#include "koagendaview.h"
42#include "koagenda.h" 42#include "koagenda.h"
43#include "kodialogmanager.h" 43#include "kodialogmanager.h"
44#include "kdialogbase.h" 44#include "kdialogbase.h"
45#include "kapplication.h" 45#include "kapplication.h"
46#include "kofilterview.h" 46#include "kofilterview.h"
47#include "kstandarddirs.h" 47#include "kstandarddirs.h"
48#include "koprefs.h" 48#include "koprefs.h"
49#include "kfiledialog.h" 49#include "kfiledialog.h"
50#include "koglobals.h" 50#include "koglobals.h"
51#include "kglobal.h" 51#include "kglobal.h"
52#include "klocale.h" 52#include "klocale.h"
53#include "kconfig.h" 53#include "kconfig.h"
54#include "simplealarmclient.h" 54#include "simplealarmclient.h"
55#include "externalapphandler.h" 55#include "externalapphandler.h"
56 56
57using namespace KCal; 57using namespace KCal;
58#ifndef _WIN32_ 58#ifndef _WIN32_
59#include <unistd.h> 59#include <unistd.h>
60#else 60#else
61#include "koimportoldialog.h" 61#include "koimportoldialog.h"
62#endif 62#endif
63#include "mainwindow.h" 63#include "mainwindow.h"
64 64
65int globalFlagBlockStartup; 65int globalFlagBlockStartup;
66MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 66MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
67 QMainWindow( parent, name ) 67 QMainWindow( parent, name )
68{ 68{
69 69
70#ifdef DESKTOP_VERSION 70#ifdef DESKTOP_VERSION
71 setFont( QFont("Arial"), 14 ); 71 setFont( QFont("Arial"), 14 );
72#endif 72#endif
73 73
74 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 74 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
75 QString confFile = locateLocal("config","korganizerrc"); 75 QString confFile = locateLocal("config","korganizerrc");
76 QFileInfo finf ( confFile ); 76 QFileInfo finf ( confFile );
77 bool showWarning = !finf.exists(); 77 bool showWarning = !finf.exists();
78 setIcon(SmallIcon( "ko24" ) ); 78 setIcon(SmallIcon( "ko24" ) );
79 mBlockAtStartup = true; 79 mBlockAtStartup = true;
80 mFlagKeyPressed = false; 80 mFlagKeyPressed = false;
81 setCaption("KOrganizer/Pi"); 81 setCaption("KOrganizer/Pi");
82 KOPrefs *p = KOPrefs::instance(); 82 KOPrefs *p = KOPrefs::instance();
83 // if ( QApplication::desktop()->height() > 480 ) { 83 // if ( QApplication::desktop()->height() > 480 ) {
84// if ( p->mHourSize == 4 ) 84// if ( p->mHourSize == 4 )
85// p->mHourSize = 6; 85// p->mHourSize = 6;
86// } 86// }
87 if ( p->mHourSize > 18 ) 87 if ( p->mHourSize > 18 )
88 p->mHourSize = 18; 88 p->mHourSize = 18;
89 QMainWindow::ToolBarDock tbd; 89 QMainWindow::ToolBarDock tbd;
90 if ( p->mToolBarHor ) { 90 if ( p->mToolBarHor ) {
91 if ( p->mToolBarUp ) 91 if ( p->mToolBarUp )
92 tbd = Bottom; 92 tbd = Bottom;
93 else 93 else
94 tbd = Top; 94 tbd = Top;
95 } 95 }
96 else { 96 else {
97 if ( p->mToolBarUp ) 97 if ( p->mToolBarUp )
98 tbd = Right; 98 tbd = Right;
99 else 99 else
100 tbd = Left; 100 tbd = Left;
101 } 101 }
102 if ( KOPrefs::instance()->mUseAppColors ) 102 if ( KOPrefs::instance()->mUseAppColors )
103 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 103 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
104 globalFlagBlockStartup = 1; 104 globalFlagBlockStartup = 1;
105 iconToolBar = new QPEToolBar( this ); 105 iconToolBar = new QPEToolBar( this );
106 addToolBar (iconToolBar , tbd ); 106 addToolBar (iconToolBar , tbd );
107 mBlockSaveFlag = false; 107 mBlockSaveFlag = false;
108 mCalendarModifiedFlag = false; 108 mCalendarModifiedFlag = false;
109 109
110 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 110 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
111 splash->setAlignment ( AlignCenter ); 111 splash->setAlignment ( AlignCenter );
112 setCentralWidget( splash ); 112 setCentralWidget( splash );
113#ifndef DESKTOP_VERSION 113#ifndef DESKTOP_VERSION
114 showMaximized(); 114 showMaximized();
115#endif 115#endif
116 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 116 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
117 setDefaultPreferences(); 117 setDefaultPreferences();
118 mCalendar = new CalendarLocal(); 118 mCalendar = new CalendarLocal();
119 mView = new CalendarView( mCalendar, this,"mCalendar " ); 119 mView = new CalendarView( mCalendar, this,"mCalendar " );
120 mView->hide(); 120 mView->hide();
121 //mView->resize(splash->size() ); 121 //mView->resize(splash->size() );
122 initActions(); 122 initActions();
123#ifndef DESKTOP_VERSION 123#ifndef DESKTOP_VERSION
124 iconToolBar->show(); 124 iconToolBar->show();
125 qApp->processEvents(); 125 qApp->processEvents();
126#endif 126#endif
127 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 127 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
128 int vh = height() ; 128 int vh = height() ;
129 int vw = width(); 129 int vw = width();
130 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 130 //qDebug("Toolbar hei %d ",iconToolBar->height() );
131 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 131 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
132 vh -= iconToolBar->height(); 132 vh -= iconToolBar->height();
133 } else { 133 } else {
134 vw -= iconToolBar->height(); 134 vw -= iconToolBar->height();
135 } 135 }
136 //mView->setMaximumSize( splash->size() ); 136 //mView->setMaximumSize( splash->size() );
137 //mView->resize( splash->size() ); 137 //mView->resize( splash->size() );
138 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 138 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
139 mView->readSettings(); 139 mView->readSettings();
140 bool oldOpened = false; 140 bool oldOpened = false;
141 bool newFile = false; 141 bool newFile = false;
142 if( !QFile::exists( defaultFileName() ) ) { 142 if( !QFile::exists( defaultFileName() ) ) {
143 QFileInfo finfo ( defaultFileName() ); 143 QFileInfo finfo ( defaultFileName() );
144 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 144 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
145 qDebug("oldfile %s ", oldFile.latin1()); 145 qDebug("oldfile %s ", oldFile.latin1());
146 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 146 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
147 finfo.setFile( oldFile ); 147 finfo.setFile( oldFile );
148 if (finfo.exists() ) { 148 if (finfo.exists() ) {
149 KMessageBox::information( this, message); 149 KMessageBox::information( this, message);
150 mView->openCalendar( oldFile ); 150 mView->openCalendar( oldFile );
151 qApp->processEvents(); 151 qApp->processEvents();
152 } else { 152 } else {
153 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 153 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
154 finfo.setFile( oldFile ); 154 finfo.setFile( oldFile );
155 if (finfo.exists() ) { 155 if (finfo.exists() ) {
156 KMessageBox::information( this, message); 156 KMessageBox::information( this, message);
157 mView->openCalendar( oldFile ); 157 mView->openCalendar( oldFile );
158 qApp->processEvents(); 158 qApp->processEvents();
159 } 159 }
160 } 160 }
161 mView->saveCalendar( defaultFileName() ); 161 mView->saveCalendar( defaultFileName() );
162 newFile = true; 162 newFile = true;
163 } 163 }
164 164
165 QTime neededSaveTime = QDateTime::currentDateTime().time(); 165 QTime neededSaveTime = QDateTime::currentDateTime().time();
166 if ( ! oldOpened ) 166 if ( ! oldOpened )
167 mView->openCalendar( defaultFileName() ); 167 mView->openCalendar( defaultFileName() );
168 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 168 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
169 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 169 qDebug("KO: Calendar loading time: %d ms",msNeeded );
170 170
171 if ( KOPrefs::instance()->mLanguageChanged ) { 171 if ( KOPrefs::instance()->mLanguageChanged ) {
172 KOPrefs::instance()->setCategoryDefaults(); 172 KOPrefs::instance()->setCategoryDefaults();
173 int count = mView->addCategories(); 173 int count = mView->addCategories();
174 KOPrefs::instance()->mLanguageChanged = false; 174 KOPrefs::instance()->mLanguageChanged = false;
175 } 175 }
176 processIncidenceSelection( 0 ); 176 processIncidenceSelection( 0 );
177 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 177 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
178 SLOT( processIncidenceSelection( Incidence * ) ) ); 178 SLOT( processIncidenceSelection( Incidence * ) ) );
179 connect( mView, SIGNAL( modifiedChanged( bool ) ), 179 connect( mView, SIGNAL( modifiedChanged( bool ) ),
180 SLOT( slotModifiedChanged( bool ) ) ); 180 SLOT( slotModifiedChanged( bool ) ) );
181 181
182 182
183 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 183 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
184 mView->setModified( false ); 184 mView->setModified( false );
185 mBlockAtStartup = false; 185 mBlockAtStartup = false;
186 mView->setModified( false ); 186 mView->setModified( false );
187 setCentralWidget( mView ); 187 setCentralWidget( mView );
188 globalFlagBlockStartup = 0; 188 globalFlagBlockStartup = 0;
189 mView->show(); 189 mView->show();
190 delete splash; 190 delete splash;
191 if ( newFile ) 191 if ( newFile )
192 mView->updateConfig(); 192 mView->updateConfig();
193 // qApp->processEvents(); 193 // qApp->processEvents();
194 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 194 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
195 fillSyncMenu(); 195 fillSyncMenu();
196 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 196 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
197 if ( showWarning ) { 197 if ( showWarning ) {
198 KMessageBox::information( this, 198 KMessageBox::information( this,
199 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 199 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
200 qApp->processEvents(); 200 qApp->processEvents();
201 mView->dialogManager()->showSyncOptions(); 201 mView->dialogManager()->showSyncOptions();
202 } 202 }
203 203
204 //US listen for result adressed from Ka/Pi 204 //US listen for result adressed from Ka/Pi
205#ifndef DESKTOP_VERSION
205 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 206 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
207#endif
206} 208}
207MainWindow::~MainWindow() 209MainWindow::~MainWindow()
208{ 210{
209 //qDebug("MainWindow::~MainWindow() "); 211 //qDebug("MainWindow::~MainWindow() ");
210 //save toolbar location 212 //save toolbar location
211 213
212 delete mCalendar; 214 delete mCalendar;
213 delete KOPrefs::instance(); 215 delete KOPrefs::instance();
214 delete KIncidenceFormatter::instance(); 216 delete KIncidenceFormatter::instance();
215 217
216 218
217} 219}
218void MainWindow::showMaximized () 220void MainWindow::showMaximized ()
219{ 221{
220#ifndef DESKTOP_VERSION 222#ifndef DESKTOP_VERSION
221 if ( ! globalFlagBlockStartup ) 223 if ( ! globalFlagBlockStartup )
222 mView->goToday(); 224 mView->goToday();
223#endif 225#endif
224 QWidget::showMaximized () ; 226 QWidget::showMaximized () ;
225} 227}
226void MainWindow::closeEvent( QCloseEvent* ce ) 228void MainWindow::closeEvent( QCloseEvent* ce )
227{ 229{
228 230
229 231
230 232
231 if ( ! KOPrefs::instance()->mAskForQuit ) { 233 if ( ! KOPrefs::instance()->mAskForQuit ) {
232 saveOnClose(); 234 saveOnClose();
233 ce->accept(); 235 ce->accept();
234 return; 236 return;
235 237
236 } 238 }
237 239
238 switch( QMessageBox::information( this, "KO/Pi", 240 switch( QMessageBox::information( this, "KO/Pi",
239 i18n("Do you really want\nto close KO/Pi?"), 241 i18n("Do you really want\nto close KO/Pi?"),
240 i18n("Close"), i18n("No"), 242 i18n("Close"), i18n("No"),
241 0, 0 ) ) { 243 0, 0 ) ) {
242 case 0: 244 case 0:
243 saveOnClose(); 245 saveOnClose();
244 ce->accept(); 246 ce->accept();
245 break; 247 break;
246 case 1: 248 case 1:
247 ce->ignore(); 249 ce->ignore();
248 break; 250 break;
249 case 2: 251 case 2:
250 252
251 default: 253 default:
252 break; 254 break;
253 } 255 }
254 256
255 257
256} 258}
257 259
258void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 260void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
259{ 261{
260 QDataStream stream( data, IO_ReadOnly ); 262 QDataStream stream( data, IO_ReadOnly );
261 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 263 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
262 //QString datamess; 264 //QString datamess;
263 //qDebug("message "); 265 //qDebug("message ");
264 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 266 qDebug("KO: QCOP message received: %s ", cmsg.data() );
265 267
266 if ( cmsg == "-writeFile" ) { 268 if ( cmsg == "-writeFile" ) {
267 // I made from the "-writeFile" an "-writeAlarm" 269 // I made from the "-writeFile" an "-writeAlarm"
268 mView->viewManager()->showWhatsNextView(); 270 mView->viewManager()->showWhatsNextView();
269 mCalendar->checkAlarmForIncidence( 0, true); 271 mCalendar->checkAlarmForIncidence( 0, true);
270 showMaximized(); 272 showMaximized();
271 raise(); 273 raise();
272 return; 274 return;
273 } 275 }
274 276
275 if ( cmsg == "-writeFile" ) { 277 if ( cmsg == "-writeFile" ) {
276 // I made from the "-writeFile" an "-writeAlarm" 278 // I made from the "-writeFile" an "-writeAlarm"
277 mView->viewManager()->showWhatsNextView(); 279 mView->viewManager()->showWhatsNextView();
278 mCalendar->checkAlarmForIncidence( 0, true); 280 mCalendar->checkAlarmForIncidence( 0, true);
279 showMaximized(); 281 showMaximized();
280 raise(); 282 raise();
281 return; 283 return;
282 284
283 } 285 }
284 if ( cmsg == "-writeFileSilent" ) { 286 if ( cmsg == "-writeFileSilent" ) {
285 // I made from the "-writeFile" an "-writeAlarm" 287 // I made from the "-writeFile" an "-writeAlarm"
286 // mView->viewManager()->showWhatsNextView(); 288 // mView->viewManager()->showWhatsNextView();
287 mCalendar->checkAlarmForIncidence( 0, true); 289 mCalendar->checkAlarmForIncidence( 0, true);
288 //showMaximized(); 290 //showMaximized();
289 //raise(); 291 //raise();
290 hide(); 292 hide();
291 return; 293 return;
292 } 294 }
293 if ( cmsg == "-newCountdown" ) { 295 if ( cmsg == "-newCountdown" ) {
294 qDebug("newCountdown "); 296 qDebug("newCountdown ");
295 297
296 } 298 }
297 QString msg ; 299 QString msg ;
298 QString allmsg = cmsg; 300 QString allmsg = cmsg;
299 while ( allmsg.length() > 0 ) { 301 while ( allmsg.length() > 0 ) {
300 int nextC = allmsg.find( "-", 1 ); 302 int nextC = allmsg.find( "-", 1 );
301 if ( nextC == -1 ) { 303 if ( nextC == -1 ) {
302 msg = allmsg; 304 msg = allmsg;
303 allmsg = ""; 305 allmsg = "";
304 } else{ 306 } else{
305 msg = allmsg.left( nextC ); 307 msg = allmsg.left( nextC );
306 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 308 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
307 } 309 }
308 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 310 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
309 if ( msg == "-newEvent" ) { 311 if ( msg == "-newEvent" ) {
310 mView->newEvent(); 312 mView->newEvent();
311 } 313 }
312 if ( msg == "-newTodo" ) { 314 if ( msg == "-newTodo" ) {
313 mView->newTodo(); 315 mView->newTodo();
314 316
315 } 317 }
316 if ( msg == "-showWN" ) { 318 if ( msg == "-showWN" ) {
317 mView->viewManager()->showWhatsNextView(); 319 mView->viewManager()->showWhatsNextView();
318 } 320 }
319 if ( msg == "-showTodo" ) { 321 if ( msg == "-showTodo" ) {
320 mView->viewManager()->showTodoView(); 322 mView->viewManager()->showTodoView();
321 } 323 }
322 if ( msg == "-showList" ) { 324 if ( msg == "-showList" ) {
323 mView->viewManager()->showListView(); 325 mView->viewManager()->showListView();
324 } 326 }
325 else if ( msg == "-showDay" ) { 327 else if ( msg == "-showDay" ) {
326 mView->viewManager()->showDayView(); 328 mView->viewManager()->showDayView();
327 } 329 }
328 else if ( msg == "-showWWeek" ) { 330 else if ( msg == "-showWWeek" ) {
329 mView->viewManager()->showWorkWeekView(); 331 mView->viewManager()->showWorkWeekView();
330 } 332 }
331 else if ( msg == "-ringSync" ) { 333 else if ( msg == "-ringSync" ) {
332 multiSync( false ); 334 multiSync( false );
333 } 335 }
334 else if ( msg == "-showWeek" ) { 336 else if ( msg == "-showWeek" ) {
335 mView->viewManager()->showWeekView(); 337 mView->viewManager()->showWeekView();
336 } 338 }
337 else if ( msg == "-showTodo" ) { 339 else if ( msg == "-showTodo" ) {
338 mView->viewManager()->showTodoView(); 340 mView->viewManager()->showTodoView();
339 } 341 }
340 else if ( msg == "-showJournal" ) { 342 else if ( msg == "-showJournal" ) {
341 mView->dateNavigator()->selectDates( 1 ); 343 mView->dateNavigator()->selectDates( 1 );
342 mView->dateNavigator()->selectToday(); 344 mView->dateNavigator()->selectToday();
343 mView->viewManager()->showJournalView(); 345 mView->viewManager()->showJournalView();
344 } 346 }
345 else if ( msg == "-showKO" ) { 347 else if ( msg == "-showKO" ) {
346 mView->viewManager()->showNextXView(); 348 mView->viewManager()->showNextXView();
347 } 349 }
348 else if ( msg == "-showWNext" || msg == "nextView()" ) { 350 else if ( msg == "-showWNext" || msg == "nextView()" ) {
349 mView->viewManager()->showWhatsNextView(); 351 mView->viewManager()->showWhatsNextView();
350 } 352 }
351 else if ( msg == "-showNextXView" ) { 353 else if ( msg == "-showNextXView" ) {
352 mView->viewManager()->showNextXView(); 354 mView->viewManager()->showNextXView();
353 } 355 }
354 356
355 357
356 } 358 }
357 359
358 showMaximized(); 360 showMaximized();
359 raise(); 361 raise();
360} 362}
361 363
362QPixmap MainWindow::loadPixmap( QString name ) 364QPixmap MainWindow::loadPixmap( QString name )
363{ 365{
364 return SmallIcon( name ); 366 return SmallIcon( name );
365 367
366} 368}
367void MainWindow::initActions() 369void MainWindow::initActions()
368{ 370{
369 //KOPrefs::instance()->mShowFullMenu 371 //KOPrefs::instance()->mShowFullMenu
370 iconToolBar->clear(); 372 iconToolBar->clear();
371 KOPrefs *p = KOPrefs::instance(); 373 KOPrefs *p = KOPrefs::instance();
372 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 374 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
373 375
374 QPopupMenu *viewMenu = new QPopupMenu( this ); 376 QPopupMenu *viewMenu = new QPopupMenu( this );
375 QPopupMenu *actionMenu = new QPopupMenu( this ); 377 QPopupMenu *actionMenu = new QPopupMenu( this );
376 QPopupMenu *importMenu = new QPopupMenu( this ); 378 QPopupMenu *importMenu = new QPopupMenu( this );
377 selectFilterMenu = new QPopupMenu( this ); 379 selectFilterMenu = new QPopupMenu( this );
378 selectFilterMenu->setCheckable( true ); 380 selectFilterMenu->setCheckable( true );
379 syncMenu = new QPopupMenu( this ); 381 syncMenu = new QPopupMenu( this );
380 configureAgendaMenu = new QPopupMenu( this ); 382 configureAgendaMenu = new QPopupMenu( this );
381 configureToolBarMenu = new QPopupMenu( this ); 383 configureToolBarMenu = new QPopupMenu( this );
382 QPopupMenu *helpMenu = new QPopupMenu( this ); 384 QPopupMenu *helpMenu = new QPopupMenu( this );
383 if ( KOPrefs::instance()->mShowFullMenu ) { 385 if ( KOPrefs::instance()->mShowFullMenu ) {
384 QMenuBar *menuBar1; 386 QMenuBar *menuBar1;
385 menuBar1 = menuBar(); 387 menuBar1 = menuBar();
386 menuBar1->insertItem( i18n("File"), importMenu ); 388 menuBar1->insertItem( i18n("File"), importMenu );
387 menuBar1->insertItem( i18n("View"), viewMenu ); 389 menuBar1->insertItem( i18n("View"), viewMenu );
388 menuBar1->insertItem( i18n("Actions"), actionMenu ); 390 menuBar1->insertItem( i18n("Actions"), actionMenu );
389 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 391 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
390 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 392 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
391 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 393 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
392 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 394 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
393 menuBar1->insertItem( i18n("Help"), helpMenu ); 395 menuBar1->insertItem( i18n("Help"), helpMenu );
394 } else { 396 } else {
395 QPEMenuBar *menuBar1; 397 QPEMenuBar *menuBar1;
396 menuBar1 = new QPEMenuBar( iconToolBar ); 398 menuBar1 = new QPEMenuBar( iconToolBar );
397 QPopupMenu *menuBar = new QPopupMenu( this ); 399 QPopupMenu *menuBar = new QPopupMenu( this );
398 menuBar1->insertItem( i18n("ME"), menuBar); 400 menuBar1->insertItem( i18n("ME"), menuBar);
399 menuBar->insertItem( i18n("File"), importMenu ); 401 menuBar->insertItem( i18n("File"), importMenu );
400 menuBar->insertItem( i18n("View"), viewMenu ); 402 menuBar->insertItem( i18n("View"), viewMenu );
401 menuBar->insertItem( i18n("Actions"), actionMenu ); 403 menuBar->insertItem( i18n("Actions"), actionMenu );
402 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 404 menuBar->insertItem( i18n("Synchronize"), syncMenu );
403 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 405 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
404 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 406 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
405 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 407 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
406 menuBar->insertItem( i18n("Help"), helpMenu ); 408 menuBar->insertItem( i18n("Help"), helpMenu );
407 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 409 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
408 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 410 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
409 } 411 }
410 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); 412 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) );
411 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 413 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
412 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); 414 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) );
413 415
414 // ****************** 416 // ******************
415 QAction *action; 417 QAction *action;
416 QIconSet icon; 418 QIconSet icon;
417 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 419 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
418 configureToolBarMenu->setCheckable( true ); 420 configureToolBarMenu->setCheckable( true );
419 421
420 QString pathString = ""; 422 QString pathString = "";
421 if ( !p->mToolBarMiniIcons ) { 423 if ( !p->mToolBarMiniIcons ) {
422 if ( QApplication::desktop()->width() < 480 ) 424 if ( QApplication::desktop()->width() < 480 )
423 pathString += "icons16/"; 425 pathString += "icons16/";
424 } else 426 } else
425 pathString += "iconsmini/"; 427 pathString += "iconsmini/";
426 configureAgendaMenu->setCheckable( true ); 428 configureAgendaMenu->setCheckable( true );
427 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); 429 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 );
428 configureAgendaMenu->insertSeparator(); 430 configureAgendaMenu->insertSeparator();
429 configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); 431 configureAgendaMenu->insertItem(i18n("Tiny"), 4 );
430 configureAgendaMenu->insertItem(i18n("Small"), 6 ); 432 configureAgendaMenu->insertItem(i18n("Small"), 6 );
431 configureAgendaMenu->insertItem(i18n("Medium"), 8 ); 433 configureAgendaMenu->insertItem(i18n("Medium"), 8 );
432 configureAgendaMenu->insertItem(i18n("Normal"), 10 ); 434 configureAgendaMenu->insertItem(i18n("Normal"), 10 );
433 configureAgendaMenu->insertItem(i18n("Large"), 12 ); 435 configureAgendaMenu->insertItem(i18n("Large"), 12 );
434 configureAgendaMenu->insertItem(i18n("Big"), 14 ); 436 configureAgendaMenu->insertItem(i18n("Big"), 14 );
435 configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); 437 configureAgendaMenu->insertItem(i18n("Bigger"), 16 );
436 configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); 438 configureAgendaMenu->insertItem(i18n("Biggest"), 18 );
437 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 439 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
438 440
439 icon = loadPixmap( pathString + "configure" ); 441 icon = loadPixmap( pathString + "configure" );
440 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 442 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
441 action->addTo( actionMenu ); 443 action->addTo( actionMenu );
442 connect( action, SIGNAL( activated() ), 444 connect( action, SIGNAL( activated() ),
443 mView, SLOT( edit_options() ) ); 445 mView, SLOT( edit_options() ) );
444 actionMenu->insertSeparator(); 446 actionMenu->insertSeparator();
445 icon = loadPixmap( pathString + "newevent" ); 447 icon = loadPixmap( pathString + "newevent" );
446 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 448 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
447 configureToolBarMenu->insertSeparator(); 449 configureToolBarMenu->insertSeparator();
448 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 450 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
449 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 451 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
450 ne_action->addTo( actionMenu ); 452 ne_action->addTo( actionMenu );
451 connect( ne_action, SIGNAL( activated() ), 453 connect( ne_action, SIGNAL( activated() ),
452 mView, SLOT( newEvent() ) ); 454 mView, SLOT( newEvent() ) );
453 icon = loadPixmap( pathString + "newtodo" ); 455 icon = loadPixmap( pathString + "newtodo" );
454 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 456 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
455 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 457 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
456 nt_action->addTo( actionMenu ); 458 nt_action->addTo( actionMenu );
457 connect( nt_action, SIGNAL( activated() ), 459 connect( nt_action, SIGNAL( activated() ),
458 mView, SLOT( newTodo() ) ); 460 mView, SLOT( newTodo() ) );
459 icon = loadPixmap( pathString + "navi" ); 461 icon = loadPixmap( pathString + "navi" );
460 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 462 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
461 action->addTo( viewMenu ); 463 action->addTo( viewMenu );
462 connect( action, SIGNAL( activated() ), 464 connect( action, SIGNAL( activated() ),
463 mView, SLOT( toggleDateNavigatorWidget() ) ); 465 mView, SLOT( toggleDateNavigatorWidget() ) );
464 icon = loadPixmap( pathString + "filter" ); 466 icon = loadPixmap( pathString + "filter" );
465 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 467 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
466 action->addTo( viewMenu ); 468 action->addTo( viewMenu );
467 connect( action, SIGNAL( activated() ), 469 connect( action, SIGNAL( activated() ),
468 mView, SLOT( toggleFilter() ) ); 470 mView, SLOT( toggleFilter() ) );
469 471
470 472
471 viewMenu->insertSeparator(); 473 viewMenu->insertSeparator();
472 icon = loadPixmap( pathString + "picker" ); 474 icon = loadPixmap( pathString + "picker" );
473 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 475 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
474 action->addTo( viewMenu ); 476 action->addTo( viewMenu );
475 connect( action, SIGNAL( activated() ), 477 connect( action, SIGNAL( activated() ),
476 mView, SLOT( showDatePicker() ) ); 478 mView, SLOT( showDatePicker() ) );
477 action->addTo( iconToolBar ); 479 action->addTo( iconToolBar );
478 viewMenu->insertSeparator(); 480 viewMenu->insertSeparator();
479 icon = loadPixmap( pathString + "list" ); 481 icon = loadPixmap( pathString + "list" );
480 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 482 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
481 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 483 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
482 showlist_action->addTo( viewMenu ); 484 showlist_action->addTo( viewMenu );
483 connect( showlist_action, SIGNAL( activated() ), 485 connect( showlist_action, SIGNAL( activated() ),
484 mView->viewManager(), SLOT( showListView() ) ); 486 mView->viewManager(), SLOT( showListView() ) );
485 487
486 488
487 icon = loadPixmap( pathString + "day" ); 489 icon = loadPixmap( pathString + "day" );
488 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 490 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
489 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 491 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
490 day1_action->addTo( viewMenu ); 492 day1_action->addTo( viewMenu );
491 // action->addTo( toolBar ); 493 // action->addTo( toolBar );
492 connect( day1_action, SIGNAL( activated() ), 494 connect( day1_action, SIGNAL( activated() ),
493 mView->viewManager(), SLOT( showDayView() ) ); 495 mView->viewManager(), SLOT( showDayView() ) );
494 496
495 icon = loadPixmap( pathString + "workweek" ); 497 icon = loadPixmap( pathString + "workweek" );
496 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 498 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
497 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 499 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
498 day5_action->addTo( viewMenu ); 500 day5_action->addTo( viewMenu );
499 connect( day5_action, SIGNAL( activated() ), 501 connect( day5_action, SIGNAL( activated() ),
500 mView->viewManager(), SLOT( showWorkWeekView() ) ); 502 mView->viewManager(), SLOT( showWorkWeekView() ) );
501 503
502 icon = loadPixmap( pathString + "week" ); 504 icon = loadPixmap( pathString + "week" );
503 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 505 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
504 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 506 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
505 day7_action->addTo( viewMenu ); 507 day7_action->addTo( viewMenu );
506 connect( day7_action, SIGNAL( activated() ), 508 connect( day7_action, SIGNAL( activated() ),
507 mView->viewManager(), SLOT( showWeekView() ) ); 509 mView->viewManager(), SLOT( showWeekView() ) );
508 510
509 icon = loadPixmap( pathString + "month" ); 511 icon = loadPixmap( pathString + "month" );
510 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 512 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
511 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 513 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
512 month_action->addTo( viewMenu ); 514 month_action->addTo( viewMenu );
513 connect( month_action, SIGNAL( activated() ), 515 connect( month_action, SIGNAL( activated() ),
514 mView->viewManager(), SLOT( showMonthView() ) ); 516 mView->viewManager(), SLOT( showMonthView() ) );
515 517
516 icon = loadPixmap( pathString + "todo" ); 518 icon = loadPixmap( pathString + "todo" );
517 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 519 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
518 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 520 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
519 todoview_action->addTo( viewMenu ); 521 todoview_action->addTo( viewMenu );
520 connect( todoview_action, SIGNAL( activated() ), 522 connect( todoview_action, SIGNAL( activated() ),
521 mView->viewManager(), SLOT( showTodoView() ) ); 523 mView->viewManager(), SLOT( showTodoView() ) );
522 524
523 icon = loadPixmap( pathString + "journal" ); 525 icon = loadPixmap( pathString + "journal" );
524 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 526 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
525 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 527 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
526 viewjournal_action->addTo( viewMenu ); 528 viewjournal_action->addTo( viewMenu );
527 connect( viewjournal_action, SIGNAL( activated() ), 529 connect( viewjournal_action, SIGNAL( activated() ),
528 mView->viewManager(), SLOT( showJournalView() ) ); 530 mView->viewManager(), SLOT( showJournalView() ) );
529 531
530 icon = loadPixmap( pathString + "xdays" ); 532 icon = loadPixmap( pathString + "xdays" );
531 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 533 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
532 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 534 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
533 xdays_action->addTo( viewMenu ); 535 xdays_action->addTo( viewMenu );
534 connect( xdays_action, SIGNAL( activated() ), 536 connect( xdays_action, SIGNAL( activated() ),
535 mView->viewManager(), SLOT( showNextXView() ) ); 537 mView->viewManager(), SLOT( showNextXView() ) );
536 538
537 icon = loadPixmap( pathString + "whatsnext" ); 539 icon = loadPixmap( pathString + "whatsnext" );
538 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 540 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
539 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 541 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
540 whatsnext_action->addTo( viewMenu ); 542 whatsnext_action->addTo( viewMenu );
541 connect( whatsnext_action, SIGNAL( activated() ), 543 connect( whatsnext_action, SIGNAL( activated() ),
542 mView->viewManager(), SLOT( showWhatsNextView() ) ); 544 mView->viewManager(), SLOT( showWhatsNextView() ) );
543 545
544#if 0 546#if 0
545 action = new QAction( "view_timespan", "Time Span", 0, this ); 547 action = new QAction( "view_timespan", "Time Span", 0, this );
546 action->addTo( viewMenu ); 548 action->addTo( viewMenu );
547 connect( action, SIGNAL( activated() ), 549 connect( action, SIGNAL( activated() ),
548 mView->viewManager(), SLOT( showTimeSpanView() ) ); 550 mView->viewManager(), SLOT( showTimeSpanView() ) );
549#endif 551#endif
550 552
551 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 553 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
552 this ); 554 this );
553 mNewSubTodoAction->addTo( actionMenu ); 555 mNewSubTodoAction->addTo( actionMenu );
554 connect( mNewSubTodoAction, SIGNAL( activated() ), 556 connect( mNewSubTodoAction, SIGNAL( activated() ),
555 mView, SLOT( newSubTodo() ) ); 557 mView, SLOT( newSubTodo() ) );
556 558
557 actionMenu->insertSeparator(); 559 actionMenu->insertSeparator();
558 560
559 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 561 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
560 mShowAction->addTo( actionMenu ); 562 mShowAction->addTo( actionMenu );
561 connect( mShowAction, SIGNAL( activated() ), 563 connect( mShowAction, SIGNAL( activated() ),
562 mView, SLOT( showIncidence() ) ); 564 mView, SLOT( showIncidence() ) );
563 565
564 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 566 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
565 mEditAction->addTo( actionMenu ); 567 mEditAction->addTo( actionMenu );
566 connect( mEditAction, SIGNAL( activated() ), 568 connect( mEditAction, SIGNAL( activated() ),
567 mView, SLOT( editIncidence() ) ); 569 mView, SLOT( editIncidence() ) );
568 570
569 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 571 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
570 mDeleteAction->addTo( actionMenu ); 572 mDeleteAction->addTo( actionMenu );
571 connect( mDeleteAction, SIGNAL( activated() ), 573 connect( mDeleteAction, SIGNAL( activated() ),
572 mView, SLOT( deleteIncidence() ) ); 574 mView, SLOT( deleteIncidence() ) );
573 575
574 actionMenu->insertSeparator(); 576 actionMenu->insertSeparator();
575 577
576 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 578 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
577 this ); 579 this );
578 action->addTo( actionMenu ); 580 action->addTo( actionMenu );
579 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 581 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
580 582
581 icon = loadPixmap( pathString + "search" ); 583 icon = loadPixmap( pathString + "search" );
582 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 584 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
583 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 585 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
584 search_action->addTo( actionMenu ); 586 search_action->addTo( actionMenu );
585 connect( search_action, SIGNAL( activated() ), 587 connect( search_action, SIGNAL( activated() ),
586 mView->dialogManager(), SLOT( showSearchDialog() ) ); 588 mView->dialogManager(), SLOT( showSearchDialog() ) );
587 589
588 icon = loadPixmap( pathString + "today" ); 590 icon = loadPixmap( pathString + "today" );
589 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 591 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
590 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 592 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
591 today_action->addTo( actionMenu ); 593 today_action->addTo( actionMenu );
592 connect( today_action, SIGNAL( activated() ), 594 connect( today_action, SIGNAL( activated() ),
593 mView, SLOT( goToday() ) ); 595 mView, SLOT( goToday() ) );
594 596
595 if ( KOPrefs::instance()->mShowFullMenu ) { 597 if ( KOPrefs::instance()->mShowFullMenu ) {
596 actionMenu->insertSeparator(); 598 actionMenu->insertSeparator();
597 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 599 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
598 600
599 } 601 }
600 // actionMenu->insertSeparator(); 602 // actionMenu->insertSeparator();
601 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 603 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
602 this ); 604 this );
603 action->addTo( importMenu ); 605 action->addTo( importMenu );
604 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 606 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
605 action = new QAction( "import_quick", i18n("Import last file"), 0, 607 action = new QAction( "import_quick", i18n("Import last file"), 0,
606 this ); 608 this );
607 action->addTo( importMenu ); 609 action->addTo( importMenu );
608 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 610 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
609 importMenu->insertSeparator(); 611 importMenu->insertSeparator();
610 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 612 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
611 this ); 613 this );
612 action->addTo( importMenu ); 614 action->addTo( importMenu );
613 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 615 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
614#ifndef DESKTOP_VERSION 616#ifndef DESKTOP_VERSION
615 importMenu->insertSeparator(); 617 importMenu->insertSeparator();
616 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 618 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
617 this ); 619 this );
618 action->addTo( importMenu ); 620 action->addTo( importMenu );
619 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 621 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
620#else 622#else
621#ifdef _WIN32_ 623#ifdef _WIN32_
622 importMenu->insertSeparator(); 624 importMenu->insertSeparator();
623 action = new QAction( "import_ol", i18n("Import from OL"), 0, 625 action = new QAction( "import_ol", i18n("Import from OL"), 0,
624 this ); 626 this );
625 action->addTo( importMenu ); 627 action->addTo( importMenu );
626 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 628 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
627#endif 629#endif
628#endif 630#endif
629 631
630 importMenu->insertSeparator(); 632 importMenu->insertSeparator();
631 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 633 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
632 this ); 634 this );
633 action->addTo( importMenu ); 635 action->addTo( importMenu );
634 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 636 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
635 637
636 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 638 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
637 this ); 639 this );
638 action->addTo( importMenu ); 640 action->addTo( importMenu );
639 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 641 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
640 642
641 importMenu->insertSeparator(); 643 importMenu->insertSeparator();
642 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 644 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
643 this ); 645 this );
644 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 646 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
645 importMenu->insertSeparator(); 647 importMenu->insertSeparator();
646 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 648 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
647 this ); 649 this );
648 action->addTo( importMenu ); 650 action->addTo( importMenu );
649 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 651 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
650#ifndef DESKTOP_VERSION 652#ifndef DESKTOP_VERSION
651 importMenu->insertSeparator(); 653 importMenu->insertSeparator();
652 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 654 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
653 this ); 655 this );
654 action->addTo( importMenu ); 656 action->addTo( importMenu );
655 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 657 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
656 658
657 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 659 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
658 this ); 660 this );
659 action->addTo( importMenu ); 661 action->addTo( importMenu );
660 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 662 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
661#else 663#else
662 importMenu->insertSeparator(); 664 importMenu->insertSeparator();
663 icon = loadPixmap( pathString + "print" ); 665 icon = loadPixmap( pathString + "print" );
664 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 666 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
665 action->addTo( importMenu ); 667 action->addTo( importMenu );
666 connect( action, SIGNAL( activated() ), 668 connect( action, SIGNAL( activated() ),
667 this, SLOT( printCal() ) ); 669 this, SLOT( printCal() ) );
668 670
669 icon = loadPixmap( pathString + "print" ); 671 icon = loadPixmap( pathString + "print" );
670 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 672 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
671 action->addTo( importMenu ); 673 action->addTo( importMenu );
672 connect( action, SIGNAL( activated() ), 674 connect( action, SIGNAL( activated() ),
673 this, SLOT( printSel() ) ); 675 this, SLOT( printSel() ) );
674#endif 676#endif
675 importMenu->insertSeparator(); 677 importMenu->insertSeparator();
676 action = new QAction( "beam all", i18n("Save"), 0, 678 action = new QAction( "beam all", i18n("Save"), 0,
677 this ); 679 this );
678 action->addTo( importMenu ); 680 action->addTo( importMenu );
679 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 681 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
680 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 682 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
681 this ); 683 this );
682 action->addTo( importMenu ); 684 action->addTo( importMenu );
683 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 685 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
684 686
685 //menuBar->insertItem( "Configure",configureMenu ); 687 //menuBar->insertItem( "Configure",configureMenu );
686 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 688 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
687 icon = loadPixmap( "korganizer/korganizer" ); 689 icon = loadPixmap( "korganizer/korganizer" );
688 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 690 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
689 action->addTo( helpMenu ); 691 action->addTo( helpMenu );
690 connect( action, SIGNAL( activated() ), 692 connect( action, SIGNAL( activated() ),
691 SLOT( keyBindings() ) ); 693 SLOT( keyBindings() ) );
692 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 694 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
693 action->addTo( helpMenu ); 695 action->addTo( helpMenu );
694 connect( action, SIGNAL( activated() ), 696 connect( action, SIGNAL( activated() ),
695 SLOT( features() ) ); 697 SLOT( features() ) );
696 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 698 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
697 action->addTo( helpMenu ); 699 action->addTo( helpMenu );
698 connect( action, SIGNAL( activated() ), 700 connect( action, SIGNAL( activated() ),
699 SLOT( aboutAutoSaving() ) ); 701 SLOT( aboutAutoSaving() ) );
700 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 702 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
701 action->addTo( helpMenu ); 703 action->addTo( helpMenu );
702 connect( action, SIGNAL( activated() ), 704 connect( action, SIGNAL( activated() ),
703 SLOT( aboutKnownBugs() ) ); 705 SLOT( aboutKnownBugs() ) );
704 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 706 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
705 action->addTo( helpMenu ); 707 action->addTo( helpMenu );
706 connect( action, SIGNAL( activated() ), 708 connect( action, SIGNAL( activated() ),
707 SLOT( usertrans() ) ); 709 SLOT( usertrans() ) );
708 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 710 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
709 action->addTo( helpMenu ); 711 action->addTo( helpMenu );
710 connect( action, SIGNAL( activated() ), 712 connect( action, SIGNAL( activated() ),
711 SLOT( synchowto() ) ); 713 SLOT( synchowto() ) );
712 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 714 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
713 action->addTo( helpMenu ); 715 action->addTo( helpMenu );
714 connect( action, SIGNAL( activated() ), 716 connect( action, SIGNAL( activated() ),
715 SLOT( whatsNew() ) ); 717 SLOT( whatsNew() ) );
716 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 718 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
717 action->addTo( helpMenu ); 719 action->addTo( helpMenu );
718 connect( action, SIGNAL( activated() ), 720 connect( action, SIGNAL( activated() ),
719 SLOT( faq() ) ); 721 SLOT( faq() ) );
720 722
721 723
722 action = new QAction( "about", i18n("About..."), 0, this ); 724 action = new QAction( "about", i18n("About..."), 0, this );
723 action->addTo( helpMenu ); 725 action->addTo( helpMenu );
724 connect( action, SIGNAL( activated() ), 726 connect( action, SIGNAL( activated() ),
725 SLOT( about() ) ); 727 SLOT( about() ) );
726 action = new QAction( "licence", i18n("Licence..."), 0, this ); 728 action = new QAction( "licence", i18n("Licence..."), 0, this );
727 action->addTo( helpMenu ); 729 action->addTo( helpMenu );
728 connect( action, SIGNAL( activated() ), 730 connect( action, SIGNAL( activated() ),
729 SLOT( licence() ) ); 731 SLOT( licence() ) );
730 //menuBar->insertSeparator(); 732 //menuBar->insertSeparator();
731 733
732 // ****************************************************** 734 // ******************************************************
733 // menubar icons 735 // menubar icons
734 736
735 737
736 iconToolBar->setHorizontalStretchable (true ); 738 iconToolBar->setHorizontalStretchable (true );
737 //menuBar->insertItem( iconToolBar ); 739 //menuBar->insertItem( iconToolBar );
738 //xdays_action 740 //xdays_action
739 if (p-> mShowIconNewEvent) 741 if (p-> mShowIconNewEvent)
740 ne_action->addTo( iconToolBar ); 742 ne_action->addTo( iconToolBar );
741 if (p->mShowIconNewTodo ) 743 if (p->mShowIconNewTodo )
742 nt_action->addTo( iconToolBar ); 744 nt_action->addTo( iconToolBar );
743 if (p-> mShowIconSearch) 745 if (p-> mShowIconSearch)
744 search_action->addTo( iconToolBar ); 746 search_action->addTo( iconToolBar );
745 if (p-> mShowIconNext) 747 if (p-> mShowIconNext)
746 whatsnext_action->addTo( iconToolBar ); 748 whatsnext_action->addTo( iconToolBar );
747 if (p-> mShowIconNextDays) 749 if (p-> mShowIconNextDays)
748 xdays_action->addTo( iconToolBar ); 750 xdays_action->addTo( iconToolBar );
749 if (p-> mShowIconList) 751 if (p-> mShowIconList)
750 showlist_action->addTo( iconToolBar ); 752 showlist_action->addTo( iconToolBar );
751 if (p-> mShowIconDay1) 753 if (p-> mShowIconDay1)
752 day1_action->addTo( iconToolBar ); 754 day1_action->addTo( iconToolBar );
753 if (p-> mShowIconDay5) 755 if (p-> mShowIconDay5)
754 day5_action->addTo( iconToolBar ); 756 day5_action->addTo( iconToolBar );
755 if (p-> mShowIconDay7) 757 if (p-> mShowIconDay7)
756 day7_action->addTo( iconToolBar ); 758 day7_action->addTo( iconToolBar );
757 if (p-> mShowIconMonth) 759 if (p-> mShowIconMonth)
758 month_action->addTo( iconToolBar ); 760 month_action->addTo( iconToolBar );
759 if (p-> mShowIconTodoview) 761 if (p-> mShowIconTodoview)
760 todoview_action->addTo( iconToolBar ); 762 todoview_action->addTo( iconToolBar );
761 if (p-> mShowIconJournal) 763 if (p-> mShowIconJournal)
762 viewjournal_action->addTo( iconToolBar ); 764 viewjournal_action->addTo( iconToolBar );
763 icon = loadPixmap( pathString + "2leftarrowB" ); 765 icon = loadPixmap( pathString + "2leftarrowB" );
764 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 766 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
765 if (p-> mShowIconBackFast) { 767 if (p-> mShowIconBackFast) {
766 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 768 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
767 connect( action, SIGNAL( activated() ), 769 connect( action, SIGNAL( activated() ),
768 mView, SLOT( goPreviousMonth() ) ); 770 mView, SLOT( goPreviousMonth() ) );
769 action->addTo( iconToolBar ); 771 action->addTo( iconToolBar );
770 } 772 }
771 icon = loadPixmap( pathString + "1leftarrowB" ); 773 icon = loadPixmap( pathString + "1leftarrowB" );
772 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 774 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
773 if (p-> mShowIconBack) { 775 if (p-> mShowIconBack) {
774 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 776 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
775 connect( action, SIGNAL( activated() ), 777 connect( action, SIGNAL( activated() ),
776 mView, SLOT( goPrevious() ) ); 778 mView, SLOT( goPrevious() ) );
777 action->addTo( iconToolBar ); 779 action->addTo( iconToolBar );
778 } 780 }
779 if (p-> mShowIconToday) 781 if (p-> mShowIconToday)
780 today_action->addTo( iconToolBar ); 782 today_action->addTo( iconToolBar );
781 icon = loadPixmap( pathString + "1rightarrowB" ); 783 icon = loadPixmap( pathString + "1rightarrowB" );
782 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 784 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
783 if (p-> mShowIconForward) { 785 if (p-> mShowIconForward) {
784 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 786 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
785 connect( action, SIGNAL( activated() ), 787 connect( action, SIGNAL( activated() ),
786 mView, SLOT( goNext() ) ); 788 mView, SLOT( goNext() ) );
787 action->addTo( iconToolBar ); 789 action->addTo( iconToolBar );
788 } 790 }
789 icon = loadPixmap( pathString + "2rightarrowB" ); 791 icon = loadPixmap( pathString + "2rightarrowB" );
790 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 792 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
791 if (p-> mShowIconForwardFast) { 793 if (p-> mShowIconForwardFast) {
792 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 794 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
793 connect( action, SIGNAL( activated() ), 795 connect( action, SIGNAL( activated() ),
794 mView, SLOT( goNextMonth() ) ); 796 mView, SLOT( goNextMonth() ) );
795 action->addTo( iconToolBar ); 797 action->addTo( iconToolBar );
796 } 798 }
797 799
798 800
799 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 801 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
800 802
801 if (p-> mShowIconNewEvent) 803 if (p-> mShowIconNewEvent)
802 configureToolBarMenu->setItemChecked( 10, true ); 804 configureToolBarMenu->setItemChecked( 10, true );
803 if (p->mShowIconNewTodo ) 805 if (p->mShowIconNewTodo )
804 configureToolBarMenu->setItemChecked( 20, true ); 806 configureToolBarMenu->setItemChecked( 20, true );
805 if (p-> mShowIconSearch) 807 if (p-> mShowIconSearch)
806 configureToolBarMenu->setItemChecked( 120, true ); 808 configureToolBarMenu->setItemChecked( 120, true );
807 if (p-> mShowIconList) 809 if (p-> mShowIconList)
808 configureToolBarMenu->setItemChecked( 30, true ); 810 configureToolBarMenu->setItemChecked( 30, true );
809 if (p-> mShowIconDay1) 811 if (p-> mShowIconDay1)
810 configureToolBarMenu->setItemChecked( 40, true ); 812 configureToolBarMenu->setItemChecked( 40, true );
811 if (p-> mShowIconDay5) 813 if (p-> mShowIconDay5)
812 configureToolBarMenu->setItemChecked( 50, true ); 814 configureToolBarMenu->setItemChecked( 50, true );
813 if (p-> mShowIconDay7) 815 if (p-> mShowIconDay7)
814 configureToolBarMenu->setItemChecked( 60, true ); 816 configureToolBarMenu->setItemChecked( 60, true );
815 if (p-> mShowIconMonth) 817 if (p-> mShowIconMonth)
816 configureToolBarMenu->setItemChecked( 70, true ); 818 configureToolBarMenu->setItemChecked( 70, true );
817 if (p-> mShowIconTodoview) 819 if (p-> mShowIconTodoview)
818 configureToolBarMenu->setItemChecked( 80, true ); 820 configureToolBarMenu->setItemChecked( 80, true );
819 if (p-> mShowIconBackFast) 821 if (p-> mShowIconBackFast)
820 configureToolBarMenu->setItemChecked( 200, true ); 822 configureToolBarMenu->setItemChecked( 200, true );
821 if (p-> mShowIconBack) 823 if (p-> mShowIconBack)
822 configureToolBarMenu->setItemChecked( 210, true ); 824 configureToolBarMenu->setItemChecked( 210, true );
823 if (p-> mShowIconToday) 825 if (p-> mShowIconToday)
824 configureToolBarMenu->setItemChecked( 130, true ); 826 configureToolBarMenu->setItemChecked( 130, true );
825 if (p-> mShowIconForward) 827 if (p-> mShowIconForward)
826 configureToolBarMenu->setItemChecked( 220, true ); 828 configureToolBarMenu->setItemChecked( 220, true );
827 if (p-> mShowIconForwardFast) 829 if (p-> mShowIconForwardFast)
828 configureToolBarMenu->setItemChecked( 230, true ); 830 configureToolBarMenu->setItemChecked( 230, true );
829 if (p-> mShowIconNextDays) 831 if (p-> mShowIconNextDays)
830 configureToolBarMenu->setItemChecked( 100, true ); 832 configureToolBarMenu->setItemChecked( 100, true );
831 if (p-> mShowIconNext) 833 if (p-> mShowIconNext)
832 configureToolBarMenu->setItemChecked( 110, true ); 834 configureToolBarMenu->setItemChecked( 110, true );
833 if (p-> mShowIconJournal) 835 if (p-> mShowIconJournal)
834 configureToolBarMenu->setItemChecked( 90, true ); 836 configureToolBarMenu->setItemChecked( 90, true );
835 if (p-> mShowIconWhatsThis) 837 if (p-> mShowIconWhatsThis)
836 configureToolBarMenu->setItemChecked( 300, true ); 838 configureToolBarMenu->setItemChecked( 300, true );
837 839
838 QLabel* dummy = new QLabel( iconToolBar ); 840 QLabel* dummy = new QLabel( iconToolBar );
839 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 841 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
840 if (!p-> mShowIconStretch) 842 if (!p-> mShowIconStretch)
841 iconToolBar->setStretchableWidget ( dummy ) ; 843 iconToolBar->setStretchableWidget ( dummy ) ;
842 else 844 else
843 configureToolBarMenu->setItemChecked( 5, true ); 845 configureToolBarMenu->setItemChecked( 5, true );
844 if (p-> mShowIconWhatsThis) 846 if (p-> mShowIconWhatsThis)
845 QWhatsThis::whatsThisButton ( iconToolBar ); 847 QWhatsThis::whatsThisButton ( iconToolBar );
846 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 848 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
847 configureAgenda( p->mHourSize ); 849 configureAgenda( p->mHourSize );
848 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 850 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
849} 851}
850void MainWindow::fillSyncMenu() 852void MainWindow::fillSyncMenu()
851{ 853{
852 syncMenu->clear(); 854 syncMenu->clear();
853 syncMenu->insertItem( i18n("Configure..."), 0 ); 855 syncMenu->insertItem( i18n("Configure..."), 0 );
854 syncMenu->insertSeparator(); 856 syncMenu->insertSeparator();
855 syncMenu->insertItem( i18n("Multiple sync"), 1 ); 857 syncMenu->insertItem( i18n("Multiple sync"), 1 );
856 syncMenu->insertSeparator(); 858 syncMenu->insertSeparator();
857 KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 859 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
858 config.setGroup("General"); 860 config.setGroup("General");
859 QStringList prof = config.readListEntry("SyncProfileNames"); 861 QStringList prof = config.readListEntry("SyncProfileNames");
860 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 862 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
861 if ( prof.count() < 3 ) { 863 if ( prof.count() < 3 ) {
862 prof.clear(); 864 prof.clear();
863 prof << i18n("Sharp_DTM"); 865 prof << i18n("Sharp_DTM");
864 prof << i18n("Local_file"); 866 prof << i18n("Local_file");
865 prof << i18n("Last_file"); 867 prof << i18n("Last_file");
866 KSyncProfile* temp = new KSyncProfile (); 868 KSyncProfile* temp = new KSyncProfile ();
867 temp->setName( prof[0] ); 869 temp->setName( prof[0] );
868 temp->writeConfig(&config); 870 temp->writeConfig(&config);
869 temp->setName( prof[1] ); 871 temp->setName( prof[1] );
870 temp->writeConfig(&config); 872 temp->writeConfig(&config);
871 temp->setName( prof[2] ); 873 temp->setName( prof[2] );
872 temp->writeConfig(&config); 874 temp->writeConfig(&config);
873 config.setGroup("General"); 875 config.setGroup("General");
874 config.writeEntry("SyncProfileNames",prof); 876 config.writeEntry("SyncProfileNames",prof);
875 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 877 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
876 config.sync(); 878 config.sync();
877 delete temp; 879 delete temp;
878 } 880 }
879 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 881 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
880 KOPrefs::instance()->mSyncProfileNames = prof; 882 KOPrefs::instance()->mSyncProfileNames = prof;
881 int i; 883 int i;
882 for ( i = 0; i < prof.count(); ++i ) { 884 for ( i = 0; i < prof.count(); ++i ) {
883 885
884 syncMenu->insertItem( prof[i], 1000+i ); 886 syncMenu->insertItem( prof[i], 1000+i );
885 if ( i == 2 ) 887 if ( i == 2 )
886 syncMenu->insertSeparator(); 888 syncMenu->insertSeparator();
887 } 889 }
888 QDir app_dir; 890 QDir app_dir;
889 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 891 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
890 syncMenu->setItemEnabled( false , 1000 ); 892 syncMenu->setItemEnabled( false , 1000 );
891 } 893 }
892 mView->setupExternSyncProfiles(); 894 mView->setupExternSyncProfiles();
893} 895}
894 896
895int MainWindow::ringSync() 897int MainWindow::ringSync()
896{ 898{
897 int syncedProfiles = 0; 899 int syncedProfiles = 0;
898 int i; 900 int i;
899 QTime timer; 901 QTime timer;
900 KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 902 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
901 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; 903 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames;
902 KSyncProfile* temp = new KSyncProfile (); 904 KSyncProfile* temp = new KSyncProfile ();
903 KOPrefs::instance()->mAskForPreferences = false; 905 KOPrefs::instance()->mAskForPreferences = false;
904 for ( i = 0; i < syncProfileNames.count(); ++i ) { 906 for ( i = 0; i < syncProfileNames.count(); ++i ) {
905 mCurrentSyncProfile = i; 907 mCurrentSyncProfile = i;
906 temp->setName(syncProfileNames[mCurrentSyncProfile]); 908 temp->setName(syncProfileNames[mCurrentSyncProfile]);
907 temp->readConfig(&config); 909 temp->readConfig(&config);
908 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { 910 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) {
909 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 911 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
910 ++syncedProfiles; 912 ++syncedProfiles;
911 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 913 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
912 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 914 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
913 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 915 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
914 KOPrefs::instance()->mShowSyncSummary = false; 916 KOPrefs::instance()->mShowSyncSummary = false;
915 mView->setSyncDevice(syncProfileNames[i] ); 917 mView->setSyncDevice(syncProfileNames[i] );
916 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 918 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
917 if ( i == 0 ) { 919 if ( i == 0 ) {
918 syncSharp(); 920 syncSharp();
919 } else { 921 } else {
920 if ( temp->getIsLocalFileSync() ) { 922 if ( temp->getIsLocalFileSync() ) {
921 if ( syncWithFile( temp->getRemoteFileName( ), true ) ) 923 if ( syncWithFile( temp->getRemoteFileName( ), true ) )
922 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 924 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
923 } else { 925 } else {
924 if ( temp->getIsPhoneSync() ) { 926 if ( temp->getIsPhoneSync() ) {
925 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 927 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
926 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 928 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
927 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 929 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
928 syncPhone(); 930 syncPhone();
929 } else 931 } else
930 syncRemote( temp, false ); 932 syncRemote( temp, false );
931 933
932 } 934 }
933 } 935 }
934 timer.start(); 936 timer.start();
935 setCaption(i18n("Multiple sync in progress ... please wait!") ); 937 setCaption(i18n("Multiple sync in progress ... please wait!") );
936 while ( timer.elapsed () < 2000 ) { 938 while ( timer.elapsed () < 2000 ) {
937 qApp->processEvents(); 939 qApp->processEvents();
938#ifndef _WIN32_ 940#ifndef _WIN32_
939 sleep (1); 941 sleep (1);
940#endif 942#endif
941 } 943 }
942 944
943 } 945 }
944 946
945 } 947 }
946 delete temp; 948 delete temp;
947 return syncedProfiles; 949 return syncedProfiles;
948} 950}
949 951
950void MainWindow::multiSync( bool askforPrefs ) 952void MainWindow::multiSync( bool askforPrefs )
951{ 953{
952 if (mBlockSaveFlag) 954 if (mBlockSaveFlag)
953 return; 955 return;
954 mBlockSaveFlag = true; 956 mBlockSaveFlag = true;
955 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 957 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
956 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 958 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
957 question, 959 question,
958 i18n("Yes"), i18n("No"), 960 i18n("Yes"), i18n("No"),
959 0, 0 ) != 0 ) { 961 0, 0 ) != 0 ) {
960 mBlockSaveFlag = false; 962 mBlockSaveFlag = false;
961 setCaption(i18n("Aborted! Nothing synced!")); 963 setCaption(i18n("Aborted! Nothing synced!"));
962 return; 964 return;
963 } 965 }
964 mView->setSyncDevice(i18n("Multiple profiles") ); 966 mView->setSyncDevice(i18n("Multiple profiles") );
965 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; 967 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs;
966 if ( askforPrefs ) { 968 if ( askforPrefs ) {
967 mView->edit_sync_options(); 969 mView->edit_sync_options();
968 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; 970 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs;
969 } 971 }
970 setCaption(i18n("Multiple sync started.") ); 972 setCaption(i18n("Multiple sync started.") );
971 qApp->processEvents(); 973 qApp->processEvents();
972 int num = ringSync() ; 974 int num = ringSync() ;
973 if ( num > 1 ) 975 if ( num > 1 )
974 ringSync(); 976 ringSync();
975 mBlockSaveFlag = false; 977 mBlockSaveFlag = false;
976 if ( num ) 978 if ( num )
977 save(); 979 save();
978 if ( num ) 980 if ( num )
979 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 981 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
980 else 982 else
981 setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 983 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
982 return; 984 return;
983} 985}
984void MainWindow::slotSyncMenu( int action ) 986void MainWindow::slotSyncMenu( int action )
985{ 987{
986 //qDebug("syncaction %d ", action); 988 //qDebug("syncaction %d ", action);
987 if ( action == 0 ) { 989 if ( action == 0 ) {
988 990
989 confSync(); 991 confSync();
990 992
991 return; 993 return;
992 } 994 }
993 if ( action == 1 ) { 995 if ( action == 1 ) {
994 multiSync( true ); 996 multiSync( true );
995 return; 997 return;
996 } 998 }
997 999
998 if (mBlockSaveFlag) 1000 if (mBlockSaveFlag)
999 return; 1001 return;
1000 mBlockSaveFlag = true; 1002 mBlockSaveFlag = true;
1001 mCurrentSyncProfile = action - 1000 ; 1003 mCurrentSyncProfile = action - 1000 ;
1002 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); 1004 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
1003 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 1005 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
1004 KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 1006 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
1005 KSyncProfile* temp = new KSyncProfile (); 1007 KSyncProfile* temp = new KSyncProfile ();
1006 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1008 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1007 temp->readConfig(&config); 1009 temp->readConfig(&config);
1008 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 1010 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
1009 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 1011 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
1010 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 1012 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
1011 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 1013 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
1012 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 1014 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
1013 if ( action == 1000 ) { 1015 if ( action == 1000 ) {
1014 syncSharp(); 1016 syncSharp();
1015 1017
1016 } else if ( action == 1001 ) { 1018 } else if ( action == 1001 ) {
1017 syncLocalFile(); 1019 syncLocalFile();
1018 1020
1019 } else if ( action == 1002 ) { 1021 } else if ( action == 1002 ) {
1020 quickSyncLocalFile(); 1022 quickSyncLocalFile();
1021 1023
1022 } else if ( action >= 1003 ) { 1024 } else if ( action >= 1003 ) {
1023 if ( temp->getIsLocalFileSync() ) { 1025 if ( temp->getIsLocalFileSync() ) {
1024 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 1026 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
1025 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 1027 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
1026 } else { 1028 } else {
1027 if ( temp->getIsPhoneSync() ) { 1029 if ( temp->getIsPhoneSync() ) {
1028 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 1030 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
1029 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 1031 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
1030 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 1032 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
1031 syncPhone(); 1033 syncPhone();
1032 } else 1034 } else
1033 syncRemote( temp ); 1035 syncRemote( temp );
1034 1036
1035 } 1037 }
1036 } 1038 }
1037 delete temp; 1039 delete temp;
1038 mBlockSaveFlag = false; 1040 mBlockSaveFlag = false;
1039} 1041}
1040void MainWindow::setDefaultPreferences() 1042void MainWindow::setDefaultPreferences()
1041{ 1043{
1042 KOPrefs *p = KOPrefs::instance(); 1044 KOPrefs *p = KOPrefs::instance();
1043 1045
1044 p->mCompactDialogs = true; 1046 p->mCompactDialogs = true;
1045 p->mConfirm = true; 1047 p->mConfirm = true;
1046 // p->mEnableQuickTodo = false; 1048 // p->mEnableQuickTodo = false;
1047} 1049}
1048 1050
1049QString MainWindow::resourcePath() 1051QString MainWindow::resourcePath()
1050{ 1052{
1051 return KGlobal::iconLoader()->iconPath(); 1053 return KGlobal::iconLoader()->iconPath();
1052} 1054}
1053 1055
1054void MainWindow::displayText( QString text ,QString cap ) 1056void MainWindow::displayText( QString text ,QString cap )
1055{ 1057{
1056 QDialog dia( this, "name", true ); ; 1058 QDialog dia( this, "name", true ); ;
1057 dia.setCaption( cap ); 1059 dia.setCaption( cap );
1058 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1060 QVBoxLayout* lay = new QVBoxLayout( &dia );
1059 lay->setSpacing( 3 ); 1061 lay->setSpacing( 3 );
1060 lay->setMargin( 3 ); 1062 lay->setMargin( 3 );
1061 QTextBrowser tb ( &dia ); 1063 QTextBrowser tb ( &dia );
1062 lay->addWidget( &tb ); 1064 lay->addWidget( &tb );
1063 tb.setText( text ); 1065 tb.setText( text );
1064#ifdef DESKTOP_VERSION 1066#ifdef DESKTOP_VERSION
1065 dia.resize( 640, 480); 1067 dia.resize( 640, 480);
1066#else 1068#else
1067 dia.showMaximized(); 1069 dia.showMaximized();
1068#endif 1070#endif
1069 dia.exec(); 1071 dia.exec();
1070} 1072}
1071void MainWindow::displayFile( QString fn, QString cap ) 1073void MainWindow::displayFile( QString fn, QString cap )
1072{ 1074{
1073 QString fileName = resourcePath() + fn; 1075 QString fileName = resourcePath() + fn;
1074 QString text; 1076 QString text;
1075 QFile file( fileName ); 1077 QFile file( fileName );
1076 if (!file.open( IO_ReadOnly ) ) { 1078 if (!file.open( IO_ReadOnly ) ) {
1077 return ; 1079 return ;
1078 1080
1079 } 1081 }
1080 QTextStream ts( &file ); 1082 QTextStream ts( &file );
1081 text = ts.read(); 1083 text = ts.read();
1082 file.close(); 1084 file.close();
1083 displayText( text, cap); 1085 displayText( text, cap);
1084} 1086}
1085void MainWindow::features() 1087void MainWindow::features()
1086{ 1088{
1087 1089
1088 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); 1090 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1089} 1091}
1090 1092
1091void MainWindow::usertrans() 1093void MainWindow::usertrans()
1092{ 1094{
1093 1095
1094 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); 1096 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
1095} 1097}
1096#if 0 1098#if 0
1097#include <libkcal/vcalformat.h> 1099#include <libkcal/vcalformat.h>
1098#include <libkcal/event.h> 1100#include <libkcal/event.h>
1099#include <libkcal/todo.h> 1101#include <libkcal/todo.h>
1100#include <libkcal/incidence.h> 1102#include <libkcal/incidence.h>
1101#endif 1103#endif
1102void MainWindow::synchowto() 1104void MainWindow::synchowto()
1103{ 1105{
1104#if 0 1106#if 0
1105 QPtrList<Incidence> er = mCalendar->rawIncidences(); 1107 QPtrList<Incidence> er = mCalendar->rawIncidences();
1106 Incidence* inR = er.first(); 1108 Incidence* inR = er.first();
1107 VCalFormat vf; 1109 VCalFormat vf;
1108 QString strout; 1110 QString strout;
1109 while ( inR ) { 1111 while ( inR ) {
1110 if ( inR->type() == "Todo" ) 1112 if ( inR->type() == "Todo" )
1111 strout = vf.todoToString( (Todo *) inR ); 1113 strout = vf.todoToString( (Todo *) inR );
1112 if ( inR->type() == "Event" ) 1114 if ( inR->type() == "Event" )
1113 strout = vf.eventToString( (Event *) inR ); 1115 strout = vf.eventToString( (Event *) inR );
1114 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); 1116 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() );
1115 inR = er.next(); 1117 inR = er.next();
1116 } 1118 }
1117#endif 1119#endif
1118 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); 1120 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") );
1119} 1121}
1120void MainWindow::faq() 1122void MainWindow::faq()
1121{ 1123{
1122 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); 1124 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
1123 1125
1124} 1126}
1125void MainWindow::whatsNew() 1127void MainWindow::whatsNew()
1126{ 1128{
1127 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); 1129 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") );
1128 1130
1129} 1131}
1130void MainWindow::licence() 1132void MainWindow::licence()
1131{ 1133{
1132 KApplication::showLicence(); 1134 KApplication::showLicence();
1133 1135
1134} 1136}
1135void MainWindow::about() 1137void MainWindow::about()
1136{ 1138{
1137 QString version; 1139 QString version;
1138#include <../version> 1140#include <../version>
1139 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1141 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1140 i18n("KOrganizer/Platform-independent\n") + 1142 i18n("KOrganizer/Platform-independent\n") +
1141 "(KO/Pi) " + version + " - " + 1143 "(KO/Pi) " + version + " - " +
1142 1144
1143#ifdef DESKTOP_VERSION 1145#ifdef DESKTOP_VERSION
1144 i18n("Desktop Edition\n") + 1146 i18n("Desktop Edition\n") +
1145#else 1147#else
1146 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1148 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1147#endif 1149#endif
1148 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); 1150 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") );
1149} 1151}
1150void MainWindow::keyBindings() 1152void MainWindow::keyBindings()
1151{ 1153{
1152 QString cap = i18n("Key bindings KOrganizer/Pi"); 1154 QString cap = i18n("Key bindings KOrganizer/Pi");
1153 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1155 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1154 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1156 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1155 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1157 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1156 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1158 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1157 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1159 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1158 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1160 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1159 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1161 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1160 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1162 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1161 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1163 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1162 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1164 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1163 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1165 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1164 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1166 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1165 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1167 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1166 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1168 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1167 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1169 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1168 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1170 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1169 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1171 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1170 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1172 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1171 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1173 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1172 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1174 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1173 i18n("<p><h3>In agenda view:</h3></p>\n") + 1175 i18n("<p><h3>In agenda view:</h3></p>\n") +
1174 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1176 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1175 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1177 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1176 i18n("<p><h3>In todo view:</h3></p>\n") + 1178 i18n("<p><h3>In todo view:</h3></p>\n") +
1177 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1179 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1178 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1180 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1179 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1181 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1180 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1182 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1181 i18n("<p><h3>In list view:</h3></p>\n") + 1183 i18n("<p><h3>In list view:</h3></p>\n") +
1182 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1184 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1183 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1185 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1184 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1186 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1185 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1187 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1186 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1188 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1187 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1189 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1188 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1190 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1189 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1191 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1190 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1192 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1191 i18n("<p><b>E</b>: Edit item</p>\n") + 1193 i18n("<p><b>E</b>: Edit item</p>\n") +
1192 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1194 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1193 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1195 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1194 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1196 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1195 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1197 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1196 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1198 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1197 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1199 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1198 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1200 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1199 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1201 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1200 i18n("<p><b>White</b>: Item readonly</p>\n"); 1202 i18n("<p><b>White</b>: Item readonly</p>\n");
1201 displayText( text, cap); 1203 displayText( text, cap);
1202 1204
1203} 1205}
1204void MainWindow::aboutAutoSaving() 1206void MainWindow::aboutAutoSaving()
1205{ 1207{
1206 QMessageBox* msg; 1208 QMessageBox* msg;
1207 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), 1209 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"),
1208 i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, 1210 i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon,
1209 QMessageBox::Ok, 1211 QMessageBox::Ok,
1210 QMessageBox::NoButton, 1212 QMessageBox::NoButton,
1211 QMessageBox::NoButton); 1213 QMessageBox::NoButton);
1212 msg->exec(); 1214 msg->exec();
1213 delete msg; 1215 delete msg;
1214 1216
1215 1217
1216} 1218}
1217void MainWindow::aboutKnownBugs() 1219void MainWindow::aboutKnownBugs()
1218{ 1220{
1219 QMessageBox* msg; 1221 QMessageBox* msg;
1220 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1222 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1221 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ 1223 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+
1222 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1224 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1223 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1225 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1224 i18n("\nor report them in the bugtracker on\n") + 1226 i18n("\nor report them in the bugtracker on\n") +
1225 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1227 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1226 QMessageBox::NoIcon, 1228 QMessageBox::NoIcon,
1227 QMessageBox::Ok, 1229 QMessageBox::Ok,
1228 QMessageBox::NoButton, 1230 QMessageBox::NoButton,
1229 QMessageBox::NoButton); 1231 QMessageBox::NoButton);
1230 msg->exec(); 1232 msg->exec();
1231 delete msg; 1233 delete msg;
1232 1234
1233} 1235}
1234 1236
1235QString MainWindow::defaultFileName() 1237QString MainWindow::defaultFileName()
1236{ 1238{
1237 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1239 return locateLocal( "data", "korganizer/mycalendar.ics" );
1238} 1240}
1239 1241
1240void MainWindow::processIncidenceSelection( Incidence *incidence ) 1242void MainWindow::processIncidenceSelection( Incidence *incidence )
1241{ 1243{
1242 if ( !incidence ) { 1244 if ( !incidence ) {
1243 enableIncidenceActions( false ); 1245 enableIncidenceActions( false );
1244 1246
1245 mNewSubTodoAction->setEnabled( false ); 1247 mNewSubTodoAction->setEnabled( false );
1246 setCaptionToDates(); 1248 setCaptionToDates();
1247 return; 1249 return;
1248 1250
1249 } 1251 }
1250 1252
1251 //KGlobal::locale()->formatDateTime(nextA, true); 1253 //KGlobal::locale()->formatDateTime(nextA, true);
1252 QString startString = ""; 1254 QString startString = "";
1253 if ( incidence->type() != "Todo" ) { 1255 if ( incidence->type() != "Todo" ) {
1254 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1256 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1255 if ( incidence->doesFloat() ) { 1257 if ( incidence->doesFloat() ) {
1256 startString += ": "+incidence->dtStartDateStr( true ); 1258 startString += ": "+incidence->dtStartDateStr( true );
1257 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1259 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1258 1260
1259 } else { 1261 } else {
1260 startString = ": "+incidence->dtStartStr(true); 1262 startString = ": "+incidence->dtStartStr(true);
1261 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1263 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1262 1264
1263 } 1265 }
1264 1266
1265 } else { 1267 } else {
1266 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1268 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1267 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1269 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1268 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1270 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1269 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1271 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1270 } 1272 }
1271 1273
1272 } 1274 }
1273 else 1275 else
1274 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1276 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1275 if ( !incidence->location().isEmpty() ) 1277 if ( !incidence->location().isEmpty() )
1276 startString += " (" +incidence->location()+")"; 1278 startString += " (" +incidence->location()+")";
1277 setCaption( incidence->summary()+startString); 1279 setCaption( incidence->summary()+startString);
1278 1280
1279 enableIncidenceActions( true ); 1281 enableIncidenceActions( true );
1280 1282
1281 if ( incidence->type() == "Event" ) { 1283 if ( incidence->type() == "Event" ) {
1282 mShowAction->setText( i18n("Show Event...") ); 1284 mShowAction->setText( i18n("Show Event...") );
1283 mEditAction->setText( i18n("Edit Event...") ); 1285 mEditAction->setText( i18n("Edit Event...") );
1284 mDeleteAction->setText( i18n("Delete Event...") ); 1286 mDeleteAction->setText( i18n("Delete Event...") );
1285 1287
1286 mNewSubTodoAction->setEnabled( false ); 1288 mNewSubTodoAction->setEnabled( false );
1287 } else if ( incidence->type() == "Todo" ) { 1289 } else if ( incidence->type() == "Todo" ) {
1288 mShowAction->setText( i18n("Show Todo...") ); 1290 mShowAction->setText( i18n("Show Todo...") );
1289 mEditAction->setText( i18n("Edit Todo...") ); 1291 mEditAction->setText( i18n("Edit Todo...") );
1290 mDeleteAction->setText( i18n("Delete Todo...") ); 1292 mDeleteAction->setText( i18n("Delete Todo...") );
1291 1293
1292 mNewSubTodoAction->setEnabled( true ); 1294 mNewSubTodoAction->setEnabled( true );
1293 } else { 1295 } else {
1294 mShowAction->setText( i18n("Show...") ); 1296 mShowAction->setText( i18n("Show...") );
1295 mShowAction->setText( i18n("Edit...") ); 1297 mShowAction->setText( i18n("Edit...") );
1296 mShowAction->setText( i18n("Delete...") ); 1298 mShowAction->setText( i18n("Delete...") );
1297 1299
1298 mNewSubTodoAction->setEnabled( false ); 1300 mNewSubTodoAction->setEnabled( false );
1299 } 1301 }
1300} 1302}
1301 1303
1302void MainWindow::enableIncidenceActions( bool enabled ) 1304void MainWindow::enableIncidenceActions( bool enabled )
1303{ 1305{
1304 mShowAction->setEnabled( enabled ); 1306 mShowAction->setEnabled( enabled );
1305 mEditAction->setEnabled( enabled ); 1307 mEditAction->setEnabled( enabled );
1306 mDeleteAction->setEnabled( enabled ); 1308 mDeleteAction->setEnabled( enabled );
1307} 1309}
1308 1310
1309void MainWindow::importOL() 1311void MainWindow::importOL()
1310{ 1312{
1311#ifdef _WIN32_ 1313#ifdef _WIN32_
1312 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1314 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1313 id->exec(); 1315 id->exec();
1314 delete id; 1316 delete id;
1315 mView->updateView(); 1317 mView->updateView();
1316#endif 1318#endif
1317} 1319}
1318void MainWindow::importBday() 1320void MainWindow::importBday()
1319{ 1321{
1320 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1322 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1321 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1323 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1322 i18n("Import!"), i18n("Cancel"), 0, 1324 i18n("Import!"), i18n("Cancel"), 0,
1323 0, 1 ); 1325 0, 1 );
1324 if ( result == 0 ) { 1326 if ( result == 0 ) {
1325 mView->importBday(); 1327 mView->importBday();
1326 1328
1327 } 1329 }
1328 1330
1329 1331
1330} 1332}
1331void MainWindow::importQtopia() 1333void MainWindow::importQtopia()
1332{ 1334{
1333#ifndef DESKTOP_VERSION 1335#ifndef DESKTOP_VERSION
1334 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1336 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1335 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), 1337 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"),
1336 i18n("Import!"), i18n("Cancel"), 0, 1338 i18n("Import!"), i18n("Cancel"), 0,
1337 0, 1 ); 1339 0, 1 );
1338 if ( result == 0 ) { 1340 if ( result == 0 ) {
1339 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1341 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1340 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1342 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1341 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1343 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1342 mView->importQtopia( categories, datebook, todolist ); 1344 mView->importQtopia( categories, datebook, todolist );
1343 } 1345 }
1344#else 1346#else
1345 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1347 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1346 i18n("Not supported \non desktop!\n"), 1348 i18n("Not supported \non desktop!\n"),
1347 i18n("Ok"), i18n("Cancel"), 0, 1349 i18n("Ok"), i18n("Cancel"), 0,
1348 0, 1 ); 1350 0, 1 );
1349 1351
1350#endif 1352#endif
1351} 1353}
1352 1354
1353void MainWindow::saveOnClose() 1355void MainWindow::saveOnClose()
1354{ 1356{
1355 KOPrefs *p = KOPrefs::instance(); 1357 KOPrefs *p = KOPrefs::instance();
1356 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1358 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1357 p->mToolBarUp = iconToolBar->x() > width()/2 || 1359 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1358 iconToolBar->y() > height()/2; 1360 iconToolBar->y() > height()/2;
1359 mView->writeSettings(); 1361 mView->writeSettings();
1360 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1362 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1361 save(); 1363 save();
1362} 1364}
1363void MainWindow::slotModifiedChanged( bool changed ) 1365void MainWindow::slotModifiedChanged( bool changed )
1364{ 1366{
1365 if ( mBlockAtStartup ) 1367 if ( mBlockAtStartup )
1366 return; 1368 return;
1367 int msec; 1369 int msec;
1368 // we store the changes after 1 minute, 1370 // we store the changes after 1 minute,
1369 // and for safety reasons after 10 minutes again 1371 // and for safety reasons after 10 minutes again
1370 if ( !mBlockSaveFlag ) 1372 if ( !mBlockSaveFlag )
1371 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1373 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1372 else 1374 else
1373 msec = 1000 * 600; 1375 msec = 1000 * 600;
1374 mSaveTimer.start( msec, true ); // 1 minute 1376 mSaveTimer.start( msec, true ); // 1 minute
1375 qDebug("KO: Saving File in %d secs!", msec/1000); 1377 qDebug("KO: Saving File in %d secs!", msec/1000);
1376 mCalendarModifiedFlag = true; 1378 mCalendarModifiedFlag = true;
1377} 1379}
1378#include <qfileinfo.h> 1380#include <qfileinfo.h>
1379void MainWindow::save() 1381void MainWindow::save()
1380{ 1382{
1381 if ( mBlockSaveFlag ) 1383 if ( mBlockSaveFlag )
1382 return; 1384 return;
1383 bool store = mBlockSaveFlag; 1385 bool store = mBlockSaveFlag;
1384 mBlockSaveFlag = true; 1386 mBlockSaveFlag = true;
1385 if ( mView->checkFileVersion( defaultFileName()) ) { 1387 if ( mView->checkFileVersion( defaultFileName()) ) {
1386 1388
1387 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1389 QTime neededSaveTime = QDateTime::currentDateTime().time();
1388 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1390 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1389 qDebug("KO: Start saving data to file!"); 1391 qDebug("KO: Start saving data to file!");
1390 mView->saveCalendar( defaultFileName() ); 1392 mView->saveCalendar( defaultFileName() );
1391 1393
1392 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1394 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1393 mView->setLoadedFileVersion(QDateTime::currentDateTime()); 1395 mView->setLoadedFileVersion(QDateTime::currentDateTime());
1394 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1396 qDebug("KO: Needed %d ms for saving.",msNeeded );
1395 QString savemes; 1397 QString savemes;
1396 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1398 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1397 setCaption(savemes); 1399 setCaption(savemes);
1398 } else 1400 } else
1399 setCaption(i18n("Saving cancelled!")); 1401 setCaption(i18n("Saving cancelled!"));
1400 mCalendarModifiedFlag = false; 1402 mCalendarModifiedFlag = false;
1401 mBlockSaveFlag = store; 1403 mBlockSaveFlag = store;
1402} 1404}
1403 1405
1404void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1406void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1405{ 1407{
1406 if ( !e->isAutoRepeat() ) { 1408 if ( !e->isAutoRepeat() ) {
1407 mFlagKeyPressed = false; 1409 mFlagKeyPressed = false;
1408 } 1410 }
1409} 1411}
1410void MainWindow::keyPressEvent ( QKeyEvent * e ) 1412void MainWindow::keyPressEvent ( QKeyEvent * e )
1411{ 1413{
1412 qApp->processEvents(); 1414 qApp->processEvents();
1413 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1415 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1414 e->ignore(); 1416 e->ignore();
1415 // qDebug(" ignore %d",e->isAutoRepeat() ); 1417 // qDebug(" ignore %d",e->isAutoRepeat() );
1416 return; 1418 return;
1417 } 1419 }
1418 if (! e->isAutoRepeat() ) 1420 if (! e->isAutoRepeat() )
1419 mFlagKeyPressed = true; 1421 mFlagKeyPressed = true;
1420 KOPrefs *p = KOPrefs::instance(); 1422 KOPrefs *p = KOPrefs::instance();
1421 bool showSelectedDates = false; 1423 bool showSelectedDates = false;
1422 int size; 1424 int size;
1423 int pro = 0; 1425 int pro = 0;
1424 //qDebug("MainWindow::keyPressEvent "); 1426 //qDebug("MainWindow::keyPressEvent ");
1425 switch ( e->key() ) { 1427 switch ( e->key() ) {
1426 case Qt::Key_Right: 1428 case Qt::Key_Right:
1427 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1429 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1428 mView->goNextMonth(); 1430 mView->goNextMonth();
1429 else 1431 else
1430 mView->goNext(); 1432 mView->goNext();
1431 showSelectedDates = true; 1433 showSelectedDates = true;
1432 break; 1434 break;
1433 case Qt::Key_Left: 1435 case Qt::Key_Left:
1434 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1436 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1435 mView->goPreviousMonth(); 1437 mView->goPreviousMonth();
1436 else 1438 else
1437 mView->goPrevious(); 1439 mView->goPrevious();
1438 showSelectedDates = true; 1440 showSelectedDates = true;
1439 break; 1441 break;
1440 case Qt::Key_Down: 1442 case Qt::Key_Down:
1441 mView->viewManager()->agendaView()->scrollOneHourDown(); 1443 mView->viewManager()->agendaView()->scrollOneHourDown();
1442 break; 1444 break;
1443 case Qt::Key_Up: 1445 case Qt::Key_Up:
1444 mView->viewManager()->agendaView()->scrollOneHourUp(); 1446 mView->viewManager()->agendaView()->scrollOneHourUp();
1445 break; 1447 break;
1446 case Qt::Key_I: 1448 case Qt::Key_I:
1447 mView->showIncidence(); 1449 mView->showIncidence();
1448 break; 1450 break;
1449 case Qt::Key_Delete: 1451 case Qt::Key_Delete:
1450 case Qt::Key_Backspace: 1452 case Qt::Key_Backspace:
1451 mView->deleteIncidence(); 1453 mView->deleteIncidence();
1452 break; 1454 break;
1453 case Qt::Key_D: 1455 case Qt::Key_D:
1454 mView->viewManager()->showDayView(); 1456 mView->viewManager()->showDayView();
1455 showSelectedDates = true; 1457 showSelectedDates = true;
1456 break; 1458 break;
1457 case Qt::Key_O: 1459 case Qt::Key_O:
1458 mView->toggleFilerEnabled( ); 1460 mView->toggleFilerEnabled( );
1459 break; 1461 break;
1460 case Qt::Key_0: 1462 case Qt::Key_0:
1461 case Qt::Key_1: 1463 case Qt::Key_1:
1462 case Qt::Key_2: 1464 case Qt::Key_2:
1463 case Qt::Key_3: 1465 case Qt::Key_3:
1464 case Qt::Key_4: 1466 case Qt::Key_4:
1465 case Qt::Key_5: 1467 case Qt::Key_5:
1466 case Qt::Key_6: 1468 case Qt::Key_6:
1467 case Qt::Key_7: 1469 case Qt::Key_7:
1468 case Qt::Key_8: 1470 case Qt::Key_8:
1469 case Qt::Key_9: 1471 case Qt::Key_9:
1470 pro = e->key()-48; 1472 pro = e->key()-48;
1471 if ( pro == 0 ) 1473 if ( pro == 0 )
1472 pro = 10; 1474 pro = 10;
1473 if ( e->state() == Qt::ControlButton) 1475 if ( e->state() == Qt::ControlButton)
1474 pro += 10; 1476 pro += 10;
1475 break; 1477 break;
1476 case Qt::Key_M: 1478 case Qt::Key_M:
1477 mView->viewManager()->showMonthView(); 1479 mView->viewManager()->showMonthView();
1478 showSelectedDates = true; 1480 showSelectedDates = true;
1479 break; 1481 break;
1480 case Qt::Key_Insert: 1482 case Qt::Key_Insert:
1481 mView->newEvent(); 1483 mView->newEvent();
1482 break; 1484 break;
1483 case Qt::Key_S : 1485 case Qt::Key_S :
1484 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1486 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1485 mView->newSubTodo(); 1487 mView->newSubTodo();
1486 else 1488 else
1487 mView->dialogManager()->showSearchDialog(); 1489 mView->dialogManager()->showSearchDialog();
1488 break; 1490 break;
1489 case Qt::Key_Y : 1491 case Qt::Key_Y :
1490 case Qt::Key_Z : 1492 case Qt::Key_Z :
1491 mView->viewManager()->showWorkWeekView(); 1493 mView->viewManager()->showWorkWeekView();
1492 showSelectedDates = true; 1494 showSelectedDates = true;
1493 break; 1495 break;
1494 case Qt::Key_U : 1496 case Qt::Key_U :
1495 mView->viewManager()->showWeekView(); 1497 mView->viewManager()->showWeekView();
1496 showSelectedDates = true; 1498 showSelectedDates = true;
1497 break; 1499 break;
1498 case Qt::Key_H : 1500 case Qt::Key_H :
1499 keyBindings(); 1501 keyBindings();
1500 break; 1502 break;
1501 case Qt::Key_W: 1503 case Qt::Key_W:
1502 mView->viewManager()->showWhatsNextView(); 1504 mView->viewManager()->showWhatsNextView();
1503 break; 1505 break;
1504 case Qt::Key_L: 1506 case Qt::Key_L:
1505 mView->viewManager()->showListView(); 1507 mView->viewManager()->showListView();
1506 break; 1508 break;
1507 case Qt::Key_N: 1509 case Qt::Key_N:
1508 mView->viewManager()->showNextXView(); 1510 mView->viewManager()->showNextXView();
1509 showSelectedDates = true; 1511 showSelectedDates = true;
1510 break; 1512 break;
1511 case Qt::Key_V: 1513 case Qt::Key_V:
1512 mView->viewManager()->showTodoView(); 1514 mView->viewManager()->showTodoView();
1513 break; 1515 break;
1514 case Qt::Key_C: 1516 case Qt::Key_C:
1515 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1517 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1516 break; 1518 break;
1517 case Qt::Key_P: 1519 case Qt::Key_P:
1518 mView->showDatePicker( ); 1520 mView->showDatePicker( );
1519 break; 1521 break;
1520 case Qt::Key_F: 1522 case Qt::Key_F:
1521 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1523 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1522 mView->editFilters(); 1524 mView->editFilters();
1523 else 1525 else
1524 mView->toggleFilter(); 1526 mView->toggleFilter();
1525 break; 1527 break;
1526 case Qt::Key_X: 1528 case Qt::Key_X:
1527 mView->toggleDateNavigatorWidget(); 1529 mView->toggleDateNavigatorWidget();
1528 break; 1530 break;
1529 case Qt::Key_Space: 1531 case Qt::Key_Space:
1530 mView->toggleExpand(); 1532 mView->toggleExpand();
1531 break; 1533 break;
1532 case Qt::Key_A: 1534 case Qt::Key_A:
1533 mView->toggleAllDaySize(); 1535 mView->toggleAllDaySize();
1534 break; 1536 break;
1535 case Qt::Key_T: 1537 case Qt::Key_T:
1536 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1538 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1537 mView->newTodo(); 1539 mView->newTodo();
1538 else { 1540 else {
1539 mView->goToday(); 1541 mView->goToday();
1540 showSelectedDates = true; 1542 showSelectedDates = true;
1541 } 1543 }
1542 break; 1544 break;
1543 case Qt::Key_J: 1545 case Qt::Key_J:
1544 mView->viewManager()->showJournalView(); 1546 mView->viewManager()->showJournalView();
1545 break; 1547 break;
1546 case Qt::Key_B: 1548 case Qt::Key_B:
1547 mView->editIncidenceDescription();; 1549 mView->editIncidenceDescription();;
1548 break; 1550 break;
1549 // case Qt::Key_Return: 1551 // case Qt::Key_Return:
1550 case Qt::Key_E: 1552 case Qt::Key_E:
1551 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1553 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1552 mView->newEvent(); 1554 mView->newEvent();
1553 else 1555 else
1554 mView->editIncidence(); 1556 mView->editIncidence();
1555 break; 1557 break;
1556 case Qt::Key_Plus: 1558 case Qt::Key_Plus:
1557 size = p->mHourSize +2; 1559 size = p->mHourSize +2;
1558 if ( size <= 18 ) 1560 if ( size <= 18 )
1559 configureAgenda( size ); 1561 configureAgenda( size );
1560 break; 1562 break;
1561 case Qt::Key_Minus: 1563 case Qt::Key_Minus:
1562 size = p->mHourSize - 2; 1564 size = p->mHourSize - 2;
1563 if ( size >= 4 ) 1565 if ( size >= 4 )
1564 configureAgenda( size ); 1566 configureAgenda( size );
1565 break; 1567 break;
1566 1568
1567 1569
1568 default: 1570 default:
1569 e->ignore(); 1571 e->ignore();
1570 } 1572 }
1571 if ( pro > 0 ) { 1573 if ( pro > 0 ) {
1572 mView->selectFilter( pro-1 ); 1574 mView->selectFilter( pro-1 );
1573 } 1575 }
1574 if ( showSelectedDates ) { 1576 if ( showSelectedDates ) {
1575 ;// setCaptionToDates(); 1577 ;// setCaptionToDates();
1576 } 1578 }
1577 1579
1578} 1580}
1579 1581
1580void MainWindow::fillFilterMenu() 1582void MainWindow::fillFilterMenu()
1581{ 1583{
1582 selectFilterMenu->clear(); 1584 selectFilterMenu->clear();
1583 bool disable = false; 1585 bool disable = false;
1584 if ( mView->filterView()->filtersEnabled() ) { 1586 if ( mView->filterView()->filtersEnabled() ) {
1585 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); 1587 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 );
1586 } 1588 }
1587 else { 1589 else {
1588 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); 1590 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 );
1589 disable = true; 1591 disable = true;
1590 } 1592 }
1591 selectFilterMenu->insertSeparator(); 1593 selectFilterMenu->insertSeparator();
1592 QPtrList<CalFilter> fili = mView->filters(); 1594 QPtrList<CalFilter> fili = mView->filters();
1593 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1595 CalFilter *curfilter = mView->filterView()->selectedFilter();
1594 CalFilter *filter = fili.first(); 1596 CalFilter *filter = fili.first();
1595 int iii = 1; 1597 int iii = 1;
1596 while(filter) { 1598 while(filter) {
1597 selectFilterMenu->insertItem( filter->name(), iii ); 1599 selectFilterMenu->insertItem( filter->name(), iii );
1598 if ( filter == curfilter) 1600 if ( filter == curfilter)
1599 selectFilterMenu->setItemChecked( iii, true ); 1601 selectFilterMenu->setItemChecked( iii, true );
1600 if ( disable ) 1602 if ( disable )
1601 selectFilterMenu->setItemEnabled( iii, false ); 1603 selectFilterMenu->setItemEnabled( iii, false );
1602 filter = fili.next(); 1604 filter = fili.next();
1603 ++iii; 1605 ++iii;
1604 } 1606 }
1605} 1607}
1606void MainWindow::selectFilter( int fil ) 1608void MainWindow::selectFilter( int fil )
1607{ 1609{
1608 if ( fil == 0 ) { 1610 if ( fil == 0 ) {
1609 mView->toggleFilerEnabled( ); 1611 mView->toggleFilerEnabled( );
1610 } else { 1612 } else {
1611 mView->selectFilter( fil-1 ); 1613 mView->selectFilter( fil-1 );
1612 } 1614 }
1613} 1615}
1614void MainWindow::configureToolBar( int item ) 1616void MainWindow::configureToolBar( int item )
1615{ 1617{
1616 1618
1617 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1619 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1618 KOPrefs *p = KOPrefs::instance(); 1620 KOPrefs *p = KOPrefs::instance();
1619 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1621 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1620 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1622 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1621 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1623 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1622 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1624 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1623 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1625 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1624 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1626 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1625 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1627 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1626 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1628 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1627 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1629 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1628 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1630 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1629 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1631 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1630 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1632 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1631 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1633 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1632 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1634 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1633 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1635 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1634 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1636 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1635 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1637 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1636 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1638 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1637 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1639 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1638 // initActions(); 1640 // initActions();
1639} 1641}
1640 1642
1641void MainWindow::setCaptionToDates() 1643void MainWindow::setCaptionToDates()
1642{ 1644{
1643 QString selDates; 1645 QString selDates;
1644 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1646 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1645 if (mView->startDate() < mView->endDate() ) 1647 if (mView->startDate() < mView->endDate() )
1646 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1648 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1647 setCaption( i18n("Dates: ") + selDates ); 1649 setCaption( i18n("Dates: ") + selDates );
1648 1650
1649} 1651}
1650// parameter item == 0: reinit 1652// parameter item == 0: reinit
1651void MainWindow::configureAgenda( int item ) 1653void MainWindow::configureAgenda( int item )
1652{ 1654{
1653 1655
1654 KOPrefs *p = KOPrefs::instance(); 1656 KOPrefs *p = KOPrefs::instance();
1655 1657
1656 int i; 1658 int i;
1657 if ( item == 1 ) { 1659 if ( item == 1 ) {
1658 mView->toggleAllDaySize(); 1660 mView->toggleAllDaySize();
1659 return; 1661 return;
1660 } 1662 }
1661 // do not allow 4 for widgets higher than 480 1663 // do not allow 4 for widgets higher than 480
1662 // if ( QApplication::desktop()->height() > 480 ) { 1664 // if ( QApplication::desktop()->height() > 480 ) {
1663// if ( item == 4 ) 1665// if ( item == 4 )
1664// item = 6; 1666// item = 6;
1665// } 1667// }
1666 for ( i = 4; i <= 18; i= i+2 ) 1668 for ( i = 4; i <= 18; i= i+2 )
1667 configureAgendaMenu->setItemChecked( i, false ); 1669 configureAgendaMenu->setItemChecked( i, false );
1668 configureAgendaMenu->setItemChecked( item, true ); 1670 configureAgendaMenu->setItemChecked( item, true );
1669 if ( p->mHourSize == item ) 1671 if ( p->mHourSize == item )
1670 return; 1672 return;
1671 p->mHourSize=item; 1673 p->mHourSize=item;
1672 mView->viewManager()->agendaView()->updateConfig(); 1674 mView->viewManager()->agendaView()->updateConfig();
1673} 1675}
1674 1676
1675void MainWindow::saveCalendar() 1677void MainWindow::saveCalendar()
1676{ 1678{
1677 QString fn = KOPrefs::instance()->mLastSaveFile; 1679 QString fn = KOPrefs::instance()->mLastSaveFile;
1678 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1680 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1679 1681
1680 if ( fn == "" ) 1682 if ( fn == "" )
1681 return; 1683 return;
1682 QFileInfo info; 1684 QFileInfo info;
1683 info.setFile( fn ); 1685 info.setFile( fn );
1684 QString mes; 1686 QString mes;
1685 bool createbup = true; 1687 bool createbup = true;
1686 if ( info. exists() ) { 1688 if ( info. exists() ) {
1687 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1689 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1688 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1690 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1689 i18n("Overwrite!"), i18n("Cancel"), 0, 1691 i18n("Overwrite!"), i18n("Cancel"), 0,
1690 0, 1 ); 1692 0, 1 );
1691 if ( result != 0 ) { 1693 if ( result != 0 ) {
1692 createbup = false; 1694 createbup = false;
1693 } 1695 }
1694 } 1696 }
1695 if ( createbup ) { 1697 if ( createbup ) {
1696 mView->saveCalendar( fn ); 1698 mView->saveCalendar( fn );
1697 mes = i18n("KO/Pi:Saved %1").arg(fn); 1699 mes = i18n("KO/Pi:Saved %1").arg(fn);
1698 KOPrefs::instance()->mLastSaveFile = fn; 1700 KOPrefs::instance()->mLastSaveFile = fn;
1699 setCaption(mes); 1701 setCaption(mes);
1700 } 1702 }
1701} 1703}
1702void MainWindow::loadCalendar() 1704void MainWindow::loadCalendar()
1703{ 1705{
1704 1706
1705 QString fn = KOPrefs::instance()->mLastLoadFile; 1707 QString fn = KOPrefs::instance()->mLastLoadFile;
1706 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1708 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1707 1709
1708 if ( fn == "" ) 1710 if ( fn == "" )
1709 return; 1711 return;
1710 QFileInfo info; 1712 QFileInfo info;
1711 info.setFile( fn ); 1713 info.setFile( fn );
1712 QString mess; 1714 QString mess;
1713 bool loadbup = true; 1715 bool loadbup = true;
1714 if ( info. exists() ) { 1716 if ( info. exists() ) {
1715 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1717 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1716 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1718 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1717 mess, 1719 mess,
1718 i18n("Load!"), i18n("Cancel"), 0, 1720 i18n("Load!"), i18n("Cancel"), 0,
1719 0, 1 ); 1721 0, 1 );
1720 if ( result != 0 ) { 1722 if ( result != 0 ) {
1721 loadbup = false; 1723 loadbup = false;
1722 } 1724 }
1723 } else { 1725 } else {
1724 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1726 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1725 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1727 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1726 0, 1 ); 1728 0, 1 );
1727 1729
1728 return; 1730 return;
1729 } 1731 }
1730 if ( loadbup ) { 1732 if ( loadbup ) {
1731 mView->openCalendar( fn ); 1733 mView->openCalendar( fn );
1732 KOPrefs::instance()->mLastLoadFile = fn; 1734 KOPrefs::instance()->mLastLoadFile = fn;
1733 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1735 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1734 setCaption(mess); 1736 setCaption(mess);
1735 } 1737 }
1736 1738
1737} 1739}
1738void MainWindow::quickImportIcal() 1740void MainWindow::quickImportIcal()
1739{ 1741{
1740 importFile( KOPrefs::instance()->mLastImportFile, false ); 1742 importFile( KOPrefs::instance()->mLastImportFile, false );
1741} 1743}
1742void MainWindow::importFile( QString fn, bool quick ) 1744void MainWindow::importFile( QString fn, bool quick )
1743{ 1745{
1744 QFileInfo info; 1746 QFileInfo info;
1745 info.setFile( fn ); 1747 info.setFile( fn );
1746 QString mess; 1748 QString mess;
1747 bool loadbup = true; 1749 bool loadbup = true;
1748 if ( !info. exists() ) { 1750 if ( !info. exists() ) {
1749 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1751 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1750 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1752 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1751 mess ); 1753 mess );
1752 return; 1754 return;
1753 } 1755 }
1754 int result = 0; 1756 int result = 0;
1755 if ( !quick ) { 1757 if ( !quick ) {
1756 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1758 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1757 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1759 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1758 mess, 1760 mess,
1759 "Import", "Cancel", 0, 1761 "Import", "Cancel", 0,
1760 0, 1 ); 1762 0, 1 );
1761 } 1763 }
1762 if ( result == 0 ) { 1764 if ( result == 0 ) {
1763 if ( mView->openCalendar( fn, true )) { 1765 if ( mView->openCalendar( fn, true )) {
1764 KOPrefs::instance()->mLastImportFile = fn; 1766 KOPrefs::instance()->mLastImportFile = fn;
1765 setCaption(i18n("Imported file successfully")); 1767 setCaption(i18n("Imported file successfully"));
1766 } else { 1768 } else {
1767 setCaption(i18n("Error importing file")); 1769 setCaption(i18n("Error importing file"));
1768 } 1770 }
1769 } 1771 }
1770} 1772}
1771 1773
1772void MainWindow::importIcal() 1774void MainWindow::importIcal()
1773{ 1775{
1774 1776
1775 QString fn =KOPrefs::instance()->mLastImportFile; 1777 QString fn =KOPrefs::instance()->mLastImportFile;
1776 1778
1777 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1779 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1778 if ( fn == "" ) 1780 if ( fn == "" )
1779 return; 1781 return;
1780 importFile( fn, true ); 1782 importFile( fn, true );
1781 1783
1782} 1784}
1783 1785
1784void MainWindow::exportVCalendar() 1786void MainWindow::exportVCalendar()
1785{ 1787{
1786 QString fn = KOPrefs::instance()->mLastVcalFile; 1788 QString fn = KOPrefs::instance()->mLastVcalFile;
1787 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1789 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1788 if ( fn == "" ) 1790 if ( fn == "" )
1789 return; 1791 return;
1790 QFileInfo info; 1792 QFileInfo info;
1791 info.setFile( fn ); 1793 info.setFile( fn );
1792 QString mes; 1794 QString mes;
1793 bool createbup = true; 1795 bool createbup = true;
1794 if ( info. exists() ) { 1796 if ( info. exists() ) {
1795 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1797 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1796 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1798 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1797 i18n("Overwrite!"), i18n("Cancel"), 0, 1799 i18n("Overwrite!"), i18n("Cancel"), 0,
1798 0, 1 ); 1800 0, 1 );
1799 if ( result != 0 ) { 1801 if ( result != 0 ) {
1800 createbup = false; 1802 createbup = false;
1801 } 1803 }
1802 } 1804 }
1803 if ( createbup ) { 1805 if ( createbup ) {
1804 if ( mView->exportVCalendar( fn ) ) { 1806 if ( mView->exportVCalendar( fn ) ) {
1805 KOPrefs::instance()->mLastVcalFile = fn; 1807 KOPrefs::instance()->mLastVcalFile = fn;
1806 if ( fn.length() > 20 ) 1808 if ( fn.length() > 20 )
1807 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 1809 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1808 else 1810 else
1809 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 1811 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1810 setCaption(mes); 1812 setCaption(mes);
1811 } 1813 }
1812 } 1814 }
1813 1815
1814} 1816}
1815#include <qpushbutton.h> 1817#include <qpushbutton.h>
1816QString MainWindow::getPassword( ) 1818QString MainWindow::getPassword( )
1817{ 1819{
1818 QString retfile = ""; 1820 QString retfile = "";
1819 QDialog dia ( this, "input-dialog", true ); 1821 QDialog dia ( this, "input-dialog", true );
1820 QLineEdit lab ( &dia ); 1822 QLineEdit lab ( &dia );
1821 lab.setEchoMode( QLineEdit::Password ); 1823 lab.setEchoMode( QLineEdit::Password );
1822 QVBoxLayout lay( &dia ); 1824 QVBoxLayout lay( &dia );
1823 lay.setMargin(7); 1825 lay.setMargin(7);
1824 lay.setSpacing(7); 1826 lay.setSpacing(7);
1825 lay.addWidget( &lab); 1827 lay.addWidget( &lab);
1826 dia.setFixedSize( 230,50 ); 1828 dia.setFixedSize( 230,50 );
1827 dia.setCaption( i18n("Enter password") ); 1829 dia.setCaption( i18n("Enter password") );
1828 QPushButton pb ( "OK", &dia); 1830 QPushButton pb ( "OK", &dia);
1829 lay.addWidget( &pb ); 1831 lay.addWidget( &pb );
1830 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1832 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1831 dia.show(); 1833 dia.show();
1832 int res = dia.exec(); 1834 int res = dia.exec();
1833 if ( res ) 1835 if ( res )
1834 retfile = lab.text(); 1836 retfile = lab.text();
1835 dia.hide(); 1837 dia.hide();
1836 qApp->processEvents(); 1838 qApp->processEvents();
1837 return retfile; 1839 return retfile;
1838 1840
1839} 1841}
1840 1842
1841void MainWindow::syncLocalFile() 1843void MainWindow::syncLocalFile()
1842{ 1844{
1843 1845
1844 QString fn =KOPrefs::instance()->mLastSyncedLocalFile; 1846 QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
1845 1847
1846 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 1848 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
1847 if ( fn == "" ) 1849 if ( fn == "" )
1848 return; 1850 return;
1849 //mView->setSyncDevice("local-file" ); 1851 //mView->setSyncDevice("local-file" );
1850 if ( syncWithFile( fn, false ) ) { 1852 if ( syncWithFile( fn, false ) ) {
1851 // Event* e = mView->getLastSyncEvent(); 1853 // Event* e = mView->getLastSyncEvent();
1852// e->setReadOnly( false ); 1854// e->setReadOnly( false );
1853// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 1855// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
1854// e->setReadOnly( true ); 1856// e->setReadOnly( true );
1855 } 1857 }
1856 1858
1857} 1859}
1858 1860
1859bool MainWindow::syncWithFile( QString fn , bool quick ) 1861bool MainWindow::syncWithFile( QString fn , bool quick )
1860{ 1862{
1861 bool ret = false; 1863 bool ret = false;
1862 QFileInfo info; 1864 QFileInfo info;
1863 info.setFile( fn ); 1865 info.setFile( fn );
1864 QString mess; 1866 QString mess;
1865 bool loadbup = true; 1867 bool loadbup = true;
1866 if ( !info. exists() ) { 1868 if ( !info. exists() ) {
1867 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 1869 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
1868 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1870 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1869 mess ); 1871 mess );
1870 return ret; 1872 return ret;
1871 } 1873 }
1872 int result = 0; 1874 int result = 0;
1873 if ( !quick ) { 1875 if ( !quick ) {
1874 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1876 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1875 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1877 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1876 mess, 1878 mess,
1877 i18n("Sync"), i18n("Cancel"), 0, 1879 i18n("Sync"), i18n("Cancel"), 0,
1878 0, 1 ); 1880 0, 1 );
1879 if ( result ) 1881 if ( result )
1880 return false; 1882 return false;
1881 } 1883 }
1882 if ( KOPrefs::instance()->mAskForPreferences ) 1884 if ( KOPrefs::instance()->mAskForPreferences )
1883 mView->edit_sync_options(); 1885 mView->edit_sync_options();
1884 if ( result == 0 ) { 1886 if ( result == 0 ) {
1885 //qDebug("Now sycing ... "); 1887 //qDebug("Now sycing ... ");
1886 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) 1888 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) )
1887 setCaption( i18n("Synchronization successful") ); 1889 setCaption( i18n("Synchronization successful") );
1888 else 1890 else
1889 setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 1891 setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
1890 if ( ! quick ) 1892 if ( ! quick )
1891 KOPrefs::instance()->mLastSyncedLocalFile = fn; 1893 KOPrefs::instance()->mLastSyncedLocalFile = fn;
1892 slotModifiedChanged( true ); 1894 slotModifiedChanged( true );
1893 } 1895 }
1894 return ret; 1896 return ret;
1895} 1897}
1896void MainWindow::quickSyncLocalFile() 1898void MainWindow::quickSyncLocalFile()
1897{ 1899{
1898 //mView->setSyncDevice("local-file" ); 1900 //mView->setSyncDevice("local-file" );
1899 //qDebug("quickSyncLocalFile() "); 1901 //qDebug("quickSyncLocalFile() ");
1900 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { 1902 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) {
1901 // Event* e = mView->getLastSyncEvent(); 1903 // Event* e = mView->getLastSyncEvent();
1902// e->setReadOnly( false ); 1904// e->setReadOnly( false );
1903// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 1905// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
1904// e->setReadOnly( true ); 1906// e->setReadOnly( true );
1905 1907
1906 } 1908 }
1907} 1909}
1908 1910
1909void MainWindow::confSync() 1911void MainWindow::confSync()
1910{ 1912{
1911 mView->confSync(); 1913 mView->confSync();
1912 fillSyncMenu(); 1914 fillSyncMenu();
1913 //mView->writeSettings(); 1915 //mView->writeSettings();
1914 1916
1915 1917
1916} 1918}
1917void MainWindow::syncRemote( KSyncProfile* prof, bool ask) 1919void MainWindow::syncRemote( KSyncProfile* prof, bool ask)
1918{ 1920{
1919 QString question; 1921 QString question;
1920 if ( ask ) { 1922 if ( ask ) {
1921 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 1923 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
1922 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 1924 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
1923 question, 1925 question,
1924 i18n("Yes"), i18n("No"), 1926 i18n("Yes"), i18n("No"),
1925 0, 0 ) != 0 ) 1927 0, 0 ) != 0 )
1926 return; 1928 return;
1927 } 1929 }
1928 QString command = prof->getPreSyncCommand(); 1930 QString command = prof->getPreSyncCommand();
1929 int fi; 1931 int fi;
1930 if ( (fi = command.find("$PWD$")) > 0 ) { 1932 if ( (fi = command.find("$PWD$")) > 0 ) {
1931 QString pwd = getPassword(); 1933 QString pwd = getPassword();
1932 command = command.left( fi )+ pwd + command.mid( fi+5 ); 1934 command = command.left( fi )+ pwd + command.mid( fi+5 );
1933 1935
1934 } 1936 }
1935 int maxlen = 30; 1937 int maxlen = 30;
1936 if ( QApplication::desktop()->width() > 320 ) 1938 if ( QApplication::desktop()->width() > 320 )
1937 maxlen += 25; 1939 maxlen += 25;
1938 setCaption ( i18n( "Copy remote file to local machine..." ) ); 1940 setCaption ( i18n( "Copy remote file to local machine..." ) );
1939 int fileSize = 0; 1941 int fileSize = 0;
1940 int result = system ( command ); 1942 int result = system ( command );
1941 // 0 : okay 1943 // 0 : okay
1942 // 256: no such file or dir 1944 // 256: no such file or dir
1943 // 1945 //
1944 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 1946 qDebug("KO: Remote copy result(0 = okay): %d ",result );
1945 if ( result != 0 ) { 1947 if ( result != 0 ) {
1946 int len = maxlen; 1948 int len = maxlen;
1947 while ( len < command.length() ) { 1949 while ( len < command.length() ) {
1948 command.insert( len , "\n" ); 1950 command.insert( len , "\n" );
1949 len += maxlen +2; 1951 len += maxlen +2;
1950 } 1952 }
1951 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; 1953 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
1952 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 1954 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
1953 question, 1955 question,
1954 i18n("Okay!")) ; 1956 i18n("Okay!")) ;
1955 setCaption ("KO/Pi"); 1957 setCaption ("KO/Pi");
1956 return; 1958 return;
1957 } 1959 }
1958 setCaption ( i18n( "Copying succeed." ) ); 1960 setCaption ( i18n( "Copying succeed." ) );
1959 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 1961 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
1960 if ( syncWithFile( prof->getLocalTempFile(), true ) ) { 1962 if ( syncWithFile( prof->getLocalTempFile(), true ) ) {
1961// Event* e = mView->getLastSyncEvent(); 1963// Event* e = mView->getLastSyncEvent();
1962// e->setReadOnly( false ); 1964// e->setReadOnly( false );
1963// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1965// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1964// e->setReadOnly( true ); 1966// e->setReadOnly( true );
1965 if ( KOPrefs::instance()->mWriteBackFile ) { 1967 if ( KOPrefs::instance()->mWriteBackFile ) {
1966 command = prof->getPostSyncCommand(); 1968 command = prof->getPostSyncCommand();
1967 setCaption ( i18n( "Writing back file ..." ) ); 1969 setCaption ( i18n( "Writing back file ..." ) );
1968 result = system ( command ); 1970 result = system ( command );
1969 qDebug("KO: Writing back file result: %d ", result); 1971 qDebug("KO: Writing back file result: %d ", result);
1970 if ( result != 0 ) { 1972 if ( result != 0 ) {
1971 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 1973 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
1972 return; 1974 return;
1973 } else { 1975 } else {
1974 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 1976 setCaption ( i18n( "Syncronization sucessfully completed" ) );
1975 } 1977 }
1976 } 1978 }
1977 } 1979 }
1978 return; 1980 return;
1979} 1981}
1980void MainWindow::syncSSH() 1982void MainWindow::syncSSH()
1981{ 1983{
1982 // not used anymore 1984 // not used anymore
1983 QTime timer; 1985 QTime timer;
1984 timer.start(); 1986 timer.start();
1985 //qDebug("MainWindow::syncssh() "); 1987 //qDebug("MainWindow::syncssh() ");
1986 KOPrefs *p = KOPrefs::instance(); 1988 KOPrefs *p = KOPrefs::instance();
1987 QString localFile = p->mLocalTempFile; 1989 QString localFile = p->mLocalTempFile;
1988 QString remoteIP = p->mRemoteIP; 1990 QString remoteIP = p->mRemoteIP;
1989 QString remoteUser = p->mRemoteUser; 1991 QString remoteUser = p->mRemoteUser;
1990 QString remoteFile = p->mRemoteFile; 1992 QString remoteFile = p->mRemoteFile;
1991 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 ) 1993 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 )
1992 remoteUser += ":" + p->mRemotePassWd; 1994 remoteUser += ":" + p->mRemotePassWd;
1993 1995
1994 QString question = i18n("Do you really want\nto remote sync?\n \n") + 1996 QString question = i18n("Do you really want\nto remote sync?\n \n") +
1995 i18n("IP: " ) +remoteIP +"\n" + 1997 i18n("IP: " ) +remoteIP +"\n" +
1996 i18n("User: " ) + remoteUser +"\n" ; 1998 i18n("User: " ) + remoteUser +"\n" ;
1997 int maxlen = 30; 1999 int maxlen = 30;
1998 if ( QApplication::desktop()->width() > 320 ) 2000 if ( QApplication::desktop()->width() > 320 )
1999 maxlen += 25; 2001 maxlen += 25;
2000 if ( remoteFile.length() > maxlen ) 2002 if ( remoteFile.length() > maxlen )
2001 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n"; 2003 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n";
2002 else 2004 else
2003 question += i18n("Remote file:\n " ) + remoteFile +"\n"; 2005 question += i18n("Remote file:\n " ) + remoteFile +"\n";
2004 if ( localFile.length() > maxlen ) 2006 if ( localFile.length() > maxlen )
2005 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n"; 2007 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n";
2006 else 2008 else
2007 question += i18n("Local temp file:\n " ) + localFile +"\n"; 2009 question += i18n("Local temp file:\n " ) + localFile +"\n";
2008 2010
2009 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 2011 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2010 question, 2012 question,
2011 i18n("Yes"), i18n("No"), 2013 i18n("Yes"), i18n("No"),
2012 0, 0 ) != 0 ) 2014 0, 0 ) != 0 )
2013 return; 2015 return;
2014 // if ( !p->mUsePassWd ) { 2016 // if ( !p->mUsePassWd ) {
2015 // QString pass = getPassword(); 2017 // QString pass = getPassword();
2016 // if ( pass.length() > 0 ) 2018 // if ( pass.length() > 0 )
2017 // remoteUser += ":" + pass; 2019 // remoteUser += ":" + pass;
2018 // } 2020 // }
2019 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile; 2021 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile;
2020 setCaption ( i18n( "Copy remote file to local machine..." ) ); 2022 setCaption ( i18n( "Copy remote file to local machine..." ) );
2021 int fileSize = 0; 2023 int fileSize = 0;
2022 int result = system ( command ); 2024 int result = system ( command );
2023 // 0 : okay 2025 // 0 : okay
2024 // 256: no such file or dir 2026 // 256: no such file or dir
2025 // 2027 //
2026 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 2028 qDebug("KO: Remote copy result(0 = okay): %d ",result );
2027 if ( result != 0 ) { 2029 if ( result != 0 ) {
2028 int len = maxlen; 2030 int len = maxlen;
2029 while ( len < command.length() ) { 2031 while ( len < command.length() ) {
2030 command.insert( len , "\n" ); 2032 command.insert( len , "\n" );
2031 len += maxlen +2; 2033 len += maxlen +2;
2032 } 2034 }
2033 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; 2035 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
2034 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2036 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2035 question, 2037 question,
2036 i18n("Okay!")) ; 2038 i18n("Okay!")) ;
2037 setCaption ("KO/Pi"); 2039 setCaption ("KO/Pi");
2038 return; 2040 return;
2039 } 2041 }
2040 2042
2041 2043
2042 setCaption ( i18n( "Copying succeed." ) ); 2044 setCaption ( i18n( "Copying succeed." ) );
2043 //mView->setSyncDevice("ssh-scp" ); 2045 //mView->setSyncDevice("ssh-scp" );
2044 if ( syncWithFile(localFile , true ) ) { 2046 if ( syncWithFile(localFile , true ) ) {
2045// Event* e = mView->getLastSyncEvent(); 2047// Event* e = mView->getLastSyncEvent();
2046// e->setReadOnly( false ); 2048// e->setReadOnly( false );
2047// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2049// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2048// e->setReadOnly( true ); 2050// e->setReadOnly( true );
2049 if ( KOPrefs::instance()->mWriteBackFile ) { 2051 if ( KOPrefs::instance()->mWriteBackFile ) {
2050 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ; 2052 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ;
2051 setCaption ( i18n( "Writing back file ..." ) ); 2053 setCaption ( i18n( "Writing back file ..." ) );
2052 result = system ( command ); 2054 result = system ( command );
2053 if ( result != 0 ) { 2055 if ( result != 0 ) {
2054 int len = maxlen; 2056 int len = maxlen;
2055 while ( len < command.length() ) { 2057 while ( len < command.length() ) {
2056 command.insert( len , "\n" ); 2058 command.insert( len , "\n" );
2057 len += maxlen +2; 2059 len += maxlen +2;
2058 } 2060 }
2059 question = i18n("Sorry, the copy back command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; 2061 question = i18n("Sorry, the copy back command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
2060 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2062 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2061 question, 2063 question,
2062 i18n("Okay!")) ; 2064 i18n("Okay!")) ;
2063 setCaption ("KO/Pi"); 2065 setCaption ("KO/Pi");
2064 return; 2066 return;
2065 } else { 2067 } else {
2066 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 2068 setCaption ( i18n( "Syncronization sucessfully completed" ) );
2067 } 2069 }
2068 } 2070 }
2069 } 2071 }
2070 return; 2072 return;
2071#if 0 2073#if 0
2072 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics"); 2074 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics");
2073 while ( timer.elapsed() < 5000 ) 2075 while ( timer.elapsed() < 5000 )
2074 qApp->processEvents(); 2076 qApp->processEvents();
2075 2077
2076 qDebug("MainWindow::merging) "); 2078 qDebug("MainWindow::merging) ");
2077 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 ); 2079 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 );
2078 while ( mBlockSaveFlag ) 2080 while ( mBlockSaveFlag )
2079 qApp->processEvents(); 2081 qApp->processEvents();
2080 save(); 2082 save();
2081 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics"); 2083 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics");
2082#endif 2084#endif
2083 2085
2084} 2086}
2085 2087
2086 2088
2087void MainWindow::syncSharp() 2089void MainWindow::syncSharp()
2088{ 2090{
2089 if ( mCalendarModifiedFlag ) 2091 if ( mCalendarModifiedFlag )
2090 save(); 2092 save();
2091 mView->syncSharp(); 2093 mView->syncSharp();
2092 slotModifiedChanged( true ); 2094 slotModifiedChanged( true );
2093 2095
2094} 2096}
2095void MainWindow::syncPhone() 2097void MainWindow::syncPhone()
2096{ 2098{
2097 if ( mCalendarModifiedFlag ) 2099 if ( mCalendarModifiedFlag )
2098 save(); 2100 save();
2099 mView->syncPhone(); 2101 mView->syncPhone();
2100 slotModifiedChanged( true ); 2102 slotModifiedChanged( true );
2101 2103
2102} 2104}
2103 2105
2104void MainWindow::printSel( ) 2106void MainWindow::printSel( )
2105{ 2107{
2106 mView->viewManager()->agendaView()->agenda()->printSelection(); 2108 mView->viewManager()->agendaView()->agenda()->printSelection();
2107} 2109}
2108 2110
2109void MainWindow::printCal() 2111void MainWindow::printCal()
2110{ 2112{
2111 mView->print();//mCp->showDialog(); 2113 mView->print();//mCp->showDialog();
2112} 2114}
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
index bd83626..6100097 100644
--- a/libkdepim/externalapphandler.cpp
+++ b/libkdepim/externalapphandler.cpp
@@ -1,1016 +1,1014 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2002 Cornelius Schumacher <schumacher@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/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30#include <stdlib.h> 30#include <stdlib.h>
31 31
32#include <qfile.h> 32#include <qfile.h>
33#include <qmap.h> 33#include <qmap.h>
34#include <qregexp.h> 34#include <qregexp.h>
35 35
36#ifndef DESKTOP_VERSION 36#ifndef DESKTOP_VERSION
37#include <qpe/qpeapplication.h> 37#include <qpe/qpeapplication.h>
38#include <qtopia/qcopenvelope_qws.h> 38#include <qtopia/qcopenvelope_qws.h>
39#else 39#else
40#include <qapplication.h> 40#include <qapplication.h>
41#endif 41#endif
42 42
43#include <kstaticdeleter.h> 43#include <kstaticdeleter.h>
44#include <kmessagebox.h> 44#include <kmessagebox.h>
45 45
46 46
47#include "externalapphandler.h" 47#include "externalapphandler.h"
48 48
49#include "kpimglobalprefs.h" 49#include "kpimglobalprefs.h"
50 50
51/********************************************************************************* 51/*********************************************************************************
52 * 52 *
53 ********************************************************************************/ 53 ********************************************************************************/
54 54
55 55
56QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 56QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
57 : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage) 57 : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage)
58{ 58{
59 //sourceMessage passes later three parameters: sourceChannel, uid, param1 59 //sourceMessage passes later three parameters: sourceChannel, uid, param1
60 if (_usedSourceParameters == 0) 60 if (_usedSourceParameters == 0)
61 _sourceMessageParameters = "(QString,QString)"; 61 _sourceMessageParameters = "(QString,QString)";
62 else if (_usedSourceParameters == 1) 62 else if (_usedSourceParameters == 1)
63 _sourceMessageParameters = "(QString,QString,QString)"; 63 _sourceMessageParameters = "(QString,QString,QString)";
64 else if (_usedSourceParameters == 2) 64 else if (_usedSourceParameters == 2)
65 _sourceMessageParameters = "(QString,QString,QString,QString)"; 65 _sourceMessageParameters = "(QString,QString,QString,QString)";
66 else if (_usedSourceParameters == 3) 66 else if (_usedSourceParameters == 3)
67 _sourceMessageParameters = "(QString,QString,QString,QString,QString)"; 67 _sourceMessageParameters = "(QString,QString,QString,QString,QString)";
68} 68}
69 69
70/*********************************************************************************/ 70/*********************************************************************************/
71 71
72QCopTransferItem::QCopTransferItem() 72QCopTransferItem::QCopTransferItem()
73{ 73{
74} 74}
75 75
76/*********************************************************************************/ 76/*********************************************************************************/
77bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3) 77bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3)
78{ 78{
79 79
80#ifndef DESKTOP_VERSION 80#ifndef DESKTOP_VERSION
81 //sourceMessage passes two parameters: sourceChannel, uid 81 //sourceMessage passes two parameters: sourceChannel, uid
82 QString sourceMessage = _sourceMessage + _sourceMessageParameters; 82 QString sourceMessage = _sourceMessage + _sourceMessageParameters;
83 83
84 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1()); 84 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1());
85 qDebug("passing sourcechannel(%s), uid(%s), param1(%s), param2(%s), param3(%s) as parameter to QCopEnvelope", _sourceChannel.latin1(), uid.latin1(), param1.latin1(), param2.latin1(), param3.latin1()); 85 qDebug("passing sourcechannel(%s), uid(%s), param1(%s), param2(%s), param3(%s) as parameter to QCopEnvelope", _sourceChannel.latin1(), uid.latin1(), param1.latin1(), param2.latin1(), param3.latin1());
86 86
87 QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1()); 87 QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1());
88 88
89 e << _sourceChannel << uid; 89 e << _sourceChannel << uid;
90 90
91 if (_usedSourceParameters == 1) 91 if (_usedSourceParameters == 1)
92 e << param1; 92 e << param1;
93 else if (_usedSourceParameters == 2) 93 else if (_usedSourceParameters == 2)
94 e << param1 << param2; 94 e << param1 << param2;
95 else if (_usedSourceParameters == 3) 95 else if (_usedSourceParameters == 3)
96 e << param1 << param2 << param3; 96 e << param1 << param2 << param3;
97 97
98 qApp->processEvents(); 98 qApp->processEvents();
99 99
100 return true; 100 return true;
101 101
102#else 102#else
103 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 103 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
104 return false; 104 return false;
105#endif 105#endif
106 106
107} 107}
108 108
109 109
110/*********************************************************************************/ 110/*********************************************************************************/
111void QCopTransferItem::setSourceChannel(const QString& sourceChannel) 111void QCopTransferItem::setSourceChannel(const QString& sourceChannel)
112{ 112{
113 113
114 if (_sourceChannel.isEmpty()) 114 if (_sourceChannel.isEmpty())
115 _sourceChannel = sourceChannel; 115 _sourceChannel = sourceChannel;
116} 116}
117 117
118 118
119/*********************************************************************************/ 119/*********************************************************************************/
120bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 120bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data )
121{ 121{
122 122
123 // copied from old mail2 123 // copied from old mail2
124/* 124/*
125 static int ii = 0; 125 static int ii = 0;
126 126
127 // block second call 127 // block second call
128 if ( ii < 2 ) { 128 if ( ii < 2 ) {
129 ++ii; 129 ++ii;
130 if ( ii > 1 ) { 130 if ( ii > 1 ) {
131 qDebug("qcop call blocked "); 131 qDebug("qcop call blocked ");
132 return true; 132 return true;
133 } 133 }
134 } 134 }
135*/ 135*/
136 136
137// qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() ); 137// qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() );
138 138
139 //we are in the target and get a request from the source 139 //we are in the target and get a request from the source
140 if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data()) 140 if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data())
141 { 141 {
142 142
143 QDataStream stream( data, IO_ReadOnly ); 143 QDataStream stream( data, IO_ReadOnly );
144 144
145 145
146 QString sourceChannel; 146 QString sourceChannel;
147 QString uid; 147 QString uid;
148 QString param1; 148 QString param1;
149 QString param2; 149 QString param2;
150 QString param3; 150 QString param3;
151 151
152 stream >> sourceChannel >> uid; 152 stream >> sourceChannel >> uid;
153 153
154 if (_usedSourceParameters == 0) 154 if (_usedSourceParameters == 0)
155 { 155 {
156 emit receivedMessageFromSource(sourceChannel, uid); 156 emit receivedMessageFromSource(sourceChannel, uid);
157 } 157 }
158 else if (_usedSourceParameters == 1) 158 else if (_usedSourceParameters == 1)
159 { 159 {
160 stream >> param1; 160 stream >> param1;
161 emit receivedMessageFromSource(sourceChannel, uid, param1); 161 emit receivedMessageFromSource(sourceChannel, uid, param1);
162 } 162 }
163 else if (_usedSourceParameters == 2) 163 else if (_usedSourceParameters == 2)
164 { 164 {
165 stream >> param1 >> param2; 165 stream >> param1 >> param2;
166 emit receivedMessageFromSource(sourceChannel, uid, param1, param2); 166 emit receivedMessageFromSource(sourceChannel, uid, param1, param2);
167 } 167 }
168 else if (_usedSourceParameters == 3) 168 else if (_usedSourceParameters == 3)
169 { 169 {
170 stream >> param1 >> param2 >> param3; 170 stream >> param1 >> param2 >> param3;
171 emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3); 171 emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3);
172 } 172 }
173 173
174 return true; 174 return true;
175 } 175 }
176 176
177 return false; 177 return false;
178} 178}
179 179
180 180
181/********************************************************************************* 181/*********************************************************************************
182 * 182 *
183 ********************************************************************************/ 183 ********************************************************************************/
184 184
185 185
186QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 186QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
187 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) 187 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage)
188{ 188{
189 //targetMessage returns later two parameters: uid, and map<qstring,qstring> 189 //targetMessage returns later two parameters: uid, and map<qstring,qstring>
190 _targetMessageParameters = "(QString,QMAP<QString,QString>)"; 190 _targetMessageParameters = "(QString,QMAP<QString,QString>)";
191} 191}
192 192
193/*********************************************************************************/ 193/*********************************************************************************/
194bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap) 194bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap)
195{ 195{
196#ifndef DESKTOP_VERSION 196#ifndef DESKTOP_VERSION
197 //targetMessage passes two parameters: uid, map 197 //targetMessage passes two parameters: uid, map
198 QString targetMessage = _targetMessage + _targetMessageParameters; 198 QString targetMessage = _targetMessage + _targetMessageParameters;
199 199
200 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); 200 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1());
201 qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1()); 201 qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1());
202 202
203 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); 203 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1());
204 //US we need no names in the To field. The emailadresses are enough 204 //US we need no names in the To field. The emailadresses are enough
205 205
206 e << uid << nameEmailMap; 206 e << uid << nameEmailMap;
207 207
208 qApp->processEvents(); 208 qApp->processEvents();
209 209
210 return true; 210 return true;
211 211
212#else 212#else
213 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 213 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
214 return false; 214 return false;
215#endif 215#endif
216 216
217} 217}
218 218
219 219
220/*********************************************************************************/ 220/*********************************************************************************/
221bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 221bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data )
222{ 222{
223 bool res = QCopTransferItem::appMessage( cmsg, data ); 223 bool res = QCopTransferItem::appMessage( cmsg, data );
224 224
225 if (res == false) 225 if (res == false)
226 { 226 {
227 QDataStream stream( data, IO_ReadOnly ); 227 QDataStream stream( data, IO_ReadOnly );
228 228
229// qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() ); 229// qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() );
230 230
231 //we are in the source and get an answer from the target 231 //we are in the source and get an answer from the target
232 if ((_targetMessage + _targetMessageParameters) == cmsg.data()) 232 if ((_targetMessage + _targetMessageParameters) == cmsg.data())
233 { 233 {
234 QMap<QString,QString> adrMap; 234 QMap<QString,QString> adrMap;
235 QString uid; 235 QString uid;
236 236
237 stream >> uid >> adrMap; 237 stream >> uid >> adrMap;
238 238
239 emit receivedMessageFromTarget(uid, adrMap); 239 emit receivedMessageFromTarget(uid, adrMap);
240 240
241 241
242 return true; 242 return true;
243 } 243 }
244 } 244 }
245 245
246 return false; 246 return false;
247} 247}
248 248
249 249
250/********************************************************************************* 250/*********************************************************************************
251 * 251 *
252 ********************************************************************************/ 252 ********************************************************************************/
253 253
254 254
255QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 255QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
256 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) 256 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage)
257{ 257{
258 //targetMessage returns later two parameters: uid, and three lists 258 //targetMessage returns later two parameters: uid, and three lists
259 _targetMessageParameters = "(QString,QStringList,QStringList,QStringList)"; 259 _targetMessageParameters = "(QString,QStringList,QStringList,QStringList)";
260} 260}
261 261
262/*********************************************************************************/ 262/*********************************************************************************/
263bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3) 263bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
264{ 264{
265#ifndef DESKTOP_VERSION 265#ifndef DESKTOP_VERSION
266 //targetMessage passes two parameters: uid, map 266 //targetMessage passes two parameters: uid, map
267 QString targetMessage = _targetMessage + _targetMessageParameters; 267 QString targetMessage = _targetMessage + _targetMessageParameters;
268 268
269 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); 269 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1());
270 qDebug("passing uid(%s) and list1, list2, list3 as parameter to QCopEnvelope", uid.latin1()); 270 qDebug("passing uid(%s) and list1, list2, list3 as parameter to QCopEnvelope", uid.latin1());
271 271
272 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); 272 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1());
273 //US we need no names in the To field. The emailadresses are enough 273 //US we need no names in the To field. The emailadresses are enough
274 274
275 e << uid << list1 << list2 << list3; 275 e << uid << list1 << list2 << list3;
276 276
277 qApp->processEvents(); 277 qApp->processEvents();
278 278
279 return true; 279 return true;
280 280
281#else 281#else
282 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 282 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
283 return false; 283 return false;
284#endif 284#endif
285 285
286} 286}
287 287
288 288
289/*********************************************************************************/ 289/*********************************************************************************/
290bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 290bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data )
291{ 291{
292 bool res = QCopTransferItem::appMessage( cmsg, data ); 292 bool res = QCopTransferItem::appMessage( cmsg, data );
293 293
294 if (res == false) 294 if (res == false)
295 { 295 {
296 QDataStream stream( data, IO_ReadOnly ); 296 QDataStream stream( data, IO_ReadOnly );
297 297
298// qDebug("QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 298// qDebug("QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
299 299
300 //we are in the source and get an answer from the target 300 //we are in the source and get an answer from the target
301 if ((_targetMessage + _targetMessageParameters) == cmsg.data()) 301 if ((_targetMessage + _targetMessageParameters) == cmsg.data())
302 { 302 {
303 QStringList list1; 303 QStringList list1;
304 QStringList list2; 304 QStringList list2;
305 QStringList list3; 305 QStringList list3;
306 QString uid; 306 QString uid;
307 307
308 stream >> uid >> list1 >> list2 >> list3; 308 stream >> uid >> list1 >> list2 >> list3;
309
310 emit receivedMessageFromTarget(uid, list1, list2, list3); 309 emit receivedMessageFromTarget(uid, list1, list2, list3);
311 310
312 311
313 return true; 312 return true;
314 } 313 }
315 } 314 }
316 315
317 return false; 316 return false;
318} 317}
319 318
320 319
321 320
322/********************************************************************************* 321/*********************************************************************************
323 * 322 *
324 ********************************************************************************/ 323 ********************************************************************************/
325 324
326 325
327ExternalAppHandler *ExternalAppHandler::sInstance = 0; 326ExternalAppHandler *ExternalAppHandler::sInstance = 0;
328static KStaticDeleter<ExternalAppHandler> staticDeleter; 327static KStaticDeleter<ExternalAppHandler> staticDeleter;
329 328
330ExternalAppHandler::ExternalAppHandler() 329ExternalAppHandler::ExternalAppHandler()
331{ 330{
332 mDefaultItems.setAutoDelete(true); 331 mDefaultItems.setAutoDelete(true);
333 332
334 mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); 333 mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList");
335 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&))); 334 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&)));
336 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); 335 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)));
337 336
338//US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); 337//US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList");
339//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&))); 338//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&)));
340//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); 339//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)));
341 340
342 mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", ""); 341 mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", "");
343 connect(mDisplayDetails, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&, const QString&, const QString&)), this, SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 342 connect(mDisplayDetails, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&, const QString&, const QString&)), this, SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
344} 343}
345 344
346ExternalAppHandler::~ExternalAppHandler() 345ExternalAppHandler::~ExternalAppHandler()
347{ 346{
348} 347}
349 348
350void ExternalAppHandler::loadConfig() 349void ExternalAppHandler::loadConfig()
351{ 350{
352 351
353 mDefaultItems.clear(); 352 mDefaultItems.clear();
354 353
355 mEmailAppAvailable = UNDEFINED; 354 mEmailAppAvailable = UNDEFINED;
356 mPhoneAppAvailable = UNDEFINED; 355 mPhoneAppAvailable = UNDEFINED;
357 mFaxAppAvailable = UNDEFINED; 356 mFaxAppAvailable = UNDEFINED;
358 mSMSAppAvailable = UNDEFINED; 357 mSMSAppAvailable = UNDEFINED;
359 mPagerAppAvailable = UNDEFINED; 358 mPagerAppAvailable = UNDEFINED;
360 359
361 360
362 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); 361 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") );
363 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); 362 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") );
364 363
365 if (opiepath.isEmpty()) 364 if (opiepath.isEmpty())
366 opiepath = qtopiapath; 365 opiepath = qtopiapath;
367 366
368 //mailclients 367 //mailclients
369 QString mailmsg1 = "writeMail(QString,QString)"; 368 QString mailmsg1 = "writeMail(QString,QString)";
370 QString mailmsg2 = "writeMail(QMap(QString,QString))"; 369 QString mailmsg2 = "writeMail(QMap(QString,QString))";
371 370
372 QString undefined = ""; 371 QString undefined = "";
373 372
374 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); 373 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined);
375 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); 374 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined);
376 375
377 if (( QFile::exists( qtopiapath + "/bin/ompi" )) || 376 if (( QFile::exists( qtopiapath + "/bin/ompi" )) ||
378 ( QFile::exists( opiepath + "/bin/ompi" ))) 377 ( QFile::exists( opiepath + "/bin/ompi" )))
379 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 378 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
380 379
381 if ( QFile::exists( qtopiapath + "/bin/qtmail" )) 380 if ( QFile::exists( qtopiapath + "/bin/qtmail" ))
382 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 381 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
383 382
384 if ( QFile::exists( opiepath + "/bin/opiemail" )) 383 if ( QFile::exists( opiepath + "/bin/opiemail" ))
385 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 384 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
386 385
387 386
388 387
389 //phoneclients 388 //phoneclients
390 389
391 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); 390 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined);
392 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); 391 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined);
393 if (( QFile::exists( qtopiapath + "/bin/kppi" )) || 392 if (( QFile::exists( qtopiapath + "/bin/kppi" )) ||
394 ( QFile::exists( opiepath + "/bin/kppi" ))) 393 ( QFile::exists( opiepath + "/bin/kppi" )))
395 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); 394 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined);
396 395
397 //faxclients 396 //faxclients
398 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); 397 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined);
399 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); 398 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined);
400 399
401 //smsclients 400 //smsclients
402 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); 401 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined);
403 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); 402 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined);
404 403
405 //pagerclients 404 //pagerclients
406 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); 405 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined);
407 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); 406 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined);
408 407
409} 408}
410 409
411ExternalAppHandler *ExternalAppHandler::instance() 410ExternalAppHandler *ExternalAppHandler::instance()
412{ 411{
413 if ( !sInstance ) { 412 if ( !sInstance ) {
414 sInstance = staticDeleter.setObject( new ExternalAppHandler() ); 413 sInstance = staticDeleter.setObject( new ExternalAppHandler() );
415 sInstance->loadConfig(); 414 sInstance->loadConfig();
416 } 415 }
417 416
418 return sInstance; 417 return sInstance;
419} 418}
420 419
421void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2) 420void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2)
422{ 421{
423 DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); 422 DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2);
424 423
425 mDefaultItems.append(dai); 424 mDefaultItems.append(dai);
426} 425}
427 426
428 427
429QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) 428QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type)
430{ 429{
431 QList<DefaultAppItem> list; 430 QList<DefaultAppItem> list;
432 431
433 DefaultAppItem* dai; 432 DefaultAppItem* dai;
434 433
435 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 434 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
436 { 435 {
437 if (dai->_type == type) 436 if (dai->_type == type)
438 list.append(dai); 437 list.append(dai);
439 } 438 }
440 439
441 return list; 440 return list;
442} 441}
443 442
444DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) 443DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid)
445{ 444{
446 DefaultAppItem* dai; 445 DefaultAppItem* dai;
447 446
448 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 447 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
449 { 448 {
450 if (dai->_type == type && dai->_id == clientid) 449 if (dai->_type == type && dai->_id == clientid)
451 return dai; 450 return dai;
452 } 451 }
453 452
454 return 0; 453 return 0;
455} 454}
456 455
457bool ExternalAppHandler::isEmailAppAvailable() 456bool ExternalAppHandler::isEmailAppAvailable()
458{ 457{
459#ifndef DESKTOP_VERSION 458#ifndef DESKTOP_VERSION
460 if (mEmailAppAvailable == UNDEFINED) 459 if (mEmailAppAvailable == UNDEFINED)
461 { 460 {
462 int client = KPimGlobalPrefs::instance()->mEmailClient; 461 int client = KPimGlobalPrefs::instance()->mEmailClient;
463 if (client == KPimGlobalPrefs::NONE_EMC) 462 if (client == KPimGlobalPrefs::NONE_EMC)
464 mEmailAppAvailable = UNAVAILABLE; 463 mEmailAppAvailable = UNAVAILABLE;
465 else 464 else
466 mEmailAppAvailable = AVAILABLE; 465 mEmailAppAvailable = AVAILABLE;
467 } 466 }
468 return (mEmailAppAvailable == AVAILABLE); 467 return (mEmailAppAvailable == AVAILABLE);
469 468
470#else //DESKTOP_VERSION 469#else //DESKTOP_VERSION
471 return false; 470 return false;
472#endif //DESKTOP_VERSION 471#endif //DESKTOP_VERSION
473} 472}
474 473
475bool ExternalAppHandler::isSMSAppAvailable() 474bool ExternalAppHandler::isSMSAppAvailable()
476{ 475{
477#ifndef DESKTOP_VERSION 476#ifndef DESKTOP_VERSION
478 if (mSMSAppAvailable == UNDEFINED) 477 if (mSMSAppAvailable == UNDEFINED)
479 { 478 {
480 int client = KPimGlobalPrefs::instance()->mSMSClient; 479 int client = KPimGlobalPrefs::instance()->mSMSClient;
481 if (client == KPimGlobalPrefs::NONE_SMC) 480 if (client == KPimGlobalPrefs::NONE_SMC)
482 mSMSAppAvailable = UNAVAILABLE; 481 mSMSAppAvailable = UNAVAILABLE;
483 else 482 else
484 mSMSAppAvailable = AVAILABLE; 483 mSMSAppAvailable = AVAILABLE;
485 } 484 }
486 485
487 return (mSMSAppAvailable == AVAILABLE); 486 return (mSMSAppAvailable == AVAILABLE);
488#else //DESKTOP_VERSION 487#else //DESKTOP_VERSION
489 return false; 488 return false;
490#endif //DESKTOP_VERSION 489#endif //DESKTOP_VERSION
491} 490}
492 491
493bool ExternalAppHandler::isPhoneAppAvailable() 492bool ExternalAppHandler::isPhoneAppAvailable()
494{ 493{
495#ifndef DESKTOP_VERSION 494#ifndef DESKTOP_VERSION
496 if (mPhoneAppAvailable == UNDEFINED) 495 if (mPhoneAppAvailable == UNDEFINED)
497 { 496 {
498 int client = KPimGlobalPrefs::instance()->mPhoneClient; 497 int client = KPimGlobalPrefs::instance()->mPhoneClient;
499 if (client == KPimGlobalPrefs::NONE_PHC) 498 if (client == KPimGlobalPrefs::NONE_PHC)
500 mPhoneAppAvailable = UNAVAILABLE; 499 mPhoneAppAvailable = UNAVAILABLE;
501 else 500 else
502 mPhoneAppAvailable = AVAILABLE; 501 mPhoneAppAvailable = AVAILABLE;
503 } 502 }
504 503
505 return (mPhoneAppAvailable == AVAILABLE); 504 return (mPhoneAppAvailable == AVAILABLE);
506#else //DESKTOP_VERSION 505#else //DESKTOP_VERSION
507 return false; 506 return false;
508#endif //DESKTOP_VERSION 507#endif //DESKTOP_VERSION
509} 508}
510 509
511bool ExternalAppHandler::isFaxAppAvailable() 510bool ExternalAppHandler::isFaxAppAvailable()
512{ 511{
513#ifndef DESKTOP_VERSION 512#ifndef DESKTOP_VERSION
514 if (mFaxAppAvailable == UNDEFINED) 513 if (mFaxAppAvailable == UNDEFINED)
515 { 514 {
516 int client = KPimGlobalPrefs::instance()->mFaxClient; 515 int client = KPimGlobalPrefs::instance()->mFaxClient;
517 if (client == KPimGlobalPrefs::NONE_FAC) 516 if (client == KPimGlobalPrefs::NONE_FAC)
518 mFaxAppAvailable = UNAVAILABLE; 517 mFaxAppAvailable = UNAVAILABLE;
519 else 518 else
520 mFaxAppAvailable = AVAILABLE; 519 mFaxAppAvailable = AVAILABLE;
521 } 520 }
522 521
523 return (mFaxAppAvailable == AVAILABLE); 522 return (mFaxAppAvailable == AVAILABLE);
524#else //DESKTOP_VERSION 523#else //DESKTOP_VERSION
525 return false; 524 return false;
526#endif //DESKTOP_VERSION 525#endif //DESKTOP_VERSION
527} 526}
528 527
529bool ExternalAppHandler::isPagerAppAvailable() 528bool ExternalAppHandler::isPagerAppAvailable()
530{ 529{
531#ifndef DESKTOP_VERSION 530#ifndef DESKTOP_VERSION
532 if (mPagerAppAvailable == UNDEFINED) 531 if (mPagerAppAvailable == UNDEFINED)
533 { 532 {
534 int client = KPimGlobalPrefs::instance()->mPagerClient; 533 int client = KPimGlobalPrefs::instance()->mPagerClient;
535 if (client == KPimGlobalPrefs::NONE_PAC) 534 if (client == KPimGlobalPrefs::NONE_PAC)
536 mPagerAppAvailable = UNAVAILABLE; 535 mPagerAppAvailable = UNAVAILABLE;
537 else 536 else
538 mPagerAppAvailable = AVAILABLE; 537 mPagerAppAvailable = AVAILABLE;
539 } 538 }
540 539
541 return (mPagerAppAvailable == AVAILABLE); 540 return (mPagerAppAvailable == AVAILABLE);
542#else //DESKTOP_VERSION 541#else //DESKTOP_VERSION
543 return false; 542 return false;
544#endif //DESKTOP_VERSION 543#endif //DESKTOP_VERSION
545} 544}
546 545
547/************************************************************************** 546/**************************************************************************
548 * 547 *
549 **************************************************************************/ 548 **************************************************************************/
550 549
551 550
552//calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) 551//calls the emailapplication with a number of attachments that need to be send (Seperated by Comma)
553bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) 552bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls )
554{ 553{
555 554
556#ifndef DESKTOP_VERSION 555#ifndef DESKTOP_VERSION
557 QString channel; 556 QString channel;
558 QString message2; 557 QString message2;
559 QString parameters2; 558 QString parameters2;
560 559
561 560
562 int client = KPimGlobalPrefs::instance()->mEmailClient; 561 int client = KPimGlobalPrefs::instance()->mEmailClient;
563 if (client == KPimGlobalPrefs::OTHER_EMC) 562 if (client == KPimGlobalPrefs::OTHER_EMC)
564 { 563 {
565 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 564 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
566 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; 565 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage;
567 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 566 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
568 } 567 }
569 else 568 else
570 { 569 {
571 DefaultAppItem* dai = getDefaultItem(EMAIL, client); 570 DefaultAppItem* dai = getDefaultItem(EMAIL, client);
572 if (!dai) 571 if (!dai)
573 { 572 {
574 qDebug("could not find configured email application."); 573 qDebug("could not find configured email application.");
575 return false; 574 return false;
576 } 575 }
577 channel = dai->_channel; 576 channel = dai->_channel;
578 message2 = dai->_message2; 577 message2 = dai->_message2;
579 parameters2 = dai->_parameters2; 578 parameters2 = dai->_parameters2;
580 } 579 }
581 580
582 //first check if one of the mailers need the emails right in the message. 581 //first check if one of the mailers need the emails right in the message.
583 message2 = translateMessage(message2, emails, urls); 582 message2 = translateMessage(message2, emails, urls);
584 583
585 584
586 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); 585 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1());
587 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); 586 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1());
588 587
589 588
590 QCopEnvelope e(channel.latin1(), message2.latin1()); 589 QCopEnvelope e(channel.latin1(), message2.latin1());
591 //US we need no names in the To field. The emailadresses are enough 590 //US we need no names in the To field. The emailadresses are enough
592 591
593 passParameters(&e, parameters2, emails, urls); 592 passParameters(&e, parameters2, emails, urls);
594 593
595 594
596 595
597#else 596#else
598 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); 597 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) );
599#endif 598#endif
600 599
601 return true; 600 return true;
602} 601}
603 602
604/************************************************************************** 603/**************************************************************************
605 * 604 *
606 **************************************************************************/ 605 **************************************************************************/
607 606
608 607
609//calls the emailapplication and creates a mail with parameter emails as recipients 608//calls the emailapplication and creates a mail with parameter emails as recipients
610bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) 609bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress )
611{ 610{
612#ifndef DESKTOP_VERSION 611#ifndef DESKTOP_VERSION
613 QString channel; 612 QString channel;
614 QString message; 613 QString message;
615 QString parameters; 614 QString parameters;
616 615
617 616
618 int client = KPimGlobalPrefs::instance()->mEmailClient; 617 int client = KPimGlobalPrefs::instance()->mEmailClient;
619 if (client == KPimGlobalPrefs::OTHER_EMC) 618 if (client == KPimGlobalPrefs::OTHER_EMC)
620 { 619 {
621 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 620 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
622 message = KPimGlobalPrefs::instance()->mEmailOtherMessage; 621 message = KPimGlobalPrefs::instance()->mEmailOtherMessage;
623 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 622 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
624 } 623 }
625 else 624 else
626 { 625 {
627 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); 626 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client);
628 if (!dai) 627 if (!dai)
629 { 628 {
630 qDebug("could not find configured email application."); 629 qDebug("could not find configured email application.");
631 return false; 630 return false;
632 } 631 }
633 channel = dai->_channel; 632 channel = dai->_channel;
634 message = dai->_message; 633 message = dai->_message;
635 parameters = dai->_parameters; 634 parameters = dai->_parameters;
636 } 635 }
637 636
638 637
639 //first check if one of the mailers need the emails right in the message. 638 //first check if one of the mailers need the emails right in the message.
640 message = translateMessage(message, name, emailadress); 639 message = translateMessage(message, name, emailadress);
641 640
642 641
643 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 642 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
644 qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); 643 qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1());
645 644
646 QCopEnvelope e(channel.latin1(), message.latin1()); 645 QCopEnvelope e(channel.latin1(), message.latin1());
647 //US we need no names in the To field. The emailadresses are enough 646 //US we need no names in the To field. The emailadresses are enough
648 647
649 passParameters(&e, parameters, name, emailadress); 648 passParameters(&e, parameters, name, emailadress);
650 649
651 650
652#else 651#else
653 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); 652 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) );
654#endif 653#endif
655 654
656 655
657 return true; 656 return true;
658} 657}
659 658
660/************************************************************************** 659/**************************************************************************
661 * 660 *
662 **************************************************************************/ 661 **************************************************************************/
663 662
664//calls the emailapplication and creates a mail with parameter as recipients 663//calls the emailapplication and creates a mail with parameter as recipients
665// parameters format is 664// parameters format is
666// NAME <EMAIL>:SUBJECT 665// NAME <EMAIL>:SUBJECT
667bool ExternalAppHandler::mailToOneContact( const QString& adressline ) 666bool ExternalAppHandler::mailToOneContact( const QString& adressline )
668{ 667{
669 QString line = adressline; 668 QString line = adressline;
670 669
671 int first = line.find( "<"); 670 int first = line.find( "<");
672 int last = line.find( ">"); 671 int last = line.find( ">");
673 QString name = line.left(first); 672 QString name = line.left(first);
674 QString emailadress = line.mid(first+1, last-first-1); 673 QString emailadress = line.mid(first+1, last-first-1);
675 674
676 //Subject can not be handled right now. 675 //Subject can not be handled right now.
677 return mailToOneContact( name, emailadress ); 676 return mailToOneContact( name, emailadress );
678 677
679} 678}
680 679
681 680
682/************************************************************************** 681/**************************************************************************
683 * 682 *
684 **************************************************************************/ 683 **************************************************************************/
685 684
686//calls the phoneapplication with the number 685//calls the phoneapplication with the number
687bool ExternalAppHandler::callByPhone( const QString& phonenumber ) 686bool ExternalAppHandler::callByPhone( const QString& phonenumber )
688{ 687{
689#ifndef DESKTOP_VERSION 688#ifndef DESKTOP_VERSION
690 QString channel; 689 QString channel;
691 QString message; 690 QString message;
692 QString parameters; 691 QString parameters;
693 692
694 693
695 int client = KPimGlobalPrefs::instance()->mPhoneClient; 694 int client = KPimGlobalPrefs::instance()->mPhoneClient;
696 if (client == KPimGlobalPrefs::OTHER_PHC) 695 if (client == KPimGlobalPrefs::OTHER_PHC)
697 { 696 {
698 channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; 697 channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel;
699 message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; 698 message = KPimGlobalPrefs::instance()->mPhoneOtherMessage;
700 parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; 699 parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters;
701 } 700 }
702 else 701 else
703 { 702 {
704 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); 703 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client);
705 if (!dai) 704 if (!dai)
706 { 705 {
707 qDebug("could not find configured phone application."); 706 qDebug("could not find configured phone application.");
708 return false; 707 return false;
709 } 708 }
710 channel = dai->_channel; 709 channel = dai->_channel;
711 message = dai->_message; 710 message = dai->_message;
712 parameters = dai->_parameters; 711 parameters = dai->_parameters;
713 } 712 }
714 713
715 714
716 //first check if one of the mailers need the emails right in the message. 715 //first check if one of the mailers need the emails right in the message.
717 message = translateMessage(message, phonenumber, ""); 716 message = translateMessage(message, phonenumber, "");
718 717
719 718
720 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 719 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
721 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); 720 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1());
722 721
723 QCopEnvelope e(channel.latin1(), message.latin1()); 722 QCopEnvelope e(channel.latin1(), message.latin1());
724 //US we need no names in the To field. The emailadresses are enough 723 //US we need no names in the To field. The emailadresses are enough
725 724
726 passParameters(&e, parameters, phonenumber, ""); 725 passParameters(&e, parameters, phonenumber, "");
727 726
728 727
729#else 728#else
730 KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); 729 KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) );
731#endif 730#endif
732 731
733 732
734 return true; 733 return true;
735} 734}
736 735
737/************************************************************************** 736/**************************************************************************
738 * 737 *
739 **************************************************************************/ 738 **************************************************************************/
740 739
741//calls the smsapplication with the number 740//calls the smsapplication with the number
742bool ExternalAppHandler::callBySMS( const QString& phonenumber ) 741bool ExternalAppHandler::callBySMS( const QString& phonenumber )
743{ 742{
744#ifndef DESKTOP_VERSION 743#ifndef DESKTOP_VERSION
745 QString channel; 744 QString channel;
746 QString message; 745 QString message;
747 QString parameters; 746 QString parameters;
748 747
749 748
750 int client = KPimGlobalPrefs::instance()->mSMSClient; 749 int client = KPimGlobalPrefs::instance()->mSMSClient;
751 if (client == KPimGlobalPrefs::OTHER_SMC) 750 if (client == KPimGlobalPrefs::OTHER_SMC)
752 { 751 {
753 channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; 752 channel = KPimGlobalPrefs::instance()->mSMSOtherChannel;
754 message = KPimGlobalPrefs::instance()->mSMSOtherMessage; 753 message = KPimGlobalPrefs::instance()->mSMSOtherMessage;
755 parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; 754 parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters;
756 } 755 }
757 else 756 else
758 { 757 {
759 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); 758 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client);
760 if (!dai) 759 if (!dai)
761 { 760 {
762 qDebug("could not find configured sms application."); 761 qDebug("could not find configured sms application.");
763 return false; 762 return false;
764 } 763 }
765 channel = dai->_channel; 764 channel = dai->_channel;
766 message = dai->_message; 765 message = dai->_message;
767 parameters = dai->_parameters; 766 parameters = dai->_parameters;
768 } 767 }
769 768
770 769
771 //first check if one of the mailers need the emails right in the message. 770 //first check if one of the mailers need the emails right in the message.
772 message = translateMessage(message, phonenumber, ""); 771 message = translateMessage(message, phonenumber, "");
773 772
774 773
775 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 774 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
776 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); 775 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1());
777 776
778 QCopEnvelope e(channel.latin1(), message.latin1()); 777 QCopEnvelope e(channel.latin1(), message.latin1());
779 //US we need no names in the To field. The emailadresses are enough 778 //US we need no names in the To field. The emailadresses are enough
780 779
781 passParameters(&e, parameters, phonenumber, ""); 780 passParameters(&e, parameters, phonenumber, "");
782 781
783 782
784#else 783#else
785 KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); 784 KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) );
786#endif 785#endif
787 786
788 787
789 return true; 788 return true;
790} 789}
791 790
792/************************************************************************** 791/**************************************************************************
793 * 792 *
794 **************************************************************************/ 793 **************************************************************************/
795 794
796//calls the pagerapplication with the number 795//calls the pagerapplication with the number
797bool ExternalAppHandler::callByPager( const QString& pagernumber ) 796bool ExternalAppHandler::callByPager( const QString& pagernumber )
798{ 797{
799#ifndef DESKTOP_VERSION 798#ifndef DESKTOP_VERSION
800 QString channel; 799 QString channel;
801 QString message; 800 QString message;
802 QString parameters; 801 QString parameters;
803 802
804 803
805 int client = KPimGlobalPrefs::instance()->mPagerClient; 804 int client = KPimGlobalPrefs::instance()->mPagerClient;
806 if (client == KPimGlobalPrefs::OTHER_PAC) 805 if (client == KPimGlobalPrefs::OTHER_PAC)
807 { 806 {
808 channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; 807 channel = KPimGlobalPrefs::instance()->mPagerOtherChannel;
809 message = KPimGlobalPrefs::instance()->mPagerOtherMessage; 808 message = KPimGlobalPrefs::instance()->mPagerOtherMessage;
810 parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; 809 parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters;
811 } 810 }
812 else 811 else
813 { 812 {
814 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); 813 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client);
815 if (!dai) 814 if (!dai)
816 { 815 {
817 qDebug("could not find configured pager application."); 816 qDebug("could not find configured pager application.");
818 return false; 817 return false;
819 } 818 }
820 channel = dai->_channel; 819 channel = dai->_channel;
821 message = dai->_message; 820 message = dai->_message;
822 parameters = dai->_parameters; 821 parameters = dai->_parameters;
823 } 822 }
824 823
825 824
826 //first check if one of the mailers need the emails right in the message. 825 //first check if one of the mailers need the emails right in the message.
827 message = translateMessage(message, pagernumber, ""); 826 message = translateMessage(message, pagernumber, "");
828 827
829 828
830 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 829 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
831 qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); 830 qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1());
832 831
833 QCopEnvelope e(channel.latin1(), message.latin1()); 832 QCopEnvelope e(channel.latin1(), message.latin1());
834 //US we need no names in the To field. The emailadresses are enough 833 //US we need no names in the To field. The emailadresses are enough
835 834
836 passParameters(&e, parameters, pagernumber, ""); 835 passParameters(&e, parameters, pagernumber, "");
837 836
838 837
839#else 838#else
840 KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); 839 KMessageBox::sorry( 0, i18n( "This version does not support paging." ) );
841#endif 840#endif
842 841
843 842
844 return true; 843 return true;
845} 844}
846 845
847/************************************************************************** 846/**************************************************************************
848 * 847 *
849 **************************************************************************/ 848 **************************************************************************/
850 849
851//calls the faxapplication with the number 850//calls the faxapplication with the number
852bool ExternalAppHandler::callByFax( const QString& faxnumber ) 851bool ExternalAppHandler::callByFax( const QString& faxnumber )
853{ 852{
854#ifndef DESKTOP_VERSION 853#ifndef DESKTOP_VERSION
855 QString channel; 854 QString channel;
856 QString message; 855 QString message;
857 QString parameters; 856 QString parameters;
858 857
859 858
860 int client = KPimGlobalPrefs::instance()->mFaxClient; 859 int client = KPimGlobalPrefs::instance()->mFaxClient;
861 if (client == KPimGlobalPrefs::OTHER_FAC) 860 if (client == KPimGlobalPrefs::OTHER_FAC)
862 { 861 {
863 channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; 862 channel = KPimGlobalPrefs::instance()->mFaxOtherChannel;
864 message = KPimGlobalPrefs::instance()->mFaxOtherMessage; 863 message = KPimGlobalPrefs::instance()->mFaxOtherMessage;
865 parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; 864 parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters;
866 } 865 }
867 else 866 else
868 { 867 {
869 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); 868 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client);
870 if (!dai) 869 if (!dai)
871 { 870 {
872 qDebug("could not find configured fax application."); 871 qDebug("could not find configured fax application.");
873 return false; 872 return false;
874 } 873 }
875 channel = dai->_channel; 874 channel = dai->_channel;
876 message = dai->_message; 875 message = dai->_message;
877 parameters = dai->_parameters; 876 parameters = dai->_parameters;
878 } 877 }
879 878
880 879
881 //first check if one of the mailers need the emails right in the message. 880 //first check if one of the mailers need the emails right in the message.
882 message = translateMessage(message, faxnumber, ""); 881 message = translateMessage(message, faxnumber, "");
883 882
884 883
885 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 884 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
886 qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); 885 qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1());
887 886
888 QCopEnvelope e(channel.latin1(), message.latin1()); 887 QCopEnvelope e(channel.latin1(), message.latin1());
889 //US we need no names in the To field. The emailadresses are enough 888 //US we need no names in the To field. The emailadresses are enough
890 889
891 passParameters(&e, parameters, faxnumber, ""); 890 passParameters(&e, parameters, faxnumber, "");
892 891
893 892
894#else 893#else
895 KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); 894 KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) );
896#endif 895#endif
897 896
898 897
899 return true; 898 return true;
900} 899}
901 900
902/************************************************************************** 901/**************************************************************************
903 * 902 *
904 **************************************************************************/ 903 **************************************************************************/
905 904
906 905
907QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const 906QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const
908{ 907{
909 message = message.replace( QRegExp("%1"), param1 ); 908 message = message.replace( QRegExp("%1"), param1 );
910 return message.replace( QRegExp("%2"), param2 ); 909 return message.replace( QRegExp("%2"), param2 );
911} 910}
912 911
913/************************************************************************** 912/**************************************************************************
914 * 913 *
915 **************************************************************************/ 914 **************************************************************************/
916 915
917void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const 916void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const
918{ 917{
919#ifndef DESKTOP_VERSION 918#ifndef DESKTOP_VERSION
920 QMap<QString, QString> valmap; 919 QMap<QString, QString> valmap;
921 bool useValMap = false; 920 bool useValMap = false;
922 921
923 // first extract all parts of the parameters. 922 // first extract all parts of the parameters.
924 QStringList paramlist = QStringList::split(";", parameters); 923 QStringList paramlist = QStringList::split(";", parameters);
925 924
926 //Now check how many parts we have. 925 //Now check how many parts we have.
927 //=0 :no params to pass 926 //=0 :no params to pass
928 //>0 :parameters to pass 927 //>0 :parameters to pass
929 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) 928 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it )
930 { 929 {
931 QString param = (*it); 930 QString param = (*it);
932 QStringList keyvallist = QStringList::split("=", param); 931 QStringList keyvallist = QStringList::split("=", param);
933 932
934 //if we have keyvalue pairs, we assume that we pass a map to the envelope 933 //if we have keyvalue pairs, we assume that we pass a map to the envelope
935 QStringList::Iterator it2 = keyvallist.begin(); 934 QStringList::Iterator it2 = keyvallist.begin();
936 QString key = (*it2); 935 QString key = (*it2);
937 key = key.replace( QRegExp("%1"), param1 ); 936 key = key.replace( QRegExp("%1"), param1 );
938 key = key.replace( QRegExp("%2"), param2 ); 937 key = key.replace( QRegExp("%2"), param2 );
939 ++it2; 938 ++it2;
940 939
941 if(it2 != keyvallist.end()) 940 if(it2 != keyvallist.end())
942 { 941 {
943 QString value = (*it2); 942 QString value = (*it2);
944 value = value.replace( QRegExp("%1"), param1 ); 943 value = value.replace( QRegExp("%1"), param1 );
945 value = value.replace( QRegExp("%2"), param2 ); 944 value = value.replace( QRegExp("%2"), param2 );
946 945
947 valmap.insert(key, value); 946 valmap.insert(key, value);
948 useValMap = true; 947 useValMap = true;
949 } 948 }
950 else 949 else
951 { 950 {
952 // qDebug("pass parameter << %s", key.latin1()); 951 // qDebug("pass parameter << %s", key.latin1());
953 (*e) << key; 952 (*e) << key;
954 } 953 }
955 } 954 }
956 955
957 if (useValMap == true) 956 if (useValMap == true)
958 (*e) << valmap; 957 (*e) << valmap;
959 958
960#endif 959#endif
961 960
962} 961}
963 962
964 963
965 964
966/************************************************************************** 965/**************************************************************************
967 * 966 *
968 **************************************************************************/ 967 **************************************************************************/
969 968
970void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) 969void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data )
971{ 970{
972 bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); 971 bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data );
973
974 if (!res) 972 if (!res)
975 res = mDisplayDetails->appMessage( cmsg, data ); 973 res = mDisplayDetails->appMessage( cmsg, data );
976 974
977// if (!res) 975// if (!res)
978// res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); 976// res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data );
979} 977}
980 978
981 979
982 980
983bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid) 981bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid)
984{ 982{
985 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); 983 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel);
986 return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid); 984 return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid);
987} 985}
988 986
989bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) 987bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
990{ 988{
991 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); 989 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel);
992 return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3); 990 return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3);
993} 991}
994 992
995bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email) 993bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email)
996{ 994{
997 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); 995 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel);
998 return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email); 996 return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email);
999} 997}
1000 998
1001bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) 999bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
1002{ 1000{
1003 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); 1001 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel);
1004 return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3); 1002 return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3);
1005} 1003}
1006 1004
1007bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid) 1005bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid)
1008{ 1006{
1009 mDisplayDetails->setSourceChannel(""); 1007 mDisplayDetails->setSourceChannel("");
1010 return mDisplayDetails->sendMessageToTarget("", name, email, uid); 1008 return mDisplayDetails->sendMessageToTarget("", name, email, uid);
1011} 1009}
1012 1010
1013 1011
1014 1012
1015 1013
1016 1014