Diffstat (limited to 'core/pim/addressbook/contacteditor.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/addressbook/contacteditor.cpp | 62 |
1 files changed, 30 insertions, 32 deletions
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp index b078968..dec4c7c 100644 --- a/core/pim/addressbook/contacteditor.cpp +++ b/core/pim/addressbook/contacteditor.cpp | |||
@@ -10,76 +10,75 @@ | |||
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 | #include "namelineedit.h" | 23 | #include "namelineedit.h" |
24 | 24 | ||
25 | #include <opie2/odebug.h> | 25 | #include <opie2/odebug.h> |
26 | #include <opie2/opimcontact.h> | 26 | #include <opie2/opimcontact.h> |
27 | 27 | ||
28 | #include <qpe/categoryselect.h> | 28 | #include <qpe/categoryselect.h> |
29 | #include <qpe/qpeapplication.h> | 29 | #include <qpe/qpeapplication.h> |
30 | #include <qpe/qpedialog.h> | 30 | #include <qpe/qpedialog.h> |
31 | #include <qpe/resource.h> | 31 | #include <qpe/resource.h> |
32 | 32 | ||
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | #include <qtabwidget.h> | ||
35 | #include <qlayout.h> | 34 | #include <qlayout.h> |
36 | #include <qlineedit.h> | 35 | #include <qlineedit.h> |
37 | #include <qmultilineedit.h> | 36 | #include <qmultilineedit.h> |
38 | #include <qtoolbutton.h> | 37 | #include <qtoolbutton.h> |
39 | #include <qlistbox.h> | 38 | #include <qlistbox.h> |
40 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
41 | #include <qwhatsthis.h> | 40 | #include <qwhatsthis.h> |
42 | 41 | ||
43 | #include <assert.h> | 42 | #include <assert.h> |
44 | 43 | ||
45 | static inline bool containsAlphaNum( const QString &str ); | 44 | static inline bool containsAlphaNum( const QString &str ); |
46 | static inline bool constainsWhiteSpace( const QString &str ); | 45 | static inline bool constainsWhiteSpace( const QString &str ); |
47 | 46 | ||
48 | // helper functions, convert our comma delimited list to proper | 47 | // helper functions, convert our comma delimited list to proper |
49 | // file format... | 48 | // file format... |
50 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, | 49 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, |
51 | QString &strAll ); | 50 | QString &strAll ); |
52 | 51 | ||
53 | // helper convert from file format to comma delimited... | 52 | // helper convert from file format to comma delimited... |
54 | void parseEmailTo( const QString &strDefaultEmail, | 53 | void parseEmailTo( const QString &strDefaultEmail, |
55 | const QString &strOtherEmail, QString &strBack ); | 54 | const QString &strOtherEmail, QString &strBack ); |
56 | 55 | ||
57 | ContactEditor::ContactEditor(const Opie::OPimContact &entry, | 56 | ContactEditor::ContactEditor(const Opie::OPimContact &entry, |
58 | QWidget *parent, | 57 | QWidget *parent, |
59 | const char *name, | 58 | const char *name, |
60 | WFlags ) | 59 | WFlags ) |
61 | : QDialog( parent, name, TRUE, WStyle_ContextHelp ), | 60 | : QDialog( parent, name, true, WStyle_ContextHelp ), |
62 | defaultEmailChooserPosition( -1 ), | 61 | defaultEmailChooserPosition( -1 ), |
63 | m_personalView ( false ), | 62 | m_personalView ( false ), |
64 | cmbDefaultEmail( 0 ), | 63 | cmbDefaultEmail( 0 ), |
65 | initializing ( false ) | 64 | initializing ( false ) |
66 | { | 65 | { |
67 | 66 | ||
68 | initializing = true; | 67 | initializing = true; |
69 | 68 | ||
70 | init(); | 69 | init(); |
71 | setEntry( entry ); | 70 | setEntry( entry ); |
72 | // cmbDefaultEmail = 0; | 71 | // cmbDefaultEmail = 0; |
73 | // defaultEmailChooserPosition = -1; | 72 | // defaultEmailChooserPosition = -1; |
74 | 73 | ||
75 | initializing = false; | 74 | initializing = false; |
76 | } | 75 | } |
77 | 76 | ||
78 | ContactEditor::~ContactEditor() { | 77 | ContactEditor::~ContactEditor() { |
79 | } | 78 | } |
80 | 79 | ||
81 | void ContactEditor::init() { | 80 | void ContactEditor::init() { |
82 | odebug << "init() START" << oendl; | 81 | odebug << "init() START" << oendl; |
83 | 82 | ||
84 | uint i = 0; | 83 | uint i = 0; |
85 | 84 | ||
@@ -98,195 +97,194 @@ void ContactEditor::init() { | |||
98 | // Ok, we have to remove elements from the list of dynamic entries | 97 | // Ok, we have to remove elements from the list of dynamic entries |
99 | // which are now stored in special (not dynamic) widgets.. | 98 | // which are now stored in special (not dynamic) widgets.. |
100 | // Otherwise we will get problems with field assignments! (se) | 99 | // Otherwise we will get problems with field assignments! (se) |
101 | slDynamicEntries.remove("Anniversary"); | 100 | slDynamicEntries.remove("Anniversary"); |
102 | slDynamicEntries.remove("Birthday"); | 101 | slDynamicEntries.remove("Birthday"); |
103 | slDynamicEntries.remove("Gender"); | 102 | slDynamicEntries.remove("Gender"); |
104 | 103 | ||
105 | // The same with translated fields.. But I will | 104 | // The same with translated fields.. But I will |
106 | // use the translation map to avoid mismatches.. | 105 | // use the translation map to avoid mismatches.. |
107 | QMap<int, QString> translMap = Opie::OPimContactFields::idToTrFields(); | 106 | QMap<int, QString> translMap = Opie::OPimContactFields::idToTrFields(); |
108 | trlDynamicEntries.remove( translMap[Qtopia::Anniversary] ); | 107 | trlDynamicEntries.remove( translMap[Qtopia::Anniversary] ); |
109 | trlDynamicEntries.remove( translMap[Qtopia::Birthday] ); | 108 | trlDynamicEntries.remove( translMap[Qtopia::Birthday] ); |
110 | trlDynamicEntries.remove( translMap[Qtopia::Gender] ); | 109 | trlDynamicEntries.remove( translMap[Qtopia::Gender] ); |
111 | 110 | ||
112 | // Last Check to be sure.. | 111 | // Last Check to be sure.. |
113 | assert( slDynamicEntries.count() == trlDynamicEntries.count() ); | 112 | assert( slDynamicEntries.count() == trlDynamicEntries.count() ); |
114 | assert( slChooserNames.count() == trlChooserNames.count() ); | 113 | assert( slChooserNames.count() == trlChooserNames.count() ); |
115 | 114 | ||
116 | for (i = 0; i < slChooserNames.count(); i++) | 115 | for (i = 0; i < slChooserNames.count(); i++) |
117 | slChooserValues.append(""); | 116 | slChooserValues.append(""); |
118 | 117 | ||
119 | 118 | ||
120 | QVBoxLayout *vb = new QVBoxLayout( this ); | 119 | QVBoxLayout *vb = new QVBoxLayout( this ); |
121 | 120 | ||
122 | tabMain = new QTabWidget( this ); | 121 | tabMain = new Opie::Ui::OTabWidget( this ); |
123 | vb->addWidget( tabMain ); | 122 | vb->addWidget( tabMain ); |
124 | 123 | ||
125 | QWidget *tabViewport = new QWidget ( tabMain ); | 124 | m_generalWidget = new QWidget ( tabMain ); |
126 | 125 | ||
127 | vb = new QVBoxLayout( tabViewport ); | 126 | vb = new QVBoxLayout( m_generalWidget ); |
128 | 127 | ||
129 | svGeneral = new QScrollView( tabViewport ); | 128 | svGeneral = new QScrollView( m_generalWidget ); |
130 | vb->addWidget( svGeneral, 0, 0 ); | 129 | vb->addWidget( svGeneral, 0, 0 ); |
131 | svGeneral->setResizePolicy( QScrollView::AutoOneFit ); | 130 | svGeneral->setResizePolicy( QScrollView::AutoOneFit ); |
132 | // svGeneral->setHScrollBarMode( QScrollView::AlwaysOff ); | 131 | // svGeneral->setHScrollBarMode( QScrollView::AlwaysOff ); |
133 | // svGeneral->setVScrollBarMode( QScrollView::AlwaysOff ); | 132 | // svGeneral->setVScrollBarMode( QScrollView::AlwaysOff ); |
134 | svGeneral->setFrameStyle( QFrame::NoFrame ); | 133 | svGeneral->setFrameStyle( QFrame::NoFrame ); |
135 | 134 | ||
136 | QWidget *container = new QWidget( svGeneral->viewport() ); | 135 | QWidget *container = new QWidget( svGeneral->viewport() ); |
137 | svGeneral->addChild( container ); | 136 | svGeneral->addChild( container ); |
138 | 137 | ||
139 | QGridLayout *gl = new QGridLayout( container, 1, 1, 2, 4 ); | 138 | QGridLayout *gl = new QGridLayout( container, 10, 2, 2, 4 ); |
140 | gl->setResizeMode( QLayout::FreeResize ); | ||
141 | 139 | ||
142 | btnFullName = new QPushButton( tr( "Full Name..." ), container ); | 140 | btnFullName = new QPushButton( tr( "Full Name..." ), container ); |
143 | QWhatsThis::add( btnFullName, tr( "Press to enter last- middle and firstname" ) ); | 141 | QWhatsThis::add( btnFullName, tr( "Press to enter last- middle and firstname" ) ); |
144 | gl->addWidget( btnFullName, 0, 0 ); | 142 | gl->addWidget( btnFullName, 0, 0 ); |
145 | txtFullName = new ABOOK::NameLineEdit( container ); | 143 | txtFullName = new ABOOK::NameLineEdit( container ); |
146 | QWhatsThis::add( txtFullName, tr( "Enter fullname directly ! If you have a lastname with multiple words ( for instance \"de la Guerra\"), please write <lastname>,<firstnames> like this: \"de la Guerra, Carlos Pedro\"" ) ); | 144 | QWhatsThis::add( txtFullName, tr( "Enter fullname directly ! If you have a lastname with multiple words ( for instance \"de la Guerra\"), please write <lastname>,<firstnames> like this: \"de la Guerra, Carlos Pedro\"" ) ); |
147 | gl->addWidget( txtFullName, 0, 1 ); | 145 | gl->addWidget( txtFullName, 0, 1 ); |
148 | 146 | ||
149 | QLabel *l = new QLabel( tr( "Job Title" ), container ); | 147 | QLabel *l = new QLabel( tr( "Job Title" ), container ); |
150 | QWhatsThis::add( l, tr( "The jobtitle.." ) ); | 148 | QWhatsThis::add( l, tr( "The jobtitle.." ) ); |
151 | gl->addWidget( l, 1, 0 ); | 149 | gl->addWidget( l, 1, 0 ); |
152 | txtJobTitle = new QLineEdit( container ); | 150 | txtJobTitle = new QLineEdit( container ); |
153 | QWhatsThis::add( txtJobTitle, tr( "The jobtitle.." ) ); | 151 | QWhatsThis::add( txtJobTitle, tr( "The jobtitle.." ) ); |
154 | gl->addWidget( txtJobTitle, 1, 1 ); | 152 | gl->addWidget( txtJobTitle, 1, 1 ); |
155 | 153 | ||
156 | l = new QLabel( tr("Suffix"), container ); | 154 | l = new QLabel( tr("Suffix"), container ); |
157 | QWhatsThis::add( l, tr( "Something like \"jr.\".." ) ); | 155 | QWhatsThis::add( l, tr( "Something like \"jr.\".." ) ); |
158 | gl->addWidget( l, 2, 0 ); | 156 | gl->addWidget( l, 2, 0 ); |
159 | txtSuffix = new QLineEdit( container ); | 157 | txtSuffix = new QLineEdit( container ); |
160 | QWhatsThis::add( txtSuffix, tr( "Something like \"jr.\".." ) ); | 158 | QWhatsThis::add( txtSuffix, tr( "Something like \"jr.\".." ) ); |
161 | gl->addWidget( txtSuffix, 2, 1 ); | 159 | gl->addWidget( txtSuffix, 2, 1 ); |
162 | 160 | ||
163 | l = new QLabel( tr( "Organization" ), container ); | 161 | l = new QLabel( tr( "Organization" ), container ); |
164 | QWhatsThis::add( l, tr( "The working place of the contact" ) ); | 162 | QWhatsThis::add( l, tr( "The working place of the contact" ) ); |
165 | gl->addWidget( l, 3, 0 ); | 163 | gl->addWidget( l, 3, 0 ); |
166 | txtOrganization = new QLineEdit( container ); | 164 | txtOrganization = new QLineEdit( container ); |
167 | QWhatsThis::add( txtOrganization, tr( "The working place of the contact" ) ); | 165 | QWhatsThis::add( txtOrganization, tr( "The working place of the contact" ) ); |
168 | gl->addWidget( txtOrganization, 3, 1 ); | 166 | gl->addWidget( txtOrganization, 3, 1 ); |
169 | 167 | ||
170 | // Chooser 1 | 168 | // Chooser 1 |
171 | cmbChooserField1 = new QComboBox( FALSE, container ); | 169 | cmbChooserField1 = new QComboBox( false, container ); |
172 | QWhatsThis::add( cmbChooserField1, tr( "Press to select attribute to change" ) ); | 170 | QWhatsThis::add( cmbChooserField1, tr( "Press to select attribute to change" ) ); |
173 | cmbChooserField1->setMaximumWidth( 90 ); | 171 | cmbChooserField1->setMaximumWidth( 90 ); |
174 | gl->addWidget( cmbChooserField1, 4, 0 ); | 172 | gl->addWidget( cmbChooserField1, 4, 0 ); |
175 | // Textfield for chooser 1. | 173 | // Textfield for chooser 1. |
176 | // Now use Widgetstack to contain the textfield and the default-email combo ! | 174 | // Now use Widgetstack to contain the textfield and the default-email combo ! |
177 | m_widgetStack1 = new QWidgetStack( container ); | 175 | m_widgetStack1 = new QWidgetStack( container ); |
178 | txtChooserField1 = new QLineEdit( m_widgetStack1 ); | 176 | txtChooserField1 = new QLineEdit( m_widgetStack1 ); |
179 | m_widgetStack1 -> addWidget( txtChooserField1, TextField ); | 177 | m_widgetStack1 -> addWidget( txtChooserField1, TextField ); |
180 | gl->addWidget( m_widgetStack1, 4, 1 ); | 178 | gl->addWidget( m_widgetStack1, 4, 1 ); |
181 | m_widgetStack1 -> raiseWidget( TextField ); | 179 | m_widgetStack1 -> raiseWidget( TextField ); |
182 | 180 | ||
183 | // Chooser 2 | 181 | // Chooser 2 |
184 | cmbChooserField2 = new QComboBox( FALSE, container ); | 182 | cmbChooserField2 = new QComboBox( false, container ); |
185 | QWhatsThis::add( cmbChooserField2, tr( "Press to select attribute to change" ) ); | 183 | QWhatsThis::add( cmbChooserField2, tr( "Press to select attribute to change" ) ); |
186 | cmbChooserField2->setMaximumWidth( 90 ); | 184 | cmbChooserField2->setMaximumWidth( 90 ); |
187 | gl->addWidget( cmbChooserField2, 5, 0 ); | 185 | gl->addWidget( cmbChooserField2, 5, 0 ); |
188 | // Textfield for chooser 2 | 186 | // Textfield for chooser 2 |
189 | // Now use WidgetStack to contain the textfield and the default-email combo! | 187 | // Now use WidgetStack to contain the textfield and the default-email combo! |
190 | m_widgetStack2 = new QWidgetStack( container ); | 188 | m_widgetStack2 = new QWidgetStack( container ); |
191 | txtChooserField2 = new QLineEdit( m_widgetStack2 ); | 189 | txtChooserField2 = new QLineEdit( m_widgetStack2 ); |
192 | m_widgetStack2 -> addWidget( txtChooserField2, TextField ); | 190 | m_widgetStack2 -> addWidget( txtChooserField2, TextField ); |
193 | gl->addWidget( m_widgetStack2, 5, 1 ); | 191 | gl->addWidget( m_widgetStack2, 5, 1 ); |
194 | m_widgetStack2 -> raiseWidget( TextField ); | 192 | m_widgetStack2 -> raiseWidget( TextField ); |
195 | 193 | ||
196 | // Chooser 3 | 194 | // Chooser 3 |
197 | cmbChooserField3 = new QComboBox( FALSE, container ); | 195 | cmbChooserField3 = new QComboBox( false, container ); |
198 | QWhatsThis::add( cmbChooserField3, tr( "Press to select attribute to change" ) ); | 196 | QWhatsThis::add( cmbChooserField3, tr( "Press to select attribute to change" ) ); |
199 | cmbChooserField3->setMaximumWidth( 90 ); | 197 | cmbChooserField3->setMaximumWidth( 90 ); |
200 | gl->addWidget( cmbChooserField3, 6, 0 ); | 198 | gl->addWidget( cmbChooserField3, 6, 0 ); |
201 | // Textfield for chooser 2 | 199 | // Textfield for chooser 2 |
202 | // Now use WidgetStack to contain the textfield and the default-email combo! | 200 | // Now use WidgetStack to contain the textfield and the default-email combo! |
203 | m_widgetStack3 = new QWidgetStack( container ); | 201 | m_widgetStack3 = new QWidgetStack( container ); |
204 | txtChooserField3 = new QLineEdit( m_widgetStack3 ); | 202 | txtChooserField3 = new QLineEdit( m_widgetStack3 ); |
205 | m_widgetStack3 -> addWidget( txtChooserField3, TextField ); | 203 | m_widgetStack3 -> addWidget( txtChooserField3, TextField ); |
206 | gl->addWidget( m_widgetStack3, 6, 1 ); | 204 | gl->addWidget( m_widgetStack3, 6, 1 ); |
207 | m_widgetStack3 -> raiseWidget( TextField ); | 205 | m_widgetStack3 -> raiseWidget( TextField ); |
208 | 206 | ||
209 | l = new QLabel( tr( "File As" ), container ); | 207 | l = new QLabel( tr( "File As" ), container ); |
210 | QWhatsThis::add( l, tr( "Press to select how to store the name (and howto show it in the listview)" ) ); | 208 | QWhatsThis::add( l, tr( "Press to select how to store the name (and howto show it in the listview)" ) ); |
211 | gl->addWidget( l, 7, 0 ); | 209 | gl->addWidget( l, 7, 0 ); |
212 | cmbFileAs = new QComboBox( TRUE, container ); | 210 | cmbFileAs = new QComboBox( true, container ); |
213 | gl->addWidget( cmbFileAs, 7, 1 ); | 211 | gl->addWidget( cmbFileAs, 7, 1 ); |
214 | 212 | ||
215 | labCat = new QLabel( tr( "Category" ), container ); | 213 | labCat = new QLabel( tr( "Category" ), container ); |
216 | gl->addWidget( labCat, 8, 0 ); | 214 | gl->addWidget( labCat, 8, 0 ); |
217 | cmbCat = new CategorySelect( container ); | 215 | cmbCat = new CategorySelect( container ); |
218 | gl->addWidget( cmbCat, 8, 1 ); | 216 | gl->addWidget( cmbCat, 8, 1 ); |
219 | labCat->show(); | 217 | labCat->show(); |
220 | cmbCat->show(); | 218 | cmbCat->show(); |
221 | 219 | ||
222 | btnNote = new QPushButton( tr( "Notes..." ), container ); | 220 | btnNote = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Notes..." ), container ); |
223 | gl->addWidget( btnNote, 9, 1 ); | 221 | gl->addWidget( btnNote, 9, 1 ); |
224 | 222 | ||
225 | tabMain->insertTab( tabViewport, tr( "General" ) ); | 223 | tabMain->addTab( m_generalWidget, "addressbook/AddressBookSmall", tr( "General" ) ); |
226 | 224 | ||
227 | tabViewport = new QWidget ( tabMain ); | 225 | QWidget *tabViewport = new QWidget ( tabMain ); |
228 | 226 | ||
229 | vb = new QVBoxLayout( tabViewport ); | 227 | vb = new QVBoxLayout( tabViewport ); |
230 | 228 | ||
231 | svAddress = new QScrollView( tabViewport ); | 229 | svAddress = new QScrollView( tabViewport ); |
232 | vb->addWidget( svAddress, 0, 0 ); | 230 | vb->addWidget( svAddress, 0, 0 ); |
233 | svAddress->setResizePolicy( QScrollView::AutoOneFit ); | 231 | svAddress->setResizePolicy( QScrollView::AutoOneFit ); |
234 | svAddress->setFrameStyle( QFrame::NoFrame ); | 232 | svAddress->setFrameStyle( QFrame::NoFrame ); |
235 | 233 | ||
236 | container = new QWidget( svAddress->viewport() ); | 234 | container = new QWidget( svAddress->viewport() ); |
237 | svAddress->addChild( container ); | 235 | svAddress->addChild( container ); |
238 | 236 | ||
239 | gl = new QGridLayout( container, 8, 3, 2, 4 ); // row 7 QSpacerItem | 237 | gl = new QGridLayout( container, 8, 3, 2, 4 ); // row 7 QSpacerItem |
240 | 238 | ||
241 | cmbAddress = new QComboBox( FALSE, container ); | 239 | cmbAddress = new QComboBox( false, container ); |
242 | cmbAddress->insertItem( tr( "Business" ) ); | 240 | cmbAddress->insertItem( tr( "Business" ) ); |
243 | cmbAddress->insertItem( tr( "Home" ) ); | 241 | cmbAddress->insertItem( tr( "Home" ) ); |
244 | gl->addMultiCellWidget( cmbAddress, 0, 0, 0, 1 ); | 242 | gl->addMultiCellWidget( cmbAddress, 0, 0, 0, 1 ); |
245 | 243 | ||
246 | l = new QLabel( tr( "Address" ), container ); | 244 | l = new QLabel( tr( "Address" ), container ); |
247 | gl->addWidget( l, 1, 0 ); | 245 | gl->addWidget( l, 1, 0 ); |
248 | txtAddress = new QLineEdit( container ); | 246 | txtAddress = new QLineEdit( container ); |
249 | gl->addMultiCellWidget( txtAddress, 1, 1, 1, 2 ); | 247 | gl->addMultiCellWidget( txtAddress, 1, 1, 1, 2 ); |
250 | 248 | ||
251 | l = new QLabel( tr( "City" ), container ); | 249 | l = new QLabel( tr( "City" ), container ); |
252 | gl->addWidget( l, 2, 0 ); | 250 | gl->addWidget( l, 2, 0 ); |
253 | txtCity = new QLineEdit( container ); | 251 | txtCity = new QLineEdit( container ); |
254 | gl->addMultiCellWidget( txtCity, 2, 2, 1, 2 ); | 252 | gl->addMultiCellWidget( txtCity, 2, 2, 1, 2 ); |
255 | 253 | ||
256 | l = new QLabel( tr( "State" ), container ); | 254 | l = new QLabel( tr( "State" ), container ); |
257 | gl->addWidget( l, 3, 0 ); | 255 | gl->addWidget( l, 3, 0 ); |
258 | txtState = new QLineEdit( container ); | 256 | txtState = new QLineEdit( container ); |
259 | gl->addMultiCellWidget( txtState, 3, 3, 1, 2 ); | 257 | gl->addMultiCellWidget( txtState, 3, 3, 1, 2 ); |
260 | 258 | ||
261 | l = new QLabel( tr( "Zip Code" ), container ); | 259 | l = new QLabel( tr( "Zip Code" ), container ); |
262 | gl->addWidget( l, 4, 0 ); | 260 | gl->addWidget( l, 4, 0 ); |
263 | txtZip = new QLineEdit( container ); | 261 | txtZip = new QLineEdit( container ); |
264 | gl->addMultiCellWidget( txtZip, 4, 4, 1, 2 ); | 262 | gl->addMultiCellWidget( txtZip, 4, 4, 1, 2 ); |
265 | 263 | ||
266 | l = new QLabel( tr( "Country" ), container ); | 264 | l = new QLabel( tr( "Country" ), container ); |
267 | gl->addWidget( l, 5, 0 ); | 265 | gl->addWidget( l, 5, 0 ); |
268 | cmbCountry = new QComboBox( TRUE, container ); | 266 | cmbCountry = new QComboBox( true, container ); |
269 | cmbCountry->insertItem( "" ); | 267 | cmbCountry->insertItem( "" ); |
270 | cmbCountry->insertItem( tr ( "United States" ) ); | 268 | cmbCountry->insertItem( tr ( "United States" ) ); |
271 | cmbCountry->insertItem( tr ( "United Kingdom" ) ); | 269 | cmbCountry->insertItem( tr ( "United Kingdom" ) ); |
272 | cmbCountry->insertItem( tr ( "Afghanistan" ) ); | 270 | cmbCountry->insertItem( tr ( "Afghanistan" ) ); |
273 | cmbCountry->insertItem( tr ( "Albania" ) ); | 271 | cmbCountry->insertItem( tr ( "Albania" ) ); |
274 | cmbCountry->insertItem( tr ( "Algeria" ) ); | 272 | cmbCountry->insertItem( tr ( "Algeria" ) ); |
275 | cmbCountry->insertItem( tr ( "American Samoa" ) ); | 273 | cmbCountry->insertItem( tr ( "American Samoa" ) ); |
276 | cmbCountry->insertItem( tr ( "Andorra" ) ); | 274 | cmbCountry->insertItem( tr ( "Andorra" ) ); |
277 | cmbCountry->insertItem( tr ( "Angola" ) ); | 275 | cmbCountry->insertItem( tr ( "Angola" ) ); |
278 | cmbCountry->insertItem( tr ( "Anguilla" ) ); | 276 | cmbCountry->insertItem( tr ( "Anguilla" ) ); |
279 | cmbCountry->insertItem( tr ( "Antarctica" ) ); | 277 | cmbCountry->insertItem( tr ( "Antarctica" ) ); |
280 | cmbCountry->insertItem( tr ( "Argentina" ) ); | 278 | cmbCountry->insertItem( tr ( "Argentina" ) ); |
281 | cmbCountry->insertItem( tr ( "Armenia" ) ); | 279 | cmbCountry->insertItem( tr ( "Armenia" ) ); |
282 | cmbCountry->insertItem( tr ( "Aruba" ) ); | 280 | cmbCountry->insertItem( tr ( "Aruba" ) ); |
283 | cmbCountry->insertItem( tr ( "Australia" ) ); | 281 | cmbCountry->insertItem( tr ( "Australia" ) ); |
284 | cmbCountry->insertItem( tr ( "Austria" ) ); | 282 | cmbCountry->insertItem( tr ( "Austria" ) ); |
285 | cmbCountry->insertItem( tr ( "Azerbaijan" ) ); | 283 | cmbCountry->insertItem( tr ( "Azerbaijan" ) ); |
286 | cmbCountry->insertItem( tr ( "Bahamas" ) ); | 284 | cmbCountry->insertItem( tr ( "Bahamas" ) ); |
287 | cmbCountry->insertItem( tr ( "Bahrain" ) ); | 285 | cmbCountry->insertItem( tr ( "Bahrain" ) ); |
288 | cmbCountry->insertItem( tr ( "Bangladesh" ) ); | 286 | cmbCountry->insertItem( tr ( "Bangladesh" ) ); |
289 | cmbCountry->insertItem( tr ( "Barbados" ) ); | 287 | cmbCountry->insertItem( tr ( "Barbados" ) ); |
290 | cmbCountry->insertItem( tr ( "Belarus" ) ); | 288 | cmbCountry->insertItem( tr ( "Belarus" ) ); |
291 | cmbCountry->insertItem( tr ( "Belgium" ) ); | 289 | cmbCountry->insertItem( tr ( "Belgium" ) ); |
292 | cmbCountry->insertItem( tr ( "Belize" ) ); | 290 | cmbCountry->insertItem( tr ( "Belize" ) ); |
@@ -464,172 +462,172 @@ void ContactEditor::init() { | |||
464 | cmbCountry->insertItem( tr ( "Turkey" ) ); | 462 | cmbCountry->insertItem( tr ( "Turkey" ) ); |
465 | cmbCountry->insertItem( tr ( "Turkmenistan" ) ); | 463 | cmbCountry->insertItem( tr ( "Turkmenistan" ) ); |
466 | cmbCountry->insertItem( tr ( "Tuvalu" ) ); | 464 | cmbCountry->insertItem( tr ( "Tuvalu" ) ); |
467 | cmbCountry->insertItem( tr ( "Uganda" ) ); | 465 | cmbCountry->insertItem( tr ( "Uganda" ) ); |
468 | cmbCountry->insertItem( tr ( "Ukraine" ) ); | 466 | cmbCountry->insertItem( tr ( "Ukraine" ) ); |
469 | cmbCountry->insertItem( tr ( "Uruguay" ) ); | 467 | cmbCountry->insertItem( tr ( "Uruguay" ) ); |
470 | cmbCountry->insertItem( tr ( "Uzbekistan" ) ); | 468 | cmbCountry->insertItem( tr ( "Uzbekistan" ) ); |
471 | cmbCountry->insertItem( tr ( "Vanuatu" ) ); | 469 | cmbCountry->insertItem( tr ( "Vanuatu" ) ); |
472 | cmbCountry->insertItem( tr ( "Venezuela" ) ); | 470 | cmbCountry->insertItem( tr ( "Venezuela" ) ); |
473 | cmbCountry->insertItem( tr ( "Vietnam" ) ); | 471 | cmbCountry->insertItem( tr ( "Vietnam" ) ); |
474 | cmbCountry->insertItem( tr ( "Virgin Islands" ) ); | 472 | cmbCountry->insertItem( tr ( "Virgin Islands" ) ); |
475 | cmbCountry->insertItem( tr ( "Western Sahara" ) ); | 473 | cmbCountry->insertItem( tr ( "Western Sahara" ) ); |
476 | cmbCountry->insertItem( tr ( "Yemen" ) ); | 474 | cmbCountry->insertItem( tr ( "Yemen" ) ); |
477 | cmbCountry->insertItem( tr ( "Yugoslavia" ) ); | 475 | cmbCountry->insertItem( tr ( "Yugoslavia" ) ); |
478 | cmbCountry->insertItem( tr ( "Zambia" ) ); | 476 | cmbCountry->insertItem( tr ( "Zambia" ) ); |
479 | cmbCountry->insertItem( tr ( "Zimbabwe" ) ); | 477 | cmbCountry->insertItem( tr ( "Zimbabwe" ) ); |
480 | if (cmbCountry->listBox()!=0) | 478 | if (cmbCountry->listBox()!=0) |
481 | cmbCountry->listBox()->sort(); | 479 | cmbCountry->listBox()->sort(); |
482 | 480 | ||
483 | cmbCountry->setMaximumWidth( 135 ); | 481 | cmbCountry->setMaximumWidth( 135 ); |
484 | 482 | ||
485 | gl->addMultiCellWidget( cmbCountry, 5, 5, 1, 2 ); | 483 | gl->addMultiCellWidget( cmbCountry, 5, 5, 1, 2 ); |
486 | 484 | ||
487 | // Chooser 4 | 485 | // Chooser 4 |
488 | cmbChooserField4 = new QComboBox( FALSE, container ); | 486 | cmbChooserField4 = new QComboBox( false, container ); |
489 | cmbChooserField4->setMaximumWidth( 90 ); | 487 | cmbChooserField4->setMaximumWidth( 90 ); |
490 | gl->addWidget( cmbChooserField4, 6, 0 ); | 488 | gl->addWidget( cmbChooserField4, 6, 0 ); |
491 | // Textfield for chooser 2 | 489 | // Textfield for chooser 2 |
492 | // Now use WidgetStack to contain the textfield and the default-email combo! | 490 | // Now use WidgetStack to contain the textfield and the default-email combo! |
493 | m_widgetStack4 = new QWidgetStack( container ); | 491 | m_widgetStack4 = new QWidgetStack( container ); |
494 | txtChooserField4 = new QLineEdit( m_widgetStack4 ); | 492 | txtChooserField4 = new QLineEdit( m_widgetStack4 ); |
495 | m_widgetStack4 -> addWidget( txtChooserField4, TextField ); | 493 | m_widgetStack4 -> addWidget( txtChooserField4, TextField ); |
496 | gl->addMultiCellWidget( m_widgetStack4, 6, 6, 1, 2 ); | 494 | gl->addMultiCellWidget( m_widgetStack4, 6, 6, 1, 2 ); |
497 | m_widgetStack4 -> raiseWidget( TextField ); | 495 | m_widgetStack4 -> raiseWidget( TextField ); |
498 | 496 | ||
499 | QSpacerItem *space = new QSpacerItem(1,1, | 497 | QSpacerItem *space = new QSpacerItem(1,1, |
500 | QSizePolicy::Maximum, | 498 | QSizePolicy::Maximum, |
501 | QSizePolicy::MinimumExpanding ); | 499 | QSizePolicy::MinimumExpanding ); |
502 | gl->addItem( space, 7, 0 ); | 500 | gl->addItem( space, 7, 0 ); |
503 | 501 | ||
504 | tabMain->insertTab( tabViewport, tr( "Address" ) ); | 502 | tabMain->addTab( tabViewport, "home", tr( "Address" ) ); |
505 | 503 | ||
506 | tabViewport = new QWidget ( tabMain ); | 504 | tabViewport = new QWidget ( tabMain ); |
507 | 505 | ||
508 | vb = new QVBoxLayout( tabViewport ); | 506 | vb = new QVBoxLayout( tabViewport ); |
509 | 507 | ||
510 | svDetails = new QScrollView( tabViewport ); | 508 | svDetails = new QScrollView( tabViewport ); |
511 | vb->addWidget( svDetails, 0, 0 ); | 509 | vb->addWidget( svDetails, 0, 0 ); |
512 | svDetails->setResizePolicy( QScrollView::AutoOneFit ); | 510 | svDetails->setResizePolicy( QScrollView::AutoOneFit ); |
513 | svDetails->setFrameStyle( QFrame::NoFrame ); | 511 | svDetails->setFrameStyle( QFrame::NoFrame ); |
514 | 512 | ||
515 | container = new QWidget( svDetails->viewport() ); | 513 | container = new QWidget( svDetails->viewport() ); |
516 | svDetails->addChild( container ); | 514 | svDetails->addChild( container ); |
517 | 515 | ||
518 | gl = new QGridLayout( container, 1, 2, 2, 4 ); | 516 | gl = new QGridLayout( container, 1, 2, 2, 4 ); |
519 | 517 | ||
520 | int counter = 0; | 518 | int counter = 0; |
521 | 519 | ||
522 | // Birthday | 520 | // Birthday |
523 | QHBox* hBox = new QHBox( container ); | 521 | QHBox* hBox = new QHBox( container ); |
524 | l = new QLabel( tr("Birthday"), container ); | 522 | l = new QLabel( tr("Birthday"), container ); |
525 | gl->addWidget( l, counter, 0 ); | 523 | gl->addWidget( l, counter, 0 ); |
526 | 524 | ||
527 | QPopupMenu* m1 = new QPopupMenu( container ); | 525 | QPopupMenu* m1 = new QPopupMenu( container ); |
528 | birthdayPicker = new DateBookMonth( m1, 0, TRUE ); | 526 | birthdayPicker = new DateBookMonth( m1, 0, true ); |
529 | m1->insertItem( birthdayPicker ); | 527 | m1->insertItem( birthdayPicker ); |
530 | 528 | ||
531 | birthdayButton= new QToolButton( hBox, "buttonStart" ); | 529 | birthdayButton= new QToolButton( hBox, "buttonStart" ); |
532 | birthdayButton->setPopup( m1 ); | 530 | birthdayButton->setPopup( m1 ); |
533 | birthdayButton->setPopupDelay(0); | 531 | birthdayButton->setPopupDelay(0); |
534 | 532 | ||
535 | QPushButton* deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), | 533 | QPushButton* deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), |
536 | tr( "Delete" ), | 534 | tr( "Delete" ), |
537 | hBox, 0 ); | 535 | hBox, 0 ); |
538 | 536 | ||
539 | gl->addWidget( hBox, counter , 1 ); | 537 | gl->addWidget( hBox, counter , 1 ); |
540 | 538 | ||
541 | connect( birthdayPicker, SIGNAL( dateClicked(int,int,int) ), | 539 | connect( birthdayPicker, SIGNAL( dateClicked(int,int,int) ), |
542 | this, SLOT( slotBirthdayDateChanged(int,int,int) ) ); | 540 | this, SLOT( slotBirthdayDateChanged(int,int,int) ) ); |
543 | connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveBirthday() ) ); | 541 | connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveBirthday() ) ); |
544 | 542 | ||
545 | ++counter; | 543 | ++counter; |
546 | 544 | ||
547 | // Anniversary | 545 | // Anniversary |
548 | hBox = new QHBox( container ); | 546 | hBox = new QHBox( container ); |
549 | l = new QLabel( tr("Anniversary"), container ); | 547 | l = new QLabel( tr("Anniversary"), container ); |
550 | gl->addWidget( l, counter, 0 ); | 548 | gl->addWidget( l, counter, 0 ); |
551 | 549 | ||
552 | m1 = new QPopupMenu( container ); | 550 | m1 = new QPopupMenu( container ); |
553 | anniversaryPicker = new DateBookMonth( m1, 0, TRUE ); | 551 | anniversaryPicker = new DateBookMonth( m1, 0, true ); |
554 | m1->insertItem( anniversaryPicker ); | 552 | m1->insertItem( anniversaryPicker ); |
555 | 553 | ||
556 | anniversaryButton= new QToolButton( hBox, "buttonStart" ); | 554 | anniversaryButton= new QToolButton( hBox, "buttonStart" ); |
557 | anniversaryButton->setPopup( m1 ); | 555 | anniversaryButton->setPopup( m1 ); |
558 | anniversaryButton->setPopupDelay(0); | 556 | anniversaryButton->setPopupDelay(0); |
559 | 557 | ||
560 | deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), | 558 | deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), |
561 | tr( "Delete" ), | 559 | tr( "Delete" ), |
562 | hBox, 0 ); | 560 | hBox, 0 ); |
563 | gl->addWidget( hBox, counter , 1 ); | 561 | gl->addWidget( hBox, counter , 1 ); |
564 | 562 | ||
565 | connect( anniversaryPicker, SIGNAL( dateClicked(int,int,int) ), | 563 | connect( anniversaryPicker, SIGNAL( dateClicked(int,int,int) ), |
566 | this, SLOT( slotAnniversaryDateChanged(int,int,int) ) ); | 564 | this, SLOT( slotAnniversaryDateChanged(int,int,int) ) ); |
567 | connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveAnniversary() ) ); | 565 | connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveAnniversary() ) ); |
568 | 566 | ||
569 | ++counter; | 567 | ++counter; |
570 | 568 | ||
571 | // Gender | 569 | // Gender |
572 | l = new QLabel( tr("Gender"), container ); | 570 | l = new QLabel( tr("Gender"), container ); |
573 | gl->addWidget( l, counter, 0 ); | 571 | gl->addWidget( l, counter, 0 ); |
574 | cmbGender = new QComboBox( container ); | 572 | cmbGender = new QComboBox( container ); |
575 | cmbGender->insertItem( "", 0 ); | 573 | cmbGender->insertItem( "", 0 ); |
576 | cmbGender->insertItem( tr("Male"), 1); | 574 | cmbGender->insertItem( tr("Male"), 1); |
577 | cmbGender->insertItem( tr("Female"), 2); | 575 | cmbGender->insertItem( tr("Female"), 2); |
578 | gl->addWidget( cmbGender, counter, 1 ); | 576 | gl->addWidget( cmbGender, counter, 1 ); |
579 | 577 | ||
580 | ++counter; | 578 | ++counter; |
581 | 579 | ||
582 | // Create Labels and lineedit fields for every dynamic entry | 580 | // Create Labels and lineedit fields for every dynamic entry |
583 | QStringList::ConstIterator it = slDynamicEntries.begin(); | 581 | QStringList::ConstIterator it = slDynamicEntries.begin(); |
584 | QMap<QString, int> mapStrToID = Opie::OPimContactFields::untrFieldsToId(); | 582 | QMap<QString, int> mapStrToID = Opie::OPimContactFields::untrFieldsToId(); |
585 | QMap<int, QString> mapIdToStr = Opie::OPimContactFields::idToTrFields(); | 583 | QMap<int, QString> mapIdToStr = Opie::OPimContactFields::idToTrFields(); |
586 | for (i = counter; it != slDynamicEntries.end(); i++, ++it ) { | 584 | for (i = counter; it != slDynamicEntries.end(); i++, ++it ) { |
587 | 585 | ||
588 | if (((*it) == "Anniversary") || | 586 | if (((*it) == "Anniversary") || |
589 | ((*it) == "Birthday")|| ((*it) == "Gender")) continue; | 587 | ((*it) == "Birthday")|| ((*it) == "Gender")) continue; |
590 | 588 | ||
591 | l = new QLabel( mapIdToStr[mapStrToID[*it]], container ); | 589 | l = new QLabel( mapIdToStr[mapStrToID[*it]], container ); |
592 | listName.append( l ); | 590 | listName.append( l ); |
593 | gl->addWidget( l, i, 0 ); | 591 | gl->addWidget( l, i, 0 ); |
594 | QLineEdit *e = new QLineEdit( container ); | 592 | QLineEdit *e = new QLineEdit( container ); |
595 | listValue.append( e ); | 593 | listValue.append( e ); |
596 | gl->addWidget( e, i, 1); | 594 | gl->addWidget( e, i, 1); |
597 | } | 595 | } |
598 | // Fill labels with names.. | 596 | // Fill labels with names.. |
599 | //loadFields(); | 597 | //loadFields(); |
600 | 598 | ||
601 | 599 | ||
602 | tabMain->insertTab( tabViewport, tr( "Details" ) ); | 600 | tabMain->addTab( tabViewport, "UtilsIcon", tr( "Details" ) ); |
603 | 601 | ||
604 | dlgNote = new QDialog( this, "Note Dialog", TRUE ); | 602 | dlgNote = new QDialog( this, "Note Dialog", true ); |
605 | dlgNote->setCaption( tr("Enter Note") ); | 603 | dlgNote->setCaption( tr("Enter Note") ); |
606 | QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); | 604 | QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); |
607 | txtNote = new QMultiLineEdit( dlgNote ); | 605 | txtNote = new QMultiLineEdit( dlgNote ); |
608 | vbNote->addWidget( txtNote ); | 606 | vbNote->addWidget( txtNote ); |
609 | connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) ); | 607 | connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) ); |
610 | 608 | ||
611 | dlgName = new QDialog( this, "Name Dialog", TRUE ); | 609 | dlgName = new QDialog( this, "Name Dialog", true ); |
612 | dlgName->setCaption( tr("Edit Name") ); | 610 | dlgName->setCaption( tr("Edit Name") ); |
613 | gl = new QGridLayout( dlgName, 5, 2, 2, 3 ); | 611 | gl = new QGridLayout( dlgName, 5, 2, 2, 3 ); |
614 | 612 | ||
615 | l = new QLabel( tr("First Name"), dlgName ); | 613 | l = new QLabel( tr("First Name"), dlgName ); |
616 | gl->addWidget( l, 0, 0 ); | 614 | gl->addWidget( l, 0, 0 ); |
617 | txtFirstName = new ABOOK::NameLineEdit( dlgName ); | 615 | txtFirstName = new ABOOK::NameLineEdit( dlgName ); |
618 | gl->addWidget( txtFirstName, 0, 1 ); | 616 | gl->addWidget( txtFirstName, 0, 1 ); |
619 | 617 | ||
620 | l = new QLabel( tr("Middle Name"), dlgName ); | 618 | l = new QLabel( tr("Middle Name"), dlgName ); |
621 | gl->addWidget( l, 1, 0 ); | 619 | gl->addWidget( l, 1, 0 ); |
622 | txtMiddleName = new ABOOK::NameLineEdit( dlgName ); | 620 | txtMiddleName = new ABOOK::NameLineEdit( dlgName ); |
623 | gl->addWidget( txtMiddleName, 1, 1 ); | 621 | gl->addWidget( txtMiddleName, 1, 1 ); |
624 | 622 | ||
625 | l = new QLabel( tr("Last Name"), dlgName ); | 623 | l = new QLabel( tr("Last Name"), dlgName ); |
626 | gl->addWidget( l, 2, 0 ); | 624 | gl->addWidget( l, 2, 0 ); |
627 | txtLastName = new ABOOK::NameLineEdit( dlgName ); | 625 | txtLastName = new ABOOK::NameLineEdit( dlgName ); |
628 | gl->addWidget( txtLastName, 2, 1 ); | 626 | gl->addWidget( txtLastName, 2, 1 ); |
629 | 627 | ||
630 | // l = new QLabel( tr("Suffix"), dlgName ); | 628 | // l = new QLabel( tr("Suffix"), dlgName ); |
631 | // gl->addWidget( l, 3, 0 ); | 629 | // gl->addWidget( l, 3, 0 ); |
632 | // txtSuffix = new QLineEdit( dlgName ); | 630 | // txtSuffix = new QLineEdit( dlgName ); |
633 | // gl->addWidget( txtSuffix, 3, 1 ); | 631 | // gl->addWidget( txtSuffix, 3, 1 ); |
634 | space = new QSpacerItem(1,1, | 632 | space = new QSpacerItem(1,1, |
635 | QSizePolicy::Maximum, | 633 | QSizePolicy::Maximum, |
@@ -1072,94 +1070,94 @@ void ContactEditor::accept() { | |||
1072 | saveEntry(); | 1070 | saveEntry(); |
1073 | cleanupFields(); | 1071 | cleanupFields(); |
1074 | QDialog::accept(); | 1072 | QDialog::accept(); |
1075 | } | 1073 | } |
1076 | 1074 | ||
1077 | } | 1075 | } |
1078 | 1076 | ||
1079 | void ContactEditor::slotNote() { | 1077 | void ContactEditor::slotNote() { |
1080 | 1078 | ||
1081 | if ( ! QPEApplication::execDialog( dlgNote ) ) { | 1079 | if ( ! QPEApplication::execDialog( dlgNote ) ) { |
1082 | txtNote->setText( ent.notes() ); | 1080 | txtNote->setText( ent.notes() ); |
1083 | } | 1081 | } |
1084 | } | 1082 | } |
1085 | 1083 | ||
1086 | void ContactEditor::slotName() { | 1084 | void ContactEditor::slotName() { |
1087 | 1085 | ||
1088 | QString tmpName; | 1086 | QString tmpName; |
1089 | 1087 | ||
1090 | txtFirstName->setText( parseName(txtFullName->text(), NAME_F) ); | 1088 | txtFirstName->setText( parseName(txtFullName->text(), NAME_F) ); |
1091 | txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) ); | 1089 | txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) ); |
1092 | txtLastName->setText( parseName(txtFullName->text(), NAME_L) ); | 1090 | txtLastName->setText( parseName(txtFullName->text(), NAME_L) ); |
1093 | // txtSuffix->setText( parseName(txtFullName->text(), NAME_S) ); | 1091 | // txtSuffix->setText( parseName(txtFullName->text(), NAME_S) ); |
1094 | 1092 | ||
1095 | if ( QPEApplication::execDialog( dlgName ) ) { | 1093 | if ( QPEApplication::execDialog( dlgName ) ) { |
1096 | if ( txtLastName->text().contains( ' ', TRUE ) ) | 1094 | if ( txtLastName->text().contains( ' ', true ) ) |
1097 | tmpName = txtLastName->text() + ", " + txtFirstName->text() + " " + txtMiddleName->text(); | 1095 | tmpName = txtLastName->text() + ", " + txtFirstName->text() + " " + txtMiddleName->text(); |
1098 | else | 1096 | else |
1099 | tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text(); | 1097 | tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text(); |
1100 | 1098 | ||
1101 | txtFullName->setText( tmpName.simplifyWhiteSpace() ); | 1099 | txtFullName->setText( tmpName.simplifyWhiteSpace() ); |
1102 | slotFullNameChange( txtFullName->text() ); | 1100 | slotFullNameChange( txtFullName->text() ); |
1103 | } | 1101 | } |
1104 | 1102 | ||
1105 | } | 1103 | } |
1106 | 1104 | ||
1107 | void ContactEditor::setNameFocus() { | 1105 | void ContactEditor::setNameFocus() { |
1108 | 1106 | ||
1109 | txtFullName->setFocus(); | 1107 | txtFullName->setFocus(); |
1110 | 1108 | ||
1111 | } | 1109 | } |
1112 | 1110 | ||
1113 | bool ContactEditor::isEmpty() { | 1111 | bool ContactEditor::isEmpty() { |
1114 | // Test and see if the record should be saved. | 1112 | // Test and see if the record should be saved. |
1115 | // More strict than the original qtopia, needs name or fileas to save | 1113 | // More strict than the original qtopia, needs name or fileas to save |
1116 | 1114 | ||
1117 | QString t = txtFullName->text(); | 1115 | QString t = txtFullName->text(); |
1118 | if ( !t.isEmpty() && containsAlphaNum( t ) ) | 1116 | if ( !t.isEmpty() && containsAlphaNum( t ) ) |
1119 | return false; | 1117 | return false; |
1120 | 1118 | ||
1121 | t = cmbFileAs->currentText(); | 1119 | t = cmbFileAs->currentText(); |
1122 | if ( !t.isEmpty() && containsAlphaNum( t ) ) | 1120 | if ( !t.isEmpty() && containsAlphaNum( t ) ) |
1123 | return false; | 1121 | return false; |
1124 | 1122 | ||
1125 | return true; | 1123 | return true; |
1126 | 1124 | ||
1127 | } | 1125 | } |
1128 | 1126 | ||
1129 | QString ContactEditor::parseName( const QString fullName, int type ) { | 1127 | QString ContactEditor::parseName( const QString fullName, int type ) { |
1130 | 1128 | ||
1131 | QString simplifiedName( fullName.simplifyWhiteSpace() ); | 1129 | QString simplifiedName( fullName.simplifyWhiteSpace() ); |
1132 | QString strFirstName; | 1130 | QString strFirstName; |
1133 | QString strMiddleName; | 1131 | QString strMiddleName; |
1134 | QString strLastName; | 1132 | QString strLastName; |
1135 | QString strTitle; | 1133 | QString strTitle; |
1136 | int commapos; | 1134 | int commapos; |
1137 | bool haveLastName = false; | 1135 | bool haveLastName = false; |
1138 | 1136 | ||
1139 | odebug << "Fullname: " << simplifiedName << oendl; | 1137 | odebug << "Fullname: " << simplifiedName << oendl; |
1140 | 1138 | ||
1141 | commapos = simplifiedName.find( ',', 0, TRUE); | 1139 | commapos = simplifiedName.find( ',', 0, true); |
1142 | if ( commapos >= 0 ) { | 1140 | if ( commapos >= 0 ) { |
1143 | odebug << " Commapos: " << commapos << oendl; | 1141 | odebug << " Commapos: " << commapos << oendl; |
1144 | 1142 | ||
1145 | // A comma (",") separates the lastname from one or | 1143 | // A comma (",") separates the lastname from one or |
1146 | // many first names. Thus, remove the lastname from the | 1144 | // many first names. Thus, remove the lastname from the |
1147 | // String and parse the firstnames. | 1145 | // String and parse the firstnames. |
1148 | 1146 | ||
1149 | strLastName = simplifiedName.left( commapos ); | 1147 | strLastName = simplifiedName.left( commapos ); |
1150 | simplifiedName= simplifiedName.mid( commapos + 1 ); | 1148 | simplifiedName= simplifiedName.mid( commapos + 1 ); |
1151 | haveLastName = true; | 1149 | haveLastName = true; |
1152 | odebug << "Fullname without ',': " << simplifiedName << oendl; | 1150 | odebug << "Fullname without ',': " << simplifiedName << oendl; |
1153 | 1151 | ||
1154 | // If we have any lastname, we should now split all first names. | 1152 | // If we have any lastname, we should now split all first names. |
1155 | // The first one will be the used as first, the rest as "middle names" | 1153 | // The first one will be the used as first, the rest as "middle names" |
1156 | 1154 | ||
1157 | QStringList allFirstNames = QStringList::split(" ", simplifiedName); | 1155 | QStringList allFirstNames = QStringList::split(" ", simplifiedName); |
1158 | QStringList::Iterator it = allFirstNames.begin(); | 1156 | QStringList::Iterator it = allFirstNames.begin(); |
1159 | strFirstName = *it++; | 1157 | strFirstName = *it++; |
1160 | QStringList allSecondNames; | 1158 | QStringList allSecondNames; |
1161 | for ( ; it != allFirstNames.end(); ++it ) | 1159 | for ( ; it != allFirstNames.end(); ++it ) |
1162 | allSecondNames.append( *it ); | 1160 | allSecondNames.append( *it ); |
1163 | 1161 | ||
1164 | strMiddleName = allSecondNames.join(" "); | 1162 | strMiddleName = allSecondNames.join(" "); |
1165 | 1163 | ||
@@ -1241,70 +1239,70 @@ void ContactEditor::cleanupFields() { | |||
1241 | txtNote->setText(""); | 1239 | txtNote->setText(""); |
1242 | txtFullName->setText(""); | 1240 | txtFullName->setText(""); |
1243 | txtJobTitle->setText(""); | 1241 | txtJobTitle->setText(""); |
1244 | txtOrganization->setText(""); | 1242 | txtOrganization->setText(""); |
1245 | txtChooserField1->setText(""); | 1243 | txtChooserField1->setText(""); |
1246 | txtChooserField2->setText(""); | 1244 | txtChooserField2->setText(""); |
1247 | txtChooserField3->setText(""); | 1245 | txtChooserField3->setText(""); |
1248 | txtAddress->setText(""); | 1246 | txtAddress->setText(""); |
1249 | txtCity->setText(""); | 1247 | txtCity->setText(""); |
1250 | txtState->setText(""); | 1248 | txtState->setText(""); |
1251 | txtZip->setText(""); | 1249 | txtZip->setText(""); |
1252 | QLineEdit *txtTmp = cmbCountry->lineEdit(); | 1250 | QLineEdit *txtTmp = cmbCountry->lineEdit(); |
1253 | txtTmp->setText(""); | 1251 | txtTmp->setText(""); |
1254 | txtTmp = cmbFileAs->lineEdit(); | 1252 | txtTmp = cmbFileAs->lineEdit(); |
1255 | txtTmp->setText(""); | 1253 | txtTmp->setText(""); |
1256 | 1254 | ||
1257 | } | 1255 | } |
1258 | 1256 | ||
1259 | void ContactEditor::setEntry( const Opie::OPimContact &entry ) { | 1257 | void ContactEditor::setEntry( const Opie::OPimContact &entry ) { |
1260 | 1258 | ||
1261 | initializing = true; | 1259 | initializing = true; |
1262 | 1260 | ||
1263 | // Cleanup and activate the general Page .. | 1261 | // Cleanup and activate the general Page .. |
1264 | cleanupFields(); | 1262 | cleanupFields(); |
1265 | tabMain->setCurrentPage( 0 ); | 1263 | tabMain->setCurrentTab( m_generalWidget ); |
1266 | 1264 | ||
1267 | ent = entry; | 1265 | ent = entry; |
1268 | 1266 | ||
1269 | emails = QStringList(ent.emailList()); | 1267 | emails = QStringList(ent.emailList()); |
1270 | defaultEmail = ent.defaultEmail(); | 1268 | defaultEmail = ent.defaultEmail(); |
1271 | if (defaultEmail.isEmpty()) defaultEmail = emails[0]; | 1269 | if (defaultEmail.isEmpty()) defaultEmail = emails[0]; |
1272 | odebug << "default email=" << defaultEmail << oendl; | 1270 | odebug << "default email=" << defaultEmail << oendl; |
1273 | 1271 | ||
1274 | txtFirstName->setText( ent.firstName() ); | 1272 | txtFirstName->setText( ent.firstName() ); |
1275 | txtMiddleName->setText( ent.middleName() ); | 1273 | txtMiddleName->setText( ent.middleName() ); |
1276 | txtLastName->setText( ent.lastName() ); | 1274 | txtLastName->setText( ent.lastName() ); |
1277 | txtSuffix->setText( ent.suffix() ); | 1275 | txtSuffix->setText( ent.suffix() ); |
1278 | 1276 | ||
1279 | // QString *tmpString = new QString; | 1277 | // QString *tmpString = new QString; |
1280 | // *tmpString = ent.firstName() + " " + ent.middleName() + | 1278 | // *tmpString = ent.firstName() + " " + ent.middleName() + |
1281 | // + " " + ent.lastName() + " " + ent.suffix(); | 1279 | // + " " + ent.lastName() + " " + ent.suffix(); |
1282 | //txtFullName->setText( tmpString->simplifyWhiteSpace() ); | 1280 | //txtFullName->setText( tmpString->simplifyWhiteSpace() ); |
1283 | 1281 | ||
1284 | if ( !ent.isEmpty() ){ | 1282 | if ( !ent.isEmpty() ){ |
1285 | // Lastnames with multiple words need to be protected by a comma ! | 1283 | // Lastnames with multiple words need to be protected by a comma ! |
1286 | if ( ent.lastName().contains( ' ', TRUE ) ) | 1284 | if ( ent.lastName().contains( ' ', true ) ) |
1287 | txtFullName->setText( ent.lastName() + ", " + ent.firstName() + " " + ent.middleName() ); | 1285 | txtFullName->setText( ent.lastName() + ", " + ent.firstName() + " " + ent.middleName() ); |
1288 | else | 1286 | else |
1289 | txtFullName->setText( ent.firstName() + " " + ent.middleName() + " " + ent.lastName() ); | 1287 | txtFullName->setText( ent.firstName() + " " + ent.middleName() + " " + ent.lastName() ); |
1290 | } | 1288 | } |
1291 | 1289 | ||
1292 | cmbFileAs->setEditText( ent.fileAs() ); | 1290 | cmbFileAs->setEditText( ent.fileAs() ); |
1293 | 1291 | ||
1294 | //if (hasTitle) | 1292 | //if (hasTitle) |
1295 | txtJobTitle->setText( ent.jobTitle() ); | 1293 | txtJobTitle->setText( ent.jobTitle() ); |
1296 | 1294 | ||
1297 | //if (hasCompany) | 1295 | //if (hasCompany) |
1298 | txtOrganization->setText( ent.company() ); | 1296 | txtOrganization->setText( ent.company() ); |
1299 | 1297 | ||
1300 | //if (hasNotes) | 1298 | //if (hasNotes) |
1301 | txtNote->setText( ent.notes() ); | 1299 | txtNote->setText( ent.notes() ); |
1302 | 1300 | ||
1303 | //if (hasStreet) { | 1301 | //if (hasStreet) { |
1304 | slHomeAddress[0] = ent.homeStreet(); | 1302 | slHomeAddress[0] = ent.homeStreet(); |
1305 | slBusinessAddress[0] = ent.businessStreet(); | 1303 | slBusinessAddress[0] = ent.businessStreet(); |
1306 | //} | 1304 | //} |
1307 | 1305 | ||
1308 | //if (hasCity) { | 1306 | //if (hasCity) { |
1309 | slHomeAddress[3] = ent.homeCity(); | 1307 | slHomeAddress[3] = ent.homeCity(); |
1310 | slBusinessAddress[3] = ent.businessCity(); | 1308 | slBusinessAddress[3] = ent.businessCity(); |
@@ -1666,60 +1664,60 @@ void parseEmailTo( const QString &strDefaultEmail, | |||
1666 | strBack = strDefaultEmail; | 1664 | strBack = strDefaultEmail; |
1667 | where = 0; | 1665 | where = 0; |
1668 | while ( where > -1 ) { | 1666 | while ( where > -1 ) { |
1669 | start = where; | 1667 | start = where; |
1670 | where = strOtherEmail.find( ' ', where + 1 ); | 1668 | where = strOtherEmail.find( ' ', where + 1 ); |
1671 | if ( where > 0 ) { | 1669 | if ( where > 0 ) { |
1672 | strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace(); | 1670 | strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace(); |
1673 | } else | 1671 | } else |
1674 | strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace(); | 1672 | strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace(); |
1675 | if ( foundDefault || strTmp != strDefaultEmail ) { | 1673 | if ( foundDefault || strTmp != strDefaultEmail ) { |
1676 | strBack.append( ", " ); | 1674 | strBack.append( ", " ); |
1677 | strBack.append( strTmp ); | 1675 | strBack.append( strTmp ); |
1678 | } else | 1676 | } else |
1679 | foundDefault = true; | 1677 | foundDefault = true; |
1680 | } | 1678 | } |
1681 | } | 1679 | } |
1682 | 1680 | ||
1683 | 1681 | ||
1684 | static inline bool containsAlphaNum( const QString &str ) | 1682 | static inline bool containsAlphaNum( const QString &str ) |
1685 | { | 1683 | { |
1686 | int i, | 1684 | int i, |
1687 | count = str.length(); | 1685 | count = str.length(); |
1688 | for ( i = 0; i < count; i++ ) | 1686 | for ( i = 0; i < count; i++ ) |
1689 | if ( !str[i].isSpace() ) | 1687 | if ( !str[i].isSpace() ) |
1690 | return TRUE; | 1688 | return true; |
1691 | return FALSE; | 1689 | return false; |
1692 | } | 1690 | } |
1693 | 1691 | ||
1694 | static inline bool constainsWhiteSpace( const QString &str ) | 1692 | static inline bool constainsWhiteSpace( const QString &str ) |
1695 | { | 1693 | { |
1696 | int i, | 1694 | int i, |
1697 | count = str.length(); | 1695 | count = str.length(); |
1698 | for (i = 0; i < count; i++ ) | 1696 | for (i = 0; i < count; i++ ) |
1699 | if ( str[i].isSpace() ) | 1697 | if ( str[i].isSpace() ) |
1700 | return TRUE; | 1698 | return true; |
1701 | return FALSE; | 1699 | return false; |
1702 | } | 1700 | } |
1703 | 1701 | ||
1704 | void ContactEditor::setPersonalView( bool personal ) | 1702 | void ContactEditor::setPersonalView( bool personal ) |
1705 | { | 1703 | { |
1706 | m_personalView = personal; | 1704 | m_personalView = personal; |
1707 | 1705 | ||
1708 | // Currently disbled due to the fact that | 1706 | // Currently disbled due to the fact that |
1709 | // show will not work... | 1707 | // show will not work... |
1710 | return; | 1708 | return; |
1711 | 1709 | ||
1712 | if ( personal ){ | 1710 | if ( personal ){ |
1713 | cmbCat->hide(); | 1711 | cmbCat->hide(); |
1714 | labCat->hide(); | 1712 | labCat->hide(); |
1715 | 1713 | ||
1716 | } else{ | 1714 | } else{ |
1717 | cmbCat->show(); | 1715 | cmbCat->show(); |
1718 | labCat->show(); | 1716 | labCat->show(); |
1719 | } | 1717 | } |
1720 | } | 1718 | } |
1721 | 1719 | ||
1722 | void ContactEditor::slotAnniversaryDateChanged( int year, int month, int day) | 1720 | void ContactEditor::slotAnniversaryDateChanged( int year, int month, int day) |
1723 | { | 1721 | { |
1724 | QDate date; | 1722 | QDate date; |
1725 | date.setYMD( year, month, day ); | 1723 | date.setYMD( year, month, day ); |