-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 7c52ef2..75e539a 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp | |||
@@ -265,192 +265,204 @@ void AddressbookWindow::setDocument( const QString &filename ) | |||
265 | switch( QMessageBox::information( this, tr ( "Add Contact?" ), | 265 | switch( QMessageBox::information( this, tr ( "Add Contact?" ), |
266 | tr( "Do you really want add contact for \n%1?" ) | 266 | tr( "Do you really want add contact for \n%1?" ) |
267 | .arg( (*it).fullName().latin1() ), | 267 | .arg( (*it).fullName().latin1() ), |
268 | tr( "&Yes" ), tr( "&No" ), tr( "&All Yes"), | 268 | tr( "&Yes" ), tr( "&No" ), tr( "&All Yes"), |
269 | 0, // Enter == button 0 | 269 | 0, // Enter == button 0 |
270 | 2 ) ) { // Escape == button 2 | 270 | 2 ) ) { // Escape == button 2 |
271 | case 0: | 271 | case 0: |
272 | odebug << "YES clicked" << oendl; | 272 | odebug << "YES clicked" << oendl; |
273 | m_abView->addEntry( *it ); | 273 | m_abView->addEntry( *it ); |
274 | break; | 274 | break; |
275 | case 1: | 275 | case 1: |
276 | odebug << "NO clicked" << oendl; | 276 | odebug << "NO clicked" << oendl; |
277 | break; | 277 | break; |
278 | case 2: | 278 | case 2: |
279 | odebug << "YesAll clicked" << oendl; | 279 | odebug << "YesAll clicked" << oendl; |
280 | doAsk = false; | 280 | doAsk = false; |
281 | break; | 281 | break; |
282 | } | 282 | } |
283 | }else | 283 | }else |
284 | m_abView->addEntry( *it ); | 284 | m_abView->addEntry( *it ); |
285 | 285 | ||
286 | } | 286 | } |
287 | 287 | ||
288 | delete access; | 288 | delete access; |
289 | } | 289 | } |
290 | 290 | ||
291 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) | 291 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) |
292 | { | 292 | { |
293 | QMainWindow::resizeEvent( e ); | 293 | QMainWindow::resizeEvent( e ); |
294 | 294 | ||
295 | 295 | ||
296 | } | 296 | } |
297 | 297 | ||
298 | AddressbookWindow::~AddressbookWindow() | 298 | AddressbookWindow::~AddressbookWindow() |
299 | { | 299 | { |
300 | ToolBarDock dock; | 300 | ToolBarDock dock; |
301 | int dummy; | 301 | int dummy; |
302 | bool bDummy; | 302 | bool bDummy; |
303 | getLocation ( listTools, dock, dummy, bDummy, dummy ); | 303 | getLocation ( listTools, dock, dummy, bDummy, dummy ); |
304 | m_config.setToolBarDock( dock ); | 304 | m_config.setToolBarDock( dock ); |
305 | m_config.save(); | 305 | m_config.save(); |
306 | } | 306 | } |
307 | 307 | ||
308 | int AddressbookWindow::create() | 308 | int AddressbookWindow::create() |
309 | { | 309 | { |
310 | return 0; | 310 | return 0; |
311 | } | 311 | } |
312 | 312 | ||
313 | bool AddressbookWindow::remove( int /*uid*/ ) | 313 | bool AddressbookWindow::remove( int /*uid*/ ) |
314 | { | 314 | { |
315 | return false; | 315 | return false; |
316 | } | 316 | } |
317 | 317 | ||
318 | void AddressbookWindow::beam( int /*uid*/ ) | 318 | void AddressbookWindow::beam( int /*uid*/ ) |
319 | { | 319 | { |
320 | } | 320 | } |
321 | 321 | ||
322 | void AddressbookWindow::show( int /*uid*/ ) | 322 | void AddressbookWindow::show( int /*uid*/ ) |
323 | { | 323 | { |
324 | } | 324 | } |
325 | 325 | ||
326 | void AddressbookWindow::edit( int /*uid*/ ) | 326 | void AddressbookWindow::edit( int /*uid*/ ) |
327 | { | 327 | { |
328 | } | 328 | } |
329 | 329 | ||
330 | void AddressbookWindow::add( const Opie::OPimRecord& ) | 330 | void AddressbookWindow::add( const Opie::OPimRecord& ) |
331 | { | 331 | { |
332 | } | 332 | } |
333 | 333 | ||
334 | void AddressbookWindow::slotItemNew() | 334 | void AddressbookWindow::slotItemNew() |
335 | { | 335 | { |
336 | Opie::OPimContact cnt; | 336 | Opie::OPimContact cnt; |
337 | if( !syncing ) { | 337 | if( !syncing ) { |
338 | editEntry( NewEntry ); | 338 | editEntry( NewEntry ); |
339 | } else { | 339 | } else { |
340 | QMessageBox::warning(this, tr("Contacts"), | 340 | QMessageBox::warning(this, tr("Contacts"), |
341 | tr("Can not edit data, currently syncing")); | 341 | tr("Can not edit data, currently syncing")); |
342 | } | 342 | } |
343 | } | 343 | } |
344 | 344 | ||
345 | void AddressbookWindow::slotItemEdit() | 345 | void AddressbookWindow::slotItemEdit() |
346 | { | 346 | { |
347 | if(!syncing) { | 347 | if(!syncing) { |
348 | if (m_actionPersonal->isOn()) { | 348 | if (m_actionPersonal->isOn()) { |
349 | editPersonal(); | 349 | editPersonal(); |
350 | } else { | 350 | } else { |
351 | editEntry( EditEntry ); | 351 | editEntry( EditEntry ); |
352 | } | 352 | } |
353 | } else { | 353 | } else { |
354 | QMessageBox::warning( this, tr("Contacts"), | 354 | QMessageBox::warning( this, tr("Contacts"), |
355 | tr("Can not edit data, currently syncing") ); | 355 | tr("Can not edit data, currently syncing") ); |
356 | } | 356 | } |
357 | } | 357 | } |
358 | 358 | ||
359 | void AddressbookWindow::slotItemDuplicate() | 359 | void AddressbookWindow::slotItemDuplicate() |
360 | { | 360 | { |
361 | if(!syncing) | ||
362 | { | ||
363 | Opie::OPimContact entry = m_abView->currentEntry(); | ||
364 | entry.assignUid(); | ||
365 | m_abView->addEntry( entry ); | ||
366 | m_abView->setCurrentUid( entry.uid() ); | ||
367 | } | ||
368 | else | ||
369 | { | ||
370 | QMessageBox::warning( this, tr("Contacts"), | ||
371 | tr("Can not edit data, currently syncing") ); | ||
372 | } | ||
361 | } | 373 | } |
362 | 374 | ||
363 | void AddressbookWindow::slotItemDelete() | 375 | void AddressbookWindow::slotItemDelete() |
364 | { | 376 | { |
365 | if(!syncing) { | 377 | if(!syncing) { |
366 | Opie::OPimContact tmpEntry = m_abView ->currentEntry(); | 378 | Opie::OPimContact tmpEntry = m_abView ->currentEntry(); |
367 | 379 | ||
368 | // get a name, do the best we can... | 380 | // get a name, do the best we can... |
369 | QString strName = tmpEntry.fullName(); | 381 | QString strName = tmpEntry.fullName(); |
370 | if ( strName.isEmpty() ) { | 382 | if ( strName.isEmpty() ) { |
371 | strName = tmpEntry.company(); | 383 | strName = tmpEntry.company(); |
372 | if ( strName.isEmpty() ) | 384 | if ( strName.isEmpty() ) |
373 | strName = "No Name"; | 385 | strName = "No Name"; |
374 | } | 386 | } |
375 | 387 | ||
376 | 388 | ||
377 | if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), | 389 | if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), |
378 | strName ) ) { | 390 | strName ) ) { |
379 | m_abView->removeEntry( tmpEntry.uid() ); | 391 | m_abView->removeEntry( tmpEntry.uid() ); |
380 | } | 392 | } |
381 | } else { | 393 | } else { |
382 | QMessageBox::warning( this, tr("Contacts"), | 394 | QMessageBox::warning( this, tr("Contacts"), |
383 | tr("Can not edit data, currently syncing") ); | 395 | tr("Can not edit data, currently syncing") ); |
384 | } | 396 | } |
385 | } | 397 | } |
386 | 398 | ||
387 | static const char * beamfile = "/tmp/obex/contact.vcf"; | 399 | static const char * beamfile = "/tmp/obex/contact.vcf"; |
388 | 400 | ||
389 | void AddressbookWindow::slotItemBeam() | 401 | void AddressbookWindow::slotItemBeam() |
390 | { | 402 | { |
391 | QString beamFilename; | 403 | QString beamFilename; |
392 | Opie::OPimContact c; | 404 | Opie::OPimContact c; |
393 | if ( m_actionPersonal->isOn() ) { | 405 | if ( m_actionPersonal->isOn() ) { |
394 | beamFilename = addressbookPersonalVCardName(); | 406 | beamFilename = addressbookPersonalVCardName(); |
395 | if ( !QFile::exists( beamFilename ) ) | 407 | if ( !QFile::exists( beamFilename ) ) |
396 | return; // can't beam a non-existent file | 408 | return; // can't beam a non-existent file |
397 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 409 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
398 | beamFilename ); | 410 | beamFilename ); |
399 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 411 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
400 | Opie::OPimContactAccess::List allList = access->allRecords(); | 412 | Opie::OPimContactAccess::List allList = access->allRecords(); |
401 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first | 413 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first |
402 | c = *it; | 414 | c = *it; |
403 | 415 | ||
404 | delete access; | 416 | delete access; |
405 | } else { | 417 | } else { |
406 | unlink( beamfile ); // delete if exists | 418 | unlink( beamfile ); // delete if exists |
407 | mkdir("/tmp/obex/", 0755); | 419 | mkdir("/tmp/obex/", 0755); |
408 | c = m_abView -> currentEntry(); | 420 | c = m_abView -> currentEntry(); |
409 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 421 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
410 | beamfile ); | 422 | beamfile ); |
411 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 423 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
412 | access->add( c ); | 424 | access->add( c ); |
413 | access->save(); | 425 | access->save(); |
414 | delete access; | 426 | delete access; |
415 | 427 | ||
416 | beamFilename = beamfile; | 428 | beamFilename = beamfile; |
417 | } | 429 | } |
418 | 430 | ||
419 | odebug << "Beaming: " << beamFilename << oendl; | 431 | odebug << "Beaming: " << beamFilename << oendl; |
420 | 432 | ||
421 | Ir *ir = new Ir( this ); | 433 | Ir *ir = new Ir( this ); |
422 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 434 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
423 | QString description = c.fullName(); | 435 | QString description = c.fullName(); |
424 | ir->send( beamFilename, description, "text/x-vCard" ); | 436 | ir->send( beamFilename, description, "text/x-vCard" ); |
425 | } | 437 | } |
426 | 438 | ||
427 | void AddressbookWindow::slotItemFind() | 439 | void AddressbookWindow::slotItemFind() |
428 | { | 440 | { |
429 | } | 441 | } |
430 | 442 | ||
431 | void AddressbookWindow::slotConfigure() | 443 | void AddressbookWindow::slotConfigure() |
432 | { | 444 | { |
433 | ConfigDlg* dlg = new ConfigDlg( this, "Config" ); | 445 | ConfigDlg* dlg = new ConfigDlg( this, "Config" ); |
434 | dlg -> setConfig( m_config ); | 446 | dlg -> setConfig( m_config ); |
435 | if ( QPEApplication::execDialog( dlg ) ) { | 447 | if ( QPEApplication::execDialog( dlg ) ) { |
436 | odebug << "Config Dialog accepted!" << oendl; | 448 | odebug << "Config Dialog accepted!" << oendl; |
437 | m_config = dlg -> getConfig(); | 449 | m_config = dlg -> getConfig(); |
438 | if ( m_curFontSize != m_config.fontSize() ){ | 450 | if ( m_curFontSize != m_config.fontSize() ){ |
439 | odebug << "Font was changed!" << oendl; | 451 | odebug << "Font was changed!" << oendl; |
440 | m_curFontSize = m_config.fontSize(); | 452 | m_curFontSize = m_config.fontSize(); |
441 | emit slotSetFont( m_curFontSize ); | 453 | emit slotSetFont( m_curFontSize ); |
442 | } | 454 | } |
443 | m_abView -> setListOrder( m_config.orderList() ); | 455 | m_abView -> setListOrder( m_config.orderList() ); |
444 | } | 456 | } |
445 | 457 | ||
446 | delete dlg; | 458 | delete dlg; |
447 | } | 459 | } |
448 | 460 | ||
449 | void AddressbookWindow::slotShowFind( bool show ) | 461 | void AddressbookWindow::slotShowFind( bool show ) |
450 | { | 462 | { |
451 | if ( show ) | 463 | if ( show ) |
452 | { | 464 | { |
453 | // Display search bar | 465 | // Display search bar |
454 | m_searchBar->show(); | 466 | m_searchBar->show(); |
455 | m_abView -> inSearch(); | 467 | m_abView -> inSearch(); |
456 | m_searchEdit->setFocus(); | 468 | m_searchEdit->setFocus(); |