author | zautrix <zautrix> | 2004-10-27 11:17:28 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-27 11:17:28 (UTC) |
commit | f73d249579d52d7aeaacde2dcb23abeb42f9ee95 (patch) (unidiff) | |
tree | 75dfc3cd592804c1b87bd2588df2e856a0ac776b | |
parent | ce5b6b62c92cc051c5c9e780508b6d42c46df8ed (diff) | |
download | kdepimpi-f73d249579d52d7aeaacde2dcb23abeb42f9ee95.zip kdepimpi-f73d249579d52d7aeaacde2dcb23abeb42f9ee95.tar.gz kdepimpi-f73d249579d52d7aeaacde2dcb23abeb42f9ee95.tar.bz2 |
compile fix
-rw-r--r-- | kabc/addressbook.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 4 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 2 |
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 | |||
@@ -195,769 +195,769 @@ AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() | |||
195 | 195 | ||
196 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) | 196 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) |
197 | { | 197 | { |
198 | (d->mIt)++; | 198 | (d->mIt)++; |
199 | return *this; | 199 | return *this; |
200 | } | 200 | } |
201 | 201 | ||
202 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() | 202 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() |
203 | { | 203 | { |
204 | (d->mIt)--; | 204 | (d->mIt)--; |
205 | return *this; | 205 | return *this; |
206 | } | 206 | } |
207 | 207 | ||
208 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) | 208 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) |
209 | { | 209 | { |
210 | (d->mIt)--; | 210 | (d->mIt)--; |
211 | return *this; | 211 | return *this; |
212 | } | 212 | } |
213 | 213 | ||
214 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) | 214 | bool 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 | ||
219 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) | 219 | bool 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 | ||
225 | AddressBook::AddressBook() | 225 | AddressBook::AddressBook() |
226 | { | 226 | { |
227 | init(0, "contact"); | 227 | init(0, "contact"); |
228 | } | 228 | } |
229 | 229 | ||
230 | AddressBook::AddressBook( const QString &config ) | 230 | AddressBook::AddressBook( const QString &config ) |
231 | { | 231 | { |
232 | init(config, "contact"); | 232 | init(config, "contact"); |
233 | } | 233 | } |
234 | 234 | ||
235 | AddressBook::AddressBook( const QString &config, const QString &family ) | 235 | AddressBook::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" |
242 | void AddressBook::init(const QString &config, const QString &family ) | 242 | void 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 | ||
333 | AddressBook::~AddressBook() | 333 | AddressBook::~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 | ||
341 | bool AddressBook::load() | 341 | bool 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 | ||
368 | bool AddressBook::save( Ticket *ticket ) | 368 | bool 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 |
380 | void AddressBook::export2File( QString fileName ) | 380 | void 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 |
410 | bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) | 410 | bool 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 | } |
480 | int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) | 480 | int 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 | } |
515 | void AddressBook::setUntagged(bool setNonSyncTagged) // = false) | 515 | void 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 | } |
528 | void AddressBook::removeUntagged() | 528 | void 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 | } |
546 | void AddressBook::smplifyAddressees() | 546 | void 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 | } |
556 | void AddressBook::removeSyncInfo( QString syncProfile) | 556 | void 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 | } |
585 | void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) | 585 | void 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 | } |
602 | void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice ) | 602 | void 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 | ||
643 | bool AddressBook::saveABphone( QString fileName ) | 643 | bool 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 | } |
659 | bool AddressBook::saveAB() | 659 | bool 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 | ||
705 | AddressBook::Iterator AddressBook::begin() | 705 | AddressBook::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 | ||
712 | AddressBook::ConstIterator AddressBook::begin() const | 712 | AddressBook::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 | ||
719 | AddressBook::Iterator AddressBook::end() | 719 | AddressBook::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 | ||
726 | AddressBook::ConstIterator AddressBook::end() const | 726 | AddressBook::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 | ||
733 | void AddressBook::clear() | 733 | void AddressBook::clear() |
734 | { | 734 | { |
735 | d->mAddressees.clear(); | 735 | d->mAddressees.clear(); |
736 | } | 736 | } |
737 | 737 | ||
738 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) | 738 | Ticket *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); |
761 | void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) | 761 | void 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 | ||
827 | void AddressBook::removeAddressee( const Addressee &a ) | 827 | void 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 | ||
858 | void AddressBook::removeSyncAddressees( bool removeDeleted ) | 858 | void 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 | ||
880 | void AddressBook::removeAddressee( const Iterator &it ) | 880 | void 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 | ||
886 | AddressBook::Iterator AddressBook::find( const Addressee &a ) | 886 | AddressBook::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 | ||
897 | Addressee AddressBook::findByUid( const QString &uid ) | 897 | Addressee 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 | } |
907 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) | 907 | void 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 | } |
917 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) | 917 | void 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 | ||
939 | bool AddressBook::containsExternalUid( const QString& uid ) | 939 | bool 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 | } |
948 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) | 948 | Addressee 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 | } |
957 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) | 957 | void 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() ) { |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index e56e46a..2f00a09 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,704 +1,704 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook. | 2 | This file is part of KAddressbook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /*s | 24 | /*s |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "kabcore.h" | 31 | #include "kabcore.h" |
32 | 32 | ||
33 | #include <stdaddressbook.h> | 33 | #include <stdaddressbook.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kfiledialog.h> | 35 | #include <kfiledialog.h> |
36 | #include <qtimer.h> | 36 | #include <qtimer.h> |
37 | #include <qlabel.h> | 37 | #include <qlabel.h> |
38 | #include <qregexp.h> | 38 | #include <qregexp.h> |
39 | #include <qlineedit.h> | 39 | #include <qlineedit.h> |
40 | #include <qcheckbox.h> | 40 | #include <qcheckbox.h> |
41 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
42 | #include <qprogressbar.h> | 42 | #include <qprogressbar.h> |
43 | #include <libkdepim/phoneaccess.h> | 43 | #include <libkdepim/phoneaccess.h> |
44 | 44 | ||
45 | #ifndef KAB_EMBEDDED | 45 | #ifndef KAB_EMBEDDED |
46 | #include <qclipboard.h> | 46 | #include <qclipboard.h> |
47 | #include <qdir.h> | 47 | #include <qdir.h> |
48 | #include <qfile.h> | 48 | #include <qfile.h> |
49 | #include <qapplicaton.h> | 49 | #include <qapplicaton.h> |
50 | #include <qprogressbar.h> | 50 | #include <qprogressbar.h> |
51 | #include <qlayout.h> | 51 | #include <qlayout.h> |
52 | #include <qregexp.h> | 52 | #include <qregexp.h> |
53 | #include <qvbox.h> | 53 | #include <qvbox.h> |
54 | #include <kabc/addresseelist.h> | 54 | #include <kabc/addresseelist.h> |
55 | #include <kabc/errorhandler.h> | 55 | #include <kabc/errorhandler.h> |
56 | #include <kabc/resource.h> | 56 | #include <kabc/resource.h> |
57 | #include <kabc/vcardconverter.h> | 57 | #include <kabc/vcardconverter.h> |
58 | #include <kapplication.h> | 58 | #include <kapplication.h> |
59 | #include <kactionclasses.h> | 59 | #include <kactionclasses.h> |
60 | #include <kcmultidialog.h> | 60 | #include <kcmultidialog.h> |
61 | #include <kdebug.h> | 61 | #include <kdebug.h> |
62 | #include <kdeversion.h> | 62 | #include <kdeversion.h> |
63 | #include <kkeydialog.h> | 63 | #include <kkeydialog.h> |
64 | #include <kmessagebox.h> | 64 | #include <kmessagebox.h> |
65 | #include <kprinter.h> | 65 | #include <kprinter.h> |
66 | #include <kprotocolinfo.h> | 66 | #include <kprotocolinfo.h> |
67 | #include <kresources/selectdialog.h> | 67 | #include <kresources/selectdialog.h> |
68 | #include <kstandarddirs.h> | 68 | #include <kstandarddirs.h> |
69 | #include <ktempfile.h> | 69 | #include <ktempfile.h> |
70 | #include <kxmlguiclient.h> | 70 | #include <kxmlguiclient.h> |
71 | #include <kaboutdata.h> | 71 | #include <kaboutdata.h> |
72 | #include <libkdepim/categoryselectdialog.h> | 72 | #include <libkdepim/categoryselectdialog.h> |
73 | 73 | ||
74 | #include "addresseeutil.h" | 74 | #include "addresseeutil.h" |
75 | #include "addresseeeditordialog.h" | 75 | #include "addresseeeditordialog.h" |
76 | #include "extensionmanager.h" | 76 | #include "extensionmanager.h" |
77 | #include "kstdaction.h" | 77 | #include "kstdaction.h" |
78 | #include "kaddressbookservice.h" | 78 | #include "kaddressbookservice.h" |
79 | #include "ldapsearchdialog.h" | 79 | #include "ldapsearchdialog.h" |
80 | #include "printing/printingwizard.h" | 80 | #include "printing/printingwizard.h" |
81 | #else // KAB_EMBEDDED | 81 | #else // KAB_EMBEDDED |
82 | 82 | ||
83 | #include <kapplication.h> | 83 | #include <kapplication.h> |
84 | #include "KDGanttMinimizeSplitter.h" | 84 | #include "KDGanttMinimizeSplitter.h" |
85 | #include "kaddressbookmain.h" | 85 | #include "kaddressbookmain.h" |
86 | #include "kactioncollection.h" | 86 | #include "kactioncollection.h" |
87 | #include "addresseedialog.h" | 87 | #include "addresseedialog.h" |
88 | //US | 88 | //US |
89 | #include <addresseeview.h> | 89 | #include <addresseeview.h> |
90 | 90 | ||
91 | #include <qapp.h> | 91 | #include <qapp.h> |
92 | #include <qmenubar.h> | 92 | #include <qmenubar.h> |
93 | //#include <qtoolbar.h> | 93 | //#include <qtoolbar.h> |
94 | #include <qmessagebox.h> | 94 | #include <qmessagebox.h> |
95 | #include <kdebug.h> | 95 | #include <kdebug.h> |
96 | #include <kiconloader.h> // needed for SmallIcon | 96 | #include <kiconloader.h> // needed for SmallIcon |
97 | #include <kresources/kcmkresources.h> | 97 | #include <kresources/kcmkresources.h> |
98 | #include <ktoolbar.h> | 98 | #include <ktoolbar.h> |
99 | 99 | ||
100 | 100 | ||
101 | //#include <qlabel.h> | 101 | //#include <qlabel.h> |
102 | 102 | ||
103 | 103 | ||
104 | #ifndef DESKTOP_VERSION | 104 | #ifndef DESKTOP_VERSION |
105 | #include <qpe/ir.h> | 105 | #include <qpe/ir.h> |
106 | #include <qpe/qpemenubar.h> | 106 | #include <qpe/qpemenubar.h> |
107 | #include <qtopia/qcopenvelope_qws.h> | 107 | #include <qtopia/qcopenvelope_qws.h> |
108 | #else | 108 | #else |
109 | 109 | ||
110 | #include <qmenubar.h> | 110 | #include <qmenubar.h> |
111 | #endif | 111 | #endif |
112 | 112 | ||
113 | #endif // KAB_EMBEDDED | 113 | #endif // KAB_EMBEDDED |
114 | #include "kcmconfigs/kcmkabconfig.h" | 114 | #include "kcmconfigs/kcmkabconfig.h" |
115 | #include "kcmconfigs/kcmkdepimconfig.h" | 115 | #include "kcmconfigs/kcmkdepimconfig.h" |
116 | #include "kpimglobalprefs.h" | 116 | #include "kpimglobalprefs.h" |
117 | #include "externalapphandler.h" | 117 | #include "externalapphandler.h" |
118 | 118 | ||
119 | 119 | ||
120 | #include <kresources/selectdialog.h> | 120 | #include <kresources/selectdialog.h> |
121 | #include <kmessagebox.h> | 121 | #include <kmessagebox.h> |
122 | 122 | ||
123 | #include <picture.h> | 123 | #include <picture.h> |
124 | #include <resource.h> | 124 | #include <resource.h> |
125 | 125 | ||
126 | //US#include <qsplitter.h> | 126 | //US#include <qsplitter.h> |
127 | #include <qmap.h> | 127 | #include <qmap.h> |
128 | #include <qdir.h> | 128 | #include <qdir.h> |
129 | #include <qfile.h> | 129 | #include <qfile.h> |
130 | #include <qvbox.h> | 130 | #include <qvbox.h> |
131 | #include <qlayout.h> | 131 | #include <qlayout.h> |
132 | #include <qclipboard.h> | 132 | #include <qclipboard.h> |
133 | #include <qtextstream.h> | 133 | #include <qtextstream.h> |
134 | 134 | ||
135 | #include <libkdepim/categoryselectdialog.h> | 135 | #include <libkdepim/categoryselectdialog.h> |
136 | #include <kabc/vcardconverter.h> | 136 | #include <kabc/vcardconverter.h> |
137 | 137 | ||
138 | 138 | ||
139 | #include "addresseeutil.h" | 139 | #include "addresseeutil.h" |
140 | #include "undocmds.h" | 140 | #include "undocmds.h" |
141 | #include "addresseeeditordialog.h" | 141 | #include "addresseeeditordialog.h" |
142 | #include "viewmanager.h" | 142 | #include "viewmanager.h" |
143 | #include "details/detailsviewcontainer.h" | 143 | #include "details/detailsviewcontainer.h" |
144 | #include "kabprefs.h" | 144 | #include "kabprefs.h" |
145 | #include "xxportmanager.h" | 145 | #include "xxportmanager.h" |
146 | #include "incsearchwidget.h" | 146 | #include "incsearchwidget.h" |
147 | #include "jumpbuttonbar.h" | 147 | #include "jumpbuttonbar.h" |
148 | #include "extensionmanager.h" | 148 | #include "extensionmanager.h" |
149 | #include "addresseeconfig.h" | 149 | #include "addresseeconfig.h" |
150 | #include <kcmultidialog.h> | 150 | #include <kcmultidialog.h> |
151 | 151 | ||
152 | #ifdef _WIN32_ | 152 | #ifdef _WIN32_ |
153 | 153 | ||
154 | #include "kaimportoldialog.h" | 154 | #include "kaimportoldialog.h" |
155 | #else | 155 | #else |
156 | #include <unistd.h> | 156 | #include <unistd.h> |
157 | #endif | 157 | #endif |
158 | // sync includes | 158 | // sync includes |
159 | #include <libkdepim/ksyncprofile.h> | 159 | #include <libkdepim/ksyncprofile.h> |
160 | #include <libkdepim/ksyncprefsdialog.h> | 160 | #include <libkdepim/ksyncprefsdialog.h> |
161 | 161 | ||
162 | class KAex2phonePrefs : public QDialog | 162 | class KAex2phonePrefs : public QDialog |
163 | { | 163 | { |
164 | public: | 164 | public: |
165 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 165 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
166 | QDialog( parent, name, true ) | 166 | QDialog( parent, name, true ) |
167 | { | 167 | { |
168 | setCaption( i18n("Export to phone options") ); | 168 | setCaption( i18n("Export to phone options") ); |
169 | QVBoxLayout* lay = new QVBoxLayout( this ); | 169 | QVBoxLayout* lay = new QVBoxLayout( this ); |
170 | lay->setSpacing( 3 ); | 170 | lay->setSpacing( 3 ); |
171 | lay->setMargin( 3 ); | 171 | lay->setMargin( 3 ); |
172 | QLabel *lab; | 172 | QLabel *lab; |
173 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 173 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
174 | lab->setAlignment (AlignHCenter ); | 174 | lab->setAlignment (AlignHCenter ); |
175 | QHBox* temphb; | 175 | QHBox* temphb; |
176 | temphb = new QHBox( this ); | 176 | temphb = new QHBox( this ); |
177 | new QLabel( i18n("I/O device: "), temphb ); | 177 | new QLabel( i18n("I/O device: "), temphb ); |
178 | mPhoneDevice = new QLineEdit( temphb); | 178 | mPhoneDevice = new QLineEdit( temphb); |
179 | lay->addWidget( temphb ); | 179 | lay->addWidget( temphb ); |
180 | temphb = new QHBox( this ); | 180 | temphb = new QHBox( this ); |
181 | new QLabel( i18n("Connection: "), temphb ); | 181 | new QLabel( i18n("Connection: "), temphb ); |
182 | mPhoneConnection = new QLineEdit( temphb); | 182 | mPhoneConnection = new QLineEdit( temphb); |
183 | lay->addWidget( temphb ); | 183 | lay->addWidget( temphb ); |
184 | temphb = new QHBox( this ); | 184 | temphb = new QHBox( this ); |
185 | new QLabel( i18n("Model(opt.): "), temphb ); | 185 | new QLabel( i18n("Model(opt.): "), temphb ); |
186 | mPhoneModel = new QLineEdit( temphb); | 186 | mPhoneModel = new QLineEdit( temphb); |
187 | lay->addWidget( temphb ); | 187 | lay->addWidget( temphb ); |
188 | // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); | 188 | // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); |
189 | // lay->addWidget( mWriteToSim ); | 189 | // lay->addWidget( mWriteToSim ); |
190 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); | 190 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); |
191 | lab->setAlignment (AlignHCenter ); | 191 | lab->setAlignment (AlignHCenter ); |
192 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 192 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
193 | lay->addWidget( ok ); | 193 | lay->addWidget( ok ); |
194 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 194 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
195 | lay->addWidget( cancel ); | 195 | lay->addWidget( cancel ); |
196 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 196 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
197 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 197 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
198 | resize( 220, 240 ); | 198 | resize( 220, 240 ); |
199 | 199 | ||
200 | } | 200 | } |
201 | 201 | ||
202 | public: | 202 | public: |
203 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 203 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
204 | QCheckBox* mWriteToSim; | 204 | QCheckBox* mWriteToSim; |
205 | }; | 205 | }; |
206 | 206 | ||
207 | 207 | ||
208 | bool pasteWithNewUid = true; | 208 | bool pasteWithNewUid = true; |
209 | 209 | ||
210 | #ifdef KAB_EMBEDDED | 210 | #ifdef KAB_EMBEDDED |
211 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 211 | KABCore::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 |
216 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 216 | KABCore::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 | ||
323 | KABCore::~KABCore() | 323 | KABCore::~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 | } |
338 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) | 338 | void 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 | } |
349 | void KABCore::toggleBeamReceive( ) | 349 | void 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 | ||
370 | void KABCore::disableBR(bool b) | 370 | void 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 | } |
387 | void KABCore::recieve( QString fn ) | 387 | void 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 | } |
398 | void KABCore::restoreSettings() | 398 | void 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 | ||
464 | void KABCore::saveSettings() | 464 | void 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 | ||
482 | KABC::AddressBook *KABCore::addressBook() const | 482 | KABC::AddressBook *KABCore::addressBook() const |
483 | { | 483 | { |
484 | return mAddressBook; | 484 | return mAddressBook; |
485 | } | 485 | } |
486 | 486 | ||
487 | KConfig *KABCore::config() | 487 | KConfig *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 | ||
496 | KActionCollection *KABCore::actionCollection() const | 496 | KActionCollection *KABCore::actionCollection() const |
497 | { | 497 | { |
498 | return mGUIClient->actionCollection(); | 498 | return mGUIClient->actionCollection(); |
499 | } | 499 | } |
500 | 500 | ||
501 | KABC::Field *KABCore::currentSearchField() const | 501 | KABC::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 | ||
509 | QStringList KABCore::selectedUIDs() const | 509 | QStringList KABCore::selectedUIDs() const |
510 | { | 510 | { |
511 | return mViewManager->selectedUids(); | 511 | return mViewManager->selectedUids(); |
512 | } | 512 | } |
513 | 513 | ||
514 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 514 | KABC::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 |
535 | KAboutData *KABCore::createAboutData() | 535 | KAboutData *KABCore::createAboutData() |
536 | #else //KAB_EMBEDDED | 536 | #else //KAB_EMBEDDED |
537 | void KABCore::createAboutData() | 537 | void 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 | ||
591 | void KABCore::setContactSelected( const QString &uid ) | 591 | void 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 | ||
640 | void KABCore::sendMail() | 640 | void KABCore::sendMail() |
641 | { | 641 | { |
642 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 642 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
643 | } | 643 | } |
644 | 644 | ||
645 | void KABCore::sendMail( const QString& emaillist ) | 645 | void 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 | ||
656 | void KABCore::mailVCard() | 656 | void 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 | ||
663 | void KABCore::mailVCard( const QStringList& uids ) | 663 | void 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 | ||
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index dc2026b..fc2d59b 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1,666 +1,666 @@ | |||
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 | ||
65 | using namespace KCal; | 65 | using 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 | ||
73 | class KOex2phonePrefs : public QDialog | 73 | class 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 | ||
119 | public: | 119 | public: |
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 | ||
125 | int globalFlagBlockStartup; | 125 | int globalFlagBlockStartup; |
126 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | 126 | MainWindow::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 | } |
284 | MainWindow::~MainWindow() | 284 | MainWindow::~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 | ||
298 | void MainWindow::disableBR(bool b) | 298 | void 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 | } |
317 | bool MainWindow::beamReceiveEnabled() | 317 | bool 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 | ||
325 | void MainWindow::toggleBeamReceive() | 325 | void 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 | } |
343 | void MainWindow::showMaximized () | 343 | void 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 | } |
353 | void MainWindow::closeEvent( QCloseEvent* ce ) | 353 | void 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 | ||
387 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | 387 | void 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 | ||
494 | QPixmap MainWindow::loadPixmap( QString name ) | 494 | QPixmap MainWindow::loadPixmap( QString name ) |
495 | { | 495 | { |
496 | return SmallIcon( name ); | 496 | return SmallIcon( name ); |
497 | 497 | ||
498 | } | 498 | } |
499 | void MainWindow::initActions() | 499 | void 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() ) ); |