summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp2
-rw-r--r--kaddressbook/kabcore.cpp4
-rw-r--r--korganizer/mainwindow.cpp2
3 files changed, 4 insertions, 4 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index df0fba4..d101589 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -1,1240 +1,1240 @@
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#include <qtextstream.h> 41#include <qtextstream.h>
42#include <qfile.h> 42#include <qfile.h>
43#include <qregexp.h> 43#include <qregexp.h>
44 44
45#include <kglobal.h> 45#include <kglobal.h>
46#include <klocale.h> 46#include <klocale.h>
47#include <kmessagebox.h> 47#include <kmessagebox.h>
48#include <kdebug.h> 48#include <kdebug.h>
49#include <libkcal/syncdefines.h> 49#include <libkcal/syncdefines.h>
50#include <libkdepim/phoneaccess.h> 50#include <libkdepim/phoneaccess.h>
51#include "addressbook.h" 51#include "addressbook.h"
52#include "resource.h" 52#include "resource.h"
53#include "vcardconverter.h" 53#include "vcardconverter.h"
54#include "vcardparser/vcardtool.h" 54#include "vcardparser/vcardtool.h"
55 55
56//US #include "addressbook.moc" 56//US #include "addressbook.moc"
57 57
58using namespace KABC; 58using namespace KABC;
59 59
60struct AddressBook::AddressBookData 60struct AddressBook::AddressBookData
61{ 61{
62 Addressee::List mAddressees; 62 Addressee::List mAddressees;
63 Addressee::List mRemovedAddressees; 63 Addressee::List mRemovedAddressees;
64 Field::List mAllFields; 64 Field::List mAllFields;
65 KConfig *mConfig; 65 KConfig *mConfig;
66 KRES::Manager<Resource> *mManager; 66 KRES::Manager<Resource> *mManager;
67//US ErrorHandler *mErrorHandler; 67//US ErrorHandler *mErrorHandler;
68}; 68};
69 69
70struct AddressBook::Iterator::IteratorData 70struct AddressBook::Iterator::IteratorData
71{ 71{
72 Addressee::List::Iterator mIt; 72 Addressee::List::Iterator mIt;
73}; 73};
74 74
75struct AddressBook::ConstIterator::ConstIteratorData 75struct AddressBook::ConstIterator::ConstIteratorData
76{ 76{
77 Addressee::List::ConstIterator mIt; 77 Addressee::List::ConstIterator mIt;
78}; 78};
79 79
80AddressBook::Iterator::Iterator() 80AddressBook::Iterator::Iterator()
81{ 81{
82 d = new IteratorData; 82 d = new IteratorData;
83} 83}
84 84
85AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) 85AddressBook::Iterator::Iterator( const AddressBook::Iterator &i )
86{ 86{
87 d = new IteratorData; 87 d = new IteratorData;
88 d->mIt = i.d->mIt; 88 d->mIt = i.d->mIt;
89} 89}
90 90
91AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) 91AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i )
92{ 92{
93 if( this == &i ) return *this; // guard against self assignment 93 if( this == &i ) return *this; // guard against self assignment
94 delete d; // delete the old data the Iterator was completely constructed before 94 delete d; // delete the old data the Iterator was completely constructed before
95 d = new IteratorData; 95 d = new IteratorData;
96 d->mIt = i.d->mIt; 96 d->mIt = i.d->mIt;
97 return *this; 97 return *this;
98} 98}
99 99
100AddressBook::Iterator::~Iterator() 100AddressBook::Iterator::~Iterator()
101{ 101{
102 delete d; 102 delete d;
103} 103}
104 104
105const Addressee &AddressBook::Iterator::operator*() const 105const Addressee &AddressBook::Iterator::operator*() const
106{ 106{
107 return *(d->mIt); 107 return *(d->mIt);
108} 108}
109 109
110Addressee &AddressBook::Iterator::operator*() 110Addressee &AddressBook::Iterator::operator*()
111{ 111{
112 return *(d->mIt); 112 return *(d->mIt);
113} 113}
114 114
115Addressee *AddressBook::Iterator::operator->() 115Addressee *AddressBook::Iterator::operator->()
116{ 116{
117 return &(*(d->mIt)); 117 return &(*(d->mIt));
118} 118}
119 119
120AddressBook::Iterator &AddressBook::Iterator::operator++() 120AddressBook::Iterator &AddressBook::Iterator::operator++()
121{ 121{
122 (d->mIt)++; 122 (d->mIt)++;
123 return *this; 123 return *this;
124} 124}
125 125
126AddressBook::Iterator &AddressBook::Iterator::operator++(int) 126AddressBook::Iterator &AddressBook::Iterator::operator++(int)
127{ 127{
128 (d->mIt)++; 128 (d->mIt)++;
129 return *this; 129 return *this;
130} 130}
131 131
132AddressBook::Iterator &AddressBook::Iterator::operator--() 132AddressBook::Iterator &AddressBook::Iterator::operator--()
133{ 133{
134 (d->mIt)--; 134 (d->mIt)--;
135 return *this; 135 return *this;
136} 136}
137 137
138AddressBook::Iterator &AddressBook::Iterator::operator--(int) 138AddressBook::Iterator &AddressBook::Iterator::operator--(int)
139{ 139{
140 (d->mIt)--; 140 (d->mIt)--;
141 return *this; 141 return *this;
142} 142}
143 143
144bool AddressBook::Iterator::operator==( const Iterator &it ) 144bool AddressBook::Iterator::operator==( const Iterator &it )
145{ 145{
146 return ( d->mIt == it.d->mIt ); 146 return ( d->mIt == it.d->mIt );
147} 147}
148 148
149bool AddressBook::Iterator::operator!=( const Iterator &it ) 149bool AddressBook::Iterator::operator!=( const Iterator &it )
150{ 150{
151 return ( d->mIt != it.d->mIt ); 151 return ( d->mIt != it.d->mIt );
152} 152}
153 153
154 154
155AddressBook::ConstIterator::ConstIterator() 155AddressBook::ConstIterator::ConstIterator()
156{ 156{
157 d = new ConstIteratorData; 157 d = new ConstIteratorData;
158} 158}
159 159
160AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) 160AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i )
161{ 161{
162 d = new ConstIteratorData; 162 d = new ConstIteratorData;
163 d->mIt = i.d->mIt; 163 d->mIt = i.d->mIt;
164} 164}
165 165
166AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) 166AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i )
167{ 167{
168 if( this == &i ) return *this; // guard for self assignment 168 if( this == &i ) return *this; // guard for self assignment
169 delete d; // delete the old data because the Iterator was really constructed before 169 delete d; // delete the old data because the Iterator was really constructed before
170 d = new ConstIteratorData; 170 d = new ConstIteratorData;
171 d->mIt = i.d->mIt; 171 d->mIt = i.d->mIt;
172 return *this; 172 return *this;
173} 173}
174 174
175AddressBook::ConstIterator::~ConstIterator() 175AddressBook::ConstIterator::~ConstIterator()
176{ 176{
177 delete d; 177 delete d;
178} 178}
179 179
180const Addressee &AddressBook::ConstIterator::operator*() const 180const Addressee &AddressBook::ConstIterator::operator*() const
181{ 181{
182 return *(d->mIt); 182 return *(d->mIt);
183} 183}
184 184
185const Addressee* AddressBook::ConstIterator::operator->() const 185const Addressee* AddressBook::ConstIterator::operator->() const
186{ 186{
187 return &(*(d->mIt)); 187 return &(*(d->mIt));
188} 188}
189 189
190AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() 190AddressBook::ConstIterator &AddressBook::ConstIterator::operator++()
191{ 191{
192 (d->mIt)++; 192 (d->mIt)++;
193 return *this; 193 return *this;
194} 194}
195 195
196AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) 196AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int)
197{ 197{
198 (d->mIt)++; 198 (d->mIt)++;
199 return *this; 199 return *this;
200} 200}
201 201
202AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() 202AddressBook::ConstIterator &AddressBook::ConstIterator::operator--()
203{ 203{
204 (d->mIt)--; 204 (d->mIt)--;
205 return *this; 205 return *this;
206} 206}
207 207
208AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) 208AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int)
209{ 209{
210 (d->mIt)--; 210 (d->mIt)--;
211 return *this; 211 return *this;
212} 212}
213 213
214bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) 214bool AddressBook::ConstIterator::operator==( const ConstIterator &it )
215{ 215{
216 return ( d->mIt == it.d->mIt ); 216 return ( d->mIt == it.d->mIt );
217} 217}
218 218
219bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) 219bool AddressBook::ConstIterator::operator!=( const ConstIterator &it )
220{ 220{
221 return ( d->mIt != it.d->mIt ); 221 return ( d->mIt != it.d->mIt );
222} 222}
223 223
224 224
225AddressBook::AddressBook() 225AddressBook::AddressBook()
226{ 226{
227 init(0, "contact"); 227 init(0, "contact");
228} 228}
229 229
230AddressBook::AddressBook( const QString &config ) 230AddressBook::AddressBook( const QString &config )
231{ 231{
232 init(config, "contact"); 232 init(config, "contact");
233} 233}
234 234
235AddressBook::AddressBook( const QString &config, const QString &family ) 235AddressBook::AddressBook( const QString &config, const QString &family )
236{ 236{
237 init(config, family); 237 init(config, family);
238 238
239} 239}
240 240
241// the default family is "contact" 241// the default family is "contact"
242void AddressBook::init(const QString &config, const QString &family ) 242void AddressBook::init(const QString &config, const QString &family )
243{ 243{
244 blockLSEchange = false; 244 blockLSEchange = false;
245 d = new AddressBookData; 245 d = new AddressBookData;
246 QString fami = family; 246 QString fami = family;
247 if (config != 0) { 247 if (config != 0) {
248 if ( family == "syncContact" ) { 248 if ( family == "syncContact" ) {
249 qDebug("creating sync config "); 249 qDebug("creating sync config ");
250 fami = "contact"; 250 fami = "contact";
251 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); 251 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") );
252 con->setGroup( "General" ); 252 con->setGroup( "General" );
253 con->writeEntry( "ResourceKeys", QString("sync") ); 253 con->writeEntry( "ResourceKeys", QString("sync") );
254 con->writeEntry( "Standard", QString("sync") ); 254 con->writeEntry( "Standard", QString("sync") );
255 con->setGroup( "Resource_sync" ); 255 con->setGroup( "Resource_sync" );
256 con->writeEntry( "FileName", config ); 256 con->writeEntry( "FileName", config );
257 con->writeEntry( "FileFormat", QString("vcard") ); 257 con->writeEntry( "FileFormat", QString("vcard") );
258 con->writeEntry( "ResourceIdentifier", QString("sync") ); 258 con->writeEntry( "ResourceIdentifier", QString("sync") );
259 con->writeEntry( "ResourceName", QString("sync_res") ); 259 con->writeEntry( "ResourceName", QString("sync_res") );
260 if ( config.right(4) == ".xml" ) 260 if ( config.right(4) == ".xml" )
261 con->writeEntry( "ResourceType", QString("qtopia") ); 261 con->writeEntry( "ResourceType", QString("qtopia") );
262 else if ( config == "sharp" ) { 262 else if ( config == "sharp" ) {
263 con->writeEntry( "ResourceType", QString("sharp") ); 263 con->writeEntry( "ResourceType", QString("sharp") );
264 } else { 264 } else {
265 con->writeEntry( "ResourceType", QString("file") ); 265 con->writeEntry( "ResourceType", QString("file") );
266 } 266 }
267 //con->sync(); 267 //con->sync();
268 d->mConfig = con; 268 d->mConfig = con;
269 } 269 }
270 else 270 else
271 d->mConfig = new KConfig( locateLocal("config", config) ); 271 d->mConfig = new KConfig( locateLocal("config", config) );
272// qDebug("AddressBook::init 1 config=%s",config.latin1() ); 272// qDebug("AddressBook::init 1 config=%s",config.latin1() );
273 } 273 }
274 else { 274 else {
275 d->mConfig = 0; 275 d->mConfig = 0;
276// qDebug("AddressBook::init 1 config=0"); 276// qDebug("AddressBook::init 1 config=0");
277 } 277 }
278 278
279//US d->mErrorHandler = 0; 279//US d->mErrorHandler = 0;
280 d->mManager = new KRES::Manager<Resource>( fami ); 280 d->mManager = new KRES::Manager<Resource>( fami );
281 d->mManager->readConfig( d->mConfig ); 281 d->mManager->readConfig( d->mConfig );
282 if ( family == "syncContact" ) { 282 if ( family == "syncContact" ) {
283 KRES::Manager<Resource> *manager = d->mManager; 283 KRES::Manager<Resource> *manager = d->mManager;
284 KRES::Manager<Resource>::ActiveIterator it; 284 KRES::Manager<Resource>::ActiveIterator it;
285 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 285 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
286 (*it)->setAddressBook( this ); 286 (*it)->setAddressBook( this );
287 if ( !(*it)->open() ) 287 if ( !(*it)->open() )
288 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); 288 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) );
289 } 289 }
290 Resource *res = standardResource(); 290 Resource *res = standardResource();
291 if ( !res ) { 291 if ( !res ) {
292 qDebug("ERROR: no standard resource"); 292 qDebug("ERROR: no standard resource");
293 res = manager->createResource( "file" ); 293 res = manager->createResource( "file" );
294 if ( res ) 294 if ( res )
295 { 295 {
296 addResource( res ); 296 addResource( res );
297 } 297 }
298 else 298 else
299 qDebug(" No resource available!!!"); 299 qDebug(" No resource available!!!");
300 } 300 }
301 setStandardResource( res ); 301 setStandardResource( res );
302 manager->writeConfig(); 302 manager->writeConfig();
303 } 303 }
304 addCustomField( i18n( "Department" ), KABC::Field::Organization, 304 addCustomField( i18n( "Department" ), KABC::Field::Organization,
305 "X-Department", "KADDRESSBOOK" ); 305 "X-Department", "KADDRESSBOOK" );
306 addCustomField( i18n( "Profession" ), KABC::Field::Organization, 306 addCustomField( i18n( "Profession" ), KABC::Field::Organization,
307 "X-Profession", "KADDRESSBOOK" ); 307 "X-Profession", "KADDRESSBOOK" );
308 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 308 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
309 "X-AssistantsName", "KADDRESSBOOK" ); 309 "X-AssistantsName", "KADDRESSBOOK" );
310 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 310 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
311 "X-ManagersName", "KADDRESSBOOK" ); 311 "X-ManagersName", "KADDRESSBOOK" );
312 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 312 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
313 "X-SpousesName", "KADDRESSBOOK" ); 313 "X-SpousesName", "KADDRESSBOOK" );
314 addCustomField( i18n( "Office" ), KABC::Field::Personal, 314 addCustomField( i18n( "Office" ), KABC::Field::Personal,
315 "X-Office", "KADDRESSBOOK" ); 315 "X-Office", "KADDRESSBOOK" );
316 addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 316 addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
317 "X-IMAddress", "KADDRESSBOOK" ); 317 "X-IMAddress", "KADDRESSBOOK" );
318 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 318 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
319 "X-Anniversary", "KADDRESSBOOK" ); 319 "X-Anniversary", "KADDRESSBOOK" );
320 320
321 //US added this field to become compatible with Opie/qtopia addressbook 321 //US added this field to become compatible with Opie/qtopia addressbook
322 // values can be "female" or "male" or "". An empty field represents undefined. 322 // values can be "female" or "male" or "". An empty field represents undefined.
323 addCustomField( i18n( "Gender" ), KABC::Field::Personal, 323 addCustomField( i18n( "Gender" ), KABC::Field::Personal,
324 "X-Gender", "KADDRESSBOOK" ); 324 "X-Gender", "KADDRESSBOOK" );
325 addCustomField( i18n( "Children" ), KABC::Field::Personal, 325 addCustomField( i18n( "Children" ), KABC::Field::Personal,
326 "X-Children", "KADDRESSBOOK" ); 326 "X-Children", "KADDRESSBOOK" );
327 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 327 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
328 "X-FreeBusyUrl", "KADDRESSBOOK" ); 328 "X-FreeBusyUrl", "KADDRESSBOOK" );
329 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, 329 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal,
330 "X-ExternalID", "KADDRESSBOOK" ); 330 "X-ExternalID", "KADDRESSBOOK" );
331} 331}
332 332
333AddressBook::~AddressBook() 333AddressBook::~AddressBook()
334{ 334{
335 delete d->mConfig; d->mConfig = 0; 335 delete d->mConfig; d->mConfig = 0;
336 delete d->mManager; d->mManager = 0; 336 delete d->mManager; d->mManager = 0;
337//US delete d->mErrorHandler; d->mErrorHandler = 0; 337//US delete d->mErrorHandler; d->mErrorHandler = 0;
338 delete d; d = 0; 338 delete d; d = 0;
339} 339}
340 340
341bool AddressBook::load() 341bool AddressBook::load()
342{ 342{
343 343
344 clear(); 344 clear();
345 KRES::Manager<Resource>::ActiveIterator it; 345 KRES::Manager<Resource>::ActiveIterator it;
346 bool ok = true; 346 bool ok = true;
347 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 347 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
348 if ( !(*it)->load() ) { 348 if ( !(*it)->load() ) {
349 qDebug( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); 349 qDebug( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) );
350 ok = false; 350 ok = false;
351 } else { 351 } else {
352 qDebug( i18n("Resource loaded: '%1'").arg( (*it)->resourceName() ) ); 352 qDebug( i18n("Resource loaded: '%1'").arg( (*it)->resourceName() ) );
353 } 353 }
354 // mark all addressees as unchanged 354 // mark all addressees as unchanged
355 Addressee::List::Iterator addrIt; 355 Addressee::List::Iterator addrIt;
356 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { 356 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) {
357 (*addrIt).setChanged( false ); 357 (*addrIt).setChanged( false );
358 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); 358 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" );
359 if ( !id.isEmpty() ) { 359 if ( !id.isEmpty() ) {
360 //qDebug("setId aa %s ", id.latin1()); 360 //qDebug("setId aa %s ", id.latin1());
361 (*addrIt).setIDStr(id ); 361 (*addrIt).setIDStr(id );
362 } 362 }
363 } 363 }
364 blockLSEchange = true; 364 blockLSEchange = true;
365 return ok; 365 return ok;
366} 366}
367 367
368bool AddressBook::save( Ticket *ticket ) 368bool AddressBook::save( Ticket *ticket )
369{ 369{
370 kdDebug(5700) << "AddressBook::save()"<< endl; 370 kdDebug(5700) << "AddressBook::save()"<< endl;
371 371
372 if ( ticket->resource() ) { 372 if ( ticket->resource() ) {
373 deleteRemovedAddressees(); 373 deleteRemovedAddressees();
374 return ticket->resource()->save( ticket ); 374 return ticket->resource()->save( ticket );
375 } 375 }
376 376
377 return false; 377 return false;
378} 378}
379// exports all Addressees, which are syncable 379// exports all Addressees, which are syncable
380void AddressBook::export2File( QString fileName ) 380void AddressBook::export2File( QString fileName )
381{ 381{
382 382
383 QFile outFile( fileName ); 383 QFile outFile( fileName );
384 if ( !outFile.open( IO_WriteOnly ) ) { 384 if ( !outFile.open( IO_WriteOnly ) ) {
385 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); 385 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" );
386 KMessageBox::error( 0, text.arg( fileName ) ); 386 KMessageBox::error( 0, text.arg( fileName ) );
387 return ; 387 return ;
388 } 388 }
389 QTextStream t( &outFile ); 389 QTextStream t( &outFile );
390 t.setEncoding( QTextStream::UnicodeUTF8 ); 390 t.setEncoding( QTextStream::UnicodeUTF8 );
391 Iterator it; 391 Iterator it;
392 KABC::VCardConverter::Version version; 392 KABC::VCardConverter::Version version;
393 version = KABC::VCardConverter::v3_0; 393 version = KABC::VCardConverter::v3_0;
394 for ( it = begin(); it != end(); ++it ) { 394 for ( it = begin(); it != end(); ++it ) {
395 if ( (*it).resource() && (*it).resource()->includeInSync() ) { 395 if ( (*it).resource() && (*it).resource()->includeInSync() ) {
396 if ( !(*it).IDStr().isEmpty() ) { 396 if ( !(*it).IDStr().isEmpty() ) {
397 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); 397 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() );
398 } 398 }
399 KABC::VCardConverter converter; 399 KABC::VCardConverter converter;
400 QString vcard; 400 QString vcard;
401 //Resource *resource() const; 401 //Resource *resource() const;
402 converter.addresseeToVCard( *it, vcard, version ); 402 converter.addresseeToVCard( *it, vcard, version );
403 t << vcard << "\r\n"; 403 t << vcard << "\r\n";
404 } 404 }
405 } 405 }
406 t << "\r\n\r\n"; 406 t << "\r\n\r\n";
407 outFile.close(); 407 outFile.close();
408} 408}
409// if QStringList uids is empty, all are exported 409// if QStringList uids is empty, all are exported
410bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) 410bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName )
411{ 411{
412 KABC::VCardConverter converter; 412 KABC::VCardConverter converter;
413 QString datastream; 413 QString datastream;
414 Iterator it; 414 Iterator it;
415 bool all = uids.isEmpty(); 415 bool all = uids.isEmpty();
416 for ( it = begin(); it != end(); ++it ) { 416 for ( it = begin(); it != end(); ++it ) {
417 // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 417 // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
418 if ( ! all ) { 418 if ( ! all ) {
419 if ( ! ( uids.contains((*it).uid() ) )) 419 if ( ! ( uids.contains((*it).uid() ) ))
420 continue; 420 continue;
421 } 421 }
422 KABC::Addressee a = ( *it ); 422 KABC::Addressee a = ( *it );
423 if ( a.isEmpty() ) 423 if ( a.isEmpty() )
424 continue; 424 continue;
425 if ( all && a.resource() && !a.resource()->includeInSync() ) 425 if ( all && a.resource() && !a.resource()->includeInSync() )
426 continue; 426 continue;
427 a.simplifyEmails(); 427 a.simplifyEmails();
428 a.simplifyPhoneNumbers(); 428 a.simplifyPhoneNumbers();
429 a.simplifyPhoneNumberTypes(); 429 a.simplifyPhoneNumberTypes();
430 a.simplifyAddresses(); 430 a.simplifyAddresses();
431 431
432 QString vcard; 432 QString vcard;
433 QString vcardnew; 433 QString vcardnew;
434 converter.addresseeToVCard( a, vcard ); 434 converter.addresseeToVCard( a, vcard );
435 int start = 0; 435 int start = 0;
436 int next; 436 int next;
437 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 437 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
438 int semi = vcard.find(";", next); 438 int semi = vcard.find(";", next);
439 int dopp = vcard.find(":", next); 439 int dopp = vcard.find(":", next);
440 int sep; 440 int sep;
441 if ( semi < dopp && semi >= 0 ) 441 if ( semi < dopp && semi >= 0 )
442 sep = semi ; 442 sep = semi ;
443 else 443 else
444 sep = dopp; 444 sep = dopp;
445 vcardnew +=vcard.mid( start, next - start); 445 vcardnew +=vcard.mid( start, next - start);
446 vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); 446 vcardnew +=vcard.mid( next+5,sep -next -5 ).upper();
447 start = sep; 447 start = sep;
448 } 448 }
449 vcardnew += vcard.mid( start,vcard.length() ); 449 vcardnew += vcard.mid( start,vcard.length() );
450 vcard = ""; 450 vcard = "";
451 start = 0; 451 start = 0;
452 while ( (next = vcardnew.find("ADR", start) )>= 0 ) { 452 while ( (next = vcardnew.find("ADR", start) )>= 0 ) {
453 int sep = vcardnew.find(":", next); 453 int sep = vcardnew.find(":", next);
454 vcard +=vcardnew.mid( start, next - start+3); 454 vcard +=vcardnew.mid( start, next - start+3);
455 start = sep; 455 start = sep;
456 } 456 }
457 vcard += vcardnew.mid( start,vcardnew.length() ); 457 vcard += vcardnew.mid( start,vcardnew.length() );
458 vcard.replace ( QRegExp(";;;") , "" ); 458 vcard.replace ( QRegExp(";;;") , "" );
459 vcard.replace ( QRegExp(";;") , "" ); 459 vcard.replace ( QRegExp(";;") , "" );
460 datastream += vcard; 460 datastream += vcard;
461 461
462 } 462 }
463 463
464 QFile outFile(fileName); 464 QFile outFile(fileName);
465 if ( outFile.open(IO_WriteOnly) ) { 465 if ( outFile.open(IO_WriteOnly) ) {
466 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 466 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
467 QTextStream t( &outFile ); // use a text stream 467 QTextStream t( &outFile ); // use a text stream
468 t.setEncoding( QTextStream::UnicodeUTF8 ); 468 t.setEncoding( QTextStream::UnicodeUTF8 );
469 t <<datastream; 469 t <<datastream;
470 t << "\r\n\r\n"; 470 t << "\r\n\r\n";
471 outFile.close(); 471 outFile.close();
472 472
473 } else { 473 } else {
474 qDebug("Error open temp file "); 474 qDebug("Error open temp file ");
475 return false; 475 return false;
476 } 476 }
477 return true; 477 return true;
478 478
479} 479}
480int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) 480int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld )
481{ 481{
482 482
483 if ( removeOld ) 483 if ( removeOld )
484 setUntagged( true ); 484 setUntagged( true );
485 KABC::Addressee::List list; 485 KABC::Addressee::List list;
486 QFile file( fileName ); 486 QFile file( fileName );
487 file.open( IO_ReadOnly ); 487 file.open( IO_ReadOnly );
488 QByteArray rawData = file.readAll(); 488 QByteArray rawData = file.readAll();
489 file.close(); 489 file.close();
490 QString data; 490 QString data;
491 if ( replaceLabel ) { 491 if ( replaceLabel ) {
492 data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); 492 data = QString::fromLatin1( rawData.data(), rawData.size() + 1 );
493 data.replace ( QRegExp("LABEL") , "ADR" ); 493 data.replace ( QRegExp("LABEL") , "ADR" );
494 data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); 494 data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" );
495 } else 495 } else
496 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 496 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
497 KABC::VCardTool tool; 497 KABC::VCardTool tool;
498 list = tool.parseVCards( data ); 498 list = tool.parseVCards( data );
499 KABC::Addressee::List::Iterator it; 499 KABC::Addressee::List::Iterator it;
500 for ( it = list.begin(); it != list.end(); ++it ) { 500 for ( it = list.begin(); it != list.end(); ++it ) {
501 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); 501 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" );
502 if ( !id.isEmpty() ) 502 if ( !id.isEmpty() )
503 (*it).setIDStr(id ); 503 (*it).setIDStr(id );
504 (*it).setResource( 0 ); 504 (*it).setResource( 0 );
505 if ( replaceLabel ) 505 if ( replaceLabel )
506 (*it).removeVoice(); 506 (*it).removeVoice();
507 if ( removeOld ) 507 if ( removeOld )
508 (*it).setTagged( true ); 508 (*it).setTagged( true );
509 insertAddressee( (*it), false, true ); 509 insertAddressee( (*it), false, true );
510 } 510 }
511 if ( removeOld ) 511 if ( removeOld )
512 removeUntagged(); 512 removeUntagged();
513 return list.count(); 513 return list.count();
514} 514}
515void AddressBook::setUntagged(bool setNonSyncTagged) // = false) 515void AddressBook::setUntagged(bool setNonSyncTagged) // = false)
516{ 516{
517 Iterator ait; 517 Iterator ait;
518 for ( ait = begin(); ait != end(); ++ait ) { 518 for ( ait = begin(); ait != end(); ++ait ) {
519 if ( setNonSyncTagged ) { 519 if ( setNonSyncTagged ) {
520 if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) { 520 if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) {
521 (*ait).setTagged( true ); 521 (*ait).setTagged( true );
522 } else 522 } else
523 (*ait).setTagged( false ); 523 (*ait).setTagged( false );
524 } else 524 } else
525 (*ait).setTagged( false ); 525 (*ait).setTagged( false );
526 } 526 }
527} 527}
528void AddressBook::removeUntagged() 528void AddressBook::removeUntagged()
529{ 529{
530 Iterator ait; 530 Iterator ait;
531 bool todelete = false; 531 bool todelete = false;
532 Iterator todel; 532 Iterator todel;
533 for ( ait = begin(); ait != end(); ++ait ) { 533 for ( ait = begin(); ait != end(); ++ait ) {
534 if ( todelete ) 534 if ( todelete )
535 removeAddressee( todel ); 535 removeAddressee( todel );
536 if (!(*ait).tagged()) { 536 if (!(*ait).tagged()) {
537 todelete = true; 537 todelete = true;
538 todel = ait; 538 todel = ait;
539 } else 539 } else
540 todelete = false; 540 todelete = false;
541 } 541 }
542 if ( todelete ) 542 if ( todelete )
543 removeAddressee( todel ); 543 removeAddressee( todel );
544 deleteRemovedAddressees(); 544 deleteRemovedAddressees();
545} 545}
546void AddressBook::smplifyAddressees() 546void AddressBook::smplifyAddressees()
547{ 547{
548 Iterator ait; 548 Iterator ait;
549 for ( ait = begin(); ait != end(); ++ait ) { 549 for ( ait = begin(); ait != end(); ++ait ) {
550 (*ait).simplifyEmails(); 550 (*ait).simplifyEmails();
551 (*ait).simplifyPhoneNumbers(); 551 (*ait).simplifyPhoneNumbers();
552 (*ait).simplifyPhoneNumberTypes(); 552 (*ait).simplifyPhoneNumberTypes();
553 (*ait).simplifyAddresses(); 553 (*ait).simplifyAddresses();
554 } 554 }
555} 555}
556void AddressBook::removeSyncInfo( QString syncProfile) 556void AddressBook::removeSyncInfo( QString syncProfile)
557{ 557{
558 Iterator ait; 558 Iterator ait;
559 for ( ait = begin(); ait != end(); ++ait ) { 559 for ( ait = begin(); ait != end(); ++ait ) {
560 (*ait).removeID( syncProfile ); 560 (*ait).removeID( syncProfile );
561 } 561 }
562 if ( syncProfile.isEmpty() ) { 562 if ( syncProfile.isEmpty() ) {
563 Iterator it = begin(); 563 Iterator it = begin();
564 Iterator it2 ; 564 Iterator it2 ;
565 QDateTime dt ( QDate( 2004,1,1) ); 565 QDateTime dt ( QDate( 2004,1,1) );
566 while ( it != end() ) { 566 while ( it != end() ) {
567 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 567 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
568 it2 = it; 568 it2 = it;
569 //qDebug("removing %s ",(*it).uid().latin1() ); 569 //qDebug("removing %s ",(*it).uid().latin1() );
570 ++it; 570 ++it;
571 removeAddressee( it2 ); 571 removeAddressee( it2 );
572 } else { 572 } else {
573 //qDebug("skipping %s ",(*it).uid().latin1() ); 573 //qDebug("skipping %s ",(*it).uid().latin1() );
574 ++it; 574 ++it;
575 } 575 }
576 } 576 }
577 } else { 577 } else {
578 Addressee lse; 578 Addressee lse;
579 lse = mAddressBook->findByUid( "last-syncAddressee-"+ syncProfile ); 579 lse = findByUid( "last-syncAddressee-"+ syncProfile );
580 if ( ! lse.isEmpty() ) 580 if ( ! lse.isEmpty() )
581 removeAddressee( lse ); 581 removeAddressee( lse );
582 } 582 }
583 583
584} 584}
585void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) 585void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync )
586{ 586{
587 Iterator ait; 587 Iterator ait;
588 for ( ait = begin(); ait != end(); ++ait ) { 588 for ( ait = begin(); ait != end(); ++ait ) {
589 QString id = (*ait).IDStr(); 589 QString id = (*ait).IDStr();
590 (*ait).setIDStr( ":"); 590 (*ait).setIDStr( ":");
591 (*ait).setExternalUID( id ); 591 (*ait).setExternalUID( id );
592 (*ait).setOriginalExternalUID( id ); 592 (*ait).setOriginalExternalUID( id );
593 if ( isPreSync ) 593 if ( isPreSync )
594 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 594 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
595 else { 595 else {
596 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 596 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
597 (*ait).setID( currentSyncDevice,id ); 597 (*ait).setID( currentSyncDevice,id );
598 598
599 } 599 }
600 } 600 }
601} 601}
602void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice ) 602void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice )
603{ 603{
604 604
605 setUntagged(); 605 setUntagged();
606 KABC::Addressee::List list; 606 KABC::Addressee::List list;
607 QFile file( fileName ); 607 QFile file( fileName );
608 file.open( IO_ReadOnly ); 608 file.open( IO_ReadOnly );
609 QByteArray rawData = file.readAll(); 609 QByteArray rawData = file.readAll();
610 file.close(); 610 file.close();
611 QString data; 611 QString data;
612 612
613 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 613 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
614 KABC::VCardTool tool; 614 KABC::VCardTool tool;
615 list = tool.parseVCards( data ); 615 list = tool.parseVCards( data );
616 KABC::Addressee::List::Iterator it; 616 KABC::Addressee::List::Iterator it;
617 for ( it = list.begin(); it != list.end(); ++it ) { 617 for ( it = list.begin(); it != list.end(); ++it ) {
618 Iterator ait; 618 Iterator ait;
619 for ( ait = begin(); ait != end(); ++ait ) { 619 for ( ait = begin(); ait != end(); ++ait ) {
620 if ( !(*ait).tagged() ) { 620 if ( !(*ait).tagged() ) {
621 if ( (*ait).containsAdr(*it)) { 621 if ( (*ait).containsAdr(*it)) {
622 (*ait).setTagged(true); 622 (*ait).setTagged(true);
623 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); 623 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" );
624 (*it).setIDStr( ":"); 624 (*it).setIDStr( ":");
625 (*it).setID( currentSyncDevice,id ); 625 (*it).setID( currentSyncDevice,id );
626 (*it).setExternalUID( id ); 626 (*it).setExternalUID( id );
627 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 627 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
628 (*it).setUid( ( (*ait).uid() )); 628 (*it).setUid( ( (*ait).uid() ));
629 break; 629 break;
630 } 630 }
631 } 631 }
632 632
633 } 633 }
634 if ( ait == end() ) 634 if ( ait == end() )
635 qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1()); 635 qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1());
636 } 636 }
637 clear(); 637 clear();
638 for ( it = list.begin(); it != list.end(); ++it ) { 638 for ( it = list.begin(); it != list.end(); ++it ) {
639 insertAddressee( (*it) ); 639 insertAddressee( (*it) );
640 } 640 }
641} 641}
642 642
643bool AddressBook::saveABphone( QString fileName ) 643bool AddressBook::saveABphone( QString fileName )
644{ 644{
645 //smplifyAddressees(); 645 //smplifyAddressees();
646 qDebug("saveABphone:: saving AB... "); 646 qDebug("saveABphone:: saving AB... ");
647 if ( ! export2PhoneFormat( QStringList() ,fileName ) ) 647 if ( ! export2PhoneFormat( QStringList() ,fileName ) )
648 return false; 648 return false;
649 qDebug("saveABphone:: writing to phone... "); 649 qDebug("saveABphone:: writing to phone... ");
650 if ( !PhoneAccess::writeToPhone( fileName) ) { 650 if ( !PhoneAccess::writeToPhone( fileName) ) {
651 return false; 651 return false;
652 } 652 }
653 qDebug("saveABphone:: re-reading from phone... "); 653 qDebug("saveABphone:: re-reading from phone... ");
654 if ( !PhoneAccess::readFromPhone( fileName) ) { 654 if ( !PhoneAccess::readFromPhone( fileName) ) {
655 return false; 655 return false;
656 } 656 }
657 return true; 657 return true;
658} 658}
659bool AddressBook::saveAB() 659bool AddressBook::saveAB()
660{ 660{
661 bool ok = true; 661 bool ok = true;
662 662
663 deleteRemovedAddressees(); 663 deleteRemovedAddressees();
664 Iterator ait; 664 Iterator ait;
665 for ( ait = begin(); ait != end(); ++ait ) { 665 for ( ait = begin(); ait != end(); ++ait ) {
666 if ( !(*ait).IDStr().isEmpty() ) { 666 if ( !(*ait).IDStr().isEmpty() ) {
667 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); 667 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() );
668 } 668 }
669 } 669 }
670 KRES::Manager<Resource>::ActiveIterator it; 670 KRES::Manager<Resource>::ActiveIterator it;
671 KRES::Manager<Resource> *manager = d->mManager; 671 KRES::Manager<Resource> *manager = d->mManager;
672 qDebug("SaveAB::saving..." ); 672 qDebug("SaveAB::saving..." );
673 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 673 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
674 qDebug("SaveAB::checking resource..." ); 674 qDebug("SaveAB::checking resource..." );
675 if ( (*it)->readOnly() ) 675 if ( (*it)->readOnly() )
676 qDebug("resource is readonly." ); 676 qDebug("resource is readonly." );
677 if ( (*it)->isOpen() ) 677 if ( (*it)->isOpen() )
678 qDebug("resource is open" ); 678 qDebug("resource is open" );
679 679
680 if ( !(*it)->readOnly() && (*it)->isOpen() ) { 680 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
681 Ticket *ticket = requestSaveTicket( *it ); 681 Ticket *ticket = requestSaveTicket( *it );
682 qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); 682 qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
683 if ( !ticket ) { 683 if ( !ticket ) {
684 qDebug( i18n( "Unable to save to resource '%1'. It is locked." ) 684 qDebug( i18n( "Unable to save to resource '%1'. It is locked." )
685 .arg( (*it)->resourceName() ) ); 685 .arg( (*it)->resourceName() ) );
686 return false; 686 return false;
687 } 687 }
688 688
689 //if ( !save( ticket ) ) 689 //if ( !save( ticket ) )
690 if ( ticket->resource() ) { 690 if ( ticket->resource() ) {
691 QString name = ticket->resource()->resourceName(); 691 QString name = ticket->resource()->resourceName();
692 if ( ! ticket->resource()->save( ticket ) ) 692 if ( ! ticket->resource()->save( ticket ) )
693 ok = false; 693 ok = false;
694 else 694 else
695 qDebug("StdAddressBook::resource saved '%s'", name.latin1() ); 695 qDebug("StdAddressBook::resource saved '%s'", name.latin1() );
696 696
697 } else 697 } else
698 ok = false; 698 ok = false;
699 699
700 } 700 }
701 } 701 }
702 return ok; 702 return ok;
703} 703}
704 704
705AddressBook::Iterator AddressBook::begin() 705AddressBook::Iterator AddressBook::begin()
706{ 706{
707 Iterator it = Iterator(); 707 Iterator it = Iterator();
708 it.d->mIt = d->mAddressees.begin(); 708 it.d->mIt = d->mAddressees.begin();
709 return it; 709 return it;
710} 710}
711 711
712AddressBook::ConstIterator AddressBook::begin() const 712AddressBook::ConstIterator AddressBook::begin() const
713{ 713{
714 ConstIterator it = ConstIterator(); 714 ConstIterator it = ConstIterator();
715 it.d->mIt = d->mAddressees.begin(); 715 it.d->mIt = d->mAddressees.begin();
716 return it; 716 return it;
717} 717}
718 718
719AddressBook::Iterator AddressBook::end() 719AddressBook::Iterator AddressBook::end()
720{ 720{
721 Iterator it = Iterator(); 721 Iterator it = Iterator();
722 it.d->mIt = d->mAddressees.end(); 722 it.d->mIt = d->mAddressees.end();
723 return it; 723 return it;
724} 724}
725 725
726AddressBook::ConstIterator AddressBook::end() const 726AddressBook::ConstIterator AddressBook::end() const
727{ 727{
728 ConstIterator it = ConstIterator(); 728 ConstIterator it = ConstIterator();
729 it.d->mIt = d->mAddressees.end(); 729 it.d->mIt = d->mAddressees.end();
730 return it; 730 return it;
731} 731}
732 732
733void AddressBook::clear() 733void AddressBook::clear()
734{ 734{
735 d->mAddressees.clear(); 735 d->mAddressees.clear();
736} 736}
737 737
738Ticket *AddressBook::requestSaveTicket( Resource *resource ) 738Ticket *AddressBook::requestSaveTicket( Resource *resource )
739{ 739{
740 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; 740 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl;
741 741
742 if ( !resource ) 742 if ( !resource )
743 { 743 {
744 qDebug("AddressBook::requestSaveTicket no resource" ); 744 qDebug("AddressBook::requestSaveTicket no resource" );
745 resource = standardResource(); 745 resource = standardResource();
746 } 746 }
747 747
748 KRES::Manager<Resource>::ActiveIterator it; 748 KRES::Manager<Resource>::ActiveIterator it;
749 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 749 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
750 if ( (*it) == resource ) { 750 if ( (*it) == resource ) {
751 if ( (*it)->readOnly() || !(*it)->isOpen() ) 751 if ( (*it)->readOnly() || !(*it)->isOpen() )
752 return 0; 752 return 0;
753 else 753 else
754 return (*it)->requestSaveTicket(); 754 return (*it)->requestSaveTicket();
755 } 755 }
756 } 756 }
757 757
758 return 0; 758 return 0;
759} 759}
760//void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); 760//void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false);
761void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) 761void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource )
762{ 762{
763 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { 763 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) {
764 //qDebug("block insert "); 764 //qDebug("block insert ");
765 return; 765 return;
766 } 766 }
767 //qDebug("inserting.... %s ",a.uid().latin1() ); 767 //qDebug("inserting.... %s ",a.uid().latin1() );
768 bool found = false; 768 bool found = false;
769 Addressee::List::Iterator it; 769 Addressee::List::Iterator it;
770 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { 770 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) {
771 if ( a.uid() == (*it).uid() ) { 771 if ( a.uid() == (*it).uid() ) {
772 772
773 bool changed = false; 773 bool changed = false;
774 Addressee addr = a; 774 Addressee addr = a;
775 if ( addr != (*it) ) 775 if ( addr != (*it) )
776 changed = true; 776 changed = true;
777 777
778 if ( takeResource ) { 778 if ( takeResource ) {
779 Resource * res = (*it).resource(); 779 Resource * res = (*it).resource();
780 (*it) = a; 780 (*it) = a;
781 (*it).setResource( res ); 781 (*it).setResource( res );
782 } else { 782 } else {
783 (*it) = a; 783 (*it) = a;
784 if ( (*it).resource() == 0 ) 784 if ( (*it).resource() == 0 )
785 (*it).setResource( standardResource() ); 785 (*it).setResource( standardResource() );
786 } 786 }
787 if ( changed ) { 787 if ( changed ) {
788 if ( setRev ) { 788 if ( setRev ) {
789 789
790 // get rid of micro seconds 790 // get rid of micro seconds
791 QDateTime dt = QDateTime::currentDateTime(); 791 QDateTime dt = QDateTime::currentDateTime();
792 QTime t = dt.time(); 792 QTime t = dt.time();
793 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 793 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
794 (*it).setRevision( dt ); 794 (*it).setRevision( dt );
795 } 795 }
796 (*it).setChanged( true ); 796 (*it).setChanged( true );
797 } 797 }
798 798
799 found = true; 799 found = true;
800 } else { 800 } else {
801 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 801 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
802 QString name = (*it).uid().mid( 19 ); 802 QString name = (*it).uid().mid( 19 );
803 Addressee b = a; 803 Addressee b = a;
804 QString id = b.getID( name ); 804 QString id = b.getID( name );
805 if ( ! id.isEmpty() ) { 805 if ( ! id.isEmpty() ) {
806 QString des = (*it).note(); 806 QString des = (*it).note();
807 int startN; 807 int startN;
808 if( (startN = des.find( id ) ) >= 0 ) { 808 if( (startN = des.find( id ) ) >= 0 ) {
809 int endN = des.find( ",", startN+1 ); 809 int endN = des.find( ",", startN+1 );
810 des = des.left( startN ) + des.mid( endN+1 ); 810 des = des.left( startN ) + des.mid( endN+1 );
811 (*it).setNote( des ); 811 (*it).setNote( des );
812 } 812 }
813 } 813 }
814 } 814 }
815 } 815 }
816 } 816 }
817 if ( found ) 817 if ( found )
818 return; 818 return;
819 d->mAddressees.append( a ); 819 d->mAddressees.append( a );
820 Addressee& addr = d->mAddressees.last(); 820 Addressee& addr = d->mAddressees.last();
821 if ( addr.resource() == 0 ) 821 if ( addr.resource() == 0 )
822 addr.setResource( standardResource() ); 822 addr.setResource( standardResource() );
823 823
824 addr.setChanged( true ); 824 addr.setChanged( true );
825} 825}
826 826
827void AddressBook::removeAddressee( const Addressee &a ) 827void AddressBook::removeAddressee( const Addressee &a )
828{ 828{
829 Iterator it; 829 Iterator it;
830 Iterator it2; 830 Iterator it2;
831 bool found = false; 831 bool found = false;
832 for ( it = begin(); it != end(); ++it ) { 832 for ( it = begin(); it != end(); ++it ) {
833 if ( a.uid() == (*it).uid() ) { 833 if ( a.uid() == (*it).uid() ) {
834 found = true; 834 found = true;
835 it2 = it; 835 it2 = it;
836 } else { 836 } else {
837 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 837 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
838 QString name = (*it).uid().mid( 19 ); 838 QString name = (*it).uid().mid( 19 );
839 Addressee b = a; 839 Addressee b = a;
840 QString id = b.getID( name ); 840 QString id = b.getID( name );
841 if ( ! id.isEmpty() ) { 841 if ( ! id.isEmpty() ) {
842 QString des = (*it).note(); 842 QString des = (*it).note();
843 if( des.find( id ) < 0 ) { 843 if( des.find( id ) < 0 ) {
844 des += id + ","; 844 des += id + ",";
845 (*it).setNote( des ); 845 (*it).setNote( des );
846 } 846 }
847 } 847 }
848 } 848 }
849 849
850 } 850 }
851 } 851 }
852 852
853 if ( found ) 853 if ( found )
854 removeAddressee( it2 ); 854 removeAddressee( it2 );
855 855
856} 856}
857 857
858void AddressBook::removeSyncAddressees( bool removeDeleted ) 858void AddressBook::removeSyncAddressees( bool removeDeleted )
859{ 859{
860 Iterator it = begin(); 860 Iterator it = begin();
861 Iterator it2 ; 861 Iterator it2 ;
862 QDateTime dt ( QDate( 2004,1,1) ); 862 QDateTime dt ( QDate( 2004,1,1) );
863 while ( it != end() ) { 863 while ( it != end() ) {
864 (*it).setRevision( dt ); 864 (*it).setRevision( dt );
865 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); 865 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" );
866 (*it).setIDStr(""); 866 (*it).setIDStr("");
867 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { 867 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) {
868 it2 = it; 868 it2 = it;
869 //qDebug("removing %s ",(*it).uid().latin1() ); 869 //qDebug("removing %s ",(*it).uid().latin1() );
870 ++it; 870 ++it;
871 removeAddressee( it2 ); 871 removeAddressee( it2 );
872 } else { 872 } else {
873 //qDebug("skipping %s ",(*it).uid().latin1() ); 873 //qDebug("skipping %s ",(*it).uid().latin1() );
874 ++it; 874 ++it;
875 } 875 }
876 } 876 }
877 deleteRemovedAddressees(); 877 deleteRemovedAddressees();
878} 878}
879 879
880void AddressBook::removeAddressee( const Iterator &it ) 880void AddressBook::removeAddressee( const Iterator &it )
881{ 881{
882 d->mRemovedAddressees.append( (*it) ); 882 d->mRemovedAddressees.append( (*it) );
883 d->mAddressees.remove( it.d->mIt ); 883 d->mAddressees.remove( it.d->mIt );
884} 884}
885 885
886AddressBook::Iterator AddressBook::find( const Addressee &a ) 886AddressBook::Iterator AddressBook::find( const Addressee &a )
887{ 887{
888 Iterator it; 888 Iterator it;
889 for ( it = begin(); it != end(); ++it ) { 889 for ( it = begin(); it != end(); ++it ) {
890 if ( a.uid() == (*it).uid() ) { 890 if ( a.uid() == (*it).uid() ) {
891 return it; 891 return it;
892 } 892 }
893 } 893 }
894 return end(); 894 return end();
895} 895}
896 896
897Addressee AddressBook::findByUid( const QString &uid ) 897Addressee AddressBook::findByUid( const QString &uid )
898{ 898{
899 Iterator it; 899 Iterator it;
900 for ( it = begin(); it != end(); ++it ) { 900 for ( it = begin(); it != end(); ++it ) {
901 if ( uid == (*it).uid() ) { 901 if ( uid == (*it).uid() ) {
902 return *it; 902 return *it;
903 } 903 }
904 } 904 }
905 return Addressee(); 905 return Addressee();
906} 906}
907void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) 907void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset )
908{ 908{
909 //qDebug("AddressBook::preExternSync "); 909 //qDebug("AddressBook::preExternSync ");
910 AddressBook::Iterator it; 910 AddressBook::Iterator it;
911 for ( it = begin(); it != end(); ++it ) { 911 for ( it = begin(); it != end(); ++it ) {
912 (*it).setID( csd, (*it).externalUID() ); 912 (*it).setID( csd, (*it).externalUID() );
913 (*it).computeCsum( csd ); 913 (*it).computeCsum( csd );
914 } 914 }
915 mergeAB( aBook ,csd, isSubset ); 915 mergeAB( aBook ,csd, isSubset );
916} 916}
917void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) 917void AddressBook::postExternSync( AddressBook* aBook , const QString& csd)
918{ 918{
919 //qDebug("AddressBook::postExternSync "); 919 //qDebug("AddressBook::postExternSync ");
920 AddressBook::Iterator it; 920 AddressBook::Iterator it;
921 for ( it = begin(); it != end(); ++it ) { 921 for ( it = begin(); it != end(); ++it ) {
922 // qDebug("check uid %s ", (*it).uid().latin1() ); 922 // qDebug("check uid %s ", (*it).uid().latin1() );
923 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || 923 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ||
924 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { 924 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) {
925 Addressee ad = aBook->findByUid( ( (*it).uid() )); 925 Addressee ad = aBook->findByUid( ( (*it).uid() ));
926 if ( ad.isEmpty() ) { 926 if ( ad.isEmpty() ) {
927 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); 927 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1());
928 } else { 928 } else {
929 (*it).computeCsum( csd ); 929 (*it).computeCsum( csd );
930 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) 930 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )
931 ad.setID( csd, (*it).externalUID() ); 931 ad.setID( csd, (*it).externalUID() );
932 ad.setCsum( csd, (*it).getCsum( csd ) ); 932 ad.setCsum( csd, (*it).getCsum( csd ) );
933 aBook->insertAddressee( ad ); 933 aBook->insertAddressee( ad );
934 } 934 }
935 } 935 }
936 } 936 }
937} 937}
938 938
939bool AddressBook::containsExternalUid( const QString& uid ) 939bool AddressBook::containsExternalUid( const QString& uid )
940{ 940{
941 Iterator it; 941 Iterator it;
942 for ( it = begin(); it != end(); ++it ) { 942 for ( it = begin(); it != end(); ++it ) {
943 if ( uid == (*it).externalUID( ) ) 943 if ( uid == (*it).externalUID( ) )
944 return true; 944 return true;
945 } 945 }
946 return false; 946 return false;
947} 947}
948Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) 948Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile )
949{ 949{
950 Iterator it; 950 Iterator it;
951 for ( it = begin(); it != end(); ++it ) { 951 for ( it = begin(); it != end(); ++it ) {
952 if ( uid == (*it).getID( profile ) ) 952 if ( uid == (*it).getID( profile ) )
953 return (*it); 953 return (*it);
954 } 954 }
955 return Addressee(); 955 return Addressee();
956} 956}
957void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) 957void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset )
958{ 958{
959 Iterator it; 959 Iterator it;
960 Addressee ad; 960 Addressee ad;
961 for ( it = begin(); it != end(); ++it ) { 961 for ( it = begin(); it != end(); ++it ) {
962 ad = aBook->findByExternUid( (*it).externalUID(), profile ); 962 ad = aBook->findByExternUid( (*it).externalUID(), profile );
963 if ( !ad.isEmpty() ) { 963 if ( !ad.isEmpty() ) {
964 (*it).mergeContact( ad ,isSubset); 964 (*it).mergeContact( ad ,isSubset);
965 } 965 }
966 } 966 }
967#if 0 967#if 0
968 // test only 968 // test only
969 for ( it = begin(); it != end(); ++it ) { 969 for ( it = begin(); it != end(); ++it ) {
970 970
971 qDebug("uid %s ", (*it).uid().latin1()); 971 qDebug("uid %s ", (*it).uid().latin1());
972 } 972 }
973#endif 973#endif
974} 974}
975 975
976#if 0 976#if 0
977Addressee::List AddressBook::getExternLastSyncAddressees() 977Addressee::List AddressBook::getExternLastSyncAddressees()
978{ 978{
979 Addressee::List results; 979 Addressee::List results;
980 980
981 Iterator it; 981 Iterator it;
982 for ( it = begin(); it != end(); ++it ) { 982 for ( it = begin(); it != end(); ++it ) {
983 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { 983 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) {
984 if ( (*it).familyName().left(4) == "!E: " ) 984 if ( (*it).familyName().left(4) == "!E: " )
985 results.append( *it ); 985 results.append( *it );
986 } 986 }
987 } 987 }
988 988
989 return results; 989 return results;
990} 990}
991#endif 991#endif
992void AddressBook::resetTempSyncStat() 992void AddressBook::resetTempSyncStat()
993{ 993{
994 Iterator it; 994 Iterator it;
995 for ( it = begin(); it != end(); ++it ) { 995 for ( it = begin(); it != end(); ++it ) {
996 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); 996 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL );
997 } 997 }
998 998
999} 999}
1000 1000
1001QStringList AddressBook:: uidList() 1001QStringList AddressBook:: uidList()
1002{ 1002{
1003 QStringList results; 1003 QStringList results;
1004 Iterator it; 1004 Iterator it;
1005 for ( it = begin(); it != end(); ++it ) { 1005 for ( it = begin(); it != end(); ++it ) {
1006 results.append( (*it).uid() ); 1006 results.append( (*it).uid() );
1007 } 1007 }
1008 return results; 1008 return results;
1009} 1009}
1010 1010
1011 1011
1012Addressee::List AddressBook::allAddressees() 1012Addressee::List AddressBook::allAddressees()
1013{ 1013{
1014 return d->mAddressees; 1014 return d->mAddressees;
1015 1015
1016} 1016}
1017 1017
1018Addressee::List AddressBook::findByName( const QString &name ) 1018Addressee::List AddressBook::findByName( const QString &name )
1019{ 1019{
1020 Addressee::List results; 1020 Addressee::List results;
1021 1021
1022 Iterator it; 1022 Iterator it;
1023 for ( it = begin(); it != end(); ++it ) { 1023 for ( it = begin(); it != end(); ++it ) {
1024 if ( name == (*it).realName() ) { 1024 if ( name == (*it).realName() ) {
1025 results.append( *it ); 1025 results.append( *it );
1026 } 1026 }
1027 } 1027 }
1028 1028
1029 return results; 1029 return results;
1030} 1030}
1031 1031
1032Addressee::List AddressBook::findByEmail( const QString &email ) 1032Addressee::List AddressBook::findByEmail( const QString &email )
1033{ 1033{
1034 Addressee::List results; 1034 Addressee::List results;
1035 QStringList mailList; 1035 QStringList mailList;
1036 1036
1037 Iterator it; 1037 Iterator it;
1038 for ( it = begin(); it != end(); ++it ) { 1038 for ( it = begin(); it != end(); ++it ) {
1039 mailList = (*it).emails(); 1039 mailList = (*it).emails();
1040 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { 1040 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) {
1041 if ( email == (*ite) ) { 1041 if ( email == (*ite) ) {
1042 results.append( *it ); 1042 results.append( *it );
1043 } 1043 }
1044 } 1044 }
1045 } 1045 }
1046 1046
1047 return results; 1047 return results;
1048} 1048}
1049 1049
1050Addressee::List AddressBook::findByCategory( const QString &category ) 1050Addressee::List AddressBook::findByCategory( const QString &category )
1051{ 1051{
1052 Addressee::List results; 1052 Addressee::List results;
1053 1053
1054 Iterator it; 1054 Iterator it;
1055 for ( it = begin(); it != end(); ++it ) { 1055 for ( it = begin(); it != end(); ++it ) {
1056 if ( (*it).hasCategory( category) ) { 1056 if ( (*it).hasCategory( category) ) {
1057 results.append( *it ); 1057 results.append( *it );
1058 } 1058 }
1059 } 1059 }
1060 1060
1061 return results; 1061 return results;
1062} 1062}
1063 1063
1064void AddressBook::dump() const 1064void AddressBook::dump() const
1065{ 1065{
1066 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; 1066 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl;
1067 1067
1068 ConstIterator it; 1068 ConstIterator it;
1069 for( it = begin(); it != end(); ++it ) { 1069 for( it = begin(); it != end(); ++it ) {
1070 (*it).dump(); 1070 (*it).dump();
1071 } 1071 }
1072 1072
1073 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; 1073 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl;
1074} 1074}
1075 1075
1076QString AddressBook::identifier() 1076QString AddressBook::identifier()
1077{ 1077{
1078 QStringList identifier; 1078 QStringList identifier;
1079 1079
1080 1080
1081 KRES::Manager<Resource>::ActiveIterator it; 1081 KRES::Manager<Resource>::ActiveIterator it;
1082 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 1082 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
1083 if ( !(*it)->identifier().isEmpty() ) 1083 if ( !(*it)->identifier().isEmpty() )
1084 identifier.append( (*it)->identifier() ); 1084 identifier.append( (*it)->identifier() );
1085 } 1085 }
1086 1086
1087 return identifier.join( ":" ); 1087 return identifier.join( ":" );
1088} 1088}
1089 1089
1090Field::List AddressBook::fields( int category ) 1090Field::List AddressBook::fields( int category )
1091{ 1091{
1092 if ( d->mAllFields.isEmpty() ) { 1092 if ( d->mAllFields.isEmpty() ) {
1093 d->mAllFields = Field::allFields(); 1093 d->mAllFields = Field::allFields();
1094 } 1094 }
1095 1095
1096 if ( category == Field::All ) return d->mAllFields; 1096 if ( category == Field::All ) return d->mAllFields;
1097 1097
1098 Field::List result; 1098 Field::List result;
1099 Field::List::ConstIterator it; 1099 Field::List::ConstIterator it;
1100 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { 1100 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) {
1101 if ( (*it)->category() & category ) result.append( *it ); 1101 if ( (*it)->category() & category ) result.append( *it );
1102 } 1102 }
1103 1103
1104 return result; 1104 return result;
1105} 1105}
1106 1106
1107bool AddressBook::addCustomField( const QString &label, int category, 1107bool AddressBook::addCustomField( const QString &label, int category,
1108 const QString &key, const QString &app ) 1108 const QString &key, const QString &app )
1109{ 1109{
1110 if ( d->mAllFields.isEmpty() ) { 1110 if ( d->mAllFields.isEmpty() ) {
1111 d->mAllFields = Field::allFields(); 1111 d->mAllFields = Field::allFields();
1112 } 1112 }
1113//US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; 1113//US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app;
1114 QString a = app.isNull() ? KGlobal::getAppName() : app; 1114 QString a = app.isNull() ? KGlobal::getAppName() : app;
1115 1115
1116 QString k = key.isNull() ? label : key; 1116 QString k = key.isNull() ? label : key;
1117 1117
1118 Field *field = Field::createCustomField( label, category, k, a ); 1118 Field *field = Field::createCustomField( label, category, k, a );
1119 1119
1120 if ( !field ) return false; 1120 if ( !field ) return false;
1121 1121
1122 d->mAllFields.append( field ); 1122 d->mAllFields.append( field );
1123 1123
1124 return true; 1124 return true;
1125} 1125}
1126 1126
1127QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) 1127QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab )
1128{ 1128{
1129 if (!ab.d) return s; 1129 if (!ab.d) return s;
1130 1130
1131 return s << ab.d->mAddressees; 1131 return s << ab.d->mAddressees;
1132} 1132}
1133 1133
1134QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) 1134QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab )
1135{ 1135{
1136 if (!ab.d) return s; 1136 if (!ab.d) return s;
1137 1137
1138 s >> ab.d->mAddressees; 1138 s >> ab.d->mAddressees;
1139 1139
1140 return s; 1140 return s;
1141} 1141}
1142 1142
1143bool AddressBook::addResource( Resource *resource ) 1143bool AddressBook::addResource( Resource *resource )
1144{ 1144{
1145 if ( !resource->open() ) { 1145 if ( !resource->open() ) {
1146 kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; 1146 kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl;
1147 return false; 1147 return false;
1148 } 1148 }
1149 1149
1150 resource->setAddressBook( this ); 1150 resource->setAddressBook( this );
1151 1151
1152 d->mManager->add( resource ); 1152 d->mManager->add( resource );
1153 return true; 1153 return true;
1154} 1154}
1155 1155
1156bool AddressBook::removeResource( Resource *resource ) 1156bool AddressBook::removeResource( Resource *resource )
1157{ 1157{
1158 resource->close(); 1158 resource->close();
1159 1159
1160 if ( resource == standardResource() ) 1160 if ( resource == standardResource() )
1161 d->mManager->setStandardResource( 0 ); 1161 d->mManager->setStandardResource( 0 );
1162 1162
1163 resource->setAddressBook( 0 ); 1163 resource->setAddressBook( 0 );
1164 1164
1165 d->mManager->remove( resource ); 1165 d->mManager->remove( resource );
1166 return true; 1166 return true;
1167} 1167}
1168 1168
1169QPtrList<Resource> AddressBook::resources() 1169QPtrList<Resource> AddressBook::resources()
1170{ 1170{
1171 QPtrList<Resource> list; 1171 QPtrList<Resource> list;
1172 1172
1173// qDebug("AddressBook::resources() 1"); 1173// qDebug("AddressBook::resources() 1");
1174 1174
1175 KRES::Manager<Resource>::ActiveIterator it; 1175 KRES::Manager<Resource>::ActiveIterator it;
1176 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 1176 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
1177 list.append( *it ); 1177 list.append( *it );
1178 1178
1179 return list; 1179 return list;
1180} 1180}
1181 1181
1182/*US 1182/*US
1183void AddressBook::setErrorHandler( ErrorHandler *handler ) 1183void AddressBook::setErrorHandler( ErrorHandler *handler )
1184{ 1184{
1185 delete d->mErrorHandler; 1185 delete d->mErrorHandler;
1186 d->mErrorHandler = handler; 1186 d->mErrorHandler = handler;
1187} 1187}
1188*/ 1188*/
1189 1189
1190void AddressBook::error( const QString& msg ) 1190void AddressBook::error( const QString& msg )
1191{ 1191{
1192/*US 1192/*US
1193 if ( !d->mErrorHandler ) // create default error handler 1193 if ( !d->mErrorHandler ) // create default error handler
1194 d->mErrorHandler = new ConsoleErrorHandler; 1194 d->mErrorHandler = new ConsoleErrorHandler;
1195 1195
1196 if ( d->mErrorHandler ) 1196 if ( d->mErrorHandler )
1197 d->mErrorHandler->error( msg ); 1197 d->mErrorHandler->error( msg );
1198 else 1198 else
1199 kdError(5700) << "no error handler defined" << endl; 1199 kdError(5700) << "no error handler defined" << endl;
1200*/ 1200*/
1201 kdDebug(5700) << "msg" << endl; 1201 kdDebug(5700) << "msg" << endl;
1202 qDebug(msg); 1202 qDebug(msg);
1203} 1203}
1204 1204
1205void AddressBook::deleteRemovedAddressees() 1205void AddressBook::deleteRemovedAddressees()
1206{ 1206{
1207 Addressee::List::Iterator it; 1207 Addressee::List::Iterator it;
1208 for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { 1208 for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) {
1209 Resource *resource = (*it).resource(); 1209 Resource *resource = (*it).resource();
1210 if ( resource && !resource->readOnly() && resource->isOpen() ) 1210 if ( resource && !resource->readOnly() && resource->isOpen() )
1211 resource->removeAddressee( *it ); 1211 resource->removeAddressee( *it );
1212 } 1212 }
1213 1213
1214 d->mRemovedAddressees.clear(); 1214 d->mRemovedAddressees.clear();
1215} 1215}
1216 1216
1217void AddressBook::setStandardResource( Resource *resource ) 1217void AddressBook::setStandardResource( Resource *resource )
1218{ 1218{
1219// qDebug("AddressBook::setStandardResource 1"); 1219// qDebug("AddressBook::setStandardResource 1");
1220 d->mManager->setStandardResource( resource ); 1220 d->mManager->setStandardResource( resource );
1221} 1221}
1222 1222
1223Resource *AddressBook::standardResource() 1223Resource *AddressBook::standardResource()
1224{ 1224{
1225 return d->mManager->standardResource(); 1225 return d->mManager->standardResource();
1226} 1226}
1227 1227
1228KRES::Manager<Resource> *AddressBook::resourceManager() 1228KRES::Manager<Resource> *AddressBook::resourceManager()
1229{ 1229{
1230 return d->mManager; 1230 return d->mManager;
1231} 1231}
1232 1232
1233void AddressBook::cleanUp() 1233void AddressBook::cleanUp()
1234{ 1234{
1235 KRES::Manager<Resource>::ActiveIterator it; 1235 KRES::Manager<Resource>::ActiveIterator it;
1236 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 1236 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
1237 if ( !(*it)->readOnly() && (*it)->isOpen() ) 1237 if ( !(*it)->readOnly() && (*it)->isOpen() )
1238 (*it)->cleanUp(); 1238 (*it)->cleanUp();
1239 } 1239 }
1240} 1240}
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index e56e46a..2f00a09 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,1856 +1,1856 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/*s 24/*s
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#include <kfiledialog.h> 35#include <kfiledialog.h>
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qcheckbox.h> 40#include <qcheckbox.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qprogressbar.h> 42#include <qprogressbar.h>
43#include <libkdepim/phoneaccess.h> 43#include <libkdepim/phoneaccess.h>
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46#include <qclipboard.h> 46#include <qclipboard.h>
47#include <qdir.h> 47#include <qdir.h>
48#include <qfile.h> 48#include <qfile.h>
49#include <qapplicaton.h> 49#include <qapplicaton.h>
50#include <qprogressbar.h> 50#include <qprogressbar.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qvbox.h> 53#include <qvbox.h>
54#include <kabc/addresseelist.h> 54#include <kabc/addresseelist.h>
55#include <kabc/errorhandler.h> 55#include <kabc/errorhandler.h>
56#include <kabc/resource.h> 56#include <kabc/resource.h>
57#include <kabc/vcardconverter.h> 57#include <kabc/vcardconverter.h>
58#include <kapplication.h> 58#include <kapplication.h>
59#include <kactionclasses.h> 59#include <kactionclasses.h>
60#include <kcmultidialog.h> 60#include <kcmultidialog.h>
61#include <kdebug.h> 61#include <kdebug.h>
62#include <kdeversion.h> 62#include <kdeversion.h>
63#include <kkeydialog.h> 63#include <kkeydialog.h>
64#include <kmessagebox.h> 64#include <kmessagebox.h>
65#include <kprinter.h> 65#include <kprinter.h>
66#include <kprotocolinfo.h> 66#include <kprotocolinfo.h>
67#include <kresources/selectdialog.h> 67#include <kresources/selectdialog.h>
68#include <kstandarddirs.h> 68#include <kstandarddirs.h>
69#include <ktempfile.h> 69#include <ktempfile.h>
70#include <kxmlguiclient.h> 70#include <kxmlguiclient.h>
71#include <kaboutdata.h> 71#include <kaboutdata.h>
72#include <libkdepim/categoryselectdialog.h> 72#include <libkdepim/categoryselectdialog.h>
73 73
74#include "addresseeutil.h" 74#include "addresseeutil.h"
75#include "addresseeeditordialog.h" 75#include "addresseeeditordialog.h"
76#include "extensionmanager.h" 76#include "extensionmanager.h"
77#include "kstdaction.h" 77#include "kstdaction.h"
78#include "kaddressbookservice.h" 78#include "kaddressbookservice.h"
79#include "ldapsearchdialog.h" 79#include "ldapsearchdialog.h"
80#include "printing/printingwizard.h" 80#include "printing/printingwizard.h"
81#else // KAB_EMBEDDED 81#else // KAB_EMBEDDED
82 82
83#include <kapplication.h> 83#include <kapplication.h>
84#include "KDGanttMinimizeSplitter.h" 84#include "KDGanttMinimizeSplitter.h"
85#include "kaddressbookmain.h" 85#include "kaddressbookmain.h"
86#include "kactioncollection.h" 86#include "kactioncollection.h"
87#include "addresseedialog.h" 87#include "addresseedialog.h"
88//US 88//US
89#include <addresseeview.h> 89#include <addresseeview.h>
90 90
91#include <qapp.h> 91#include <qapp.h>
92#include <qmenubar.h> 92#include <qmenubar.h>
93//#include <qtoolbar.h> 93//#include <qtoolbar.h>
94#include <qmessagebox.h> 94#include <qmessagebox.h>
95#include <kdebug.h> 95#include <kdebug.h>
96#include <kiconloader.h> // needed for SmallIcon 96#include <kiconloader.h> // needed for SmallIcon
97#include <kresources/kcmkresources.h> 97#include <kresources/kcmkresources.h>
98#include <ktoolbar.h> 98#include <ktoolbar.h>
99 99
100 100
101//#include <qlabel.h> 101//#include <qlabel.h>
102 102
103 103
104#ifndef DESKTOP_VERSION 104#ifndef DESKTOP_VERSION
105#include <qpe/ir.h> 105#include <qpe/ir.h>
106#include <qpe/qpemenubar.h> 106#include <qpe/qpemenubar.h>
107#include <qtopia/qcopenvelope_qws.h> 107#include <qtopia/qcopenvelope_qws.h>
108#else 108#else
109 109
110#include <qmenubar.h> 110#include <qmenubar.h>
111#endif 111#endif
112 112
113#endif // KAB_EMBEDDED 113#endif // KAB_EMBEDDED
114#include "kcmconfigs/kcmkabconfig.h" 114#include "kcmconfigs/kcmkabconfig.h"
115#include "kcmconfigs/kcmkdepimconfig.h" 115#include "kcmconfigs/kcmkdepimconfig.h"
116#include "kpimglobalprefs.h" 116#include "kpimglobalprefs.h"
117#include "externalapphandler.h" 117#include "externalapphandler.h"
118 118
119 119
120#include <kresources/selectdialog.h> 120#include <kresources/selectdialog.h>
121#include <kmessagebox.h> 121#include <kmessagebox.h>
122 122
123#include <picture.h> 123#include <picture.h>
124#include <resource.h> 124#include <resource.h>
125 125
126//US#include <qsplitter.h> 126//US#include <qsplitter.h>
127#include <qmap.h> 127#include <qmap.h>
128#include <qdir.h> 128#include <qdir.h>
129#include <qfile.h> 129#include <qfile.h>
130#include <qvbox.h> 130#include <qvbox.h>
131#include <qlayout.h> 131#include <qlayout.h>
132#include <qclipboard.h> 132#include <qclipboard.h>
133#include <qtextstream.h> 133#include <qtextstream.h>
134 134
135#include <libkdepim/categoryselectdialog.h> 135#include <libkdepim/categoryselectdialog.h>
136#include <kabc/vcardconverter.h> 136#include <kabc/vcardconverter.h>
137 137
138 138
139#include "addresseeutil.h" 139#include "addresseeutil.h"
140#include "undocmds.h" 140#include "undocmds.h"
141#include "addresseeeditordialog.h" 141#include "addresseeeditordialog.h"
142#include "viewmanager.h" 142#include "viewmanager.h"
143#include "details/detailsviewcontainer.h" 143#include "details/detailsviewcontainer.h"
144#include "kabprefs.h" 144#include "kabprefs.h"
145#include "xxportmanager.h" 145#include "xxportmanager.h"
146#include "incsearchwidget.h" 146#include "incsearchwidget.h"
147#include "jumpbuttonbar.h" 147#include "jumpbuttonbar.h"
148#include "extensionmanager.h" 148#include "extensionmanager.h"
149#include "addresseeconfig.h" 149#include "addresseeconfig.h"
150#include <kcmultidialog.h> 150#include <kcmultidialog.h>
151 151
152#ifdef _WIN32_ 152#ifdef _WIN32_
153 153
154#include "kaimportoldialog.h" 154#include "kaimportoldialog.h"
155#else 155#else
156#include <unistd.h> 156#include <unistd.h>
157#endif 157#endif
158// sync includes 158// sync includes
159#include <libkdepim/ksyncprofile.h> 159#include <libkdepim/ksyncprofile.h>
160#include <libkdepim/ksyncprefsdialog.h> 160#include <libkdepim/ksyncprefsdialog.h>
161 161
162class KAex2phonePrefs : public QDialog 162class KAex2phonePrefs : public QDialog
163{ 163{
164 public: 164 public:
165 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 165 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
166 QDialog( parent, name, true ) 166 QDialog( parent, name, true )
167 { 167 {
168 setCaption( i18n("Export to phone options") ); 168 setCaption( i18n("Export to phone options") );
169 QVBoxLayout* lay = new QVBoxLayout( this ); 169 QVBoxLayout* lay = new QVBoxLayout( this );
170 lay->setSpacing( 3 ); 170 lay->setSpacing( 3 );
171 lay->setMargin( 3 ); 171 lay->setMargin( 3 );
172 QLabel *lab; 172 QLabel *lab;
173 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 173 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
174 lab->setAlignment (AlignHCenter ); 174 lab->setAlignment (AlignHCenter );
175 QHBox* temphb; 175 QHBox* temphb;
176 temphb = new QHBox( this ); 176 temphb = new QHBox( this );
177 new QLabel( i18n("I/O device: "), temphb ); 177 new QLabel( i18n("I/O device: "), temphb );
178 mPhoneDevice = new QLineEdit( temphb); 178 mPhoneDevice = new QLineEdit( temphb);
179 lay->addWidget( temphb ); 179 lay->addWidget( temphb );
180 temphb = new QHBox( this ); 180 temphb = new QHBox( this );
181 new QLabel( i18n("Connection: "), temphb ); 181 new QLabel( i18n("Connection: "), temphb );
182 mPhoneConnection = new QLineEdit( temphb); 182 mPhoneConnection = new QLineEdit( temphb);
183 lay->addWidget( temphb ); 183 lay->addWidget( temphb );
184 temphb = new QHBox( this ); 184 temphb = new QHBox( this );
185 new QLabel( i18n("Model(opt.): "), temphb ); 185 new QLabel( i18n("Model(opt.): "), temphb );
186 mPhoneModel = new QLineEdit( temphb); 186 mPhoneModel = new QLineEdit( temphb);
187 lay->addWidget( temphb ); 187 lay->addWidget( temphb );
188 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 188 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
189 // lay->addWidget( mWriteToSim ); 189 // lay->addWidget( mWriteToSim );
190 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 190 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
191 lab->setAlignment (AlignHCenter ); 191 lab->setAlignment (AlignHCenter );
192 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 192 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
193 lay->addWidget( ok ); 193 lay->addWidget( ok );
194 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 194 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
195 lay->addWidget( cancel ); 195 lay->addWidget( cancel );
196 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 196 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
197 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 197 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
198 resize( 220, 240 ); 198 resize( 220, 240 );
199 199
200 } 200 }
201 201
202public: 202public:
203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
204 QCheckBox* mWriteToSim; 204 QCheckBox* mWriteToSim;
205}; 205};
206 206
207 207
208bool pasteWithNewUid = true; 208bool pasteWithNewUid = true;
209 209
210#ifdef KAB_EMBEDDED 210#ifdef KAB_EMBEDDED
211KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 211KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
212 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 212 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
213 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 213 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
214 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 214 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
215#else //KAB_EMBEDDED 215#else //KAB_EMBEDDED
216KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 216KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
217 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 217 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
218 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 218 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
219 mReadWrite( readWrite ), mModified( false ) 219 mReadWrite( readWrite ), mModified( false )
220#endif //KAB_EMBEDDED 220#endif //KAB_EMBEDDED
221{ 221{
222 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 222 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
223 // syncManager->setBlockSave(false); 223 // syncManager->setBlockSave(false);
224 mExtensionBarSplitter = 0; 224 mExtensionBarSplitter = 0;
225 mIsPart = !parent->inherits( "KAddressBookMain" ); 225 mIsPart = !parent->inherits( "KAddressBookMain" );
226 mAddressBook = KABC::StdAddressBook::self(); 226 mAddressBook = KABC::StdAddressBook::self();
227 KABC::StdAddressBook::setAutomaticSave( false ); 227 KABC::StdAddressBook::setAutomaticSave( false );
228 228
229#ifndef KAB_EMBEDDED 229#ifndef KAB_EMBEDDED
230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
231#endif //KAB_EMBEDDED 231#endif //KAB_EMBEDDED
232 232
233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
234 SLOT( addressBookChanged() ) ); 234 SLOT( addressBookChanged() ) );
235 235
236#if 0 236#if 0
237 // LP moved to addressbook init method 237 // LP moved to addressbook init method
238 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 238 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
239 "X-Department", "KADDRESSBOOK" ); 239 "X-Department", "KADDRESSBOOK" );
240 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 240 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
241 "X-Profession", "KADDRESSBOOK" ); 241 "X-Profession", "KADDRESSBOOK" );
242 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 242 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
243 "X-AssistantsName", "KADDRESSBOOK" ); 243 "X-AssistantsName", "KADDRESSBOOK" );
244 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 244 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
245 "X-ManagersName", "KADDRESSBOOK" ); 245 "X-ManagersName", "KADDRESSBOOK" );
246 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 246 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
247 "X-SpousesName", "KADDRESSBOOK" ); 247 "X-SpousesName", "KADDRESSBOOK" );
248 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 248 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
249 "X-Office", "KADDRESSBOOK" ); 249 "X-Office", "KADDRESSBOOK" );
250 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 250 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
251 "X-IMAddress", "KADDRESSBOOK" ); 251 "X-IMAddress", "KADDRESSBOOK" );
252 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 252 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
253 "X-Anniversary", "KADDRESSBOOK" ); 253 "X-Anniversary", "KADDRESSBOOK" );
254 254
255 //US added this field to become compatible with Opie/qtopia addressbook 255 //US added this field to become compatible with Opie/qtopia addressbook
256 // values can be "female" or "male" or "". An empty field represents undefined. 256 // values can be "female" or "male" or "". An empty field represents undefined.
257 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 257 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
258 "X-Gender", "KADDRESSBOOK" ); 258 "X-Gender", "KADDRESSBOOK" );
259 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 259 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
260 "X-Children", "KADDRESSBOOK" ); 260 "X-Children", "KADDRESSBOOK" );
261 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 261 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
262 "X-FreeBusyUrl", "KADDRESSBOOK" ); 262 "X-FreeBusyUrl", "KADDRESSBOOK" );
263#endif 263#endif
264 initGUI(); 264 initGUI();
265 265
266 mIncSearchWidget->setFocus(); 266 mIncSearchWidget->setFocus();
267 267
268 268
269 connect( mViewManager, SIGNAL( selected( const QString& ) ), 269 connect( mViewManager, SIGNAL( selected( const QString& ) ),
270 SLOT( setContactSelected( const QString& ) ) ); 270 SLOT( setContactSelected( const QString& ) ) );
271 connect( mViewManager, SIGNAL( executed( const QString& ) ), 271 connect( mViewManager, SIGNAL( executed( const QString& ) ),
272 SLOT( executeContact( const QString& ) ) ); 272 SLOT( executeContact( const QString& ) ) );
273 273
274 connect( mViewManager, SIGNAL( deleteRequest( ) ), 274 connect( mViewManager, SIGNAL( deleteRequest( ) ),
275 SLOT( deleteContacts( ) ) ); 275 SLOT( deleteContacts( ) ) );
276 connect( mViewManager, SIGNAL( modified() ), 276 connect( mViewManager, SIGNAL( modified() ),
277 SLOT( setModified() ) ); 277 SLOT( setModified() ) );
278 278
279 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 279 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
280 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 280 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
281 281
282 connect( mXXPortManager, SIGNAL( modified() ), 282 connect( mXXPortManager, SIGNAL( modified() ),
283 SLOT( setModified() ) ); 283 SLOT( setModified() ) );
284 284
285 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 285 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
286 SLOT( incrementalSearch( const QString& ) ) ); 286 SLOT( incrementalSearch( const QString& ) ) );
287 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 287 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
288 mJumpButtonBar, SLOT( recreateButtons() ) ); 288 mJumpButtonBar, SLOT( recreateButtons() ) );
289 289
290 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 290 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
291 SLOT( sendMail( const QString& ) ) ); 291 SLOT( sendMail( const QString& ) ) );
292 292
293 293
294 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 294 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
295 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 295 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
296 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 296 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
297 297
298 298
299#ifndef KAB_EMBEDDED 299#ifndef KAB_EMBEDDED
300 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 300 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
301 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 301 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
302 302
303 connect( mDetails, SIGNAL( browse( const QString& ) ), 303 connect( mDetails, SIGNAL( browse( const QString& ) ),
304 SLOT( browse( const QString& ) ) ); 304 SLOT( browse( const QString& ) ) );
305 305
306 306
307 mAddressBookService = new KAddressBookService( this ); 307 mAddressBookService = new KAddressBookService( this );
308 308
309#endif //KAB_EMBEDDED 309#endif //KAB_EMBEDDED
310 310
311 mMessageTimer = new QTimer( this ); 311 mMessageTimer = new QTimer( this );
312 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 312 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
313 mEditorDialog = 0; 313 mEditorDialog = 0;
314 createAddresseeEditorDialog( this ); 314 createAddresseeEditorDialog( this );
315 setModified( false ); 315 setModified( false );
316 mBRdisabled = 0; 316 mBRdisabled = false;
317#ifndef DESKTOP_VERSION 317#ifndef DESKTOP_VERSION
318 infrared = 0; 318 infrared = 0;
319#endif 319#endif
320 toggleBeamReceive( ); 320 //toggleBeamReceive( );
321} 321}
322 322
323KABCore::~KABCore() 323KABCore::~KABCore()
324{ 324{
325 // save(); 325 // save();
326 //saveSettings(); 326 //saveSettings();
327 //KABPrefs::instance()->writeConfig(); 327 //KABPrefs::instance()->writeConfig();
328 delete AddresseeConfig::instance(); 328 delete AddresseeConfig::instance();
329 mAddressBook = 0; 329 mAddressBook = 0;
330 KABC::StdAddressBook::close(); 330 KABC::StdAddressBook::close();
331 331
332 delete syncManager; 332 delete syncManager;
333#ifndef DESKTOP_VERSION 333#ifndef DESKTOP_VERSION
334 if ( infrared ) 334 if ( infrared )
335 delete infrared; 335 delete infrared;
336#endif 336#endif
337} 337}
338void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 338void KABCore::receive( const QCString& cmsg, const QByteArray& data )
339{ 339{
340 qDebug("KA: QCOP message received: %s ", cmsg.data() ); 340 qDebug("KA: QCOP message received: %s ", cmsg.data() );
341 if ( cmsg == "setDocument(QString)" ) { 341 if ( cmsg == "setDocument(QString)" ) {
342 QDataStream stream( data, IO_ReadOnly ); 342 QDataStream stream( data, IO_ReadOnly );
343 QString fileName; 343 QString fileName;
344 stream >> fileName; 344 stream >> fileName;
345 recieve( fileName ); 345 recieve( fileName );
346 return; 346 return;
347 } 347 }
348} 348}
349void KABCore::toggleBeamReceive( ) 349void KABCore::toggleBeamReceive( )
350{ 350{
351 if ( mBRdisabled ) 351 if ( mBRdisabled )
352 return; 352 return;
353#ifndef DESKTOP_VERSION 353#ifndef DESKTOP_VERSION
354 if ( infrared ) { 354 if ( infrared ) {
355 qDebug("AB disable BeamReceive "); 355 qDebug("AB disable BeamReceive ");
356 delete infrared; 356 delete infrared;
357 infrared = 0; 357 infrared = 0;
358 mActionBR->setChecked(false); 358 mActionBR->setChecked(false);
359 return; 359 return;
360 } 360 }
361 qDebug("AB enable BeamReceive "); 361 qDebug("AB enable BeamReceive ");
362 mActionBR->setChecked(true); 362 mActionBR->setChecked(true);
363 363
364 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 364 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
365 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 365 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
366#endif 366#endif
367} 367}
368 368
369 369
370void KABCore::disableBR(bool b) 370void KABCore::disableBR(bool b)
371{ 371{
372#ifndef DESKTOP_VERSION 372#ifndef DESKTOP_VERSION
373 if ( b ) { 373 if ( b ) {
374 if ( infrared ) { 374 if ( infrared ) {
375 toggleBeamReceive( ); 375 toggleBeamReceive( );
376 } 376 }
377 mBRdisabled = true; 377 mBRdisabled = true;
378 } else { 378 } else {
379 if ( mBRdisabled ) { 379 if ( mBRdisabled ) {
380 mBRdisabled = false; 380 mBRdisabled = false;
381 //toggleBeamReceive( ); 381 //toggleBeamReceive( );
382 } 382 }
383 } 383 }
384#endif 384#endif
385 385
386} 386}
387void KABCore::recieve( QString fn ) 387void KABCore::recieve( QString fn )
388{ 388{
389 //qDebug("KABCore::recieve "); 389 //qDebug("KABCore::recieve ");
390 int count = mAddressBook->importFromFile( fn, true ); 390 int count = mAddressBook->importFromFile( fn, true );
391 if ( count ) 391 if ( count )
392 setModified( true ); 392 setModified( true );
393 mViewManager->refreshView(); 393 mViewManager->refreshView();
394 message(i18n("%1 contact(s) received!").arg( count )); 394 message(i18n("%1 contact(s) received!").arg( count ));
395 topLevelWidget()->showMaximized(); 395 topLevelWidget()->showMaximized();
396 topLevelWidget()->raise(); 396 topLevelWidget()->raise();
397} 397}
398void KABCore::restoreSettings() 398void KABCore::restoreSettings()
399{ 399{
400 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 400 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
401 401
402 bool state; 402 bool state;
403 403
404 if (mMultipleViewsAtOnce) 404 if (mMultipleViewsAtOnce)
405 state = KABPrefs::instance()->mDetailsPageVisible; 405 state = KABPrefs::instance()->mDetailsPageVisible;
406 else 406 else
407 state = false; 407 state = false;
408 408
409 mActionDetails->setChecked( state ); 409 mActionDetails->setChecked( state );
410 setDetailsVisible( state ); 410 setDetailsVisible( state );
411 411
412 state = KABPrefs::instance()->mJumpButtonBarVisible; 412 state = KABPrefs::instance()->mJumpButtonBarVisible;
413 413
414 mActionJumpBar->setChecked( state ); 414 mActionJumpBar->setChecked( state );
415 setJumpButtonBarVisible( state ); 415 setJumpButtonBarVisible( state );
416/*US 416/*US
417 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 417 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
418 if ( splitterSize.count() == 0 ) { 418 if ( splitterSize.count() == 0 ) {
419 splitterSize.append( width() / 2 ); 419 splitterSize.append( width() / 2 );
420 splitterSize.append( width() / 2 ); 420 splitterSize.append( width() / 2 );
421 } 421 }
422 mMiniSplitter->setSizes( splitterSize ); 422 mMiniSplitter->setSizes( splitterSize );
423 if ( mExtensionBarSplitter ) { 423 if ( mExtensionBarSplitter ) {
424 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 424 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
425 if ( splitterSize.count() == 0 ) { 425 if ( splitterSize.count() == 0 ) {
426 splitterSize.append( width() / 2 ); 426 splitterSize.append( width() / 2 );
427 splitterSize.append( width() / 2 ); 427 splitterSize.append( width() / 2 );
428 } 428 }
429 mExtensionBarSplitter->setSizes( splitterSize ); 429 mExtensionBarSplitter->setSizes( splitterSize );
430 430
431 } 431 }
432*/ 432*/
433 mViewManager->restoreSettings(); 433 mViewManager->restoreSettings();
434 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 434 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
435 mExtensionManager->restoreSettings(); 435 mExtensionManager->restoreSettings();
436#ifdef DESKTOP_VERSION 436#ifdef DESKTOP_VERSION
437 int wid = width(); 437 int wid = width();
438 if ( wid < 10 ) 438 if ( wid < 10 )
439 wid = 400; 439 wid = 400;
440#else 440#else
441 int wid = QApplication::desktop()->width(); 441 int wid = QApplication::desktop()->width();
442 if ( wid < 640 ) 442 if ( wid < 640 )
443 wid = QApplication::desktop()->height(); 443 wid = QApplication::desktop()->height();
444#endif 444#endif
445 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 445 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
446 if ( true /*splitterSize.count() == 0*/ ) { 446 if ( true /*splitterSize.count() == 0*/ ) {
447 splitterSize.append( wid / 2 ); 447 splitterSize.append( wid / 2 );
448 splitterSize.append( wid / 2 ); 448 splitterSize.append( wid / 2 );
449 } 449 }
450 mMiniSplitter->setSizes( splitterSize ); 450 mMiniSplitter->setSizes( splitterSize );
451 if ( mExtensionBarSplitter ) { 451 if ( mExtensionBarSplitter ) {
452 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 452 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
453 if ( true /*splitterSize.count() == 0*/ ) { 453 if ( true /*splitterSize.count() == 0*/ ) {
454 splitterSize.append( wid / 2 ); 454 splitterSize.append( wid / 2 );
455 splitterSize.append( wid / 2 ); 455 splitterSize.append( wid / 2 );
456 } 456 }
457 mExtensionBarSplitter->setSizes( splitterSize ); 457 mExtensionBarSplitter->setSizes( splitterSize );
458 458
459 } 459 }
460 460
461 461
462} 462}
463 463
464void KABCore::saveSettings() 464void KABCore::saveSettings()
465{ 465{
466 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 466 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
467 if ( mExtensionBarSplitter ) 467 if ( mExtensionBarSplitter )
468 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 468 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
469 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 469 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
470 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 470 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
471#ifndef KAB_EMBEDDED 471#ifndef KAB_EMBEDDED
472 472
473 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 473 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
474 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 474 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
475#endif //KAB_EMBEDDED 475#endif //KAB_EMBEDDED
476 mExtensionManager->saveSettings(); 476 mExtensionManager->saveSettings();
477 mViewManager->saveSettings(); 477 mViewManager->saveSettings();
478 478
479 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 479 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
480} 480}
481 481
482KABC::AddressBook *KABCore::addressBook() const 482KABC::AddressBook *KABCore::addressBook() const
483{ 483{
484 return mAddressBook; 484 return mAddressBook;
485} 485}
486 486
487KConfig *KABCore::config() 487KConfig *KABCore::config()
488{ 488{
489#ifndef KAB_EMBEDDED 489#ifndef KAB_EMBEDDED
490 return KABPrefs::instance()->config(); 490 return KABPrefs::instance()->config();
491#else //KAB_EMBEDDED 491#else //KAB_EMBEDDED
492 return KABPrefs::instance()->getConfig(); 492 return KABPrefs::instance()->getConfig();
493#endif //KAB_EMBEDDED 493#endif //KAB_EMBEDDED
494} 494}
495 495
496KActionCollection *KABCore::actionCollection() const 496KActionCollection *KABCore::actionCollection() const
497{ 497{
498 return mGUIClient->actionCollection(); 498 return mGUIClient->actionCollection();
499} 499}
500 500
501KABC::Field *KABCore::currentSearchField() const 501KABC::Field *KABCore::currentSearchField() const
502{ 502{
503 if (mIncSearchWidget) 503 if (mIncSearchWidget)
504 return mIncSearchWidget->currentField(); 504 return mIncSearchWidget->currentField();
505 else 505 else
506 return 0; 506 return 0;
507} 507}
508 508
509QStringList KABCore::selectedUIDs() const 509QStringList KABCore::selectedUIDs() const
510{ 510{
511 return mViewManager->selectedUids(); 511 return mViewManager->selectedUids();
512} 512}
513 513
514KABC::Resource *KABCore::requestResource( QWidget *parent ) 514KABC::Resource *KABCore::requestResource( QWidget *parent )
515{ 515{
516 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 516 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
517 517
518 QPtrList<KRES::Resource> kresResources; 518 QPtrList<KRES::Resource> kresResources;
519 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 519 QPtrListIterator<KABC::Resource> resIt( kabcResources );
520 KABC::Resource *resource; 520 KABC::Resource *resource;
521 while ( ( resource = resIt.current() ) != 0 ) { 521 while ( ( resource = resIt.current() ) != 0 ) {
522 ++resIt; 522 ++resIt;
523 if ( !resource->readOnly() ) { 523 if ( !resource->readOnly() ) {
524 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 524 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
525 if ( res ) 525 if ( res )
526 kresResources.append( res ); 526 kresResources.append( res );
527 } 527 }
528 } 528 }
529 529
530 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 530 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
531 return static_cast<KABC::Resource*>( res ); 531 return static_cast<KABC::Resource*>( res );
532} 532}
533 533
534#ifndef KAB_EMBEDDED 534#ifndef KAB_EMBEDDED
535KAboutData *KABCore::createAboutData() 535KAboutData *KABCore::createAboutData()
536#else //KAB_EMBEDDED 536#else //KAB_EMBEDDED
537void KABCore::createAboutData() 537void KABCore::createAboutData()
538#endif //KAB_EMBEDDED 538#endif //KAB_EMBEDDED
539{ 539{
540#ifndef KAB_EMBEDDED 540#ifndef KAB_EMBEDDED
541 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 541 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
542 "3.1", I18N_NOOP( "The KDE Address Book" ), 542 "3.1", I18N_NOOP( "The KDE Address Book" ),
543 KAboutData::License_GPL_V2, 543 KAboutData::License_GPL_V2,
544 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 544 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
545 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 545 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
546 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 546 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
547 about->addAuthor( "Cornelius Schumacher", 547 about->addAuthor( "Cornelius Schumacher",
548 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 548 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
549 "schumacher@kde.org" ); 549 "schumacher@kde.org" );
550 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 550 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
551 "mpilone@slac.com" ); 551 "mpilone@slac.com" );
552 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 552 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
553 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 553 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
554 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 554 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
555 "michel@klaralvdalens-datakonsult.se" ); 555 "michel@klaralvdalens-datakonsult.se" );
556 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 556 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
557 "hansen@kde.org" ); 557 "hansen@kde.org" );
558 558
559 return about; 559 return about;
560#endif //KAB_EMBEDDED 560#endif //KAB_EMBEDDED
561 561
562 QString version; 562 QString version;
563#include <../version> 563#include <../version>
564 QMessageBox::about( this, "About KAddressbook/Pi", 564 QMessageBox::about( this, "About KAddressbook/Pi",
565 "KAddressbook/Platform-independent\n" 565 "KAddressbook/Platform-independent\n"
566 "(KA/Pi) " +version + " - " + 566 "(KA/Pi) " +version + " - " +
567#ifdef DESKTOP_VERSION 567#ifdef DESKTOP_VERSION
568 "Desktop Edition\n" 568 "Desktop Edition\n"
569#else 569#else
570 "PDA-Edition\n" 570 "PDA-Edition\n"
571 "for: Zaurus 5500 / 7x0 / 8x0\n" 571 "for: Zaurus 5500 / 7x0 / 8x0\n"
572#endif 572#endif
573 573
574 "(c) 2004 Ulf Schenk\n" 574 "(c) 2004 Ulf Schenk\n"
575 "(c) 2004 Lutz Rogowski\n" 575 "(c) 2004 Lutz Rogowski\n"
576 "(c) 1997-2003, The KDE PIM Team\n" 576 "(c) 1997-2003, The KDE PIM Team\n"
577 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 577 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
578 "Don Sanders Original author\n" 578 "Don Sanders Original author\n"
579 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 579 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
580 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 580 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
581 "Greg Stern DCOP interface\n" 581 "Greg Stern DCOP interface\n"
582 "Mark Westcot Contact pinning\n" 582 "Mark Westcot Contact pinning\n"
583 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 583 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
584 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 584 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
585#ifdef _WIN32_ 585#ifdef _WIN32_
586 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 586 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
587#endif 587#endif
588 ); 588 );
589} 589}
590 590
591void KABCore::setContactSelected( const QString &uid ) 591void KABCore::setContactSelected( const QString &uid )
592{ 592{
593 KABC::Addressee addr = mAddressBook->findByUid( uid ); 593 KABC::Addressee addr = mAddressBook->findByUid( uid );
594 if ( !mDetails->isHidden() ) 594 if ( !mDetails->isHidden() )
595 mDetails->setAddressee( addr ); 595 mDetails->setAddressee( addr );
596 596
597 if ( !addr.isEmpty() ) { 597 if ( !addr.isEmpty() ) {
598 emit contactSelected( addr.formattedName() ); 598 emit contactSelected( addr.formattedName() );
599 KABC::Picture pic = addr.photo(); 599 KABC::Picture pic = addr.photo();
600 if ( pic.isIntern() ) { 600 if ( pic.isIntern() ) {
601//US emit contactSelected( pic.data() ); 601//US emit contactSelected( pic.data() );
602//US instead use: 602//US instead use:
603 QPixmap px; 603 QPixmap px;
604 if (pic.data().isNull() != true) 604 if (pic.data().isNull() != true)
605 { 605 {
606 px.convertFromImage(pic.data()); 606 px.convertFromImage(pic.data());
607 } 607 }
608 608
609 emit contactSelected( px ); 609 emit contactSelected( px );
610 } 610 }
611 } 611 }
612 612
613 613
614 mExtensionManager->setSelectionChanged(); 614 mExtensionManager->setSelectionChanged();
615 615
616 // update the actions 616 // update the actions
617 bool selected = !uid.isEmpty(); 617 bool selected = !uid.isEmpty();
618 618
619 if ( mReadWrite ) { 619 if ( mReadWrite ) {
620 mActionCut->setEnabled( selected ); 620 mActionCut->setEnabled( selected );
621 mActionPaste->setEnabled( selected ); 621 mActionPaste->setEnabled( selected );
622 } 622 }
623 623
624 mActionCopy->setEnabled( selected ); 624 mActionCopy->setEnabled( selected );
625 mActionDelete->setEnabled( selected ); 625 mActionDelete->setEnabled( selected );
626 mActionEditAddressee->setEnabled( selected ); 626 mActionEditAddressee->setEnabled( selected );
627 mActionMail->setEnabled( selected ); 627 mActionMail->setEnabled( selected );
628 mActionMailVCard->setEnabled( selected ); 628 mActionMailVCard->setEnabled( selected );
629 //if (mActionBeam) 629 //if (mActionBeam)
630 //mActionBeam->setEnabled( selected ); 630 //mActionBeam->setEnabled( selected );
631 631
632 if (mActionBeamVCard) 632 if (mActionBeamVCard)
633 mActionBeamVCard->setEnabled( selected ); 633 mActionBeamVCard->setEnabled( selected );
634 634
635 mActionExport2phone->setEnabled( selected ); 635 mActionExport2phone->setEnabled( selected );
636 mActionWhoAmI->setEnabled( selected ); 636 mActionWhoAmI->setEnabled( selected );
637 mActionCategories->setEnabled( selected ); 637 mActionCategories->setEnabled( selected );
638} 638}
639 639
640void KABCore::sendMail() 640void KABCore::sendMail()
641{ 641{
642 sendMail( mViewManager->selectedEmails().join( ", " ) ); 642 sendMail( mViewManager->selectedEmails().join( ", " ) );
643} 643}
644 644
645void KABCore::sendMail( const QString& emaillist ) 645void KABCore::sendMail( const QString& emaillist )
646{ 646{
647 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 647 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
648 if (emaillist.contains(",") > 0) 648 if (emaillist.contains(",") > 0)
649 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 649 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
650 else 650 else
651 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 651 ExternalAppHandler::instance()->mailToOneContact( emaillist );
652} 652}
653 653
654 654
655 655
656void KABCore::mailVCard() 656void KABCore::mailVCard()
657{ 657{
658 QStringList uids = mViewManager->selectedUids(); 658 QStringList uids = mViewManager->selectedUids();
659 if ( !uids.isEmpty() ) 659 if ( !uids.isEmpty() )
660 mailVCard( uids ); 660 mailVCard( uids );
661} 661}
662 662
663void KABCore::mailVCard( const QStringList& uids ) 663void KABCore::mailVCard( const QStringList& uids )
664{ 664{
665 QStringList urls; 665 QStringList urls;
666 666
667// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 667// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
668 668
669 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 669 QString dirName = "/tmp/" + KApplication::randomString( 8 );
670 670
671 671
672 672
673 QDir().mkdir( dirName, true ); 673 QDir().mkdir( dirName, true );
674 674
675 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 675 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
676 KABC::Addressee a = mAddressBook->findByUid( *it ); 676 KABC::Addressee a = mAddressBook->findByUid( *it );
677 677
678 if ( a.isEmpty() ) 678 if ( a.isEmpty() )
679 continue; 679 continue;
680 680
681 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 681 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
682 682
683 QString fileName = dirName + "/" + name; 683 QString fileName = dirName + "/" + name;
684 684
685 QFile outFile(fileName); 685 QFile outFile(fileName);
686 686
687 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 687 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
688 KABC::VCardConverter converter; 688 KABC::VCardConverter converter;
689 QString vcard; 689 QString vcard;
690 690
691 converter.addresseeToVCard( a, vcard ); 691 converter.addresseeToVCard( a, vcard );
692 692
693 QTextStream t( &outFile ); // use a text stream 693 QTextStream t( &outFile ); // use a text stream
694 t.setEncoding( QTextStream::UnicodeUTF8 ); 694 t.setEncoding( QTextStream::UnicodeUTF8 );
695 t << vcard; 695 t << vcard;
696 696
697 outFile.close(); 697 outFile.close();
698 698
699 urls.append( fileName ); 699 urls.append( fileName );
700 } 700 }
701 } 701 }
702 702
703 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 703 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
704 704
705 705
706/*US 706/*US
707 kapp->invokeMailer( QString::null, QString::null, QString::null, 707 kapp->invokeMailer( QString::null, QString::null, QString::null,
708 QString::null, // subject 708 QString::null, // subject
709 QString::null, // body 709 QString::null, // body
710 QString::null, 710 QString::null,
711 urls ); // attachments 711 urls ); // attachments
712*/ 712*/
713 713
714} 714}
715 715
716/** 716/**
717 Beams the "WhoAmI contact. 717 Beams the "WhoAmI contact.
718*/ 718*/
719void KABCore::beamMySelf() 719void KABCore::beamMySelf()
720{ 720{
721 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 721 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
722 if (!a.isEmpty()) 722 if (!a.isEmpty())
723 { 723 {
724 QStringList uids; 724 QStringList uids;
725 uids << a.uid(); 725 uids << a.uid();
726 726
727 beamVCard(uids); 727 beamVCard(uids);
728 } else { 728 } else {
729 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 729 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
730 730
731 731
732 } 732 }
733} 733}
734 734
735void KABCore::export2phone() 735void KABCore::export2phone()
736{ 736{
737 737
738 KAex2phonePrefs ex2phone; 738 KAex2phonePrefs ex2phone;
739 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 739 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
740 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 740 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
741 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 741 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
742 742
743 if ( !ex2phone.exec() ) { 743 if ( !ex2phone.exec() ) {
744 return; 744 return;
745 } 745 }
746 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 746 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
747 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 747 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
748 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 748 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
749 749
750 750
751 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 751 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
752 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 752 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
753 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 753 KPimGlobalPrefs::instance()->mEx2PhoneModel );
754 754
755 QStringList uids = mViewManager->selectedUids(); 755 QStringList uids = mViewManager->selectedUids();
756 if ( uids.isEmpty() ) 756 if ( uids.isEmpty() )
757 return; 757 return;
758 758
759 QString fileName = getPhoneFile(); 759 QString fileName = getPhoneFile();
760 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 760 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
761 return; 761 return;
762 762
763 message(i18n("Exporting to phone...")); 763 message(i18n("Exporting to phone..."));
764 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 764 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
765 765
766} 766}
767QString KABCore::getPhoneFile() 767QString KABCore::getPhoneFile()
768{ 768{
769#ifdef DESKTOP_VERSION 769#ifdef DESKTOP_VERSION
770 return locateLocal("tmp", "phonefile.vcf"); 770 return locateLocal("tmp", "phonefile.vcf");
771#else 771#else
772 return "/tmp/phonefile.vcf"; 772 return "/tmp/phonefile.vcf";
773#endif 773#endif
774 774
775} 775}
776void KABCore::writeToPhone( ) 776void KABCore::writeToPhone( )
777{ 777{
778 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 778 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
779 message(i18n("Export to phone finished!")); 779 message(i18n("Export to phone finished!"));
780 else 780 else
781 qDebug(i18n("Error exporting to phone")); 781 qDebug(i18n("Error exporting to phone"));
782} 782}
783void KABCore::beamVCard() 783void KABCore::beamVCard()
784{ 784{
785 QStringList uids = mViewManager->selectedUids(); 785 QStringList uids = mViewManager->selectedUids();
786 if ( !uids.isEmpty() ) 786 if ( !uids.isEmpty() )
787 beamVCard( uids ); 787 beamVCard( uids );
788} 788}
789 789
790 790
791void KABCore::beamVCard(const QStringList& uids) 791void KABCore::beamVCard(const QStringList& uids)
792{ 792{
793 793
794 // LR: we should use the /tmp dir on the Zaurus, 794 // LR: we should use the /tmp dir on the Zaurus,
795 // because: /tmp = RAM, (HOME)/kdepim = flash memory 795 // because: /tmp = RAM, (HOME)/kdepim = flash memory
796 796
797#ifdef DESKTOP_VERSION 797#ifdef DESKTOP_VERSION
798 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 798 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
799#else 799#else
800 QString fileName = "/tmp/kapibeamfile.vcf"; 800 QString fileName = "/tmp/kapibeamfile.vcf";
801#endif 801#endif
802 802
803 KABC::VCardConverter converter; 803 KABC::VCardConverter converter;
804 QString description; 804 QString description;
805 QString datastream; 805 QString datastream;
806 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 806 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
807 KABC::Addressee a = mAddressBook->findByUid( *it ); 807 KABC::Addressee a = mAddressBook->findByUid( *it );
808 808
809 if ( a.isEmpty() ) 809 if ( a.isEmpty() )
810 continue; 810 continue;
811 811
812 if (description.isEmpty()) 812 if (description.isEmpty())
813 description = a.formattedName(); 813 description = a.formattedName();
814 814
815 QString vcard; 815 QString vcard;
816 converter.addresseeToVCard( a, vcard ); 816 converter.addresseeToVCard( a, vcard );
817 int start = 0; 817 int start = 0;
818 int next; 818 int next;
819 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 819 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
820 int semi = vcard.find(";", next); 820 int semi = vcard.find(";", next);
821 int dopp = vcard.find(":", next); 821 int dopp = vcard.find(":", next);
822 int sep; 822 int sep;
823 if ( semi < dopp && semi >= 0 ) 823 if ( semi < dopp && semi >= 0 )
824 sep = semi ; 824 sep = semi ;
825 else 825 else
826 sep = dopp; 826 sep = dopp;
827 datastream +=vcard.mid( start, next - start); 827 datastream +=vcard.mid( start, next - start);
828 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 828 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
829 start = sep; 829 start = sep;
830 } 830 }
831 datastream += vcard.mid( start,vcard.length() ); 831 datastream += vcard.mid( start,vcard.length() );
832 } 832 }
833#ifndef DESKTOP_VERSION 833#ifndef DESKTOP_VERSION
834 QFile outFile(fileName); 834 QFile outFile(fileName);
835 if ( outFile.open(IO_WriteOnly) ) { 835 if ( outFile.open(IO_WriteOnly) ) {
836 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 836 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
837 QTextStream t( &outFile ); // use a text stream 837 QTextStream t( &outFile ); // use a text stream
838 //t.setEncoding( QTextStream::UnicodeUTF8 ); 838 //t.setEncoding( QTextStream::UnicodeUTF8 );
839 t.setEncoding( QTextStream::Latin1 ); 839 t.setEncoding( QTextStream::Latin1 );
840 t <<datastream.latin1(); 840 t <<datastream.latin1();
841 outFile.close(); 841 outFile.close();
842 Ir *ir = new Ir( this ); 842 Ir *ir = new Ir( this );
843 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 843 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
844 ir->send( fileName, description, "text/x-vCard" ); 844 ir->send( fileName, description, "text/x-vCard" );
845 } else { 845 } else {
846 qDebug("Error open temp beam file "); 846 qDebug("Error open temp beam file ");
847 return; 847 return;
848 } 848 }
849#endif 849#endif
850 850
851} 851}
852 852
853void KABCore::beamDone( Ir *ir ) 853void KABCore::beamDone( Ir *ir )
854{ 854{
855#ifndef DESKTOP_VERSION 855#ifndef DESKTOP_VERSION
856 delete ir; 856 delete ir;
857#endif 857#endif
858 topLevelWidget()->raise(); 858 topLevelWidget()->raise();
859 message( i18n("Beaming finished!") ); 859 message( i18n("Beaming finished!") );
860} 860}
861 861
862 862
863void KABCore::browse( const QString& url ) 863void KABCore::browse( const QString& url )
864{ 864{
865#ifndef KAB_EMBEDDED 865#ifndef KAB_EMBEDDED
866 kapp->invokeBrowser( url ); 866 kapp->invokeBrowser( url );
867#else //KAB_EMBEDDED 867#else //KAB_EMBEDDED
868 qDebug("KABCore::browse must be fixed"); 868 qDebug("KABCore::browse must be fixed");
869#endif //KAB_EMBEDDED 869#endif //KAB_EMBEDDED
870} 870}
871 871
872void KABCore::selectAllContacts() 872void KABCore::selectAllContacts()
873{ 873{
874 mViewManager->setSelected( QString::null, true ); 874 mViewManager->setSelected( QString::null, true );
875} 875}
876 876
877void KABCore::deleteContacts() 877void KABCore::deleteContacts()
878{ 878{
879 QStringList uidList = mViewManager->selectedUids(); 879 QStringList uidList = mViewManager->selectedUids();
880 deleteContacts( uidList ); 880 deleteContacts( uidList );
881} 881}
882 882
883void KABCore::deleteContacts( const QStringList &uids ) 883void KABCore::deleteContacts( const QStringList &uids )
884{ 884{
885 if ( uids.count() > 0 ) { 885 if ( uids.count() > 0 ) {
886 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 886 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
887 UndoStack::instance()->push( command ); 887 UndoStack::instance()->push( command );
888 RedoStack::instance()->clear(); 888 RedoStack::instance()->clear();
889 889
890 // now if we deleted anything, refresh 890 // now if we deleted anything, refresh
891 setContactSelected( QString::null ); 891 setContactSelected( QString::null );
892 setModified( true ); 892 setModified( true );
893 } 893 }
894} 894}
895 895
896void KABCore::copyContacts() 896void KABCore::copyContacts()
897{ 897{
898 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 898 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
899 899
900 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 900 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
901 901
902 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 902 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
903 903
904 QClipboard *cb = QApplication::clipboard(); 904 QClipboard *cb = QApplication::clipboard();
905 cb->setText( clipText ); 905 cb->setText( clipText );
906} 906}
907 907
908void KABCore::cutContacts() 908void KABCore::cutContacts()
909{ 909{
910 QStringList uidList = mViewManager->selectedUids(); 910 QStringList uidList = mViewManager->selectedUids();
911 911
912//US if ( uidList.size() > 0 ) { 912//US if ( uidList.size() > 0 ) {
913 if ( uidList.count() > 0 ) { 913 if ( uidList.count() > 0 ) {
914 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 914 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
915 UndoStack::instance()->push( command ); 915 UndoStack::instance()->push( command );
916 RedoStack::instance()->clear(); 916 RedoStack::instance()->clear();
917 917
918 setModified( true ); 918 setModified( true );
919 } 919 }
920} 920}
921 921
922void KABCore::pasteContacts() 922void KABCore::pasteContacts()
923{ 923{
924 QClipboard *cb = QApplication::clipboard(); 924 QClipboard *cb = QApplication::clipboard();
925 925
926 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 926 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
927 927
928 pasteContacts( list ); 928 pasteContacts( list );
929} 929}
930 930
931void KABCore::pasteContacts( KABC::Addressee::List &list ) 931void KABCore::pasteContacts( KABC::Addressee::List &list )
932{ 932{
933 KABC::Resource *resource = requestResource( this ); 933 KABC::Resource *resource = requestResource( this );
934 KABC::Addressee::List::Iterator it; 934 KABC::Addressee::List::Iterator it;
935 for ( it = list.begin(); it != list.end(); ++it ) 935 for ( it = list.begin(); it != list.end(); ++it )
936 (*it).setResource( resource ); 936 (*it).setResource( resource );
937 937
938 PwPasteCommand *command = new PwPasteCommand( this, list ); 938 PwPasteCommand *command = new PwPasteCommand( this, list );
939 UndoStack::instance()->push( command ); 939 UndoStack::instance()->push( command );
940 RedoStack::instance()->clear(); 940 RedoStack::instance()->clear();
941 941
942 setModified( true ); 942 setModified( true );
943} 943}
944 944
945void KABCore::setWhoAmI() 945void KABCore::setWhoAmI()
946{ 946{
947 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 947 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
948 948
949 if ( addrList.count() > 1 ) { 949 if ( addrList.count() > 1 ) {
950 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 950 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
951 return; 951 return;
952 } 952 }
953 953
954 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 954 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
955 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 955 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
956 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 956 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
957} 957}
958 958
959void KABCore::setCategories() 959void KABCore::setCategories()
960{ 960{
961 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 961 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
962 if ( !dlg.exec() ) 962 if ( !dlg.exec() )
963 return; 963 return;
964 964
965 bool merge = false; 965 bool merge = false;
966 QString msg = i18n( "Merge with existing categories?" ); 966 QString msg = i18n( "Merge with existing categories?" );
967 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 967 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
968 merge = true; 968 merge = true;
969 969
970 QStringList categories = dlg.selectedCategories(); 970 QStringList categories = dlg.selectedCategories();
971 971
972 QStringList uids = mViewManager->selectedUids(); 972 QStringList uids = mViewManager->selectedUids();
973 QStringList::Iterator it; 973 QStringList::Iterator it;
974 for ( it = uids.begin(); it != uids.end(); ++it ) { 974 for ( it = uids.begin(); it != uids.end(); ++it ) {
975 KABC::Addressee addr = mAddressBook->findByUid( *it ); 975 KABC::Addressee addr = mAddressBook->findByUid( *it );
976 if ( !addr.isEmpty() ) { 976 if ( !addr.isEmpty() ) {
977 if ( !merge ) 977 if ( !merge )
978 addr.setCategories( categories ); 978 addr.setCategories( categories );
979 else { 979 else {
980 QStringList addrCategories = addr.categories(); 980 QStringList addrCategories = addr.categories();
981 QStringList::Iterator catIt; 981 QStringList::Iterator catIt;
982 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 982 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
983 if ( !addrCategories.contains( *catIt ) ) 983 if ( !addrCategories.contains( *catIt ) )
984 addrCategories.append( *catIt ); 984 addrCategories.append( *catIt );
985 } 985 }
986 addr.setCategories( addrCategories ); 986 addr.setCategories( addrCategories );
987 } 987 }
988 988
989 mAddressBook->insertAddressee( addr ); 989 mAddressBook->insertAddressee( addr );
990 } 990 }
991 } 991 }
992 992
993 if ( uids.count() > 0 ) 993 if ( uids.count() > 0 )
994 setModified( true ); 994 setModified( true );
995} 995}
996 996
997void KABCore::setSearchFields( const KABC::Field::List &fields ) 997void KABCore::setSearchFields( const KABC::Field::List &fields )
998{ 998{
999 mIncSearchWidget->setFields( fields ); 999 mIncSearchWidget->setFields( fields );
1000} 1000}
1001 1001
1002void KABCore::incrementalSearch( const QString& text ) 1002void KABCore::incrementalSearch( const QString& text )
1003{ 1003{
1004 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1004 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1005} 1005}
1006 1006
1007void KABCore::setModified() 1007void KABCore::setModified()
1008{ 1008{
1009 setModified( true ); 1009 setModified( true );
1010} 1010}
1011 1011
1012void KABCore::setModifiedWOrefresh() 1012void KABCore::setModifiedWOrefresh()
1013{ 1013{
1014 // qDebug("KABCore::setModifiedWOrefresh() "); 1014 // qDebug("KABCore::setModifiedWOrefresh() ");
1015 mModified = true; 1015 mModified = true;
1016 mActionSave->setEnabled( mModified ); 1016 mActionSave->setEnabled( mModified );
1017#ifdef DESKTOP_VERSION 1017#ifdef DESKTOP_VERSION
1018 mDetails->refreshView(); 1018 mDetails->refreshView();
1019#endif 1019#endif
1020 1020
1021} 1021}
1022void KABCore::setModified( bool modified ) 1022void KABCore::setModified( bool modified )
1023{ 1023{
1024 mModified = modified; 1024 mModified = modified;
1025 mActionSave->setEnabled( mModified ); 1025 mActionSave->setEnabled( mModified );
1026 1026
1027 if ( modified ) 1027 if ( modified )
1028 mJumpButtonBar->recreateButtons(); 1028 mJumpButtonBar->recreateButtons();
1029 1029
1030 mViewManager->refreshView(); 1030 mViewManager->refreshView();
1031 mDetails->refreshView(); 1031 mDetails->refreshView();
1032 1032
1033} 1033}
1034 1034
1035bool KABCore::modified() const 1035bool KABCore::modified() const
1036{ 1036{
1037 return mModified; 1037 return mModified;
1038} 1038}
1039 1039
1040void KABCore::contactModified( const KABC::Addressee &addr ) 1040void KABCore::contactModified( const KABC::Addressee &addr )
1041{ 1041{
1042 1042
1043 Command *command = 0; 1043 Command *command = 0;
1044 QString uid; 1044 QString uid;
1045 1045
1046 // check if it exists already 1046 // check if it exists already
1047 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1047 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1048 if ( origAddr.isEmpty() ) 1048 if ( origAddr.isEmpty() )
1049 command = new PwNewCommand( mAddressBook, addr ); 1049 command = new PwNewCommand( mAddressBook, addr );
1050 else { 1050 else {
1051 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1051 command = new PwEditCommand( mAddressBook, origAddr, addr );
1052 uid = addr.uid(); 1052 uid = addr.uid();
1053 } 1053 }
1054 1054
1055 UndoStack::instance()->push( command ); 1055 UndoStack::instance()->push( command );
1056 RedoStack::instance()->clear(); 1056 RedoStack::instance()->clear();
1057 1057
1058 setModified( true ); 1058 setModified( true );
1059} 1059}
1060 1060
1061void KABCore::newContact() 1061void KABCore::newContact()
1062{ 1062{
1063 1063
1064 1064
1065 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1065 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1066 1066
1067 QPtrList<KRES::Resource> kresResources; 1067 QPtrList<KRES::Resource> kresResources;
1068 QPtrListIterator<KABC::Resource> it( kabcResources ); 1068 QPtrListIterator<KABC::Resource> it( kabcResources );
1069 KABC::Resource *resource; 1069 KABC::Resource *resource;
1070 while ( ( resource = it.current() ) != 0 ) { 1070 while ( ( resource = it.current() ) != 0 ) {
1071 ++it; 1071 ++it;
1072 if ( !resource->readOnly() ) { 1072 if ( !resource->readOnly() ) {
1073 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1073 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1074 if ( res ) 1074 if ( res )
1075 kresResources.append( res ); 1075 kresResources.append( res );
1076 } 1076 }
1077 } 1077 }
1078 1078
1079 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1079 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1080 resource = static_cast<KABC::Resource*>( res ); 1080 resource = static_cast<KABC::Resource*>( res );
1081 1081
1082 if ( resource ) { 1082 if ( resource ) {
1083 KABC::Addressee addr; 1083 KABC::Addressee addr;
1084 addr.setResource( resource ); 1084 addr.setResource( resource );
1085 mEditorDialog->setAddressee( addr ); 1085 mEditorDialog->setAddressee( addr );
1086 KApplication::execDialog ( mEditorDialog ); 1086 KApplication::execDialog ( mEditorDialog );
1087 1087
1088 } else 1088 } else
1089 return; 1089 return;
1090 1090
1091 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1091 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1092 1092
1093 1093
1094} 1094}
1095 1095
1096void KABCore::addEmail( QString aStr ) 1096void KABCore::addEmail( QString aStr )
1097{ 1097{
1098#ifndef KAB_EMBEDDED 1098#ifndef KAB_EMBEDDED
1099 QString fullName, email; 1099 QString fullName, email;
1100 1100
1101 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1101 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1102 1102
1103 // Try to lookup the addressee matching the email address 1103 // Try to lookup the addressee matching the email address
1104 bool found = false; 1104 bool found = false;
1105 QStringList emailList; 1105 QStringList emailList;
1106 KABC::AddressBook::Iterator it; 1106 KABC::AddressBook::Iterator it;
1107 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1107 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1108 emailList = (*it).emails(); 1108 emailList = (*it).emails();
1109 if ( emailList.contains( email ) > 0 ) { 1109 if ( emailList.contains( email ) > 0 ) {
1110 found = true; 1110 found = true;
1111 (*it).setNameFromString( fullName ); 1111 (*it).setNameFromString( fullName );
1112 editContact( (*it).uid() ); 1112 editContact( (*it).uid() );
1113 } 1113 }
1114 } 1114 }
1115 1115
1116 if ( !found ) { 1116 if ( !found ) {
1117 KABC::Addressee addr; 1117 KABC::Addressee addr;
1118 addr.setNameFromString( fullName ); 1118 addr.setNameFromString( fullName );
1119 addr.insertEmail( email, true ); 1119 addr.insertEmail( email, true );
1120 1120
1121 mAddressBook->insertAddressee( addr ); 1121 mAddressBook->insertAddressee( addr );
1122 mViewManager->refreshView( addr.uid() ); 1122 mViewManager->refreshView( addr.uid() );
1123 editContact( addr.uid() ); 1123 editContact( addr.uid() );
1124 } 1124 }
1125#else //KAB_EMBEDDED 1125#else //KAB_EMBEDDED
1126 qDebug("KABCore::addEmail finsih method"); 1126 qDebug("KABCore::addEmail finsih method");
1127#endif //KAB_EMBEDDED 1127#endif //KAB_EMBEDDED
1128} 1128}
1129 1129
1130void KABCore::importVCard( const KURL &url, bool showPreview ) 1130void KABCore::importVCard( const KURL &url, bool showPreview )
1131{ 1131{
1132 mXXPortManager->importVCard( url, showPreview ); 1132 mXXPortManager->importVCard( url, showPreview );
1133} 1133}
1134void KABCore::importFromOL() 1134void KABCore::importFromOL()
1135{ 1135{
1136#ifdef _WIN32_ 1136#ifdef _WIN32_
1137 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1137 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1138 idgl->exec(); 1138 idgl->exec();
1139 KABC::Addressee::List list = idgl->getAddressList(); 1139 KABC::Addressee::List list = idgl->getAddressList();
1140 if ( list.count() > 0 ) { 1140 if ( list.count() > 0 ) {
1141 KABC::Addressee::List listNew; 1141 KABC::Addressee::List listNew;
1142 KABC::Addressee::List listExisting; 1142 KABC::Addressee::List listExisting;
1143 KABC::Addressee::List::Iterator it; 1143 KABC::Addressee::List::Iterator it;
1144 KABC::AddressBook::Iterator iter; 1144 KABC::AddressBook::Iterator iter;
1145 for ( it = list.begin(); it != list.end(); ++it ) { 1145 for ( it = list.begin(); it != list.end(); ++it ) {
1146 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1146 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1147 listNew.append( (*it) ); 1147 listNew.append( (*it) );
1148 else 1148 else
1149 listExisting.append( (*it) ); 1149 listExisting.append( (*it) );
1150 } 1150 }
1151 if ( listExisting.count() > 0 ) 1151 if ( listExisting.count() > 0 )
1152 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1152 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1153 if ( listNew.count() > 0 ) { 1153 if ( listNew.count() > 0 ) {
1154 pasteWithNewUid = false; 1154 pasteWithNewUid = false;
1155 pasteContacts( listNew ); 1155 pasteContacts( listNew );
1156 pasteWithNewUid = true; 1156 pasteWithNewUid = true;
1157 } 1157 }
1158 } 1158 }
1159 delete idgl; 1159 delete idgl;
1160#endif 1160#endif
1161} 1161}
1162 1162
1163void KABCore::importVCard( const QString &vCard, bool showPreview ) 1163void KABCore::importVCard( const QString &vCard, bool showPreview )
1164{ 1164{
1165 mXXPortManager->importVCard( vCard, showPreview ); 1165 mXXPortManager->importVCard( vCard, showPreview );
1166} 1166}
1167 1167
1168//US added a second method without defaultparameter 1168//US added a second method without defaultparameter
1169void KABCore::editContact2() { 1169void KABCore::editContact2() {
1170 editContact( QString::null ); 1170 editContact( QString::null );
1171} 1171}
1172 1172
1173void KABCore::editContact( const QString &uid ) 1173void KABCore::editContact( const QString &uid )
1174{ 1174{
1175 1175
1176 if ( mExtensionManager->isQuickEditVisible() ) 1176 if ( mExtensionManager->isQuickEditVisible() )
1177 return; 1177 return;
1178 1178
1179 // First, locate the contact entry 1179 // First, locate the contact entry
1180 QString localUID = uid; 1180 QString localUID = uid;
1181 if ( localUID.isNull() ) { 1181 if ( localUID.isNull() ) {
1182 QStringList uidList = mViewManager->selectedUids(); 1182 QStringList uidList = mViewManager->selectedUids();
1183 if ( uidList.count() > 0 ) 1183 if ( uidList.count() > 0 )
1184 localUID = *( uidList.at( 0 ) ); 1184 localUID = *( uidList.at( 0 ) );
1185 } 1185 }
1186 1186
1187 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1187 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1188 if ( !addr.isEmpty() ) { 1188 if ( !addr.isEmpty() ) {
1189 mEditorDialog->setAddressee( addr ); 1189 mEditorDialog->setAddressee( addr );
1190 KApplication::execDialog ( mEditorDialog ); 1190 KApplication::execDialog ( mEditorDialog );
1191 } 1191 }
1192} 1192}
1193 1193
1194/** 1194/**
1195 Shows or edits the detail view for the given uid. If the uid is QString::null, 1195 Shows or edits the detail view for the given uid. If the uid is QString::null,
1196 the method will try to find a selected addressee in the view. 1196 the method will try to find a selected addressee in the view.
1197 */ 1197 */
1198void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1198void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1199{ 1199{
1200 if ( mMultipleViewsAtOnce ) 1200 if ( mMultipleViewsAtOnce )
1201 { 1201 {
1202 editContact( uid ); 1202 editContact( uid );
1203 } 1203 }
1204 else 1204 else
1205 { 1205 {
1206 setDetailsVisible( true ); 1206 setDetailsVisible( true );
1207 mActionDetails->setChecked(true); 1207 mActionDetails->setChecked(true);
1208 } 1208 }
1209 1209
1210} 1210}
1211 1211
1212void KABCore::save() 1212void KABCore::save()
1213{ 1213{
1214 if (syncManager->blockSave()) 1214 if (syncManager->blockSave())
1215 return; 1215 return;
1216 if ( !mModified ) 1216 if ( !mModified )
1217 return; 1217 return;
1218 1218
1219 syncManager->setBlockSave(true); 1219 syncManager->setBlockSave(true);
1220 QString text = i18n( "There was an error while attempting to save\n the " 1220 QString text = i18n( "There was an error while attempting to save\n the "
1221 "address book. Please check that some \nother application is " 1221 "address book. Please check that some \nother application is "
1222 "not using it. " ); 1222 "not using it. " );
1223 message(i18n("Saving addressbook ... ")); 1223 message(i18n("Saving addressbook ... "));
1224#ifndef KAB_EMBEDDED 1224#ifndef KAB_EMBEDDED
1225 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1225 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1226 if ( !b || !b->save() ) { 1226 if ( !b || !b->save() ) {
1227 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1227 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1228 } 1228 }
1229#else //KAB_EMBEDDED 1229#else //KAB_EMBEDDED
1230 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1230 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1231 if ( !b || !b->save() ) { 1231 if ( !b || !b->save() ) {
1232 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1232 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1233 } 1233 }
1234#endif //KAB_EMBEDDED 1234#endif //KAB_EMBEDDED
1235 1235
1236 message(i18n("Addressbook saved!")); 1236 message(i18n("Addressbook saved!"));
1237 setModified( false ); 1237 setModified( false );
1238 syncManager->setBlockSave(false); 1238 syncManager->setBlockSave(false);
1239} 1239}
1240 1240
1241 1241
1242void KABCore::undo() 1242void KABCore::undo()
1243{ 1243{
1244 UndoStack::instance()->undo(); 1244 UndoStack::instance()->undo();
1245 1245
1246 // Refresh the view 1246 // Refresh the view
1247 mViewManager->refreshView(); 1247 mViewManager->refreshView();
1248} 1248}
1249 1249
1250void KABCore::redo() 1250void KABCore::redo()
1251{ 1251{
1252 RedoStack::instance()->redo(); 1252 RedoStack::instance()->redo();
1253 1253
1254 // Refresh the view 1254 // Refresh the view
1255 mViewManager->refreshView(); 1255 mViewManager->refreshView();
1256} 1256}
1257 1257
1258void KABCore::setJumpButtonBarVisible( bool visible ) 1258void KABCore::setJumpButtonBarVisible( bool visible )
1259{ 1259{
1260 if (mMultipleViewsAtOnce) 1260 if (mMultipleViewsAtOnce)
1261 { 1261 {
1262 if ( visible ) 1262 if ( visible )
1263 mJumpButtonBar->show(); 1263 mJumpButtonBar->show();
1264 else 1264 else
1265 mJumpButtonBar->hide(); 1265 mJumpButtonBar->hide();
1266 } 1266 }
1267 else 1267 else
1268 { 1268 {
1269 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1269 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1270 if (mViewManager->isVisible()) 1270 if (mViewManager->isVisible())
1271 { 1271 {
1272 if ( visible ) 1272 if ( visible )
1273 mJumpButtonBar->show(); 1273 mJumpButtonBar->show();
1274 else 1274 else
1275 mJumpButtonBar->hide(); 1275 mJumpButtonBar->hide();
1276 } 1276 }
1277 else 1277 else
1278 { 1278 {
1279 mJumpButtonBar->hide(); 1279 mJumpButtonBar->hide();
1280 } 1280 }
1281 } 1281 }
1282} 1282}
1283 1283
1284 1284
1285void KABCore::setDetailsToState() 1285void KABCore::setDetailsToState()
1286{ 1286{
1287 setDetailsVisible( mActionDetails->isChecked() ); 1287 setDetailsVisible( mActionDetails->isChecked() );
1288} 1288}
1289 1289
1290 1290
1291 1291
1292void KABCore::setDetailsVisible( bool visible ) 1292void KABCore::setDetailsVisible( bool visible )
1293{ 1293{
1294 if (visible && mDetails->isHidden()) 1294 if (visible && mDetails->isHidden())
1295 { 1295 {
1296 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1296 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1297 if ( addrList.count() > 0 ) 1297 if ( addrList.count() > 0 )
1298 mDetails->setAddressee( addrList[ 0 ] ); 1298 mDetails->setAddressee( addrList[ 0 ] );
1299 } 1299 }
1300 1300
1301 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1301 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1302 // the listview and the detailview. We do that by changing the splitbar size. 1302 // the listview and the detailview. We do that by changing the splitbar size.
1303 if (mMultipleViewsAtOnce) 1303 if (mMultipleViewsAtOnce)
1304 { 1304 {
1305 if ( visible ) 1305 if ( visible )
1306 mDetails->show(); 1306 mDetails->show();
1307 else 1307 else
1308 mDetails->hide(); 1308 mDetails->hide();
1309 } 1309 }
1310 else 1310 else
1311 { 1311 {
1312 if ( visible ) { 1312 if ( visible ) {
1313 mViewManager->hide(); 1313 mViewManager->hide();
1314 mDetails->show(); 1314 mDetails->show();
1315 } 1315 }
1316 else { 1316 else {
1317 mViewManager->show(); 1317 mViewManager->show();
1318 mDetails->hide(); 1318 mDetails->hide();
1319 } 1319 }
1320 setJumpButtonBarVisible( !visible ); 1320 setJumpButtonBarVisible( !visible );
1321 } 1321 }
1322 1322
1323} 1323}
1324 1324
1325void KABCore::extensionChanged( int id ) 1325void KABCore::extensionChanged( int id )
1326{ 1326{
1327 //change the details view only for non desktop systems 1327 //change the details view only for non desktop systems
1328#ifndef DESKTOP_VERSION 1328#ifndef DESKTOP_VERSION
1329 1329
1330 if (id == 0) 1330 if (id == 0)
1331 { 1331 {
1332 //the user disabled the extension. 1332 //the user disabled the extension.
1333 1333
1334 if (mMultipleViewsAtOnce) 1334 if (mMultipleViewsAtOnce)
1335 { // enable detailsview again 1335 { // enable detailsview again
1336 setDetailsVisible( true ); 1336 setDetailsVisible( true );
1337 mActionDetails->setChecked( true ); 1337 mActionDetails->setChecked( true );
1338 } 1338 }
1339 else 1339 else
1340 { //go back to the listview 1340 { //go back to the listview
1341 setDetailsVisible( false ); 1341 setDetailsVisible( false );
1342 mActionDetails->setChecked( false ); 1342 mActionDetails->setChecked( false );
1343 mActionDetails->setEnabled(true); 1343 mActionDetails->setEnabled(true);
1344 } 1344 }
1345 1345
1346 } 1346 }
1347 else 1347 else
1348 { 1348 {
1349 //the user enabled the extension. 1349 //the user enabled the extension.
1350 setDetailsVisible( false ); 1350 setDetailsVisible( false );
1351 mActionDetails->setChecked( false ); 1351 mActionDetails->setChecked( false );
1352 1352
1353 if (!mMultipleViewsAtOnce) 1353 if (!mMultipleViewsAtOnce)
1354 { 1354 {
1355 mActionDetails->setEnabled(false); 1355 mActionDetails->setEnabled(false);
1356 } 1356 }
1357 1357
1358 mExtensionManager->setSelectionChanged(); 1358 mExtensionManager->setSelectionChanged();
1359 1359
1360 } 1360 }
1361 1361
1362#endif// DESKTOP_VERSION 1362#endif// DESKTOP_VERSION
1363 1363
1364} 1364}
1365 1365
1366 1366
1367void KABCore::extensionModified( const KABC::Addressee::List &list ) 1367void KABCore::extensionModified( const KABC::Addressee::List &list )
1368{ 1368{
1369 1369
1370 if ( list.count() != 0 ) { 1370 if ( list.count() != 0 ) {
1371 KABC::Addressee::List::ConstIterator it; 1371 KABC::Addressee::List::ConstIterator it;
1372 for ( it = list.begin(); it != list.end(); ++it ) 1372 for ( it = list.begin(); it != list.end(); ++it )
1373 mAddressBook->insertAddressee( *it ); 1373 mAddressBook->insertAddressee( *it );
1374 if ( list.count() > 1 ) 1374 if ( list.count() > 1 )
1375 setModified(); 1375 setModified();
1376 else 1376 else
1377 setModifiedWOrefresh(); 1377 setModifiedWOrefresh();
1378 } 1378 }
1379 if ( list.count() == 0 ) 1379 if ( list.count() == 0 )
1380 mViewManager->refreshView(); 1380 mViewManager->refreshView();
1381 else 1381 else
1382 mViewManager->refreshView( list[ 0 ].uid() ); 1382 mViewManager->refreshView( list[ 0 ].uid() );
1383 1383
1384 1384
1385 1385
1386} 1386}
1387 1387
1388QString KABCore::getNameByPhone( const QString &phone ) 1388QString KABCore::getNameByPhone( const QString &phone )
1389{ 1389{
1390#ifndef KAB_EMBEDDED 1390#ifndef KAB_EMBEDDED
1391 QRegExp r( "[/*/-/ ]" ); 1391 QRegExp r( "[/*/-/ ]" );
1392 QString localPhone( phone ); 1392 QString localPhone( phone );
1393 1393
1394 bool found = false; 1394 bool found = false;
1395 QString ownerName = ""; 1395 QString ownerName = "";
1396 KABC::AddressBook::Iterator iter; 1396 KABC::AddressBook::Iterator iter;
1397 KABC::PhoneNumber::List::Iterator phoneIter; 1397 KABC::PhoneNumber::List::Iterator phoneIter;
1398 KABC::PhoneNumber::List phoneList; 1398 KABC::PhoneNumber::List phoneList;
1399 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1399 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1400 phoneList = (*iter).phoneNumbers(); 1400 phoneList = (*iter).phoneNumbers();
1401 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1401 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1402 ++phoneIter) { 1402 ++phoneIter) {
1403 // Get rid of separator chars so just the numbers are compared. 1403 // Get rid of separator chars so just the numbers are compared.
1404 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1404 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1405 ownerName = (*iter).formattedName(); 1405 ownerName = (*iter).formattedName();
1406 found = true; 1406 found = true;
1407 } 1407 }
1408 } 1408 }
1409 } 1409 }
1410 1410
1411 return ownerName; 1411 return ownerName;
1412#else //KAB_EMBEDDED 1412#else //KAB_EMBEDDED
1413 qDebug("KABCore::getNameByPhone finsih method"); 1413 qDebug("KABCore::getNameByPhone finsih method");
1414 return ""; 1414 return "";
1415#endif //KAB_EMBEDDED 1415#endif //KAB_EMBEDDED
1416 1416
1417} 1417}
1418 1418
1419void KABCore::openConfigDialog() 1419void KABCore::openConfigDialog()
1420{ 1420{
1421 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1421 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1422 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1422 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1423 ConfigureDialog->addModule(kabcfg ); 1423 ConfigureDialog->addModule(kabcfg );
1424 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1424 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1425 ConfigureDialog->addModule(kdelibcfg ); 1425 ConfigureDialog->addModule(kdelibcfg );
1426 1426
1427 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1427 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1428 this, SLOT( configurationChanged() ) ); 1428 this, SLOT( configurationChanged() ) );
1429 connect( ConfigureDialog, SIGNAL( okClicked() ), 1429 connect( ConfigureDialog, SIGNAL( okClicked() ),
1430 this, SLOT( configurationChanged() ) ); 1430 this, SLOT( configurationChanged() ) );
1431 saveSettings(); 1431 saveSettings();
1432#ifndef DESKTOP_VERSION 1432#ifndef DESKTOP_VERSION
1433 ConfigureDialog->showMaximized(); 1433 ConfigureDialog->showMaximized();
1434#endif 1434#endif
1435 if ( ConfigureDialog->exec() ) 1435 if ( ConfigureDialog->exec() )
1436 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1436 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1437 delete ConfigureDialog; 1437 delete ConfigureDialog;
1438} 1438}
1439 1439
1440void KABCore::openLDAPDialog() 1440void KABCore::openLDAPDialog()
1441{ 1441{
1442#ifndef KAB_EMBEDDED 1442#ifndef KAB_EMBEDDED
1443 if ( !mLdapSearchDialog ) { 1443 if ( !mLdapSearchDialog ) {
1444 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1444 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1445 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1445 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1446 SLOT( refreshView() ) ); 1446 SLOT( refreshView() ) );
1447 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1447 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1448 SLOT( setModified() ) ); 1448 SLOT( setModified() ) );
1449 } else 1449 } else
1450 mLdapSearchDialog->restoreSettings(); 1450 mLdapSearchDialog->restoreSettings();
1451 1451
1452 if ( mLdapSearchDialog->isOK() ) 1452 if ( mLdapSearchDialog->isOK() )
1453 mLdapSearchDialog->exec(); 1453 mLdapSearchDialog->exec();
1454#else //KAB_EMBEDDED 1454#else //KAB_EMBEDDED
1455 qDebug("KABCore::openLDAPDialog() finsih method"); 1455 qDebug("KABCore::openLDAPDialog() finsih method");
1456#endif //KAB_EMBEDDED 1456#endif //KAB_EMBEDDED
1457} 1457}
1458 1458
1459void KABCore::print() 1459void KABCore::print()
1460{ 1460{
1461#ifndef KAB_EMBEDDED 1461#ifndef KAB_EMBEDDED
1462 KPrinter printer; 1462 KPrinter printer;
1463 if ( !printer.setup( this ) ) 1463 if ( !printer.setup( this ) )
1464 return; 1464 return;
1465 1465
1466 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1466 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1467 mViewManager->selectedUids(), this ); 1467 mViewManager->selectedUids(), this );
1468 1468
1469 wizard.exec(); 1469 wizard.exec();
1470#else //KAB_EMBEDDED 1470#else //KAB_EMBEDDED
1471 qDebug("KABCore::print() finsih method"); 1471 qDebug("KABCore::print() finsih method");
1472#endif //KAB_EMBEDDED 1472#endif //KAB_EMBEDDED
1473 1473
1474} 1474}
1475 1475
1476 1476
1477void KABCore::addGUIClient( KXMLGUIClient *client ) 1477void KABCore::addGUIClient( KXMLGUIClient *client )
1478{ 1478{
1479 if ( mGUIClient ) 1479 if ( mGUIClient )
1480 mGUIClient->insertChildClient( client ); 1480 mGUIClient->insertChildClient( client );
1481 else 1481 else
1482 KMessageBox::error( this, "no KXMLGUICLient"); 1482 KMessageBox::error( this, "no KXMLGUICLient");
1483} 1483}
1484 1484
1485 1485
1486void KABCore::configurationChanged() 1486void KABCore::configurationChanged()
1487{ 1487{
1488 mExtensionManager->reconfigure(); 1488 mExtensionManager->reconfigure();
1489} 1489}
1490 1490
1491void KABCore::addressBookChanged() 1491void KABCore::addressBookChanged()
1492{ 1492{
1493/*US 1493/*US
1494 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1494 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1495 while ( it.current() ) { 1495 while ( it.current() ) {
1496 if ( it.current()->dirty() ) { 1496 if ( it.current()->dirty() ) {
1497 QString text = i18n( "Data has been changed externally. Unsaved " 1497 QString text = i18n( "Data has been changed externally. Unsaved "
1498 "changes will be lost." ); 1498 "changes will be lost." );
1499 KMessageBox::information( this, text ); 1499 KMessageBox::information( this, text );
1500 } 1500 }
1501 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1501 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1502 ++it; 1502 ++it;
1503 } 1503 }
1504*/ 1504*/
1505 if (mEditorDialog) 1505 if (mEditorDialog)
1506 { 1506 {
1507 if (mEditorDialog->dirty()) 1507 if (mEditorDialog->dirty())
1508 { 1508 {
1509 QString text = i18n( "Data has been changed externally. Unsaved " 1509 QString text = i18n( "Data has been changed externally. Unsaved "
1510 "changes will be lost." ); 1510 "changes will be lost." );
1511 KMessageBox::information( this, text ); 1511 KMessageBox::information( this, text );
1512 } 1512 }
1513 QString currentuid = mEditorDialog->addressee().uid(); 1513 QString currentuid = mEditorDialog->addressee().uid();
1514 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1514 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1515 } 1515 }
1516 mViewManager->refreshView(); 1516 mViewManager->refreshView();
1517// mDetails->refreshView(); 1517// mDetails->refreshView();
1518 1518
1519 1519
1520} 1520}
1521 1521
1522AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1522AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1523 const char *name ) 1523 const char *name )
1524{ 1524{
1525 1525
1526 if ( mEditorDialog == 0 ) { 1526 if ( mEditorDialog == 0 ) {
1527 mEditorDialog = new AddresseeEditorDialog( this, parent, 1527 mEditorDialog = new AddresseeEditorDialog( this, parent,
1528 name ? name : "editorDialog" ); 1528 name ? name : "editorDialog" );
1529 1529
1530 1530
1531 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1531 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1532 SLOT( contactModified( const KABC::Addressee& ) ) ); 1532 SLOT( contactModified( const KABC::Addressee& ) ) );
1533 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1533 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1534 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1534 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1535 } 1535 }
1536 1536
1537 return mEditorDialog; 1537 return mEditorDialog;
1538} 1538}
1539 1539
1540void KABCore::slotEditorDestroyed( const QString &uid ) 1540void KABCore::slotEditorDestroyed( const QString &uid )
1541{ 1541{
1542 //mEditorDict.remove( uid ); 1542 //mEditorDict.remove( uid );
1543} 1543}
1544 1544
1545void KABCore::initGUI() 1545void KABCore::initGUI()
1546{ 1546{
1547#ifndef KAB_EMBEDDED 1547#ifndef KAB_EMBEDDED
1548 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1548 QHBoxLayout *topLayout = new QHBoxLayout( this );
1549 topLayout->setSpacing( KDialogBase::spacingHint() ); 1549 topLayout->setSpacing( KDialogBase::spacingHint() );
1550 1550
1551 mExtensionBarSplitter = new QSplitter( this ); 1551 mExtensionBarSplitter = new QSplitter( this );
1552 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1552 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1553 1553
1554 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1554 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1555 1555
1556 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1556 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1557 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1557 mIncSearchWidget = new IncSearchWidget( viewSpace );
1558 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1558 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1559 SLOT( incrementalSearch( const QString& ) ) ); 1559 SLOT( incrementalSearch( const QString& ) ) );
1560 1560
1561 mViewManager = new ViewManager( this, viewSpace ); 1561 mViewManager = new ViewManager( this, viewSpace );
1562 viewSpace->setStretchFactor( mViewManager, 1 ); 1562 viewSpace->setStretchFactor( mViewManager, 1 );
1563 1563
1564 mDetails = new ViewContainer( mDetailsSplitter ); 1564 mDetails = new ViewContainer( mDetailsSplitter );
1565 1565
1566 mJumpButtonBar = new JumpButtonBar( this, this ); 1566 mJumpButtonBar = new JumpButtonBar( this, this );
1567 1567
1568 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1568 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1569 1569
1570 topLayout->addWidget( mExtensionBarSplitter ); 1570 topLayout->addWidget( mExtensionBarSplitter );
1571 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1571 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1572 topLayout->addWidget( mJumpButtonBar ); 1572 topLayout->addWidget( mJumpButtonBar );
1573 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1573 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1574 1574
1575 mXXPortManager = new XXPortManager( this, this ); 1575 mXXPortManager = new XXPortManager( this, this );
1576 1576
1577#else //KAB_EMBEDDED 1577#else //KAB_EMBEDDED
1578 //US initialize viewMenu before settingup viewmanager. 1578 //US initialize viewMenu before settingup viewmanager.
1579 // Viewmanager needs this menu to plugin submenues. 1579 // Viewmanager needs this menu to plugin submenues.
1580 viewMenu = new QPopupMenu( this ); 1580 viewMenu = new QPopupMenu( this );
1581 settingsMenu = new QPopupMenu( this ); 1581 settingsMenu = new QPopupMenu( this );
1582 //filterMenu = new QPopupMenu( this ); 1582 //filterMenu = new QPopupMenu( this );
1583 ImportMenu = new QPopupMenu( this ); 1583 ImportMenu = new QPopupMenu( this );
1584 ExportMenu = new QPopupMenu( this ); 1584 ExportMenu = new QPopupMenu( this );
1585 syncMenu = new QPopupMenu( this ); 1585 syncMenu = new QPopupMenu( this );
1586 changeMenu= new QPopupMenu( this ); 1586 changeMenu= new QPopupMenu( this );
1587 1587
1588//US since we have no splitter for the embedded system, setup 1588//US since we have no splitter for the embedded system, setup
1589// a layout with two frames. One left and one right. 1589// a layout with two frames. One left and one right.
1590 1590
1591 QBoxLayout *topLayout; 1591 QBoxLayout *topLayout;
1592 1592
1593 // = new QHBoxLayout( this ); 1593 // = new QHBoxLayout( this );
1594// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1594// QBoxLayout *topLayout = (QBoxLayout*)layout();
1595 1595
1596// QWidget *mainBox = new QWidget( this ); 1596// QWidget *mainBox = new QWidget( this );
1597// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1597// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1598 1598
1599#ifdef DESKTOP_VERSION 1599#ifdef DESKTOP_VERSION
1600 topLayout = new QHBoxLayout( this ); 1600 topLayout = new QHBoxLayout( this );
1601 1601
1602 1602
1603 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1603 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1604 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1604 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1605 1605
1606 topLayout->addWidget(mMiniSplitter ); 1606 topLayout->addWidget(mMiniSplitter );
1607 1607
1608 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1608 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1609 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1609 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1610 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1610 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1611 mDetails = new ViewContainer( mMiniSplitter ); 1611 mDetails = new ViewContainer( mMiniSplitter );
1612 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1612 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1613#else 1613#else
1614 if ( QApplication::desktop()->width() > 480 ) { 1614 if ( QApplication::desktop()->width() > 480 ) {
1615 topLayout = new QHBoxLayout( this ); 1615 topLayout = new QHBoxLayout( this );
1616 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1616 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1617 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1617 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1618 } else { 1618 } else {
1619 1619
1620 topLayout = new QHBoxLayout( this ); 1620 topLayout = new QHBoxLayout( this );
1621 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1621 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1622 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1622 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1623 } 1623 }
1624 1624
1625 topLayout->addWidget(mMiniSplitter ); 1625 topLayout->addWidget(mMiniSplitter );
1626 mViewManager = new ViewManager( this, mMiniSplitter ); 1626 mViewManager = new ViewManager( this, mMiniSplitter );
1627 mDetails = new ViewContainer( mMiniSplitter ); 1627 mDetails = new ViewContainer( mMiniSplitter );
1628 1628
1629 1629
1630 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1630 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1631#endif 1631#endif
1632 //eh->hide(); 1632 //eh->hide();
1633 // topLayout->addWidget(mExtensionManager ); 1633 // topLayout->addWidget(mExtensionManager );
1634 1634
1635 1635
1636/*US 1636/*US
1637#ifndef KAB_NOSPLITTER 1637#ifndef KAB_NOSPLITTER
1638 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1638 QHBoxLayout *topLayout = new QHBoxLayout( this );
1639//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1639//US topLayout->setSpacing( KDialogBase::spacingHint() );
1640 topLayout->setSpacing( 10 ); 1640 topLayout->setSpacing( 10 );
1641 1641
1642 mDetailsSplitter = new QSplitter( this ); 1642 mDetailsSplitter = new QSplitter( this );
1643 1643
1644 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1644 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1645 1645
1646 mViewManager = new ViewManager( this, viewSpace ); 1646 mViewManager = new ViewManager( this, viewSpace );
1647 viewSpace->setStretchFactor( mViewManager, 1 ); 1647 viewSpace->setStretchFactor( mViewManager, 1 );
1648 1648
1649 mDetails = new ViewContainer( mDetailsSplitter ); 1649 mDetails = new ViewContainer( mDetailsSplitter );
1650 1650
1651 topLayout->addWidget( mDetailsSplitter ); 1651 topLayout->addWidget( mDetailsSplitter );
1652 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1652 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1653#else //KAB_NOSPLITTER 1653#else //KAB_NOSPLITTER
1654 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1654 QHBoxLayout *topLayout = new QHBoxLayout( this );
1655//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1655//US topLayout->setSpacing( KDialogBase::spacingHint() );
1656 topLayout->setSpacing( 10 ); 1656 topLayout->setSpacing( 10 );
1657 1657
1658// mDetailsSplitter = new QSplitter( this ); 1658// mDetailsSplitter = new QSplitter( this );
1659 1659
1660 QVBox *viewSpace = new QVBox( this ); 1660 QVBox *viewSpace = new QVBox( this );
1661 1661
1662 mViewManager = new ViewManager( this, viewSpace ); 1662 mViewManager = new ViewManager( this, viewSpace );
1663 viewSpace->setStretchFactor( mViewManager, 1 ); 1663 viewSpace->setStretchFactor( mViewManager, 1 );
1664 1664
1665 mDetails = new ViewContainer( this ); 1665 mDetails = new ViewContainer( this );
1666 1666
1667 topLayout->addWidget( viewSpace ); 1667 topLayout->addWidget( viewSpace );
1668// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1668// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1669 topLayout->addWidget( mDetails ); 1669 topLayout->addWidget( mDetails );
1670#endif //KAB_NOSPLITTER 1670#endif //KAB_NOSPLITTER
1671*/ 1671*/
1672 1672
1673 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1673 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1674 syncManager->setBlockSave(false); 1674 syncManager->setBlockSave(false);
1675 1675
1676 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1676 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1677 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1677 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1678 syncManager->setDefaultFileName( sentSyncFile()); 1678 syncManager->setDefaultFileName( sentSyncFile());
1679 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1679 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1680 1680
1681#endif //KAB_EMBEDDED 1681#endif //KAB_EMBEDDED
1682 initActions(); 1682 initActions();
1683 1683
1684#ifdef KAB_EMBEDDED 1684#ifdef KAB_EMBEDDED
1685 addActionsManually(); 1685 addActionsManually();
1686 //US make sure the export and import menues are initialized before creating the xxPortManager. 1686 //US make sure the export and import menues are initialized before creating the xxPortManager.
1687 mXXPortManager = new XXPortManager( this, this ); 1687 mXXPortManager = new XXPortManager( this, this );
1688 1688
1689 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1689 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1690 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1690 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1691 // mActionQuit->plug ( mMainWindow->toolBar()); 1691 // mActionQuit->plug ( mMainWindow->toolBar());
1692 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1692 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1693 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1693 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1694 // mIncSearchWidget->hide(); 1694 // mIncSearchWidget->hide();
1695 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1695 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1696 SLOT( incrementalSearch( const QString& ) ) ); 1696 SLOT( incrementalSearch( const QString& ) ) );
1697 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1697 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1698 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1698 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1699 1699
1700 mJumpButtonBar = new JumpButtonBar( this, this ); 1700 mJumpButtonBar = new JumpButtonBar( this, this );
1701 1701
1702 topLayout->addWidget( mJumpButtonBar ); 1702 topLayout->addWidget( mJumpButtonBar );
1703//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1703//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1704 1704
1705// mMainWindow->getIconToolBar()->raise(); 1705// mMainWindow->getIconToolBar()->raise();
1706 1706
1707#endif //KAB_EMBEDDED 1707#endif //KAB_EMBEDDED
1708 1708
1709} 1709}
1710void KABCore::initActions() 1710void KABCore::initActions()
1711{ 1711{
1712//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1712//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1713 1713
1714#ifndef KAB_EMBEDDED 1714#ifndef KAB_EMBEDDED
1715 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1715 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1716 SLOT( clipboardDataChanged() ) ); 1716 SLOT( clipboardDataChanged() ) );
1717#endif //KAB_EMBEDDED 1717#endif //KAB_EMBEDDED
1718 1718
1719 // file menu 1719 // file menu
1720 if ( mIsPart ) { 1720 if ( mIsPart ) {
1721 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1721 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1722 SLOT( sendMail() ), actionCollection(), 1722 SLOT( sendMail() ), actionCollection(),
1723 "kaddressbook_mail" ); 1723 "kaddressbook_mail" );
1724 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1724 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1725 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1725 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1726 1726
1727 } else { 1727 } else {
1728 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1728 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1729 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1729 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1730 } 1730 }
1731 1731
1732 1732
1733 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1733 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1734 SLOT( save() ), actionCollection(), "file_sync" ); 1734 SLOT( save() ), actionCollection(), "file_sync" );
1735 1735
1736 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1736 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1737 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1737 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1738 1738
1739 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1739 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1740 this, SLOT( mailVCard() ), 1740 this, SLOT( mailVCard() ),
1741 actionCollection(), "file_mail_vcard"); 1741 actionCollection(), "file_mail_vcard");
1742 1742
1743 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, 1743 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this,
1744 SLOT( export2phone() ), actionCollection(), 1744 SLOT( export2phone() ), actionCollection(),
1745 "kaddressbook_ex2phone" ); 1745 "kaddressbook_ex2phone" );
1746 1746
1747 mActionBeamVCard = 0; 1747 mActionBeamVCard = 0;
1748 mActionBeam = 0; 1748 mActionBeam = 0;
1749 1749
1750#ifndef DESKTOP_VERSION 1750#ifndef DESKTOP_VERSION
1751 if ( Ir::supported() ) { 1751 if ( Ir::supported() ) {
1752 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, 1752 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this,
1753 SLOT( beamVCard() ), actionCollection(), 1753 SLOT( beamVCard() ), actionCollection(),
1754 "kaddressbook_beam_vcard" ); 1754 "kaddressbook_beam_vcard" );
1755 1755
1756 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1756 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1757 SLOT( beamMySelf() ), actionCollection(), 1757 SLOT( beamMySelf() ), actionCollection(),
1758 "kaddressbook_beam_myself" ); 1758 "kaddressbook_beam_myself" );
1759 } 1759 }
1760#endif 1760#endif
1761 1761
1762 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1762 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1763 this, SLOT( editContact2() ), 1763 this, SLOT( editContact2() ),
1764 actionCollection(), "file_properties" ); 1764 actionCollection(), "file_properties" );
1765 1765
1766#ifdef KAB_EMBEDDED 1766#ifdef KAB_EMBEDDED
1767 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1767 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1768 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1768 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1769 mMainWindow, SLOT( exit() ), 1769 mMainWindow, SLOT( exit() ),
1770 actionCollection(), "quit" ); 1770 actionCollection(), "quit" );
1771#endif //KAB_EMBEDDED 1771#endif //KAB_EMBEDDED
1772 1772
1773 // edit menu 1773 // edit menu
1774 if ( mIsPart ) { 1774 if ( mIsPart ) {
1775 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1775 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1776 SLOT( copyContacts() ), actionCollection(), 1776 SLOT( copyContacts() ), actionCollection(),
1777 "kaddressbook_copy" ); 1777 "kaddressbook_copy" );
1778 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1778 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1779 SLOT( cutContacts() ), actionCollection(), 1779 SLOT( cutContacts() ), actionCollection(),
1780 "kaddressbook_cut" ); 1780 "kaddressbook_cut" );
1781 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1781 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1782 SLOT( pasteContacts() ), actionCollection(), 1782 SLOT( pasteContacts() ), actionCollection(),
1783 "kaddressbook_paste" ); 1783 "kaddressbook_paste" );
1784 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1784 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1785 SLOT( selectAllContacts() ), actionCollection(), 1785 SLOT( selectAllContacts() ), actionCollection(),
1786 "kaddressbook_select_all" ); 1786 "kaddressbook_select_all" );
1787 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1787 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1788 SLOT( undo() ), actionCollection(), 1788 SLOT( undo() ), actionCollection(),
1789 "kaddressbook_undo" ); 1789 "kaddressbook_undo" );
1790 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1790 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1791 this, SLOT( redo() ), actionCollection(), 1791 this, SLOT( redo() ), actionCollection(),
1792 "kaddressbook_redo" ); 1792 "kaddressbook_redo" );
1793 } else { 1793 } else {
1794 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1794 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1795 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1795 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1796 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1796 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1797 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1797 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1798 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1798 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1799 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1799 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1800 } 1800 }
1801 1801
1802 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1802 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1803 Key_Delete, this, SLOT( deleteContacts() ), 1803 Key_Delete, this, SLOT( deleteContacts() ),
1804 actionCollection(), "edit_delete" ); 1804 actionCollection(), "edit_delete" );
1805 1805
1806 mActionUndo->setEnabled( false ); 1806 mActionUndo->setEnabled( false );
1807 mActionRedo->setEnabled( false ); 1807 mActionRedo->setEnabled( false );
1808 1808
1809 // settings menu 1809 // settings menu
1810#ifdef KAB_EMBEDDED 1810#ifdef KAB_EMBEDDED
1811//US special menuentry to configure the addressbook resources. On KDE 1811//US special menuentry to configure the addressbook resources. On KDE
1812// you do that through the control center !!! 1812// you do that through the control center !!!
1813 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1813 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1814 SLOT( configureResources() ), actionCollection(), 1814 SLOT( configureResources() ), actionCollection(),
1815 "kaddressbook_configure_resources" ); 1815 "kaddressbook_configure_resources" );
1816#endif //KAB_EMBEDDED 1816#endif //KAB_EMBEDDED
1817 1817
1818 if ( mIsPart ) { 1818 if ( mIsPart ) {
1819 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1819 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1820 SLOT( openConfigDialog() ), actionCollection(), 1820 SLOT( openConfigDialog() ), actionCollection(),
1821 "kaddressbook_configure" ); 1821 "kaddressbook_configure" );
1822 1822
1823 //US not implemented yet 1823 //US not implemented yet
1824 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1824 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1825 // this, SLOT( configureKeyBindings() ), actionCollection(), 1825 // this, SLOT( configureKeyBindings() ), actionCollection(),
1826 // "kaddressbook_configure_shortcuts" ); 1826 // "kaddressbook_configure_shortcuts" );
1827#ifdef KAB_EMBEDDED 1827#ifdef KAB_EMBEDDED
1828 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1828 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1829 mActionConfigureToolbars->setEnabled( false ); 1829 mActionConfigureToolbars->setEnabled( false );
1830#endif //KAB_EMBEDDED 1830#endif //KAB_EMBEDDED
1831 1831
1832 } else { 1832 } else {
1833 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1833 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1834 1834
1835 //US not implemented yet 1835 //US not implemented yet
1836 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1836 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1837 } 1837 }
1838 1838
1839 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1839 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1840 actionCollection(), "options_show_jump_bar" ); 1840 actionCollection(), "options_show_jump_bar" );
1841 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1841 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1842 1842
1843 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 1843 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1844 actionCollection(), "options_show_details" ); 1844 actionCollection(), "options_show_details" );
1845 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1845 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1846 1846
1847 1847
1848 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 1848 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
1849 SLOT( toggleBeamReceive() ), actionCollection(), 1849 SLOT( toggleBeamReceive() ), actionCollection(),
1850 "kaddressbook_beam_rec" ); 1850 "kaddressbook_beam_rec" );
1851 1851
1852 1852
1853 // misc 1853 // misc
1854 // only enable LDAP lookup if we can handle the protocol 1854 // only enable LDAP lookup if we can handle the protocol
1855#ifndef KAB_EMBEDDED 1855#ifndef KAB_EMBEDDED
1856 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1856 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index dc2026b..fc2d59b 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,1818 +1,1818 @@
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 <qpushbutton.h> 7#include <qpushbutton.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qtextcodec.h> 10#include <qtextcodec.h>
11#include <qfile.h> 11#include <qfile.h>
12#include <qdir.h> 12#include <qdir.h>
13#include <qapp.h> 13#include <qapp.h>
14#include <qfileinfo.h> 14#include <qfileinfo.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qspinbox.h> 16#include <qspinbox.h>
17#include <qcheckbox.h> 17#include <qcheckbox.h>
18#include <qmap.h> 18#include <qmap.h>
19#include <qwmatrix.h> 19#include <qwmatrix.h>
20#include <qtextbrowser.h> 20#include <qtextbrowser.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#ifndef DESKTOP_VERSION 22#ifndef DESKTOP_VERSION
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qtopia/alarmserver.h> 28#include <qtopia/alarmserver.h>
29#include <qtopia/qcopenvelope_qws.h> 29#include <qtopia/qcopenvelope_qws.h>
30#include <unistd.h> // for sleep 30#include <unistd.h> // for sleep
31#else 31#else
32#include <qmenubar.h> 32#include <qmenubar.h>
33#include <qtoolbar.h> 33#include <qtoolbar.h>
34#include <qapplication.h> 34#include <qapplication.h>
35//#include <resource.h> 35//#include <resource.h>
36 36
37#endif 37#endif
38#include <libkcal/calendarlocal.h> 38#include <libkcal/calendarlocal.h>
39#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40#include <libkcal/phoneformat.h> 40#include <libkcal/phoneformat.h>
41#include <libkdepim/ksyncprofile.h> 41#include <libkdepim/ksyncprofile.h>
42#include <libkdepim/phoneaccess.h> 42#include <libkdepim/phoneaccess.h>
43#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
44#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
45 45
46#include "calendarview.h" 46#include "calendarview.h"
47#include "koviewmanager.h" 47#include "koviewmanager.h"
48#include "datenavigator.h" 48#include "datenavigator.h"
49#include "koagendaview.h" 49#include "koagendaview.h"
50#include "koagenda.h" 50#include "koagenda.h"
51#include "kodialogmanager.h" 51#include "kodialogmanager.h"
52#include "kdialogbase.h" 52#include "kdialogbase.h"
53#include "kapplication.h" 53#include "kapplication.h"
54#include "kofilterview.h" 54#include "kofilterview.h"
55#include "kstandarddirs.h" 55#include "kstandarddirs.h"
56#include "koprefs.h" 56#include "koprefs.h"
57#include "kfiledialog.h" 57#include "kfiledialog.h"
58#include "koglobals.h" 58#include "koglobals.h"
59#include "kglobal.h" 59#include "kglobal.h"
60#include "klocale.h" 60#include "klocale.h"
61#include "kconfig.h" 61#include "kconfig.h"
62#include "simplealarmclient.h" 62#include "simplealarmclient.h"
63#include "externalapphandler.h" 63#include "externalapphandler.h"
64 64
65using namespace KCal; 65using namespace KCal;
66#ifndef _WIN32_ 66#ifndef _WIN32_
67#include <unistd.h> 67#include <unistd.h>
68#else 68#else
69#include "koimportoldialog.h" 69#include "koimportoldialog.h"
70#endif 70#endif
71#include "mainwindow.h" 71#include "mainwindow.h"
72 72
73class KOex2phonePrefs : public QDialog 73class KOex2phonePrefs : public QDialog
74{ 74{
75 public: 75 public:
76 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 76 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
77 QDialog( parent, name, true ) 77 QDialog( parent, name, true )
78 { 78 {
79 setCaption( i18n("Export to phone options") ); 79 setCaption( i18n("Export to phone options") );
80 QVBoxLayout* lay = new QVBoxLayout( this ); 80 QVBoxLayout* lay = new QVBoxLayout( this );
81 lay->setSpacing( 3 ); 81 lay->setSpacing( 3 );
82 lay->setMargin( 3 ); 82 lay->setMargin( 3 );
83 QLabel *lab; 83 QLabel *lab;
84 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 84 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
85 lab->setAlignment (AlignHCenter ); 85 lab->setAlignment (AlignHCenter );
86 QHBox* temphb; 86 QHBox* temphb;
87 temphb = new QHBox( this ); 87 temphb = new QHBox( this );
88 new QLabel( i18n("I/O device: "), temphb ); 88 new QLabel( i18n("I/O device: "), temphb );
89 mPhoneDevice = new QLineEdit( temphb); 89 mPhoneDevice = new QLineEdit( temphb);
90 lay->addWidget( temphb ); 90 lay->addWidget( temphb );
91 temphb = new QHBox( this ); 91 temphb = new QHBox( this );
92 new QLabel( i18n("Connection: "), temphb ); 92 new QLabel( i18n("Connection: "), temphb );
93 mPhoneConnection = new QLineEdit( temphb); 93 mPhoneConnection = new QLineEdit( temphb);
94 lay->addWidget( temphb ); 94 lay->addWidget( temphb );
95 temphb = new QHBox( this ); 95 temphb = new QHBox( this );
96 new QLabel( i18n("Model(opt.): "), temphb ); 96 new QLabel( i18n("Model(opt.): "), temphb );
97 mPhoneModel = new QLineEdit( temphb); 97 mPhoneModel = new QLineEdit( temphb);
98 lay->addWidget( temphb ); 98 lay->addWidget( temphb );
99 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 99 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
100 mWriteBackFuture->setChecked( true ); 100 mWriteBackFuture->setChecked( true );
101 lay->addWidget( mWriteBackFuture ); 101 lay->addWidget( mWriteBackFuture );
102 temphb = new QHBox( this ); 102 temphb = new QHBox( this );
103 new QLabel( i18n("Max. weeks in future: ") , temphb ); 103 new QLabel( i18n("Max. weeks in future: ") , temphb );
104 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 104 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
105 mWriteBackFutureWeeks->setValue( 8 ); 105 mWriteBackFutureWeeks->setValue( 8 );
106 lay->addWidget( temphb ); 106 lay->addWidget( temphb );
107 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 107 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
108 lab->setAlignment (AlignHCenter ); 108 lab->setAlignment (AlignHCenter );
109 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 109 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
110 lay->addWidget( ok ); 110 lay->addWidget( ok );
111 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 111 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
112 lay->addWidget( cancel ); 112 lay->addWidget( cancel );
113 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 113 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
114 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 114 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
115 resize( 220, 240 ); 115 resize( 220, 240 );
116 116
117 } 117 }
118 118
119public: 119public:
120 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 120 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
121 QCheckBox* mWriteBackFuture; 121 QCheckBox* mWriteBackFuture;
122 QSpinBox* mWriteBackFutureWeeks; 122 QSpinBox* mWriteBackFutureWeeks;
123}; 123};
124 124
125int globalFlagBlockStartup; 125int globalFlagBlockStartup;
126MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 126MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
127 QMainWindow( parent, name ) 127 QMainWindow( parent, name )
128{ 128{
129 129
130#ifdef DESKTOP_VERSION 130#ifdef DESKTOP_VERSION
131 setFont( QFont("Arial"), 14 ); 131 setFont( QFont("Arial"), 14 );
132#endif 132#endif
133 mClosed = false; 133 mClosed = false;
134 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 134 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
135 QString confFile = locateLocal("config","korganizerrc"); 135 QString confFile = locateLocal("config","korganizerrc");
136 QFileInfo finf ( confFile ); 136 QFileInfo finf ( confFile );
137 bool showWarning = !finf.exists(); 137 bool showWarning = !finf.exists();
138 setIcon(SmallIcon( "ko24" ) ); 138 setIcon(SmallIcon( "ko24" ) );
139 mBlockAtStartup = true; 139 mBlockAtStartup = true;
140 mFlagKeyPressed = false; 140 mFlagKeyPressed = false;
141 setCaption("KOrganizer/Pi"); 141 setCaption("KOrganizer/Pi");
142 KOPrefs *p = KOPrefs::instance(); 142 KOPrefs *p = KOPrefs::instance();
143 KPimGlobalPrefs::instance()->setGlobalConfig(); 143 KPimGlobalPrefs::instance()->setGlobalConfig();
144 if ( p->mHourSize > 18 ) 144 if ( p->mHourSize > 18 )
145 p->mHourSize = 18; 145 p->mHourSize = 18;
146 QMainWindow::ToolBarDock tbd; 146 QMainWindow::ToolBarDock tbd;
147 if ( p->mToolBarHor ) { 147 if ( p->mToolBarHor ) {
148 if ( p->mToolBarUp ) 148 if ( p->mToolBarUp )
149 tbd = Bottom; 149 tbd = Bottom;
150 else 150 else
151 tbd = Top; 151 tbd = Top;
152 } 152 }
153 else { 153 else {
154 if ( p->mToolBarUp ) 154 if ( p->mToolBarUp )
155 tbd = Right; 155 tbd = Right;
156 else 156 else
157 tbd = Left; 157 tbd = Left;
158 } 158 }
159 if ( KOPrefs::instance()->mUseAppColors ) 159 if ( KOPrefs::instance()->mUseAppColors )
160 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 160 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
161 globalFlagBlockStartup = 1; 161 globalFlagBlockStartup = 1;
162 iconToolBar = new QPEToolBar( this ); 162 iconToolBar = new QPEToolBar( this );
163 addToolBar (iconToolBar , tbd ); 163 addToolBar (iconToolBar , tbd );
164 mCalendarModifiedFlag = false; 164 mCalendarModifiedFlag = false;
165 165
166 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 166 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
167 splash->setAlignment ( AlignCenter ); 167 splash->setAlignment ( AlignCenter );
168 setCentralWidget( splash ); 168 setCentralWidget( splash );
169#ifndef DESKTOP_VERSION 169#ifndef DESKTOP_VERSION
170 showMaximized(); 170 showMaximized();
171#endif 171#endif
172 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 172 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
173 setDefaultPreferences(); 173 setDefaultPreferences();
174 mCalendar = new CalendarLocal(); 174 mCalendar = new CalendarLocal();
175 mView = new CalendarView( mCalendar, this,"mCalendar " ); 175 mView = new CalendarView( mCalendar, this,"mCalendar " );
176 mView->hide(); 176 mView->hide();
177 //mView->resize(splash->size() ); 177 //mView->resize(splash->size() );
178 initActions(); 178 initActions();
179 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 179 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
180 mSyncManager->setBlockSave(false); 180 mSyncManager->setBlockSave(false);
181 mView->setSyncManager(mSyncManager); 181 mView->setSyncManager(mSyncManager);
182#ifndef DESKTOP_VERSION 182#ifndef DESKTOP_VERSION
183 iconToolBar->show(); 183 iconToolBar->show();
184 qApp->processEvents(); 184 qApp->processEvents();
185#endif 185#endif
186 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 186 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
187 int vh = height() ; 187 int vh = height() ;
188 int vw = width(); 188 int vw = width();
189 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 189 //qDebug("Toolbar hei %d ",iconToolBar->height() );
190 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 190 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
191 vh -= iconToolBar->height(); 191 vh -= iconToolBar->height();
192 } else { 192 } else {
193 vw -= iconToolBar->height(); 193 vw -= iconToolBar->height();
194 } 194 }
195 //mView->setMaximumSize( splash->size() ); 195 //mView->setMaximumSize( splash->size() );
196 //mView->resize( splash->size() ); 196 //mView->resize( splash->size() );
197 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 197 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
198 mView->readSettings(); 198 mView->readSettings();
199 bool newFile = false; 199 bool newFile = false;
200 if( !QFile::exists( defaultFileName() ) ) { 200 if( !QFile::exists( defaultFileName() ) ) {
201 QFileInfo finfo ( defaultFileName() ); 201 QFileInfo finfo ( defaultFileName() );
202 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 202 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
203 qDebug("oldfile %s ", oldFile.latin1()); 203 qDebug("oldfile %s ", oldFile.latin1());
204 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"; 204 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";
205 finfo.setFile( oldFile ); 205 finfo.setFile( oldFile );
206 if (finfo.exists() ) { 206 if (finfo.exists() ) {
207 KMessageBox::information( this, message); 207 KMessageBox::information( this, message);
208 mView->openCalendar( oldFile ); 208 mView->openCalendar( oldFile );
209 qApp->processEvents(); 209 qApp->processEvents();
210 } else { 210 } else {
211 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 211 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
212 finfo.setFile( oldFile ); 212 finfo.setFile( oldFile );
213 if (finfo.exists() ) { 213 if (finfo.exists() ) {
214 KMessageBox::information( this, message); 214 KMessageBox::information( this, message);
215 mView->openCalendar( oldFile ); 215 mView->openCalendar( oldFile );
216 qApp->processEvents(); 216 qApp->processEvents();
217 } 217 }
218 } 218 }
219 mView->saveCalendar( defaultFileName() ); 219 mView->saveCalendar( defaultFileName() );
220 newFile = true; 220 newFile = true;
221 } 221 }
222 222
223 QTime neededSaveTime = QDateTime::currentDateTime().time(); 223 QTime neededSaveTime = QDateTime::currentDateTime().time();
224 mView->openCalendar( defaultFileName() ); 224 mView->openCalendar( defaultFileName() );
225 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 225 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
226 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 226 qDebug("KO: Calendar loading time: %d ms",msNeeded );
227 227
228 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { 228 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
229 KOPrefs::instance()->setCategoryDefaults(); 229 KOPrefs::instance()->setCategoryDefaults();
230 int count = mView->addCategories(); 230 int count = mView->addCategories();
231 } 231 }
232 processIncidenceSelection( 0 ); 232 processIncidenceSelection( 0 );
233 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 233 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
234 SLOT( processIncidenceSelection( Incidence * ) ) ); 234 SLOT( processIncidenceSelection( Incidence * ) ) );
235 connect( mView, SIGNAL( modifiedChanged( bool ) ), 235 connect( mView, SIGNAL( modifiedChanged( bool ) ),
236 SLOT( slotModifiedChanged( bool ) ) ); 236 SLOT( slotModifiedChanged( bool ) ) );
237 237
238 238
239 connect( mView, SIGNAL( tempDisableBR(bool) ), 239 connect( mView, SIGNAL( tempDisableBR(bool) ),
240 SLOT( disableBR(bool) ) ); 240 SLOT( disableBR(bool) ) );
241 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 241 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
242 mView->setModified( false ); 242 mView->setModified( false );
243 mBlockAtStartup = false; 243 mBlockAtStartup = false;
244 mView->setModified( false ); 244 mView->setModified( false );
245 setCentralWidget( mView ); 245 setCentralWidget( mView );
246 globalFlagBlockStartup = 0; 246 globalFlagBlockStartup = 0;
247 mView->show(); 247 mView->show();
248 delete splash; 248 delete splash;
249 if ( newFile ) 249 if ( newFile )
250 mView->updateConfig(); 250 mView->updateConfig();
251 // qApp->processEvents(); 251 // qApp->processEvents();
252 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 252 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
253 //fillSyncMenu(); 253 //fillSyncMenu();
254 254
255 255
256 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 256 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
257 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 257 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
258 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 258 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
259 mSyncManager->setDefaultFileName( defaultFileName()); 259 mSyncManager->setDefaultFileName( defaultFileName());
260 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 260 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
261 mSyncManager->fillSyncMenu(); 261 mSyncManager->fillSyncMenu();
262 262
263 263
264 264
265 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 265 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
266 if ( showWarning ) { 266 if ( showWarning ) {
267 KMessageBox::information( this, 267 KMessageBox::information( this,
268 "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"); 268 "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");
269 qApp->processEvents(); 269 qApp->processEvents();
270 mView->dialogManager()->showSyncOptions(); 270 mView->dialogManager()->showSyncOptions();
271 } 271 }
272 272
273 //US listen for result adressed from Ka/Pi 273 //US listen for result adressed from Ka/Pi
274#ifndef DESKTOP_VERSION 274#ifndef DESKTOP_VERSION
275 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 275 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
276#endif 276#endif
277#ifndef DESKTOP_VERSION 277#ifndef DESKTOP_VERSION
278 infrared = 0; 278 infrared = 0;
279#endif 279#endif
280 280
281 mBRdisabled = false; 281 mBRdisabled = false;
282 toggleBeamReceive(); 282 //toggleBeamReceive();
283} 283}
284MainWindow::~MainWindow() 284MainWindow::~MainWindow()
285{ 285{
286 //qDebug("MainWindow::~MainWindow() "); 286 //qDebug("MainWindow::~MainWindow() ");
287 //save toolbar location 287 //save toolbar location
288 delete mCalendar; 288 delete mCalendar;
289 delete mSyncManager; 289 delete mSyncManager;
290#ifndef DESKTOP_VERSION 290#ifndef DESKTOP_VERSION
291 if ( infrared ) 291 if ( infrared )
292 delete infrared; 292 delete infrared;
293#endif 293#endif
294 294
295 295
296} 296}
297 297
298void MainWindow::disableBR(bool b) 298void MainWindow::disableBR(bool b)
299{ 299{
300#ifndef DESKTOP_VERSION 300#ifndef DESKTOP_VERSION
301 if ( b ) { 301 if ( b ) {
302 if ( infrared ) { 302 if ( infrared ) {
303 toggleBeamReceive(); 303 toggleBeamReceive();
304 mBRdisabled = true; 304 mBRdisabled = true;
305 } 305 }
306 mBRdisabled = true; 306 mBRdisabled = true;
307 } else { 307 } else {
308 if ( mBRdisabled ) { 308 if ( mBRdisabled ) {
309 mBRdisabled = false; 309 mBRdisabled = false;
310 //makes no sense,because other cal ap is probably running 310 //makes no sense,because other cal ap is probably running
311 // toggleBeamReceive(); 311 // toggleBeamReceive();
312 } 312 }
313 } 313 }
314#endif 314#endif
315 315
316} 316}
317bool MainWindow::beamReceiveEnabled() 317bool MainWindow::beamReceiveEnabled()
318{ 318{
319#ifndef DESKTOP_VERSION 319#ifndef DESKTOP_VERSION
320 return ( infrared != 0 ); 320 return ( infrared != 0 );
321#endif 321#endif
322 return false; 322 return false;
323} 323}
324 324
325void MainWindow::toggleBeamReceive() 325void MainWindow::toggleBeamReceive()
326{ 326{
327 if ( mBRdisabled ) 327 if ( mBRdisabled )
328 return; 328 return;
329#ifndef DESKTOP_VERSION 329#ifndef DESKTOP_VERSION
330 if ( infrared ) { 330 if ( infrared ) {
331 qDebug("disable BeamReceive "); 331 qDebug("disable BeamReceive ");
332 delete infrared; 332 delete infrared;
333 infrared = 0; 333 infrared = 0;
334 brAction->setOn(false); 334 brAction->setOn(false);
335 return; 335 return;
336 } 336 }
337 qDebug("enable BeamReceive "); 337 qDebug("enable BeamReceive ");
338 brAction->setOn(true); 338 brAction->setOn(true);
339 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; 339 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
340 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); 340 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
341#endif 341#endif
342} 342}
343void MainWindow::showMaximized () 343void MainWindow::showMaximized ()
344{ 344{
345#ifndef DESKTOP_VERSION 345#ifndef DESKTOP_VERSION
346 if ( ! globalFlagBlockStartup ) 346 if ( ! globalFlagBlockStartup )
347 if ( mClosed ) 347 if ( mClosed )
348 mView->goToday(); 348 mView->goToday();
349#endif 349#endif
350 QWidget::showMaximized () ; 350 QWidget::showMaximized () ;
351 mClosed = false; 351 mClosed = false;
352} 352}
353void MainWindow::closeEvent( QCloseEvent* ce ) 353void MainWindow::closeEvent( QCloseEvent* ce )
354{ 354{
355 355
356 356
357 357
358 if ( ! KOPrefs::instance()->mAskForQuit ) { 358 if ( ! KOPrefs::instance()->mAskForQuit ) {
359 saveOnClose(); 359 saveOnClose();
360 mClosed = true; 360 mClosed = true;
361 ce->accept(); 361 ce->accept();
362 return; 362 return;
363 363
364 } 364 }
365 365
366 switch( QMessageBox::information( this, "KO/Pi", 366 switch( QMessageBox::information( this, "KO/Pi",
367 i18n("Do you really want\nto close KO/Pi?"), 367 i18n("Do you really want\nto close KO/Pi?"),
368 i18n("Close"), i18n("No"), 368 i18n("Close"), i18n("No"),
369 0, 0 ) ) { 369 0, 0 ) ) {
370 case 0: 370 case 0:
371 saveOnClose(); 371 saveOnClose();
372 mClosed = true; 372 mClosed = true;
373 ce->accept(); 373 ce->accept();
374 break; 374 break;
375 case 1: 375 case 1:
376 ce->ignore(); 376 ce->ignore();
377 break; 377 break;
378 case 2: 378 case 2:
379 379
380 default: 380 default:
381 break; 381 break;
382 } 382 }
383 383
384 384
385} 385}
386 386
387void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 387void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
388{ 388{
389 QDataStream stream( data, IO_ReadOnly ); 389 QDataStream stream( data, IO_ReadOnly );
390 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 390 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
391 //QString datamess; 391 //QString datamess;
392 //qDebug("message "); 392 //qDebug("message ");
393 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 393 qDebug("KO: QCOP message received: %s ", cmsg.data() );
394 394
395 if ( cmsg == "setDocument(QString)" ) { 395 if ( cmsg == "setDocument(QString)" ) {
396 QDataStream stream( data, IO_ReadOnly ); 396 QDataStream stream( data, IO_ReadOnly );
397 QString fileName; 397 QString fileName;
398 stream >> fileName; 398 stream >> fileName;
399 //qDebug("filename %s ", fileName.latin1()); 399 //qDebug("filename %s ", fileName.latin1());
400 showMaximized(); 400 showMaximized();
401 raise(); 401 raise();
402 KOPrefs::instance()->mLastSyncedLocalFile = fileName ; 402 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
403 mSyncManager->slotSyncMenu( 1002 ); 403 mSyncManager->slotSyncMenu( 1002 );
404 return; 404 return;
405 } 405 }
406 406
407 if ( cmsg == "-writeFile" ) { 407 if ( cmsg == "-writeFile" ) {
408 // I made from the "-writeFile" an "-writeAlarm" 408 // I made from the "-writeFile" an "-writeAlarm"
409 mView->viewManager()->showWhatsNextView(); 409 mView->viewManager()->showWhatsNextView();
410 mCalendar->checkAlarmForIncidence( 0, true); 410 mCalendar->checkAlarmForIncidence( 0, true);
411 showMaximized(); 411 showMaximized();
412 raise(); 412 raise();
413 return; 413 return;
414 414
415 } 415 }
416 if ( cmsg == "-writeFileSilent" ) { 416 if ( cmsg == "-writeFileSilent" ) {
417 // I made from the "-writeFile" an "-writeAlarm" 417 // I made from the "-writeFile" an "-writeAlarm"
418 // mView->viewManager()->showWhatsNextView(); 418 // mView->viewManager()->showWhatsNextView();
419 mCalendar->checkAlarmForIncidence( 0, true); 419 mCalendar->checkAlarmForIncidence( 0, true);
420 //showMaximized(); 420 //showMaximized();
421 //raise(); 421 //raise();
422 hide(); 422 hide();
423 return; 423 return;
424 } 424 }
425 if ( cmsg == "-newCountdown" ) { 425 if ( cmsg == "-newCountdown" ) {
426 qDebug("newCountdown "); 426 qDebug("newCountdown ");
427 427
428 } 428 }
429 QString msg ; 429 QString msg ;
430 QString allmsg = cmsg; 430 QString allmsg = cmsg;
431 while ( allmsg.length() > 0 ) { 431 while ( allmsg.length() > 0 ) {
432 int nextC = allmsg.find( "-", 1 ); 432 int nextC = allmsg.find( "-", 1 );
433 if ( nextC == -1 ) { 433 if ( nextC == -1 ) {
434 msg = allmsg; 434 msg = allmsg;
435 allmsg = ""; 435 allmsg = "";
436 } else{ 436 } else{
437 msg = allmsg.left( nextC ); 437 msg = allmsg.left( nextC );
438 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 438 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
439 } 439 }
440 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 440 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
441 if ( msg == "-newEvent" ) { 441 if ( msg == "-newEvent" ) {
442 mView->newEvent(); 442 mView->newEvent();
443 } 443 }
444 if ( msg == "-newTodo" ) { 444 if ( msg == "-newTodo" ) {
445 mView->newTodo(); 445 mView->newTodo();
446 446
447 } 447 }
448 if ( msg == "-showWN" ) { 448 if ( msg == "-showWN" ) {
449 mView->viewManager()->showWhatsNextView(); 449 mView->viewManager()->showWhatsNextView();
450 } 450 }
451 if ( msg == "-showTodo" ) { 451 if ( msg == "-showTodo" ) {
452 mView->viewManager()->showTodoView(); 452 mView->viewManager()->showTodoView();
453 } 453 }
454 if ( msg == "-showList" ) { 454 if ( msg == "-showList" ) {
455 mView->viewManager()->showListView(); 455 mView->viewManager()->showListView();
456 } 456 }
457 else if ( msg == "-showDay" ) { 457 else if ( msg == "-showDay" ) {
458 mView->viewManager()->showDayView(); 458 mView->viewManager()->showDayView();
459 } 459 }
460 else if ( msg == "-showWWeek" ) { 460 else if ( msg == "-showWWeek" ) {
461 mView->viewManager()->showWorkWeekView(); 461 mView->viewManager()->showWorkWeekView();
462 } 462 }
463 else if ( msg == "-ringSync" ) { 463 else if ( msg == "-ringSync" ) {
464 mSyncManager->multiSync( false ); 464 mSyncManager->multiSync( false );
465 } 465 }
466 else if ( msg == "-showWeek" ) { 466 else if ( msg == "-showWeek" ) {
467 mView->viewManager()->showWeekView(); 467 mView->viewManager()->showWeekView();
468 } 468 }
469 else if ( msg == "-showTodo" ) { 469 else if ( msg == "-showTodo" ) {
470 mView->viewManager()->showTodoView(); 470 mView->viewManager()->showTodoView();
471 } 471 }
472 else if ( msg == "-showJournal" ) { 472 else if ( msg == "-showJournal" ) {
473 mView->dateNavigator()->selectDates( 1 ); 473 mView->dateNavigator()->selectDates( 1 );
474 mView->dateNavigator()->selectToday(); 474 mView->dateNavigator()->selectToday();
475 mView->viewManager()->showJournalView(); 475 mView->viewManager()->showJournalView();
476 } 476 }
477 else if ( msg == "-showKO" ) { 477 else if ( msg == "-showKO" ) {
478 mView->viewManager()->showNextXView(); 478 mView->viewManager()->showNextXView();
479 } 479 }
480 else if ( msg == "-showWNext" || msg == "nextView()" ) { 480 else if ( msg == "-showWNext" || msg == "nextView()" ) {
481 mView->viewManager()->showWhatsNextView(); 481 mView->viewManager()->showWhatsNextView();
482 } 482 }
483 else if ( msg == "-showNextXView" ) { 483 else if ( msg == "-showNextXView" ) {
484 mView->viewManager()->showNextXView(); 484 mView->viewManager()->showNextXView();
485 } 485 }
486 486
487 487
488 } 488 }
489 489
490 showMaximized(); 490 showMaximized();
491 raise(); 491 raise();
492} 492}
493 493
494QPixmap MainWindow::loadPixmap( QString name ) 494QPixmap MainWindow::loadPixmap( QString name )
495{ 495{
496 return SmallIcon( name ); 496 return SmallIcon( name );
497 497
498} 498}
499void MainWindow::initActions() 499void MainWindow::initActions()
500{ 500{
501 //KOPrefs::instance()->mShowFullMenu 501 //KOPrefs::instance()->mShowFullMenu
502 iconToolBar->clear(); 502 iconToolBar->clear();
503 KOPrefs *p = KOPrefs::instance(); 503 KOPrefs *p = KOPrefs::instance();
504 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 504 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
505 505
506 QPopupMenu *viewMenu = new QPopupMenu( this ); 506 QPopupMenu *viewMenu = new QPopupMenu( this );
507 QPopupMenu *actionMenu = new QPopupMenu( this ); 507 QPopupMenu *actionMenu = new QPopupMenu( this );
508 QPopupMenu *importMenu = new QPopupMenu( this ); 508 QPopupMenu *importMenu = new QPopupMenu( this );
509 selectFilterMenu = new QPopupMenu( this ); 509 selectFilterMenu = new QPopupMenu( this );
510 selectFilterMenu->setCheckable( true ); 510 selectFilterMenu->setCheckable( true );
511 syncMenu = new QPopupMenu( this ); 511 syncMenu = new QPopupMenu( this );
512 configureAgendaMenu = new QPopupMenu( this ); 512 configureAgendaMenu = new QPopupMenu( this );
513 configureToolBarMenu = new QPopupMenu( this ); 513 configureToolBarMenu = new QPopupMenu( this );
514 QPopupMenu *helpMenu = new QPopupMenu( this ); 514 QPopupMenu *helpMenu = new QPopupMenu( this );
515 if ( KOPrefs::instance()->mShowFullMenu ) { 515 if ( KOPrefs::instance()->mShowFullMenu ) {
516 QMenuBar *menuBar1; 516 QMenuBar *menuBar1;
517 menuBar1 = menuBar(); 517 menuBar1 = menuBar();
518 menuBar1->insertItem( i18n("File"), importMenu ); 518 menuBar1->insertItem( i18n("File"), importMenu );
519 menuBar1->insertItem( i18n("View"), viewMenu ); 519 menuBar1->insertItem( i18n("View"), viewMenu );
520 menuBar1->insertItem( i18n("Actions"), actionMenu ); 520 menuBar1->insertItem( i18n("Actions"), actionMenu );
521 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 521 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
522 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 522 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
523 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 523 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
524 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 524 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
525 menuBar1->insertItem( i18n("Help"), helpMenu ); 525 menuBar1->insertItem( i18n("Help"), helpMenu );
526 } else { 526 } else {
527 QPEMenuBar *menuBar1; 527 QPEMenuBar *menuBar1;
528 menuBar1 = new QPEMenuBar( iconToolBar ); 528 menuBar1 = new QPEMenuBar( iconToolBar );
529 QPopupMenu *menuBar = new QPopupMenu( this ); 529 QPopupMenu *menuBar = new QPopupMenu( this );
530 menuBar1->insertItem( i18n("ME"), menuBar); 530 menuBar1->insertItem( i18n("ME"), menuBar);
531 menuBar->insertItem( i18n("File"), importMenu ); 531 menuBar->insertItem( i18n("File"), importMenu );
532 menuBar->insertItem( i18n("View"), viewMenu ); 532 menuBar->insertItem( i18n("View"), viewMenu );
533 menuBar->insertItem( i18n("Actions"), actionMenu ); 533 menuBar->insertItem( i18n("Actions"), actionMenu );
534 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 534 menuBar->insertItem( i18n("Synchronize"), syncMenu );
535 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 535 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
536 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 536 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
537 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 537 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
538 menuBar->insertItem( i18n("Help"), helpMenu ); 538 menuBar->insertItem( i18n("Help"), helpMenu );
539 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 539 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
540 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 540 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
541 } 541 }
542 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 542 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
543 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); 543 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) );
544 544
545 // ****************** 545 // ******************
546 QAction *action; 546 QAction *action;
547 QIconSet icon; 547 QIconSet icon;
548 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 548 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
549 configureToolBarMenu->setCheckable( true ); 549 configureToolBarMenu->setCheckable( true );
550 550
551 QString pathString = ""; 551 QString pathString = "";
552 if ( !p->mToolBarMiniIcons ) { 552 if ( !p->mToolBarMiniIcons ) {
553 if ( QApplication::desktop()->width() < 480 ) 553 if ( QApplication::desktop()->width() < 480 )
554 pathString += "icons16/"; 554 pathString += "icons16/";
555 } else 555 } else
556 pathString += "iconsmini/"; 556 pathString += "iconsmini/";
557 configureAgendaMenu->setCheckable( true ); 557 configureAgendaMenu->setCheckable( true );
558 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); 558 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 );
559 configureAgendaMenu->insertSeparator(); 559 configureAgendaMenu->insertSeparator();
560 configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); 560 configureAgendaMenu->insertItem(i18n("Tiny"), 4 );
561 configureAgendaMenu->insertItem(i18n("Small"), 6 ); 561 configureAgendaMenu->insertItem(i18n("Small"), 6 );
562 configureAgendaMenu->insertItem(i18n("Medium"), 8 ); 562 configureAgendaMenu->insertItem(i18n("Medium"), 8 );
563 configureAgendaMenu->insertItem(i18n("Normal"), 10 ); 563 configureAgendaMenu->insertItem(i18n("Normal"), 10 );
564 configureAgendaMenu->insertItem(i18n("Large"), 12 ); 564 configureAgendaMenu->insertItem(i18n("Large"), 12 );
565 configureAgendaMenu->insertItem(i18n("Big"), 14 ); 565 configureAgendaMenu->insertItem(i18n("Big"), 14 );
566 configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); 566 configureAgendaMenu->insertItem(i18n("Bigger"), 16 );
567 configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); 567 configureAgendaMenu->insertItem(i18n("Biggest"), 18 );
568 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 568 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
569 569
570 icon = loadPixmap( pathString + "configure" ); 570 icon = loadPixmap( pathString + "configure" );
571 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 571 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
572 action->addTo( actionMenu ); 572 action->addTo( actionMenu );
573 connect( action, SIGNAL( activated() ), 573 connect( action, SIGNAL( activated() ),
574 mView, SLOT( edit_options() ) ); 574 mView, SLOT( edit_options() ) );
575 actionMenu->insertSeparator(); 575 actionMenu->insertSeparator();
576 icon = loadPixmap( pathString + "newevent" ); 576 icon = loadPixmap( pathString + "newevent" );
577 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 577 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
578 configureToolBarMenu->insertSeparator(); 578 configureToolBarMenu->insertSeparator();
579 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 579 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
580 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 580 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
581 ne_action->addTo( actionMenu ); 581 ne_action->addTo( actionMenu );
582 connect( ne_action, SIGNAL( activated() ), 582 connect( ne_action, SIGNAL( activated() ),
583 mView, SLOT( newEvent() ) ); 583 mView, SLOT( newEvent() ) );
584 icon = loadPixmap( pathString + "newtodo" ); 584 icon = loadPixmap( pathString + "newtodo" );
585 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 585 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
586 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 586 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
587 nt_action->addTo( actionMenu ); 587 nt_action->addTo( actionMenu );
588 connect( nt_action, SIGNAL( activated() ), 588 connect( nt_action, SIGNAL( activated() ),
589 mView, SLOT( newTodo() ) ); 589 mView, SLOT( newTodo() ) );
590 icon = loadPixmap( pathString + "navi" ); 590 icon = loadPixmap( pathString + "navi" );
591 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 591 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
592 action->addTo( viewMenu ); 592 action->addTo( viewMenu );
593 connect( action, SIGNAL( activated() ), 593 connect( action, SIGNAL( activated() ),
594 mView, SLOT( toggleDateNavigatorWidget() ) ); 594 mView, SLOT( toggleDateNavigatorWidget() ) );
595 icon = loadPixmap( pathString + "filter" ); 595 icon = loadPixmap( pathString + "filter" );
596 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 596 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
597 action->addTo( viewMenu ); 597 action->addTo( viewMenu );
598 connect( action, SIGNAL( activated() ), 598 connect( action, SIGNAL( activated() ),
599 mView, SLOT( toggleFilter() ) ); 599 mView, SLOT( toggleFilter() ) );
600 600
601 601
602 viewMenu->insertSeparator(); 602 viewMenu->insertSeparator();
603 icon = loadPixmap( pathString + "picker" ); 603 icon = loadPixmap( pathString + "picker" );
604 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 604 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
605 action->addTo( viewMenu ); 605 action->addTo( viewMenu );
606 connect( action, SIGNAL( activated() ), 606 connect( action, SIGNAL( activated() ),
607 mView, SLOT( showDatePicker() ) ); 607 mView, SLOT( showDatePicker() ) );
608 action->addTo( iconToolBar ); 608 action->addTo( iconToolBar );
609 viewMenu->insertSeparator(); 609 viewMenu->insertSeparator();
610 icon = loadPixmap( pathString + "list" ); 610 icon = loadPixmap( pathString + "list" );
611 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 611 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
612 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 612 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
613 showlist_action->addTo( viewMenu ); 613 showlist_action->addTo( viewMenu );
614 connect( showlist_action, SIGNAL( activated() ), 614 connect( showlist_action, SIGNAL( activated() ),
615 mView->viewManager(), SLOT( showListView() ) ); 615 mView->viewManager(), SLOT( showListView() ) );
616 616
617 617
618 icon = loadPixmap( pathString + "day" ); 618 icon = loadPixmap( pathString + "day" );
619 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 619 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
620 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 620 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
621 day1_action->addTo( viewMenu ); 621 day1_action->addTo( viewMenu );
622 // action->addTo( toolBar ); 622 // action->addTo( toolBar );
623 connect( day1_action, SIGNAL( activated() ), 623 connect( day1_action, SIGNAL( activated() ),
624 mView->viewManager(), SLOT( showDayView() ) ); 624 mView->viewManager(), SLOT( showDayView() ) );
625 625
626 icon = loadPixmap( pathString + "workweek" ); 626 icon = loadPixmap( pathString + "workweek" );
627 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 627 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
628 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 628 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
629 day5_action->addTo( viewMenu ); 629 day5_action->addTo( viewMenu );
630 connect( day5_action, SIGNAL( activated() ), 630 connect( day5_action, SIGNAL( activated() ),
631 mView->viewManager(), SLOT( showWorkWeekView() ) ); 631 mView->viewManager(), SLOT( showWorkWeekView() ) );
632 632
633 icon = loadPixmap( pathString + "week" ); 633 icon = loadPixmap( pathString + "week" );
634 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 634 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
635 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 635 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
636 day7_action->addTo( viewMenu ); 636 day7_action->addTo( viewMenu );
637 connect( day7_action, SIGNAL( activated() ), 637 connect( day7_action, SIGNAL( activated() ),
638 mView->viewManager(), SLOT( showWeekView() ) ); 638 mView->viewManager(), SLOT( showWeekView() ) );
639 639
640 icon = loadPixmap( pathString + "month" ); 640 icon = loadPixmap( pathString + "month" );
641 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 641 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
642 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 642 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
643 month_action->addTo( viewMenu ); 643 month_action->addTo( viewMenu );
644 connect( month_action, SIGNAL( activated() ), 644 connect( month_action, SIGNAL( activated() ),
645 mView->viewManager(), SLOT( showMonthView() ) ); 645 mView->viewManager(), SLOT( showMonthView() ) );
646 646
647 icon = loadPixmap( pathString + "todo" ); 647 icon = loadPixmap( pathString + "todo" );
648 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 648 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
649 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 649 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
650 todoview_action->addTo( viewMenu ); 650 todoview_action->addTo( viewMenu );
651 connect( todoview_action, SIGNAL( activated() ), 651 connect( todoview_action, SIGNAL( activated() ),
652 mView->viewManager(), SLOT( showTodoView() ) ); 652 mView->viewManager(), SLOT( showTodoView() ) );
653 653
654 icon = loadPixmap( pathString + "journal" ); 654 icon = loadPixmap( pathString + "journal" );
655 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 655 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
656 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 656 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
657 viewjournal_action->addTo( viewMenu ); 657 viewjournal_action->addTo( viewMenu );
658 connect( viewjournal_action, SIGNAL( activated() ), 658 connect( viewjournal_action, SIGNAL( activated() ),
659 mView->viewManager(), SLOT( showJournalView() ) ); 659 mView->viewManager(), SLOT( showJournalView() ) );
660 660
661 icon = loadPixmap( pathString + "xdays" ); 661 icon = loadPixmap( pathString + "xdays" );
662 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 662 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
663 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 663 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
664 xdays_action->addTo( viewMenu ); 664 xdays_action->addTo( viewMenu );
665 connect( xdays_action, SIGNAL( activated() ), 665 connect( xdays_action, SIGNAL( activated() ),
666 mView->viewManager(), SLOT( showNextXView() ) ); 666 mView->viewManager(), SLOT( showNextXView() ) );
667 667
668 icon = loadPixmap( pathString + "whatsnext" ); 668 icon = loadPixmap( pathString + "whatsnext" );
669 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 669 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
670 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 670 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
671 whatsnext_action->addTo( viewMenu ); 671 whatsnext_action->addTo( viewMenu );
672 connect( whatsnext_action, SIGNAL( activated() ), 672 connect( whatsnext_action, SIGNAL( activated() ),
673 mView->viewManager(), SLOT( showWhatsNextView() ) ); 673 mView->viewManager(), SLOT( showWhatsNextView() ) );
674 674
675#if 0 675#if 0
676 action = new QAction( "view_timespan", "Time Span", 0, this ); 676 action = new QAction( "view_timespan", "Time Span", 0, this );
677 action->addTo( viewMenu ); 677 action->addTo( viewMenu );
678 connect( action, SIGNAL( activated() ), 678 connect( action, SIGNAL( activated() ),
679 mView->viewManager(), SLOT( showTimeSpanView() ) ); 679 mView->viewManager(), SLOT( showTimeSpanView() ) );
680#endif 680#endif
681 681
682 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 682 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
683 this ); 683 this );
684 mNewSubTodoAction->addTo( actionMenu ); 684 mNewSubTodoAction->addTo( actionMenu );
685 connect( mNewSubTodoAction, SIGNAL( activated() ), 685 connect( mNewSubTodoAction, SIGNAL( activated() ),
686 mView, SLOT( newSubTodo() ) ); 686 mView, SLOT( newSubTodo() ) );
687 687
688 actionMenu->insertSeparator(); 688 actionMenu->insertSeparator();
689 689
690 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 690 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
691 mShowAction->addTo( actionMenu ); 691 mShowAction->addTo( actionMenu );
692 connect( mShowAction, SIGNAL( activated() ), 692 connect( mShowAction, SIGNAL( activated() ),
693 mView, SLOT( showIncidence() ) ); 693 mView, SLOT( showIncidence() ) );
694 694
695 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 695 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
696 mEditAction->addTo( actionMenu ); 696 mEditAction->addTo( actionMenu );
697 connect( mEditAction, SIGNAL( activated() ), 697 connect( mEditAction, SIGNAL( activated() ),
698 mView, SLOT( editIncidence() ) ); 698 mView, SLOT( editIncidence() ) );
699 699
700 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 700 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
701 mDeleteAction->addTo( actionMenu ); 701 mDeleteAction->addTo( actionMenu );
702 connect( mDeleteAction, SIGNAL( activated() ), 702 connect( mDeleteAction, SIGNAL( activated() ),
703 mView, SLOT( deleteIncidence() ) ); 703 mView, SLOT( deleteIncidence() ) );
704 704
705 705
706 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 706 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
707 mCloneAction->addTo( actionMenu ); 707 mCloneAction->addTo( actionMenu );
708 connect( mCloneAction, SIGNAL( activated() ), 708 connect( mCloneAction, SIGNAL( activated() ),
709 mView, SLOT( cloneIncidence() ) ); 709 mView, SLOT( cloneIncidence() ) );
710 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 710 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
711 mMoveAction->addTo( actionMenu ); 711 mMoveAction->addTo( actionMenu );
712 connect( mMoveAction, SIGNAL( activated() ), 712 connect( mMoveAction, SIGNAL( activated() ),
713 mView, SLOT( moveIncidence() ) ); 713 mView, SLOT( moveIncidence() ) );
714 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 714 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
715 mBeamAction->addTo( actionMenu ); 715 mBeamAction->addTo( actionMenu );
716 connect( mBeamAction, SIGNAL( activated() ), 716 connect( mBeamAction, SIGNAL( activated() ),
717 mView, SLOT( beamIncidence() ) ); 717 mView, SLOT( beamIncidence() ) );
718 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 718 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
719 mCancelAction->addTo( actionMenu ); 719 mCancelAction->addTo( actionMenu );
720 connect( mCancelAction, SIGNAL( activated() ), 720 connect( mCancelAction, SIGNAL( activated() ),
721 mView, SLOT( toggleCancelIncidence() ) ); 721 mView, SLOT( toggleCancelIncidence() ) );
722 722
723 actionMenu->insertSeparator(); 723 actionMenu->insertSeparator();
724 724
725 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 725 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
726 this ); 726 this );
727 action->addTo( actionMenu ); 727 action->addTo( actionMenu );
728 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 728 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
729 729
730 icon = loadPixmap( pathString + "search" ); 730 icon = loadPixmap( pathString + "search" );
731 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 731 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
732 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 732 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
733 search_action->addTo( actionMenu ); 733 search_action->addTo( actionMenu );
734 connect( search_action, SIGNAL( activated() ), 734 connect( search_action, SIGNAL( activated() ),
735 mView->dialogManager(), SLOT( showSearchDialog() ) ); 735 mView->dialogManager(), SLOT( showSearchDialog() ) );
736 736
737 icon = loadPixmap( pathString + "today" ); 737 icon = loadPixmap( pathString + "today" );
738 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 738 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
739 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 739 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
740 today_action->addTo( actionMenu ); 740 today_action->addTo( actionMenu );
741 connect( today_action, SIGNAL( activated() ), 741 connect( today_action, SIGNAL( activated() ),
742 mView, SLOT( goToday() ) ); 742 mView, SLOT( goToday() ) );
743 743
744 if ( KOPrefs::instance()->mShowFullMenu ) { 744 if ( KOPrefs::instance()->mShowFullMenu ) {
745 actionMenu->insertSeparator(); 745 actionMenu->insertSeparator();
746 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 746 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
747 747
748 } 748 }
749 // actionMenu->insertSeparator(); 749 // actionMenu->insertSeparator();
750 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 750 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
751 this ); 751 this );
752 action->addTo( importMenu ); 752 action->addTo( importMenu );
753 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 753 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
754 action = new QAction( "import_quick", i18n("Import last file"), 0, 754 action = new QAction( "import_quick", i18n("Import last file"), 0,
755 this ); 755 this );
756 action->addTo( importMenu ); 756 action->addTo( importMenu );
757 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 757 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
758 importMenu->insertSeparator(); 758 importMenu->insertSeparator();
759 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 759 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
760 this ); 760 this );
761 action->addTo( importMenu ); 761 action->addTo( importMenu );
762 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 762 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
763#ifndef DESKTOP_VERSION 763#ifndef DESKTOP_VERSION
764 importMenu->insertSeparator(); 764 importMenu->insertSeparator();
765 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 765 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
766 this ); 766 this );
767 action->addTo( importMenu ); 767 action->addTo( importMenu );
768 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 768 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
769#else 769#else
770#ifdef _WIN32_ 770#ifdef _WIN32_
771 importMenu->insertSeparator(); 771 importMenu->insertSeparator();
772 action = new QAction( "import_ol", i18n("Import from OL"), 0, 772 action = new QAction( "import_ol", i18n("Import from OL"), 0,
773 this ); 773 this );
774 action->addTo( importMenu ); 774 action->addTo( importMenu );
775 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 775 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
776#endif 776#endif
777#endif 777#endif
778 778
779 importMenu->insertSeparator(); 779 importMenu->insertSeparator();
780 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 780 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
781 this ); 781 this );
782 action->addTo( importMenu ); 782 action->addTo( importMenu );
783 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 783 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
784 784
785 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 785 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
786 this ); 786 this );
787 action->addTo( importMenu ); 787 action->addTo( importMenu );
788 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 788 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
789 789
790 importMenu->insertSeparator(); 790 importMenu->insertSeparator();
791 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 791 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
792 this ); 792 this );
793 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 793 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
794 794
795 795
796 //LR 796 //LR
797 QPopupMenu *ex2phone = new QPopupMenu( this ); 797 QPopupMenu *ex2phone = new QPopupMenu( this );
798 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 798 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
799 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 799 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
800 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 800 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
801 importMenu->insertItem( i18n("Export to phone"), ex2phone ); 801 importMenu->insertItem( i18n("Export to phone"), ex2phone );
802 802
803 importMenu->insertSeparator(); 803 importMenu->insertSeparator();
804 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 804 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
805 this ); 805 this );
806 action->addTo( importMenu ); 806 action->addTo( importMenu );
807 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 807 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
808#ifndef DESKTOP_VERSION 808#ifndef DESKTOP_VERSION
809 importMenu->insertSeparator(); 809 importMenu->insertSeparator();
810 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, 810 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0,
811 this ); 811 this );
812 brAction->addTo( importMenu ); 812 brAction->addTo( importMenu );
813 brAction->setToggleAction (true ) ; 813 brAction->setToggleAction (true ) ;
814 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); 814 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) );
815 815
816 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 816 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
817 this ); 817 this );
818 action->addTo( importMenu ); 818 action->addTo( importMenu );
819 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 819 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
820 820
821 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 821 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
822 this ); 822 this );
823 action->addTo( importMenu ); 823 action->addTo( importMenu );
824 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 824 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
825#else 825#else
826 importMenu->insertSeparator(); 826 importMenu->insertSeparator();
827 icon = loadPixmap( pathString + "print" ); 827 icon = loadPixmap( pathString + "print" );
828 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 828 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
829 action->addTo( importMenu ); 829 action->addTo( importMenu );
830 connect( action, SIGNAL( activated() ), 830 connect( action, SIGNAL( activated() ),
831 this, SLOT( printCal() ) ); 831 this, SLOT( printCal() ) );
832 832
833 icon = loadPixmap( pathString + "print" ); 833 icon = loadPixmap( pathString + "print" );
834 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 834 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
835 action->addTo( importMenu ); 835 action->addTo( importMenu );
836 connect( action, SIGNAL( activated() ), 836 connect( action, SIGNAL( activated() ),
837 this, SLOT( printSel() ) ); 837 this, SLOT( printSel() ) );
838#endif 838#endif
839 importMenu->insertSeparator(); 839 importMenu->insertSeparator();
840 action = new QAction( "beam all", i18n("Save"), 0, 840 action = new QAction( "beam all", i18n("Save"), 0,
841 this ); 841 this );
842 action->addTo( importMenu ); 842 action->addTo( importMenu );
843 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 843 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
844 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 844 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
845 this ); 845 this );
846 action->addTo( importMenu ); 846 action->addTo( importMenu );
847 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 847 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
848 848
849 //menuBar->insertItem( "Configure",configureMenu ); 849 //menuBar->insertItem( "Configure",configureMenu );
850 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 850 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
851 icon = loadPixmap( "korganizer/korganizer" ); 851 icon = loadPixmap( "korganizer/korganizer" );
852 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 852 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
853 action->addTo( helpMenu ); 853 action->addTo( helpMenu );
854 connect( action, SIGNAL( activated() ), 854 connect( action, SIGNAL( activated() ),
855 SLOT( keyBindings() ) ); 855 SLOT( keyBindings() ) );
856 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 856 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
857 action->addTo( helpMenu ); 857 action->addTo( helpMenu );
858 connect( action, SIGNAL( activated() ), 858 connect( action, SIGNAL( activated() ),
859 SLOT( features() ) ); 859 SLOT( features() ) );
860 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 860 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
861 action->addTo( helpMenu ); 861 action->addTo( helpMenu );
862 connect( action, SIGNAL( activated() ), 862 connect( action, SIGNAL( activated() ),
863 SLOT( aboutAutoSaving() ) ); 863 SLOT( aboutAutoSaving() ) );
864 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 864 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
865 action->addTo( helpMenu ); 865 action->addTo( helpMenu );
866 connect( action, SIGNAL( activated() ), 866 connect( action, SIGNAL( activated() ),
867 SLOT( aboutKnownBugs() ) ); 867 SLOT( aboutKnownBugs() ) );
868 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 868 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
869 action->addTo( helpMenu ); 869 action->addTo( helpMenu );
870 connect( action, SIGNAL( activated() ), 870 connect( action, SIGNAL( activated() ),
871 SLOT( usertrans() ) ); 871 SLOT( usertrans() ) );
872 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 872 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
873 action->addTo( helpMenu ); 873 action->addTo( helpMenu );
874 connect( action, SIGNAL( activated() ), 874 connect( action, SIGNAL( activated() ),
875 SLOT( synchowto() ) ); 875 SLOT( synchowto() ) );
876 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 876 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
877 action->addTo( helpMenu ); 877 action->addTo( helpMenu );
878 connect( action, SIGNAL( activated() ), 878 connect( action, SIGNAL( activated() ),
879 SLOT( whatsNew() ) ); 879 SLOT( whatsNew() ) );
880 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 880 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
881 action->addTo( helpMenu ); 881 action->addTo( helpMenu );
882 connect( action, SIGNAL( activated() ), 882 connect( action, SIGNAL( activated() ),
883 SLOT( faq() ) ); 883 SLOT( faq() ) );
884 884
885 885
886 action = new QAction( "about", i18n("About..."), 0, this ); 886 action = new QAction( "about", i18n("About..."), 0, this );
887 action->addTo( helpMenu ); 887 action->addTo( helpMenu );
888 connect( action, SIGNAL( activated() ), 888 connect( action, SIGNAL( activated() ),
889 SLOT( about() ) ); 889 SLOT( about() ) );
890 action = new QAction( "licence", i18n("Licence..."), 0, this ); 890 action = new QAction( "licence", i18n("Licence..."), 0, this );
891 action->addTo( helpMenu ); 891 action->addTo( helpMenu );
892 connect( action, SIGNAL( activated() ), 892 connect( action, SIGNAL( activated() ),
893 SLOT( licence() ) ); 893 SLOT( licence() ) );
894 //menuBar->insertSeparator(); 894 //menuBar->insertSeparator();
895 895
896 // ****************************************************** 896 // ******************************************************
897 // menubar icons 897 // menubar icons
898 898
899 899
900 iconToolBar->setHorizontalStretchable (true ); 900 iconToolBar->setHorizontalStretchable (true );
901 //menuBar->insertItem( iconToolBar ); 901 //menuBar->insertItem( iconToolBar );
902 //xdays_action 902 //xdays_action
903 if (p-> mShowIconNewEvent) 903 if (p-> mShowIconNewEvent)
904 ne_action->addTo( iconToolBar ); 904 ne_action->addTo( iconToolBar );
905 if (p->mShowIconNewTodo ) 905 if (p->mShowIconNewTodo )
906 nt_action->addTo( iconToolBar ); 906 nt_action->addTo( iconToolBar );
907 if (p-> mShowIconSearch) 907 if (p-> mShowIconSearch)
908 search_action->addTo( iconToolBar ); 908 search_action->addTo( iconToolBar );
909 if (p-> mShowIconNext) 909 if (p-> mShowIconNext)
910 whatsnext_action->addTo( iconToolBar ); 910 whatsnext_action->addTo( iconToolBar );
911 if (p-> mShowIconNextDays) 911 if (p-> mShowIconNextDays)
912 xdays_action->addTo( iconToolBar ); 912 xdays_action->addTo( iconToolBar );
913 if (p-> mShowIconList) 913 if (p-> mShowIconList)
914 showlist_action->addTo( iconToolBar ); 914 showlist_action->addTo( iconToolBar );
915 if (p-> mShowIconDay1) 915 if (p-> mShowIconDay1)
916 day1_action->addTo( iconToolBar ); 916 day1_action->addTo( iconToolBar );
917 if (p-> mShowIconDay5) 917 if (p-> mShowIconDay5)
918 day5_action->addTo( iconToolBar ); 918 day5_action->addTo( iconToolBar );
919 if (p-> mShowIconDay7) 919 if (p-> mShowIconDay7)
920 day7_action->addTo( iconToolBar ); 920 day7_action->addTo( iconToolBar );
921 if (p-> mShowIconMonth) 921 if (p-> mShowIconMonth)
922 month_action->addTo( iconToolBar ); 922 month_action->addTo( iconToolBar );
923 if (p-> mShowIconTodoview) 923 if (p-> mShowIconTodoview)
924 todoview_action->addTo( iconToolBar ); 924 todoview_action->addTo( iconToolBar );
925 if (p-> mShowIconJournal) 925 if (p-> mShowIconJournal)
926 viewjournal_action->addTo( iconToolBar ); 926 viewjournal_action->addTo( iconToolBar );
927 icon = loadPixmap( pathString + "2leftarrowB" ); 927 icon = loadPixmap( pathString + "2leftarrowB" );
928 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 928 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
929 if (p-> mShowIconBackFast) { 929 if (p-> mShowIconBackFast) {
930 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 930 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
931 connect( action, SIGNAL( activated() ), 931 connect( action, SIGNAL( activated() ),
932 mView, SLOT( goPreviousMonth() ) ); 932 mView, SLOT( goPreviousMonth() ) );
933 action->addTo( iconToolBar ); 933 action->addTo( iconToolBar );
934 } 934 }
935 icon = loadPixmap( pathString + "1leftarrowB" ); 935 icon = loadPixmap( pathString + "1leftarrowB" );
936 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 936 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
937 if (p-> mShowIconBack) { 937 if (p-> mShowIconBack) {
938 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 938 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
939 connect( action, SIGNAL( activated() ), 939 connect( action, SIGNAL( activated() ),
940 mView, SLOT( goPrevious() ) ); 940 mView, SLOT( goPrevious() ) );
941 action->addTo( iconToolBar ); 941 action->addTo( iconToolBar );
942 } 942 }
943 if (p-> mShowIconToday) 943 if (p-> mShowIconToday)
944 today_action->addTo( iconToolBar ); 944 today_action->addTo( iconToolBar );
945 icon = loadPixmap( pathString + "1rightarrowB" ); 945 icon = loadPixmap( pathString + "1rightarrowB" );
946 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 946 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
947 if (p-> mShowIconForward) { 947 if (p-> mShowIconForward) {
948 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 948 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
949 connect( action, SIGNAL( activated() ), 949 connect( action, SIGNAL( activated() ),
950 mView, SLOT( goNext() ) ); 950 mView, SLOT( goNext() ) );
951 action->addTo( iconToolBar ); 951 action->addTo( iconToolBar );
952 } 952 }
953 icon = loadPixmap( pathString + "2rightarrowB" ); 953 icon = loadPixmap( pathString + "2rightarrowB" );
954 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 954 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
955 if (p-> mShowIconForwardFast) { 955 if (p-> mShowIconForwardFast) {
956 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 956 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
957 connect( action, SIGNAL( activated() ), 957 connect( action, SIGNAL( activated() ),
958 mView, SLOT( goNextMonth() ) ); 958 mView, SLOT( goNextMonth() ) );
959 action->addTo( iconToolBar ); 959 action->addTo( iconToolBar );
960 } 960 }
961 961
962 962
963 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 963 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
964 964
965 if (p-> mShowIconNewEvent) 965 if (p-> mShowIconNewEvent)
966 configureToolBarMenu->setItemChecked( 10, true ); 966 configureToolBarMenu->setItemChecked( 10, true );
967 if (p->mShowIconNewTodo ) 967 if (p->mShowIconNewTodo )
968 configureToolBarMenu->setItemChecked( 20, true ); 968 configureToolBarMenu->setItemChecked( 20, true );
969 if (p-> mShowIconSearch) 969 if (p-> mShowIconSearch)
970 configureToolBarMenu->setItemChecked( 120, true ); 970 configureToolBarMenu->setItemChecked( 120, true );
971 if (p-> mShowIconList) 971 if (p-> mShowIconList)
972 configureToolBarMenu->setItemChecked( 30, true ); 972 configureToolBarMenu->setItemChecked( 30, true );
973 if (p-> mShowIconDay1) 973 if (p-> mShowIconDay1)
974 configureToolBarMenu->setItemChecked( 40, true ); 974 configureToolBarMenu->setItemChecked( 40, true );
975 if (p-> mShowIconDay5) 975 if (p-> mShowIconDay5)
976 configureToolBarMenu->setItemChecked( 50, true ); 976 configureToolBarMenu->setItemChecked( 50, true );
977 if (p-> mShowIconDay7) 977 if (p-> mShowIconDay7)
978 configureToolBarMenu->setItemChecked( 60, true ); 978 configureToolBarMenu->setItemChecked( 60, true );
979 if (p-> mShowIconMonth) 979 if (p-> mShowIconMonth)
980 configureToolBarMenu->setItemChecked( 70, true ); 980 configureToolBarMenu->setItemChecked( 70, true );
981 if (p-> mShowIconTodoview) 981 if (p-> mShowIconTodoview)
982 configureToolBarMenu->setItemChecked( 80, true ); 982 configureToolBarMenu->setItemChecked( 80, true );
983 if (p-> mShowIconBackFast) 983 if (p-> mShowIconBackFast)
984 configureToolBarMenu->setItemChecked( 200, true ); 984 configureToolBarMenu->setItemChecked( 200, true );
985 if (p-> mShowIconBack) 985 if (p-> mShowIconBack)
986 configureToolBarMenu->setItemChecked( 210, true ); 986 configureToolBarMenu->setItemChecked( 210, true );
987 if (p-> mShowIconToday) 987 if (p-> mShowIconToday)
988 configureToolBarMenu->setItemChecked( 130, true ); 988 configureToolBarMenu->setItemChecked( 130, true );
989 if (p-> mShowIconForward) 989 if (p-> mShowIconForward)
990 configureToolBarMenu->setItemChecked( 220, true ); 990 configureToolBarMenu->setItemChecked( 220, true );
991 if (p-> mShowIconForwardFast) 991 if (p-> mShowIconForwardFast)
992 configureToolBarMenu->setItemChecked( 230, true ); 992 configureToolBarMenu->setItemChecked( 230, true );
993 if (p-> mShowIconNextDays) 993 if (p-> mShowIconNextDays)
994 configureToolBarMenu->setItemChecked( 100, true ); 994 configureToolBarMenu->setItemChecked( 100, true );
995 if (p-> mShowIconNext) 995 if (p-> mShowIconNext)
996 configureToolBarMenu->setItemChecked( 110, true ); 996 configureToolBarMenu->setItemChecked( 110, true );
997 if (p-> mShowIconJournal) 997 if (p-> mShowIconJournal)
998 configureToolBarMenu->setItemChecked( 90, true ); 998 configureToolBarMenu->setItemChecked( 90, true );
999 if (p-> mShowIconWhatsThis) 999 if (p-> mShowIconWhatsThis)
1000 configureToolBarMenu->setItemChecked( 300, true ); 1000 configureToolBarMenu->setItemChecked( 300, true );
1001 1001
1002 QLabel* dummy = new QLabel( iconToolBar ); 1002 QLabel* dummy = new QLabel( iconToolBar );
1003 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 1003 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
1004 if (!p-> mShowIconStretch) 1004 if (!p-> mShowIconStretch)
1005 iconToolBar->setStretchableWidget ( dummy ) ; 1005 iconToolBar->setStretchableWidget ( dummy ) ;
1006 else 1006 else
1007 configureToolBarMenu->setItemChecked( 5, true ); 1007 configureToolBarMenu->setItemChecked( 5, true );
1008 if (p-> mShowIconWhatsThis) 1008 if (p-> mShowIconWhatsThis)
1009 QWhatsThis::whatsThisButton ( iconToolBar ); 1009 QWhatsThis::whatsThisButton ( iconToolBar );
1010 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 1010 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
1011 configureAgenda( p->mHourSize ); 1011 configureAgenda( p->mHourSize );
1012 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 1012 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
1013} 1013}
1014 1014
1015void MainWindow::exportToPhone( int mode ) 1015void MainWindow::exportToPhone( int mode )
1016{ 1016{
1017 1017
1018 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1018 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1019 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1019 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1020 KOex2phonePrefs ex2phone; 1020 KOex2phonePrefs ex2phone;
1021 1021
1022 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 1022 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
1023 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 1023 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
1024 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1024 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
1025 if ( mode == 1 ) 1025 if ( mode == 1 )
1026 ex2phone.setCaption(i18n("Export complete calendar")); 1026 ex2phone.setCaption(i18n("Export complete calendar"));
1027 if ( mode == 2 ) 1027 if ( mode == 2 )
1028 ex2phone.setCaption(i18n("Export filtered calendar")); 1028 ex2phone.setCaption(i18n("Export filtered calendar"));
1029 1029
1030 if ( !ex2phone.exec() ) { 1030 if ( !ex2phone.exec() ) {
1031 return; 1031 return;
1032 } 1032 }
1033 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 1033 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1034 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 1034 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1035 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 1035 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1036 1036
1037 int inFuture = 0; 1037 int inFuture = 0;
1038 if ( ex2phone.mWriteBackFuture->isChecked() ) 1038 if ( ex2phone.mWriteBackFuture->isChecked() )
1039 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 1039 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1040 QPtrList<Incidence> delSel; 1040 QPtrList<Incidence> delSel;
1041 if ( mode == 1 ) 1041 if ( mode == 1 )
1042 delSel = mCalendar->rawIncidences(); 1042 delSel = mCalendar->rawIncidences();
1043 if ( mode == 2 ) 1043 if ( mode == 2 )
1044 delSel = mCalendar->incidences(); 1044 delSel = mCalendar->incidences();
1045 CalendarLocal* cal = new CalendarLocal(); 1045 CalendarLocal* cal = new CalendarLocal();
1046 cal->setLocalTime(); 1046 cal->setLocalTime();
1047 Incidence *incidence = delSel.first(); 1047 Incidence *incidence = delSel.first();
1048 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1048 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1049 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 1049 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1050 while ( incidence ) { 1050 while ( incidence ) {
1051 if ( incidence->type() != "Journal" ) { 1051 if ( incidence->type() != "Journal" ) {
1052 bool add = true; 1052 bool add = true;
1053 if ( inFuture ) { 1053 if ( inFuture ) {
1054 QDateTime dt; 1054 QDateTime dt;
1055 if ( incidence->type() == "Todo" ) { 1055 if ( incidence->type() == "Todo" ) {
1056 Todo * t = (Todo*)incidence; 1056 Todo * t = (Todo*)incidence;
1057 if ( t->hasDueDate() ) 1057 if ( t->hasDueDate() )
1058 dt = t->dtDue(); 1058 dt = t->dtDue();
1059 else 1059 else
1060 dt = cur.addSecs( 62 ); 1060 dt = cur.addSecs( 62 );
1061 } 1061 }
1062 else { 1062 else {
1063 bool ok; 1063 bool ok;
1064 dt = incidence->getNextOccurence( cur, &ok ); 1064 dt = incidence->getNextOccurence( cur, &ok );
1065 if ( !ok ) 1065 if ( !ok )
1066 dt = cur.addSecs( -62 ); 1066 dt = cur.addSecs( -62 );
1067 } 1067 }
1068 if ( dt < cur || dt > end ) { 1068 if ( dt < cur || dt > end ) {
1069 add = false; 1069 add = false;
1070 } 1070 }
1071 } 1071 }
1072 if ( add ) { 1072 if ( add ) {
1073 Incidence *in = incidence->clone(); 1073 Incidence *in = incidence->clone();
1074 cal->addIncidence( in ); 1074 cal->addIncidence( in );
1075 } 1075 }
1076 } 1076 }
1077 incidence = delSel.next(); 1077 incidence = delSel.next();
1078 } 1078 }
1079 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1079 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1080 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1080 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1081 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1081 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1082 1082
1083 setCaption( i18n("Writing to phone...")); 1083 setCaption( i18n("Writing to phone..."));
1084 if ( PhoneFormat::writeToPhone( cal ) ) 1084 if ( PhoneFormat::writeToPhone( cal ) )
1085 setCaption( i18n("Export to phone successful!")); 1085 setCaption( i18n("Export to phone successful!"));
1086 else 1086 else
1087 setCaption( i18n("Error exporting to phone!")); 1087 setCaption( i18n("Error exporting to phone!"));
1088 delete cal; 1088 delete cal;
1089} 1089}
1090 1090
1091 1091
1092void MainWindow::setDefaultPreferences() 1092void MainWindow::setDefaultPreferences()
1093{ 1093{
1094 KOPrefs *p = KOPrefs::instance(); 1094 KOPrefs *p = KOPrefs::instance();
1095 1095
1096 p->mCompactDialogs = true; 1096 p->mCompactDialogs = true;
1097 p->mConfirm = true; 1097 p->mConfirm = true;
1098 // p->mEnableQuickTodo = false; 1098 // p->mEnableQuickTodo = false;
1099 1099
1100} 1100}
1101 1101
1102QString MainWindow::resourcePath() 1102QString MainWindow::resourcePath()
1103{ 1103{
1104 return KGlobal::iconLoader()->iconPath(); 1104 return KGlobal::iconLoader()->iconPath();
1105} 1105}
1106 1106
1107void MainWindow::displayText( QString text ,QString cap ) 1107void MainWindow::displayText( QString text ,QString cap )
1108{ 1108{
1109 QDialog dia( this, "name", true ); ; 1109 QDialog dia( this, "name", true ); ;
1110 dia.setCaption( cap ); 1110 dia.setCaption( cap );
1111 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1111 QVBoxLayout* lay = new QVBoxLayout( &dia );
1112 lay->setSpacing( 3 ); 1112 lay->setSpacing( 3 );
1113 lay->setMargin( 3 ); 1113 lay->setMargin( 3 );
1114 QTextBrowser tb ( &dia ); 1114 QTextBrowser tb ( &dia );
1115 lay->addWidget( &tb ); 1115 lay->addWidget( &tb );
1116 tb.setText( text ); 1116 tb.setText( text );
1117#ifdef DESKTOP_VERSION 1117#ifdef DESKTOP_VERSION
1118 dia.resize( 640, 480); 1118 dia.resize( 640, 480);
1119#else 1119#else
1120 dia.showMaximized(); 1120 dia.showMaximized();
1121#endif 1121#endif
1122 dia.exec(); 1122 dia.exec();
1123} 1123}
1124void MainWindow::displayFile( QString fn, QString cap ) 1124void MainWindow::displayFile( QString fn, QString cap )
1125{ 1125{
1126 QString fileName = resourcePath() + fn; 1126 QString fileName = resourcePath() + fn;
1127 QString text; 1127 QString text;
1128 QFile file( fileName ); 1128 QFile file( fileName );
1129 if (!file.open( IO_ReadOnly ) ) { 1129 if (!file.open( IO_ReadOnly ) ) {
1130 return ; 1130 return ;
1131 1131
1132 } 1132 }
1133 QTextStream ts( &file ); 1133 QTextStream ts( &file );
1134 text = ts.read(); 1134 text = ts.read();
1135 file.close(); 1135 file.close();
1136 displayText( text, cap); 1136 displayText( text, cap);
1137} 1137}
1138void MainWindow::features() 1138void MainWindow::features()
1139{ 1139{
1140 1140
1141 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); 1141 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1142} 1142}
1143 1143
1144void MainWindow::usertrans() 1144void MainWindow::usertrans()
1145{ 1145{
1146 1146
1147 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); 1147 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
1148} 1148}
1149 1149
1150void MainWindow::synchowto() 1150void MainWindow::synchowto()
1151{ 1151{
1152 1152
1153 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1153 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1154} 1154}
1155void MainWindow::faq() 1155void MainWindow::faq()
1156{ 1156{
1157 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); 1157 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
1158 1158
1159} 1159}
1160void MainWindow::whatsNew() 1160void MainWindow::whatsNew()
1161{ 1161{
1162 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1162 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1163 1163
1164} 1164}
1165void MainWindow::licence() 1165void MainWindow::licence()
1166{ 1166{
1167 KApplication::showLicence(); 1167 KApplication::showLicence();
1168 1168
1169} 1169}
1170void MainWindow::about() 1170void MainWindow::about()
1171{ 1171{
1172 QString version; 1172 QString version;
1173#include <../version> 1173#include <../version>
1174 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1174 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1175 i18n("KOrganizer/Platform-independent\n") + 1175 i18n("KOrganizer/Platform-independent\n") +
1176 "(KO/Pi) " + version + " - " + 1176 "(KO/Pi) " + version + " - " +
1177 1177
1178#ifdef DESKTOP_VERSION 1178#ifdef DESKTOP_VERSION
1179 i18n("Desktop Edition\n") + 1179 i18n("Desktop Edition\n") +
1180#else 1180#else
1181 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1181 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1182#endif 1182#endif
1183 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") ); 1183 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") );
1184} 1184}
1185void MainWindow::keyBindings() 1185void MainWindow::keyBindings()
1186{ 1186{
1187 QString cap = i18n("Key bindings KOrganizer/Pi"); 1187 QString cap = i18n("Key bindings KOrganizer/Pi");
1188 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1188 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1189 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1189 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1190 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1190 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1191 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1191 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1192 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1192 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1193 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1193 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1194 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1194 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1195 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1195 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1196 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1196 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1197 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1197 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1198 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1198 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1199 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1199 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1200 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1200 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1201 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1201 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1202 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1202 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1203 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1203 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1204 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1204 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1205 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1205 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1206 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1206 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1207 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1207 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1208 i18n("<p><h3>In agenda view:</h3></p>\n") + 1208 i18n("<p><h3>In agenda view:</h3></p>\n") +
1209 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1209 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1210 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1210 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1211 i18n("<p><h3>In todo view:</h3></p>\n") + 1211 i18n("<p><h3>In todo view:</h3></p>\n") +
1212 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ 1212 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
1213 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ 1213 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
1214 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ 1214 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
1215 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1215 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1216 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1216 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1217 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1217 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1218 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1218 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1219 i18n("<p><h3>In list view:</h3></p>\n") + 1219 i18n("<p><h3>In list view:</h3></p>\n") +
1220 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1220 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1221 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1221 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1222 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1222 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1223 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1223 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1224 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1224 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1225 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1225 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1226 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1226 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1227 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1227 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1228 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1228 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1229 i18n("<p><b>E</b>: Edit item</p>\n") + 1229 i18n("<p><b>E</b>: Edit item</p>\n") +
1230 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1230 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1231 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1231 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1232 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1232 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1233 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1233 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1234 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1234 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1235 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1235 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1236 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1236 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1237 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1237 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1238 i18n("<p><b>White</b>: Item readonly</p>\n"); 1238 i18n("<p><b>White</b>: Item readonly</p>\n");
1239 displayText( text, cap); 1239 displayText( text, cap);
1240 1240
1241} 1241}
1242void MainWindow::aboutAutoSaving() 1242void MainWindow::aboutAutoSaving()
1243{ 1243{
1244 QMessageBox* msg; 1244 QMessageBox* msg;
1245 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), 1245 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"),
1246 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, 1246 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,
1247 QMessageBox::Ok, 1247 QMessageBox::Ok,
1248 QMessageBox::NoButton, 1248 QMessageBox::NoButton,
1249 QMessageBox::NoButton); 1249 QMessageBox::NoButton);
1250 msg->exec(); 1250 msg->exec();
1251 delete msg; 1251 delete msg;
1252 1252
1253 1253
1254} 1254}
1255void MainWindow::aboutKnownBugs() 1255void MainWindow::aboutKnownBugs()
1256{ 1256{
1257 QMessageBox* msg; 1257 QMessageBox* msg;
1258 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1258 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1259 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")+ 1259 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")+
1260 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1260 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1261 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1261 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1262 i18n("\nor report them in the bugtracker on\n") + 1262 i18n("\nor report them in the bugtracker on\n") +
1263 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1263 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1264 QMessageBox::NoIcon, 1264 QMessageBox::NoIcon,
1265 QMessageBox::Ok, 1265 QMessageBox::Ok,
1266 QMessageBox::NoButton, 1266 QMessageBox::NoButton,
1267 QMessageBox::NoButton); 1267 QMessageBox::NoButton);
1268 msg->exec(); 1268 msg->exec();
1269 delete msg; 1269 delete msg;
1270 1270
1271} 1271}
1272 1272
1273QString MainWindow::defaultFileName() 1273QString MainWindow::defaultFileName()
1274{ 1274{
1275 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1275 return locateLocal( "data", "korganizer/mycalendar.ics" );
1276} 1276}
1277QString MainWindow::syncFileName() 1277QString MainWindow::syncFileName()
1278{ 1278{
1279#ifdef DESKTOP_VERSION 1279#ifdef DESKTOP_VERSION
1280 return locateLocal( "tmp", "synccalendar.ics" ); 1280 return locateLocal( "tmp", "synccalendar.ics" );
1281#else 1281#else
1282 return QString( "/tmp/synccalendar.ics" ); 1282 return QString( "/tmp/synccalendar.ics" );
1283#endif 1283#endif
1284} 1284}
1285 1285
1286void MainWindow::processIncidenceSelection( Incidence *incidence ) 1286void MainWindow::processIncidenceSelection( Incidence *incidence )
1287{ 1287{
1288 if ( !incidence ) { 1288 if ( !incidence ) {
1289 enableIncidenceActions( false ); 1289 enableIncidenceActions( false );
1290 1290
1291 mNewSubTodoAction->setEnabled( false ); 1291 mNewSubTodoAction->setEnabled( false );
1292 setCaptionToDates(); 1292 setCaptionToDates();
1293 return; 1293 return;
1294 1294
1295 } 1295 }
1296 1296
1297 //KGlobal::locale()->formatDateTime(nextA, true); 1297 //KGlobal::locale()->formatDateTime(nextA, true);
1298 QString startString = ""; 1298 QString startString = "";
1299 if ( incidence->type() != "Todo" ) { 1299 if ( incidence->type() != "Todo" ) {
1300 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1300 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1301 if ( incidence->doesFloat() ) { 1301 if ( incidence->doesFloat() ) {
1302 startString += ": "+incidence->dtStartDateStr( true ); 1302 startString += ": "+incidence->dtStartDateStr( true );
1303 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1303 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1304 1304
1305 } else { 1305 } else {
1306 startString = ": "+incidence->dtStartStr(true); 1306 startString = ": "+incidence->dtStartStr(true);
1307 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1307 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1308 1308
1309 } 1309 }
1310 1310
1311 } else { 1311 } else {
1312 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1312 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1313 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1313 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1314 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1314 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1315 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1315 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1316 } 1316 }
1317 1317
1318 } 1318 }
1319 else 1319 else
1320 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1320 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1321 if ( !incidence->location().isEmpty() ) 1321 if ( !incidence->location().isEmpty() )
1322 startString += " (" +incidence->location()+")"; 1322 startString += " (" +incidence->location()+")";
1323 setCaption( incidence->summary()+startString); 1323 setCaption( incidence->summary()+startString);
1324 1324
1325 enableIncidenceActions( true ); 1325 enableIncidenceActions( true );
1326 1326
1327 if ( incidence->type() == "Event" ) { 1327 if ( incidence->type() == "Event" ) {
1328 mShowAction->setText( i18n("Show Event...") ); 1328 mShowAction->setText( i18n("Show Event...") );
1329 mEditAction->setText( i18n("Edit Event...") ); 1329 mEditAction->setText( i18n("Edit Event...") );
1330 mDeleteAction->setText( i18n("Delete Event...") ); 1330 mDeleteAction->setText( i18n("Delete Event...") );
1331 1331
1332 mNewSubTodoAction->setEnabled( false ); 1332 mNewSubTodoAction->setEnabled( false );
1333 } else if ( incidence->type() == "Todo" ) { 1333 } else if ( incidence->type() == "Todo" ) {
1334 mShowAction->setText( i18n("Show Todo...") ); 1334 mShowAction->setText( i18n("Show Todo...") );
1335 mEditAction->setText( i18n("Edit Todo...") ); 1335 mEditAction->setText( i18n("Edit Todo...") );
1336 mDeleteAction->setText( i18n("Delete Todo...") ); 1336 mDeleteAction->setText( i18n("Delete Todo...") );
1337 1337
1338 mNewSubTodoAction->setEnabled( true ); 1338 mNewSubTodoAction->setEnabled( true );
1339 } else { 1339 } else {
1340 mShowAction->setText( i18n("Show...") ); 1340 mShowAction->setText( i18n("Show...") );
1341 mShowAction->setText( i18n("Edit...") ); 1341 mShowAction->setText( i18n("Edit...") );
1342 mShowAction->setText( i18n("Delete...") ); 1342 mShowAction->setText( i18n("Delete...") );
1343 1343
1344 mNewSubTodoAction->setEnabled( false ); 1344 mNewSubTodoAction->setEnabled( false );
1345 } 1345 }
1346} 1346}
1347 1347
1348void MainWindow::enableIncidenceActions( bool enabled ) 1348void MainWindow::enableIncidenceActions( bool enabled )
1349{ 1349{
1350 mShowAction->setEnabled( enabled ); 1350 mShowAction->setEnabled( enabled );
1351 mEditAction->setEnabled( enabled ); 1351 mEditAction->setEnabled( enabled );
1352 mDeleteAction->setEnabled( enabled ); 1352 mDeleteAction->setEnabled( enabled );
1353 1353
1354 mCloneAction->setEnabled( enabled ); 1354 mCloneAction->setEnabled( enabled );
1355 mMoveAction->setEnabled( enabled ); 1355 mMoveAction->setEnabled( enabled );
1356 mBeamAction->setEnabled( enabled ); 1356 mBeamAction->setEnabled( enabled );
1357 mCancelAction->setEnabled( enabled ); 1357 mCancelAction->setEnabled( enabled );
1358} 1358}
1359 1359
1360void MainWindow::importOL() 1360void MainWindow::importOL()
1361{ 1361{
1362#ifdef _WIN32_ 1362#ifdef _WIN32_
1363 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1363 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1364 id->exec(); 1364 id->exec();
1365 delete id; 1365 delete id;
1366 mView->updateView(); 1366 mView->updateView();
1367#endif 1367#endif
1368} 1368}
1369void MainWindow::importBday() 1369void MainWindow::importBday()
1370{ 1370{
1371 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1371 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1372 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1372 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1373 i18n("Import!"), i18n("Cancel"), 0, 1373 i18n("Import!"), i18n("Cancel"), 0,
1374 0, 1 ); 1374 0, 1 );
1375 if ( result == 0 ) { 1375 if ( result == 0 ) {
1376 mView->importBday(); 1376 mView->importBday();
1377 1377
1378 } 1378 }
1379 1379
1380 1380
1381} 1381}
1382void MainWindow::importQtopia() 1382void MainWindow::importQtopia()
1383{ 1383{
1384#ifndef DESKTOP_VERSION 1384#ifndef DESKTOP_VERSION
1385 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1385 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1386 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"), 1386 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"),
1387 i18n("Import!"), i18n("Cancel"), 0, 1387 i18n("Import!"), i18n("Cancel"), 0,
1388 0, 1 ); 1388 0, 1 );
1389 if ( result == 0 ) { 1389 if ( result == 0 ) {
1390 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1390 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1391 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1391 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1392 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1392 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1393 mView->importQtopia( categories, datebook, todolist ); 1393 mView->importQtopia( categories, datebook, todolist );
1394 } 1394 }
1395#else 1395#else
1396 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1396 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1397 i18n("Not supported \non desktop!\n"), 1397 i18n("Not supported \non desktop!\n"),
1398 i18n("Ok"), i18n("Cancel"), 0, 1398 i18n("Ok"), i18n("Cancel"), 0,
1399 0, 1 ); 1399 0, 1 );
1400 1400
1401#endif 1401#endif
1402} 1402}
1403 1403
1404void MainWindow::saveOnClose() 1404void MainWindow::saveOnClose()
1405{ 1405{
1406 KOPrefs *p = KOPrefs::instance(); 1406 KOPrefs *p = KOPrefs::instance();
1407 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1407 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1408 p->mToolBarUp = iconToolBar->x() > width()/2 || 1408 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1409 iconToolBar->y() > height()/2; 1409 iconToolBar->y() > height()/2;
1410 mView->writeSettings(); 1410 mView->writeSettings();
1411 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1411 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1412 save(); 1412 save();
1413} 1413}
1414void MainWindow::slotModifiedChanged( bool changed ) 1414void MainWindow::slotModifiedChanged( bool changed )
1415{ 1415{
1416 if ( mBlockAtStartup ) 1416 if ( mBlockAtStartup )
1417 return; 1417 return;
1418 int msec; 1418 int msec;
1419 // we store the changes after 1 minute, 1419 // we store the changes after 1 minute,
1420 // and for safety reasons after 10 minutes again 1420 // and for safety reasons after 10 minutes again
1421 if ( !mSyncManager->blockSave() ) 1421 if ( !mSyncManager->blockSave() )
1422 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1422 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1423 else 1423 else
1424 msec = 1000 * 600; 1424 msec = 1000 * 600;
1425 mSaveTimer.start( msec, true ); // 1 minute 1425 mSaveTimer.start( msec, true ); // 1 minute
1426 qDebug("KO: Saving File in %d secs!", msec/1000); 1426 qDebug("KO: Saving File in %d secs!", msec/1000);
1427 mCalendarModifiedFlag = true; 1427 mCalendarModifiedFlag = true;
1428} 1428}
1429void MainWindow::save() 1429void MainWindow::save()
1430{ 1430{
1431 if ( mSyncManager->blockSave() ) 1431 if ( mSyncManager->blockSave() )
1432 return; 1432 return;
1433 mSyncManager->setBlockSave(true); 1433 mSyncManager->setBlockSave(true);
1434 if ( mView->checkFileVersion( defaultFileName()) ) { 1434 if ( mView->checkFileVersion( defaultFileName()) ) {
1435 1435
1436 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1436 QTime neededSaveTime = QDateTime::currentDateTime().time();
1437 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1437 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1438 qDebug("KO: Start saving data to file!"); 1438 qDebug("KO: Start saving data to file!");
1439 mView->saveCalendar( defaultFileName() ); 1439 mView->saveCalendar( defaultFileName() );
1440 1440
1441 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1441 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1442 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1442 qDebug("KO: Needed %d ms for saving.",msNeeded );
1443 QString savemes; 1443 QString savemes;
1444 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1444 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1445 setCaption(savemes); 1445 setCaption(savemes);
1446 } else 1446 } else
1447 setCaption(i18n("Saving cancelled!")); 1447 setCaption(i18n("Saving cancelled!"));
1448 mCalendarModifiedFlag = false; 1448 mCalendarModifiedFlag = false;
1449 mSyncManager->setBlockSave( false ); 1449 mSyncManager->setBlockSave( false );
1450} 1450}
1451 1451
1452void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1452void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1453{ 1453{
1454 if ( !e->isAutoRepeat() ) { 1454 if ( !e->isAutoRepeat() ) {
1455 mFlagKeyPressed = false; 1455 mFlagKeyPressed = false;
1456 } 1456 }
1457} 1457}
1458void MainWindow::keyPressEvent ( QKeyEvent * e ) 1458void MainWindow::keyPressEvent ( QKeyEvent * e )
1459{ 1459{
1460 qApp->processEvents(); 1460 qApp->processEvents();
1461 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1461 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1462 e->ignore(); 1462 e->ignore();
1463 // qDebug(" ignore %d",e->isAutoRepeat() ); 1463 // qDebug(" ignore %d",e->isAutoRepeat() );
1464 return; 1464 return;
1465 } 1465 }
1466 if (! e->isAutoRepeat() ) 1466 if (! e->isAutoRepeat() )
1467 mFlagKeyPressed = true; 1467 mFlagKeyPressed = true;
1468 KOPrefs *p = KOPrefs::instance(); 1468 KOPrefs *p = KOPrefs::instance();
1469 bool showSelectedDates = false; 1469 bool showSelectedDates = false;
1470 int size; 1470 int size;
1471 int pro = 0; 1471 int pro = 0;
1472 //qDebug("MainWindow::keyPressEvent "); 1472 //qDebug("MainWindow::keyPressEvent ");
1473 switch ( e->key() ) { 1473 switch ( e->key() ) {
1474 case Qt::Key_Right: 1474 case Qt::Key_Right:
1475 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1475 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1476 mView->goNextMonth(); 1476 mView->goNextMonth();
1477 else 1477 else
1478 mView->goNext(); 1478 mView->goNext();
1479 showSelectedDates = true; 1479 showSelectedDates = true;
1480 break; 1480 break;
1481 case Qt::Key_Left: 1481 case Qt::Key_Left:
1482 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1482 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1483 mView->goPreviousMonth(); 1483 mView->goPreviousMonth();
1484 else 1484 else
1485 mView->goPrevious(); 1485 mView->goPrevious();
1486 showSelectedDates = true; 1486 showSelectedDates = true;
1487 break; 1487 break;
1488 case Qt::Key_Down: 1488 case Qt::Key_Down:
1489 mView->viewManager()->agendaView()->scrollOneHourDown(); 1489 mView->viewManager()->agendaView()->scrollOneHourDown();
1490 break; 1490 break;
1491 case Qt::Key_Up: 1491 case Qt::Key_Up:
1492 mView->viewManager()->agendaView()->scrollOneHourUp(); 1492 mView->viewManager()->agendaView()->scrollOneHourUp();
1493 break; 1493 break;
1494 case Qt::Key_I: 1494 case Qt::Key_I:
1495 mView->showIncidence(); 1495 mView->showIncidence();
1496 break; 1496 break;
1497 case Qt::Key_Delete: 1497 case Qt::Key_Delete:
1498 case Qt::Key_Backspace: 1498 case Qt::Key_Backspace:
1499 mView->deleteIncidence(); 1499 mView->deleteIncidence();
1500 break; 1500 break;
1501 case Qt::Key_D: 1501 case Qt::Key_D:
1502 mView->viewManager()->showDayView(); 1502 mView->viewManager()->showDayView();
1503 showSelectedDates = true; 1503 showSelectedDates = true;
1504 break; 1504 break;
1505 case Qt::Key_O: 1505 case Qt::Key_O:
1506 mView->toggleFilerEnabled( ); 1506 mView->toggleFilerEnabled( );
1507 break; 1507 break;
1508 case Qt::Key_0: 1508 case Qt::Key_0:
1509 case Qt::Key_1: 1509 case Qt::Key_1:
1510 case Qt::Key_2: 1510 case Qt::Key_2:
1511 case Qt::Key_3: 1511 case Qt::Key_3:
1512 case Qt::Key_4: 1512 case Qt::Key_4:
1513 case Qt::Key_5: 1513 case Qt::Key_5:
1514 case Qt::Key_6: 1514 case Qt::Key_6:
1515 case Qt::Key_7: 1515 case Qt::Key_7:
1516 case Qt::Key_8: 1516 case Qt::Key_8:
1517 case Qt::Key_9: 1517 case Qt::Key_9:
1518 pro = e->key()-48; 1518 pro = e->key()-48;
1519 if ( pro == 0 ) 1519 if ( pro == 0 )
1520 pro = 10; 1520 pro = 10;
1521 if ( e->state() == Qt::ControlButton) 1521 if ( e->state() == Qt::ControlButton)
1522 pro += 10; 1522 pro += 10;
1523 break; 1523 break;
1524 case Qt::Key_M: 1524 case Qt::Key_M:
1525 mView->viewManager()->showMonthView(); 1525 mView->viewManager()->showMonthView();
1526 showSelectedDates = true; 1526 showSelectedDates = true;
1527 break; 1527 break;
1528 case Qt::Key_Insert: 1528 case Qt::Key_Insert:
1529 mView->newEvent(); 1529 mView->newEvent();
1530 break; 1530 break;
1531 case Qt::Key_S : 1531 case Qt::Key_S :
1532 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1532 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1533 mView->newSubTodo(); 1533 mView->newSubTodo();
1534 else 1534 else
1535 mView->dialogManager()->showSearchDialog(); 1535 mView->dialogManager()->showSearchDialog();
1536 break; 1536 break;
1537 case Qt::Key_Y : 1537 case Qt::Key_Y :
1538 case Qt::Key_Z : 1538 case Qt::Key_Z :
1539 mView->viewManager()->showWorkWeekView(); 1539 mView->viewManager()->showWorkWeekView();
1540 showSelectedDates = true; 1540 showSelectedDates = true;
1541 break; 1541 break;
1542 case Qt::Key_U : 1542 case Qt::Key_U :
1543 mView->viewManager()->showWeekView(); 1543 mView->viewManager()->showWeekView();
1544 showSelectedDates = true; 1544 showSelectedDates = true;
1545 break; 1545 break;
1546 case Qt::Key_H : 1546 case Qt::Key_H :
1547 keyBindings(); 1547 keyBindings();
1548 break; 1548 break;
1549 case Qt::Key_W: 1549 case Qt::Key_W:
1550 mView->viewManager()->showWhatsNextView(); 1550 mView->viewManager()->showWhatsNextView();
1551 break; 1551 break;
1552 case Qt::Key_L: 1552 case Qt::Key_L:
1553 mView->viewManager()->showListView(); 1553 mView->viewManager()->showListView();
1554 break; 1554 break;
1555 case Qt::Key_N: 1555 case Qt::Key_N:
1556 mView->viewManager()->showNextXView(); 1556 mView->viewManager()->showNextXView();
1557 showSelectedDates = true; 1557 showSelectedDates = true;
1558 break; 1558 break;
1559 case Qt::Key_V: 1559 case Qt::Key_V:
1560 mView->viewManager()->showTodoView(); 1560 mView->viewManager()->showTodoView();
1561 break; 1561 break;
1562 case Qt::Key_C: 1562 case Qt::Key_C:
1563 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1563 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1564 break; 1564 break;
1565 case Qt::Key_P: 1565 case Qt::Key_P:
1566 mView->showDatePicker( ); 1566 mView->showDatePicker( );
1567 break; 1567 break;
1568 case Qt::Key_F: 1568 case Qt::Key_F:
1569 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1569 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1570 mView->editFilters(); 1570 mView->editFilters();
1571 else 1571 else
1572 mView->toggleFilter(); 1572 mView->toggleFilter();
1573 break; 1573 break;
1574 case Qt::Key_X: 1574 case Qt::Key_X:
1575 mView->toggleDateNavigatorWidget(); 1575 mView->toggleDateNavigatorWidget();
1576 break; 1576 break;
1577 case Qt::Key_Space: 1577 case Qt::Key_Space:
1578 mView->toggleExpand(); 1578 mView->toggleExpand();
1579 break; 1579 break;
1580 case Qt::Key_A: 1580 case Qt::Key_A:
1581 mView->toggleAllDaySize(); 1581 mView->toggleAllDaySize();
1582 break; 1582 break;
1583 case Qt::Key_T: 1583 case Qt::Key_T:
1584 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1584 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1585 mView->newTodo(); 1585 mView->newTodo();
1586 else { 1586 else {
1587 mView->goToday(); 1587 mView->goToday();
1588 showSelectedDates = true; 1588 showSelectedDates = true;
1589 } 1589 }
1590 break; 1590 break;
1591 case Qt::Key_J: 1591 case Qt::Key_J:
1592 mView->viewManager()->showJournalView(); 1592 mView->viewManager()->showJournalView();
1593 break; 1593 break;
1594 case Qt::Key_B: 1594 case Qt::Key_B:
1595 mView->editIncidenceDescription();; 1595 mView->editIncidenceDescription();;
1596 break; 1596 break;
1597 // case Qt::Key_Return: 1597 // case Qt::Key_Return:
1598 case Qt::Key_E: 1598 case Qt::Key_E:
1599 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1599 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1600 mView->newEvent(); 1600 mView->newEvent();
1601 else 1601 else
1602 mView->editIncidence(); 1602 mView->editIncidence();
1603 break; 1603 break;
1604 case Qt::Key_Plus: 1604 case Qt::Key_Plus:
1605 size = p->mHourSize +2; 1605 size = p->mHourSize +2;
1606 if ( size <= 18 ) 1606 if ( size <= 18 )
1607 configureAgenda( size ); 1607 configureAgenda( size );
1608 break; 1608 break;
1609 case Qt::Key_Minus: 1609 case Qt::Key_Minus:
1610 size = p->mHourSize - 2; 1610 size = p->mHourSize - 2;
1611 if ( size >= 4 ) 1611 if ( size >= 4 )
1612 configureAgenda( size ); 1612 configureAgenda( size );
1613 break; 1613 break;
1614 1614
1615 1615
1616 default: 1616 default:
1617 e->ignore(); 1617 e->ignore();
1618 } 1618 }
1619 if ( pro > 0 ) { 1619 if ( pro > 0 ) {
1620 mView->selectFilter( pro-1 ); 1620 mView->selectFilter( pro-1 );
1621 } 1621 }
1622 if ( showSelectedDates ) { 1622 if ( showSelectedDates ) {
1623 ;// setCaptionToDates(); 1623 ;// setCaptionToDates();
1624 } 1624 }
1625 1625
1626} 1626}
1627 1627
1628void MainWindow::fillFilterMenu() 1628void MainWindow::fillFilterMenu()
1629{ 1629{
1630 selectFilterMenu->clear(); 1630 selectFilterMenu->clear();
1631 bool disable = false; 1631 bool disable = false;
1632 if ( mView->filterView()->filtersEnabled() ) { 1632 if ( mView->filterView()->filtersEnabled() ) {
1633 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); 1633 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 );
1634 } 1634 }
1635 else { 1635 else {
1636 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); 1636 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 );
1637 disable = true; 1637 disable = true;
1638 } 1638 }
1639 selectFilterMenu->insertSeparator(); 1639 selectFilterMenu->insertSeparator();
1640 QPtrList<CalFilter> fili = mView->filters(); 1640 QPtrList<CalFilter> fili = mView->filters();
1641 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1641 CalFilter *curfilter = mView->filterView()->selectedFilter();
1642 CalFilter *filter = fili.first(); 1642 CalFilter *filter = fili.first();
1643 int iii = 1; 1643 int iii = 1;
1644 while(filter) { 1644 while(filter) {
1645 selectFilterMenu->insertItem( filter->name(), iii ); 1645 selectFilterMenu->insertItem( filter->name(), iii );
1646 if ( filter == curfilter) 1646 if ( filter == curfilter)
1647 selectFilterMenu->setItemChecked( iii, true ); 1647 selectFilterMenu->setItemChecked( iii, true );
1648 if ( disable ) 1648 if ( disable )
1649 selectFilterMenu->setItemEnabled( iii, false ); 1649 selectFilterMenu->setItemEnabled( iii, false );
1650 filter = fili.next(); 1650 filter = fili.next();
1651 ++iii; 1651 ++iii;
1652 } 1652 }
1653} 1653}
1654void MainWindow::selectFilter( int fil ) 1654void MainWindow::selectFilter( int fil )
1655{ 1655{
1656 if ( fil == 0 ) { 1656 if ( fil == 0 ) {
1657 mView->toggleFilerEnabled( ); 1657 mView->toggleFilerEnabled( );
1658 } else { 1658 } else {
1659 mView->selectFilter( fil-1 ); 1659 mView->selectFilter( fil-1 );
1660 } 1660 }
1661} 1661}
1662void MainWindow::configureToolBar( int item ) 1662void MainWindow::configureToolBar( int item )
1663{ 1663{
1664 1664
1665 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1665 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1666 KOPrefs *p = KOPrefs::instance(); 1666 KOPrefs *p = KOPrefs::instance();
1667 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1667 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1668 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1668 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1669 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1669 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1670 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1670 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1671 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1671 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1672 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1672 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1673 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1673 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1674 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1674 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1675 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1675 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1676 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1676 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1677 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1677 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1678 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1678 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1679 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1679 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1680 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1680 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1681 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1681 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1682 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1682 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1683 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1683 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1684 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1684 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1685 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1685 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1686 // initActions(); 1686 // initActions();
1687} 1687}
1688 1688
1689void MainWindow::setCaptionToDates() 1689void MainWindow::setCaptionToDates()
1690{ 1690{
1691 QString selDates; 1691 QString selDates;
1692 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1692 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1693 if (mView->startDate() < mView->endDate() ) 1693 if (mView->startDate() < mView->endDate() )
1694 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1694 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1695 setCaption( i18n("Dates: ") + selDates ); 1695 setCaption( i18n("Dates: ") + selDates );
1696 1696
1697} 1697}
1698// parameter item == 0: reinit 1698// parameter item == 0: reinit
1699void MainWindow::configureAgenda( int item ) 1699void MainWindow::configureAgenda( int item )
1700{ 1700{
1701 1701
1702 KOPrefs *p = KOPrefs::instance(); 1702 KOPrefs *p = KOPrefs::instance();
1703 1703
1704 int i; 1704 int i;
1705 if ( item == 1 ) { 1705 if ( item == 1 ) {
1706 mView->toggleAllDaySize(); 1706 mView->toggleAllDaySize();
1707 return; 1707 return;
1708 } 1708 }
1709 // do not allow 4 for widgets higher than 480 1709 // do not allow 4 for widgets higher than 480
1710 // if ( QApplication::desktop()->height() > 480 ) { 1710 // if ( QApplication::desktop()->height() > 480 ) {
1711// if ( item == 4 ) 1711// if ( item == 4 )
1712// item = 6; 1712// item = 6;
1713// } 1713// }
1714 for ( i = 4; i <= 18; i= i+2 ) 1714 for ( i = 4; i <= 18; i= i+2 )
1715 configureAgendaMenu->setItemChecked( i, false ); 1715 configureAgendaMenu->setItemChecked( i, false );
1716 configureAgendaMenu->setItemChecked( item, true ); 1716 configureAgendaMenu->setItemChecked( item, true );
1717 if ( p->mHourSize == item ) 1717 if ( p->mHourSize == item )
1718 return; 1718 return;
1719 p->mHourSize=item; 1719 p->mHourSize=item;
1720 mView->viewManager()->agendaView()->updateConfig(); 1720 mView->viewManager()->agendaView()->updateConfig();
1721} 1721}
1722 1722
1723void MainWindow::saveCalendar() 1723void MainWindow::saveCalendar()
1724{ 1724{
1725 QString fn = KOPrefs::instance()->mLastSaveFile; 1725 QString fn = KOPrefs::instance()->mLastSaveFile;
1726 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1726 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1727 1727
1728 if ( fn == "" ) 1728 if ( fn == "" )
1729 return; 1729 return;
1730 QFileInfo info; 1730 QFileInfo info;
1731 info.setFile( fn ); 1731 info.setFile( fn );
1732 QString mes; 1732 QString mes;
1733 bool createbup = true; 1733 bool createbup = true;
1734 if ( info. exists() ) { 1734 if ( info. exists() ) {
1735 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1735 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1736 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1736 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1737 i18n("Overwrite!"), i18n("Cancel"), 0, 1737 i18n("Overwrite!"), i18n("Cancel"), 0,
1738 0, 1 ); 1738 0, 1 );
1739 if ( result != 0 ) { 1739 if ( result != 0 ) {
1740 createbup = false; 1740 createbup = false;
1741 } 1741 }
1742 } 1742 }
1743 if ( createbup ) { 1743 if ( createbup ) {
1744 mView->saveCalendar( fn ); 1744 mView->saveCalendar( fn );
1745 mes = i18n("KO/Pi:Saved %1").arg(fn); 1745 mes = i18n("KO/Pi:Saved %1").arg(fn);
1746 KOPrefs::instance()->mLastSaveFile = fn; 1746 KOPrefs::instance()->mLastSaveFile = fn;
1747 setCaption(mes); 1747 setCaption(mes);
1748 } 1748 }
1749} 1749}
1750void MainWindow::loadCalendar() 1750void MainWindow::loadCalendar()
1751{ 1751{
1752 1752
1753 QString fn = KOPrefs::instance()->mLastLoadFile; 1753 QString fn = KOPrefs::instance()->mLastLoadFile;
1754 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1754 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1755 1755
1756 if ( fn == "" ) 1756 if ( fn == "" )
1757 return; 1757 return;
1758 QFileInfo info; 1758 QFileInfo info;
1759 info.setFile( fn ); 1759 info.setFile( fn );
1760 QString mess; 1760 QString mess;
1761 bool loadbup = true; 1761 bool loadbup = true;
1762 if ( info. exists() ) { 1762 if ( info. exists() ) {
1763 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1763 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1764 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1764 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1765 mess, 1765 mess,
1766 i18n("Load!"), i18n("Cancel"), 0, 1766 i18n("Load!"), i18n("Cancel"), 0,
1767 0, 1 ); 1767 0, 1 );
1768 if ( result != 0 ) { 1768 if ( result != 0 ) {
1769 loadbup = false; 1769 loadbup = false;
1770 } 1770 }
1771 } else { 1771 } else {
1772 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1772 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1773 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1773 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1774 0, 1 ); 1774 0, 1 );
1775 1775
1776 return; 1776 return;
1777 } 1777 }
1778 if ( loadbup ) { 1778 if ( loadbup ) {
1779 mView->openCalendar( fn ); 1779 mView->openCalendar( fn );
1780 KOPrefs::instance()->mLastLoadFile = fn; 1780 KOPrefs::instance()->mLastLoadFile = fn;
1781 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1781 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1782 setCaption(mess); 1782 setCaption(mess);
1783 } 1783 }
1784 1784
1785} 1785}
1786void MainWindow::quickImportIcal() 1786void MainWindow::quickImportIcal()
1787{ 1787{
1788 importFile( KOPrefs::instance()->mLastImportFile, false ); 1788 importFile( KOPrefs::instance()->mLastImportFile, false );
1789} 1789}
1790void MainWindow::importFile( QString fn, bool quick ) 1790void MainWindow::importFile( QString fn, bool quick )
1791{ 1791{
1792 QFileInfo info; 1792 QFileInfo info;
1793 info.setFile( fn ); 1793 info.setFile( fn );
1794 QString mess; 1794 QString mess;
1795 bool loadbup = true; 1795 bool loadbup = true;
1796 if ( !info. exists() ) { 1796 if ( !info. exists() ) {
1797 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1797 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1798 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1798 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1799 mess ); 1799 mess );
1800 return; 1800 return;
1801 } 1801 }
1802 int result = 0; 1802 int result = 0;
1803 if ( !quick ) { 1803 if ( !quick ) {
1804 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 )); 1804 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 ));
1805 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1805 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1806 mess, 1806 mess,
1807 "Import", "Cancel", 0, 1807 "Import", "Cancel", 0,
1808 0, 1 ); 1808 0, 1 );
1809 } 1809 }
1810 if ( result == 0 ) { 1810 if ( result == 0 ) {
1811 if ( mView->openCalendar( fn, true )) { 1811 if ( mView->openCalendar( fn, true )) {
1812 KOPrefs::instance()->mLastImportFile = fn; 1812 KOPrefs::instance()->mLastImportFile = fn;
1813 setCaption(i18n("Imported file successfully")); 1813 setCaption(i18n("Imported file successfully"));
1814 } else { 1814 } else {
1815 setCaption(i18n("Error importing file")); 1815 setCaption(i18n("Error importing file"));
1816 } 1816 }
1817 } 1817 }
1818} 1818}