summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/contacteditor.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp
index adea1a1..e74da87 100644
--- a/core/pim/addressbook/contacteditor.cpp
+++ b/core/pim/addressbook/contacteditor.cpp
@@ -1,121 +1,121 @@
1/* 1/*
2 * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org> 2 * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org>
3 * 3 *
4 * This file is an add-on for the OPIE Palmtop Environment 4 * This file is an add-on for the OPIE 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 pacakaging 8 * Foundation and appearing in the file LICENSE.GPL included in the pacakaging
9 * of this file. 9 * 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 * 14 *
15 * This is a rewrite of the abeditor.h file, modified to provide a more 15 * 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 16 * intuitive interface to TrollTech's original Address Book editor. This
17 * is made to operate exactly in interface with the exception of name. 17 * is made to operate exactly in interface with the exception of name.
18 * 18 *
19 */ 19 */
20 20
21#include "contacteditor.h" 21#include "contacteditor.h"
22#include "addresspicker.h" 22#include "addresspicker.h"
23 23
24#include <qpe/categoryselect.h> 24#include <qpe/categoryselect.h>
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26#include <qpe/qpedialog.h> 26#include <qpe/qpedialog.h>
27 27
28#include <qcombobox.h> 28#include <qcombobox.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qtabwidget.h> 30#include <qtabwidget.h>
31#include <qlayout.h> 31#include <qlayout.h>
32#include <qlineedit.h> 32#include <qlineedit.h>
33#include <qmultilineedit.h> 33#include <qmultilineedit.h>
34#include <qscrollview.h> 34#include <qscrollview.h>
35#include <qtoolbutton.h> 35#include <qtoolbutton.h>
36#include <qpushbutton.h> 36#include <qpushbutton.h>
37#include <qmainwindow.h> 37#include <qmainwindow.h>
38#include <qvaluelist.h> 38#include <qvaluelist.h>
39 39
40static inline bool containsAlphaNum( const QString &str ); 40static inline bool containsAlphaNum( const QString &str );
41static inline bool constainsWhiteSpace( const QString &str ); 41static inline bool constainsWhiteSpace( const QString &str );
42 42
43// helper functions, convert our comma delimited list to proper 43// helper functions, convert our comma delimited list to proper
44// file format... 44// file format...
45void parseEmailFrom( const QString &txt, QString &strDefaultEmail, 45void parseEmailFrom( const QString &txt, QString &strDefaultEmail,
46 QString &strAll ); 46 QString &strAll );
47 47
48// helper convert from file format to comma delimited... 48// helper convert from file format to comma delimited...
49void parseEmailTo( const QString &strDefaultEmail, 49void parseEmailTo( const QString &strDefaultEmail,
50 const QString &strOtherEmail, QString &strBack ); 50 const QString &strOtherEmail, QString &strBack );
51 51
52 ContactEditor::ContactEditor(const Contact &entry, 52 ContactEditor::ContactEditor(const Contact &entry,
53 const QValueList<int> *newOrderedValues, 53 const QValueList<int> *newOrderedValues,
54 QStringList *slNewOrdered, 54 QStringList *slNewOrdered,
55 QWidget *parent = 0, 55 QWidget *parent,
56 const char *name = 0, 56 const char *name,
57 WFlags fl = 0 ) 57 WFlags fl )
58 : QDialog( parent, name, TRUE, fl ), 58 : QDialog( parent, name, TRUE, fl ),
59 orderedValues( newOrderedValues ), 59 orderedValues( newOrderedValues ),
60 slOrdered( slNewOrdered ) 60 slOrdered( slNewOrdered )
61{ 61{
62 62
63 init(); 63 init();
64 initMap(); 64 initMap();
65 setEntry( entry ); 65 setEntry( entry );
66 qDebug("finish"); 66 qDebug("finish");
67} 67}
68 68
69ContactEditor::~ContactEditor() { 69ContactEditor::~ContactEditor() {
70} 70}
71 71
72void ContactEditor::init() { 72void ContactEditor::init() {
73 73
74 useFullName = TRUE; 74 useFullName = TRUE;
75 75
76 int i = 0; 76 int i = 0;
77 77
78 slHomeAddress = new QStringList; 78 slHomeAddress = new QStringList;
79 slBusinessAddress = new QStringList; 79 slBusinessAddress = new QStringList;
80 slChooserNames = new QStringList; 80 slChooserNames = new QStringList;
81 slChooserValues = new QStringList; 81 slChooserValues = new QStringList;
82 82
83 slDynamicEntries = new QStringList; 83 slDynamicEntries = new QStringList;
84 84
85 //*slDynamicEntries = *slOrdered; 85 //*slDynamicEntries = *slOrdered;
86 86
87 for (i = 0; i <= 6; i++) { 87 for (i = 0; i <= 6; i++) {
88 slHomeAddress->append( "" ); 88 slHomeAddress->append( "" );
89 slBusinessAddress->append( "" ); 89 slBusinessAddress->append( "" );
90 } 90 }
91 91
92 { 92 {
93 hasGender = FALSE; 93 hasGender = FALSE;
94 hasTitle = FALSE; 94 hasTitle = FALSE;
95 hasCompany = FALSE; 95 hasCompany = FALSE;
96 hasNotes = FALSE; 96 hasNotes = FALSE;
97 hasStreet = FALSE; 97 hasStreet = FALSE;
98 hasStreet2 = FALSE; 98 hasStreet2 = FALSE;
99 hasPOBox = FALSE; 99 hasPOBox = FALSE;
100 hasCity = FALSE; 100 hasCity = FALSE;
101 hasState = FALSE; 101 hasState = FALSE;
102 hasZip = FALSE; 102 hasZip = FALSE;
103 hasCountry = FALSE; 103 hasCountry = FALSE;
104 104
105 QStringList::ConstIterator it = slOrdered->begin(); 105 QStringList::ConstIterator it = slOrdered->begin();
106 for ( i = 0; it != slOrdered->end(); i++, ++it ) { 106 for ( i = 0; it != slOrdered->end(); i++, ++it ) {
107 107
108 if ( (*it).right( 3 ) == tr( "Fax" ) ) { 108 if ( (*it).right( 3 ) == tr( "Fax" ) ) {
109 slChooserNames->append( *it ); 109 slChooserNames->append( *it );
110 slChooserValues->append( tr( "" ) ); 110 slChooserValues->append( tr( "" ) );
111 //slDynamicEntries->remove( it ); 111 //slDynamicEntries->remove( it );
112 continue; 112 continue;
113 } 113 }
114 114
115 if ( (*it).right( 5 ) == tr( "Phone" ) ) { 115 if ( (*it).right( 5 ) == tr( "Phone" ) ) {
116 slChooserNames->append( *it ); 116 slChooserNames->append( *it );
117 slChooserValues->append( "" ); 117 slChooserValues->append( "" );
118 //slDynamicEntries->remove( it ); 118 //slDynamicEntries->remove( it );
119 continue; 119 continue;
120 } 120 }
121 121
@@ -1064,128 +1064,129 @@ QString ContactEditor::parseName( const QString fullName, int type ) {
1064 break; 1064 break;
1065 1065
1066 case 3: 1066 case 3:
1067 spPos = simplifiedName.find( ' ', 0, TRUE ); 1067 spPos = simplifiedName.find( ' ', 0, TRUE );
1068 strLastName = simplifiedName.left( spPos ); 1068 strLastName = simplifiedName.left( spPos );
1069 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); 1069 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1070 strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); 1070 strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1071 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); 1071 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE );
1072 strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); 1072 strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 );
1073 strSuffix = simplifiedName.mid( spPos + 1 ); 1073 strSuffix = simplifiedName.mid( spPos + 1 );
1074 break; 1074 break;
1075 1075
1076 case 4: 1076 case 4:
1077 spPos = simplifiedName.find( ' ', 0, TRUE ); 1077 spPos = simplifiedName.find( ' ', 0, TRUE );
1078 strLastName = simplifiedName.left( spPos ); 1078 strLastName = simplifiedName.left( spPos );
1079 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); 1079 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1080 strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); 1080 strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1081 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); 1081 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE );
1082 strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); 1082 strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 );
1083 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); 1083 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1084 strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); 1084 strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1085 strSuffix = simplifiedName.mid( spPos2 + 1 ); 1085 strSuffix = simplifiedName.mid( spPos2 + 1 );
1086 break; 1086 break;
1087 1087
1088 default: 1088 default:
1089 spPos = simplifiedName.find( ' ', 0, TRUE ); 1089 spPos = simplifiedName.find( ' ', 0, TRUE );
1090 strLastName = simplifiedName.left( spPos ); 1090 strLastName = simplifiedName.left( spPos );
1091 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); 1091 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1092 strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); 1092 strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1093 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); 1093 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE );
1094 strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos ); 1094 strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos );
1095 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); 1095 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1096 strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); 1096 strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1097 strSuffix = simplifiedName.mid( spPos2 + 1 ); 1097 strSuffix = simplifiedName.mid( spPos2 + 1 );
1098 break; 1098 break;
1099 } 1099 }
1100 } 1100 }
1101 1101
1102 switch (type) { 1102 switch (type) {
1103 case NAME_FL: 1103 case NAME_FL:
1104 return strFirstName + " " + strLastName; 1104 return strFirstName + " " + strLastName;
1105 1105
1106 case NAME_LF: 1106 case NAME_LF:
1107 return strLastName + ", " + strFirstName; 1107 return strLastName + ", " + strFirstName;
1108 1108
1109 case NAME_LFM: 1109 case NAME_LFM:
1110 return strLastName + ", " + strFirstName + " " + strMiddleName; 1110 return strLastName + ", " + strFirstName + " " + strMiddleName;
1111 1111
1112 case NAME_FMLS: 1112 case NAME_FMLS:
1113 return strFirstName + " " + strMiddleName + " " + strLastName + " " + strSuffix; 1113 return strFirstName + " " + strMiddleName + " " + strLastName + " " + strSuffix;
1114 1114
1115 case NAME_F: 1115 case NAME_F:
1116 return strFirstName; 1116 return strFirstName;
1117 1117
1118 case NAME_M: 1118 case NAME_M:
1119 return strMiddleName; 1119 return strMiddleName;
1120 1120
1121 case NAME_L: 1121 case NAME_L:
1122 return strLastName; 1122 return strLastName;
1123 1123
1124 case NAME_S: 1124 case NAME_S:
1125 return strSuffix; 1125 return strSuffix;
1126 1126
1127 } 1127 }
1128 return QString::null;
1128} 1129}
1129 1130
1130void ContactEditor::cleanupFields() { 1131void ContactEditor::cleanupFields() {
1131 1132
1132 QStringList::Iterator it = slChooserValues->begin(); 1133 QStringList::Iterator it = slChooserValues->begin();
1133 for ( int i = 0; it != slChooserValues->end(); i++, ++it ) { 1134 for ( int i = 0; it != slChooserValues->end(); i++, ++it ) {
1134 (*it) = ""; 1135 (*it) = "";
1135 } 1136 }
1136 1137
1137 for ( int i = 0; i < 7; i++ ) { 1138 for ( int i = 0; i < 7; i++ ) {
1138 (*slHomeAddress)[i] = ""; 1139 (*slHomeAddress)[i] = "";
1139 (*slBusinessAddress)[i] = ""; 1140 (*slBusinessAddress)[i] = "";
1140 } 1141 }
1141 1142
1142 QStringList::ConstIterator cit; 1143 QStringList::ConstIterator cit;
1143 QListIterator<QLineEdit> itLE( listValue ); 1144 QListIterator<QLineEdit> itLE( listValue );
1144 for ( cit = slDynamicEntries->begin(); cit != slDynamicEntries->end(); ++cit, ++itLE) { 1145 for ( cit = slDynamicEntries->begin(); cit != slDynamicEntries->end(); ++cit, ++itLE) {
1145 (*itLE)->setText( "" ); 1146 (*itLE)->setText( "" );
1146 } 1147 }
1147 1148
1148 txtFirstName->setText(""); 1149 txtFirstName->setText("");
1149 txtMiddleName->setText(""); 1150 txtMiddleName->setText("");
1150 txtLastName->setText(""); 1151 txtLastName->setText("");
1151 txtSuffix->setText(""); 1152 txtSuffix->setText("");
1152 txtNote->setText(""); 1153 txtNote->setText("");
1153 txtFullName->setText(""); 1154 txtFullName->setText("");
1154 txtJobTitle->setText(""); 1155 txtJobTitle->setText("");
1155 txtOrganization->setText(""); 1156 txtOrganization->setText("");
1156 txtChooserField1->setText(""); 1157 txtChooserField1->setText("");
1157 txtChooserField2->setText(""); 1158 txtChooserField2->setText("");
1158 txtChooserField3->setText(""); 1159 txtChooserField3->setText("");
1159 txtAddress->setText(""); 1160 txtAddress->setText("");
1160 //txtAddress2->setText(""); 1161 //txtAddress2->setText("");
1161 txtCity->setText(""); 1162 txtCity->setText("");
1162 //txtPOBox->setText(""); 1163 //txtPOBox->setText("");
1163 txtState->setText(""); 1164 txtState->setText("");
1164 txtZip->setText(""); 1165 txtZip->setText("");
1165 QLineEdit *txtTmp = cmbCountry->lineEdit(); 1166 QLineEdit *txtTmp = cmbCountry->lineEdit();
1166 txtTmp->setText(""); 1167 txtTmp->setText("");
1167 txtTmp = cmbFileAs->lineEdit(); 1168 txtTmp = cmbFileAs->lineEdit();
1168 txtTmp->setText(""); 1169 txtTmp->setText("");
1169 1170
1170} 1171}
1171 1172
1172void ContactEditor::setEntry( const Contact &entry ) { 1173void ContactEditor::setEntry( const Contact &entry ) {
1173 1174
1174 cleanupFields(); 1175 cleanupFields();
1175 1176
1176 1177
1177 ent = entry; 1178 ent = entry;
1178 1179
1179 useFullName = FALSE; 1180 useFullName = FALSE;
1180 txtFirstName->setText( ent.firstName() ); 1181 txtFirstName->setText( ent.firstName() );
1181 txtMiddleName->setText( ent.middleName() ); 1182 txtMiddleName->setText( ent.middleName() );
1182 txtLastName->setText( ent.lastName() ); 1183 txtLastName->setText( ent.lastName() );
1183 txtSuffix->setText( ent.suffix() ); 1184 txtSuffix->setText( ent.suffix() );
1184 1185
1185 QString *tmpString = new QString; 1186 QString *tmpString = new QString;
1186 *tmpString = ent.firstName() + " " + ent.middleName() + 1187 *tmpString = ent.firstName() + " " + ent.middleName() +
1187 + " " + ent.lastName() + " " + ent.suffix(); 1188 + " " + ent.lastName() + " " + ent.suffix();
1188 1189
1189 txtFullName->setText( tmpString->simplifyWhiteSpace() ); 1190 txtFullName->setText( tmpString->simplifyWhiteSpace() );
1190 1191
1191 cmbFileAs->setEditText( ent.fileAs() ); 1192 cmbFileAs->setEditText( ent.fileAs() );