Diffstat (limited to 'core/pim/addressbook/contacteditor.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/addressbook/contacteditor.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp index 8acf570..534666d 100644 --- a/core/pim/addressbook/contacteditor.cpp +++ b/core/pim/addressbook/contacteditor.cpp | |||
@@ -1,128 +1,129 @@ | |||
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 | * Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) |
4 | * | 4 | * |
5 | * This file is an add-on for the OPIE Palmtop Environment | 5 | * This file is an add-on for the OPIE Palmtop Environment |
6 | * | 6 | * |
7 | * 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 |
8 | * 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 |
9 | * 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 |
10 | * of this file. | 10 | * of this file. |
11 | * | 11 | * |
12 | * 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 |
13 | * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
14 | * | 14 | * |
15 | * | 15 | * |
16 | * 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 |
17 | * intuitive interface to TrollTech's original Address Book editor. This | 17 | * intuitive interface to TrollTech's original Address Book editor. This |
18 | * 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. |
19 | * | 19 | * |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include "contacteditor.h" | 22 | #include "contacteditor.h" |
23 | 23 | ||
24 | #include <opie2/opimcontact.h> | ||
25 | |||
24 | #include <qpe/categoryselect.h> | 26 | #include <qpe/categoryselect.h> |
25 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/qpedialog.h> | 28 | #include <qpe/qpedialog.h> |
27 | #include <opie/ocontact.h> | ||
28 | #include <qpe/resource.h> | 29 | #include <qpe/resource.h> |
29 | 30 | ||
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 <qtoolbutton.h> | 36 | #include <qtoolbutton.h> |
36 | #include <qlistbox.h> | 37 | #include <qlistbox.h> |
37 | #include <qmessagebox.h> | 38 | #include <qmessagebox.h> |
38 | #include <qwhatsthis.h> | 39 | #include <qwhatsthis.h> |
39 | 40 | ||
40 | #include <assert.h> | 41 | #include <assert.h> |
41 | 42 | ||
42 | static inline bool containsAlphaNum( const QString &str ); | 43 | static inline bool containsAlphaNum( const QString &str ); |
43 | static inline bool constainsWhiteSpace( const QString &str ); | 44 | static inline bool constainsWhiteSpace( const QString &str ); |
44 | 45 | ||
45 | // helper functions, convert our comma delimited list to proper | 46 | // helper functions, convert our comma delimited list to proper |
46 | // file format... | 47 | // file format... |
47 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, | 48 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, |
48 | QString &strAll ); | 49 | QString &strAll ); |
49 | 50 | ||
50 | // helper convert from file format to comma delimited... | 51 | // helper convert from file format to comma delimited... |
51 | void parseEmailTo( const QString &strDefaultEmail, | 52 | void parseEmailTo( const QString &strDefaultEmail, |
52 | const QString &strOtherEmail, QString &strBack ); | 53 | const QString &strOtherEmail, QString &strBack ); |
53 | 54 | ||
54 | ContactEditor::ContactEditor(const OContact &entry, | 55 | ContactEditor::ContactEditor(const Opie::OPimContact &entry, |
55 | QWidget *parent, | 56 | QWidget *parent, |
56 | const char *name, | 57 | const char *name, |
57 | WFlags ) | 58 | WFlags ) |
58 | : QDialog( parent, name, TRUE, WStyle_ContextHelp ), | 59 | : QDialog( parent, name, TRUE, WStyle_ContextHelp ), |
59 | defaultEmailChooserPosition( -1 ), | 60 | defaultEmailChooserPosition( -1 ), |
60 | m_personalView ( false ), | 61 | m_personalView ( false ), |
61 | cmbDefaultEmail( 0 ), | 62 | cmbDefaultEmail( 0 ), |
62 | initializing ( false ) | 63 | initializing ( false ) |
63 | { | 64 | { |
64 | 65 | ||
65 | initializing = true; | 66 | initializing = true; |
66 | 67 | ||
67 | init(); | 68 | init(); |
68 | setEntry( entry ); | 69 | setEntry( entry ); |
69 | // cmbDefaultEmail = 0; | 70 | // cmbDefaultEmail = 0; |
70 | // defaultEmailChooserPosition = -1; | 71 | // defaultEmailChooserPosition = -1; |
71 | 72 | ||
72 | initializing = false; | 73 | initializing = false; |
73 | } | 74 | } |
74 | 75 | ||
75 | ContactEditor::~ContactEditor() { | 76 | ContactEditor::~ContactEditor() { |
76 | } | 77 | } |
77 | 78 | ||
78 | void ContactEditor::init() { | 79 | void ContactEditor::init() { |
79 | qWarning("init() START"); | 80 | qWarning("init() START"); |
80 | 81 | ||
81 | uint i = 0; | 82 | uint i = 0; |
82 | 83 | ||
83 | QStringList trlChooserNames; | 84 | QStringList trlChooserNames; |
84 | 85 | ||
85 | for (i = 0; i <= 6; i++) { | 86 | for (i = 0; i <= 6; i++) { |
86 | slHomeAddress.append( "" ); | 87 | slHomeAddress.append( "" ); |
87 | slBusinessAddress.append( "" ); | 88 | slBusinessAddress.append( "" ); |
88 | } | 89 | } |
89 | 90 | ||
90 | trlChooserNames = OContactFields::trphonefields( false ); | 91 | trlChooserNames = Opie::OPimContactFields::trphonefields( false ); |
91 | slChooserNames = OContactFields::untrphonefields( false ); | 92 | slChooserNames = Opie::OPimContactFields::untrphonefields( false ); |
92 | slDynamicEntries = OContactFields::untrdetailsfields( false ); | 93 | slDynamicEntries = Opie::OPimContactFields::untrdetailsfields( false ); |
93 | trlDynamicEntries = OContactFields::trdetailsfields( false ); | 94 | trlDynamicEntries = Opie::OPimContactFields::trdetailsfields( false ); |
94 | 95 | ||
95 | // Ok, we have to remove elements from the list of dynamic entries | 96 | // Ok, we have to remove elements from the list of dynamic entries |
96 | // which are now stored in special (not dynamic) widgets.. | 97 | // which are now stored in special (not dynamic) widgets.. |
97 | // Otherwise we will get problems with field assignments! (se) | 98 | // Otherwise we will get problems with field assignments! (se) |
98 | slDynamicEntries.remove("Anniversary"); | 99 | slDynamicEntries.remove("Anniversary"); |
99 | slDynamicEntries.remove("Birthday"); | 100 | slDynamicEntries.remove("Birthday"); |
100 | slDynamicEntries.remove("Gender"); | 101 | slDynamicEntries.remove("Gender"); |
101 | 102 | ||
102 | // The same with translated fields.. But I will | 103 | // The same with translated fields.. But I will |
103 | // use the translation map to avoid mismatches.. | 104 | // use the translation map to avoid mismatches.. |
104 | QMap<int, QString> translMap = OContactFields::idToTrFields(); | 105 | QMap<int, QString> translMap = Opie::OPimContactFields::idToTrFields(); |
105 | trlDynamicEntries.remove( translMap[Qtopia::Anniversary] ); | 106 | trlDynamicEntries.remove( translMap[Qtopia::Anniversary] ); |
106 | trlDynamicEntries.remove( translMap[Qtopia::Birthday] ); | 107 | trlDynamicEntries.remove( translMap[Qtopia::Birthday] ); |
107 | trlDynamicEntries.remove( translMap[Qtopia::Gender] ); | 108 | trlDynamicEntries.remove( translMap[Qtopia::Gender] ); |
108 | 109 | ||
109 | // Last Check to be sure.. | 110 | // Last Check to be sure.. |
110 | assert( slDynamicEntries.count() == trlDynamicEntries.count() ); | 111 | assert( slDynamicEntries.count() == trlDynamicEntries.count() ); |
111 | assert( slChooserNames.count() == trlChooserNames.count() ); | 112 | assert( slChooserNames.count() == trlChooserNames.count() ); |
112 | 113 | ||
113 | for (i = 0; i < slChooserNames.count(); i++) | 114 | for (i = 0; i < slChooserNames.count(); i++) |
114 | slChooserValues.append(""); | 115 | slChooserValues.append(""); |
115 | 116 | ||
116 | 117 | ||
117 | QVBoxLayout *vb = new QVBoxLayout( this ); | 118 | QVBoxLayout *vb = new QVBoxLayout( this ); |
118 | 119 | ||
119 | tabMain = new QTabWidget( this ); | 120 | tabMain = new QTabWidget( this ); |
120 | vb->addWidget( tabMain ); | 121 | vb->addWidget( tabMain ); |
121 | 122 | ||
122 | QWidget *tabViewport = new QWidget ( tabMain ); | 123 | QWidget *tabViewport = new QWidget ( tabMain ); |
123 | 124 | ||
124 | vb = new QVBoxLayout( tabViewport ); | 125 | vb = new QVBoxLayout( tabViewport ); |
125 | 126 | ||
126 | svGeneral = new QScrollView( tabViewport ); | 127 | svGeneral = new QScrollView( tabViewport ); |
127 | vb->addWidget( svGeneral, 0, 0 ); | 128 | vb->addWidget( svGeneral, 0, 0 ); |
128 | svGeneral->setResizePolicy( QScrollView::AutoOneFit ); | 129 | svGeneral->setResizePolicy( QScrollView::AutoOneFit ); |
@@ -557,50 +558,50 @@ void ContactEditor::init() { | |||
557 | deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), | 558 | deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), |
558 | tr( "Delete" ), | 559 | tr( "Delete" ), |
559 | hBox, 0 ); | 560 | hBox, 0 ); |
560 | gl->addWidget( hBox, counter , 1 ); | 561 | gl->addWidget( hBox, counter , 1 ); |
561 | 562 | ||
562 | connect( anniversaryPicker, SIGNAL( dateClicked(int,int,int) ), | 563 | connect( anniversaryPicker, SIGNAL( dateClicked(int,int,int) ), |
563 | this, SLOT( slotAnniversaryDateChanged(int,int,int) ) ); | 564 | this, SLOT( slotAnniversaryDateChanged(int,int,int) ) ); |
564 | connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveAnniversary() ) ); | 565 | connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveAnniversary() ) ); |
565 | 566 | ||
566 | ++counter; | 567 | ++counter; |
567 | 568 | ||
568 | // Gender | 569 | // Gender |
569 | l = new QLabel( tr("Gender"), container ); | 570 | l = new QLabel( tr("Gender"), container ); |
570 | gl->addWidget( l, counter, 0 ); | 571 | gl->addWidget( l, counter, 0 ); |
571 | cmbGender = new QComboBox( container ); | 572 | cmbGender = new QComboBox( container ); |
572 | cmbGender->insertItem( "", 0 ); | 573 | cmbGender->insertItem( "", 0 ); |
573 | cmbGender->insertItem( tr("Male"), 1); | 574 | cmbGender->insertItem( tr("Male"), 1); |
574 | cmbGender->insertItem( tr("Female"), 2); | 575 | cmbGender->insertItem( tr("Female"), 2); |
575 | gl->addWidget( cmbGender, counter, 1 ); | 576 | gl->addWidget( cmbGender, counter, 1 ); |
576 | 577 | ||
577 | ++counter; | 578 | ++counter; |
578 | 579 | ||
579 | // Create Labels and lineedit fields for every dynamic entry | 580 | // Create Labels and lineedit fields for every dynamic entry |
580 | QStringList::ConstIterator it = slDynamicEntries.begin(); | 581 | QStringList::ConstIterator it = slDynamicEntries.begin(); |
581 | QMap<QString, int> mapStrToID = OContactFields::untrFieldsToId(); | 582 | QMap<QString, int> mapStrToID = Opie::OPimContactFields::untrFieldsToId(); |
582 | QMap<int, QString> mapIdToStr = OContactFields::idToTrFields(); | 583 | QMap<int, QString> mapIdToStr = Opie::OPimContactFields::idToTrFields(); |
583 | for (i = counter; it != slDynamicEntries.end(); i++, ++it ) { | 584 | for (i = counter; it != slDynamicEntries.end(); i++, ++it ) { |
584 | 585 | ||
585 | if (((*it) == "Anniversary") || | 586 | if (((*it) == "Anniversary") || |
586 | ((*it) == "Birthday")|| ((*it) == "Gender")) continue; | 587 | ((*it) == "Birthday")|| ((*it) == "Gender")) continue; |
587 | 588 | ||
588 | l = new QLabel( mapIdToStr[mapStrToID[*it]], container ); | 589 | l = new QLabel( mapIdToStr[mapStrToID[*it]], container ); |
589 | listName.append( l ); | 590 | listName.append( l ); |
590 | gl->addWidget( l, i, 0 ); | 591 | gl->addWidget( l, i, 0 ); |
591 | QLineEdit *e = new QLineEdit( container ); | 592 | QLineEdit *e = new QLineEdit( container ); |
592 | listValue.append( e ); | 593 | listValue.append( e ); |
593 | gl->addWidget( e, i, 1); | 594 | gl->addWidget( e, i, 1); |
594 | } | 595 | } |
595 | // Fill labels with names.. | 596 | // Fill labels with names.. |
596 | //loadFields(); | 597 | //loadFields(); |
597 | 598 | ||
598 | 599 | ||
599 | tabMain->insertTab( tabViewport, tr( "Details" ) ); | 600 | tabMain->insertTab( tabViewport, tr( "Details" ) ); |
600 | 601 | ||
601 | dlgNote = new QDialog( this, "Note Dialog", TRUE ); | 602 | dlgNote = new QDialog( this, "Note Dialog", TRUE ); |
602 | dlgNote->setCaption( tr("Enter Note") ); | 603 | dlgNote->setCaption( tr("Enter Note") ); |
603 | QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); | 604 | QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); |
604 | txtNote = new QMultiLineEdit( dlgNote ); | 605 | txtNote = new QMultiLineEdit( dlgNote ); |
605 | vbNote->addWidget( txtNote ); | 606 | vbNote->addWidget( txtNote ); |
606 | connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) ); | 607 | connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) ); |
@@ -1229,49 +1230,49 @@ void ContactEditor::cleanupFields() { | |||
1229 | } | 1230 | } |
1230 | 1231 | ||
1231 | txtFirstName->setText(""); | 1232 | txtFirstName->setText(""); |
1232 | txtMiddleName->setText(""); | 1233 | txtMiddleName->setText(""); |
1233 | txtLastName->setText(""); | 1234 | txtLastName->setText(""); |
1234 | txtSuffix->setText(""); | 1235 | txtSuffix->setText(""); |
1235 | txtNote->setText(""); | 1236 | txtNote->setText(""); |
1236 | txtFullName->setText(""); | 1237 | txtFullName->setText(""); |
1237 | txtJobTitle->setText(""); | 1238 | txtJobTitle->setText(""); |
1238 | txtOrganization->setText(""); | 1239 | txtOrganization->setText(""); |
1239 | txtChooserField1->setText(""); | 1240 | txtChooserField1->setText(""); |
1240 | txtChooserField2->setText(""); | 1241 | txtChooserField2->setText(""); |
1241 | txtChooserField3->setText(""); | 1242 | txtChooserField3->setText(""); |
1242 | txtAddress->setText(""); | 1243 | txtAddress->setText(""); |
1243 | txtCity->setText(""); | 1244 | txtCity->setText(""); |
1244 | txtState->setText(""); | 1245 | txtState->setText(""); |
1245 | txtZip->setText(""); | 1246 | txtZip->setText(""); |
1246 | QLineEdit *txtTmp = cmbCountry->lineEdit(); | 1247 | QLineEdit *txtTmp = cmbCountry->lineEdit(); |
1247 | txtTmp->setText(""); | 1248 | txtTmp->setText(""); |
1248 | txtTmp = cmbFileAs->lineEdit(); | 1249 | txtTmp = cmbFileAs->lineEdit(); |
1249 | txtTmp->setText(""); | 1250 | txtTmp->setText(""); |
1250 | 1251 | ||
1251 | } | 1252 | } |
1252 | 1253 | ||
1253 | void ContactEditor::setEntry( const OContact &entry ) { | 1254 | void ContactEditor::setEntry( const Opie::OPimContact &entry ) { |
1254 | 1255 | ||
1255 | initializing = true; | 1256 | initializing = true; |
1256 | 1257 | ||
1257 | // Cleanup and activate the general Page .. | 1258 | // Cleanup and activate the general Page .. |
1258 | cleanupFields(); | 1259 | cleanupFields(); |
1259 | tabMain->setCurrentPage( 0 ); | 1260 | tabMain->setCurrentPage( 0 ); |
1260 | 1261 | ||
1261 | ent = entry; | 1262 | ent = entry; |
1262 | 1263 | ||
1263 | emails = QStringList(ent.emailList()); | 1264 | emails = QStringList(ent.emailList()); |
1264 | defaultEmail = ent.defaultEmail(); | 1265 | defaultEmail = ent.defaultEmail(); |
1265 | if (defaultEmail.isEmpty()) defaultEmail = emails[0]; | 1266 | if (defaultEmail.isEmpty()) defaultEmail = emails[0]; |
1266 | qDebug("default email=%s",defaultEmail.latin1()); | 1267 | qDebug("default email=%s",defaultEmail.latin1()); |
1267 | 1268 | ||
1268 | txtFirstName->setText( ent.firstName() ); | 1269 | txtFirstName->setText( ent.firstName() ); |
1269 | txtMiddleName->setText( ent.middleName() ); | 1270 | txtMiddleName->setText( ent.middleName() ); |
1270 | txtLastName->setText( ent.lastName() ); | 1271 | txtLastName->setText( ent.lastName() ); |
1271 | txtSuffix->setText( ent.suffix() ); | 1272 | txtSuffix->setText( ent.suffix() ); |
1272 | 1273 | ||
1273 | // QString *tmpString = new QString; | 1274 | // QString *tmpString = new QString; |
1274 | // *tmpString = ent.firstName() + " " + ent.middleName() + | 1275 | // *tmpString = ent.firstName() + " " + ent.middleName() + |
1275 | // + " " + ent.lastName() + " " + ent.suffix(); | 1276 | // + " " + ent.lastName() + " " + ent.suffix(); |
1276 | //txtFullName->setText( tmpString->simplifyWhiteSpace() ); | 1277 | //txtFullName->setText( tmpString->simplifyWhiteSpace() ); |
1277 | 1278 | ||