summaryrefslogtreecommitdiff
authoreilers <eilers>2002-10-27 16:18:51 (UTC)
committer eilers <eilers>2002-10-27 16:18:51 (UTC)
commitcc01384d8c2b421d5f455f32631d8c2ec4b7e844 (patch) (unidiff)
tree0917ecf78c54b17620a583e584198881db24fee2
parent5f09fc992af19fc208315217eb46635a762f1e55 (diff)
downloadopie-cc01384d8c2b421d5f455f32631d8c2ec4b7e844.zip
opie-cc01384d8c2b421d5f455f32631d8c2ec4b7e844.tar.gz
opie-cc01384d8c2b421d5f455f32631d8c2ec4b7e844.tar.bz2
OContact now uses QDate to avoid wrong interpreted strings
A lot of inline functions moved into the library..
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/abtable.cpp5
-rw-r--r--core/pim/addressbook/contacteditor.cpp34
2 files changed, 20 insertions, 19 deletions
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp
index 4feadeb..5222f16 100644
--- a/core/pim/addressbook/abtable.cpp
+++ b/core/pim/addressbook/abtable.cpp
@@ -1,122 +1,123 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#define QTOPIA_INTERNAL_CONTACT_MRE 21#define QTOPIA_INTERNAL_CONTACT_MRE
22 22
23#include <qpe/categoryselect.h> 23#include <qpe/categoryselect.h>
24#include <qpe/config.h> 24#include <qpe/config.h>
25#include <qpe/stringutil.h> 25#include <qpe/stringutil.h>
26#include <qpe/qcopenvelope_qws.h> 26#include <qpe/qcopenvelope_qws.h>
27#include <qpe/timestring.h>
27 28
28#include <opie/orecordlist.h> 29#include <opie/orecordlist.h>
29 30
30#include <qasciidict.h> 31#include <qasciidict.h>
31#include <qdatetime.h> 32#include <qdatetime.h>
32#include <qfile.h> 33#include <qfile.h>
33#include <qregexp.h> 34#include <qregexp.h>
34#include <qmessagebox.h> 35#include <qmessagebox.h>
35 36
36#include "abtable.h" 37#include "abtable.h"
37 38
38#include <errno.h> 39#include <errno.h>
39#include <fcntl.h> 40#include <fcntl.h>
40#include <unistd.h> 41#include <unistd.h>
41#include <stdlib.h> 42#include <stdlib.h>
42 43
43#include <ctype.h> //toupper() for key hack 44#include <ctype.h> //toupper() for key hack
44 45
45static bool contactCompare( const OContact &cnt, const QRegExp &r, int category ); 46static bool contactCompare( const OContact &cnt, const QRegExp &r, int category );
46 47
47 48
48/*! 49/*!
49 \class AbTableItem abtable.h 50 \class AbTableItem abtable.h
50 51
51 \brief QTableItem based class for showing a field of an entry 52 \brief QTableItem based class for showing a field of an entry
52*/ 53*/
53 54
54AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s, 55AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s,
55 const QString &secondSortKey) 56 const QString &secondSortKey)
56 : QTableItem( t, et, s ) 57 : QTableItem( t, et, s )
57{ 58{
58 // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower(); 59 // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower();
59 sortKey = Qtopia::buildSortKey( s, secondSortKey ); 60 sortKey = Qtopia::buildSortKey( s, secondSortKey );
60} 61}
61 62
62int AbTableItem::alignment() const 63int AbTableItem::alignment() const
63{ 64{
64 return AlignLeft|AlignVCenter; 65 return AlignLeft|AlignVCenter;
65} 66}
66 67
67QString AbTableItem::key() const 68QString AbTableItem::key() const
68{ 69{
69 return sortKey; 70 return sortKey;
70} 71}
71 72
72// A way to reset the item, without out doing a delete or a new... 73// A way to reset the item, without out doing a delete or a new...
73void AbTableItem::setItem( const QString &txt, const QString &secondKey ) 74void AbTableItem::setItem( const QString &txt, const QString &secondKey )
74{ 75{
75 setText( txt ); 76 setText( txt );
76 sortKey = Qtopia::buildSortKey( txt, secondKey ); 77 sortKey = Qtopia::buildSortKey( txt, secondKey );
77 78
78 // sortKey = txt.lower() + QChar( '\0' ) + secondKey.lower(); 79 // sortKey = txt.lower() + QChar( '\0' ) + secondKey.lower();
79} 80}
80 81
81/*! 82/*!
82 \class AbPickItem abtable.h 83 \class AbPickItem abtable.h
83 84
84 \brief QTableItem based class for showing slection of an entry 85 \brief QTableItem based class for showing slection of an entry
85*/ 86*/
86 87
87AbPickItem::AbPickItem( QTable *t ) : 88AbPickItem::AbPickItem( QTable *t ) :
88 QTableItem(t, WhenCurrent, "?") 89 QTableItem(t, WhenCurrent, "?")
89{ 90{
90} 91}
91 92
92QWidget *AbPickItem::createEditor() const 93QWidget *AbPickItem::createEditor() const
93{ 94{
94 QComboBox* combo = new QComboBox( table()->viewport() ); 95 QComboBox* combo = new QComboBox( table()->viewport() );
95 ( (AbPickItem*)this )->cb = combo; 96 ( (AbPickItem*)this )->cb = combo;
96 AbTable* t = static_cast<AbTable*>(table()); 97 AbTable* t = static_cast<AbTable*>(table());
97 QStringList c = t->choiceNames(); 98 QStringList c = t->choiceNames();
98 int cur = 0; 99 int cur = 0;
99 for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) { 100 for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) {
100 if ( *it == text() ) 101 if ( *it == text() )
101 cur = combo->count(); 102 cur = combo->count();
102 combo->insertItem(*it); 103 combo->insertItem(*it);
103 } 104 }
104 combo->setCurrentItem(cur); 105 combo->setCurrentItem(cur);
105 return combo; 106 return combo;
106} 107}
107 108
108void AbPickItem::setContentFromEditor( QWidget *w ) 109void AbPickItem::setContentFromEditor( QWidget *w )
109{ 110{
110 if ( w->inherits("QComboBox") ) 111 if ( w->inherits("QComboBox") )
111 setText( ( (QComboBox*)w )->currentText() ); 112 setText( ( (QComboBox*)w )->currentText() );
112 else 113 else
113 QTableItem::setContentFromEditor( w ); 114 QTableItem::setContentFromEditor( w );
114} 115}
115 116
116/*! 117/*!
117 \class AbTable abtable.h 118 \class AbTable abtable.h
118 119
119 \brief QTable based class for showing a list of entries 120 \brief QTable based class for showing a list of entries
120*/ 121*/
121 122
122AbTable::AbTable( const QValueList<int> *order, QWidget *parent, const char *name ) 123AbTable::AbTable( const QValueList<int> *order, QWidget *parent, const char *name )
@@ -357,196 +358,196 @@ QString AbTable::findContactContact( const OContact &entry, int /* row */ )
357 case Qtopia::Title: 358 case Qtopia::Title:
358 value = entry.title(); 359 value = entry.title();
359 break; 360 break;
360 case Qtopia::Suffix: 361 case Qtopia::Suffix:
361 value = entry.suffix(); 362 value = entry.suffix();
362 break; 363 break;
363 case Qtopia::FileAs: 364 case Qtopia::FileAs:
364 value = entry.fileAs(); 365 value = entry.fileAs();
365 break; 366 break;
366 case Qtopia::DefaultEmail: 367 case Qtopia::DefaultEmail:
367 value = entry.defaultEmail(); 368 value = entry.defaultEmail();
368 case Qtopia::Emails: 369 case Qtopia::Emails:
369 value = entry.emails(); 370 value = entry.emails();
370 break; 371 break;
371 case Qtopia::HomeStreet: 372 case Qtopia::HomeStreet:
372 value = entry.homeStreet(); 373 value = entry.homeStreet();
373 break; 374 break;
374 case Qtopia::HomeCity: 375 case Qtopia::HomeCity:
375 value = entry.homeCity(); 376 value = entry.homeCity();
376 break; 377 break;
377 case Qtopia::HomeState: 378 case Qtopia::HomeState:
378 value = entry.homeState(); 379 value = entry.homeState();
379 break; 380 break;
380 case Qtopia::HomeZip: 381 case Qtopia::HomeZip:
381 value = entry.homeZip(); 382 value = entry.homeZip();
382 break; 383 break;
383 case Qtopia::HomeCountry: 384 case Qtopia::HomeCountry:
384 value = entry.homeCountry(); 385 value = entry.homeCountry();
385 break; 386 break;
386 case Qtopia::HomePhone: 387 case Qtopia::HomePhone:
387 value = entry.homePhone(); 388 value = entry.homePhone();
388 break; 389 break;
389 case Qtopia::HomeFax: 390 case Qtopia::HomeFax:
390 value = entry.homeFax(); 391 value = entry.homeFax();
391 break; 392 break;
392 case Qtopia::HomeMobile: 393 case Qtopia::HomeMobile:
393 value = entry.homeMobile(); 394 value = entry.homeMobile();
394 break; 395 break;
395 case Qtopia::HomeWebPage: 396 case Qtopia::HomeWebPage:
396 value = entry.homeWebpage(); 397 value = entry.homeWebpage();
397 break; 398 break;
398 case Qtopia::Company: 399 case Qtopia::Company:
399 value = entry.company(); 400 value = entry.company();
400 break; 401 break;
401 case Qtopia::BusinessCity: 402 case Qtopia::BusinessCity:
402 value = entry.businessCity(); 403 value = entry.businessCity();
403 break; 404 break;
404 case Qtopia::BusinessStreet: 405 case Qtopia::BusinessStreet:
405 value = entry.businessStreet(); 406 value = entry.businessStreet();
406 break; 407 break;
407 case Qtopia::BusinessZip: 408 case Qtopia::BusinessZip:
408 value = entry.businessZip(); 409 value = entry.businessZip();
409 break; 410 break;
410 case Qtopia::BusinessCountry: 411 case Qtopia::BusinessCountry:
411 value = entry.businessCountry(); 412 value = entry.businessCountry();
412 break; 413 break;
413 case Qtopia::BusinessWebPage: 414 case Qtopia::BusinessWebPage:
414 value = entry.businessWebpage(); 415 value = entry.businessWebpage();
415 break; 416 break;
416 case Qtopia::JobTitle: 417 case Qtopia::JobTitle:
417 value = entry.jobTitle(); 418 value = entry.jobTitle();
418 break; 419 break;
419 case Qtopia::Department: 420 case Qtopia::Department:
420 value = entry.department(); 421 value = entry.department();
421 break; 422 break;
422 case Qtopia::Office: 423 case Qtopia::Office:
423 value = entry.office(); 424 value = entry.office();
424 break; 425 break;
425 case Qtopia::BusinessPhone: 426 case Qtopia::BusinessPhone:
426 value = entry.businessPhone(); 427 value = entry.businessPhone();
427 break; 428 break;
428 case Qtopia::BusinessFax: 429 case Qtopia::BusinessFax:
429 value = entry.businessFax(); 430 value = entry.businessFax();
430 break; 431 break;
431 case Qtopia::BusinessMobile: 432 case Qtopia::BusinessMobile:
432 value = entry.businessMobile(); 433 value = entry.businessMobile();
433 break; 434 break;
434 case Qtopia::BusinessPager: 435 case Qtopia::BusinessPager:
435 value = entry.businessPager(); 436 value = entry.businessPager();
436 break; 437 break;
437 case Qtopia::Profession: 438 case Qtopia::Profession:
438 value = entry.profession(); 439 value = entry.profession();
439 break; 440 break;
440 case Qtopia::Assistant: 441 case Qtopia::Assistant:
441 value = entry.assistant(); 442 value = entry.assistant();
442 break; 443 break;
443 case Qtopia::Manager: 444 case Qtopia::Manager:
444 value = entry.manager(); 445 value = entry.manager();
445 break; 446 break;
446 case Qtopia::Spouse: 447 case Qtopia::Spouse:
447 value = entry.spouse(); 448 value = entry.spouse();
448 break; 449 break;
449 case Qtopia::Gender: 450 case Qtopia::Gender:
450 value = entry.gender(); 451 value = entry.gender();
451 break; 452 break;
452 case Qtopia::Birthday: 453 case Qtopia::Birthday:
453 value = entry.birthday(); 454 value = TimeString::numberDateString( entry.birthday() );
454 break; 455 break;
455 case Qtopia::Anniversary: 456 case Qtopia::Anniversary:
456 value = entry.anniversary(); 457 value = TimeString::numberDateString( entry.anniversary() );
457 break; 458 break;
458 case Qtopia::Nickname: 459 case Qtopia::Nickname:
459 value = entry.nickname(); 460 value = entry.nickname();
460 break; 461 break;
461 case Qtopia::Children: 462 case Qtopia::Children:
462 value = entry.children(); 463 value = entry.children();
463 break; 464 break;
464 case Qtopia::Notes: 465 case Qtopia::Notes:
465 value = entry.notes(); 466 value = entry.notes();
466 break; 467 break;
467 } 468 }
468 if ( !value.isEmpty() ) 469 if ( !value.isEmpty() )
469 break; 470 break;
470 } 471 }
471 return value; 472 return value;
472} 473}
473 474
474void AbTable::addEntry( const OContact &newCnt ) 475void AbTable::addEntry( const OContact &newCnt )
475{ 476{
476 int row = numRows(); 477 int row = numRows();
477 478
478 setNumRows( row + 1 ); 479 setNumRows( row + 1 );
479 insertIntoTable( newCnt, row ); 480 insertIntoTable( newCnt, row );
480 481
481 qWarning("abtable:AddContact"); 482 qWarning("abtable:AddContact");
482 m_contactdb.add ( newCnt ); 483 m_contactdb.add ( newCnt );
483 484
484 setCurrentCell( row, 0 ); 485 setCurrentCell( row, 0 );
485 // updateVisible(); 486 // updateVisible();
486} 487}
487 488
488void AbTable::resizeRows() { 489void AbTable::resizeRows() {
489 /* 490 /*
490 if (numRows()) { 491 if (numRows()) {
491 for (int i = 0; i < numRows(); i++) { 492 for (int i = 0; i < numRows(); i++) {
492 setRowHeight( i, size ); 493 setRowHeight( i, size );
493 } 494 }
494 } 495 }
495 updateVisible(); 496 updateVisible();
496 */ 497 */
497} 498}
498 499
499 500
500bool AbTable::save() 501bool AbTable::save()
501{ 502{
502 // QTime t; 503 // QTime t;
503 // t.start(); 504 // t.start();
504 qWarning("abtable:Save data"); 505 qWarning("abtable:Save data");
505 506
506 return m_contactdb.save(); 507 return m_contactdb.save();
507} 508}
508 509
509void AbTable::load() 510void AbTable::load()
510{ 511{
511 setSorting( false ); 512 setSorting( false );
512 setUpdatesEnabled( FALSE ); 513 setUpdatesEnabled( FALSE );
513 514
514 qWarning("abtable:Load data"); 515 qWarning("abtable:Load data");
515 516
516 OContactAccess::List list = m_contactdb.allRecords(); 517 OContactAccess::List list = m_contactdb.allRecords();
517 OContactAccess::List::Iterator it; 518 OContactAccess::List::Iterator it;
518 setNumRows( list.count() ); 519 setNumRows( list.count() );
519 int row = 0; 520 int row = 0;
520 for ( it = list.begin(); it != list.end(); ++it ) 521 for ( it = list.begin(); it != list.end(); ++it )
521 insertIntoTable( *it, row++ ); 522 insertIntoTable( *it, row++ );
522 523
523 setUpdatesEnabled( TRUE ); 524 setUpdatesEnabled( TRUE );
524 525
525 setSorting( true ); 526 setSorting( true );
526 resort(); 527 resort();
527} 528}
528 529
529 530
530void AbTable::reload() 531void AbTable::reload()
531{ 532{
532 m_contactdb.reload(); 533 m_contactdb.reload();
533 load(); 534 load();
534} 535}
535 536
536void AbTable::realignTable( int row ) 537void AbTable::realignTable( int row )
537{ 538{
538 QTableItem *ti1, 539 QTableItem *ti1,
539 *ti2; 540 *ti2;
540 int totalRows = numRows(); 541 int totalRows = numRows();
541 for ( int curr = row; curr < totalRows - 1; curr++ ) { 542 for ( int curr = row; curr < totalRows - 1; curr++ ) {
542 // the same info from the todo list still applies, but I 543 // the same info from the todo list still applies, but I
543 // don't think it is _too_ bad. 544 // don't think it is _too_ bad.
544 ti1 = item( curr + 1, 0 ); 545 ti1 = item( curr + 1, 0 );
545 ti2 = item( curr + 1, 1 ); 546 ti2 = item( curr + 1, 1 );
546 takeItem( ti1 ); 547 takeItem( ti1 );
547 takeItem( ti2 ); 548 takeItem( ti2 );
548 setItem( curr, 0, ti1 ); 549 setItem( curr, 0, ti1 );
549 setItem( curr, 1, ti2 ); 550 setItem( curr, 1, ti2 );
550 } 551 }
551 setNumRows( totalRows - 1 ); 552 setNumRows( totalRows - 1 );
552 resort(); 553 resort();
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp
index 52ab0f2..e034b35 100644
--- a/core/pim/addressbook/contacteditor.cpp
+++ b/core/pim/addressbook/contacteditor.cpp
@@ -1,98 +1,99 @@
1/* 1/*
2 * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org> 2 * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org>
3 * Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de)
3 * 4 *
4 * This file is an add-on for the OPIE Palmtop Environment 5 * This file is an add-on for the OPIE Palmtop Environment
5 * 6 *
6 * This file may be distributed and/or modified under the terms of the 7 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software 8 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the pacakaging 9 * Foundation and appearing in the file LICENSE.GPL included in the pacakaging
9 * of this file. 10 * of this file.
10 * 11 *
11 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 12 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 13 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13 * 14 *
14 * 15 *
15 * This is a rewrite of the abeditor.h file, modified to provide a more 16 * This is a rewrite of the abeditor.h file, modified to provide a more
16 * intuitive interface to TrollTech's original Address Book editor. This 17 * intuitive interface to TrollTech's original Address Book editor. This
17 * is made to operate exactly in interface with the exception of name. 18 * is made to operate exactly in interface with the exception of name.
18 * 19 *
19 */ 20 */
20 21
21#include "contacteditor.h" 22#include "contacteditor.h"
22#include "addresspicker.h" 23#include "addresspicker.h"
23 24
24#include <qpe/categoryselect.h> 25#include <qpe/categoryselect.h>
25#include <qpe/qpeapplication.h> 26#include <qpe/qpeapplication.h>
26#include <qpe/qpedialog.h> 27#include <qpe/qpedialog.h>
27#include <qpe/timeconversion.h> 28#include <qpe/timeconversion.h>
28 29
29#include <qcombobox.h> 30#include <qcombobox.h>
30#include <qlabel.h> 31#include <qlabel.h>
31#include <qtabwidget.h> 32#include <qtabwidget.h>
32#include <qlayout.h> 33#include <qlayout.h>
33#include <qlineedit.h> 34#include <qlineedit.h>
34#include <qmultilineedit.h> 35#include <qmultilineedit.h>
35#include <qscrollview.h> 36#include <qscrollview.h>
36#include <qtoolbutton.h> 37#include <qtoolbutton.h>
37#include <qpushbutton.h> 38#include <qpushbutton.h>
38#include <qmainwindow.h> 39#include <qmainwindow.h>
39#include <qvaluelist.h> 40#include <qvaluelist.h>
40#include <qpopupmenu.h> 41#include <qpopupmenu.h>
41#include <qlistbox.h> 42#include <qlistbox.h>
42 43
43static inline bool containsAlphaNum( const QString &str ); 44static inline bool containsAlphaNum( const QString &str );
44static inline bool constainsWhiteSpace( const QString &str ); 45static inline bool constainsWhiteSpace( const QString &str );
45 46
46// helper functions, convert our comma delimited list to proper 47// helper functions, convert our comma delimited list to proper
47// file format... 48// file format...
48void parseEmailFrom( const QString &txt, QString &strDefaultEmail, 49void parseEmailFrom( const QString &txt, QString &strDefaultEmail,
49 QString &strAll ); 50 QString &strAll );
50 51
51// helper convert from file format to comma delimited... 52// helper convert from file format to comma delimited...
52void parseEmailTo( const QString &strDefaultEmail, 53void parseEmailTo( const QString &strDefaultEmail,
53 const QString &strOtherEmail, QString &strBack ); 54 const QString &strOtherEmail, QString &strBack );
54 55
55 ContactEditor::ContactEditor(const OContact &entry, 56 ContactEditor::ContactEditor(const OContact &entry,
56 const QValueList<int> *newOrderedValues, 57 const QValueList<int> *newOrderedValues,
57 QStringList *slNewOrdered, 58 QStringList *slNewOrdered,
58 QWidget *parent, 59 QWidget *parent,
59 const char *name, 60 const char *name,
60 WFlags fl ) 61 WFlags fl )
61 : QDialog( parent, name, TRUE, fl ), 62 : QDialog( parent, name, TRUE, fl ),
62 orderedValues( newOrderedValues ), 63 orderedValues( newOrderedValues ),
63 slOrdered( *slNewOrdered ), 64 slOrdered( *slNewOrdered ),
64 m_personalView ( false ) 65 m_personalView ( false )
65{ 66{
66 67
67 init(); 68 init();
68 initMap(); 69 initMap();
69 setEntry( entry ); 70 setEntry( entry );
70 qDebug("finish"); 71 qDebug("finish");
71} 72}
72 73
73ContactEditor::~ContactEditor() { 74ContactEditor::~ContactEditor() {
74} 75}
75 76
76void ContactEditor::init() { 77void ContactEditor::init() {
77 78
78 useFullName = TRUE; 79 useFullName = TRUE;
79 80
80 int i = 0; 81 int i = 0;
81/** SHut up and stop leaking 82/** SHut up and stop leaking
82 slHomeAddress = new QStringList; 83 slHomeAddress = new QStringList;
83 slBusinessAddress = new QStringList; 84 slBusinessAddress = new QStringList;
84 slChooserNames = new QStringList; 85 slChooserNames = new QStringList;
85 slChooserValues = new QStringList; 86 slChooserValues = new QStringList;
86 87
87 slDynamicEntries = new QStringList; 88 slDynamicEntries = new QStringList;
88*/ 89*/
89 //*slDynamicEntries = *slOrdered; 90 //*slDynamicEntries = *slOrdered;
90 91
91 QStringList trlChooserNames; 92 QStringList trlChooserNames;
92 93
93 for (i = 0; i <= 6; i++) { 94 for (i = 0; i <= 6; i++) {
94 slHomeAddress.append( "" ); 95 slHomeAddress.append( "" );
95 slBusinessAddress.append( "" ); 96 slBusinessAddress.append( "" );
96 } 97 }
97 98
98 { 99 {
@@ -1015,206 +1016,192 @@ void ContactEditor::slotCmbChooser2Change( int index ) {
1015 txtChooserField2->setFocus(); 1016 txtChooserField2->setFocus();
1016} 1017}
1017 1018
1018void ContactEditor::slotCmbChooser3Change( int index ) { 1019void ContactEditor::slotCmbChooser3Change( int index ) {
1019 1020
1020 txtChooserField3->setText( slChooserValues[index] ); 1021 txtChooserField3->setText( slChooserValues[index] );
1021 txtChooserField3->setFocus(); 1022 txtChooserField3->setFocus();
1022 1023
1023} 1024}
1024 1025
1025void ContactEditor::slotCmbChooser4Change( int index ) { 1026void ContactEditor::slotCmbChooser4Change( int index ) {
1026 1027
1027 txtChooserField4->setText( slChooserValues[index] ); 1028 txtChooserField4->setText( slChooserValues[index] );
1028 txtChooserField4->setFocus(); 1029 txtChooserField4->setFocus();
1029 1030
1030} 1031}
1031 1032
1032void ContactEditor::slotAddressTypeChange( int index ) { 1033void ContactEditor::slotAddressTypeChange( int index ) {
1033 1034
1034 if ( index == 0 ) { 1035 if ( index == 0 ) {
1035 1036
1036 txtAddress->setText( slBusinessAddress[0] ); 1037 txtAddress->setText( slBusinessAddress[0] );
1037 //txtAddress2->setText( (*slBusinessAddress)[1] ); 1038 //txtAddress2->setText( (*slBusinessAddress)[1] );
1038 //txtPOBox->setText( (*slBusinessAddress)[2] ); 1039 //txtPOBox->setText( (*slBusinessAddress)[2] );
1039 txtCity->setText( slBusinessAddress[3] ); 1040 txtCity->setText( slBusinessAddress[3] );
1040 txtState->setText( slBusinessAddress[4] ); 1041 txtState->setText( slBusinessAddress[4] );
1041 txtZip->setText( slBusinessAddress[5] ); 1042 txtZip->setText( slBusinessAddress[5] );
1042 QLineEdit *txtTmp = cmbCountry->lineEdit(); 1043 QLineEdit *txtTmp = cmbCountry->lineEdit();
1043 txtTmp->setText( slBusinessAddress[6] ); 1044 txtTmp->setText( slBusinessAddress[6] );
1044 1045
1045 } else { 1046 } else {
1046 1047
1047 txtAddress->setText( slHomeAddress[0] ); 1048 txtAddress->setText( slHomeAddress[0] );
1048 //txtAddress2->setText( (*slHomeAddress)[1] ); 1049 //txtAddress2->setText( (*slHomeAddress)[1] );
1049 //txtPOBox->setText( (*slHomeAddress)[2] ); 1050 //txtPOBox->setText( (*slHomeAddress)[2] );
1050 txtCity->setText( slHomeAddress[3] ); 1051 txtCity->setText( slHomeAddress[3] );
1051 txtState->setText( slHomeAddress[4] ); 1052 txtState->setText( slHomeAddress[4] );
1052 txtZip->setText( slHomeAddress[5] ); 1053 txtZip->setText( slHomeAddress[5] );
1053 QLineEdit *txtTmp = cmbCountry->lineEdit(); 1054 QLineEdit *txtTmp = cmbCountry->lineEdit();
1054 txtTmp->setText( slHomeAddress[6] ); 1055 txtTmp->setText( slHomeAddress[6] );
1055 1056
1056 } 1057 }
1057 1058
1058} 1059}
1059 1060
1060void ContactEditor::slotFullNameChange( const QString &textChanged ) { 1061void ContactEditor::slotFullNameChange( const QString &textChanged ) {
1061 1062
1062 int index = cmbFileAs->currentItem(); 1063 int index = cmbFileAs->currentItem();
1063 1064
1064 cmbFileAs->clear(); 1065 cmbFileAs->clear();
1065 1066
1066 cmbFileAs->insertItem( parseName( textChanged, 0 ) ); 1067 cmbFileAs->insertItem( parseName( textChanged, 0 ) );
1067 cmbFileAs->insertItem( parseName( textChanged, 1 ) ); 1068 cmbFileAs->insertItem( parseName( textChanged, 1 ) );
1068 cmbFileAs->insertItem( parseName( textChanged, 2 ) ); 1069 cmbFileAs->insertItem( parseName( textChanged, 2 ) );
1069 cmbFileAs->insertItem( parseName( textChanged, 3 ) ); 1070 cmbFileAs->insertItem( parseName( textChanged, 3 ) );
1070 1071
1071 cmbFileAs->setCurrentItem( index ); 1072 cmbFileAs->setCurrentItem( index );
1072 1073
1073 useFullName = TRUE; 1074 useFullName = TRUE;
1074 1075
1075} 1076}
1076 1077
1077// Loads the detail fields 1078// Loads the detail fields
1078void ContactEditor::loadFields() { 1079void ContactEditor::loadFields() {
1079 1080
1080 QStringList::ConstIterator it; 1081 QStringList::ConstIterator it;
1081 QListIterator<QLabel> lit( listName ); 1082 QListIterator<QLabel> lit( listName );
1082 for ( it = slDynamicEntries.begin(); *lit; ++lit, ++it) { 1083 for ( it = slDynamicEntries.begin(); *lit; ++lit, ++it) {
1083 1084
1084 if ( *it == "Department" ) 1085 if ( *it == "Department" )
1085 (*lit)->setText( tr( "Department" ) ); 1086 (*lit)->setText( tr( "Department" ) );
1086 1087
1087 if ( *it == "Company" ) 1088 if ( *it == "Company" )
1088 (*lit)->setText( tr( "Company" ) ); 1089 (*lit)->setText( tr( "Company" ) );
1089 1090
1090 if ( *it == "Office" ) 1091 if ( *it == "Office" )
1091 (*lit)->setText( tr( "Office" ) ); 1092 (*lit)->setText( tr( "Office" ) );
1092 1093
1093 if ( *it == "Profession" ) 1094 if ( *it == "Profession" )
1094 (*lit)->setText( tr( "Profession" ) ); 1095 (*lit)->setText( tr( "Profession" ) );
1095 1096
1096 if ( *it == "Assistant" ) 1097 if ( *it == "Assistant" )
1097 (*lit)->setText( tr( "Assistant" ) ); 1098 (*lit)->setText( tr( "Assistant" ) );
1098 1099
1099 if ( *it == "Manager" ) 1100 if ( *it == "Manager" )
1100 (*lit)->setText( tr( "Manager" ) ); 1101 (*lit)->setText( tr( "Manager" ) );
1101 1102
1102 if ( *it == "Spouse" ) 1103 if ( *it == "Spouse" )
1103 (*lit)->setText( tr( "Spouse" ) ); 1104 (*lit)->setText( tr( "Spouse" ) );
1104 1105
1105 if ( *it == "Nickname" ) 1106 if ( *it == "Nickname" )
1106 (*lit)->setText( tr( "Nickname" ) ); 1107 (*lit)->setText( tr( "Nickname" ) );
1107 1108
1108 if ( *it == "Children" ) 1109 if ( *it == "Children" )
1109 (*lit)->setText( tr( "Children" ) ); 1110 (*lit)->setText( tr( "Children" ) );
1110 } 1111 }
1111 // Set DatePicker
1112 qWarning ("**Info: %s", ent.birthday().latin1() );
1113 if ( !ent.birthday().isEmpty() ){
1114 birthdayButton->setText( ent.birthday() );
1115 birthdayPicker->setDate( TimeConversion::fromString ( ent.birthday() ) );
1116 } else
1117 birthdayButton->setText( tr ("Unknown") );
1118
1119 qWarning ("**Info: %s", ent.anniversary().latin1() );
1120 if ( !ent.anniversary().isEmpty() ){
1121 anniversaryButton->setText( ent.anniversary() );
1122 anniversaryPicker->setDate( TimeConversion::fromString ( ent.birthday() ) );
1123 } else
1124 anniversaryButton->setText( tr ("Unknown") );
1125 1112
1126} 1113}
1127 1114
1128void ContactEditor::accept() { 1115void ContactEditor::accept() {
1129 1116
1130 if ( isEmpty() ) { 1117 if ( isEmpty() ) {
1131 cleanupFields(); 1118 cleanupFields();
1132 reject(); 1119 reject();
1133 } else { 1120 } else {
1134 saveEntry(); 1121 saveEntry();
1135 cleanupFields(); 1122 cleanupFields();
1136 QDialog::accept(); 1123 QDialog::accept();
1137 } 1124 }
1138 1125
1139} 1126}
1140 1127
1141void ContactEditor::slotNote() { 1128void ContactEditor::slotNote() {
1142 1129
1143 dlgNote->showMaximized(); 1130 dlgNote->showMaximized();
1144 if ( !dlgNote->exec() ) { 1131 if ( !dlgNote->exec() ) {
1145 txtNote->setText( ent.notes() ); 1132 txtNote->setText( ent.notes() );
1146 } 1133 }
1147} 1134}
1148 1135
1149void ContactEditor::slotName() { 1136void ContactEditor::slotName() {
1150 1137
1151 QString tmpName; 1138 QString tmpName;
1152 if (useFullName == TRUE) { 1139 if (useFullName == TRUE) {
1153 txtFirstName->setText( parseName(txtFullName->text(), NAME_F) ); 1140 txtFirstName->setText( parseName(txtFullName->text(), NAME_F) );
1154 txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) ); 1141 txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) );
1155 txtLastName->setText( parseName(txtFullName->text(), NAME_L) ); 1142 txtLastName->setText( parseName(txtFullName->text(), NAME_L) );
1156 txtSuffix->setText( parseName(txtFullName->text(), NAME_S) ); 1143 txtSuffix->setText( parseName(txtFullName->text(), NAME_S) );
1157 } 1144 }
1158 dlgName->showMaximized(); 1145 dlgName->showMaximized();
1159 if ( dlgName->exec() ) { 1146 if ( dlgName->exec() ) {
1160 1147
1161 tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text() + " " + txtSuffix->text(); 1148 tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text() + " " + txtSuffix->text();
1162 txtFullName->setText( tmpName.simplifyWhiteSpace() ); 1149 txtFullName->setText( tmpName.simplifyWhiteSpace() );
1163 slotFullNameChange( txtFullName->text() ); 1150 slotFullNameChange( txtFullName->text() );
1164 useFullName = FALSE; 1151 useFullName = FALSE;
1165 } 1152 }
1166 1153
1167} 1154}
1168 1155
1169void ContactEditor::setNameFocus() { 1156void ContactEditor::setNameFocus() {
1170 1157
1171 txtFullName->setFocus(); 1158 txtFullName->setFocus();
1172 1159
1173} 1160}
1174 1161
1175bool ContactEditor::isEmpty() { 1162bool ContactEditor::isEmpty() {
1176 // Test and see if the record should be saved. 1163 // Test and see if the record should be saved.
1177 // More strict than the original qtopia, needs name or fileas to save 1164 // More strict than the original qtopia, needs name or fileas to save
1178 1165
1179 QString t = txtFullName->text(); 1166 QString t = txtFullName->text();
1180 if ( !t.isEmpty() && containsAlphaNum( t ) ) 1167 if ( !t.isEmpty() && containsAlphaNum( t ) )
1181 return false; 1168 return false;
1182 1169
1183 t = cmbFileAs->currentText(); 1170 t = cmbFileAs->currentText();
1184 if ( !t.isEmpty() && containsAlphaNum( t ) ) 1171 if ( !t.isEmpty() && containsAlphaNum( t ) )
1185 return false; 1172 return false;
1186 1173
1187 return true; 1174 return true;
1188 1175
1189} 1176}
1190 1177
1191QString ContactEditor::parseName( const QString fullName, int type ) { 1178QString ContactEditor::parseName( const QString fullName, int type ) {
1192 1179
1193 QString simplifiedName( fullName.simplifyWhiteSpace() ); 1180 QString simplifiedName( fullName.simplifyWhiteSpace() );
1194 QString strFirstName; 1181 QString strFirstName;
1195 QString strMiddleName; 1182 QString strMiddleName;
1196 QString strLastName; 1183 QString strLastName;
1197 QString strSuffix; 1184 QString strSuffix;
1198 QString strTitle; 1185 QString strTitle;
1199 int commapos; 1186 int commapos;
1200 int spCount; 1187 int spCount;
1201 int spPos; 1188 int spPos;
1202 int spPos2; 1189 int spPos2;
1203 1190
1204 1191
1205 commapos = simplifiedName.find( ',', 0, TRUE); 1192 commapos = simplifiedName.find( ',', 0, TRUE);
1206 spCount = simplifiedName.contains( ' ', TRUE ); 1193 spCount = simplifiedName.contains( ' ', TRUE );
1207 1194
1208 if ( commapos == -1 ) { 1195 if ( commapos == -1 ) {
1209 1196
1210 switch (spCount) { 1197 switch (spCount) {
1211 case 0: 1198 case 0:
1212 //return simplifiedName; 1199 //return simplifiedName;
1213 if (txtLastName->text() != "") { 1200 if (txtLastName->text() != "") {
1214 strLastName = simplifiedName; 1201 strLastName = simplifiedName;
1215 break; 1202 break;
1216 } 1203 }
1217 if (txtMiddleName->text() != "") { 1204 if (txtMiddleName->text() != "") {
1218 strMiddleName = simplifiedName; 1205 strMiddleName = simplifiedName;
1219 break; 1206 break;
1220 } 1207 }
@@ -1508,193 +1495,206 @@ void ContactEditor::setEntry( const OContact &entry ) {
1508 (*itLE)->setText( ent.nickname() ); 1495 (*itLE)->setText( ent.nickname() );
1509 1496
1510 if ( *it == "Children" ) 1497 if ( *it == "Children" )
1511 (*itLE)->setText( ent.children() ); 1498 (*itLE)->setText( ent.children() );
1512 1499
1513 } 1500 }
1514 1501
1515 QStringList::Iterator itV; 1502 QStringList::Iterator itV;
1516 for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) { 1503 for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) {
1517 1504
1518 if ( ( *it == "Business Phone") || ( *it == "Work Phone" ) ) 1505 if ( ( *it == "Business Phone") || ( *it == "Work Phone" ) )
1519 *itV = ent.businessPhone(); 1506 *itV = ent.businessPhone();
1520/* 1507/*
1521 if ( *it == "Business 2 Phone" ) 1508 if ( *it == "Business 2 Phone" )
1522 *itV = ent.business2Phone(); 1509 *itV = ent.business2Phone();
1523*/ 1510*/
1524 if ( ( *it == "Business Fax") || ( *it == "Work Fax" ) ) 1511 if ( ( *it == "Business Fax") || ( *it == "Work Fax" ) )
1525 *itV = ent.businessFax(); 1512 *itV = ent.businessFax();
1526 1513
1527 if ( ( *it == "Business Mobile" ) || ( *it == "work Mobile" ) ) 1514 if ( ( *it == "Business Mobile" ) || ( *it == "work Mobile" ) )
1528 *itV = ent.businessMobile(); 1515 *itV = ent.businessMobile();
1529/* 1516/*
1530 if ( *it == "Company Phone" ) 1517 if ( *it == "Company Phone" )
1531 *itV = ent.companyPhone(); 1518 *itV = ent.companyPhone();
1532*/ 1519*/
1533 if ( *it == "Default Email" ) 1520 if ( *it == "Default Email" )
1534 *itV = ent.defaultEmail(); 1521 *itV = ent.defaultEmail();
1535 1522
1536 if ( *it == "Emails" ) 1523 if ( *it == "Emails" )
1537 *itV = ent.emailList().join(", "); // :SX 1524 *itV = ent.emailList().join(", "); // :SX
1538 1525
1539 if ( *it == "Home Phone" ) 1526 if ( *it == "Home Phone" )
1540 *itV = ent.homePhone(); 1527 *itV = ent.homePhone();
1541/* 1528/*
1542 if ( *it == "Home 2 Phone" ) 1529 if ( *it == "Home 2 Phone" )
1543 *itV = ent.home2Phone(); 1530 *itV = ent.home2Phone();
1544*/ 1531*/
1545 if ( *it == "Home Fax" ) 1532 if ( *it == "Home Fax" )
1546 *itV = ent.homeFax(); 1533 *itV = ent.homeFax();
1547 1534
1548 if ( *it == "Home Mobile" ) 1535 if ( *it == "Home Mobile" )
1549 *itV = ent.homeMobile(); 1536 *itV = ent.homeMobile();
1550/* 1537/*
1551 if ( *it == "Car Phone" ) 1538 if ( *it == "Car Phone" )
1552 *itV = ent.carPhone(); 1539 *itV = ent.carPhone();
1553 1540
1554 if ( *it == "ISDN Phone" ) 1541 if ( *it == "ISDN Phone" )
1555 *itV = ent.ISDNPhone(); 1542 *itV = ent.ISDNPhone();
1556 1543
1557 if ( *it == "Other Phone" ) 1544 if ( *it == "Other Phone" )
1558 *itV = ent.otherPhone(); 1545 *itV = ent.otherPhone();
1559*/ 1546*/
1560 if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) ) 1547 if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) )
1561 *itV = ent.businessPager(); 1548 *itV = ent.businessPager();
1562/* 1549/*
1563 if ( *it == "Home Pager") 1550 if ( *it == "Home Pager")
1564 *itV = ent.homePager(); 1551 *itV = ent.homePager();
1565 1552
1566 if ( *it == "AIM IM" ) 1553 if ( *it == "AIM IM" )
1567 *itV = ent.AIMIM(); 1554 *itV = ent.AIMIM();
1568 1555
1569 if ( *it == "ICQ IM" ) 1556 if ( *it == "ICQ IM" )
1570 *itV = ent.ICQIM(); 1557 *itV = ent.ICQIM();
1571 1558
1572 if ( *it == "Jabber IM" ) 1559 if ( *it == "Jabber IM" )
1573 *itV = ent.jabberIM(); 1560 *itV = ent.jabberIM();
1574 1561
1575 if ( *it == "MSN IM" ) 1562 if ( *it == "MSN IM" )
1576 *itV = ent.MSNIM(); 1563 *itV = ent.MSNIM();
1577 1564
1578 if ( *it == "Yahoo IM" ) 1565 if ( *it == "Yahoo IM" )
1579 *itV = ent.yahooIM(); 1566 *itV = ent.yahooIM();
1580*/ 1567*/
1581 if ( *it == "Home Web Page" ) 1568 if ( *it == "Home Web Page" )
1582 *itV = ent.homeWebpage(); 1569 *itV = ent.homeWebpage();
1583 1570
1584 if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) ) 1571 if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) )
1585 *itV = ent.businessWebpage(); 1572 *itV = ent.businessWebpage();
1586 1573
1587 1574
1588 } 1575 }
1589 1576
1590 1577
1591 cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") ); 1578 cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") );
1592 1579
1593 QString gender = ent.gender(); 1580 QString gender = ent.gender();
1594 cmbGender->setCurrentItem( gender.toInt() ); 1581 cmbGender->setCurrentItem( gender.toInt() );
1595 1582
1596 txtNote->setText( ent.notes() ); 1583 txtNote->setText( ent.notes() );
1597 1584
1598 slotCmbChooser1Change( cmbChooserField1->currentItem() ); 1585 slotCmbChooser1Change( cmbChooserField1->currentItem() );
1599 slotCmbChooser2Change( cmbChooserField2->currentItem() ); 1586 slotCmbChooser2Change( cmbChooserField2->currentItem() );
1600 slotCmbChooser3Change( cmbChooserField3->currentItem() ); 1587 slotCmbChooser3Change( cmbChooserField3->currentItem() );
1601 1588
1602 slotAddressTypeChange( cmbAddress->currentItem() ); 1589 slotAddressTypeChange( cmbAddress->currentItem() );
1603 1590
1604 loadFields(); 1591 // loadFields(); :SX
1592
1593 // Set DatePicker
1594 if ( !ent.birthday().isNull() ){
1595 birthdayButton->setText( TimeString::numberDateString( ent.birthday() ) );
1596 birthdayPicker->setDate( ent.birthday() );
1597 } else
1598 birthdayButton->setText( tr ("Unknown") );
1599
1600 if ( !ent.anniversary().isNull() ){
1601 anniversaryButton->setText( TimeString::numberDateString( ent.anniversary() ) );
1602 anniversaryPicker->setDate( ent.anniversary() );
1603 } else
1604 anniversaryButton->setText( tr ("Unknown") );
1605 1605
1606} 1606}
1607 1607
1608void ContactEditor::saveEntry() { 1608void ContactEditor::saveEntry() {
1609 1609
1610 if ( useFullName == TRUE ) { 1610 if ( useFullName == TRUE ) {
1611 txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) ); 1611 txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) );
1612 txtMiddleName->setText( parseName( txtFullName->text(), NAME_M ) ); 1612 txtMiddleName->setText( parseName( txtFullName->text(), NAME_M ) );
1613 txtLastName->setText( parseName( txtFullName->text(), NAME_L ) ); 1613 txtLastName->setText( parseName( txtFullName->text(), NAME_L ) );
1614 txtSuffix->setText( parseName( txtFullName->text(), NAME_S ) ); 1614 txtSuffix->setText( parseName( txtFullName->text(), NAME_S ) );
1615 1615
1616 useFullName = FALSE; 1616 useFullName = FALSE;
1617} 1617}
1618 1618
1619 /*if ( ent.firstName() != txtFirstName->text() || 1619 /*if ( ent.firstName() != txtFirstName->text() ||
1620 ent.lastName != txtLastName->text() || 1620 ent.lastName != txtLastName->text() ||
1621 ent.middleName != txtMiddleName->text() ) { 1621 ent.middleName != txtMiddleName->text() ) {
1622 */ 1622 */
1623 ent.setFirstName( txtFirstName->text() ); 1623 ent.setFirstName( txtFirstName->text() );
1624 ent.setLastName( txtLastName->text() ); 1624 ent.setLastName( txtLastName->text() );
1625 ent.setMiddleName( txtMiddleName->text() ); 1625 ent.setMiddleName( txtMiddleName->text() );
1626 ent.setSuffix( txtSuffix->text() ); 1626 ent.setSuffix( txtSuffix->text() );
1627 1627
1628 //} 1628 //}
1629 1629
1630 ent.setFileAs( cmbFileAs->currentText() ); 1630 ent.setFileAs( cmbFileAs->currentText() );
1631 1631
1632 ent.setCategories( cmbCat->currentCategories() ); 1632 ent.setCategories( cmbCat->currentCategories() );
1633 1633
1634 if (hasTitle) 1634 if (hasTitle)
1635 ent.setJobTitle( txtJobTitle->text() ); 1635 ent.setJobTitle( txtJobTitle->text() );
1636 1636
1637 if (hasCompany) 1637 if (hasCompany)
1638 ent.setCompany( txtOrganization->text() ); 1638 ent.setCompany( txtOrganization->text() );
1639 1639
1640 if (hasNotes) 1640 if (hasNotes)
1641 ent.setNotes( txtNote->text() ); 1641 ent.setNotes( txtNote->text() );
1642 1642
1643 if (hasStreet) { 1643 if (hasStreet) {
1644 ent.setHomeStreet( slHomeAddress[0] ); 1644 ent.setHomeStreet( slHomeAddress[0] );
1645 ent.setBusinessStreet( slBusinessAddress[0] ); 1645 ent.setBusinessStreet( slBusinessAddress[0] );
1646 } 1646 }
1647/* 1647/*
1648 if (hasStreet2) { 1648 if (hasStreet2) {
1649 ent.setHomeStreet2( (*slHomeAddress)[1] ); 1649 ent.setHomeStreet2( (*slHomeAddress)[1] );
1650 ent.setBusinessStreet2( (*slBusinessAddress)[1] ); 1650 ent.setBusinessStreet2( (*slBusinessAddress)[1] );
1651 } 1651 }
1652 1652
1653 if (hasPOBox) { 1653 if (hasPOBox) {
1654 ent.setHomePOBox( (*slHomeAddress)[2] ); 1654 ent.setHomePOBox( (*slHomeAddress)[2] );
1655 ent.setBusinessPOBox( (*slBusinessAddress)[2] ); 1655 ent.setBusinessPOBox( (*slBusinessAddress)[2] );
1656 } 1656 }
1657*/ 1657*/
1658 if (hasCity) { 1658 if (hasCity) {
1659 ent.setHomeCity( slHomeAddress[3] ); 1659 ent.setHomeCity( slHomeAddress[3] );
1660 ent.setBusinessCity( slBusinessAddress[3] ); 1660 ent.setBusinessCity( slBusinessAddress[3] );
1661 } 1661 }
1662 1662
1663 if (hasState) { 1663 if (hasState) {
1664 ent.setHomeState( slHomeAddress[4] ); 1664 ent.setHomeState( slHomeAddress[4] );
1665 ent.setBusinessState( slBusinessAddress[4] ); 1665 ent.setBusinessState( slBusinessAddress[4] );
1666 } 1666 }
1667 1667
1668 if (hasZip) { 1668 if (hasZip) {
1669 ent.setHomeZip( slHomeAddress[5] ); 1669 ent.setHomeZip( slHomeAddress[5] );
1670 ent.setBusinessZip( slBusinessAddress[5] ); 1670 ent.setBusinessZip( slBusinessAddress[5] );
1671 } 1671 }
1672 1672
1673 if (hasCountry) { 1673 if (hasCountry) {
1674 ent.setHomeCountry( slHomeAddress[6] ); 1674 ent.setHomeCountry( slHomeAddress[6] );
1675 ent.setBusinessCountry( slBusinessAddress[6] ); 1675 ent.setBusinessCountry( slBusinessAddress[6] );
1676 } 1676 }
1677 1677
1678 QStringList::ConstIterator it; 1678 QStringList::ConstIterator it;
1679 QListIterator<QLineEdit> itLE( listValue ); 1679 QListIterator<QLineEdit> itLE( listValue );
1680 for ( it = slDynamicEntries.begin(); it != slDynamicEntries.end(); ++it, ++itLE) { 1680 for ( it = slDynamicEntries.begin(); it != slDynamicEntries.end(); ++it, ++itLE) {
1681 if ( *it == "Department" ) 1681 if ( *it == "Department" )
1682 ent.setDepartment( (*itLE)->text() ); 1682 ent.setDepartment( (*itLE)->text() );
1683 1683
1684 if ( *it == "Company" ) 1684 if ( *it == "Company" )
1685 ent.setCompany( (*itLE)->text() ); 1685 ent.setCompany( (*itLE)->text() );
1686 1686
1687 if ( *it == "Office" ) 1687 if ( *it == "Office" )
1688 ent.setOffice( (*itLE)->text() ); 1688 ent.setOffice( (*itLE)->text() );
1689 1689
1690 if ( *it == "Profession" ) 1690 if ( *it == "Profession" )
1691 ent.setProfession( (*itLE)->text() ); 1691 ent.setProfession( (*itLE)->text() );
1692 1692
1693 if ( *it == "Assistant" ) 1693 if ( *it == "Assistant" )
1694 ent.setAssistant( (*itLE)->text() ); 1694 ent.setAssistant( (*itLE)->text() );
1695 1695
1696 if ( *it == "Manager" ) 1696 if ( *it == "Manager" )
1697 ent.setManager( (*itLE)->text() ); 1697 ent.setManager( (*itLE)->text() );
1698 1698
1699 if ( *it == "Spouse" ) 1699 if ( *it == "Spouse" )
1700 ent.setSpouse( (*itLE)->text() ); 1700 ent.setSpouse( (*itLE)->text() );
@@ -1798,107 +1798,107 @@ void ContactEditor::saveEntry() {
1798} 1798}
1799 1799
1800void parseEmailFrom( const QString &txt, QString &strDefaultEmail, 1800void parseEmailFrom( const QString &txt, QString &strDefaultEmail,
1801 QString &strAll ) 1801 QString &strAll )
1802{ 1802{
1803 int where, 1803 int where,
1804 start; 1804 start;
1805 if ( txt.isEmpty() ) 1805 if ( txt.isEmpty() )
1806 return; 1806 return;
1807 // find the first 1807 // find the first
1808 where = txt.find( ',' ); 1808 where = txt.find( ',' );
1809 if ( where < 0 ) { 1809 if ( where < 0 ) {
1810 strDefaultEmail = txt; 1810 strDefaultEmail = txt;
1811 strAll = txt; 1811 strAll = txt;
1812 } else { 1812 } else {
1813 strDefaultEmail = txt.left( where ).stripWhiteSpace(); 1813 strDefaultEmail = txt.left( where ).stripWhiteSpace();
1814 strAll = strDefaultEmail; 1814 strAll = strDefaultEmail;
1815 while ( where > -1 ) { 1815 while ( where > -1 ) {
1816 strAll.append(" "); 1816 strAll.append(" ");
1817 start = where; 1817 start = where;
1818 where = txt.find( ',', where + 1 ); 1818 where = txt.find( ',', where + 1 );
1819 if ( where > - 1 ) 1819 if ( where > - 1 )
1820 strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() ); 1820 strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() );
1821 else // grab until the end... 1821 else // grab until the end...
1822 strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() ); 1822 strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() );
1823 } 1823 }
1824 } 1824 }
1825} 1825}
1826 1826
1827void parseEmailTo( const QString &strDefaultEmail, 1827void parseEmailTo( const QString &strDefaultEmail,
1828 const QString &strOtherEmail, QString &strBack ) 1828 const QString &strOtherEmail, QString &strBack )
1829{ 1829{
1830 // create a comma dilimeted set of emails... 1830 // create a comma dilimeted set of emails...
1831 // use the power of short circuiting... 1831 // use the power of short circuiting...
1832 bool foundDefault = false; 1832 bool foundDefault = false;
1833 QString strTmp; 1833 QString strTmp;
1834 int start = 0; 1834 int start = 0;
1835 int where; 1835 int where;
1836 // start at the beginng. 1836 // start at the beginng.
1837 strBack = strDefaultEmail; 1837 strBack = strDefaultEmail;
1838 where = 0; 1838 where = 0;
1839 while ( where > -1 ) { 1839 while ( where > -1 ) {
1840 start = where; 1840 start = where;
1841 where = strOtherEmail.find( ' ', where + 1 ); 1841 where = strOtherEmail.find( ' ', where + 1 );
1842 if ( where > 0 ) { 1842 if ( where > 0 ) {
1843 strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace(); 1843 strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace();
1844 } else 1844 } else
1845 strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace(); 1845 strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace();
1846 if ( foundDefault || strTmp != strDefaultEmail ) { 1846 if ( foundDefault || strTmp != strDefaultEmail ) {
1847 strBack.append( ", " ); 1847 strBack.append( ", " );
1848 strBack.append( strTmp ); 1848 strBack.append( strTmp );
1849 } else 1849 } else
1850 foundDefault = true; 1850 foundDefault = true;
1851 } 1851 }
1852} 1852}
1853 1853
1854 1854
1855static inline bool containsAlphaNum( const QString &str ) 1855static inline bool containsAlphaNum( const QString &str )
1856{ 1856{
1857 int i, 1857 int i,
1858 count = str.length(); 1858 count = str.length();
1859 for ( i = 0; i < count; i++ ) 1859 for ( i = 0; i < count; i++ )
1860 if ( !str[i].isSpace() ) 1860 if ( !str[i].isSpace() )
1861 return TRUE; 1861 return TRUE;
1862 return FALSE; 1862 return FALSE;
1863} 1863}
1864 1864
1865static inline bool constainsWhiteSpace( const QString &str ) 1865static inline bool constainsWhiteSpace( const QString &str )
1866{ 1866{
1867 int i, 1867 int i,
1868 count = str.length(); 1868 count = str.length();
1869 for (i = 0; i < count; i++ ) 1869 for (i = 0; i < count; i++ )
1870 if ( str[i].isSpace() ) 1870 if ( str[i].isSpace() )
1871 return TRUE; 1871 return TRUE;
1872 return FALSE; 1872 return FALSE;
1873} 1873}
1874 1874
1875void ContactEditor::setPersonalView( bool personal ) 1875void ContactEditor::setPersonalView( bool personal )
1876{ 1876{
1877 m_personalView = personal; 1877 m_personalView = personal;
1878 if ( personal ){ 1878 if ( personal ){
1879 cmbCat->hide(); 1879 cmbCat->hide();
1880 labCat->hide(); 1880 labCat->hide();
1881 } else{ 1881 } else{
1882 cmbCat->show(); 1882 cmbCat->show();
1883 labCat->show(); 1883 labCat->show();
1884 1884
1885 } 1885 }
1886} 1886}
1887 1887
1888void ContactEditor::slotAnniversaryDateChanged( int year, int month, int day) 1888void ContactEditor::slotAnniversaryDateChanged( int year, int month, int day)
1889{ 1889{
1890 QDate date; 1890 QDate date;
1891 date.setYMD( year, month, day ); 1891 date.setYMD( year, month, day );
1892 QString dateString = TimeString::numberDateString( date ); 1892 QString dateString = TimeString::numberDateString( date );
1893 anniversaryButton->setText( dateString ); 1893 anniversaryButton->setText( dateString );
1894 ent.setAnniversary ( dateString ); 1894 ent.setAnniversary ( date );
1895} 1895}
1896 1896
1897void ContactEditor::slotBirthdayDateChanged( int year, int month, int day) 1897void ContactEditor::slotBirthdayDateChanged( int year, int month, int day)
1898{ 1898{
1899 QDate date; 1899 QDate date;
1900 date.setYMD( year, month, day ); 1900 date.setYMD( year, month, day );
1901 QString dateString = TimeString::numberDateString( date ); 1901 QString dateString = TimeString::numberDateString( date );
1902 birthdayButton->setText( dateString ); 1902 birthdayButton->setText( dateString );
1903 ent.setBirthday ( dateString ); 1903 ent.setBirthday ( date );
1904} 1904}