summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/TODO16
-rw-r--r--core/pim/addressbook/abtable.cpp40
-rw-r--r--core/pim/addressbook/abview.cpp48
-rw-r--r--core/pim/addressbook/contacteditor.cpp75
-rw-r--r--core/pim/addressbook/contacteditor.h5
-rw-r--r--core/pim/addressbook/ocontactfields.cpp101
-rw-r--r--core/pim/addressbook/ocontactfields.h34
-rw-r--r--core/pim/addressbook/version.h4
8 files changed, 251 insertions, 72 deletions
diff --git a/core/pim/addressbook/TODO b/core/pim/addressbook/TODO
index 76247c1..c600d20 100644
--- a/core/pim/addressbook/TODO
+++ b/core/pim/addressbook/TODO
@@ -1,112 +1,114 @@
1Stuff todo until OPIE 1.0 : 1Stuff todo until OPIE 1.0 :
2=========================== 2===========================
3 3
4Feature requests: 4Feature requests:
5----------------- 5-----------------
6- Dial by mobile phone by tapping the number.. 6- Dial by mobile phone by tapping the number..
7 (Maybe using gsmtool. And we may 7 (Maybe using gsmtool. And we may
8 add a library class for this) 8 add a library class for this)
9- dial with dtmfdial incase it's installed and there's no mobile 9- dial with dtmfdial in case it's installed and there's no mobile
10- 3rd column for 2. Contact 10- 3rd column for 2. Contact
11- Implementing additional Views (Phonebook, ...) 11- Implementing additional Views (Phonebook, ...)
12- Birthday & Anniversary Reminder 12- Birthday & Anniversary Reminder
13- Plugin for Today for Birthdays and Anniversaries
14- Beaming of multiple contacts (current list/ by search or by category) 13- Beaming of multiple contacts (current list/ by search or by category)
14- Configure the letter-picker: lastname/fullname search
15 15
16Known Bugs: 16Known Bugs:
17----------- 17-----------
18 18- Email-button: A lot of problems.. :(
19- Default Email-Button: Sometimes not hiding the textfields completely
19 20
20Bugs but not in addressbook: 21Bugs but not in addressbook:
21----------------------------- 22-----------------------------
22- VCARD: If umlaut (äöüß) in address, the parser gets confused.. 23- VCARD: If umlaut (äöüß) in address, the parser gets confused..
23 24
24- Exporting and reimporting of Jobtitle was reported to fail (Could not reproduce this ! (se)) 25- Exporting and reimporting of Jobtitle was reported to fail (Could not reproduce this ! (se))
25 26
26 27
27Urgent: 28Urgent:
28-------- 29--------
29ContactEditor: 30ContactEditor:
30- Contact-Editor is temporarely reenabled. Wait for replacement. 31- Contact-Editor is temporarely reenabled. Wait for replacement.
31- Redesign of Contacteditor 32- Redesign of Contacteditor
32- Store last settings of combo-boxes
33- Category is on the wrong position after changing to personal and back to normal 33- Category is on the wrong position after changing to personal and back to normal
34 ( Temporarily workaround: Category is never deactivated.. :S ) 34 ( Temporarily workaround: Category is never deactivated.. :S )
35 35
36- Personal and Business Web-page is not editable 36- Personal and Business Web-page is not editable
37 37
38Important: 38Important:
39---------- 39----------
40 40
41- If new contact is added (contacteditor closed): focus (table, card) to 41- If new contact is added (contacteditor closed): focus (table, card) to
42 this entry ! 42 this entry !
43- Implement a picker/combo for the default email.
44- After search (Started with Return): KeyFocus should be on Tabelle 43- After search (Started with Return): KeyFocus should be on Tabelle
45 44
46- "What's this" should be added (Deleyed after Feature Freeze) 45- "What's this" should be added (Deleyed after Feature Freeze)
47 46
48Less important: 47Less important:
49--------------- 48---------------
50- Reload if contacts were changed externally 49- Reload if contacts were changed externally
51- Overview window cleanup needed..
52- The picker (alphabetical sort widget) should be 50- The picker (alphabetical sort widget) should be
53 placed verticaly or horizontally (configurable) 51 placed verticaly or horizontally (configurable)
54- Find a smart solution for activating/deactivating the "send email" event 52- Find a smart solution for activating/deactivating the "send email" event
55 53
56Should be Fixed (not absolute sure, need further validation): 54Should be Fixed (not absolute sure, need further validation):
57------------------------------------------------------------- 55-------------------------------------------------------------
58 56
59 57
60Fixed: 58Fixed/Ready:
61------- 59-------
62- Syncing: abtable not reloaded after sync. 60- Syncing: abtable not reloaded after sync.
63- Find widget should be replaced by something like 61- Find widget should be replaced by something like
64 qpdf has. 62 qpdf has.
65- Adding a configuration dialog 63- Adding a configuration dialog
66- Picker: Activated letter schould be more visible 64- Picker: Activated letter schould be more visible
67- Advanced handling of cursor keys (search..) 65- Advanced handling of cursor keys (search..)
68- Mail-Icon is missing 66- Mail-Icon is missing
69- Use opie-mail insted of qt-mail if possible. 67- Use opie-mail insted of qt-mail if possible.
70- Font menu is invisible using german translation 68- Font menu is invisible using german translation
71- Personal contact editor: Disable categories 69- Personal contact editor: Disable categories
72- "Nonenglish" translation bug has to be fixed. 70- "Nonenglish" translation bug has to be fixed.
73- contacteditor: Birthday, annyversary, ... : Use Dateselector 71- contacteditor: Birthday, annyversary, ... : Use Dateselector
74- The names of the countries are sorted by there english names, only.. 72- The names of the countries are sorted by there english names, only..
75 Even if they are translated.. :S 73 Even if they are translated.. :S
76- Cursor keys should work in detail-view (ablabel) 74- Cursor keys should work in detail-view (ablabel)
77 -> Ablabel should be removed and Abtable should be increased with 75 -> Ablabel should be removed and Abtable should be increased with
78 different views (as started by darwin zins).. 76 different views (as started by darwin zins)..
79- Use advanced database functions in abtable to decrease 77- Use advanced database functions in abtable to decrease
80 memory footprint and to make everything more easy ! 78 memory footprint and to make everything more easy !
81 (abtable should store Iterator for selected Category) 79 (abtable should store Iterator for selected Category)
82- Abtable: Configure Contact column (internally already available, 80- Abtable: Configure Contact column (internally already available,
83 need configuration) 81 need configuration)
84- Select of primary contact (see #274 on mantis) 82- Select of primary contact (see #274 on mantis)
85- Category-select does not work completely: "Unfiled" is always in listview .. 83- Category-select does not work completely: "Unfiled" is always in listview ..
86- Return from Contacteditor: Category resettet to all 84- Return from Contacteditor: Category resettet to all
87- Personal Details not working 85- Personal Details not working
88- If category changed, the letterpicker should be resetted 86- If category changed, the letterpicker should be resetted
89- There should be some icons for List and Cardview 87- There should be some icons for List and Cardview
90- If in Cardview and a category change removes all entries: 88- If in Cardview and a category change removes all entries:
91 There are already entries in Cardview after up/down 89 There are already entries in Cardview after up/down
92- Personal Details: Anniversary zeigt Fantasie-Werte 90- Personal Details: Anniversary zeigt Fantasie-Werte
93- Unfiled shown just in Category "All" and "Unfiled". 91- Unfiled shown just in Category "All" and "Unfiled".
94- After finising search and after Edit: Clear Picker 92- After finising search and after Edit: Clear Picker
95- After Edit: Table position back to edited entry. 93- After Edit: Table position back to edited entry.
96- Optimize Table Update... 94- Optimize Table Update...
97- Change MyDialog to Config 95- Change MyDialog to Config
98- Store position and state of toolbar 96- Store position and state of toolbar
99- Searchwidget closed: Selected user is jumping 97- Searchwidget closed: Selected user is jumping
100- Wenn suchen beendet, dann dauert das Tabellenupdate (was überhaupt überflüssig ist) 98- Wenn suchen beendet, dann dauert das Tabellenupdate (was überhaupt überflüssig ist)
101 zu lange.. 99 zu lange..
102- VCARD: Import of Anniversary does not work correctly (currently disabled) 100- VCARD: Import of Anniversary does not work correctly (currently disabled)
103- Name order selected in "contacteditor" not used in list view. 101- Name order selected in "contacteditor" not used in list view.
104- OK-Key does not switch from Detailview (ablable) to Listview 102- OK-Key does not switch from Detailview (ablable) to Listview
105- Receiving of beams should open a dialog 103- Receiving of beams should open a dialog
106- Fix start of opie-mail 104- Fix start of opie-mail
107- Implement Button Pics 105- Implement Button Pics
108- Add a dialog to accept and optionally edit received contacts by IRDA. 106- Add a dialog to accept and optionally edit received contacts by IRDA.
109- Language not English (tested with german opie-translation): 107- Language not English (tested with german opie-translation):
110 1. Configure nicht übersetzt (alles leer). 108 1. Configure nicht übersetzt (alles leer).
111 2. Contacteditor nur teilweise übersetzt. 109 2. Contacteditor nur teilweise übersetzt.
112 3. Kategorie-Picker geht nicht. 110 3. Kategorie-Picker geht nicht.
111- Plugin for Today for Birthdays and Anniversaries
112- Implement a picker/combo for the default email.
113- Overview window cleanup needed..
114- Store last settings of combo-boxes
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp
index 00335ae..aec390d 100644
--- a/core/pim/addressbook/abtable.cpp
+++ b/core/pim/addressbook/abtable.cpp
@@ -1,747 +1,747 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de) 3** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de)
4** 4**
5** This file is part of Qt Palmtop Environment. 5** This file is part of Qt 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 9** Foundation and appearing in the file LICENSE.GPL included in the
10** packaging of this file. 10** packaging 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** See http://www.trolltech.com/gpl/ for GPL licensing information. 15** See http://www.trolltech.com/gpl/ for GPL licensing information.
16** 16**
17** Contact info@trolltech.com if any conditions of this licensing are 17** Contact info@trolltech.com if any conditions of this licensing are
18** not clear to you. 18** not clear to you.
19** 19**
20**********************************************************************/ 20**********************************************************************/
21 21
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#include <qpe/timestring.h>
28 28
29#include <opie/orecordlist.h> 29#include <opie/orecordlist.h>
30 30
31#include <qasciidict.h> 31#include <qasciidict.h>
32#include <qdatetime.h> 32#include <qdatetime.h>
33#include <qfile.h> 33#include <qfile.h>
34#include <qregexp.h> 34#include <qregexp.h>
35#include <qmessagebox.h> 35#include <qmessagebox.h>
36 36
37#include "abtable.h" 37#include "abtable.h"
38 38
39#include <errno.h> 39#include <errno.h>
40#include <fcntl.h> 40#include <fcntl.h>
41#include <unistd.h> 41#include <unistd.h>
42#include <stdlib.h> 42#include <stdlib.h>
43 43
44#include <ctype.h> //toupper() for key hack 44#include <ctype.h> //toupper() for key hack
45 45
46/*! 46/*!
47 \class AbTableItem abtable.h 47 \class AbTableItem abtable.h
48 48
49 \brief QTableItem based class for showing a field of an entry 49 \brief QTableItem based class for showing a field of an entry
50*/ 50*/
51 51
52AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s, 52AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s,
53 const QString &secondSortKey) 53 const QString &secondSortKey)
54 : QTableItem( t, et, s ) 54 : QTableItem( t, et, s )
55{ 55{
56 // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower(); 56 // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower();
57 sortKey = Qtopia::buildSortKey( s, secondSortKey ); 57 sortKey = Qtopia::buildSortKey( s, secondSortKey );
58} 58}
59 59
60int AbTableItem::alignment() const 60int AbTableItem::alignment() const
61{ 61{
62 return AlignLeft|AlignVCenter; 62 return AlignLeft|AlignVCenter;
63} 63}
64 64
65QString AbTableItem::key() const 65QString AbTableItem::key() const
66{ 66{
67 return sortKey; 67 return sortKey;
68} 68}
69 69
70// A way to reset the item, without out doing a delete or a new... 70// A way to reset the item, without out doing a delete or a new...
71void AbTableItem::setItem( const QString &txt, const QString &secondKey ) 71void AbTableItem::setItem( const QString &txt, const QString &secondKey )
72{ 72{
73 setText( txt ); 73 setText( txt );
74 sortKey = Qtopia::buildSortKey( txt, secondKey ); 74 sortKey = Qtopia::buildSortKey( txt, secondKey );
75 75
76 // sortKey = txt.lower() + QChar( '\0' ) + secondKey.lower(); 76 // sortKey = txt.lower() + QChar( '\0' ) + secondKey.lower();
77} 77}
78 78
79/*! 79/*!
80 \class AbPickItem abtable.h 80 \class AbPickItem abtable.h
81 81
82 \brief QTableItem based class for showing slection of an entry 82 \brief QTableItem based class for showing slection of an entry
83*/ 83*/
84 84
85AbPickItem::AbPickItem( QTable *t ) : 85AbPickItem::AbPickItem( QTable *t ) :
86 QTableItem(t, WhenCurrent, "?") 86 QTableItem(t, WhenCurrent, "?")
87{ 87{
88} 88}
89 89
90QWidget *AbPickItem::createEditor() const 90QWidget *AbPickItem::createEditor() const
91{ 91{
92 QComboBox* combo = new QComboBox( table()->viewport() ); 92 QComboBox* combo = new QComboBox( table()->viewport() );
93 ( (AbPickItem*)this )->cb = combo; 93 ( (AbPickItem*)this )->cb = combo;
94 AbTable* t = static_cast<AbTable*>(table()); 94 AbTable* t = static_cast<AbTable*>(table());
95 QStringList c = t->choiceNames(); 95 QStringList c = t->choiceNames();
96 int cur = 0; 96 int cur = 0;
97 for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) { 97 for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) {
98 if ( *it == text() ) 98 if ( *it == text() )
99 cur = combo->count(); 99 cur = combo->count();
100 combo->insertItem(*it); 100 combo->insertItem(*it);
101 } 101 }
102 combo->setCurrentItem(cur); 102 combo->setCurrentItem(cur);
103 return combo; 103 return combo;
104} 104}
105 105
106void AbPickItem::setContentFromEditor( QWidget *w ) 106void AbPickItem::setContentFromEditor( QWidget *w )
107{ 107{
108 if ( w->inherits("QComboBox") ) 108 if ( w->inherits("QComboBox") )
109 setText( ( (QComboBox*)w )->currentText() ); 109 setText( ( (QComboBox*)w )->currentText() );
110 else 110 else
111 QTableItem::setContentFromEditor( w ); 111 QTableItem::setContentFromEditor( w );
112} 112}
113 113
114/*! 114/*!
115 \class AbTable abtable.h 115 \class AbTable abtable.h
116 116
117 \brief QTable based class for showing a list of entries 117 \brief QTable based class for showing a list of entries
118*/ 118*/
119 119
120AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name ) 120AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name )
121 : QTable( parent, name ), 121 : QTable( parent, name ),
122 lastSortCol( -1 ), 122 lastSortCol( -1 ),
123 asc( TRUE ), 123 asc( TRUE ),
124 intFields( order ), 124 intFields( order ),
125 enablePainting( true ), 125 enablePainting( true ),
126 columnVisible( true ), 126 columnVisible( true ),
127 countNested( 0 ) 127 countNested( 0 )
128{ 128{
129 qWarning("C'tor start"); 129 //qWarning("C'tor start");
130 130
131 setSelectionMode( NoSelection ); 131 setSelectionMode( NoSelection );
132 init(); 132 init();
133 setSorting( TRUE ); 133 setSorting( TRUE );
134 connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), 134 connect( this, SIGNAL(clicked(int,int,int,const QPoint &)),
135 this, SLOT(itemClicked(int,int)) ); 135 this, SLOT(itemClicked(int,int)) );
136 136
137 contactList.clear(); 137 contactList.clear();
138 qWarning("C'tor end"); 138 //qWarning("C'tor end");
139} 139}
140 140
141AbTable::~AbTable() 141AbTable::~AbTable()
142{ 142{
143} 143}
144 144
145void AbTable::init() 145void AbTable::init()
146{ 146{
147 // :SX showChar = '\0'; 147 // :SX showChar = '\0';
148 setNumRows( 0 ); 148 setNumRows( 0 );
149 setNumCols( 2 ); 149 setNumCols( 2 );
150 150
151 horizontalHeader()->setLabel( 0, tr( "Full Name" )); 151 horizontalHeader()->setLabel( 0, tr( "Full Name" ));
152 horizontalHeader()->setLabel( 1, tr( "Contact" )); 152 horizontalHeader()->setLabel( 1, tr( "Contact" ));
153 setLeftMargin( 0 ); 153 setLeftMargin( 0 );
154 verticalHeader()->hide(); 154 verticalHeader()->hide();
155 columnVisible = true; 155 columnVisible = true;
156} 156}
157 157
158void AbTable::setContacts( const OContactAccess::List& viewList ) 158void AbTable::setContacts( const OContactAccess::List& viewList )
159{ 159{
160 qWarning("AbTable::setContacts()"); 160 //qWarning("AbTable::setContacts()");
161 161
162 clear(); 162 clear();
163 m_viewList = viewList; 163 m_viewList = viewList;
164 164
165 setSorting( false ); 165 setSorting( false );
166 setPaintingEnabled( FALSE ); 166 setPaintingEnabled( FALSE );
167 167
168 OContactAccess::List::Iterator it; 168 OContactAccess::List::Iterator it;
169 setNumRows( m_viewList.count() ); 169 setNumRows( m_viewList.count() );
170 int row = 0; 170 int row = 0;
171 for ( it = m_viewList.begin(); it != m_viewList.end(); ++it ) 171 for ( it = m_viewList.begin(); it != m_viewList.end(); ++it )
172 insertIntoTable( *it, row++ ); 172 insertIntoTable( *it, row++ );
173 173
174 setSorting( true ); 174 setSorting( true );
175 175
176 resort(); 176 resort();
177 177
178 updateVisible(); 178 updateVisible();
179 179
180 setPaintingEnabled( TRUE ); 180 setPaintingEnabled( TRUE );
181 181
182} 182}
183 183
184bool AbTable::selectContact( int UID ) 184bool AbTable::selectContact( int UID )
185{ 185{
186 qWarning( "AbTable::selectContact( %d )", UID ); 186 //qWarning( "AbTable::selectContact( %d )", UID );
187 int rows = numRows(); 187 int rows = numRows();
188 AbTableItem *abi; 188 AbTableItem *abi;
189 OContact* foundContact = 0l; 189 OContact* foundContact = 0l;
190 bool found = false; 190 bool found = false;
191 191
192 setPaintingEnabled( FALSE ); 192 setPaintingEnabled( FALSE );
193 for ( int r = 0; r < rows; ++r ) { 193 for ( int r = 0; r < rows; ++r ) {
194 abi = static_cast<AbTableItem*>( item(r, 0) ); 194 abi = static_cast<AbTableItem*>( item(r, 0) );
195 foundContact = &contactList[abi]; 195 foundContact = &contactList[abi];
196 if ( foundContact -> uid() == UID ){ 196 if ( foundContact -> uid() == UID ){
197 ensureCellVisible( r, 0 ); 197 ensureCellVisible( r, 0 );
198 setCurrentCell( r, 0 ); 198 setCurrentCell( r, 0 );
199 found = true; 199 found = true;
200 break; 200 break;
201 } 201 }
202 } 202 }
203 203
204 if ( !found ){ 204 if ( !found ){
205 ensureCellVisible( 0,0 ); 205 ensureCellVisible( 0,0 );
206 setCurrentCell( 0, 0 ); 206 setCurrentCell( 0, 0 );
207 } 207 }
208 208
209 setPaintingEnabled( TRUE ); 209 setPaintingEnabled( TRUE );
210 210
211 return true; 211 return true;
212} 212}
213 213
214void AbTable::insertIntoTable( const OContact& cnt, int row ) 214void AbTable::insertIntoTable( const OContact& cnt, int row )
215{ 215{
216 qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row ); 216 //qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row );
217 QString strName, 217 QString strName,
218 strContact; 218 strContact;
219 219
220 strName = findContactName( cnt ); 220 strName = findContactName( cnt );
221 strContact = findContactContact( cnt, row ); 221 strContact = findContactContact( cnt, row );
222 222
223 AbTableItem *ati; 223 AbTableItem *ati;
224 ati = new AbTableItem( this, QTableItem::Never, strName, strContact); 224 ati = new AbTableItem( this, QTableItem::Never, strName, strContact);
225 contactList.insert( ati, cnt ); 225 contactList.insert( ati, cnt );
226 setItem( row, 0, ati ); 226 setItem( row, 0, ati );
227 ati = new AbTableItem( this, QTableItem::Never, strContact, strName); 227 ati = new AbTableItem( this, QTableItem::Never, strContact, strName);
228 setItem( row, 1, ati ); 228 setItem( row, 1, ati );
229 229
230 //### cannot do this; table only has two columns at this point 230 //### cannot do this; table only has two columns at this point
231 // setItem( row, 2, new AbPickItem( this ) ); 231 // setItem( row, 2, new AbPickItem( this ) );
232 232
233} 233}
234 234
235 235
236 236
237void AbTable::columnClicked( int col ) 237void AbTable::columnClicked( int col )
238{ 238{
239 if ( !sorting() ) 239 if ( !sorting() )
240 return; 240 return;
241 241
242 if ( lastSortCol == -1 ) 242 if ( lastSortCol == -1 )
243 lastSortCol = col; 243 lastSortCol = col;
244 244
245 if ( col == lastSortCol ) { 245 if ( col == lastSortCol ) {
246 asc = !asc; 246 asc = !asc;
247 } else { 247 } else {
248 lastSortCol = col; 248 lastSortCol = col;
249 asc = TRUE; 249 asc = TRUE;
250 } 250 }
251 //QMessageBox::information( this, "resort", "columnClicked" ); 251 //QMessageBox::information( this, "resort", "columnClicked" );
252 resort(); 252 resort();
253} 253}
254 254
255void AbTable::resort() 255void AbTable::resort()
256{ 256{
257 qWarning( "void AbTable::resort()" ); 257 //qWarning( "void AbTable::resort()" );
258 setPaintingEnabled( FALSE ); 258 setPaintingEnabled( FALSE );
259 if ( sorting() ) { 259 if ( sorting() ) {
260 if ( lastSortCol == -1 ) 260 if ( lastSortCol == -1 )
261 lastSortCol = 0; 261 lastSortCol = 0;
262 sortColumn( lastSortCol, asc, TRUE ); 262 sortColumn( lastSortCol, asc, TRUE );
263 //QMessageBox::information( this, "resort", "resort" ); 263 //QMessageBox::information( this, "resort", "resort" );
264 updateVisible(); 264 updateVisible();
265 } 265 }
266 setPaintingEnabled( TRUE ); 266 setPaintingEnabled( TRUE );
267} 267}
268 268
269OContact AbTable::currentEntry() 269OContact AbTable::currentEntry()
270{ 270{
271 qWarning( "OContact AbTable::currentEntry()" ); 271 //qWarning( "OContact AbTable::currentEntry()" );
272 OContact cnt; 272 OContact cnt;
273 AbTableItem *abItem; 273 AbTableItem *abItem;
274 abItem = static_cast<AbTableItem*>(item( currentRow(), 0 )); 274 abItem = static_cast<AbTableItem*>(item( currentRow(), 0 ));
275 if ( abItem ) { 275 if ( abItem ) {
276 cnt = contactList[abItem]; 276 cnt = contactList[abItem];
277 //cnt = contactList[currentRow()]; 277 //cnt = contactList[currentRow()];
278 } 278 }
279 return cnt; 279 return cnt;
280} 280}
281 281
282int AbTable::currentEntry_UID() 282int AbTable::currentEntry_UID()
283{ 283{
284 return ( currentEntry().uid() ); 284 return ( currentEntry().uid() );
285} 285}
286 286
287void AbTable::clear() 287void AbTable::clear()
288{ 288{
289 qWarning( "void AbTable::clear()" ); 289 //qWarning( "void AbTable::clear()" );
290 contactList.clear(); 290 contactList.clear();
291 291
292 setPaintingEnabled( FALSE ); 292 setPaintingEnabled( FALSE );
293 for ( int r = 0; r < numRows(); ++r ) { 293 for ( int r = 0; r < numRows(); ++r ) {
294 for ( int c = 0; c < numCols(); ++c ) { 294 for ( int c = 0; c < numCols(); ++c ) {
295 if ( cellWidget( r, c ) ) 295 if ( cellWidget( r, c ) )
296 clearCellWidget( r, c ); 296 clearCellWidget( r, c );
297 clearCell( r, c ); 297 clearCell( r, c );
298 } 298 }
299 } 299 }
300 setNumRows( 0 ); 300 setNumRows( 0 );
301 setPaintingEnabled( TRUE ); 301 setPaintingEnabled( TRUE );
302} 302}
303 303
304// Refresh updates column 2 if the contactsettings changed 304// Refresh updates column 2 if the contactsettings changed
305void AbTable::refresh() 305void AbTable::refresh()
306{ 306{
307 qWarning( "void AbTable::refresh()" ); 307 //qWarning( "void AbTable::refresh()" );
308 int rows = numRows(); 308 int rows = numRows();
309 QString value; 309 QString value;
310 AbTableItem *abi; 310 AbTableItem *abi;
311 311
312 setPaintingEnabled( FALSE ); 312 setPaintingEnabled( FALSE );
313 for ( int r = 0; r < rows; ++r ) { 313 for ( int r = 0; r < rows; ++r ) {
314 abi = static_cast<AbTableItem*>( item(r, 0) ); 314 abi = static_cast<AbTableItem*>( item(r, 0) );
315 value = findContactContact( contactList[abi], r ); 315 value = findContactContact( contactList[abi], r );
316 static_cast<AbTableItem*>( item(r, 1) )->setItem( value, abi->text() ); 316 static_cast<AbTableItem*>( item(r, 1) )->setItem( value, abi->text() );
317 } 317 }
318 resort(); 318 resort();
319 setPaintingEnabled( TRUE ); 319 setPaintingEnabled( TRUE );
320} 320}
321 321
322void AbTable::keyPressEvent( QKeyEvent *e ) 322void AbTable::keyPressEvent( QKeyEvent *e )
323{ 323{
324 char key = toupper( e->ascii() ); 324 char key = toupper( e->ascii() );
325 325
326 if ( key >= 'A' && key <= 'Z' ) 326 if ( key >= 'A' && key <= 'Z' )
327 moveTo( key ); 327 moveTo( key );
328 328
329 qWarning("Received key .."); 329 //qWarning("Received key ..");
330 switch( e->key() ) { 330 switch( e->key() ) {
331 case Qt::Key_Space: 331 case Qt::Key_Space:
332 case Qt::Key_Return: 332 case Qt::Key_Return:
333 case Qt::Key_Enter: 333 case Qt::Key_Enter:
334 emit signalSwitch(); 334 emit signalSwitch();
335 break; 335 break;
336 // case Qt::Key_Up: 336 // case Qt::Key_Up:
337 // qWarning("a"); 337 // qWarning("a");
338 // emit signalKeyUp(); 338 // emit signalKeyUp();
339 // break; 339 // break;
340 // case Qt::Key_Down: 340 // case Qt::Key_Down:
341 // qWarning("b"); 341 // qWarning("b");
342 // emit signalKeyDown(); 342 // emit signalKeyDown();
343 // break; 343 // break;
344 default: 344 default:
345 QTable::keyPressEvent( e ); 345 QTable::keyPressEvent( e );
346 } 346 }
347 347
348} 348}
349 349
350void AbTable::moveTo( char c ) 350void AbTable::moveTo( char c )
351{ 351{
352 qWarning( "void AbTable::moveTo( char c )" ); 352 qWarning( "void AbTable::moveTo( char c )" );
353 353
354 int rows = numRows(); 354 int rows = numRows();
355 QString value; 355 QString value;
356 AbTableItem *abi; 356 AbTableItem *abi;
357 int r; 357 int r;
358 if ( asc ) { 358 if ( asc ) {
359 r = 0; 359 r = 0;
360 while ( r < rows-1) { 360 while ( r < rows-1) {
361 abi = static_cast<AbTableItem*>( item(r, 0) ); 361 abi = static_cast<AbTableItem*>( item(r, 0) );
362 QChar first = abi->key()[0]; 362 QChar first = abi->key()[0];
363 //### is there a bug in QChar to char comparison??? 363 //### is there a bug in QChar to char comparison???
364 if ( first.row() || first.cell() >= c ) 364 if ( first.row() || first.cell() >= c )
365 break; 365 break;
366 r++; 366 r++;
367 } 367 }
368 } else { 368 } else {
369 //### should probably disable reverse sorting instead 369 //### should probably disable reverse sorting instead
370 r = rows - 1; 370 r = rows - 1;
371 while ( r > 0 ) { 371 while ( r > 0 ) {
372 abi = static_cast<AbTableItem*>( item(r, 0) ); 372 abi = static_cast<AbTableItem*>( item(r, 0) );
373 QChar first = abi->key()[0]; 373 QChar first = abi->key()[0];
374 //### is there a bug in QChar to char comparison??? 374 //### is there a bug in QChar to char comparison???
375 if ( first.row() || first.cell() >= c ) 375 if ( first.row() || first.cell() >= c )
376 break; 376 break;
377 r--; 377 r--;
378 } 378 }
379 } 379 }
380 setCurrentCell( r, currentColumn() ); 380 setCurrentCell( r, currentColumn() );
381} 381}
382 382
383 383
384QString AbTable::findContactName( const OContact &entry ) 384QString AbTable::findContactName( const OContact &entry )
385{ 385{
386 // We use the fileAs, then company, defaultEmail 386 // We use the fileAs, then company, defaultEmail
387 QString str; 387 QString str;
388 str = entry.fileAs(); 388 str = entry.fileAs();
389 if ( str.isEmpty() ) { 389 if ( str.isEmpty() ) {
390 str = entry.company(); 390 str = entry.company();
391 if ( str.isEmpty() ) { 391 if ( str.isEmpty() ) {
392 str = entry.defaultEmail(); 392 str = entry.defaultEmail();
393 } 393 }
394 } 394 }
395 return str; 395 return str;
396} 396}
397 397
398 398
399 399
400void AbTable::resizeRows() { 400void AbTable::resizeRows() {
401 /* 401 /*
402 if (numRows()) { 402 if (numRows()) {
403 for (int i = 0; i < numRows(); i++) { 403 for (int i = 0; i < numRows(); i++) {
404 setRowHeight( i, size ); 404 setRowHeight( i, size );
405 } 405 }
406 } 406 }
407 updateVisible(); 407 updateVisible();
408 */ 408 */
409} 409}
410 410
411 411
412void AbTable::realignTable() 412void AbTable::realignTable()
413{ 413{
414 qWarning( "void AbTable::realignTable()" ); 414 //qWarning( "void AbTable::realignTable()" );
415 415
416 setPaintingEnabled( FALSE ); 416 setPaintingEnabled( FALSE );
417 417
418 resizeRows(); 418 resizeRows();
419 fitColumns(); 419 fitColumns();
420 420
421 setPaintingEnabled( TRUE ); 421 setPaintingEnabled( TRUE );
422 422
423} 423}
424 424
425 425
426 426
427 427
428#if QT_VERSION <= 230 428#if QT_VERSION <= 230
429#ifndef SINGLE_APP 429#ifndef SINGLE_APP
430void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) 430void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch )
431{ 431{
432 // Region of the rect we should draw 432 // Region of the rect we should draw
433 QRegion reg( QRect( cx, cy, cw, ch ) ); 433 QRegion reg( QRect( cx, cy, cw, ch ) );
434 // Subtract the table from it 434 // Subtract the table from it
435 reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) ); 435 reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) );
436 // And draw the rectangles (transformed as needed) 436 // And draw the rectangles (transformed as needed)
437 QArray<QRect> r = reg.rects(); 437 QArray<QRect> r = reg.rects();
438 for (unsigned int i=0; i<r.count(); i++) 438 for (unsigned int i=0; i<r.count(); i++)
439 p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) ); 439 p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) );
440} 440}
441#endif 441#endif
442#endif 442#endif
443 443
444 444
445// int AbTable::rowHeight( int ) const 445// int AbTable::rowHeight( int ) const
446// { 446// {
447// return 18; 447// return 18;
448// } 448// }
449 449
450// int AbTable::rowPos( int row ) const 450// int AbTable::rowPos( int row ) const
451// { 451// {
452// return 18*row; 452// return 18*row;
453// } 453// }
454 454
455// int AbTable::rowAt( int pos ) const 455// int AbTable::rowAt( int pos ) const
456// { 456// {
457// return QMIN( pos/18, numRows()-1 ); 457// return QMIN( pos/18, numRows()-1 );
458// } 458// }
459 459
460 460
461 461
462void AbTable::fitColumns() 462void AbTable::fitColumns()
463{ 463{
464 qWarning( "void AbTable::fitColumns()" ); 464 //qWarning( "void AbTable::fitColumns()" );
465 int contentsWidth = visibleWidth() / 2; // :SX Why too low 465 int contentsWidth = visibleWidth() / 2; // :SX Why too low
466 // Fix to better value 466 // Fix to better value
467 // contentsWidth = 130; 467 // contentsWidth = 130;
468 468
469 setPaintingEnabled( FALSE ); 469 setPaintingEnabled( FALSE );
470 470
471 if ( columnVisible == false ){ 471 if ( columnVisible == false ){
472 showColumn(0); 472 showColumn(0);
473 columnVisible = true; 473 columnVisible = true;
474 } 474 }
475 475
476 qWarning("Width: %d", contentsWidth); 476 //qWarning("Width: %d", contentsWidth);
477 477
478 setColumnWidth( 0, contentsWidth ); 478 setColumnWidth( 0, contentsWidth );
479 adjustColumn(1); 479 adjustColumn(1);
480 if ( columnWidth(1) < contentsWidth ) 480 if ( columnWidth(1) < contentsWidth )
481 setColumnWidth( 1, contentsWidth ); 481 setColumnWidth( 1, contentsWidth );
482 482
483 setPaintingEnabled( TRUE ); 483 setPaintingEnabled( TRUE );
484} 484}
485 485
486void AbTable::show() 486void AbTable::show()
487{ 487{
488 qWarning( "void AbTable::show()" ); 488 //qWarning( "void AbTable::show()" );
489 realignTable(); 489 realignTable();
490 QTable::show(); 490 QTable::show();
491} 491}
492 492
493void AbTable::setChoiceNames( const QStringList& list) 493void AbTable::setChoiceNames( const QStringList& list)
494{ 494{
495 choicenames = list; 495 choicenames = list;
496 if ( choicenames.isEmpty() ) { 496 if ( choicenames.isEmpty() ) {
497 // hide pick column 497 // hide pick column
498 setNumCols( 2 ); 498 setNumCols( 2 );
499 } else { 499 } else {
500 // show pick column 500 // show pick column
501 setNumCols( 3 ); 501 setNumCols( 3 );
502 setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 ); 502 setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 );
503 horizontalHeader()->setLabel( 2, tr( "Pick" )); 503 horizontalHeader()->setLabel( 2, tr( "Pick" ));
504 } 504 }
505 fitColumns(); 505 fitColumns();
506} 506}
507 507
508void AbTable::itemClicked(int,int col) 508void AbTable::itemClicked(int,int col)
509{ 509{
510 qWarning( "AbTable::itemClicked(int, col:%d)", col); 510 //qWarning( "AbTable::itemClicked(int, col:%d)", col);
511 if ( col == 2 ) { 511 if ( col == 2 ) {
512 return; 512 return;
513 } else { 513 } else {
514 qWarning ("Emitting signalSwitch()"); 514 // qWarning ("Emitting signalSwitch()");
515 emit signalSwitch(); 515 emit signalSwitch();
516 } 516 }
517} 517}
518 518
519QStringList AbTable::choiceNames() const 519QStringList AbTable::choiceNames() const
520{ 520{
521 return choicenames; 521 return choicenames;
522} 522}
523 523
524void AbTable::setChoiceSelection( const QValueList<int>& list ) 524void AbTable::setChoiceSelection( const QValueList<int>& list )
525{ 525{
526 intFields = list; 526 intFields = list;
527} 527}
528 528
529QStringList AbTable::choiceSelection(int /*index*/) const 529QStringList AbTable::choiceSelection(int /*index*/) const
530{ 530{
531 QStringList r; 531 QStringList r;
532 /* ###### 532 /* ######
533 533
534 QString selname = choicenames.at(index); 534 QString selname = choicenames.at(index);
535 for (each row) { 535 for (each row) {
536 OContact *c = contactForRow(row); 536 OContact *c = contactForRow(row);
537 if ( text(row,2) == selname ) { 537 if ( text(row,2) == selname ) {
538 r.append(c->email); 538 r.append(c->email);
539 } 539 }
540 } 540 }
541 541
542 */ 542 */
543 return r; 543 return r;
544} 544}
545 545
546 546
547 547
548 548
549void AbTable::updateVisible() 549void AbTable::updateVisible()
550{ 550{
551 qWarning("void AbTable::updateVisible()"); 551 //qWarning("void AbTable::updateVisible()");
552 552
553 int visible, 553 int visible,
554 totalRows, 554 totalRows,
555 row, 555 row,
556 selectedRow = 0; 556 selectedRow = 0;
557 557
558 visible = 0; 558 visible = 0;
559 559
560 setPaintingEnabled( FALSE ); 560 setPaintingEnabled( FALSE );
561 561
562 realignTable(); 562 realignTable();
563 563
564 totalRows = numRows(); 564 totalRows = numRows();
565 for ( row = 0; row < totalRows; row++ ) { 565 for ( row = 0; row < totalRows; row++ ) {
566 if ( rowHeight(row) == 0 ) { 566 if ( rowHeight(row) == 0 ) {
567 showRow( row ); 567 showRow( row );
568 adjustRow( row ); 568 adjustRow( row );
569 if ( isSelected( row,0 ) || isSelected( row,1 ) ) 569 if ( isSelected( row,0 ) || isSelected( row,1 ) )
570 selectedRow = row; 570 selectedRow = row;
571 } 571 }
572 visible++; 572 visible++;
573 } 573 }
574 574
575 if ( selectedRow ) 575 if ( selectedRow )
576 setCurrentCell( selectedRow, 0 ); 576 setCurrentCell( selectedRow, 0 );
577 577
578 if ( !visible ) 578 if ( !visible )
579 setCurrentCell( -1, 0 ); 579 setCurrentCell( -1, 0 );
580 580
581 setPaintingEnabled( TRUE ); 581 setPaintingEnabled( TRUE );
582 582
583 583
584} 584}
585 585
586 586
587void AbTable::setPaintingEnabled( bool e ) 587void AbTable::setPaintingEnabled( bool e )
588{ 588{
589 qWarning("IN void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested ); 589 //qWarning("IN void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested );
590 590
591 if ( e ) { 591 if ( e ) {
592 if ( countNested > 0 ) 592 if ( countNested > 0 )
593 --countNested; 593 --countNested;
594 if ( ! countNested ){ 594 if ( ! countNested ){
595 setUpdatesEnabled( true ); 595 setUpdatesEnabled( true );
596 enablePainting = true; 596 enablePainting = true;
597 rowHeightChanged( 0 ); 597 rowHeightChanged( 0 );
598 viewport()->update(); 598 viewport()->update();
599 } 599 }
600 } else { 600 } else {
601 ++countNested; 601 ++countNested;
602 enablePainting = false; 602 enablePainting = false;
603 setUpdatesEnabled( false ); 603 setUpdatesEnabled( false );
604 } 604 }
605 qWarning("OUT void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested ); 605 //qWarning("OUT void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested );
606} 606}
607 607
608void AbTable::viewportPaintEvent( QPaintEvent* e ) { 608void AbTable::viewportPaintEvent( QPaintEvent* e ) {
609 qWarning(" void AbTable::viewportPaintEvent( QPaintEvent* e ) -> %d", enablePainting); 609 //qWarning(" void AbTable::viewportPaintEvent( QPaintEvent* e ) -> %d", enablePainting);
610 if ( enablePainting ) 610 if ( enablePainting )
611 QTable::viewportPaintEvent( e ); 611 QTable::viewportPaintEvent( e );
612} 612}
613 613
614 614
615 615
616void AbTable::rowHeightChanged( int row ) 616void AbTable::rowHeightChanged( int row )
617{ 617{
618 if ( enablePainting ) 618 if ( enablePainting )
619 QTable::rowHeightChanged( row ); 619 QTable::rowHeightChanged( row );
620} 620}
621QString AbTable::findContactContact( const OContact &entry, int /* row */ ) 621QString AbTable::findContactContact( const OContact &entry, int /* row */ )
622{ 622{
623 QString value; 623 QString value;
624 value = ""; 624 value = "";
625 for ( QValueList<int>::ConstIterator it = intFields.begin(); 625 for ( QValueList<int>::ConstIterator it = intFields.begin();
626 it != intFields.end(); ++it ) { 626 it != intFields.end(); ++it ) {
627 switch ( *it ) { 627 switch ( *it ) {
628 default: 628 default:
629 break; 629 break;
630 case Qtopia::Title: 630 case Qtopia::Title:
631 value = entry.title(); 631 value = entry.title();
632 break; 632 break;
633 case Qtopia::Suffix: 633 case Qtopia::Suffix:
634 value = entry.suffix(); 634 value = entry.suffix();
635 break; 635 break;
636 case Qtopia::FileAs: 636 case Qtopia::FileAs:
637 value = entry.fileAs(); 637 value = entry.fileAs();
638 break; 638 break;
639 case Qtopia::DefaultEmail: 639 case Qtopia::DefaultEmail:
640 value = entry.defaultEmail(); 640 value = entry.defaultEmail();
641 case Qtopia::Emails: 641 case Qtopia::Emails:
642 value = entry.emails(); 642 value = entry.emails();
643 break; 643 break;
644 case Qtopia::HomeStreet: 644 case Qtopia::HomeStreet:
645 value = entry.homeStreet(); 645 value = entry.homeStreet();
646 break; 646 break;
647 case Qtopia::HomeCity: 647 case Qtopia::HomeCity:
648 value = entry.homeCity(); 648 value = entry.homeCity();
649 break; 649 break;
650 case Qtopia::HomeState: 650 case Qtopia::HomeState:
651 value = entry.homeState(); 651 value = entry.homeState();
652 break; 652 break;
653 case Qtopia::HomeZip: 653 case Qtopia::HomeZip:
654 value = entry.homeZip(); 654 value = entry.homeZip();
655 break; 655 break;
656 case Qtopia::HomeCountry: 656 case Qtopia::HomeCountry:
657 value = entry.homeCountry(); 657 value = entry.homeCountry();
658 break; 658 break;
659 case Qtopia::HomePhone: 659 case Qtopia::HomePhone:
660 value = entry.homePhone(); 660 value = entry.homePhone();
661 break; 661 break;
662 case Qtopia::HomeFax: 662 case Qtopia::HomeFax:
663 value = entry.homeFax(); 663 value = entry.homeFax();
664 break; 664 break;
665 case Qtopia::HomeMobile: 665 case Qtopia::HomeMobile:
666 value = entry.homeMobile(); 666 value = entry.homeMobile();
667 break; 667 break;
668 case Qtopia::HomeWebPage: 668 case Qtopia::HomeWebPage:
669 value = entry.homeWebpage(); 669 value = entry.homeWebpage();
670 break; 670 break;
671 case Qtopia::Company: 671 case Qtopia::Company:
672 value = entry.company(); 672 value = entry.company();
673 break; 673 break;
674 case Qtopia::BusinessCity: 674 case Qtopia::BusinessCity:
675 value = entry.businessCity(); 675 value = entry.businessCity();
676 break; 676 break;
677 case Qtopia::BusinessStreet: 677 case Qtopia::BusinessStreet:
678 value = entry.businessStreet(); 678 value = entry.businessStreet();
679 break; 679 break;
680 case Qtopia::BusinessZip: 680 case Qtopia::BusinessZip:
681 value = entry.businessZip(); 681 value = entry.businessZip();
682 break; 682 break;
683 case Qtopia::BusinessCountry: 683 case Qtopia::BusinessCountry:
684 value = entry.businessCountry(); 684 value = entry.businessCountry();
685 break; 685 break;
686 case Qtopia::BusinessWebPage: 686 case Qtopia::BusinessWebPage:
687 value = entry.businessWebpage(); 687 value = entry.businessWebpage();
688 break; 688 break;
689 case Qtopia::JobTitle: 689 case Qtopia::JobTitle:
690 value = entry.jobTitle(); 690 value = entry.jobTitle();
691 break; 691 break;
692 case Qtopia::Department: 692 case Qtopia::Department:
693 value = entry.department(); 693 value = entry.department();
694 break; 694 break;
695 case Qtopia::Office: 695 case Qtopia::Office:
696 value = entry.office(); 696 value = entry.office();
697 break; 697 break;
698 case Qtopia::BusinessPhone: 698 case Qtopia::BusinessPhone:
699 value = entry.businessPhone(); 699 value = entry.businessPhone();
700 break; 700 break;
701 case Qtopia::BusinessFax: 701 case Qtopia::BusinessFax:
702 value = entry.businessFax(); 702 value = entry.businessFax();
703 break; 703 break;
704 case Qtopia::BusinessMobile: 704 case Qtopia::BusinessMobile:
705 value = entry.businessMobile(); 705 value = entry.businessMobile();
706 break; 706 break;
707 case Qtopia::BusinessPager: 707 case Qtopia::BusinessPager:
708 value = entry.businessPager(); 708 value = entry.businessPager();
709 break; 709 break;
710 case Qtopia::Profession: 710 case Qtopia::Profession:
711 value = entry.profession(); 711 value = entry.profession();
712 break; 712 break;
713 case Qtopia::Assistant: 713 case Qtopia::Assistant:
714 value = entry.assistant(); 714 value = entry.assistant();
715 break; 715 break;
716 case Qtopia::Manager: 716 case Qtopia::Manager:
717 value = entry.manager(); 717 value = entry.manager();
718 break; 718 break;
719 case Qtopia::Spouse: 719 case Qtopia::Spouse:
720 value = entry.spouse(); 720 value = entry.spouse();
721 break; 721 break;
722 case Qtopia::Gender: 722 case Qtopia::Gender:
723 value = entry.gender(); 723 value = entry.gender();
724 break; 724 break;
725 case Qtopia::Birthday: 725 case Qtopia::Birthday:
726 if ( ! entry.birthday().isNull() ) 726 if ( ! entry.birthday().isNull() )
727 value = TimeString::numberDateString( entry.birthday() ); 727 value = TimeString::numberDateString( entry.birthday() );
728 break; 728 break;
729 case Qtopia::Anniversary: 729 case Qtopia::Anniversary:
730 if ( ! entry.anniversary().isNull() ) 730 if ( ! entry.anniversary().isNull() )
731 value = TimeString::numberDateString( entry.anniversary() ); 731 value = TimeString::numberDateString( entry.anniversary() );
732 break; 732 break;
733 case Qtopia::Nickname: 733 case Qtopia::Nickname:
734 value = entry.nickname(); 734 value = entry.nickname();
735 break; 735 break;
736 case Qtopia::Children: 736 case Qtopia::Children:
737 value = entry.children(); 737 value = entry.children();
738 break; 738 break;
739 case Qtopia::Notes: 739 case Qtopia::Notes:
740 value = entry.notes(); 740 value = entry.notes();
741 break; 741 break;
742 } 742 }
743 if ( !value.isEmpty() ) 743 if ( !value.isEmpty() )
744 break; 744 break;
745 } 745 }
746 return value; 746 return value;
747} 747}
diff --git a/core/pim/addressbook/abview.cpp b/core/pim/addressbook/abview.cpp
index 93e57ca..7da0992 100644
--- a/core/pim/addressbook/abview.cpp
+++ b/core/pim/addressbook/abview.cpp
@@ -1,475 +1,475 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de) 2** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de)
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** 14**
15**********************************************************************/ 15**********************************************************************/
16 16
17#include "abview.h" 17#include "abview.h"
18 18
19#include <qlayout.h> 19#include <qlayout.h>
20 20
21#include <qpe/global.h> 21#include <qpe/global.h>
22 22
23#include <opie/ocontactaccessbackend_vcard.h> 23#include <opie/ocontactaccessbackend_vcard.h>
24 24
25 25
26// Is defined in LibQPE 26// Is defined in LibQPE
27extern QString categoryFileName(); 27extern QString categoryFileName();
28 28
29QString addressbookPersonalVCardName() 29QString addressbookPersonalVCardName()
30{ 30{
31 QString filename = Global::applicationFileName("addressbook", 31 QString filename = Global::applicationFileName("addressbook",
32 "businesscard.vcf"); 32 "businesscard.vcf");
33 return filename; 33 return filename;
34} 34}
35 35
36 36
37AbView::AbView ( QWidget* parent, const QValueList<int>& ordered ): 37AbView::AbView ( QWidget* parent, const QValueList<int>& ordered ):
38 QWidget(parent), 38 QWidget(parent),
39 mCat(0), 39 mCat(0),
40 m_inSearch( false ), 40 m_inSearch( false ),
41 m_inPersonal( false ), 41 m_inPersonal( false ),
42 m_curr_category( -1 ), 42 m_curr_category( -1 ),
43 m_curr_View( TableView ), 43 m_curr_View( TableView ),
44 m_prev_View( TableView ), 44 m_prev_View( TableView ),
45 m_curr_Contact ( 0 ), 45 m_curr_Contact ( 0 ),
46 m_contactdb ( 0l ), 46 m_contactdb ( 0l ),
47 m_storedDB ( 0l ), 47 m_storedDB ( 0l ),
48 m_viewStack( 0l ), 48 m_viewStack( 0l ),
49 m_abTable( 0l ), 49 m_abTable( 0l ),
50 m_orderedFields( ordered ) 50 m_orderedFields( ordered )
51{ 51{
52 // Load default database and handle syncing myself.. ! 52 // Load default database and handle syncing myself.. !
53 m_contactdb = new OContactAccess ( "addressbook", 0l, 0l, false ), 53 m_contactdb = new OContactAccess ( "addressbook", 0l, 0l, false ),
54 mCat.load( categoryFileName() ); 54 mCat.load( categoryFileName() );
55 55
56 // Create Layout and put WidgetStack into it. 56 // Create Layout and put WidgetStack into it.
57 QVBoxLayout *vb = new QVBoxLayout( this ); 57 QVBoxLayout *vb = new QVBoxLayout( this );
58 m_viewStack = new QWidgetStack( this ); 58 m_viewStack = new QWidgetStack( this );
59 vb->addWidget( m_viewStack ); 59 vb->addWidget( m_viewStack );
60 60
61 // Creat TableView 61 // Creat TableView
62 QVBox* tableBox = new QVBox( m_viewStack ); 62 QVBox* tableBox = new QVBox( m_viewStack );
63 m_abTable = new AbTable( m_orderedFields, tableBox, "table" ); 63 m_abTable = new AbTable( m_orderedFields, tableBox, "table" );
64 m_abTable->setCurrentCell( 0, 0 ); 64 m_abTable->setCurrentCell( 0, 0 );
65 m_abTable->setFocus(); 65 m_abTable->setFocus();
66 66
67 // Add TableView to WidgetStack and raise it 67 // Add TableView to WidgetStack and raise it
68 m_viewStack -> addWidget( tableBox , TableView ); 68 m_viewStack -> addWidget( tableBox , TableView );
69 69
70 // Create CardView and add it to WidgetStack 70 // Create CardView and add it to WidgetStack
71 QVBox* cardBox = new QVBox( m_viewStack ); 71 QVBox* cardBox = new QVBox( m_viewStack );
72 m_ablabel = new AbLabel( cardBox, "CardView"); 72 m_ablabel = new AbLabel( cardBox, "CardView");
73 m_viewStack -> addWidget( cardBox , CardView ); 73 m_viewStack -> addWidget( cardBox , CardView );
74 74
75 // Connect views to me 75 // Connect views to me
76 connect ( m_abTable, SIGNAL( signalSwitch( void ) ), 76 connect ( m_abTable, SIGNAL( signalSwitch( void ) ),
77 this, SLOT( slotSwitch( void ) ) ); 77 this, SLOT( slotSwitch( void ) ) );
78 connect ( m_ablabel, SIGNAL( signalOkPressed( void ) ), 78 connect ( m_ablabel, SIGNAL( signalOkPressed( void ) ),
79 this, SLOT( slotSwitch( void ) ) ); 79 this, SLOT( slotSwitch( void ) ) );
80 80
81 load(); 81 load();
82} 82}
83 83
84AbView::~AbView() 84AbView::~AbView()
85{ 85{
86 m_contactdb -> save(); 86 m_contactdb -> save();
87 delete m_contactdb; 87 delete m_contactdb;
88 88
89 if ( m_storedDB ){ 89 if ( m_storedDB ){
90 m_storedDB -> save(); 90 m_storedDB -> save();
91 delete m_storedDB; 91 delete m_storedDB;
92 } 92 }
93} 93}
94 94
95 95
96void AbView::setView( Views view ) 96void AbView::setView( Views view )
97{ 97{
98 qWarning("AbView::setView( Views view )"); 98 //qWarning("AbView::setView( Views view )");
99 m_curr_View = view; 99 m_curr_View = view;
100 load(); 100 load();
101} 101}
102 102
103void AbView::addEntry( const OContact &newContact ) 103void AbView::addEntry( const OContact &newContact )
104{ 104{
105 qWarning("abview:AddContact"); 105 //qWarning("abview:AddContact");
106 m_contactdb->add ( newContact ); 106 m_contactdb->add ( newContact );
107 load(); 107 load();
108 108
109} 109}
110void AbView::removeEntry( const int UID ) 110void AbView::removeEntry( const int UID )
111{ 111{
112 qWarning("abview:RemoveContact"); 112 //qWarning("abview:RemoveContact");
113 m_contactdb->remove( UID ); 113 m_contactdb->remove( UID );
114 load(); 114 load();
115} 115}
116 116
117void AbView::replaceEntry( const OContact &contact ) 117void AbView::replaceEntry( const OContact &contact )
118{ 118{
119 qWarning("abview:ReplaceContact"); 119 //qWarning("abview:ReplaceContact");
120 m_contactdb->replace( contact ); 120 m_contactdb->replace( contact );
121 load(); 121 load();
122 122
123} 123}
124 124
125OContact AbView::currentEntry() 125OContact AbView::currentEntry()
126{ 126{
127 OContact currentContact; 127 OContact currentContact;
128 128
129 switch ( (int) m_curr_View ) { 129 switch ( (int) m_curr_View ) {
130 case TableView: 130 case TableView:
131 currentContact = m_abTable -> currentEntry(); 131 currentContact = m_abTable -> currentEntry();
132 break; 132 break;
133 case CardView: 133 case CardView:
134 currentContact = m_ablabel -> currentEntry(); 134 currentContact = m_ablabel -> currentEntry();
135 break; 135 break;
136 } 136 }
137 m_curr_Contact = currentContact.uid(); 137 m_curr_Contact = currentContact.uid();
138 return currentContact; 138 return currentContact;
139} 139}
140 140
141bool AbView::save() 141bool AbView::save()
142{ 142{
143 qWarning("abView:Save data"); 143 //qWarning("abView:Save data");
144 144
145 return m_contactdb->save(); 145 return m_contactdb->save();
146} 146}
147 147
148void AbView::load() 148void AbView::load()
149{ 149{
150 qWarning("abView:Load data"); 150 //qWarning("abView:Load data");
151 151
152 // Letter Search is stopped at this place 152 // Letter Search is stopped at this place
153 emit signalClearLetterPicker(); 153 emit signalClearLetterPicker();
154 154
155 if ( m_inPersonal ) 155 if ( m_inPersonal )
156 // VCard Backend does not sort.. 156 // VCard Backend does not sort..
157 m_list = m_contactdb->allRecords(); 157 m_list = m_contactdb->allRecords();
158 else{ 158 else{
159 m_list = m_contactdb->sorted( true, 0, 0, 0 ); 159 m_list = m_contactdb->sorted( true, 0, 0, 0 );
160 clearForCategory(); 160 clearForCategory();
161 } 161 }
162 162
163 qWarning ("Number of contacts: %d", m_list.count()); 163 //qWarning ("Number of contacts: %d", m_list.count());
164 164
165 updateView( true ); 165 updateView( true );
166 166
167} 167}
168 168
169void AbView::reload() 169void AbView::reload()
170{ 170{
171 qWarning( "void AbView::reload()" ); 171 //qWarning( "void AbView::reload()" );
172 172
173 m_contactdb->reload(); 173 m_contactdb->reload();
174 load(); 174 load();
175} 175}
176 176
177void AbView::clear() 177void AbView::clear()
178{ 178{
179 // :SX 179 // :SX
180} 180}
181 181
182void AbView::setShowByCategory( const QString& cat ) 182void AbView::setShowByCategory( const QString& cat )
183{ 183{
184 qWarning("AbView::setShowCategory( const QString& cat )"); 184 //qWarning("AbView::setShowCategory( const QString& cat )");
185 185
186 int intCat = 0; 186 int intCat = 0;
187 187
188 // All (cat == NULL) will be stored as -1 188 // All (cat == NULL) will be stored as -1
189 if ( cat.isNull() ) 189 if ( cat.isNull() )
190 intCat = -1; 190 intCat = -1;
191 else 191 else
192 intCat = mCat.id("Contacts", cat ); 192 intCat = mCat.id("Contacts", cat );
193 193
194 // Just do anything if we really change the category 194 // Just do anything if we really change the category
195 if ( intCat != m_curr_category ){ 195 if ( intCat != m_curr_category ){
196 qWarning ("Categories: Selected %s.. Number: %d", cat.latin1(), m_curr_category); 196 // qWarning ("Categories: Selected %s.. Number: %d", cat.latin1(), m_curr_category);
197 197
198 m_curr_category = intCat; 198 m_curr_category = intCat;
199 emit signalClearLetterPicker(); 199 emit signalClearLetterPicker();
200 200
201 load(); 201 load();
202 } 202 }
203 203
204} 204}
205 205
206void AbView::setShowToView( Views view ) 206void AbView::setShowToView( Views view )
207{ 207{
208 qWarning("void AbView::setShowToView( View %d )", view); 208 //qWarning("void AbView::setShowToView( View %d )", view);
209 209
210 qWarning ("Change the View (Category is: %d)", m_curr_category); 210 //qWarning ("Change the View (Category is: %d)", m_curr_category);
211 211
212 if ( m_curr_View != view ){ 212 if ( m_curr_View != view ){
213 m_prev_View = m_curr_View; 213 m_prev_View = m_curr_View;
214 m_curr_View = view; 214 m_curr_View = view;
215 215
216 updateView(); 216 updateView();
217 } 217 }
218 218
219} 219}
220 220
221void AbView::setShowByLetter( char c ) 221void AbView::setShowByLetter( char c )
222{ 222{
223 qWarning("void AbView::setShowByLetter( %c )", c ); 223 //qWarning("void AbView::setShowByLetter( %c )", c );
224 OContact query; 224 OContact query;
225 if ( c == 0 ){ 225 if ( c == 0 ){
226 load(); 226 load();
227 return; 227 return;
228 }else{ 228 }else{
229 // If the current Backend is unable to solve the query, we will 229 // If the current Backend is unable to solve the query, we will
230 // ignore the request .. 230 // ignore the request ..
231 if ( ! m_contactdb->hasQuerySettings( OContactAccess::WildCards | OContactAccess::IgnoreCase ) ){ 231 if ( ! m_contactdb->hasQuerySettings( OContactAccess::WildCards | OContactAccess::IgnoreCase ) ){
232 return; 232 return;
233 } 233 }
234 234
235 query.setLastName( QString("%1*").arg(c) ); 235 query.setLastName( QString("%1*").arg(c) );
236 m_list = m_contactdb->queryByExample( query, OContactAccess::WildCards | OContactAccess::IgnoreCase ); 236 m_list = m_contactdb->queryByExample( query, OContactAccess::WildCards | OContactAccess::IgnoreCase );
237 clearForCategory(); 237 clearForCategory();
238 m_curr_Contact = 0; 238 m_curr_Contact = 0;
239 } 239 }
240 updateView( true ); 240 updateView( true );
241} 241}
242 242
243void AbView::setListOrder( const QValueList<int>& ordered ) 243void AbView::setListOrder( const QValueList<int>& ordered )
244{ 244{
245 m_orderedFields = ordered; 245 m_orderedFields = ordered;
246 updateView(); 246 updateView();
247} 247}
248 248
249 249
250QString AbView::showCategory() const 250QString AbView::showCategory() const
251{ 251{
252 return mCat.label( "Contacts", m_curr_category ); 252 return mCat.label( "Contacts", m_curr_category );
253} 253}
254 254
255void AbView::showPersonal( bool personal ) 255void AbView::showPersonal( bool personal )
256{ 256{
257 qWarning ("void AbView::showPersonal( %d )", personal); 257 //qWarning ("void AbView::showPersonal( %d )", personal);
258 258
259 if ( personal ){ 259 if ( personal ){
260 260
261 if ( m_inPersonal ) 261 if ( m_inPersonal )
262 return; 262 return;
263 263
264 // Now switch to vCard Backend and load data. 264 // Now switch to vCard Backend and load data.
265 // The current default backend will be stored 265 // The current default backend will be stored
266 // to avoid unneeded load/stores. 266 // to avoid unneeded load/stores.
267 m_storedDB = m_contactdb; 267 m_storedDB = m_contactdb;
268 268
269 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, 269 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
270 addressbookPersonalVCardName() ); 270 addressbookPersonalVCardName() );
271 m_contactdb = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); 271 m_contactdb = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
272 272
273 m_inPersonal = true; 273 m_inPersonal = true;
274 m_curr_View = CardView; 274 m_curr_View = CardView;
275 275
276 }else{ 276 }else{
277 277
278 if ( !m_inPersonal ) 278 if ( !m_inPersonal )
279 return; 279 return;
280 280
281 // Remove vCard Backend and restore default 281 // Remove vCard Backend and restore default
282 m_contactdb->save(); 282 m_contactdb->save();
283 delete m_contactdb; 283 delete m_contactdb;
284 284
285 m_contactdb = m_storedDB; 285 m_contactdb = m_storedDB;
286 m_storedDB = 0l; 286 m_storedDB = 0l;
287 287
288 m_curr_View = TableView; 288 m_curr_View = TableView;
289 m_inPersonal = false; 289 m_inPersonal = false;
290 290
291 } 291 }
292 load(); 292 load();
293} 293}
294 294
295QStringList AbView::categories() 295QStringList AbView::categories()
296{ 296{
297 mCat.load( categoryFileName() ); 297 mCat.load( categoryFileName() );
298 QStringList categoryList = mCat.labels( "Contacts" ); 298 QStringList categoryList = mCat.labels( "Contacts" );
299 return categoryList; 299 return categoryList;
300} 300}
301 301
302// BEGIN: Slots 302// BEGIN: Slots
303void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, 303void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp,
304 bool , QString cat ) 304 bool , QString cat )
305{ 305{
306 qWarning( "void AbView::slotDoFind" ); 306 //qWarning( "void AbView::slotDoFind" );
307 307
308 // We reloading the data: Deselect Letterpicker 308 // We reloading the data: Deselect Letterpicker
309 emit signalClearLetterPicker(); 309 emit signalClearLetterPicker();
310 310
311 // Use the current Category if nothing else selected 311 // Use the current Category if nothing else selected
312 int category = 0; 312 int category = 0;
313 313
314 if ( cat.isEmpty() ) 314 if ( cat.isEmpty() )
315 category = m_curr_category; 315 category = m_curr_category;
316 else{ 316 else{
317 category = mCat.id("Contacts", cat ); 317 category = mCat.id("Contacts", cat );
318 } 318 }
319 319
320 qWarning ("Find in Category %d", category); 320 //qWarning ("Find in Category %d", category);
321 321
322 QRegExp r( str ); 322 QRegExp r( str );
323 r.setCaseSensitive( caseSensitive ); 323 r.setCaseSensitive( caseSensitive );
324 r.setWildcard( !useRegExp ); 324 r.setWildcard( !useRegExp );
325 325
326 // Get all matching entries out of the database 326 // Get all matching entries out of the database
327 m_list = m_contactdb->matchRegexp( r ); 327 m_list = m_contactdb->matchRegexp( r );
328 328
329 qWarning( "found: %d", m_list.count() ); 329 //qWarning( "found: %d", m_list.count() );
330 if ( m_list.count() == 0 ){ 330 if ( m_list.count() == 0 ){
331 emit signalNotFound(); 331 emit signalNotFound();
332 return; 332 return;
333 } 333 }
334 334
335 // Now remove all contacts with wrong category (if any selected) 335 // Now remove all contacts with wrong category (if any selected)
336 // This algorithm is a litte bit ineffective, but 336 // This algorithm is a litte bit ineffective, but
337 // we will not have a lot of matching entries.. 337 // we will not have a lot of matching entries..
338 clearForCategory(); 338 clearForCategory();
339 339
340 // Now show all found entries 340 // Now show all found entries
341 updateView( true ); 341 updateView( true );
342} 342}
343 343
344void AbView::offSearch() 344void AbView::offSearch()
345{ 345{
346 m_inSearch = false; 346 m_inSearch = false;
347 347
348 load(); 348 load();
349} 349}
350 350
351void AbView::slotSwitch(){ 351void AbView::slotSwitch(){
352 qWarning("AbView::slotSwitch()"); 352 //qWarning("AbView::slotSwitch()");
353 353
354 m_prev_View = m_curr_View; 354 m_prev_View = m_curr_View;
355 switch ( (int) m_curr_View ){ 355 switch ( (int) m_curr_View ){
356 case TableView: 356 case TableView:
357 qWarning("Switching to CardView"); 357 qWarning("Switching to CardView");
358 m_curr_View = CardView; 358 m_curr_View = CardView;
359 break; 359 break;
360 case CardView: 360 case CardView:
361 qWarning("Switching to TableView"); 361 qWarning("Switching to TableView");
362 m_curr_View = TableView; 362 m_curr_View = TableView;
363 break; 363 break;
364 } 364 }
365 updateView(); 365 updateView();
366 366
367} 367}
368 368
369// END: Slots 369// END: Slots
370 370
371void AbView::clearForCategory() 371void AbView::clearForCategory()
372{ 372{
373 OContactAccess::List::Iterator it; 373 OContactAccess::List::Iterator it;
374 // Now remove all contacts with wrong category if any category selected 374 // Now remove all contacts with wrong category if any category selected
375 375
376 OContactAccess::List allList = m_list; 376 OContactAccess::List allList = m_list;
377 if ( m_curr_category != -1 ){ 377 if ( m_curr_category != -1 ){
378 for ( it = allList.begin(); it != allList.end(); ++it ){ 378 for ( it = allList.begin(); it != allList.end(); ++it ){
379 if ( !contactCompare( *it, m_curr_category ) ){ 379 if ( !contactCompare( *it, m_curr_category ) ){
380 qWarning("Removing %d", (*it).uid()); 380 // qWarning("Removing %d", (*it).uid());
381 m_list.remove( (*it).uid() ); 381 m_list.remove( (*it).uid() );
382 } 382 }
383 } 383 }
384 } 384 }
385 385
386} 386}
387 387
388bool AbView::contactCompare( const OContact &cnt, int category ) 388bool AbView::contactCompare( const OContact &cnt, int category )
389{ 389{
390 qWarning ("bool AbView::contactCompare( const OContact &cnt, %d )", category); 390 //qWarning ("bool AbView::contactCompare( const OContact &cnt, %d )", category);
391 391
392 bool returnMe; 392 bool returnMe;
393 QArray<int> cats; 393 QArray<int> cats;
394 cats = cnt.categories(); 394 cats = cnt.categories();
395 395
396 qWarning ("Number of categories: %d", cats.count() ); 396 //qWarning ("Number of categories: %d", cats.count() );
397 397
398 returnMe = false; 398 returnMe = false;
399 if ( cats.count() == 0 && category == 0 ) 399 if ( cats.count() == 0 && category == 0 )
400 // Contacts with no category will just shown on "All" and "Unfiled" 400 // Contacts with no category will just shown on "All" and "Unfiled"
401 returnMe = true; 401 returnMe = true;
402 else { 402 else {
403 int i; 403 int i;
404 for ( i = 0; i < int(cats.count()); i++ ) { 404 for ( i = 0; i < int(cats.count()); i++ ) {
405 qWarning("Comparing %d with %d",cats[i],category ); 405 // qWarning("Comparing %d with %d",cats[i],category );
406 if ( cats[i] == category ) { 406 if ( cats[i] == category ) {
407 returnMe = true; 407 returnMe = true;
408 break; 408 break;
409 } 409 }
410 } 410 }
411 } 411 }
412 qWarning ("Return: %d", returnMe); 412 //qWarning ("Return: %d", returnMe);
413 return returnMe; 413 return returnMe;
414} 414}
415 415
416// In Some rare cases we have to update all lists.. 416// In Some rare cases we have to update all lists..
417void AbView::updateListinViews() 417void AbView::updateListinViews()
418{ 418{
419 m_abTable -> setContacts( m_list ); 419 m_abTable -> setContacts( m_list );
420 m_ablabel -> setContacts( m_list ); 420 m_ablabel -> setContacts( m_list );
421} 421}
422 422
423void AbView::updateView( bool newdata ) 423void AbView::updateView( bool newdata )
424{ 424{
425 qWarning("AbView::updateView()"); 425 //qWarning("AbView::updateView()");
426 426
427 if ( m_viewStack -> visibleWidget() ){ 427 if ( m_viewStack -> visibleWidget() ){
428 m_viewStack -> visibleWidget() -> clearFocus(); 428 m_viewStack -> visibleWidget() -> clearFocus();
429 } 429 }
430 430
431 // If we switching the view, we have to store some information 431 // If we switching the view, we have to store some information
432 if ( !newdata ){ 432 if ( !newdata ){
433 if ( m_list.count() ){ 433 if ( m_list.count() ){
434 switch ( (int) m_prev_View ) { 434 switch ( (int) m_prev_View ) {
435 case TableView: 435 case TableView:
436 m_curr_Contact = m_abTable -> currentEntry_UID(); 436 m_curr_Contact = m_abTable -> currentEntry_UID();
437 break; 437 break;
438 case CardView: 438 case CardView:
439 m_curr_Contact = m_ablabel -> currentEntry_UID(); 439 m_curr_Contact = m_ablabel -> currentEntry_UID();
440 break; 440 break;
441 } 441 }
442 }else 442 }else
443 m_curr_Contact = 0; 443 m_curr_Contact = 0;
444 } 444 }
445 445
446 // Feed all views with new lists 446 // Feed all views with new lists
447 if ( newdata ) 447 if ( newdata )
448 updateListinViews(); 448 updateListinViews();
449 449
450 // Tell the world that the view is changed 450 // Tell the world that the view is changed
451 if ( m_curr_View != m_prev_View ) 451 if ( m_curr_View != m_prev_View )
452 emit signalViewSwitched ( (int) m_curr_View ); 452 emit signalViewSwitched ( (int) m_curr_View );
453 453
454 m_prev_View = m_curr_View; 454 m_prev_View = m_curr_View;
455 455
456 // Switch to new View 456 // Switch to new View
457 switch ( (int) m_curr_View ) { 457 switch ( (int) m_curr_View ) {
458 case TableView: 458 case TableView:
459 m_abTable -> setChoiceSelection( m_orderedFields ); 459 m_abTable -> setChoiceSelection( m_orderedFields );
460 if ( m_curr_Contact != 0 ) 460 if ( m_curr_Contact != 0 )
461 m_abTable -> selectContact ( m_curr_Contact ); 461 m_abTable -> selectContact ( m_curr_Contact );
462 m_abTable -> setFocus(); 462 m_abTable -> setFocus();
463 break; 463 break;
464 case CardView: 464 case CardView:
465 if ( m_curr_Contact != 0 ) 465 if ( m_curr_Contact != 0 )
466 m_ablabel -> selectContact( m_curr_Contact ); 466 m_ablabel -> selectContact( m_curr_Contact );
467 m_ablabel -> setFocus(); 467 m_ablabel -> setFocus();
468 break; 468 break;
469 } 469 }
470 470
471 // Raise the current View 471 // Raise the current View
472 m_viewStack -> raiseWidget( m_curr_View ); 472 m_viewStack -> raiseWidget( m_curr_View );
473} 473}
474 474
475 475
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp
index d14ac51..d830ad3 100644
--- a/core/pim/addressbook/contacteditor.cpp
+++ b/core/pim/addressbook/contacteditor.cpp
@@ -1,1754 +1,1797 @@
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#include "addresspicker.h" 23#include "addresspicker.h"
24#include "ocontactfields.h" 24#include "ocontactfields.h"
25 25
26#include <qpe/categoryselect.h> 26#include <qpe/categoryselect.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qpe/qpedialog.h> 28#include <qpe/qpedialog.h>
29#include <qpe/timeconversion.h> 29#include <qpe/timeconversion.h>
30#include <opie/ocontact.h> 30#include <opie/ocontact.h>
31#include <qpe/resource.h> 31#include <qpe/resource.h>
32 32
33#include <qcombobox.h> 33#include <qcombobox.h>
34#include <qlabel.h> 34#include <qlabel.h>
35#include <qtabwidget.h> 35#include <qtabwidget.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qlineedit.h> 37#include <qlineedit.h>
38#include <qmultilineedit.h> 38#include <qmultilineedit.h>
39#include <qscrollview.h> 39#include <qscrollview.h>
40#include <qtoolbutton.h> 40#include <qtoolbutton.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qmainwindow.h> 42#include <qmainwindow.h>
43#include <qvaluelist.h> 43#include <qvaluelist.h>
44#include <qpopupmenu.h> 44#include <qpopupmenu.h>
45#include <qlistbox.h> 45#include <qlistbox.h>
46#include <qhbox.h> 46#include <qhbox.h>
47#include <qaction.h> 47#include <qaction.h>
48#include <qiconset.h> 48#include <qiconset.h>
49#include <qmessagebox.h> 49#include <qmessagebox.h>
50 50
51#include <assert.h> 51#include <assert.h>
52 52
53static inline bool containsAlphaNum( const QString &str ); 53static inline bool containsAlphaNum( const QString &str );
54static inline bool constainsWhiteSpace( const QString &str ); 54static inline bool constainsWhiteSpace( const QString &str );
55 55
56// helper functions, convert our comma delimited list to proper 56// helper functions, convert our comma delimited list to proper
57// file format... 57// file format...
58void parseEmailFrom( const QString &txt, QString &strDefaultEmail, 58void parseEmailFrom( const QString &txt, QString &strDefaultEmail,
59 QString &strAll ); 59 QString &strAll );
60 60
61// helper convert from file format to comma delimited... 61// helper convert from file format to comma delimited...
62void parseEmailTo( const QString &strDefaultEmail, 62void parseEmailTo( const QString &strDefaultEmail,
63 const QString &strOtherEmail, QString &strBack ); 63 const QString &strOtherEmail, QString &strBack );
64 64
65 ContactEditor::ContactEditor(const OContact &entry, 65 ContactEditor::ContactEditor(const OContact &entry,
66 QWidget *parent, 66 QWidget *parent,
67 const char *name, 67 const char *name,
68 WFlags fl ) 68 WFlags fl )
69 : QDialog( parent, name, TRUE, fl ), 69 : QDialog( parent, name, TRUE, fl ),
70 m_personalView ( false ) 70 defaultEmailChooserPosition( -1 ),
71 71 m_personalView ( false ),
72 cmbDefaultEmail( 0 ),
73 initializing ( false )
72{ 74{
73 75
76 initializing = true;
77
74 init(); 78 init();
75 setEntry( entry ); 79 setEntry( entry );
76 cmbDefaultEmail = 0; 80 // cmbDefaultEmail = 0;
77 defaultEmailChooserPosition = -1; 81 // defaultEmailChooserPosition = -1;
82
83 initializing = false;
78} 84}
79 85
80ContactEditor::~ContactEditor() { 86ContactEditor::~ContactEditor() {
81} 87}
82 88
83void ContactEditor::init() { 89void ContactEditor::init() {
90 qWarning("init() START");
84 91
85 useFullName = true; 92 useFullName = true;
86 93
87 uint i = 0; 94 uint i = 0;
88 95
89 QStringList trlChooserNames; 96 QStringList trlChooserNames;
90 97
91 for (i = 0; i <= 6; i++) { 98 for (i = 0; i <= 6; i++) {
92 slHomeAddress.append( "" ); 99 slHomeAddress.append( "" );
93 slBusinessAddress.append( "" ); 100 slBusinessAddress.append( "" );
94 } 101 }
95 102
96 trlChooserNames = OContactFields::trphonefields( false ); 103 trlChooserNames = OContactFields::trphonefields( false );
97 slChooserNames = OContactFields::untrphonefields( false ); 104 slChooserNames = OContactFields::untrphonefields( false );
98 slDynamicEntries = OContactFields::untrdetailsfields( false ); 105 slDynamicEntries = OContactFields::untrdetailsfields( false );
99 trlDynamicEntries = OContactFields::trdetailsfields( false ); 106 trlDynamicEntries = OContactFields::trdetailsfields( false );
100 107
101 // Ok, we have to remove elements from the list of dynamic entries 108 // Ok, we have to remove elements from the list of dynamic entries
102 // which are now stored in special (not dynamic) widgets.. 109 // which are now stored in special (not dynamic) widgets..
103 // Otherwise we will get problems with field assignments! (se) 110 // Otherwise we will get problems with field assignments! (se)
104 slDynamicEntries.remove("Anniversary"); 111 slDynamicEntries.remove("Anniversary");
105 slDynamicEntries.remove("Birthday"); 112 slDynamicEntries.remove("Birthday");
106 slDynamicEntries.remove("Gender"); 113 slDynamicEntries.remove("Gender");
107 114
108 // The same with translated fields.. But I will 115 // The same with translated fields.. But I will
109 // use the translation map to avoid mismatches.. 116 // use the translation map to avoid mismatches..
110 QMap<int, QString> translMap = OContactFields::idToTrFields(); 117 QMap<int, QString> translMap = OContactFields::idToTrFields();
111 trlDynamicEntries.remove( translMap[Qtopia::Anniversary] ); 118 trlDynamicEntries.remove( translMap[Qtopia::Anniversary] );
112 trlDynamicEntries.remove( translMap[Qtopia::Birthday] ); 119 trlDynamicEntries.remove( translMap[Qtopia::Birthday] );
113 trlDynamicEntries.remove( translMap[Qtopia::Gender] ); 120 trlDynamicEntries.remove( translMap[Qtopia::Gender] );
114 121
115 // Last Check to be sure.. 122 // Last Check to be sure..
116 assert( slDynamicEntries.count() == trlDynamicEntries.count() ); 123 assert( slDynamicEntries.count() == trlDynamicEntries.count() );
117 assert( slChooserNames.count() == trlChooserNames.count() ); 124 assert( slChooserNames.count() == trlChooserNames.count() );
118 125
119 for (i = 0; i < slChooserNames.count(); i++) 126 for (i = 0; i < slChooserNames.count(); i++)
120 slChooserValues.append(""); 127 slChooserValues.append("");
121 128
122 129
123 QVBoxLayout *vb = new QVBoxLayout( this ); 130 QVBoxLayout *vb = new QVBoxLayout( this );
124 131
125 tabMain = new QTabWidget( this ); 132 tabMain = new QTabWidget( this );
126 vb->addWidget( tabMain ); 133 vb->addWidget( tabMain );
127 134
128 QWidget *tabViewport = new QWidget ( tabMain ); 135 QWidget *tabViewport = new QWidget ( tabMain );
129 136
130 vb = new QVBoxLayout( tabViewport ); 137 vb = new QVBoxLayout( tabViewport );
131 138
132 svGeneral = new QScrollView( tabViewport ); 139 svGeneral = new QScrollView( tabViewport );
133 vb->addWidget( svGeneral, 0, 0 ); 140 vb->addWidget( svGeneral, 0, 0 );
134 svGeneral->setResizePolicy( QScrollView::AutoOneFit ); 141 svGeneral->setResizePolicy( QScrollView::AutoOneFit );
135 svGeneral->setFrameStyle( QFrame::NoFrame ); 142 svGeneral->setFrameStyle( QFrame::NoFrame );
136 143
137 QWidget *container = new QWidget( svGeneral->viewport() ); 144 QWidget *container = new QWidget( svGeneral->viewport() );
138 svGeneral->addChild( container ); 145 svGeneral->addChild( container );
139 146
140 QGridLayout *gl = new QGridLayout( container, 1, 1, 2, 4 ); 147 QGridLayout *gl = new QGridLayout( container, 1, 1, 2, 4 );
141 gl->setResizeMode( QLayout::FreeResize ); 148 gl->setResizeMode( QLayout::FreeResize );
142 149
143 btnFullName = new QPushButton( tr( "Full Name..." ), container ); 150 btnFullName = new QPushButton( tr( "Full Name..." ), container );
144 gl->addWidget( btnFullName, 0, 0 ); 151 gl->addWidget( btnFullName, 0, 0 );
145 txtFullName = new QLineEdit( container ); 152 txtFullName = new QLineEdit( container );
146 gl->addWidget( txtFullName, 0, 1 ); 153 gl->addWidget( txtFullName, 0, 1 );
147 154
148 QLabel *l = new QLabel( tr( "Job Title" ), container ); 155 QLabel *l = new QLabel( tr( "Job Title" ), container );
149 gl->addWidget( l, 1, 0 ); 156 gl->addWidget( l, 1, 0 );
150 txtJobTitle = new QLineEdit( container ); 157 txtJobTitle = new QLineEdit( container );
151 gl->addWidget( txtJobTitle, 1, 1 ); 158 gl->addWidget( txtJobTitle, 1, 1 );
152 159
153 l = new QLabel( tr( "Organization" ), container ); 160 l = new QLabel( tr( "Organization" ), container );
154 gl->addWidget( l, 2, 0 ); 161 gl->addWidget( l, 2, 0 );
155 txtOrganization = new QLineEdit( container ); 162 txtOrganization = new QLineEdit( container );
156 gl->addWidget( txtOrganization, 2, 1 ); 163 gl->addWidget( txtOrganization, 2, 1 );
157 164
158 cmbChooserField1 = new QComboBox( FALSE, container ); 165 cmbChooserField1 = new QComboBox( FALSE, container );
159 cmbChooserField1->setMaximumWidth( 90 ); 166 cmbChooserField1->setMaximumWidth( 90 );
160 gl->addWidget( cmbChooserField1, 3, 0 ); 167 gl->addWidget( cmbChooserField1, 3, 0 );
161 txtChooserField1 = new QLineEdit( container ); 168 txtChooserField1 = new QLineEdit( container );
162 gl->addWidget( txtChooserField1, 3, 1 ); 169 gl->addWidget( txtChooserField1, 3, 1 );
163 170
164 cmbChooserField2 = new QComboBox( FALSE, container ); 171 cmbChooserField2 = new QComboBox( FALSE, container );
165 cmbChooserField2->setMaximumWidth( 90 ); 172 cmbChooserField2->setMaximumWidth( 90 );
166 gl->addWidget( cmbChooserField2, 4, 0 ); 173 gl->addWidget( cmbChooserField2, 4, 0 );
167 txtChooserField2 = new QLineEdit( container ); 174 txtChooserField2 = new QLineEdit( container );
168 gl->addWidget( txtChooserField2, 4, 1 ); 175 gl->addWidget( txtChooserField2, 4, 1 );
169 176
170 cmbChooserField3 = new QComboBox( FALSE, container ); 177 cmbChooserField3 = new QComboBox( FALSE, container );
171 cmbChooserField3->setMaximumWidth( 90 ); 178 cmbChooserField3->setMaximumWidth( 90 );
172 gl->addWidget( cmbChooserField3, 5, 0 ); 179 gl->addWidget( cmbChooserField3, 5, 0 );
173 txtChooserField3 = new QLineEdit( container ); 180 txtChooserField3 = new QLineEdit( container );
174 gl->addWidget( txtChooserField3, 5, 1 ); 181 gl->addWidget( txtChooserField3, 5, 1 );
175 182
176 l = new QLabel( tr( "File As" ), container ); 183 l = new QLabel( tr( "File As" ), container );
177 gl->addWidget( l, 6, 0 ); 184 gl->addWidget( l, 6, 0 );
178 cmbFileAs = new QComboBox( TRUE, container ); 185 cmbFileAs = new QComboBox( TRUE, container );
179 gl->addWidget( cmbFileAs, 6, 1 ); 186 gl->addWidget( cmbFileAs, 6, 1 );
180 187
181 labCat = new QLabel( tr( "Category" ), container ); 188 labCat = new QLabel( tr( "Category" ), container );
182 gl->addWidget( labCat, 7, 0 ); 189 gl->addWidget( labCat, 7, 0 );
183 cmbCat = new CategorySelect( container ); 190 cmbCat = new CategorySelect( container );
184 gl->addWidget( cmbCat, 7, 1 ); 191 gl->addWidget( cmbCat, 7, 1 );
185 labCat->show(); 192 labCat->show();
186 cmbCat->show(); 193 cmbCat->show();
187 194
188 btnNote = new QPushButton( tr( "Notes..." ), container ); 195 btnNote = new QPushButton( tr( "Notes..." ), container );
189 gl->addWidget( btnNote, 8, 1 ); 196 gl->addWidget( btnNote, 8, 1 );
190 197
191 tabMain->insertTab( tabViewport, tr( "General" ) ); 198 tabMain->insertTab( tabViewport, tr( "General" ) );
192 199
193 tabViewport = new QWidget ( tabMain ); 200 tabViewport = new QWidget ( tabMain );
194 201
195 vb = new QVBoxLayout( tabViewport ); 202 vb = new QVBoxLayout( tabViewport );
196 203
197 svAddress = new QScrollView( tabViewport ); 204 svAddress = new QScrollView( tabViewport );
198 vb->addWidget( svAddress, 0, 0 ); 205 vb->addWidget( svAddress, 0, 0 );
199 svAddress->setResizePolicy( QScrollView::AutoOneFit ); 206 svAddress->setResizePolicy( QScrollView::AutoOneFit );
200 svAddress->setFrameStyle( QFrame::NoFrame ); 207 svAddress->setFrameStyle( QFrame::NoFrame );
201 208
202 container = new QWidget( svAddress->viewport() ); 209 container = new QWidget( svAddress->viewport() );
203 svAddress->addChild( container ); 210 svAddress->addChild( container );
204 211
205 gl = new QGridLayout( container, 8, 3, 2, 4 ); // row 7 QSpacerItem 212 gl = new QGridLayout( container, 8, 3, 2, 4 ); // row 7 QSpacerItem
206 213
207 cmbAddress = new QComboBox( FALSE, container ); 214 cmbAddress = new QComboBox( FALSE, container );
208 cmbAddress->insertItem( tr( "Business" ) ); 215 cmbAddress->insertItem( tr( "Business" ) );
209 cmbAddress->insertItem( tr( "Home" ) ); 216 cmbAddress->insertItem( tr( "Home" ) );
210 gl->addMultiCellWidget( cmbAddress, 0, 0, 0, 1 ); 217 gl->addMultiCellWidget( cmbAddress, 0, 0, 0, 1 );
211 218
212 l = new QLabel( tr( "Address" ), container ); 219 l = new QLabel( tr( "Address" ), container );
213 gl->addWidget( l, 1, 0 ); 220 gl->addWidget( l, 1, 0 );
214 txtAddress = new QLineEdit( container ); 221 txtAddress = new QLineEdit( container );
215 gl->addMultiCellWidget( txtAddress, 1, 1, 1, 2 ); 222 gl->addMultiCellWidget( txtAddress, 1, 1, 1, 2 );
216 223
217 l = new QLabel( tr( "City" ), container ); 224 l = new QLabel( tr( "City" ), container );
218 gl->addWidget( l, 2, 0 ); 225 gl->addWidget( l, 2, 0 );
219 txtCity = new QLineEdit( container ); 226 txtCity = new QLineEdit( container );
220 gl->addMultiCellWidget( txtCity, 2, 2, 1, 2 ); 227 gl->addMultiCellWidget( txtCity, 2, 2, 1, 2 );
221 228
222 l = new QLabel( tr( "State" ), container ); 229 l = new QLabel( tr( "State" ), container );
223 gl->addWidget( l, 3, 0 ); 230 gl->addWidget( l, 3, 0 );
224 txtState = new QLineEdit( container ); 231 txtState = new QLineEdit( container );
225 gl->addMultiCellWidget( txtState, 3, 3, 1, 2 ); 232 gl->addMultiCellWidget( txtState, 3, 3, 1, 2 );
226 233
227 l = new QLabel( tr( "Zip Code" ), container ); 234 l = new QLabel( tr( "Zip Code" ), container );
228 gl->addWidget( l, 4, 0 ); 235 gl->addWidget( l, 4, 0 );
229 txtZip = new QLineEdit( container ); 236 txtZip = new QLineEdit( container );
230 gl->addMultiCellWidget( txtZip, 4, 4, 1, 2 ); 237 gl->addMultiCellWidget( txtZip, 4, 4, 1, 2 );
231 238
232 l = new QLabel( tr( "Country" ), container ); 239 l = new QLabel( tr( "Country" ), container );
233 gl->addWidget( l, 5, 0 ); 240 gl->addWidget( l, 5, 0 );
234 cmbCountry = new QComboBox( TRUE, container ); 241 cmbCountry = new QComboBox( TRUE, container );
235 cmbCountry->insertItem( tr( "" ) ); 242 cmbCountry->insertItem( tr( "" ) );
236 cmbCountry->insertItem( tr ( "United States" ) ); 243 cmbCountry->insertItem( tr ( "United States" ) );
237 cmbCountry->insertItem( tr ( "United Kingdom" ) ); 244 cmbCountry->insertItem( tr ( "United Kingdom" ) );
238 cmbCountry->insertItem( tr ( "Afghanistan" ) ); 245 cmbCountry->insertItem( tr ( "Afghanistan" ) );
239 cmbCountry->insertItem( tr ( "Albania" ) ); 246 cmbCountry->insertItem( tr ( "Albania" ) );
240 cmbCountry->insertItem( tr ( "Algeria" ) ); 247 cmbCountry->insertItem( tr ( "Algeria" ) );
241 cmbCountry->insertItem( tr ( "American Samoa" ) ); 248 cmbCountry->insertItem( tr ( "American Samoa" ) );
242 cmbCountry->insertItem( tr ( "Andorra" ) ); 249 cmbCountry->insertItem( tr ( "Andorra" ) );
243 cmbCountry->insertItem( tr ( "Angola" ) ); 250 cmbCountry->insertItem( tr ( "Angola" ) );
244 cmbCountry->insertItem( tr ( "Anguilla" ) ); 251 cmbCountry->insertItem( tr ( "Anguilla" ) );
245 cmbCountry->insertItem( tr ( "Antarctica" ) ); 252 cmbCountry->insertItem( tr ( "Antarctica" ) );
246 cmbCountry->insertItem( tr ( "Argentina" ) ); 253 cmbCountry->insertItem( tr ( "Argentina" ) );
247 cmbCountry->insertItem( tr ( "Armenia" ) ); 254 cmbCountry->insertItem( tr ( "Armenia" ) );
248 cmbCountry->insertItem( tr ( "Aruba" ) ); 255 cmbCountry->insertItem( tr ( "Aruba" ) );
249 cmbCountry->insertItem( tr ( "Australia" ) ); 256 cmbCountry->insertItem( tr ( "Australia" ) );
250 cmbCountry->insertItem( tr ( "Austria" ) ); 257 cmbCountry->insertItem( tr ( "Austria" ) );
251 cmbCountry->insertItem( tr ( "Azerbaijan" ) ); 258 cmbCountry->insertItem( tr ( "Azerbaijan" ) );
252 cmbCountry->insertItem( tr ( "Bahamas" ) ); 259 cmbCountry->insertItem( tr ( "Bahamas" ) );
253 cmbCountry->insertItem( tr ( "Bahrain" ) ); 260 cmbCountry->insertItem( tr ( "Bahrain" ) );
254 cmbCountry->insertItem( tr ( "Bangladesh" ) ); 261 cmbCountry->insertItem( tr ( "Bangladesh" ) );
255 cmbCountry->insertItem( tr ( "Barbados" ) ); 262 cmbCountry->insertItem( tr ( "Barbados" ) );
256 cmbCountry->insertItem( tr ( "Belarus" ) ); 263 cmbCountry->insertItem( tr ( "Belarus" ) );
257 cmbCountry->insertItem( tr ( "Belgium" ) ); 264 cmbCountry->insertItem( tr ( "Belgium" ) );
258 cmbCountry->insertItem( tr ( "Belize" ) ); 265 cmbCountry->insertItem( tr ( "Belize" ) );
259 cmbCountry->insertItem( tr ( "Benin" ) ); 266 cmbCountry->insertItem( tr ( "Benin" ) );
260 cmbCountry->insertItem( tr ( "Bermuda" ) ); 267 cmbCountry->insertItem( tr ( "Bermuda" ) );
261 cmbCountry->insertItem( tr ( "Bhutan" ) ); 268 cmbCountry->insertItem( tr ( "Bhutan" ) );
262 cmbCountry->insertItem( tr ( "Bolivia" ) ); 269 cmbCountry->insertItem( tr ( "Bolivia" ) );
263 cmbCountry->insertItem( tr ( "Botswana" ) ); 270 cmbCountry->insertItem( tr ( "Botswana" ) );
264 cmbCountry->insertItem( tr ( "Bouvet Island" ) ); 271 cmbCountry->insertItem( tr ( "Bouvet Island" ) );
265 cmbCountry->insertItem( tr ( "Brazil" ) ); 272 cmbCountry->insertItem( tr ( "Brazil" ) );
266 cmbCountry->insertItem( tr ( "Brunei Darussalam" ) ); 273 cmbCountry->insertItem( tr ( "Brunei Darussalam" ) );
267 cmbCountry->insertItem( tr ( "Bulgaria" ) ); 274 cmbCountry->insertItem( tr ( "Bulgaria" ) );
268 cmbCountry->insertItem( tr ( "Burkina Faso" ) ); 275 cmbCountry->insertItem( tr ( "Burkina Faso" ) );
269 cmbCountry->insertItem( tr ( "Burundi" ) ); 276 cmbCountry->insertItem( tr ( "Burundi" ) );
270 cmbCountry->insertItem( tr ( "Cambodia" ) ); 277 cmbCountry->insertItem( tr ( "Cambodia" ) );
271 cmbCountry->insertItem( tr ( "Cameroon" ) ); 278 cmbCountry->insertItem( tr ( "Cameroon" ) );
272 cmbCountry->insertItem( tr ( "Canada" ) ); 279 cmbCountry->insertItem( tr ( "Canada" ) );
273 cmbCountry->insertItem( tr ( "Cape Verde" ) ); 280 cmbCountry->insertItem( tr ( "Cape Verde" ) );
274 cmbCountry->insertItem( tr ( "Cayman Islands" ) ); 281 cmbCountry->insertItem( tr ( "Cayman Islands" ) );
275 cmbCountry->insertItem( tr ( "Chad" ) ); 282 cmbCountry->insertItem( tr ( "Chad" ) );
276 cmbCountry->insertItem( tr ( "Chile" ) ); 283 cmbCountry->insertItem( tr ( "Chile" ) );
277 cmbCountry->insertItem( tr ( "China" ) ); 284 cmbCountry->insertItem( tr ( "China" ) );
278 cmbCountry->insertItem( tr ( "Christmas Island" ) ); 285 cmbCountry->insertItem( tr ( "Christmas Island" ) );
279 cmbCountry->insertItem( tr ( "Colombia" ) ); 286 cmbCountry->insertItem( tr ( "Colombia" ) );
280 cmbCountry->insertItem( tr ( "Comoros" ) ); 287 cmbCountry->insertItem( tr ( "Comoros" ) );
281 cmbCountry->insertItem( tr ( "Congo" ) ); 288 cmbCountry->insertItem( tr ( "Congo" ) );
282 cmbCountry->insertItem( tr ( "Cook Island" ) ); 289 cmbCountry->insertItem( tr ( "Cook Island" ) );
283 cmbCountry->insertItem( tr ( "Costa Rica" ) ); 290 cmbCountry->insertItem( tr ( "Costa Rica" ) );
284 cmbCountry->insertItem( tr ( "Cote d'Ivoire" ) ); 291 cmbCountry->insertItem( tr ( "Cote d'Ivoire" ) );
285 cmbCountry->insertItem( tr ( "Croatia" ) ); 292 cmbCountry->insertItem( tr ( "Croatia" ) );
286 cmbCountry->insertItem( tr ( "Cuba" ) ); 293 cmbCountry->insertItem( tr ( "Cuba" ) );
287 cmbCountry->insertItem( tr ( "Cyprus" ) ); 294 cmbCountry->insertItem( tr ( "Cyprus" ) );
288 cmbCountry->insertItem( tr ( "Czech Republic" ) ); 295 cmbCountry->insertItem( tr ( "Czech Republic" ) );
289 cmbCountry->insertItem( tr ( "Denmark" ) ); 296 cmbCountry->insertItem( tr ( "Denmark" ) );
290 cmbCountry->insertItem( tr ( "Djibouti" ) ); 297 cmbCountry->insertItem( tr ( "Djibouti" ) );
291 cmbCountry->insertItem( tr ( "Dominica" ) ); 298 cmbCountry->insertItem( tr ( "Dominica" ) );
292 cmbCountry->insertItem( tr ( "Dominican Republic" ) ); 299 cmbCountry->insertItem( tr ( "Dominican Republic" ) );
293 cmbCountry->insertItem( tr ( "East Timor" ) ); 300 cmbCountry->insertItem( tr ( "East Timor" ) );
294 cmbCountry->insertItem( tr ( "Ecuador" ) ); 301 cmbCountry->insertItem( tr ( "Ecuador" ) );
295 cmbCountry->insertItem( tr ( "Egypt" ) ); 302 cmbCountry->insertItem( tr ( "Egypt" ) );
296 cmbCountry->insertItem( tr ( "El Salvador" ) ); 303 cmbCountry->insertItem( tr ( "El Salvador" ) );
297 cmbCountry->insertItem( tr ( "Equatorial Guinea" ) ); 304 cmbCountry->insertItem( tr ( "Equatorial Guinea" ) );
298 cmbCountry->insertItem( tr ( "Eritrea" ) ); 305 cmbCountry->insertItem( tr ( "Eritrea" ) );
299 cmbCountry->insertItem( tr ( "Estonia" ) ); 306 cmbCountry->insertItem( tr ( "Estonia" ) );
300 cmbCountry->insertItem( tr ( "Ethiopia" ) ); 307 cmbCountry->insertItem( tr ( "Ethiopia" ) );
301 cmbCountry->insertItem( tr ( "Falkland Islands" ) ); 308 cmbCountry->insertItem( tr ( "Falkland Islands" ) );
302 cmbCountry->insertItem( tr ( "Faroe Islands" ) ); 309 cmbCountry->insertItem( tr ( "Faroe Islands" ) );
303 cmbCountry->insertItem( tr ( "Fiji" ) ); 310 cmbCountry->insertItem( tr ( "Fiji" ) );
304 cmbCountry->insertItem( tr ( "Finland" ) ); 311 cmbCountry->insertItem( tr ( "Finland" ) );
305 cmbCountry->insertItem( tr ( "France" ) ); 312 cmbCountry->insertItem( tr ( "France" ) );
306 cmbCountry->insertItem( tr ( "French Guiana" ) ); 313 cmbCountry->insertItem( tr ( "French Guiana" ) );
307 cmbCountry->insertItem( tr ( "French Polynesia" ) ); 314 cmbCountry->insertItem( tr ( "French Polynesia" ) );
308 cmbCountry->insertItem( tr ( "Gabon" ) ); 315 cmbCountry->insertItem( tr ( "Gabon" ) );
309 cmbCountry->insertItem( tr ( "Gambia" ) ); 316 cmbCountry->insertItem( tr ( "Gambia" ) );
310 cmbCountry->insertItem( tr ( "Georgia" ) ); 317 cmbCountry->insertItem( tr ( "Georgia" ) );
311 cmbCountry->insertItem( tr ( "Germany" ) ); 318 cmbCountry->insertItem( tr ( "Germany" ) );
312 cmbCountry->insertItem( tr ( "Ghana" ) ); 319 cmbCountry->insertItem( tr ( "Ghana" ) );
313 cmbCountry->insertItem( tr ( "Gibraltar" ) ); 320 cmbCountry->insertItem( tr ( "Gibraltar" ) );
314 cmbCountry->insertItem( tr ( "Greece" ) ); 321 cmbCountry->insertItem( tr ( "Greece" ) );
315 cmbCountry->insertItem( tr ( "Greenland" ) ); 322 cmbCountry->insertItem( tr ( "Greenland" ) );
316 cmbCountry->insertItem( tr ( "Grenada" ) ); 323 cmbCountry->insertItem( tr ( "Grenada" ) );
317 cmbCountry->insertItem( tr ( "Guadeloupe" ) ); 324 cmbCountry->insertItem( tr ( "Guadeloupe" ) );
318 cmbCountry->insertItem( tr ( "Guam" ) ); 325 cmbCountry->insertItem( tr ( "Guam" ) );
319 cmbCountry->insertItem( tr ( "Guatemala" ) ); 326 cmbCountry->insertItem( tr ( "Guatemala" ) );
320 cmbCountry->insertItem( tr ( "Guinea" ) ); 327 cmbCountry->insertItem( tr ( "Guinea" ) );
321 cmbCountry->insertItem( tr ( "Guinea-Bissau" ) ); 328 cmbCountry->insertItem( tr ( "Guinea-Bissau" ) );
322 cmbCountry->insertItem( tr ( "Guyana" ) ); 329 cmbCountry->insertItem( tr ( "Guyana" ) );
323 cmbCountry->insertItem( tr ( "Haiti" ) ); 330 cmbCountry->insertItem( tr ( "Haiti" ) );
324 cmbCountry->insertItem( tr ( "Holy See" ) ); 331 cmbCountry->insertItem( tr ( "Holy See" ) );
325 cmbCountry->insertItem( tr ( "Honduras" ) ); 332 cmbCountry->insertItem( tr ( "Honduras" ) );
326 cmbCountry->insertItem( tr ( "Hong Kong" ) ); 333 cmbCountry->insertItem( tr ( "Hong Kong" ) );
327 cmbCountry->insertItem( tr ( "Hungary" ) ); 334 cmbCountry->insertItem( tr ( "Hungary" ) );
328 cmbCountry->insertItem( tr ( "Iceland" ) ); 335 cmbCountry->insertItem( tr ( "Iceland" ) );
329 cmbCountry->insertItem( tr ( "India" ) ); 336 cmbCountry->insertItem( tr ( "India" ) );
330 cmbCountry->insertItem( tr ( "Indonesia" ) ); 337 cmbCountry->insertItem( tr ( "Indonesia" ) );
331 cmbCountry->insertItem( tr ( "Ireland" ) ); 338 cmbCountry->insertItem( tr ( "Ireland" ) );
332 cmbCountry->insertItem( tr ( "Israel" ) ); 339 cmbCountry->insertItem( tr ( "Israel" ) );
333 cmbCountry->insertItem( tr ( "Italy" ) ); 340 cmbCountry->insertItem( tr ( "Italy" ) );
334 cmbCountry->insertItem( tr ( "Jamaica" ) ); 341 cmbCountry->insertItem( tr ( "Jamaica" ) );
335 cmbCountry->insertItem( tr ( "Japan" ) ); 342 cmbCountry->insertItem( tr ( "Japan" ) );
336 cmbCountry->insertItem( tr ( "Jordan" ) ); 343 cmbCountry->insertItem( tr ( "Jordan" ) );
337 cmbCountry->insertItem( tr ( "Kazakhstan" ) ); 344 cmbCountry->insertItem( tr ( "Kazakhstan" ) );
338 cmbCountry->insertItem( tr ( "Kenya" ) ); 345 cmbCountry->insertItem( tr ( "Kenya" ) );
339 cmbCountry->insertItem( tr ( "Kiribati" ) ); 346 cmbCountry->insertItem( tr ( "Kiribati" ) );
340 cmbCountry->insertItem( tr ( "Korea" ) ); 347 cmbCountry->insertItem( tr ( "Korea" ) );
341 cmbCountry->insertItem( tr ( "Kuwait" ) ); 348 cmbCountry->insertItem( tr ( "Kuwait" ) );
342 cmbCountry->insertItem( tr ( "Kyrgyzstan" ) ); 349 cmbCountry->insertItem( tr ( "Kyrgyzstan" ) );
343 cmbCountry->insertItem( tr ( "Laos" ) ); 350 cmbCountry->insertItem( tr ( "Laos" ) );
344 cmbCountry->insertItem( tr ( "Latvia" ) ); 351 cmbCountry->insertItem( tr ( "Latvia" ) );
345 cmbCountry->insertItem( tr ( "Lebanon" ) ); 352 cmbCountry->insertItem( tr ( "Lebanon" ) );
346 cmbCountry->insertItem( tr ( "Lesotho" ) ); 353 cmbCountry->insertItem( tr ( "Lesotho" ) );
347 cmbCountry->insertItem( tr ( "Liberia" ) ); 354 cmbCountry->insertItem( tr ( "Liberia" ) );
348 cmbCountry->insertItem( tr ( "Liechtenstein" ) ); 355 cmbCountry->insertItem( tr ( "Liechtenstein" ) );
349 cmbCountry->insertItem( tr ( "Lithuania" ) ); 356 cmbCountry->insertItem( tr ( "Lithuania" ) );
350 cmbCountry->insertItem( tr ( "Luxembourg" ) ); 357 cmbCountry->insertItem( tr ( "Luxembourg" ) );
351 cmbCountry->insertItem( tr ( "Macau" ) ); 358 cmbCountry->insertItem( tr ( "Macau" ) );
352 cmbCountry->insertItem( tr ( "Macedonia" ) ); 359 cmbCountry->insertItem( tr ( "Macedonia" ) );
353 cmbCountry->insertItem( tr ( "Madagascar" ) ); 360 cmbCountry->insertItem( tr ( "Madagascar" ) );
354 cmbCountry->insertItem( tr ( "Malawi" ) ); 361 cmbCountry->insertItem( tr ( "Malawi" ) );
355 cmbCountry->insertItem( tr ( "Malaysia" ) ); 362 cmbCountry->insertItem( tr ( "Malaysia" ) );
356 cmbCountry->insertItem( tr ( "Maldives" ) ); 363 cmbCountry->insertItem( tr ( "Maldives" ) );
357 cmbCountry->insertItem( tr ( "Mali" ) ); 364 cmbCountry->insertItem( tr ( "Mali" ) );
358 cmbCountry->insertItem( tr ( "Malta" ) ); 365 cmbCountry->insertItem( tr ( "Malta" ) );
359 cmbCountry->insertItem( tr ( "Martinique" ) ); 366 cmbCountry->insertItem( tr ( "Martinique" ) );
360 cmbCountry->insertItem( tr ( "Mauritania" ) ); 367 cmbCountry->insertItem( tr ( "Mauritania" ) );
361 cmbCountry->insertItem( tr ( "Mauritius" ) ); 368 cmbCountry->insertItem( tr ( "Mauritius" ) );
362 cmbCountry->insertItem( tr ( "Mayotte" ) ); 369 cmbCountry->insertItem( tr ( "Mayotte" ) );
363 cmbCountry->insertItem( tr ( "Mexico" ) ); 370 cmbCountry->insertItem( tr ( "Mexico" ) );
364 cmbCountry->insertItem( tr ( "Micronesia" ) ); 371 cmbCountry->insertItem( tr ( "Micronesia" ) );
365 cmbCountry->insertItem( tr ( "Moldova" ) ); 372 cmbCountry->insertItem( tr ( "Moldova" ) );
366 cmbCountry->insertItem( tr ( "Monaco" ) ); 373 cmbCountry->insertItem( tr ( "Monaco" ) );
367 cmbCountry->insertItem( tr ( "Mongolia" ) ); 374 cmbCountry->insertItem( tr ( "Mongolia" ) );
368 cmbCountry->insertItem( tr ( "Montserrat" ) ); 375 cmbCountry->insertItem( tr ( "Montserrat" ) );
369 cmbCountry->insertItem( tr ( "Morocco" ) ); 376 cmbCountry->insertItem( tr ( "Morocco" ) );
370 cmbCountry->insertItem( tr ( "Mozambique" ) ); 377 cmbCountry->insertItem( tr ( "Mozambique" ) );
371 cmbCountry->insertItem( tr ( "Myanmar" ) ); 378 cmbCountry->insertItem( tr ( "Myanmar" ) );
372 cmbCountry->insertItem( tr ( "Namibia" ) ); 379 cmbCountry->insertItem( tr ( "Namibia" ) );
373 cmbCountry->insertItem( tr ( "Nauru" ) ); 380 cmbCountry->insertItem( tr ( "Nauru" ) );
374 cmbCountry->insertItem( tr ( "Nepal" ) ); 381 cmbCountry->insertItem( tr ( "Nepal" ) );
375 cmbCountry->insertItem( tr ( "Netherlands" ) ); 382 cmbCountry->insertItem( tr ( "Netherlands" ) );
376 cmbCountry->insertItem( tr ( "New Caledonia" ) ); 383 cmbCountry->insertItem( tr ( "New Caledonia" ) );
377 cmbCountry->insertItem( tr ( "New Zealand" ) ); 384 cmbCountry->insertItem( tr ( "New Zealand" ) );
378 cmbCountry->insertItem( tr ( "Nicaragua" ) ); 385 cmbCountry->insertItem( tr ( "Nicaragua" ) );
379 cmbCountry->insertItem( tr ( "Niger" ) ); 386 cmbCountry->insertItem( tr ( "Niger" ) );
380 cmbCountry->insertItem( tr ( "Nigeria" ) ); 387 cmbCountry->insertItem( tr ( "Nigeria" ) );
381 cmbCountry->insertItem( tr ( "Niue" ) ); 388 cmbCountry->insertItem( tr ( "Niue" ) );
382 cmbCountry->insertItem( tr ( "Norway" ) ); 389 cmbCountry->insertItem( tr ( "Norway" ) );
383 cmbCountry->insertItem( tr ( "Oman" ) ); 390 cmbCountry->insertItem( tr ( "Oman" ) );
384 cmbCountry->insertItem( tr ( "Pakistan" ) ); 391 cmbCountry->insertItem( tr ( "Pakistan" ) );
385 cmbCountry->insertItem( tr ( "Palau" ) ); 392 cmbCountry->insertItem( tr ( "Palau" ) );
386 cmbCountry->insertItem( tr ( "Palestinian Sovereign Areas" ) ); 393 cmbCountry->insertItem( tr ( "Palestinian Sovereign Areas" ) );
387 cmbCountry->insertItem( tr ( "Panama" ) ); 394 cmbCountry->insertItem( tr ( "Panama" ) );
388 cmbCountry->insertItem( tr ( "Papua New Guinea" ) ); 395 cmbCountry->insertItem( tr ( "Papua New Guinea" ) );
389 cmbCountry->insertItem( tr ( "Paraguay" ) ); 396 cmbCountry->insertItem( tr ( "Paraguay" ) );
390 cmbCountry->insertItem( tr ( "Peru" ) ); 397 cmbCountry->insertItem( tr ( "Peru" ) );
391 cmbCountry->insertItem( tr ( "Philippines" ) ); 398 cmbCountry->insertItem( tr ( "Philippines" ) );
392 cmbCountry->insertItem( tr ( "Pitcairn Islands" ) ); 399 cmbCountry->insertItem( tr ( "Pitcairn Islands" ) );
393 cmbCountry->insertItem( tr ( "Poland" ) ); 400 cmbCountry->insertItem( tr ( "Poland" ) );
394 cmbCountry->insertItem( tr ( "Portugal" ) ); 401 cmbCountry->insertItem( tr ( "Portugal" ) );
395 cmbCountry->insertItem( tr ( "Puerto Rico" ) ); 402 cmbCountry->insertItem( tr ( "Puerto Rico" ) );
396 cmbCountry->insertItem( tr ( "Qatar" ) ); 403 cmbCountry->insertItem( tr ( "Qatar" ) );
397 cmbCountry->insertItem( tr ( "Reunion" ) ); 404 cmbCountry->insertItem( tr ( "Reunion" ) );
398 cmbCountry->insertItem( tr ( "Romania" ) ); 405 cmbCountry->insertItem( tr ( "Romania" ) );
399 cmbCountry->insertItem( tr ( "Russia" ) ); 406 cmbCountry->insertItem( tr ( "Russia" ) );
400 cmbCountry->insertItem( tr ( "Rwanda" ) ); 407 cmbCountry->insertItem( tr ( "Rwanda" ) );
401 cmbCountry->insertItem( tr ( "Saint Lucia" ) ); 408 cmbCountry->insertItem( tr ( "Saint Lucia" ) );
402 cmbCountry->insertItem( tr ( "Samoa" ) ); 409 cmbCountry->insertItem( tr ( "Samoa" ) );
403 cmbCountry->insertItem( tr ( "San Marino" ) ); 410 cmbCountry->insertItem( tr ( "San Marino" ) );
404 cmbCountry->insertItem( tr ( "Saudi Arabia" ) ); 411 cmbCountry->insertItem( tr ( "Saudi Arabia" ) );
405 cmbCountry->insertItem( tr ( "Senegal" ) ); 412 cmbCountry->insertItem( tr ( "Senegal" ) );
406 cmbCountry->insertItem( tr ( "Seychelles" ) ); 413 cmbCountry->insertItem( tr ( "Seychelles" ) );
407 cmbCountry->insertItem( tr ( "Sierra Leone" ) ); 414 cmbCountry->insertItem( tr ( "Sierra Leone" ) );
408 cmbCountry->insertItem( tr ( "Singapore" ) ); 415 cmbCountry->insertItem( tr ( "Singapore" ) );
409 cmbCountry->insertItem( tr ( "Slovakia" ) ); 416 cmbCountry->insertItem( tr ( "Slovakia" ) );
410 cmbCountry->insertItem( tr ( "Slovenia" ) ); 417 cmbCountry->insertItem( tr ( "Slovenia" ) );
411 cmbCountry->insertItem( tr ( "Solomon Islands" ) ); 418 cmbCountry->insertItem( tr ( "Solomon Islands" ) );
412 cmbCountry->insertItem( tr ( "Somalia" ) ); 419 cmbCountry->insertItem( tr ( "Somalia" ) );
413 cmbCountry->insertItem( tr ( "South Africa" ) ); 420 cmbCountry->insertItem( tr ( "South Africa" ) );
414 cmbCountry->insertItem( tr ( "Spain" ) ); 421 cmbCountry->insertItem( tr ( "Spain" ) );
415 cmbCountry->insertItem( tr ( "Sri Lanka" ) ); 422 cmbCountry->insertItem( tr ( "Sri Lanka" ) );
416 cmbCountry->insertItem( tr ( "St. Helena" ) ); 423 cmbCountry->insertItem( tr ( "St. Helena" ) );
417 cmbCountry->insertItem( tr ( "Sudan" ) ); 424 cmbCountry->insertItem( tr ( "Sudan" ) );
418 cmbCountry->insertItem( tr ( "Suriname" ) ); 425 cmbCountry->insertItem( tr ( "Suriname" ) );
419 cmbCountry->insertItem( tr ( "Swaziland" ) ); 426 cmbCountry->insertItem( tr ( "Swaziland" ) );
420 cmbCountry->insertItem( tr ( "Sweden" ) ); 427 cmbCountry->insertItem( tr ( "Sweden" ) );
421 cmbCountry->insertItem( tr ( "Switzerland" ) ); 428 cmbCountry->insertItem( tr ( "Switzerland" ) );
422 cmbCountry->insertItem( tr ( "Taiwan" ) ); 429 cmbCountry->insertItem( tr ( "Taiwan" ) );
423 cmbCountry->insertItem( tr ( "Tajikistan" ) ); 430 cmbCountry->insertItem( tr ( "Tajikistan" ) );
424 cmbCountry->insertItem( tr ( "Tanzania" ) ); 431 cmbCountry->insertItem( tr ( "Tanzania" ) );
425 cmbCountry->insertItem( tr ( "Thailand" ) ); 432 cmbCountry->insertItem( tr ( "Thailand" ) );
426 cmbCountry->insertItem( tr ( "Togo" ) ); 433 cmbCountry->insertItem( tr ( "Togo" ) );
427 cmbCountry->insertItem( tr ( "Tokelau" ) ); 434 cmbCountry->insertItem( tr ( "Tokelau" ) );
428 cmbCountry->insertItem( tr ( "Tonga" ) ); 435 cmbCountry->insertItem( tr ( "Tonga" ) );
429 cmbCountry->insertItem( tr ( "Tunisia" ) ); 436 cmbCountry->insertItem( tr ( "Tunisia" ) );
430 cmbCountry->insertItem( tr ( "Turkey" ) ); 437 cmbCountry->insertItem( tr ( "Turkey" ) );
431 cmbCountry->insertItem( tr ( "Turkmenistan" ) ); 438 cmbCountry->insertItem( tr ( "Turkmenistan" ) );
432 cmbCountry->insertItem( tr ( "Tuvalu" ) ); 439 cmbCountry->insertItem( tr ( "Tuvalu" ) );
433 cmbCountry->insertItem( tr ( "Uganda" ) ); 440 cmbCountry->insertItem( tr ( "Uganda" ) );
434 cmbCountry->insertItem( tr ( "Ukraine" ) ); 441 cmbCountry->insertItem( tr ( "Ukraine" ) );
435 cmbCountry->insertItem( tr ( "Uruguay" ) ); 442 cmbCountry->insertItem( tr ( "Uruguay" ) );
436 cmbCountry->insertItem( tr ( "Uzbekistan" ) ); 443 cmbCountry->insertItem( tr ( "Uzbekistan" ) );
437 cmbCountry->insertItem( tr ( "Vanuatu" ) ); 444 cmbCountry->insertItem( tr ( "Vanuatu" ) );
438 cmbCountry->insertItem( tr ( "Venezuela" ) ); 445 cmbCountry->insertItem( tr ( "Venezuela" ) );
439 cmbCountry->insertItem( tr ( "Vietnam" ) ); 446 cmbCountry->insertItem( tr ( "Vietnam" ) );
440 cmbCountry->insertItem( tr ( "Virgin Islands" ) ); 447 cmbCountry->insertItem( tr ( "Virgin Islands" ) );
441 cmbCountry->insertItem( tr ( "Western Sahara" ) ); 448 cmbCountry->insertItem( tr ( "Western Sahara" ) );
442 cmbCountry->insertItem( tr ( "Yemen" ) ); 449 cmbCountry->insertItem( tr ( "Yemen" ) );
443 cmbCountry->insertItem( tr ( "Yugoslavia" ) ); 450 cmbCountry->insertItem( tr ( "Yugoslavia" ) );
444 cmbCountry->insertItem( tr ( "Zambia" ) ); 451 cmbCountry->insertItem( tr ( "Zambia" ) );
445 cmbCountry->insertItem( tr ( "Zimbabwe" ) ); 452 cmbCountry->insertItem( tr ( "Zimbabwe" ) );
446 if (cmbCountry->listBox()!=0) 453 if (cmbCountry->listBox()!=0)
447 cmbCountry->listBox()->sort(); 454 cmbCountry->listBox()->sort();
448 455
449 cmbCountry->setMaximumWidth( 135 ); 456 cmbCountry->setMaximumWidth( 135 );
450 457
451 gl->addMultiCellWidget( cmbCountry, 5, 5, 1, 2 ); 458 gl->addMultiCellWidget( cmbCountry, 5, 5, 1, 2 );
452 459
453 cmbChooserField4 = new QComboBox( FALSE, container ); 460 cmbChooserField4 = new QComboBox( FALSE, container );
454 cmbChooserField4->setMaximumWidth( 90 ); 461 cmbChooserField4->setMaximumWidth( 90 );
455 gl->addWidget( cmbChooserField4, 6, 0 ); 462 gl->addWidget( cmbChooserField4, 6, 0 );
456 txtChooserField4 = new QLineEdit( container ); 463 txtChooserField4 = new QLineEdit( container );
457 gl->addMultiCellWidget( txtChooserField4, 6, 6, 1, 2 ); 464 gl->addMultiCellWidget( txtChooserField4, 6, 6, 1, 2 );
458 465
459 QSpacerItem *space = new QSpacerItem(1,1, 466 QSpacerItem *space = new QSpacerItem(1,1,
460 QSizePolicy::Maximum, 467 QSizePolicy::Maximum,
461 QSizePolicy::MinimumExpanding ); 468 QSizePolicy::MinimumExpanding );
462 gl->addItem( space, 7, 0 ); 469 gl->addItem( space, 7, 0 );
463 470
464 tabMain->insertTab( tabViewport, tr( "Address" ) ); 471 tabMain->insertTab( tabViewport, tr( "Address" ) );
465 472
466 tabViewport = new QWidget ( tabMain ); 473 tabViewport = new QWidget ( tabMain );
467 474
468 vb = new QVBoxLayout( tabViewport ); 475 vb = new QVBoxLayout( tabViewport );
469 476
470 svDetails = new QScrollView( tabViewport ); 477 svDetails = new QScrollView( tabViewport );
471 vb->addWidget( svDetails, 0, 0 ); 478 vb->addWidget( svDetails, 0, 0 );
472 svDetails->setResizePolicy( QScrollView::AutoOneFit ); 479 svDetails->setResizePolicy( QScrollView::AutoOneFit );
473 svDetails->setFrameStyle( QFrame::NoFrame ); 480 svDetails->setFrameStyle( QFrame::NoFrame );
474 481
475 container = new QWidget( svDetails->viewport() ); 482 container = new QWidget( svDetails->viewport() );
476 svDetails->addChild( container ); 483 svDetails->addChild( container );
477 484
478 gl = new QGridLayout( container, 1, 2, 2, 4 ); 485 gl = new QGridLayout( container, 1, 2, 2, 4 );
479 486
480 int counter = 0; 487 int counter = 0;
481 488
482 // Birthday 489 // Birthday
483 QHBox* hBox = new QHBox( container ); 490 QHBox* hBox = new QHBox( container );
484 l = new QLabel( tr("Birthday"), container ); 491 l = new QLabel( tr("Birthday"), container );
485 gl->addWidget( l, counter, 0 ); 492 gl->addWidget( l, counter, 0 );
486 493
487 QPopupMenu* m1 = new QPopupMenu( container ); 494 QPopupMenu* m1 = new QPopupMenu( container );
488 birthdayPicker = new DateBookMonth( m1, 0, TRUE ); 495 birthdayPicker = new DateBookMonth( m1, 0, TRUE );
489 m1->insertItem( birthdayPicker ); 496 m1->insertItem( birthdayPicker );
490 497
491 birthdayButton= new QToolButton( hBox, "buttonStart" ); 498 birthdayButton= new QToolButton( hBox, "buttonStart" );
492 birthdayButton->setPopup( m1 ); 499 birthdayButton->setPopup( m1 );
493 birthdayButton->setPopupDelay(0); 500 birthdayButton->setPopupDelay(0);
494 501
495 QPushButton* deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), 502 QPushButton* deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ),
496 tr( "Delete" ), 503 tr( "Delete" ),
497 hBox, 0 ); 504 hBox, 0 );
498 505
499 gl->addWidget( hBox, counter , 1 ); 506 gl->addWidget( hBox, counter , 1 );
500 507
501 connect( birthdayPicker, SIGNAL( dateClicked( int, int, int ) ), 508 connect( birthdayPicker, SIGNAL( dateClicked( int, int, int ) ),
502 this, SLOT( slotBirthdayDateChanged( int, int, int ) ) ); 509 this, SLOT( slotBirthdayDateChanged( int, int, int ) ) );
503 connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveBirthday() ) ); 510 connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveBirthday() ) );
504 511
505 ++counter; 512 ++counter;
506 513
507 // Anniversary 514 // Anniversary
508 hBox = new QHBox( container ); 515 hBox = new QHBox( container );
509 l = new QLabel( tr("Anniversary"), container ); 516 l = new QLabel( tr("Anniversary"), container );
510 gl->addWidget( l, counter, 0 ); 517 gl->addWidget( l, counter, 0 );
511 518
512 m1 = new QPopupMenu( container ); 519 m1 = new QPopupMenu( container );
513 anniversaryPicker = new DateBookMonth( m1, 0, TRUE ); 520 anniversaryPicker = new DateBookMonth( m1, 0, TRUE );
514 m1->insertItem( anniversaryPicker ); 521 m1->insertItem( anniversaryPicker );
515 522
516 anniversaryButton= new QToolButton( hBox, "buttonStart" ); 523 anniversaryButton= new QToolButton( hBox, "buttonStart" );
517 anniversaryButton->setPopup( m1 ); 524 anniversaryButton->setPopup( m1 );
518 anniversaryButton->setPopupDelay(0); 525 anniversaryButton->setPopupDelay(0);
519 526
520 deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), 527 deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ),
521 tr( "Delete" ), 528 tr( "Delete" ),
522 hBox, 0 ); 529 hBox, 0 );
523 gl->addWidget( hBox, counter , 1 ); 530 gl->addWidget( hBox, counter , 1 );
524 531
525 connect( anniversaryPicker, SIGNAL( dateClicked( int, int, int ) ), 532 connect( anniversaryPicker, SIGNAL( dateClicked( int, int, int ) ),
526 this, SLOT( slotAnniversaryDateChanged( int, int, int ) ) ); 533 this, SLOT( slotAnniversaryDateChanged( int, int, int ) ) );
527 connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveAnniversary() ) ); 534 connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveAnniversary() ) );
528 535
529 ++counter; 536 ++counter;
530 537
531 // Gender 538 // Gender
532 l = new QLabel( tr("Gender"), container ); 539 l = new QLabel( tr("Gender"), container );
533 gl->addWidget( l, counter, 0 ); 540 gl->addWidget( l, counter, 0 );
534 cmbGender = new QComboBox( container ); 541 cmbGender = new QComboBox( container );
535 cmbGender->insertItem( "", 0 ); 542 cmbGender->insertItem( "", 0 );
536 cmbGender->insertItem( tr("Male"), 1); 543 cmbGender->insertItem( tr("Male"), 1);
537 cmbGender->insertItem( tr("Female"), 2); 544 cmbGender->insertItem( tr("Female"), 2);
538 gl->addWidget( cmbGender, counter, 1 ); 545 gl->addWidget( cmbGender, counter, 1 );
539 546
540 ++counter; 547 ++counter;
541 548
542 // Create Labels and lineedit fields for every dynamic entry 549 // Create Labels and lineedit fields for every dynamic entry
543 QStringList::ConstIterator it = slDynamicEntries.begin(); 550 QStringList::ConstIterator it = slDynamicEntries.begin();
544 QStringList::ConstIterator trit = trlDynamicEntries.begin(); 551 QStringList::ConstIterator trit = trlDynamicEntries.begin();
545 for (i = counter; it != slDynamicEntries.end(); i++, ++it, ++trit) { 552 for (i = counter; it != slDynamicEntries.end(); i++, ++it, ++trit) {
546 553
547 if (((*it) == "Anniversary") || 554 if (((*it) == "Anniversary") ||
548 ((*it) == "Birthday")|| ((*it) == "Gender")) continue; 555 ((*it) == "Birthday")|| ((*it) == "Gender")) continue;
549 556
550 l = new QLabel( (*it).utf8() , container ); 557 l = new QLabel( (*it).utf8() , container );
551 listName.append( l ); 558 listName.append( l );
552 gl->addWidget( l, i, 0 ); 559 gl->addWidget( l, i, 0 );
553 QLineEdit *e = new QLineEdit( container ); 560 QLineEdit *e = new QLineEdit( container );
554 listValue.append( e ); 561 listValue.append( e );
555 gl->addWidget( e, i, 1); 562 gl->addWidget( e, i, 1);
556 } 563 }
557 // Fill labels with names.. 564 // Fill labels with names..
558 //loadFields(); 565 //loadFields();
559 566
560 567
561 tabMain->insertTab( tabViewport, tr( "Details" ) ); 568 tabMain->insertTab( tabViewport, tr( "Details" ) );
562 569
563 dlgNote = new QDialog( this, "Note Dialog", TRUE ); 570 dlgNote = new QDialog( this, "Note Dialog", TRUE );
564 dlgNote->setCaption( tr("Enter Note") ); 571 dlgNote->setCaption( tr("Enter Note") );
565 QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); 572 QVBoxLayout *vbNote = new QVBoxLayout( dlgNote );
566 txtNote = new QMultiLineEdit( dlgNote ); 573 txtNote = new QMultiLineEdit( dlgNote );
567 vbNote->addWidget( txtNote ); 574 vbNote->addWidget( txtNote );
568 connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) ); 575 connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) );
569 576
570 dlgName = new QDialog( this, "Name Dialog", TRUE ); 577 dlgName = new QDialog( this, "Name Dialog", TRUE );
571 dlgName->setCaption( tr("Edit Name") ); 578 dlgName->setCaption( tr("Edit Name") );
572 gl = new QGridLayout( dlgName, 5, 2, 2, 3 ); 579 gl = new QGridLayout( dlgName, 5, 2, 2, 3 );
573 580
574 l = new QLabel( tr("First Name"), dlgName ); 581 l = new QLabel( tr("First Name"), dlgName );
575 gl->addWidget( l, 0, 0 ); 582 gl->addWidget( l, 0, 0 );
576 txtFirstName = new QLineEdit( dlgName ); 583 txtFirstName = new QLineEdit( dlgName );
577 gl->addWidget( txtFirstName, 0, 1 ); 584 gl->addWidget( txtFirstName, 0, 1 );
578 585
579 l = new QLabel( tr("Middle Name"), dlgName ); 586 l = new QLabel( tr("Middle Name"), dlgName );
580 gl->addWidget( l, 1, 0 ); 587 gl->addWidget( l, 1, 0 );
581 txtMiddleName = new QLineEdit( dlgName ); 588 txtMiddleName = new QLineEdit( dlgName );
582 gl->addWidget( txtMiddleName, 1, 1 ); 589 gl->addWidget( txtMiddleName, 1, 1 );
583 590
584 l = new QLabel( tr("Last Name"), dlgName ); 591 l = new QLabel( tr("Last Name"), dlgName );
585 gl->addWidget( l, 2, 0 ); 592 gl->addWidget( l, 2, 0 );
586 txtLastName = new QLineEdit( dlgName ); 593 txtLastName = new QLineEdit( dlgName );
587 gl->addWidget( txtLastName, 2, 1 ); 594 gl->addWidget( txtLastName, 2, 1 );
588 595
589 l = new QLabel( tr("Suffix"), dlgName ); 596 l = new QLabel( tr("Suffix"), dlgName );
590 gl->addWidget( l, 3, 0 ); 597 gl->addWidget( l, 3, 0 );
591 txtSuffix = new QLineEdit( dlgName ); 598 txtSuffix = new QLineEdit( dlgName );
592 gl->addWidget( txtSuffix, 3, 1 ); 599 gl->addWidget( txtSuffix, 3, 1 );
593 space = new QSpacerItem(1,1, 600 space = new QSpacerItem(1,1,
594 QSizePolicy::Maximum, 601 QSizePolicy::Maximum,
595 QSizePolicy::MinimumExpanding ); 602 QSizePolicy::MinimumExpanding );
596 gl->addItem( space, 4, 0 ); 603 gl->addItem( space, 4, 0 );
597 604
598 cmbChooserField1->insertStringList( trlChooserNames ); 605 cmbChooserField1->insertStringList( trlChooserNames );
599 cmbChooserField2->insertStringList( trlChooserNames ); 606 cmbChooserField2->insertStringList( trlChooserNames );
600 cmbChooserField3->insertStringList( trlChooserNames ); 607 cmbChooserField3->insertStringList( trlChooserNames );
601 cmbChooserField4->insertStringList( trlChooserNames ); 608 cmbChooserField4->insertStringList( trlChooserNames );
602 609
603 cmbChooserField1->setCurrentItem( 0 ); 610 cmbChooserField1->setCurrentItem( 0 );
604 cmbChooserField2->setCurrentItem( 1 ); 611 cmbChooserField2->setCurrentItem( 1 );
605 cmbChooserField3->setCurrentItem( 2 ); 612 cmbChooserField3->setCurrentItem( 2 );
606 613
607 connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) ); 614 connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) );
608 615
609 connect( txtFullName, SIGNAL(textChanged(const QString &)), this, SLOT(slotFullNameChange(const QString &)) ); 616 connect( txtFullName, SIGNAL(textChanged(const QString &)), this, SLOT(slotFullNameChange(const QString &)) );
610 617
611 connect( txtChooserField1, SIGNAL(textChanged(const QString &)), 618 connect( txtChooserField1, SIGNAL(textChanged(const QString &)),
612 this, SLOT(slotChooser1Change(const QString &)) ); 619 this, SLOT(slotChooser1Change(const QString &)) );
613 connect( txtChooserField2, SIGNAL(textChanged(const QString &)), 620 connect( txtChooserField2, SIGNAL(textChanged(const QString &)),
614 this, SLOT(slotChooser2Change(const QString &)) ); 621 this, SLOT(slotChooser2Change(const QString &)) );
615 connect( txtChooserField3, SIGNAL(textChanged(const QString &)), 622 connect( txtChooserField3, SIGNAL(textChanged(const QString &)),
616 this, SLOT(slotChooser3Change(const QString &)) ); 623 this, SLOT(slotChooser3Change(const QString &)) );
617 connect( txtChooserField4, SIGNAL(textChanged(const QString &)), 624 connect( txtChooserField4, SIGNAL(textChanged(const QString &)),
618 this, SLOT(slotChooser4Change(const QString &)) ); 625 this, SLOT(slotChooser4Change(const QString &)) );
619 connect( txtAddress, SIGNAL(textChanged(const QString &)), 626 connect( txtAddress, SIGNAL(textChanged(const QString &)),
620 this, SLOT(slotAddressChange(const QString &)) ); 627 this, SLOT(slotAddressChange(const QString &)) );
621 connect( txtCity, SIGNAL(textChanged(const QString &)), 628 connect( txtCity, SIGNAL(textChanged(const QString &)),
622 this, SLOT(slotCityChange(const QString &)) ); 629 this, SLOT(slotCityChange(const QString &)) );
623 connect( txtState, SIGNAL(textChanged(const QString &)), 630 connect( txtState, SIGNAL(textChanged(const QString &)),
624 this, SLOT(slotStateChange(const QString &)) ); 631 this, SLOT(slotStateChange(const QString &)) );
625 connect( txtZip, SIGNAL(textChanged(const QString &)), 632 connect( txtZip, SIGNAL(textChanged(const QString &)),
626 this, SLOT(slotZipChange(const QString &)) ); 633 this, SLOT(slotZipChange(const QString &)) );
627 connect( cmbCountry, SIGNAL(textChanged(const QString &)), 634 connect( cmbCountry, SIGNAL(textChanged(const QString &)),
628 this, SLOT(slotCountryChange(const QString &)) ); 635 this, SLOT(slotCountryChange(const QString &)) );
629 connect( cmbCountry, SIGNAL(activated(const QString &)), 636 connect( cmbCountry, SIGNAL(activated(const QString &)),
630 this, SLOT(slotCountryChange(const QString &)) ); 637 this, SLOT(slotCountryChange(const QString &)) );
631 connect( cmbChooserField1, SIGNAL(activated(int)), 638 connect( cmbChooserField1, SIGNAL(activated(int)),
632 this, SLOT(slotCmbChooser1Change(int)) ); 639 this, SLOT(slotCmbChooser1Change(int)) );
633 connect( cmbChooserField2, SIGNAL(activated(int)), 640 connect( cmbChooserField2, SIGNAL(activated(int)),
634 this, SLOT(slotCmbChooser2Change(int)) ); 641 this, SLOT(slotCmbChooser2Change(int)) );
635 connect( cmbChooserField3, SIGNAL(activated(int)), 642 connect( cmbChooserField3, SIGNAL(activated(int)),
636 this, SLOT(slotCmbChooser3Change(int)) ); 643 this, SLOT(slotCmbChooser3Change(int)) );
637 connect( cmbChooserField4, SIGNAL(activated(int)), 644 connect( cmbChooserField4, SIGNAL(activated(int)),
638 this, SLOT(slotCmbChooser4Change(int)) ); 645 this, SLOT(slotCmbChooser4Change(int)) );
639 connect( cmbAddress, SIGNAL(activated(int)), 646 connect( cmbAddress, SIGNAL(activated(int)),
640 this, SLOT(slotAddressTypeChange(int)) ); 647 this, SLOT(slotAddressTypeChange(int)) );
641 648
642 new QPEDialogListener(this); 649 new QPEDialogListener(this);
643 650
644 setPersonalView ( m_personalView ); 651 setPersonalView ( m_personalView );
652
653 qWarning("init() END");
645} 654}
646 655
647void ContactEditor::defaultEmailChanged(int i){ 656void ContactEditor::defaultEmailChanged(int i){
648 qDebug("defaultEmailChanged"); 657 qDebug("defaultEmailChanged");
649 658
650 // was sollte das ? (se) 659 // was sollte das ? (se)
651 // int index = cmbChooserField1->currentItem(); 660 // int index = cmbChooserField1->currentItem();
652 // slChooserValues[index] = cmbDefaultEmail->text(i); 661 // slChooserValues[index] = cmbDefaultEmail->text(i);
653 662
654 defaultEmail = cmbDefaultEmail->text(i); 663 defaultEmail = cmbDefaultEmail->text(i);
655 qDebug ("Changed to: %s", defaultEmail.latin1()); 664 qDebug ("Changed to: %s", defaultEmail.latin1());
656 665
657} 666}
658 667
659void ContactEditor::populateDefaultEmailCmb(){ 668void ContactEditor::populateDefaultEmailCmb(){
660 669
661 // if the default-email combo was not selected and therfore not created 670 // if the default-email combo was not selected and therfore not created
662 // we get a lot of trouble.. Therfore create an invisible one.. 671 // we get a lot of trouble.. Therfore create an invisible one..
663 if ( !cmbDefaultEmail ){ 672 if ( !cmbDefaultEmail ){
664 cmbDefaultEmail = new QComboBox(this); 673 cmbDefaultEmail = new QComboBox(this);
665 cmbDefaultEmail -> hide(); 674 cmbDefaultEmail -> hide();
666 } 675 }
667 cmbDefaultEmail->clear(); 676 cmbDefaultEmail->clear();
668 cmbDefaultEmail->insertStringList( emails ); 677 cmbDefaultEmail->insertStringList( emails );
669 // cmbDefaultEmail->show(); 678 // cmbDefaultEmail->show();
670 679
671 // Select default email in combo.. 680 // Select default email in combo..
672 bool found = false; 681 bool found = false;
673 for ( int i = 0; i < cmbDefaultEmail->count(); i++){ 682 for ( int i = 0; i < cmbDefaultEmail->count(); i++){
674 qDebug(" populateDefaultEmailCmb text >%s< defaultEmail >%s<", 683 qDebug(" populateDefaultEmailCmb text >%s< defaultEmail >%s<",
675 cmbDefaultEmail->text( i ).latin1(), defaultEmail.latin1()); 684 cmbDefaultEmail->text( i ).latin1(), defaultEmail.latin1());
676 685
677 if ( cmbDefaultEmail->text( i ).stripWhiteSpace() == defaultEmail.stripWhiteSpace() ){ 686 if ( cmbDefaultEmail->text( i ).stripWhiteSpace() == defaultEmail.stripWhiteSpace() ){
678 cmbDefaultEmail->setCurrentItem( i ); 687 cmbDefaultEmail->setCurrentItem( i );
679 qDebug("set"); 688 qDebug("set");
680 found = true; 689 found = true;
681 } 690 }
682 } 691 }
683 692
684 // If the current default email is not found in the list, we choose the 693 // If the current default email is not found in the list, we choose the
685 // first one.. 694 // first one..
686 if ( !found ) 695 if ( !found )
687 defaultEmail = cmbDefaultEmail->text(0); 696 defaultEmail = cmbDefaultEmail->text(0);
688} 697}
689 698
690// Called when any combobox was changed. 699// Called when any combobox was changed.
691// "true" returned if the change was chandled by this function, else it should 700// "true" returned if the change was chandled by this function, else it should
692// be handled by something else.. 701// be handled by something else..
693bool ContactEditor::cmbChooserChange( int index, QLineEdit *inputWid, int widgetPos ) { 702bool ContactEditor::cmbChooserChange( int index, QLineEdit *inputWid, int widgetPos ) {
694 QString type = slChooserNames[index]; 703 QString type = slChooserNames[index];
695 qWarning("ContactEditor::cmbChooserChange -> Type: %s", type.latin1() ); 704 qWarning("ContactEditor::cmbChooserChange -> Type: %s, WidgetPos: %d", type.latin1(), widgetPos );
705
706 if ( !initializing )
707 contactfields.setFieldOrder( widgetPos-1, index );
696 708
697 // Create and connect combobox for selecting the default email 709 // Create and connect combobox for selecting the default email
698 if ( type == "Default Email"){ 710 if ( type == "Default Email"){
699 qWarning("Choosing default-email "); 711 qWarning("Choosing default-email (defaultEmailChooserPosition= %d) ", defaultEmailChooserPosition);
700 712
701 // More than one defaul-email chooser is not allowed ! 713 // More than one defaul-email chooser is not allowed !
702 if ( ( defaultEmailChooserPosition != -1 ) && 714 if ( ( defaultEmailChooserPosition != -1 ) &&
703 defaultEmailChooserPosition != widgetPos ){ 715 defaultEmailChooserPosition != widgetPos && !initializing){
704 chooserError( widgetPos ); 716 chooserError( widgetPos );
705 return true; 717 return true;
706 } 718 }
707 719
708 if ( cmbDefaultEmail ){ 720 if ( cmbDefaultEmail ){
709 delete cmbDefaultEmail; 721 delete cmbDefaultEmail;
710 cmbDefaultEmail = 0l; 722 cmbDefaultEmail = 0l;
711 } 723 }
712 cmbDefaultEmail = new QComboBox(inputWid->parentWidget()); 724 cmbDefaultEmail = new QComboBox(inputWid->parentWidget());
713 cmbDefaultEmail->setGeometry(inputWid->frameGeometry()); 725 cmbDefaultEmail->setGeometry(inputWid->frameGeometry()); /* :SX */
726
727 QRect rect = inputWid->frameGeometry();
728 qWarning("Geometrie: X=%d, Y=%d, Left=%d, Top=%d, Right=%d, Bottom=%d",
729 rect.x(), rect.y(), rect.left(), rect.top(), rect.right(), rect.bottom());
730 QPoint pnt = inputWid->pos();
731 qWarning("Position : X=%d, Y=%d", pnt.x(), pnt.y() );
714 732
715 connect( cmbDefaultEmail,SIGNAL( activated(int) ), 733 connect( cmbDefaultEmail,SIGNAL( activated(int) ),
716 SLOT( defaultEmailChanged(int) ) ); 734 SLOT( defaultEmailChanged(int) ) );
717 735
718 cmbDefaultEmail->clear(); 736 cmbDefaultEmail->clear();
719 cmbDefaultEmail->insertStringList( emails ); 737 cmbDefaultEmail->insertStringList( emails );
720 cmbDefaultEmail->show(); 738 cmbDefaultEmail->show();
721 739
722 defaultEmailChooserPosition = widgetPos; 740 defaultEmailChooserPosition = widgetPos;
723 741
724 // Set current default email 742 // Set current default email
725 populateDefaultEmailCmb(); 743 populateDefaultEmailCmb();
726 744
727 745
728 } else { 746 } else {
729 // Something else was selected: Hide combo.. 747 // Something else was selected: Hide combo..
730 qWarning(" Hiding default-email combo" ); 748 qWarning(" Hiding default-email combo" );
731 if ( defaultEmailChooserPosition == widgetPos ){ 749 if ( defaultEmailChooserPosition == widgetPos ){
732 defaultEmailChooserPosition = -1; 750 defaultEmailChooserPosition = -1;
733 if ( cmbDefaultEmail ) 751 if ( cmbDefaultEmail )
734 cmbDefaultEmail->hide(); 752 cmbDefaultEmail->hide();
735 753
736 } 754 }
737 755
738 // Caller should initialize the responsible textfield, therefore 756 // Caller should initialize the responsible textfield, therefore
739 // "false" is returned 757 // "false" is returned
740 return false; 758 return false;
741 } 759 }
742 760
743 // Everything is worked off .. 761 // Everything is worked off ..
744 return true; 762 return true;
745 763
746} 764}
747 765
748// Currently accessed when we select default-email more than once ! 766// Currently accessed when we select default-email more than once !
749void ContactEditor::chooserError( int index ) 767void ContactEditor::chooserError( int index )
750{ 768{
751 qWarning("ContactEditor::chooserError( %d )", index); 769 qWarning("ContactEditor::chooserError( %d )", index);
752 QMessageBox::warning( this, "Chooser Error", 770 QMessageBox::warning( this, "Chooser Error",
753 "Multiple selection of this\n" 771 "Multiple selection of this\n"
754 "Item is not allowed !\n\n" 772 "Item is not allowed !\n\n"
755 "First deselect the previous one !", 773 "First deselect the previous one !",
756 "&OK", 0, 0, 774 "&OK", 0, 0,
757 0, 0 ); 775 0, 0 );
758 776
759 // Reset the selected Chooser. Unfortunately the chooser 777 // Reset the selected Chooser. Unfortunately the chooser
760 // generates no signal, therfore we have to 778 // generates no signal, therfore we have to
761 // call the cmbChooserChange function manually.. 779 // call the cmbChooserChange function manually..
762 switch( index ){ 780 switch( index ){
763 case 1: 781 case 1:
764 cmbChooserField1 -> setCurrentItem( 0 ); 782 cmbChooserField1 -> setCurrentItem( 0 );
765 slotCmbChooser1Change( 0 ); 783 slotCmbChooser1Change( 0 );
766 break; 784 break;
767 case 2: 785 case 2:
768 cmbChooserField2 -> setCurrentItem( 0 ); 786 cmbChooserField2 -> setCurrentItem( 0 );
769 slotCmbChooser2Change( 0 ); 787 slotCmbChooser2Change( 0 );
770 break; 788 break;
771 case 3: 789 case 3:
772 cmbChooserField3 -> setCurrentItem( 0 ); 790 cmbChooserField3 -> setCurrentItem( 0 );
773 slotCmbChooser3Change( 0 ); 791 slotCmbChooser3Change( 0 );
774 break; 792 break;
775 case 4: 793 case 4:
776 cmbChooserField4 -> setCurrentItem( 0 ); 794 cmbChooserField4 -> setCurrentItem( 0 );
777 slotCmbChooser4Change( 0 ); 795 slotCmbChooser4Change( 0 );
778 break; 796 break;
779 } 797 }
780} 798}
781 799
782// Called when something was changed in a textfield (shouldn't it called textchanged? (se)) 800// Called when something was changed in a textfield (shouldn't it called textchanged? (se))
783void ContactEditor::chooserChange( const QString &textChanged, int index, 801void ContactEditor::chooserChange( const QString &textChanged, int index,
784 QLineEdit* , int widgetPos ) { 802 QLineEdit* , int widgetPos ) {
785 803
786 QString type = slChooserNames[index]; 804 QString type = slChooserNames[index];
787 qDebug("ContactEditor::chooserChange( type=>%s<, textChanged=>%s< index=%i, widgetPos=%i", 805 qDebug("ContactEditor::chooserChange( type=>%s<, textChanged=>%s< index=%i, widgetPos=%i",
788 type.latin1(),textChanged.latin1(), index, widgetPos ); 806 type.latin1(),textChanged.latin1(), index, widgetPos );
789 807
790 if ( type == "Default Email"){ 808 if ( type == "Default Email"){
791 qWarning ("??? Wozu??: %s", textChanged.latin1()); 809 qWarning ("??? Wozu??: %s", textChanged.latin1());
792 defaultEmail = textChanged; 810 defaultEmail = textChanged;
793 811
794 populateDefaultEmailCmb(); 812 populateDefaultEmailCmb();
795 813
796 }else if (defaultEmailChooserPosition == widgetPos){ 814 }else if (defaultEmailChooserPosition == widgetPos){
797 qDebug("cmbDefaultEmail->hide()"); 815 qDebug("cmbDefaultEmail->hide()");
798 816
799 if (cmbDefaultEmail) cmbDefaultEmail->hide(); 817 if (cmbDefaultEmail) cmbDefaultEmail->hide();
800 widgetPos=-1; 818 widgetPos=-1;
801 819
802 }else if (type == "Emails"){ 820 }else if (type == "Emails"){
803 qDebug("emails"); 821 qDebug("emails");
804 822
805 QString de; 823 QString de;
806 emails = QStringList::split (",", textChanged ); 824 emails = QStringList::split (",", textChanged );
807 825
808 populateDefaultEmailCmb(); 826 populateDefaultEmailCmb();
809 } 827 }
810 828
811 slChooserValues[index] = textChanged; 829 slChooserValues[index] = textChanged;
812 830
813} 831}
814 832
815void ContactEditor::slotChooser1Change( const QString &textChanged ) { 833void ContactEditor::slotChooser1Change( const QString &textChanged ) {
816 qWarning("ContactEditor::slotChooser1Change( %s )", textChanged.latin1()); 834 qWarning("ContactEditor::slotChooser1Change( %s )", textChanged.latin1());
817 chooserChange( textChanged, cmbChooserField1->currentItem(), txtChooserField1, 1); 835 chooserChange( textChanged, cmbChooserField1->currentItem(), txtChooserField1, 1);
818} 836}
819 837
820void ContactEditor::slotChooser2Change( const QString &textChanged ) { 838void ContactEditor::slotChooser2Change( const QString &textChanged ) {
821 qWarning("ContactEditor::slotChooser2Change( %s )", textChanged.latin1()); 839 qWarning("ContactEditor::slotChooser2Change( %s )", textChanged.latin1());
822 chooserChange( textChanged, cmbChooserField2->currentItem(), txtChooserField2, 2); 840 chooserChange( textChanged, cmbChooserField2->currentItem(), txtChooserField2, 2);
823 841
824} 842}
825 843
826void ContactEditor::slotChooser3Change( const QString &textChanged ) { 844void ContactEditor::slotChooser3Change( const QString &textChanged ) {
827 qWarning("ContactEditor::slotChooser3Change( %s )", textChanged.latin1()); 845 qWarning("ContactEditor::slotChooser3Change( %s )", textChanged.latin1());
828 chooserChange( textChanged, cmbChooserField3->currentItem(), txtChooserField3, 3); 846 chooserChange( textChanged, cmbChooserField3->currentItem(), txtChooserField3, 3);
829} 847}
830 848
831void ContactEditor::slotChooser4Change( const QString &textChanged ) { 849void ContactEditor::slotChooser4Change( const QString &textChanged ) {
832 qWarning("ContactEditor::slotChooser4Change( %s )", textChanged.latin1()); 850 qWarning("ContactEditor::slotChooser4Change( %s )", textChanged.latin1());
833 chooserChange( textChanged, cmbChooserField4->currentItem(), txtChooserField4, 4); 851 chooserChange( textChanged, cmbChooserField4->currentItem(), txtChooserField4, 4);
834} 852}
835 853
836void ContactEditor::slotAddressChange( const QString &textChanged ) { 854void ContactEditor::slotAddressChange( const QString &textChanged ) {
837 855
838 if ( cmbAddress->currentItem() == 0 ) { 856 if ( cmbAddress->currentItem() == 0 ) {
839 slBusinessAddress[0] = textChanged; 857 slBusinessAddress[0] = textChanged;
840 } else { 858 } else {
841 slHomeAddress[0] = textChanged; 859 slHomeAddress[0] = textChanged;
842 } 860 }
843} 861}
844 862
845void ContactEditor::slotAddress2Change( const QString &textChanged ) { 863void ContactEditor::slotAddress2Change( const QString &textChanged ) {
846 864
847 if ( cmbAddress->currentItem() == 0 ) { 865 if ( cmbAddress->currentItem() == 0 ) {
848 slBusinessAddress[1] = textChanged; 866 slBusinessAddress[1] = textChanged;
849 } else { 867 } else {
850 slHomeAddress[1] = textChanged; 868 slHomeAddress[1] = textChanged;
851 } 869 }
852} 870}
853 871
854void ContactEditor::slotPOBoxChange( const QString &textChanged ) { 872void ContactEditor::slotPOBoxChange( const QString &textChanged ) {
855 873
856 if ( cmbAddress->currentItem() == 0 ) { 874 if ( cmbAddress->currentItem() == 0 ) {
857 slBusinessAddress[2] = textChanged; 875 slBusinessAddress[2] = textChanged;
858 } else { 876 } else {
859 slHomeAddress[2] = textChanged; 877 slHomeAddress[2] = textChanged;
860 } 878 }
861} 879}
862 880
863void ContactEditor::slotCityChange( const QString &textChanged ) { 881void ContactEditor::slotCityChange( const QString &textChanged ) {
864 882
865 if ( cmbAddress->currentItem() == 0 ) { 883 if ( cmbAddress->currentItem() == 0 ) {
866 slBusinessAddress[3] = textChanged; 884 slBusinessAddress[3] = textChanged;
867 } else { 885 } else {
868 slHomeAddress[3] = textChanged; 886 slHomeAddress[3] = textChanged;
869 } 887 }
870} 888}
871 889
872void ContactEditor::slotStateChange( const QString &textChanged ) { 890void ContactEditor::slotStateChange( const QString &textChanged ) {
873 891
874 892
875 if ( cmbAddress->currentItem() == 0 ) { 893 if ( cmbAddress->currentItem() == 0 ) {
876 slBusinessAddress[4] = textChanged; 894 slBusinessAddress[4] = textChanged;
877 } else { 895 } else {
878 slHomeAddress[4] = textChanged; 896 slHomeAddress[4] = textChanged;
879 } 897 }
880} 898}
881 899
882void ContactEditor::slotZipChange( const QString &textChanged ) { 900void ContactEditor::slotZipChange( const QString &textChanged ) {
883 901
884 if ( cmbAddress->currentItem() == 0 ) { 902 if ( cmbAddress->currentItem() == 0 ) {
885 slBusinessAddress[5] = textChanged; 903 slBusinessAddress[5] = textChanged;
886 } else { 904 } else {
887 slHomeAddress[5] = textChanged; 905 slHomeAddress[5] = textChanged;
888 } 906 }
889} 907}
890 908
891void ContactEditor::slotCountryChange( const QString &textChanged ) { 909void ContactEditor::slotCountryChange( const QString &textChanged ) {
892 910
893 if ( cmbAddress->currentItem() == 0 ) { 911 if ( cmbAddress->currentItem() == 0 ) {
894 slBusinessAddress[6] = textChanged; 912 slBusinessAddress[6] = textChanged;
895 } else { 913 } else {
896 slHomeAddress[6] = textChanged; 914 slHomeAddress[6] = textChanged;
897 } 915 }
898} 916}
899 917
900 918
901void ContactEditor::slotCmbChooser1Change( int index ) { 919void ContactEditor::slotCmbChooser1Change( int index ) {
902 qWarning("ContactEditor::slotCmbChooser1Change( %d )", index); 920 qWarning("ContactEditor::slotCmbChooser1Change( %d )", index);
903 if ( !cmbChooserChange( cmbChooserField1->currentItem(), txtChooserField1, 1) ){ 921 if ( !cmbChooserChange( cmbChooserField1->currentItem(), txtChooserField1, 1) ){
904 922
905 txtChooserField1->setText( slChooserValues[index] ); 923 txtChooserField1->setText( slChooserValues[index] );
906 txtChooserField1->setFocus(); 924 txtChooserField1->setFocus();
907 925
908 } 926 }
909 927
910} 928}
911 929
912void ContactEditor::slotCmbChooser2Change( int index ) { 930void ContactEditor::slotCmbChooser2Change( int index ) {
913 qWarning("ContactEditor::slotCmbChooser2Change( %d )", index); 931 qWarning("ContactEditor::slotCmbChooser2Change( %d )", index);
914 932
915 if ( !cmbChooserChange( cmbChooserField2->currentItem(), txtChooserField2, 2) ){ 933 if ( !cmbChooserChange( cmbChooserField2->currentItem(), txtChooserField2, 2) ){
916 934
917 txtChooserField2->setText( slChooserValues[index] ); 935 txtChooserField2->setText( slChooserValues[index] );
918 txtChooserField2->setFocus(); 936 txtChooserField2->setFocus();
919 937
920 } 938 }
921} 939}
922 940
923void ContactEditor::slotCmbChooser3Change( int index ) { 941void ContactEditor::slotCmbChooser3Change( int index ) {
924 qWarning("ContactEditor::slotCmbChooser3Change( %d )", index); 942 qWarning("ContactEditor::slotCmbChooser3Change( %d )", index);
925 943
926 if ( !cmbChooserChange( cmbChooserField3->currentItem(), txtChooserField3, 3) ){ 944 if ( !cmbChooserChange( cmbChooserField3->currentItem(), txtChooserField3, 3) ){
927 945
928 txtChooserField3->setText( slChooserValues[index] ); 946 txtChooserField3->setText( slChooserValues[index] );
929 txtChooserField3->setFocus(); 947 txtChooserField3->setFocus();
930 948
931 } 949 }
932} 950}
933 951
934void ContactEditor::slotCmbChooser4Change( int index ) { 952void ContactEditor::slotCmbChooser4Change( int index ) {
935 qWarning("ContactEditor::slotCmbChooser4Change( %d )", index); 953 qWarning("ContactEditor::slotCmbChooser4Change( %d )", index);
936 954
937 if ( !cmbChooserChange( cmbChooserField4->currentItem(), txtChooserField4, 4) ){ 955 if ( !cmbChooserChange( cmbChooserField4->currentItem(), txtChooserField4, 4) ){
938 956
939 txtChooserField4->setText( slChooserValues[index] ); 957 txtChooserField4->setText( slChooserValues[index] );
940 txtChooserField4->setFocus(); 958 txtChooserField4->setFocus();
941 959
942 } 960 }
943} 961}
944 962
945void ContactEditor::slotAddressTypeChange( int index ) { 963void ContactEditor::slotAddressTypeChange( int index ) {
946 964
965
966 if ( !initializing )
967 contactfields.setFieldOrder( 4, index );
968
969
947 if ( index == 0 ) { 970 if ( index == 0 ) {
948 971
949 txtAddress->setText( slBusinessAddress[0] ); 972 txtAddress->setText( slBusinessAddress[0] );
950 //txtAddress2->setText( (*slBusinessAddress)[1] ); 973 //txtAddress2->setText( (*slBusinessAddress)[1] );
951 //txtPOBox->setText( (*slBusinessAddress)[2] ); 974 //txtPOBox->setText( (*slBusinessAddress)[2] );
952 txtCity->setText( slBusinessAddress[3] ); 975 txtCity->setText( slBusinessAddress[3] );
953 txtState->setText( slBusinessAddress[4] ); 976 txtState->setText( slBusinessAddress[4] );
954 txtZip->setText( slBusinessAddress[5] ); 977 txtZip->setText( slBusinessAddress[5] );
955 QLineEdit *txtTmp = cmbCountry->lineEdit(); 978 QLineEdit *txtTmp = cmbCountry->lineEdit();
956 txtTmp->setText( slBusinessAddress[6] ); 979 txtTmp->setText( slBusinessAddress[6] );
957 980
958 } else { 981 } else {
959 982
960 txtAddress->setText( slHomeAddress[0] ); 983 txtAddress->setText( slHomeAddress[0] );
961 //txtAddress2->setText( (*slHomeAddress)[1] ); 984 //txtAddress2->setText( (*slHomeAddress)[1] );
962 //txtPOBox->setText( (*slHomeAddress)[2] ); 985 //txtPOBox->setText( (*slHomeAddress)[2] );
963 txtCity->setText( slHomeAddress[3] ); 986 txtCity->setText( slHomeAddress[3] );
964 txtState->setText( slHomeAddress[4] ); 987 txtState->setText( slHomeAddress[4] );
965 txtZip->setText( slHomeAddress[5] ); 988 txtZip->setText( slHomeAddress[5] );
966 QLineEdit *txtTmp = cmbCountry->lineEdit(); 989 QLineEdit *txtTmp = cmbCountry->lineEdit();
967 txtTmp->setText( slHomeAddress[6] ); 990 txtTmp->setText( slHomeAddress[6] );
968 991
969 } 992 }
970 993
971} 994}
972 995
973void ContactEditor::slotFullNameChange( const QString &textChanged ) { 996void ContactEditor::slotFullNameChange( const QString &textChanged ) {
974 997
975 int index = cmbFileAs->currentItem(); 998 int index = cmbFileAs->currentItem();
976 999
977 cmbFileAs->clear(); 1000 cmbFileAs->clear();
978 1001
979 cmbFileAs->insertItem( parseName( textChanged, 0 ) ); 1002 cmbFileAs->insertItem( parseName( textChanged, 0 ) );
980 cmbFileAs->insertItem( parseName( textChanged, 1 ) ); 1003 cmbFileAs->insertItem( parseName( textChanged, 1 ) );
981 cmbFileAs->insertItem( parseName( textChanged, 2 ) ); 1004 cmbFileAs->insertItem( parseName( textChanged, 2 ) );
982 cmbFileAs->insertItem( parseName( textChanged, 3 ) ); 1005 cmbFileAs->insertItem( parseName( textChanged, 3 ) );
983 1006
984 cmbFileAs->setCurrentItem( index ); 1007 cmbFileAs->setCurrentItem( index );
985 1008
986 useFullName = true; 1009 useFullName = true;
987 1010
988} 1011}
989 1012
990void ContactEditor::accept() { 1013void ContactEditor::accept() {
991 1014
992 if ( isEmpty() ) { 1015 if ( isEmpty() ) {
993 cleanupFields(); 1016 cleanupFields();
994 reject(); 1017 reject();
995 } else { 1018 } else {
996 saveEntry(); 1019 saveEntry();
997 cleanupFields(); 1020 cleanupFields();
998 QDialog::accept(); 1021 QDialog::accept();
999 } 1022 }
1000 1023
1001} 1024}
1002 1025
1003void ContactEditor::slotNote() { 1026void ContactEditor::slotNote() {
1004 1027
1005 dlgNote->showMaximized(); 1028 dlgNote->showMaximized();
1006 if ( !dlgNote->exec() ) { 1029 if ( !dlgNote->exec() ) {
1007 txtNote->setText( ent.notes() ); 1030 txtNote->setText( ent.notes() );
1008 } 1031 }
1009} 1032}
1010 1033
1011void ContactEditor::slotName() { 1034void ContactEditor::slotName() {
1012 1035
1013 QString tmpName; 1036 QString tmpName;
1014 if (useFullName) { 1037 if (useFullName) {
1015 txtFirstName->setText( parseName(txtFullName->text(), NAME_F) ); 1038 txtFirstName->setText( parseName(txtFullName->text(), NAME_F) );
1016 txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) ); 1039 txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) );
1017 txtLastName->setText( parseName(txtFullName->text(), NAME_L) ); 1040 txtLastName->setText( parseName(txtFullName->text(), NAME_L) );
1018 txtSuffix->setText( parseName(txtFullName->text(), NAME_S) ); 1041 txtSuffix->setText( parseName(txtFullName->text(), NAME_S) );
1019 } 1042 }
1020 dlgName->showMaximized(); 1043 dlgName->showMaximized();
1021 if ( dlgName->exec() ) { 1044 if ( dlgName->exec() ) {
1022 1045
1023 tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text() + " " + txtSuffix->text(); 1046 tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text() + " " + txtSuffix->text();
1024 txtFullName->setText( tmpName.simplifyWhiteSpace() ); 1047 txtFullName->setText( tmpName.simplifyWhiteSpace() );
1025 slotFullNameChange( txtFullName->text() ); 1048 slotFullNameChange( txtFullName->text() );
1026 useFullName = false; 1049 useFullName = false;
1027 } 1050 }
1028 1051
1029} 1052}
1030 1053
1031void ContactEditor::setNameFocus() { 1054void ContactEditor::setNameFocus() {
1032 1055
1033 txtFullName->setFocus(); 1056 txtFullName->setFocus();
1034 1057
1035} 1058}
1036 1059
1037bool ContactEditor::isEmpty() { 1060bool ContactEditor::isEmpty() {
1038 // Test and see if the record should be saved. 1061 // Test and see if the record should be saved.
1039 // More strict than the original qtopia, needs name or fileas to save 1062 // More strict than the original qtopia, needs name or fileas to save
1040 1063
1041 QString t = txtFullName->text(); 1064 QString t = txtFullName->text();
1042 if ( !t.isEmpty() && containsAlphaNum( t ) ) 1065 if ( !t.isEmpty() && containsAlphaNum( t ) )
1043 return false; 1066 return false;
1044 1067
1045 t = cmbFileAs->currentText(); 1068 t = cmbFileAs->currentText();
1046 if ( !t.isEmpty() && containsAlphaNum( t ) ) 1069 if ( !t.isEmpty() && containsAlphaNum( t ) )
1047 return false; 1070 return false;
1048 1071
1049 return true; 1072 return true;
1050 1073
1051} 1074}
1052 1075
1053QString ContactEditor::parseName( const QString fullName, int type ) { 1076QString ContactEditor::parseName( const QString fullName, int type ) {
1054 1077
1055 QString simplifiedName( fullName.simplifyWhiteSpace() ); 1078 QString simplifiedName( fullName.simplifyWhiteSpace() );
1056 QString strFirstName; 1079 QString strFirstName;
1057 QString strMiddleName; 1080 QString strMiddleName;
1058 QString strLastName; 1081 QString strLastName;
1059 QString strSuffix; 1082 QString strSuffix;
1060 QString strTitle; 1083 QString strTitle;
1061 int commapos; 1084 int commapos;
1062 int spCount; 1085 int spCount;
1063 int spPos; 1086 int spPos;
1064 int spPos2; 1087 int spPos2;
1065 1088
1066 1089
1067 commapos = simplifiedName.find( ',', 0, TRUE); 1090 commapos = simplifiedName.find( ',', 0, TRUE);
1068 spCount = simplifiedName.contains( ' ', TRUE ); 1091 spCount = simplifiedName.contains( ' ', TRUE );
1069 1092
1070 if ( commapos == -1 ) { 1093 if ( commapos == -1 ) {
1071 1094
1072 switch (spCount) { 1095 switch (spCount) {
1073 case 0: 1096 case 0:
1074 //return simplifiedName; 1097 //return simplifiedName;
1075 if (txtLastName->text() != "") { 1098 if (txtLastName->text() != "") {
1076 strLastName = simplifiedName; 1099 strLastName = simplifiedName;
1077 break; 1100 break;
1078 } 1101 }
1079 if (txtMiddleName->text() != "") { 1102 if (txtMiddleName->text() != "") {
1080 strMiddleName = simplifiedName; 1103 strMiddleName = simplifiedName;
1081 break; 1104 break;
1082 } 1105 }
1083 if (txtSuffix->text() != "") { 1106 if (txtSuffix->text() != "") {
1084 strSuffix = simplifiedName; 1107 strSuffix = simplifiedName;
1085 break; 1108 break;
1086 } 1109 }
1087 strFirstName = simplifiedName; 1110 strFirstName = simplifiedName;
1088 break; 1111 break;
1089 1112
1090 case 1: 1113 case 1:
1091 spPos = simplifiedName.find( ' ', 0, TRUE ); 1114 spPos = simplifiedName.find( ' ', 0, TRUE );
1092 strFirstName = simplifiedName.left( spPos ); 1115 strFirstName = simplifiedName.left( spPos );
1093 strLastName = simplifiedName.mid( spPos + 1 ); 1116 strLastName = simplifiedName.mid( spPos + 1 );
1094 break; 1117 break;
1095 1118
1096 case 2: 1119 case 2:
1097 spPos = simplifiedName.find( ' ', 0, TRUE ); 1120 spPos = simplifiedName.find( ' ', 0, TRUE );
1098 strFirstName = simplifiedName.left( spPos ); 1121 strFirstName = simplifiedName.left( spPos );
1099 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); 1122 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1100 strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); 1123 strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1101 strLastName = simplifiedName.mid( spPos2 + 1 ); 1124 strLastName = simplifiedName.mid( spPos2 + 1 );
1102 break; 1125 break;
1103 1126
1104 case 3: 1127 case 3:
1105 spPos = simplifiedName.find( ' ', 0, TRUE ); 1128 spPos = simplifiedName.find( ' ', 0, TRUE );
1106 strFirstName = simplifiedName.left( spPos ); 1129 strFirstName = simplifiedName.left( spPos );
1107 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); 1130 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1108 strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); 1131 strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1109 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); 1132 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE );
1110 strLastName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); 1133 strLastName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 );
1111 strSuffix = simplifiedName.mid( spPos + 1 ); 1134 strSuffix = simplifiedName.mid( spPos + 1 );
1112 break; 1135 break;
1113 1136
1114 case 4: 1137 case 4:
1115 spPos = simplifiedName.find( ' ', 0, TRUE ); 1138 spPos = simplifiedName.find( ' ', 0, TRUE );
1116 strTitle = simplifiedName.left( spPos ); 1139 strTitle = simplifiedName.left( spPos );
1117 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); 1140 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1118 strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); 1141 strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1119 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); 1142 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE );
1120 strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); 1143 strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 );
1121 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); 1144 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1122 strLastName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); 1145 strLastName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1123 strSuffix = simplifiedName.mid( spPos2 + 1 ); 1146 strSuffix = simplifiedName.mid( spPos2 + 1 );
1124 break; 1147 break;
1125 1148
1126 default: 1149 default:
1127 spPos = simplifiedName.find( ' ', 0, TRUE ); 1150 spPos = simplifiedName.find( ' ', 0, TRUE );
1128 strTitle = simplifiedName.left( spPos ); 1151 strTitle = simplifiedName.left( spPos );
1129 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); 1152 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1130 strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); 1153 strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1131 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); 1154 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE );
1132 strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); 1155 strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 );
1133 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); 1156 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1134 strLastName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); 1157 strLastName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1135 strSuffix = simplifiedName.mid( spPos2 + 1 ); 1158 strSuffix = simplifiedName.mid( spPos2 + 1 );
1136 break; 1159 break;
1137 } 1160 }
1138 } else { 1161 } else {
1139 simplifiedName.replace( commapos, 1, " " ); 1162 simplifiedName.replace( commapos, 1, " " );
1140 simplifiedName = simplifiedName.simplifyWhiteSpace(); 1163 simplifiedName = simplifiedName.simplifyWhiteSpace();
1141 1164
1142 switch (spCount) { 1165 switch (spCount) {
1143 case 0: 1166 case 0:
1144 //return simplifiedName; 1167 //return simplifiedName;
1145 if (txtLastName->text() != "") { 1168 if (txtLastName->text() != "") {
1146 strLastName = simplifiedName; 1169 strLastName = simplifiedName;
1147 break; 1170 break;
1148 } 1171 }
1149 if (txtMiddleName->text() != "") { 1172 if (txtMiddleName->text() != "") {
1150 strMiddleName = simplifiedName; 1173 strMiddleName = simplifiedName;
1151 break; 1174 break;
1152 } 1175 }
1153 if (txtSuffix->text() != "") { 1176 if (txtSuffix->text() != "") {
1154 strSuffix = simplifiedName; 1177 strSuffix = simplifiedName;
1155 break; 1178 break;
1156 } 1179 }
1157 strFirstName = simplifiedName; 1180 strFirstName = simplifiedName;
1158 break; 1181 break;
1159 1182
1160 case 1: 1183 case 1:
1161 spPos = simplifiedName.find( ' ', 0, TRUE ); 1184 spPos = simplifiedName.find( ' ', 0, TRUE );
1162 strLastName = simplifiedName.left( spPos ); 1185 strLastName = simplifiedName.left( spPos );
1163 strFirstName = simplifiedName.mid( spPos + 1 ); 1186 strFirstName = simplifiedName.mid( spPos + 1 );
1164 break; 1187 break;
1165 1188
1166 case 2: 1189 case 2:
1167 spPos = simplifiedName.find( ' ', 0, TRUE ); 1190 spPos = simplifiedName.find( ' ', 0, TRUE );
1168 strLastName = simplifiedName.left( spPos ); 1191 strLastName = simplifiedName.left( spPos );
1169 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); 1192 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1170 strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); 1193 strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1171 strMiddleName = simplifiedName.mid( spPos2 + 1 ); 1194 strMiddleName = simplifiedName.mid( spPos2 + 1 );
1172 break; 1195 break;
1173 1196
1174 case 3: 1197 case 3:
1175 spPos = simplifiedName.find( ' ', 0, TRUE ); 1198 spPos = simplifiedName.find( ' ', 0, TRUE );
1176 strLastName = simplifiedName.left( spPos ); 1199 strLastName = simplifiedName.left( spPos );
1177 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); 1200 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1178 strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); 1201 strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1179 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); 1202 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE );
1180 strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); 1203 strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 );
1181 strSuffix = simplifiedName.mid( spPos + 1 ); 1204 strSuffix = simplifiedName.mid( spPos + 1 );
1182 break; 1205 break;
1183 1206
1184 case 4: 1207 case 4:
1185 spPos = simplifiedName.find( ' ', 0, TRUE ); 1208 spPos = simplifiedName.find( ' ', 0, TRUE );
1186 strLastName = simplifiedName.left( spPos ); 1209 strLastName = simplifiedName.left( spPos );
1187 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); 1210 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1188 strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); 1211 strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1189 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); 1212 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE );
1190 strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); 1213 strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 );
1191 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); 1214 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1192 strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); 1215 strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1193 strSuffix = simplifiedName.mid( spPos2 + 1 ); 1216 strSuffix = simplifiedName.mid( spPos2 + 1 );
1194 break; 1217 break;
1195 1218
1196 default: 1219 default:
1197 spPos = simplifiedName.find( ' ', 0, TRUE ); 1220 spPos = simplifiedName.find( ' ', 0, TRUE );
1198 strLastName = simplifiedName.left( spPos ); 1221 strLastName = simplifiedName.left( spPos );
1199 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); 1222 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1200 strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); 1223 strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1201 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); 1224 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE );
1202 strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos ); 1225 strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos );
1203 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); 1226 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1204 strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); 1227 strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1205 strSuffix = simplifiedName.mid( spPos2 + 1 ); 1228 strSuffix = simplifiedName.mid( spPos2 + 1 );
1206 break; 1229 break;
1207 } 1230 }
1208 } 1231 }
1209 switch (type) { 1232 switch (type) {
1210 case NAME_FL: 1233 case NAME_FL:
1211 return strFirstName + " " + strLastName; 1234 return strFirstName + " " + strLastName;
1212 1235
1213 case NAME_LF: 1236 case NAME_LF:
1214 return strLastName + ", " + strFirstName; 1237 return strLastName + ", " + strFirstName;
1215 1238
1216 case NAME_LFM: 1239 case NAME_LFM:
1217 return strLastName + ", " + strFirstName + " " + strMiddleName; 1240 return strLastName + ", " + strFirstName + " " + strMiddleName;
1218 1241
1219 case NAME_FMLS: 1242 case NAME_FMLS:
1220 return strFirstName + " " + strMiddleName + " " + strLastName + " " + strSuffix; 1243 return strFirstName + " " + strMiddleName + " " + strLastName + " " + strSuffix;
1221 1244
1222 case NAME_F: 1245 case NAME_F:
1223 return strFirstName; 1246 return strFirstName;
1224 1247
1225 case NAME_M: 1248 case NAME_M:
1226 return strMiddleName; 1249 return strMiddleName;
1227 1250
1228 case NAME_L: 1251 case NAME_L:
1229 return strLastName; 1252 return strLastName;
1230 1253
1231 case NAME_S: 1254 case NAME_S:
1232 return strSuffix; 1255 return strSuffix;
1233 1256
1234 } 1257 }
1235 return QString::null; 1258 return QString::null;
1236} 1259}
1237 1260
1238void ContactEditor::cleanupFields() { 1261void ContactEditor::cleanupFields() {
1239 QStringList::Iterator it = slChooserValues.begin(); 1262 QStringList::Iterator it = slChooserValues.begin();
1240 1263
1241 for ( int i = 0; it != slChooserValues.end(); i++, ++it ) { 1264 for ( int i = 0; it != slChooserValues.end(); i++, ++it ) {
1242 (*it) = ""; 1265 (*it) = "";
1243 } 1266 }
1244 1267
1245 for ( int i = 0; i < 7; i++ ) { 1268 for ( int i = 0; i < 7; i++ ) {
1246 slHomeAddress[i] = ""; 1269 slHomeAddress[i] = "";
1247 slBusinessAddress[i] = ""; 1270 slBusinessAddress[i] = "";
1248 } 1271 }
1249 1272
1250 QListIterator<QLineEdit> itLV( listValue ); 1273 QListIterator<QLineEdit> itLV( listValue );
1251 for ( ; itLV.current(); ++itLV ) { 1274 for ( ; itLV.current(); ++itLV ) {
1252 (*itLV)->setText( "" ); 1275 (*itLV)->setText( "" );
1253 } 1276 }
1254 1277
1255 txtFirstName->setText(""); 1278 txtFirstName->setText("");
1256 txtMiddleName->setText(""); 1279 txtMiddleName->setText("");
1257 txtLastName->setText(""); 1280 txtLastName->setText("");
1258 txtSuffix->setText(""); 1281 txtSuffix->setText("");
1259 txtNote->setText(""); 1282 txtNote->setText("");
1260 txtFullName->setText(""); 1283 txtFullName->setText("");
1261 txtJobTitle->setText(""); 1284 txtJobTitle->setText("");
1262 txtOrganization->setText(""); 1285 txtOrganization->setText("");
1263 txtChooserField1->setText(""); 1286 txtChooserField1->setText("");
1264 txtChooserField2->setText(""); 1287 txtChooserField2->setText("");
1265 txtChooserField3->setText(""); 1288 txtChooserField3->setText("");
1266 txtAddress->setText(""); 1289 txtAddress->setText("");
1267 txtCity->setText(""); 1290 txtCity->setText("");
1268 txtState->setText(""); 1291 txtState->setText("");
1269 txtZip->setText(""); 1292 txtZip->setText("");
1270 QLineEdit *txtTmp = cmbCountry->lineEdit(); 1293 QLineEdit *txtTmp = cmbCountry->lineEdit();
1271 txtTmp->setText(""); 1294 txtTmp->setText("");
1272 txtTmp = cmbFileAs->lineEdit(); 1295 txtTmp = cmbFileAs->lineEdit();
1273 txtTmp->setText(""); 1296 txtTmp->setText("");
1274 1297
1275} 1298}
1276 1299
1277void ContactEditor::setEntry( const OContact &entry ) { 1300void ContactEditor::setEntry( const OContact &entry ) {
1278 1301
1302 initializing = true;
1303
1279 cleanupFields(); 1304 cleanupFields();
1280 1305
1281 ent = entry; 1306 ent = entry;
1282 1307
1283
1284
1285 emails = QStringList(ent.emailList()); 1308 emails = QStringList(ent.emailList());
1286 defaultEmail = ent.defaultEmail(); 1309 defaultEmail = ent.defaultEmail();
1287 if (defaultEmail.isEmpty()) defaultEmail = emails[0]; 1310 if (defaultEmail.isEmpty()) defaultEmail = emails[0];
1288 qDebug("default email=%s",defaultEmail.latin1()); 1311 qDebug("default email=%s",defaultEmail.latin1());
1289 1312
1290 useFullName = false; 1313 useFullName = false;
1291 txtFirstName->setText( ent.firstName() ); 1314 txtFirstName->setText( ent.firstName() );
1292 txtMiddleName->setText( ent.middleName() ); 1315 txtMiddleName->setText( ent.middleName() );
1293 txtLastName->setText( ent.lastName() ); 1316 txtLastName->setText( ent.lastName() );
1294 txtSuffix->setText( ent.suffix() ); 1317 txtSuffix->setText( ent.suffix() );
1295 1318
1296 QString *tmpString = new QString; 1319 QString *tmpString = new QString;
1297 *tmpString = ent.firstName() + " " + ent.middleName() + 1320 *tmpString = ent.firstName() + " " + ent.middleName() +
1298 + " " + ent.lastName() + " " + ent.suffix(); 1321 + " " + ent.lastName() + " " + ent.suffix();
1299 1322
1300 txtFullName->setText( tmpString->simplifyWhiteSpace() ); 1323 txtFullName->setText( tmpString->simplifyWhiteSpace() );
1301 1324
1302 cmbFileAs->setEditText( ent.fileAs() ); 1325 cmbFileAs->setEditText( ent.fileAs() );
1303 1326
1304 //if (hasTitle) 1327 //if (hasTitle)
1305 txtJobTitle->setText( ent.jobTitle() ); 1328 txtJobTitle->setText( ent.jobTitle() );
1306 1329
1307 //if (hasCompany) 1330 //if (hasCompany)
1308 txtOrganization->setText( ent.company() ); 1331 txtOrganization->setText( ent.company() );
1309 1332
1310 //if (hasNotes) 1333 //if (hasNotes)
1311 txtNote->setText( ent.notes() ); 1334 txtNote->setText( ent.notes() );
1312 1335
1313 //if (hasStreet) { 1336 //if (hasStreet) {
1314 slHomeAddress[0] = ent.homeStreet(); 1337 slHomeAddress[0] = ent.homeStreet();
1315 slBusinessAddress[0] = ent.businessStreet(); 1338 slBusinessAddress[0] = ent.businessStreet();
1316 //} 1339 //}
1317 1340
1318 //if (hasCity) { 1341 //if (hasCity) {
1319 slHomeAddress[3] = ent.homeCity(); 1342 slHomeAddress[3] = ent.homeCity();
1320 slBusinessAddress[3] = ent.businessCity(); 1343 slBusinessAddress[3] = ent.businessCity();
1321//} 1344//}
1322 1345
1323//if (hasState) { 1346//if (hasState) {
1324 slHomeAddress[4] = ent.homeState(); 1347 slHomeAddress[4] = ent.homeState();
1325 slBusinessAddress[4] = ent.businessState(); 1348 slBusinessAddress[4] = ent.businessState();
1326//} 1349//}
1327 1350
1328//if (hasZip) { 1351//if (hasZip) {
1329 slHomeAddress[5] = ent.homeZip(); 1352 slHomeAddress[5] = ent.homeZip();
1330 slBusinessAddress[5] = ent.businessZip(); 1353 slBusinessAddress[5] = ent.businessZip();
1331//} 1354//}
1332 1355
1333//if (hasCountry) { 1356//if (hasCountry) {
1334 slHomeAddress[6] = ent.homeCountry(); 1357 slHomeAddress[6] = ent.homeCountry();
1335 slBusinessAddress[6] = ent.businessCountry(); 1358 slBusinessAddress[6] = ent.businessCountry();
1336//} 1359//}
1337 1360
1338 QStringList::ConstIterator it; 1361 QStringList::ConstIterator it;
1339 QListIterator<QLineEdit> itLE( listValue ); 1362 QListIterator<QLineEdit> itLE( listValue );
1340 for ( it = slDynamicEntries.begin(); itLE.current()/* != slDynamicEntries.end()*/; ++it, ++itLE) { 1363 for ( it = slDynamicEntries.begin(); itLE.current()/* != slDynamicEntries.end()*/; ++it, ++itLE) {
1341 1364
1342 qWarning(" Filling dynamic Field: %s", (*it).latin1() ); 1365 qWarning(" Filling dynamic Field: %s", (*it).latin1() );
1343 1366
1344 if ( *it == "Department" ) 1367 if ( *it == "Department" )
1345 (*itLE)->setText( ent.department() ); 1368 (*itLE)->setText( ent.department() );
1346 1369
1347 if ( *it == "Company" ) 1370 if ( *it == "Company" )
1348 (*itLE)->setText( ent.company() ); 1371 (*itLE)->setText( ent.company() );
1349 1372
1350 if ( *it == "Office" ) 1373 if ( *it == "Office" )
1351 (*itLE)->setText( ent.office() ); 1374 (*itLE)->setText( ent.office() );
1352 1375
1353 if ( *it == "Profession" ) 1376 if ( *it == "Profession" )
1354 (*itLE)->setText( ent.profession() ); 1377 (*itLE)->setText( ent.profession() );
1355 1378
1356 if ( *it == "Assistant" ) 1379 if ( *it == "Assistant" )
1357 (*itLE)->setText( ent.assistant() ); 1380 (*itLE)->setText( ent.assistant() );
1358 1381
1359 if ( *it == "Manager" ) 1382 if ( *it == "Manager" )
1360 (*itLE)->setText( ent.manager() ); 1383 (*itLE)->setText( ent.manager() );
1361 1384
1362 if ( *it == "Spouse" ) 1385 if ( *it == "Spouse" )
1363 (*itLE)->setText( ent.spouse() ); 1386 (*itLE)->setText( ent.spouse() );
1364 1387
1365 if ( *it == "Nickname" ){ 1388 if ( *it == "Nickname" ){
1366 qWarning("**** Nichname: %s", ent.nickname().latin1() ); 1389 qWarning("**** Nichname: %s", ent.nickname().latin1() );
1367 (*itLE)->setText( ent.nickname() ); 1390 (*itLE)->setText( ent.nickname() );
1368 } 1391 }
1369 1392
1370 if ( *it == "Children" ) 1393 if ( *it == "Children" )
1371 (*itLE)->setText( ent.children() ); 1394 (*itLE)->setText( ent.children() );
1372 1395
1373 } 1396 }
1374 1397
1375 QStringList::Iterator itV; 1398 QStringList::Iterator itV;
1376 for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) { 1399 for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) {
1377 1400
1378 if ( ( *it == "Business Phone") || ( *it == "Work Phone" ) ) 1401 if ( ( *it == "Business Phone") || ( *it == "Work Phone" ) )
1379 *itV = ent.businessPhone(); 1402 *itV = ent.businessPhone();
1380/* 1403/*
1381 if ( *it == "Business 2 Phone" ) 1404 if ( *it == "Business 2 Phone" )
1382 *itV = ent.business2Phone(); 1405 *itV = ent.business2Phone();
1383*/ 1406*/
1384 if ( ( *it == "Business Fax") || ( *it == "Work Fax" ) ) 1407 if ( ( *it == "Business Fax") || ( *it == "Work Fax" ) )
1385 *itV = ent.businessFax(); 1408 *itV = ent.businessFax();
1386 1409
1387 if ( ( *it == "Business Mobile" ) || ( *it == "work Mobile" ) ) 1410 if ( ( *it == "Business Mobile" ) || ( *it == "work Mobile" ) )
1388 *itV = ent.businessMobile(); 1411 *itV = ent.businessMobile();
1389/* 1412/*
1390 if ( *it == "Company Phone" ) 1413 if ( *it == "Company Phone" )
1391 *itV = ent.companyPhone(); 1414 *itV = ent.companyPhone();
1392*/ 1415*/
1393 if ( *it == "Default Email" ) 1416 if ( *it == "Default Email" )
1394 *itV = ent.defaultEmail(); 1417 *itV = ent.defaultEmail();
1395 1418
1396 if ( *it == "Emails" ) 1419 if ( *it == "Emails" )
1397 *itV = ent.emailList().join(", "); // :SX 1420 *itV = ent.emailList().join(", "); // :SX
1398 1421
1399 if ( *it == "Home Phone" ) 1422 if ( *it == "Home Phone" )
1400 *itV = ent.homePhone(); 1423 *itV = ent.homePhone();
1401/* 1424/*
1402 if ( *it == "Home 2 Phone" ) 1425 if ( *it == "Home 2 Phone" )
1403 *itV = ent.home2Phone(); 1426 *itV = ent.home2Phone();
1404*/ 1427*/
1405 if ( *it == "Home Fax" ) 1428 if ( *it == "Home Fax" )
1406 *itV = ent.homeFax(); 1429 *itV = ent.homeFax();
1407 1430
1408 if ( *it == "Home Mobile" ) 1431 if ( *it == "Home Mobile" )
1409 *itV = ent.homeMobile(); 1432 *itV = ent.homeMobile();
1410/* 1433/*
1411 if ( *it == "Car Phone" ) 1434 if ( *it == "Car Phone" )
1412 *itV = ent.carPhone(); 1435 *itV = ent.carPhone();
1413 1436
1414 if ( *it == "ISDN Phone" ) 1437 if ( *it == "ISDN Phone" )
1415 *itV = ent.ISDNPhone(); 1438 *itV = ent.ISDNPhone();
1416 1439
1417 if ( *it == "Other Phone" ) 1440 if ( *it == "Other Phone" )
1418 *itV = ent.otherPhone(); 1441 *itV = ent.otherPhone();
1419*/ 1442*/
1420 if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) ) 1443 if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) )
1421 *itV = ent.businessPager(); 1444 *itV = ent.businessPager();
1422/* 1445/*
1423 if ( *it == "Home Pager") 1446 if ( *it == "Home Pager")
1424 *itV = ent.homePager(); 1447 *itV = ent.homePager();
1425 1448
1426 if ( *it == "AIM IM" ) 1449 if ( *it == "AIM IM" )
1427 *itV = ent.AIMIM(); 1450 *itV = ent.AIMIM();
1428 1451
1429 if ( *it == "ICQ IM" ) 1452 if ( *it == "ICQ IM" )
1430 *itV = ent.ICQIM(); 1453 *itV = ent.ICQIM();
1431 1454
1432 if ( *it == "Jabber IM" ) 1455 if ( *it == "Jabber IM" )
1433 *itV = ent.jabberIM(); 1456 *itV = ent.jabberIM();
1434 1457
1435 if ( *it == "MSN IM" ) 1458 if ( *it == "MSN IM" )
1436 *itV = ent.MSNIM(); 1459 *itV = ent.MSNIM();
1437 1460
1438 if ( *it == "Yahoo IM" ) 1461 if ( *it == "Yahoo IM" )
1439 *itV = ent.yahooIM(); 1462 *itV = ent.yahooIM();
1440*/ 1463*/
1441 if ( *it == "Home Web Page" ) 1464 if ( *it == "Home Web Page" )
1442 *itV = ent.homeWebpage(); 1465 *itV = ent.homeWebpage();
1443 1466
1444 if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) ) 1467 if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) )
1445 *itV = ent.businessWebpage(); 1468 *itV = ent.businessWebpage();
1446 1469
1447 1470
1448 } 1471 }
1449 1472
1450 1473
1451 cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") ); 1474 cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") );
1452 1475
1453 QString gender = ent.gender(); 1476 QString gender = ent.gender();
1454 cmbGender->setCurrentItem( gender.toInt() ); 1477 cmbGender->setCurrentItem( gender.toInt() );
1455 1478
1456 txtNote->setText( ent.notes() ); 1479 txtNote->setText( ent.notes() );
1457 1480
1481 slotAddressTypeChange( cmbAddress->currentItem() );
1482
1483 // Calling "show()" to arrange all widgets. Otherwise we will get
1484 // a wrong position of the textfields and are unable to put our
1485 // default-email combo over it.. This is very ugly !
1486 // Does anybody has a better solution ?
1487 // Basically we should rethink the strategy to hide
1488 // a textfield with overwriting.. (se)
1489 show();
1490
1491 // Get combo-settings from contact and set preset..
1492 contactfields.loadFromRecord( ent );
1493 cmbChooserField1->setCurrentItem( contactfields.getFieldOrder(0, 0) );
1494 cmbChooserField2->setCurrentItem( contactfields.getFieldOrder(1, 1) );
1495 cmbChooserField3->setCurrentItem( contactfields.getFieldOrder(2, 2) );
1496 cmbChooserField4->setCurrentItem( contactfields.getFieldOrder(3, 5) );
1497 cmbAddress->setCurrentItem( contactfields.getFieldOrder(4, 1) );
1458 slotCmbChooser1Change( cmbChooserField1->currentItem() ); 1498 slotCmbChooser1Change( cmbChooserField1->currentItem() );
1459 slotCmbChooser2Change( cmbChooserField2->currentItem() ); 1499 slotCmbChooser2Change( cmbChooserField2->currentItem() );
1460 slotCmbChooser3Change( cmbChooserField3->currentItem() ); 1500 slotCmbChooser3Change( cmbChooserField3->currentItem() );
1461 1501 slotCmbChooser4Change( cmbChooserField4->currentItem() );
1462 slotAddressTypeChange( cmbAddress->currentItem() ); 1502 slotAddressTypeChange( cmbAddress->currentItem() );
1463 1503
1464 // loadFields(); :SX
1465 updateDatePicker(); 1504 updateDatePicker();
1505
1506 initializing = false;
1466} 1507}
1467void ContactEditor::updateDatePicker() 1508void ContactEditor::updateDatePicker()
1468{ 1509{
1469 // Set DatePicker 1510 // Set DatePicker
1470 if ( !ent.birthday().isNull() ){ 1511 if ( !ent.birthday().isNull() ){
1471 birthdayButton->setText( TimeString::numberDateString( ent.birthday() ) ); 1512 birthdayButton->setText( TimeString::numberDateString( ent.birthday() ) );
1472 birthdayPicker->setDate( ent.birthday() ); 1513 birthdayPicker->setDate( ent.birthday() );
1473 } else 1514 } else
1474 birthdayButton->setText( tr ("Unknown") ); 1515 birthdayButton->setText( tr ("Unknown") );
1475 1516
1476 if ( !ent.anniversary().isNull() ){ 1517 if ( !ent.anniversary().isNull() ){
1477 anniversaryButton->setText( TimeString::numberDateString( ent.anniversary() ) ); 1518 anniversaryButton->setText( TimeString::numberDateString( ent.anniversary() ) );
1478 anniversaryPicker->setDate( ent.anniversary() ); 1519 anniversaryPicker->setDate( ent.anniversary() );
1479 } else 1520 } else
1480 anniversaryButton->setText( tr ("Unknown") ); 1521 anniversaryButton->setText( tr ("Unknown") );
1481 1522
1482} 1523}
1483 1524
1484void ContactEditor::saveEntry() { 1525void ContactEditor::saveEntry() {
1485 1526
1486 1527 // Store current combo into contact
1528 contactfields.saveToRecord( ent );
1529
1487 if ( useFullName ) { 1530 if ( useFullName ) {
1488 txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) ); 1531 txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) );
1489 txtMiddleName->setText( parseName( txtFullName->text(), NAME_M ) ); 1532 txtMiddleName->setText( parseName( txtFullName->text(), NAME_M ) );
1490 txtLastName->setText( parseName( txtFullName->text(), NAME_L ) ); 1533 txtLastName->setText( parseName( txtFullName->text(), NAME_L ) );
1491 txtSuffix->setText( parseName( txtFullName->text(), NAME_S ) ); 1534 txtSuffix->setText( parseName( txtFullName->text(), NAME_S ) );
1492 1535
1493 useFullName = false; 1536 useFullName = false;
1494 } 1537 }
1495 1538
1496 ent.setFirstName( txtFirstName->text() ); 1539 ent.setFirstName( txtFirstName->text() );
1497 ent.setLastName( txtLastName->text() ); 1540 ent.setLastName( txtLastName->text() );
1498 ent.setMiddleName( txtMiddleName->text() ); 1541 ent.setMiddleName( txtMiddleName->text() );
1499 ent.setSuffix( txtSuffix->text() ); 1542 ent.setSuffix( txtSuffix->text() );
1500 1543
1501 ent.setFileAs( cmbFileAs->currentText() ); 1544 ent.setFileAs( cmbFileAs->currentText() );
1502 1545
1503 ent.setCategories( cmbCat->currentCategories() ); 1546 ent.setCategories( cmbCat->currentCategories() );
1504 1547
1505 1548
1506 //if (hasTitle) 1549 //if (hasTitle)
1507 ent.setJobTitle( txtJobTitle->text() ); 1550 ent.setJobTitle( txtJobTitle->text() );
1508 1551
1509 //if (hasCompany) 1552 //if (hasCompany)
1510 ent.setCompany( txtOrganization->text() ); 1553 ent.setCompany( txtOrganization->text() );
1511 1554
1512 //if (hasNotes) 1555 //if (hasNotes)
1513 ent.setNotes( txtNote->text() ); 1556 ent.setNotes( txtNote->text() );
1514 1557
1515 //if (hasStreet) { 1558 //if (hasStreet) {
1516 ent.setHomeStreet( slHomeAddress[0] ); 1559 ent.setHomeStreet( slHomeAddress[0] );
1517 ent.setBusinessStreet( slBusinessAddress[0] ); 1560 ent.setBusinessStreet( slBusinessAddress[0] );
1518 //} 1561 //}
1519 1562
1520 //if (hasCity) { 1563 //if (hasCity) {
1521 ent.setHomeCity( slHomeAddress[3] ); 1564 ent.setHomeCity( slHomeAddress[3] );
1522 ent.setBusinessCity( slBusinessAddress[3] ); 1565 ent.setBusinessCity( slBusinessAddress[3] );
1523 //} 1566 //}
1524 1567
1525 //if (hasState) { 1568 //if (hasState) {
1526 ent.setHomeState( slHomeAddress[4] ); 1569 ent.setHomeState( slHomeAddress[4] );
1527 ent.setBusinessState( slBusinessAddress[4] ); 1570 ent.setBusinessState( slBusinessAddress[4] );
1528 //} 1571 //}
1529 1572
1530 //if (hasZip) { 1573 //if (hasZip) {
1531 ent.setHomeZip( slHomeAddress[5] ); 1574 ent.setHomeZip( slHomeAddress[5] );
1532 ent.setBusinessZip( slBusinessAddress[5] ); 1575 ent.setBusinessZip( slBusinessAddress[5] );
1533 //} 1576 //}
1534 1577
1535 //if (hasCountry) { 1578 //if (hasCountry) {
1536 ent.setHomeCountry( slHomeAddress[6] ); 1579 ent.setHomeCountry( slHomeAddress[6] );
1537 ent.setBusinessCountry( slBusinessAddress[6] ); 1580 ent.setBusinessCountry( slBusinessAddress[6] );
1538 //} 1581 //}
1539 1582
1540 QStringList::ConstIterator it; 1583 QStringList::ConstIterator it;
1541 QListIterator<QLineEdit> itLE( listValue ); 1584 QListIterator<QLineEdit> itLE( listValue );
1542 for ( it = slDynamicEntries.begin(); itLE.current() && it != slDynamicEntries.end(); ++it, ++itLE) { 1585 for ( it = slDynamicEntries.begin(); itLE.current() && it != slDynamicEntries.end(); ++it, ++itLE) {
1543 1586
1544 if ( *it == "Department" ) 1587 if ( *it == "Department" )
1545 ent.setDepartment( (*itLE)->text() ); 1588 ent.setDepartment( (*itLE)->text() );
1546 1589
1547 if ( *it == "Company" ) 1590 if ( *it == "Company" )
1548 ent.setCompany( (*itLE)->text() ); 1591 ent.setCompany( (*itLE)->text() );
1549 1592
1550 if ( *it == "Office" ) 1593 if ( *it == "Office" )
1551 ent.setOffice( (*itLE)->text() ); 1594 ent.setOffice( (*itLE)->text() );
1552 1595
1553 if ( *it == "Profession" ) 1596 if ( *it == "Profession" )
1554 ent.setProfession( (*itLE)->text() ); 1597 ent.setProfession( (*itLE)->text() );
1555 1598
1556 if ( *it == "Assistant" ) 1599 if ( *it == "Assistant" )
1557 ent.setAssistant( (*itLE)->text() ); 1600 ent.setAssistant( (*itLE)->text() );
1558 1601
1559 if ( *it == "Manager" ) 1602 if ( *it == "Manager" )
1560 ent.setManager( (*itLE)->text() ); 1603 ent.setManager( (*itLE)->text() );
1561 1604
1562 if ( *it == "Spouse" ) 1605 if ( *it == "Spouse" )
1563 ent.setSpouse( (*itLE)->text() ); 1606 ent.setSpouse( (*itLE)->text() );
1564 1607
1565 if ( *it == "Nickname" ) 1608 if ( *it == "Nickname" )
1566 ent.setNickname( (*itLE)->text() ); 1609 ent.setNickname( (*itLE)->text() );
1567 1610
1568 if ( *it == "Children" ) 1611 if ( *it == "Children" )
1569 ent.setChildren( (*itLE)->text() ); 1612 ent.setChildren( (*itLE)->text() );
1570 1613
1571 } 1614 }
1572 1615
1573 1616
1574 QStringList::ConstIterator itV; 1617 QStringList::ConstIterator itV;
1575 for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) { 1618 for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) {
1576 1619
1577 if ( ( *it == "Business Phone" ) || ( *it == "Work Phone" ) ) 1620 if ( ( *it == "Business Phone" ) || ( *it == "Work Phone" ) )
1578 ent.setBusinessPhone( *itV ); 1621 ent.setBusinessPhone( *itV );
1579 1622
1580 if ( ( *it == "Business Fax" ) || ( *it == "Work Fax" ) ) 1623 if ( ( *it == "Business Fax" ) || ( *it == "Work Fax" ) )
1581 ent.setBusinessFax( *itV ); 1624 ent.setBusinessFax( *itV );
1582 1625
1583 if ( ( *it == "Business Mobile" ) || ( *it == "Work Mobile" ) ) 1626 if ( ( *it == "Business Mobile" ) || ( *it == "Work Mobile" ) )
1584 ent.setBusinessMobile( *itV ); 1627 ent.setBusinessMobile( *itV );
1585 1628
1586 if ( *it == "Emails" ){ 1629 if ( *it == "Emails" ){
1587 QString allemail; 1630 QString allemail;
1588 QString defaultmail; 1631 QString defaultmail;
1589 parseEmailFrom( emails.join(","), defaultmail, allemail ); 1632 parseEmailFrom( emails.join(","), defaultmail, allemail );
1590 if ( defaultEmail.isEmpty() ){ 1633 if ( defaultEmail.isEmpty() ){
1591 qWarning("Default email was not set by user!"); 1634 qWarning("Default email was not set by user!");
1592 qWarning("Using first email in list: %s", defaultmail.latin1()); 1635 qWarning("Using first email in list: %s", defaultmail.latin1());
1593 ent.setDefaultEmail( defaultmail ); 1636 ent.setDefaultEmail( defaultmail );
1594 } 1637 }
1595 ent.setEmails( allemail ); 1638 ent.setEmails( allemail );
1596 } 1639 }
1597 1640
1598 if ( *it == "Default Email") 1641 if ( *it == "Default Email")
1599 ent.setDefaultEmail( defaultEmail /* *itV */ ); 1642 ent.setDefaultEmail( defaultEmail /* *itV */ );
1600 1643
1601 if ( *it == "Home Phone" ) 1644 if ( *it == "Home Phone" )
1602 ent.setHomePhone( *itV ); 1645 ent.setHomePhone( *itV );
1603 1646
1604 if ( *it == "Home Fax" ) 1647 if ( *it == "Home Fax" )
1605 ent.setHomeFax( *itV ); 1648 ent.setHomeFax( *itV );
1606 1649
1607 if ( *it == "Home Mobile" ) 1650 if ( *it == "Home Mobile" )
1608 ent.setHomeMobile( *itV ); 1651 ent.setHomeMobile( *itV );
1609 1652
1610 if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) ) 1653 if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) )
1611 ent.setBusinessPager( *itV ); 1654 ent.setBusinessPager( *itV );
1612 1655
1613 if ( *it == "Home Web Page" ) 1656 if ( *it == "Home Web Page" )
1614 ent.setHomeWebpage( *itV ); 1657 ent.setHomeWebpage( *itV );
1615 1658
1616 if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) ) 1659 if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) )
1617 ent.setBusinessWebpage( *itV ); 1660 ent.setBusinessWebpage( *itV );
1618 1661
1619 1662
1620 } 1663 }
1621 1664
1622 int gender = cmbGender->currentItem(); 1665 int gender = cmbGender->currentItem();
1623 ent.setGender( QString::number( gender ) ); 1666 ent.setGender( QString::number( gender ) );
1624 1667
1625 QString str = txtNote->text(); 1668 QString str = txtNote->text();
1626 if ( !str.isNull() ) 1669 if ( !str.isNull() )
1627 ent.setNotes( str ); 1670 ent.setNotes( str );
1628 1671
1629} 1672}
1630 1673
1631void parseEmailFrom( const QString &txt, QString &strDefaultEmail, 1674void parseEmailFrom( const QString &txt, QString &strDefaultEmail,
1632 QString &strAll ) 1675 QString &strAll )
1633{ 1676{
1634 int where, 1677 int where,
1635 start; 1678 start;
1636 if ( txt.isEmpty() ) 1679 if ( txt.isEmpty() )
1637 return; 1680 return;
1638 // find the first 1681 // find the first
1639 where = txt.find( ',' ); 1682 where = txt.find( ',' );
1640 if ( where < 0 ) { 1683 if ( where < 0 ) {
1641 strDefaultEmail = txt; 1684 strDefaultEmail = txt;
1642 strAll = txt; 1685 strAll = txt;
1643 } else { 1686 } else {
1644 strDefaultEmail = txt.left( where ).stripWhiteSpace(); 1687 strDefaultEmail = txt.left( where ).stripWhiteSpace();
1645 strAll = strDefaultEmail; 1688 strAll = strDefaultEmail;
1646 while ( where > -1 ) { 1689 while ( where > -1 ) {
1647 strAll.append(" "); 1690 strAll.append(" ");
1648 start = where; 1691 start = where;
1649 where = txt.find( ',', where + 1 ); 1692 where = txt.find( ',', where + 1 );
1650 if ( where > - 1 ) 1693 if ( where > - 1 )
1651 strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() ); 1694 strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() );
1652 else // grab until the end... 1695 else // grab until the end...
1653 strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() ); 1696 strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() );
1654 } 1697 }
1655 } 1698 }
1656} 1699}
1657 1700
1658void parseEmailTo( const QString &strDefaultEmail, 1701void parseEmailTo( const QString &strDefaultEmail,
1659 const QString &strOtherEmail, QString &strBack ) 1702 const QString &strOtherEmail, QString &strBack )
1660{ 1703{
1661 // create a comma dilimeted set of emails... 1704 // create a comma dilimeted set of emails...
1662 // use the power of short circuiting... 1705 // use the power of short circuiting...
1663 bool foundDefault = false; 1706 bool foundDefault = false;
1664 QString strTmp; 1707 QString strTmp;
1665 int start = 0; 1708 int start = 0;
1666 int where; 1709 int where;
1667 // start at the beginng. 1710 // start at the beginng.
1668 strBack = strDefaultEmail; 1711 strBack = strDefaultEmail;
1669 where = 0; 1712 where = 0;
1670 while ( where > -1 ) { 1713 while ( where > -1 ) {
1671 start = where; 1714 start = where;
1672 where = strOtherEmail.find( ' ', where + 1 ); 1715 where = strOtherEmail.find( ' ', where + 1 );
1673 if ( where > 0 ) { 1716 if ( where > 0 ) {
1674 strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace(); 1717 strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace();
1675 } else 1718 } else
1676 strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace(); 1719 strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace();
1677 if ( foundDefault || strTmp != strDefaultEmail ) { 1720 if ( foundDefault || strTmp != strDefaultEmail ) {
1678 strBack.append( ", " ); 1721 strBack.append( ", " );
1679 strBack.append( strTmp ); 1722 strBack.append( strTmp );
1680 } else 1723 } else
1681 foundDefault = true; 1724 foundDefault = true;
1682 } 1725 }
1683} 1726}
1684 1727
1685 1728
1686static inline bool containsAlphaNum( const QString &str ) 1729static inline bool containsAlphaNum( const QString &str )
1687{ 1730{
1688 int i, 1731 int i,
1689 count = str.length(); 1732 count = str.length();
1690 for ( i = 0; i < count; i++ ) 1733 for ( i = 0; i < count; i++ )
1691 if ( !str[i].isSpace() ) 1734 if ( !str[i].isSpace() )
1692 return TRUE; 1735 return TRUE;
1693 return FALSE; 1736 return FALSE;
1694} 1737}
1695 1738
1696static inline bool constainsWhiteSpace( const QString &str ) 1739static inline bool constainsWhiteSpace( const QString &str )
1697{ 1740{
1698 int i, 1741 int i,
1699 count = str.length(); 1742 count = str.length();
1700 for (i = 0; i < count; i++ ) 1743 for (i = 0; i < count; i++ )
1701 if ( str[i].isSpace() ) 1744 if ( str[i].isSpace() )
1702 return TRUE; 1745 return TRUE;
1703 return FALSE; 1746 return FALSE;
1704} 1747}
1705 1748
1706void ContactEditor::setPersonalView( bool personal ) 1749void ContactEditor::setPersonalView( bool personal )
1707{ 1750{
1708 m_personalView = personal; 1751 m_personalView = personal;
1709 1752
1710 // Currently disbled due to the fact that 1753 // Currently disbled due to the fact that
1711 // show will not work... 1754 // show will not work...
1712 return; 1755 return;
1713 1756
1714 if ( personal ){ 1757 if ( personal ){
1715 cmbCat->hide(); 1758 cmbCat->hide();
1716 labCat->hide(); 1759 labCat->hide();
1717 1760
1718 } else{ 1761 } else{
1719 cmbCat->show(); 1762 cmbCat->show();
1720 labCat->show(); 1763 labCat->show();
1721 } 1764 }
1722} 1765}
1723 1766
1724void ContactEditor::slotAnniversaryDateChanged( int year, int month, int day) 1767void ContactEditor::slotAnniversaryDateChanged( int year, int month, int day)
1725{ 1768{
1726 QDate date; 1769 QDate date;
1727 date.setYMD( year, month, day ); 1770 date.setYMD( year, month, day );
1728 QString dateString = TimeString::numberDateString( date ); 1771 QString dateString = TimeString::numberDateString( date );
1729 anniversaryButton->setText( dateString ); 1772 anniversaryButton->setText( dateString );
1730 ent.setAnniversary ( date ); 1773 ent.setAnniversary ( date );
1731} 1774}
1732 1775
1733void ContactEditor::slotBirthdayDateChanged( int year, int month, int day) 1776void ContactEditor::slotBirthdayDateChanged( int year, int month, int day)
1734{ 1777{
1735 QDate date; 1778 QDate date;
1736 date.setYMD( year, month, day ); 1779 date.setYMD( year, month, day );
1737 QString dateString = TimeString::numberDateString( date ); 1780 QString dateString = TimeString::numberDateString( date );
1738 birthdayButton->setText( dateString ); 1781 birthdayButton->setText( dateString );
1739 ent.setBirthday ( date ); 1782 ent.setBirthday ( date );
1740} 1783}
1741 1784
1742void ContactEditor::slotRemoveBirthday() 1785void ContactEditor::slotRemoveBirthday()
1743{ 1786{
1744 qWarning("void ContactEditor::slotRemoveBirthday()"); 1787 qWarning("void ContactEditor::slotRemoveBirthday()");
1745 ent.setBirthday( QDate() ); 1788 ent.setBirthday( QDate() );
1746 updateDatePicker(); 1789 updateDatePicker();
1747} 1790}
1748 1791
1749void ContactEditor::slotRemoveAnniversary() 1792void ContactEditor::slotRemoveAnniversary()
1750{ 1793{
1751 qWarning("void ContactEditor::slotRemoveAnniversary()"); 1794 qWarning("void ContactEditor::slotRemoveAnniversary()");
1752 ent.setAnniversary( QDate() ); 1795 ent.setAnniversary( QDate() );
1753 updateDatePicker(); 1796 updateDatePicker();
1754} 1797}
diff --git a/core/pim/addressbook/contacteditor.h b/core/pim/addressbook/contacteditor.h
index 4fa48d1..95f9f2d 100644
--- a/core/pim/addressbook/contacteditor.h
+++ b/core/pim/addressbook/contacteditor.h
@@ -1,181 +1,186 @@
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#ifndef CONTACTEDITOR_H 21#ifndef CONTACTEDITOR_H
22#define CONTACTEDITOR_H 22#define CONTACTEDITOR_H
23 23
24#include <opie/ocontact.h> 24#include <opie/ocontact.h>
25 25
26#include <qpe/datebookmonth.h> 26#include <qpe/datebookmonth.h>
27 27
28#include <qdialog.h> 28#include <qdialog.h>
29#include <qlist.h> 29#include <qlist.h>
30#include <qmap.h> 30#include <qmap.h>
31#include <qstringlist.h> 31#include <qstringlist.h>
32 32
33#include "ocontactfields.h"
34
33const int NAME_LF = 0; 35const int NAME_LF = 0;
34const int NAME_LFM = 1; 36const int NAME_LFM = 1;
35const int NAME_FL = 2; 37const int NAME_FL = 2;
36const int NAME_FMLS = 3; 38const int NAME_FMLS = 3;
37 39
38const int NAME_F = 4; 40const int NAME_F = 4;
39const int NAME_M = 5; 41const int NAME_M = 5;
40const int NAME_L = 6; 42const int NAME_L = 6;
41const int NAME_S = 7; 43const int NAME_S = 7;
42 44
43 45
44class QScrollView; 46class QScrollView;
45class QTabWidget; 47class QTabWidget;
46class QMultiLineEdit; 48class QMultiLineEdit;
47class QLineEdit; 49class QLineEdit;
48class QComboBox; 50class QComboBox;
49class QPushButton; 51class QPushButton;
50class CategorySelect; 52class CategorySelect;
51class QLabel; 53class QLabel;
52 54
53class ContactEditor : public QDialog { 55class ContactEditor : public QDialog {
54 Q_OBJECT 56 Q_OBJECT
55 57
56 public: 58 public:
57 ContactEditor(const OContact &entry, 59 ContactEditor(const OContact &entry,
58 QWidget *parent = 0, 60 QWidget *parent = 0,
59 const char *name = 0, 61 const char *name = 0,
60 WFlags fl = 0 ); 62 WFlags fl = 0 );
61 ~ContactEditor(); 63 ~ContactEditor();
62 void setNameFocus(); 64 void setNameFocus();
63 void setPersonalView( bool personal = true ); 65 void setPersonalView( bool personal = true );
64 OContact entry() const { return ent; } 66 OContact entry() const { return ent; }
65 67
66 public slots: 68 public slots:
67 void slotNote(); 69 void slotNote();
68 void slotName(); 70 void slotName();
69 void setEntry(const OContact &entry); 71 void setEntry(const OContact &entry);
70 72
71 protected slots: 73 protected slots:
72 void accept(); 74 void accept();
73 75
74 private: 76 private:
75 void init(); 77 void init();
76 void saveEntry(); 78 void saveEntry();
77 bool isEmpty(); 79 bool isEmpty();
78 void cleanupFields(); 80 void cleanupFields();
79 void updateDatePicker(); 81 void updateDatePicker();
80 QString parseName( QString fullName, int type ); 82 QString parseName( QString fullName, int type );
81 void chooserError( int index ); 83 void chooserError( int index );
82 private slots: 84 private slots:
83 void slotChooser1Change( const QString &textChanged ); 85 void slotChooser1Change( const QString &textChanged );
84 void slotChooser2Change( const QString &textChanged ); 86 void slotChooser2Change( const QString &textChanged );
85 void slotChooser3Change( const QString &textChanged ); 87 void slotChooser3Change( const QString &textChanged );
86 void slotChooser4Change( const QString &textChanged ); 88 void slotChooser4Change( const QString &textChanged );
87 void slotCmbChooser1Change( int index ); 89 void slotCmbChooser1Change( int index );
88 void slotCmbChooser2Change( int index ); 90 void slotCmbChooser2Change( int index );
89 void slotCmbChooser3Change( int index ); 91 void slotCmbChooser3Change( int index );
90 void slotCmbChooser4Change( int index ); 92 void slotCmbChooser4Change( int index );
91 void slotAddressTypeChange( int index ); 93 void slotAddressTypeChange( int index );
92 void slotAddressChange( const QString &textChanged ); 94 void slotAddressChange( const QString &textChanged );
93 void slotAddress2Change( const QString &textChanged ); 95 void slotAddress2Change( const QString &textChanged );
94 void slotPOBoxChange( const QString &textChanged ); 96 void slotPOBoxChange( const QString &textChanged );
95 void slotCityChange( const QString &textChanged ); 97 void slotCityChange( const QString &textChanged );
96 void slotStateChange( const QString &textChanged ); 98 void slotStateChange( const QString &textChanged );
97 void slotZipChange( const QString &textChanged ); 99 void slotZipChange( const QString &textChanged );
98 void slotCountryChange( const QString &textChanged ); 100 void slotCountryChange( const QString &textChanged );
99 void slotFullNameChange( const QString &textChanged ); 101 void slotFullNameChange( const QString &textChanged );
100 void slotAnniversaryDateChanged( int year, int month, int day); 102 void slotAnniversaryDateChanged( int year, int month, int day);
101 void slotBirthdayDateChanged( int year, int month, int day); 103 void slotBirthdayDateChanged( int year, int month, int day);
102 void slotRemoveBirthday(); 104 void slotRemoveBirthday();
103 void slotRemoveAnniversary(); 105 void slotRemoveAnniversary();
104 void defaultEmailChanged(int); 106 void defaultEmailChanged(int);
105 107
106 private: 108 private:
107 int defaultEmailChooserPosition; 109 int defaultEmailChooserPosition;
108 void populateDefaultEmailCmb(); 110 void populateDefaultEmailCmb();
109 void chooserChange( const QString&, int , QLineEdit*, int ); 111 void chooserChange( const QString&, int , QLineEdit*, int );
110 bool cmbChooserChange( int , QLineEdit*, int ); 112 bool cmbChooserChange( int , QLineEdit*, int );
113 OContactFields contactfields;
111 114
112 bool useFullName; 115 bool useFullName;
113 116
114 OContact ent; 117 OContact ent;
115 118
116 QDialog *dlgNote; 119 QDialog *dlgNote;
117 QDialog *dlgName; 120 QDialog *dlgName;
118 121
119 QList<QLineEdit> listValue; 122 QList<QLineEdit> listValue;
120 QList<QLabel> listName; 123 QList<QLabel> listName;
121 124
122 QStringList slDynamicEntries; 125 QStringList slDynamicEntries;
123 QStringList trlDynamicEntries; 126 QStringList trlDynamicEntries;
124 127
125 bool m_personalView; 128 bool m_personalView;
126 129
127 QStringList slHomeAddress; 130 QStringList slHomeAddress;
128 QStringList slBusinessAddress; 131 QStringList slBusinessAddress;
129 QStringList slChooserNames; 132 QStringList slChooserNames;
130 QStringList slChooserValues; 133 QStringList slChooserValues;
131 QStringList emails; 134 QStringList emails;
132 QString defaultEmail; 135 QString defaultEmail;
133 136
134 QMultiLineEdit *txtNote; 137 QMultiLineEdit *txtNote;
135 QLabel *lblNote; 138 QLabel *lblNote;
136 139
137 //QLineEdit *txtTitle; 140 //QLineEdit *txtTitle;
138 QLineEdit *txtFirstName; 141 QLineEdit *txtFirstName;
139 QLineEdit *txtMiddleName; 142 QLineEdit *txtMiddleName;
140 QLineEdit *txtLastName; 143 QLineEdit *txtLastName;
141 QLineEdit *txtSuffix; 144 QLineEdit *txtSuffix;
142 145
143 QTabWidget *tabMain; 146 QTabWidget *tabMain;
144 QScrollView *svGeneral; 147 QScrollView *svGeneral;
145 QPushButton *btnFullName; 148 QPushButton *btnFullName;
146 QPushButton *btnNote; 149 QPushButton *btnNote;
147 QLineEdit *txtFullName; 150 QLineEdit *txtFullName;
148 QLineEdit *txtJobTitle; 151 QLineEdit *txtJobTitle;
149 QLineEdit *txtOrganization; 152 QLineEdit *txtOrganization;
150 QLineEdit *txtChooserField1; 153 QLineEdit *txtChooserField1;
151 QLineEdit *txtChooserField2; 154 QLineEdit *txtChooserField2;
152 QLineEdit *txtChooserField3; 155 QLineEdit *txtChooserField3;
153 QLineEdit *txtChooserField4; 156 QLineEdit *txtChooserField4;
154 QComboBox *cmbChooserField1; 157 QComboBox *cmbChooserField1;
155 QComboBox *cmbChooserField2; 158 QComboBox *cmbChooserField2;
156 QComboBox *cmbChooserField3; 159 QComboBox *cmbChooserField3;
157 QComboBox *cmbChooserField4; 160 QComboBox *cmbChooserField4;
158 QComboBox *cmbDefaultEmail; 161 QComboBox *cmbDefaultEmail;
159 QComboBox *cmbFileAs; 162 QComboBox *cmbFileAs;
160 CategorySelect *cmbCat; 163 CategorySelect *cmbCat;
161 QLabel *labCat; 164 QLabel *labCat;
162 165
163 QScrollView *svAddress; 166 QScrollView *svAddress;
164 QLineEdit *txtAddress; 167 QLineEdit *txtAddress;
165 //QLineEdit *txtAddress2; 168 //QLineEdit *txtAddress2;
166 //QLineEdit *txtPOBox; 169 //QLineEdit *txtPOBox;
167 QLineEdit *txtCity; 170 QLineEdit *txtCity;
168 QLineEdit *txtState; 171 QLineEdit *txtState;
169 QLineEdit *txtZip; 172 QLineEdit *txtZip;
170 QComboBox *cmbAddress; 173 QComboBox *cmbAddress;
171 QComboBox *cmbCountry; 174 QComboBox *cmbCountry;
172 175
173 QScrollView *svDetails; 176 QScrollView *svDetails;
174 QComboBox *cmbGender; 177 QComboBox *cmbGender;
175 DateBookMonth* birthdayPicker; 178 DateBookMonth* birthdayPicker;
176 QToolButton* birthdayButton; 179 QToolButton* birthdayButton;
177 DateBookMonth* anniversaryPicker; 180 DateBookMonth* anniversaryPicker;
178 QToolButton* anniversaryButton; 181 QToolButton* anniversaryButton;
182
183 bool initializing;
179 }; 184 };
180 185
181#endif 186#endif
diff --git a/core/pim/addressbook/ocontactfields.cpp b/core/pim/addressbook/ocontactfields.cpp
index 0da6a4f..75a7641 100644
--- a/core/pim/addressbook/ocontactfields.cpp
+++ b/core/pim/addressbook/ocontactfields.cpp
@@ -1,274 +1,369 @@
1 1
2#include "ocontactfields.h" 2#include "ocontactfields.h"
3 3
4#include <qstringlist.h> 4#include <qstringlist.h>
5#include <qobject.h> 5#include <qobject.h>
6 6
7// We should use our own enum in the future .. 7// We should use our own enum in the future ..
8#include <qpe/recordfields.h> 8#include <qpe/recordfields.h>
9#include <qpe/config.h>
10#include <opie/ocontact.h>
9 11
10/*! 12/*!
11 \internal 13 \internal
12 Returns a list of details field names for a contact. 14 Returns a list of details field names for a contact.
13*/ 15*/
14QStringList OContactFields::untrdetailsfields( bool sorted ) 16QStringList OContactFields::untrdetailsfields( bool sorted )
15{ 17{
16 QStringList list; 18 QStringList list;
17 19
18 list.append( "Office" ); 20 list.append( "Office" );
19 list.append( "Profession" ); 21 list.append( "Profession" );
20 list.append( "Assistant" ); 22 list.append( "Assistant" );
21 list.append( "Manager" ); 23 list.append( "Manager" );
22 24
23 list.append( "Spouse" ); 25 list.append( "Spouse" );
24 list.append( "Gender" ); 26 list.append( "Gender" );
25 list.append( "Birthday" ); 27 list.append( "Birthday" );
26 list.append( "Anniversary" ); 28 list.append( "Anniversary" );
27 list.append( "Nickname" ); 29 list.append( "Nickname" );
28 list.append( "Children" ); 30 list.append( "Children" );
29 31
30 if (sorted) list.sort(); 32 if (sorted) list.sort();
31 return list; 33 return list;
32} 34}
33 35
34/*! 36/*!
35 \internal 37 \internal
36 Returns a translated list of details field names for a contact. 38 Returns a translated list of details field names for a contact.
37*/ 39*/
38QStringList OContactFields::trdetailsfields( bool sorted ) 40QStringList OContactFields::trdetailsfields( bool sorted )
39{ 41{
40 QStringList list; 42 QStringList list;
41 43
42 list.append( QObject::tr( "Office" ) ); 44 list.append( QObject::tr( "Office" ) );
43 list.append( QObject::tr( "Profession" ) ); 45 list.append( QObject::tr( "Profession" ) );
44 list.append( QObject::tr( "Assistant" ) ); 46 list.append( QObject::tr( "Assistant" ) );
45 list.append( QObject::tr( "Manager" ) ); 47 list.append( QObject::tr( "Manager" ) );
46 48
47 list.append( QObject::tr( "Spouse" ) ); 49 list.append( QObject::tr( "Spouse" ) );
48 list.append( QObject::tr( "Gender" ) ); 50 list.append( QObject::tr( "Gender" ) );
49 list.append( QObject::tr( "Birthday" ) ); 51 list.append( QObject::tr( "Birthday" ) );
50 list.append( QObject::tr( "Anniversary" ) ); 52 list.append( QObject::tr( "Anniversary" ) );
51 list.append( QObject::tr( "Nickname" ) ); 53 list.append( QObject::tr( "Nickname" ) );
52 list.append( QObject::tr( "Children" ) ); 54 list.append( QObject::tr( "Children" ) );
53 55
54 if (sorted) list.sort(); 56 if (sorted) list.sort();
55 return list; 57 return list;
56} 58}
57 59
58 60
59/*! 61/*!
60 \internal 62 \internal
61 Returns a translated list of phone field names for a contact. 63 Returns a translated list of phone field names for a contact.
62*/ 64*/
63QStringList OContactFields::trphonefields( bool sorted ) 65QStringList OContactFields::trphonefields( bool sorted )
64{ 66{
65 QStringList list; 67 QStringList list;
66 list.append( QObject::tr( "Business Phone" ) ); 68 list.append( QObject::tr( "Business Phone" ) );
67 list.append( QObject::tr( "Business Fax" ) ); 69 list.append( QObject::tr( "Business Fax" ) );
68 list.append( QObject::tr( "Business Mobile" ) ); 70 list.append( QObject::tr( "Business Mobile" ) );
69 71
70 list.append( QObject::tr( "Default Email" ) ); 72 list.append( QObject::tr( "Default Email" ) );
71 list.append( QObject::tr( "Emails" ) ); 73 list.append( QObject::tr( "Emails" ) );
72 74
73 list.append( QObject::tr( "Home Phone" ) ); 75 list.append( QObject::tr( "Home Phone" ) );
74 list.append( QObject::tr( "Home Fax" ) ); 76 list.append( QObject::tr( "Home Fax" ) );
75 list.append( QObject::tr( "Home Mobile" ) ); 77 list.append( QObject::tr( "Home Mobile" ) );
76 78
77 if (sorted) list.sort(); 79 if (sorted) list.sort();
78 80
79 return list; 81 return list;
80} 82}
81 83
82 84
83/*! 85/*!
84 \internal 86 \internal
85 Returns a list of phone field names for a contact. 87 Returns a list of phone field names for a contact.
86*/ 88*/
87QStringList OContactFields::untrphonefields( bool sorted ) 89QStringList OContactFields::untrphonefields( bool sorted )
88{ 90{
89 QStringList list; 91 QStringList list;
90 92
91 list.append( "Business Phone" ); 93 list.append( "Business Phone" );
92 list.append( "Business Fax" ); 94 list.append( "Business Fax" );
93 list.append( "Business Mobile" ); 95 list.append( "Business Mobile" );
94 96
95 list.append( "Default Email" ); 97 list.append( "Default Email" );
96 list.append( "Emails" ); 98 list.append( "Emails" );
97 99
98 list.append( "Home Phone" ); 100 list.append( "Home Phone" );
99 list.append( "Home Fax" ); 101 list.append( "Home Fax" );
100 list.append( "Home Mobile" ); 102 list.append( "Home Mobile" );
101 103
102 if (sorted) list.sort(); 104 if (sorted) list.sort();
103 105
104 return list; 106 return list;
105} 107}
106 108
107 109
108/*! 110/*!
109 \internal 111 \internal
110 Returns a translated list of field names for a contact. 112 Returns a translated list of field names for a contact.
111*/ 113*/
112QStringList OContactFields::trfields( bool sorted ) 114QStringList OContactFields::trfields( bool sorted )
113{ 115{
114 QStringList list; 116 QStringList list;
115 117
116 list.append( QObject::tr( "Name Title") ); 118 list.append( QObject::tr( "Name Title") );
117 list.append( QObject::tr( "First Name" ) ); 119 list.append( QObject::tr( "First Name" ) );
118 list.append( QObject::tr( "Middle Name" ) ); 120 list.append( QObject::tr( "Middle Name" ) );
119 list.append( QObject::tr( "Last Name" ) ); 121 list.append( QObject::tr( "Last Name" ) );
120 list.append( QObject::tr( "Suffix" ) ); 122 list.append( QObject::tr( "Suffix" ) );
121 list.append( QObject::tr( "File As" ) ); 123 list.append( QObject::tr( "File As" ) );
122 124
123 list.append( QObject::tr( "Job Title" ) ); 125 list.append( QObject::tr( "Job Title" ) );
124 list.append( QObject::tr( "Department" ) ); 126 list.append( QObject::tr( "Department" ) );
125 list.append( QObject::tr( "Company" ) ); 127 list.append( QObject::tr( "Company" ) );
126 128
127 list += trphonefields( sorted ); 129 list += trphonefields( sorted );
128 130
129 list.append( QObject::tr( "Business Street" ) ); 131 list.append( QObject::tr( "Business Street" ) );
130 list.append( QObject::tr( "Business City" ) ); 132 list.append( QObject::tr( "Business City" ) );
131 list.append( QObject::tr( "Business State" ) ); 133 list.append( QObject::tr( "Business State" ) );
132 list.append( QObject::tr( "Business Zip" ) ); 134 list.append( QObject::tr( "Business Zip" ) );
133 list.append( QObject::tr( "Business Country" ) ); 135 list.append( QObject::tr( "Business Country" ) );
134 list.append( QObject::tr( "Business Pager" ) ); 136 list.append( QObject::tr( "Business Pager" ) );
135 list.append( QObject::tr( "Business WebPage" ) ); 137 list.append( QObject::tr( "Business WebPage" ) );
136 138
137 list.append( QObject::tr( "Home Street" ) ); 139 list.append( QObject::tr( "Home Street" ) );
138 list.append( QObject::tr( "Home City" ) ); 140 list.append( QObject::tr( "Home City" ) );
139 list.append( QObject::tr( "Home State" ) ); 141 list.append( QObject::tr( "Home State" ) );
140 list.append( QObject::tr( "Home Zip" ) ); 142 list.append( QObject::tr( "Home Zip" ) );
141 list.append( QObject::tr( "Home Country" ) ); 143 list.append( QObject::tr( "Home Country" ) );
142 list.append( QObject::tr( "Home Web Page" ) ); 144 list.append( QObject::tr( "Home Web Page" ) );
143 145
144 list += trdetailsfields( sorted ); 146 list += trdetailsfields( sorted );
145 147
146 list.append( QObject::tr( "Notes" ) ); 148 list.append( QObject::tr( "Notes" ) );
147 list.append( QObject::tr( "Groups" ) ); 149 list.append( QObject::tr( "Groups" ) );
148 150
149 if (sorted) list.sort(); 151 if (sorted) list.sort();
150 152
151 return list; 153 return list;
152} 154}
153 155
154/*! 156/*!
155 \internal 157 \internal
156 Returns an untranslated list of field names for a contact. 158 Returns an untranslated list of field names for a contact.
157*/ 159*/
158QStringList OContactFields::untrfields( bool sorted ) 160QStringList OContactFields::untrfields( bool sorted )
159{ 161{
160 QStringList list; 162 QStringList list;
161 163
162 list.append( "Name Title" ); 164 list.append( "Name Title" );
163 list.append( "First Name" ); 165 list.append( "First Name" );
164 list.append( "Middle Name" ); 166 list.append( "Middle Name" );
165 list.append( "Last Name" ); 167 list.append( "Last Name" );
166 list.append( "Suffix" ); 168 list.append( "Suffix" );
167 list.append( "File As" ); 169 list.append( "File As" );
168 170
169 list.append( "Job Title" ); 171 list.append( "Job Title" );
170 list.append( "Department" ); 172 list.append( "Department" );
171 list.append( "Company" ); 173 list.append( "Company" );
172 174
173 list += untrphonefields( sorted ); 175 list += untrphonefields( sorted );
174 176
175 list.append( "Business Street" ); 177 list.append( "Business Street" );
176 list.append( "Business City" ); 178 list.append( "Business City" );
177 list.append( "Business State" ); 179 list.append( "Business State" );
178 list.append( "Business Zip" ); 180 list.append( "Business Zip" );
179 list.append( "Business Country" ); 181 list.append( "Business Country" );
180 list.append( "Business Pager" ); 182 list.append( "Business Pager" );
181 list.append( "Business WebPage" ); 183 list.append( "Business WebPage" );
182 184
183 list.append( "Home Street" ); 185 list.append( "Home Street" );
184 list.append( "Home City" ); 186 list.append( "Home City" );
185 list.append( "Home State" ); 187 list.append( "Home State" );
186 list.append( "Home Zip" ); 188 list.append( "Home Zip" );
187 list.append( "Home Country" ); 189 list.append( "Home Country" );
188 list.append( "Home Web Page" ); 190 list.append( "Home Web Page" );
189 191
190 list += untrdetailsfields( sorted ); 192 list += untrdetailsfields( sorted );
191 193
192 list.append( "Notes" ); 194 list.append( "Notes" );
193 list.append( "Groups" ); 195 list.append( "Groups" );
194 196
195 if (sorted) list.sort(); 197 if (sorted) list.sort();
196 198
197 return list; 199 return list;
198} 200}
199QMap<int, QString> OContactFields::idToTrFields() 201QMap<int, QString> OContactFields::idToTrFields()
200{ 202{
201 QMap<int, QString> ret_map; 203 QMap<int, QString> ret_map;
202 204
203 ret_map.insert( Qtopia::Title, QObject::tr( "Name Title") ); 205 ret_map.insert( Qtopia::Title, QObject::tr( "Name Title") );
204 ret_map.insert( Qtopia::FirstName, QObject::tr( "First Name" ) ); 206 ret_map.insert( Qtopia::FirstName, QObject::tr( "First Name" ) );
205 ret_map.insert( Qtopia::MiddleName, QObject::tr( "Middle Name" ) ); 207 ret_map.insert( Qtopia::MiddleName, QObject::tr( "Middle Name" ) );
206 ret_map.insert( Qtopia::LastName, QObject::tr( "Last Name" ) ); 208 ret_map.insert( Qtopia::LastName, QObject::tr( "Last Name" ) );
207 ret_map.insert( Qtopia::Suffix, QObject::tr( "Suffix" )); 209 ret_map.insert( Qtopia::Suffix, QObject::tr( "Suffix" ));
208 ret_map.insert( Qtopia::FileAs, QObject::tr( "File As" ) ); 210 ret_map.insert( Qtopia::FileAs, QObject::tr( "File As" ) );
209 211
210 ret_map.insert( Qtopia::JobTitle, QObject::tr( "Job Title" ) ); 212 ret_map.insert( Qtopia::JobTitle, QObject::tr( "Job Title" ) );
211 ret_map.insert( Qtopia::Department, QObject::tr( "Department" ) ); 213 ret_map.insert( Qtopia::Department, QObject::tr( "Department" ) );
212 ret_map.insert( Qtopia::Company, QObject::tr( "Company" ) ); 214 ret_map.insert( Qtopia::Company, QObject::tr( "Company" ) );
213 ret_map.insert( Qtopia::BusinessPhone, QObject::tr( "Business Phone" ) ); 215 ret_map.insert( Qtopia::BusinessPhone, QObject::tr( "Business Phone" ) );
214 ret_map.insert( Qtopia::BusinessFax, QObject::tr( "Business Fax" ) ); 216 ret_map.insert( Qtopia::BusinessFax, QObject::tr( "Business Fax" ) );
215 ret_map.insert( Qtopia::BusinessMobile, QObject::tr( "Business Mobile" )); 217 ret_map.insert( Qtopia::BusinessMobile, QObject::tr( "Business Mobile" ));
216 218
217 // email 219 // email
218 ret_map.insert( Qtopia::DefaultEmail, QObject::tr( "Default Email" ) ); 220 ret_map.insert( Qtopia::DefaultEmail, QObject::tr( "Default Email" ) );
219 ret_map.insert( Qtopia::Emails, QObject::tr( "Emails" ) ); 221 ret_map.insert( Qtopia::Emails, QObject::tr( "Emails" ) );
220 222
221 ret_map.insert( Qtopia::HomePhone, QObject::tr( "Home Phone" ) ); 223 ret_map.insert( Qtopia::HomePhone, QObject::tr( "Home Phone" ) );
222 ret_map.insert( Qtopia::HomeFax, QObject::tr( "Home Fax" ) ); 224 ret_map.insert( Qtopia::HomeFax, QObject::tr( "Home Fax" ) );
223 ret_map.insert( Qtopia::HomeMobile, QObject::tr( "Home Mobile" ) ); 225 ret_map.insert( Qtopia::HomeMobile, QObject::tr( "Home Mobile" ) );
224 226
225 // business 227 // business
226 ret_map.insert( Qtopia::BusinessStreet, QObject::tr( "Business Street" ) ); 228 ret_map.insert( Qtopia::BusinessStreet, QObject::tr( "Business Street" ) );
227 ret_map.insert( Qtopia::BusinessCity, QObject::tr( "Business City" ) ); 229 ret_map.insert( Qtopia::BusinessCity, QObject::tr( "Business City" ) );
228 ret_map.insert( Qtopia::BusinessState, QObject::tr( "Business State" ) ); 230 ret_map.insert( Qtopia::BusinessState, QObject::tr( "Business State" ) );
229 ret_map.insert( Qtopia::BusinessZip, QObject::tr( "Business Zip" ) ); 231 ret_map.insert( Qtopia::BusinessZip, QObject::tr( "Business Zip" ) );
230 ret_map.insert( Qtopia::BusinessCountry, QObject::tr( "Business Country" ) ); 232 ret_map.insert( Qtopia::BusinessCountry, QObject::tr( "Business Country" ) );
231 ret_map.insert( Qtopia::BusinessPager, QObject::tr( "Business Pager" ) ); 233 ret_map.insert( Qtopia::BusinessPager, QObject::tr( "Business Pager" ) );
232 ret_map.insert( Qtopia::BusinessWebPage, QObject::tr( "Business WebPage" ) ); 234 ret_map.insert( Qtopia::BusinessWebPage, QObject::tr( "Business WebPage" ) );
233 235
234 ret_map.insert( Qtopia::Office, QObject::tr( "Office" ) ); 236 ret_map.insert( Qtopia::Office, QObject::tr( "Office" ) );
235 ret_map.insert( Qtopia::Profession, QObject::tr( "Profession" ) ); 237 ret_map.insert( Qtopia::Profession, QObject::tr( "Profession" ) );
236 ret_map.insert( Qtopia::Assistant, QObject::tr( "Assistant" ) ); 238 ret_map.insert( Qtopia::Assistant, QObject::tr( "Assistant" ) );
237 ret_map.insert( Qtopia::Manager, QObject::tr( "Manager" ) ); 239 ret_map.insert( Qtopia::Manager, QObject::tr( "Manager" ) );
238 240
239 // home 241 // home
240 ret_map.insert( Qtopia::HomeStreet, QObject::tr( "Home Street" ) ); 242 ret_map.insert( Qtopia::HomeStreet, QObject::tr( "Home Street" ) );
241 ret_map.insert( Qtopia::HomeCity, QObject::tr( "Home City" ) ); 243 ret_map.insert( Qtopia::HomeCity, QObject::tr( "Home City" ) );
242 ret_map.insert( Qtopia::HomeState, QObject::tr( "Home State" ) ); 244 ret_map.insert( Qtopia::HomeState, QObject::tr( "Home State" ) );
243 ret_map.insert( Qtopia::HomeZip, QObject::tr( "Home Zip" ) ); 245 ret_map.insert( Qtopia::HomeZip, QObject::tr( "Home Zip" ) );
244 ret_map.insert( Qtopia::HomeCountry, QObject::tr( "Home Country" ) ); 246 ret_map.insert( Qtopia::HomeCountry, QObject::tr( "Home Country" ) );
245 ret_map.insert( Qtopia::HomeWebPage, QObject::tr( "Home Web Page" ) ); 247 ret_map.insert( Qtopia::HomeWebPage, QObject::tr( "Home Web Page" ) );
246 248
247 //personal 249 //personal
248 ret_map.insert( Qtopia::Spouse, QObject::tr( "Spouse" ) ); 250 ret_map.insert( Qtopia::Spouse, QObject::tr( "Spouse" ) );
249 ret_map.insert( Qtopia::Gender, QObject::tr( "Gender" ) ); 251 ret_map.insert( Qtopia::Gender, QObject::tr( "Gender" ) );
250 ret_map.insert( Qtopia::Birthday, QObject::tr( "Birthday" ) ); 252 ret_map.insert( Qtopia::Birthday, QObject::tr( "Birthday" ) );
251 ret_map.insert( Qtopia::Anniversary, QObject::tr( "Anniversary" ) ); 253 ret_map.insert( Qtopia::Anniversary, QObject::tr( "Anniversary" ) );
252 ret_map.insert( Qtopia::Nickname, QObject::tr( "Nickname" ) ); 254 ret_map.insert( Qtopia::Nickname, QObject::tr( "Nickname" ) );
253 ret_map.insert( Qtopia::Children, QObject::tr( "Children" ) ); 255 ret_map.insert( Qtopia::Children, QObject::tr( "Children" ) );
254 256
255 // other 257 // other
256 ret_map.insert( Qtopia::Notes, QObject::tr( "Notes" ) ); 258 ret_map.insert( Qtopia::Notes, QObject::tr( "Notes" ) );
257 259
258 260
259 return ret_map; 261 return ret_map;
260} 262}
261 263
262QMap<QString, int> OContactFields::trFieldsToId() 264QMap<QString, int> OContactFields::trFieldsToId()
263{ 265{
264 QMap<int, QString> idtostr = idToTrFields(); 266 QMap<int, QString> idtostr = idToTrFields();
265 QMap<QString, int> ret_map; 267 QMap<QString, int> ret_map;
266 268
267 269
268 QMap<int, QString>::Iterator it; 270 QMap<int, QString>::Iterator it;
269 for( it = idtostr.begin(); it != idtostr.end(); ++it ) 271 for( it = idtostr.begin(); it != idtostr.end(); ++it )
270 ret_map.insert( *it, it.key() ); 272 ret_map.insert( *it, it.key() );
271 273
272 274
273 return ret_map; 275 return ret_map;
274} 276}
277
278OContactFields::OContactFields():
279 fieldOrder( DEFAULT_FIELD_ORDER ),
280 changedFieldOrder( false )
281{
282 // Get the global field order from the config file and
283 // use it as a start pattern
284 Config cfg ( "AddressBook" );
285 cfg.setGroup( "ContactFieldOrder" );
286 globalFieldOrder = cfg.readEntry( "General", DEFAULT_FIELD_ORDER );
287}
288
289OContactFields::~OContactFields(){
290
291 // We will store the fieldorder into the config file
292 // to reuse it for the future..
293 if ( changedFieldOrder ){
294 Config cfg ( "AddressBook" );
295 cfg.setGroup( "ContactFieldOrder" );
296 cfg.writeEntry( "General", globalFieldOrder );
297 }
298}
299
300
301
302void OContactFields::saveToRecord( OContact &cnt ){
303
304 qDebug("ocontactfields saveToRecord: >%s<",fieldOrder.latin1());
305
306 // Store fieldorder into this contact.
307 cnt.setCustomField( CONTACT_FIELD_ORDER_NAME, fieldOrder );
308
309 globalFieldOrder = fieldOrder;
310 changedFieldOrder = true;
311
312}
313
314void OContactFields::loadFromRecord( const OContact &cnt ){
315 qDebug("ocontactfields loadFromRecord");
316 qDebug("loading >%s<",cnt.fullName().latin1());
317
318 // Get fieldorder for this contact. If none is defined,
319 // we will use the global one from the config file..
320
321 fieldOrder = cnt.customField( CONTACT_FIELD_ORDER_NAME );
322
323 qDebug("fieldOrder from contact>%s<",fieldOrder.latin1());
324
325 if (fieldOrder.isEmpty()){
326 fieldOrder = globalFieldOrder;
327 }
328
329
330 qDebug("effective fieldOrder in loadFromRecord >%s<",fieldOrder.latin1());
331}
332
333void OContactFields::setFieldOrder( int num, int index ){
334 qDebug("qcontactfields setfieldorder pos %i -> %i",num,index);
335
336 fieldOrder[num] = QString::number( index )[0];
337
338 // We will store this new fieldorder globally to
339 // remember it for contacts which have none
340 globalFieldOrder = fieldOrder;
341 changedFieldOrder = true;
342
343 qDebug("fieldOrder >%s<",fieldOrder.latin1());
344}
345
346int OContactFields::getFieldOrder( int num, int defIndex ){
347 qDebug("ocontactfields getFieldOrder");
348 qDebug("fieldOrder >%s<",fieldOrder.latin1());
349
350 // Get index of combo as char..
351 QChar poschar = fieldOrder[num];
352
353 bool ok;
354 int ret = 0;
355 // Convert char to number..
356 if ( !( poschar == QChar::null ) )
357 ret = QString( poschar ).toInt(&ok, 10);
358 else
359 ok = false;
360
361 // Return default value if index for
362 // num was not set or if anything else happened..
363 if ( !ok ) ret = defIndex;
364
365 qDebug("returning >%i<",ret);
366
367 return ret;
368
369}
diff --git a/core/pim/addressbook/ocontactfields.h b/core/pim/addressbook/ocontactfields.h
index 796bc0a..bf3a7f5 100644
--- a/core/pim/addressbook/ocontactfields.h
+++ b/core/pim/addressbook/ocontactfields.h
@@ -1,24 +1,58 @@
1#ifndef OPIE_CONTACTS_FIELDS 1#ifndef OPIE_CONTACTS_FIELDS
2#define OPIE_CONTACTS_FIELDS 2#define OPIE_CONTACTS_FIELDS
3 3
4class QStringList; 4class QStringList;
5 5
6#include <qmap.h> 6#include <qmap.h>
7#include <qstring.h> 7#include <qstring.h>
8#include <opie/ocontact.h>
8 9
10#define CONTACT_FIELD_ORDER_NAME "opie-contactfield-order"
11#define DEFAULT_FIELD_ORDER "__________"
12
9class OContactFields{ 13class OContactFields{
10 14
11 public: 15 public:
16 OContactFields();
17 ~OContactFields();
18 /** Set the index for combo boxes.
19 * Sets the <b>index</b> of combo <b>num</b>.
20 * @param num selects the number of the combo
21 * @param index sets the index in the combo
22 */
23 void setFieldOrder( int num, int index );
24
25 /** Get the index for combo boxes.
26 * Returns the index of combo <b>num</b> or defindex
27 * if none was defined..
28 * @param num Selects the number of the combo
29 * @param defIndex will be returned if none was defined (either
30 * globally in the config file, nor by the contact which was used
31 * by loadFromRecord() )
32 */
33 int getFieldOrder( int num, int defIndex);
34
35 /** Store fieldorder to contact. */
36 void saveToRecord( OContact& );
37 /** Get Fieldorder from contact. */
38 void loadFromRecord( const OContact& );
39
40 private:
41 QString fieldOrder;
42 QString globalFieldOrder;
43 bool changedFieldOrder;
44
45 public:
12 static QStringList trphonefields( bool sorted = true ); 46 static QStringList trphonefields( bool sorted = true );
13 static QStringList untrphonefields( bool sorted = true ); 47 static QStringList untrphonefields( bool sorted = true );
14 static QStringList trdetailsfields( bool sorted = true ); 48 static QStringList trdetailsfields( bool sorted = true );
15 static QStringList untrdetailsfields( bool sorted = true ); 49 static QStringList untrdetailsfields( bool sorted = true );
16 static QStringList trfields( bool sorted = true ); 50 static QStringList trfields( bool sorted = true );
17 static QStringList untrfields( bool sorted = true ); 51 static QStringList untrfields( bool sorted = true );
18 52
19 static QMap<int, QString> idToTrFields(); 53 static QMap<int, QString> idToTrFields();
20 static QMap<QString, int> trFieldsToId(); 54 static QMap<QString, int> trFieldsToId();
21 55
22}; 56};
23 57
24#endif 58#endif
diff --git a/core/pim/addressbook/version.h b/core/pim/addressbook/version.h
index b740326..e716fe4 100644
--- a/core/pim/addressbook/version.h
+++ b/core/pim/addressbook/version.h
@@ -1,10 +1,10 @@
1#ifndef _VERSION_H_ 1#ifndef _VERSION_H_
2#define _VERSION_H_ 2#define _VERSION_H_
3 3
4#define MAINVERSION "0" 4#define MAINVERSION "0"
5#define SUBVERSION "1" 5#define SUBVERSION "2"
6#define PATCHVERSION "1" 6#define PATCHVERSION "0"
7 7
8#define APPNAME "OPIE_ADDRESSBOOK" 8#define APPNAME "OPIE_ADDRESSBOOK"
9 9
10#endif 10#endif