author | eilers <eilers> | 2002-10-27 16:18:51 (UTC) |
---|---|---|
committer | eilers <eilers> | 2002-10-27 16:18:51 (UTC) |
commit | cc01384d8c2b421d5f455f32631d8c2ec4b7e844 (patch) (unidiff) | |
tree | 0917ecf78c54b17620a583e584198881db24fee2 | |
parent | 5f09fc992af19fc208315217eb46635a762f1e55 (diff) | |
download | opie-cc01384d8c2b421d5f455f32631d8c2ec4b7e844.zip opie-cc01384d8c2b421d5f455f32631d8c2ec4b7e844.tar.gz opie-cc01384d8c2b421d5f455f32631d8c2ec4b7e844.tar.bz2 |
OContact now uses QDate to avoid wrong interpreted strings
A lot of inline functions moved into the library..
-rw-r--r-- | core/pim/addressbook/abtable.cpp | 5 | ||||
-rw-r--r-- | core/pim/addressbook/contacteditor.cpp | 34 |
2 files changed, 20 insertions, 19 deletions
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp index 4feadeb..5222f16 100644 --- a/core/pim/addressbook/abtable.cpp +++ b/core/pim/addressbook/abtable.cpp | |||
@@ -1,840 +1,841 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #define QTOPIA_INTERNAL_CONTACT_MRE | 21 | #define QTOPIA_INTERNAL_CONTACT_MRE |
22 | 22 | ||
23 | #include <qpe/categoryselect.h> | 23 | #include <qpe/categoryselect.h> |
24 | #include <qpe/config.h> | 24 | #include <qpe/config.h> |
25 | #include <qpe/stringutil.h> | 25 | #include <qpe/stringutil.h> |
26 | #include <qpe/qcopenvelope_qws.h> | 26 | #include <qpe/qcopenvelope_qws.h> |
27 | #include <qpe/timestring.h> | ||
27 | 28 | ||
28 | #include <opie/orecordlist.h> | 29 | #include <opie/orecordlist.h> |
29 | 30 | ||
30 | #include <qasciidict.h> | 31 | #include <qasciidict.h> |
31 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
32 | #include <qfile.h> | 33 | #include <qfile.h> |
33 | #include <qregexp.h> | 34 | #include <qregexp.h> |
34 | #include <qmessagebox.h> | 35 | #include <qmessagebox.h> |
35 | 36 | ||
36 | #include "abtable.h" | 37 | #include "abtable.h" |
37 | 38 | ||
38 | #include <errno.h> | 39 | #include <errno.h> |
39 | #include <fcntl.h> | 40 | #include <fcntl.h> |
40 | #include <unistd.h> | 41 | #include <unistd.h> |
41 | #include <stdlib.h> | 42 | #include <stdlib.h> |
42 | 43 | ||
43 | #include <ctype.h> //toupper() for key hack | 44 | #include <ctype.h> //toupper() for key hack |
44 | 45 | ||
45 | static bool contactCompare( const OContact &cnt, const QRegExp &r, int category ); | 46 | static bool contactCompare( const OContact &cnt, const QRegExp &r, int category ); |
46 | 47 | ||
47 | 48 | ||
48 | /*! | 49 | /*! |
49 | \class AbTableItem abtable.h | 50 | \class AbTableItem abtable.h |
50 | 51 | ||
51 | \brief QTableItem based class for showing a field of an entry | 52 | \brief QTableItem based class for showing a field of an entry |
52 | */ | 53 | */ |
53 | 54 | ||
54 | AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s, | 55 | AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s, |
55 | const QString &secondSortKey) | 56 | const QString &secondSortKey) |
56 | : QTableItem( t, et, s ) | 57 | : QTableItem( t, et, s ) |
57 | { | 58 | { |
58 | // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower(); | 59 | // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower(); |
59 | sortKey = Qtopia::buildSortKey( s, secondSortKey ); | 60 | sortKey = Qtopia::buildSortKey( s, secondSortKey ); |
60 | } | 61 | } |
61 | 62 | ||
62 | int AbTableItem::alignment() const | 63 | int AbTableItem::alignment() const |
63 | { | 64 | { |
64 | return AlignLeft|AlignVCenter; | 65 | return AlignLeft|AlignVCenter; |
65 | } | 66 | } |
66 | 67 | ||
67 | QString AbTableItem::key() const | 68 | QString AbTableItem::key() const |
68 | { | 69 | { |
69 | return sortKey; | 70 | return sortKey; |
70 | } | 71 | } |
71 | 72 | ||
72 | // A way to reset the item, without out doing a delete or a new... | 73 | // A way to reset the item, without out doing a delete or a new... |
73 | void AbTableItem::setItem( const QString &txt, const QString &secondKey ) | 74 | void AbTableItem::setItem( const QString &txt, const QString &secondKey ) |
74 | { | 75 | { |
75 | setText( txt ); | 76 | setText( txt ); |
76 | sortKey = Qtopia::buildSortKey( txt, secondKey ); | 77 | sortKey = Qtopia::buildSortKey( txt, secondKey ); |
77 | 78 | ||
78 | // sortKey = txt.lower() + QChar( '\0' ) + secondKey.lower(); | 79 | // sortKey = txt.lower() + QChar( '\0' ) + secondKey.lower(); |
79 | } | 80 | } |
80 | 81 | ||
81 | /*! | 82 | /*! |
82 | \class AbPickItem abtable.h | 83 | \class AbPickItem abtable.h |
83 | 84 | ||
84 | \brief QTableItem based class for showing slection of an entry | 85 | \brief QTableItem based class for showing slection of an entry |
85 | */ | 86 | */ |
86 | 87 | ||
87 | AbPickItem::AbPickItem( QTable *t ) : | 88 | AbPickItem::AbPickItem( QTable *t ) : |
88 | QTableItem(t, WhenCurrent, "?") | 89 | QTableItem(t, WhenCurrent, "?") |
89 | { | 90 | { |
90 | } | 91 | } |
91 | 92 | ||
92 | QWidget *AbPickItem::createEditor() const | 93 | QWidget *AbPickItem::createEditor() const |
93 | { | 94 | { |
94 | QComboBox* combo = new QComboBox( table()->viewport() ); | 95 | QComboBox* combo = new QComboBox( table()->viewport() ); |
95 | ( (AbPickItem*)this )->cb = combo; | 96 | ( (AbPickItem*)this )->cb = combo; |
96 | AbTable* t = static_cast<AbTable*>(table()); | 97 | AbTable* t = static_cast<AbTable*>(table()); |
97 | QStringList c = t->choiceNames(); | 98 | QStringList c = t->choiceNames(); |
98 | int cur = 0; | 99 | int cur = 0; |
99 | for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) { | 100 | for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) { |
100 | if ( *it == text() ) | 101 | if ( *it == text() ) |
101 | cur = combo->count(); | 102 | cur = combo->count(); |
102 | combo->insertItem(*it); | 103 | combo->insertItem(*it); |
103 | } | 104 | } |
104 | combo->setCurrentItem(cur); | 105 | combo->setCurrentItem(cur); |
105 | return combo; | 106 | return combo; |
106 | } | 107 | } |
107 | 108 | ||
108 | void AbPickItem::setContentFromEditor( QWidget *w ) | 109 | void AbPickItem::setContentFromEditor( QWidget *w ) |
109 | { | 110 | { |
110 | if ( w->inherits("QComboBox") ) | 111 | if ( w->inherits("QComboBox") ) |
111 | setText( ( (QComboBox*)w )->currentText() ); | 112 | setText( ( (QComboBox*)w )->currentText() ); |
112 | else | 113 | else |
113 | QTableItem::setContentFromEditor( w ); | 114 | QTableItem::setContentFromEditor( w ); |
114 | } | 115 | } |
115 | 116 | ||
116 | /*! | 117 | /*! |
117 | \class AbTable abtable.h | 118 | \class AbTable abtable.h |
118 | 119 | ||
119 | \brief QTable based class for showing a list of entries | 120 | \brief QTable based class for showing a list of entries |
120 | */ | 121 | */ |
121 | 122 | ||
122 | AbTable::AbTable( const QValueList<int> *order, QWidget *parent, const char *name ) | 123 | AbTable::AbTable( const QValueList<int> *order, QWidget *parent, const char *name ) |
123 | // #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR | 124 | // #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR |
124 | // : QTable( 0, 0, parent, name, TRUE ), | 125 | // : QTable( 0, 0, parent, name, TRUE ), |
125 | // #else | 126 | // #else |
126 | : QTable( parent, name ), | 127 | : QTable( parent, name ), |
127 | // #endif | 128 | // #endif |
128 | lastSortCol( -1 ), | 129 | lastSortCol( -1 ), |
129 | asc( TRUE ), | 130 | asc( TRUE ), |
130 | intFields( order ), | 131 | intFields( order ), |
131 | currFindRow( -1 ), | 132 | currFindRow( -1 ), |
132 | mCat( 0 ), | 133 | mCat( 0 ), |
133 | m_inSearch (false), | 134 | m_inSearch (false), |
134 | m_contactdb ("addressbook", 0l, 0l, false) // Handle syncing myself.. ! | 135 | m_contactdb ("addressbook", 0l, 0l, false) // Handle syncing myself.. ! |
135 | { | 136 | { |
136 | mCat.load( categoryFileName() ); | 137 | mCat.load( categoryFileName() ); |
137 | setSelectionMode( NoSelection ); | 138 | setSelectionMode( NoSelection ); |
138 | init(); | 139 | init(); |
139 | setSorting( TRUE ); | 140 | setSorting( TRUE ); |
140 | connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), | 141 | connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), |
141 | this, SLOT(itemClicked(int,int)) ); | 142 | this, SLOT(itemClicked(int,int)) ); |
142 | } | 143 | } |
143 | 144 | ||
144 | AbTable::~AbTable() | 145 | AbTable::~AbTable() |
145 | { | 146 | { |
146 | } | 147 | } |
147 | 148 | ||
148 | void AbTable::init() | 149 | void AbTable::init() |
149 | { | 150 | { |
150 | showChar = '\0'; | 151 | showChar = '\0'; |
151 | setNumRows( 0 ); | 152 | setNumRows( 0 ); |
152 | setNumCols( 2 ); | 153 | setNumCols( 2 ); |
153 | 154 | ||
154 | horizontalHeader()->setLabel( 0, tr( "Full Name" )); | 155 | horizontalHeader()->setLabel( 0, tr( "Full Name" )); |
155 | horizontalHeader()->setLabel( 1, tr( "Contact" )); | 156 | horizontalHeader()->setLabel( 1, tr( "Contact" )); |
156 | setLeftMargin( 0 ); | 157 | setLeftMargin( 0 ); |
157 | verticalHeader()->hide(); | 158 | verticalHeader()->hide(); |
158 | columnVisible = true; | 159 | columnVisible = true; |
159 | } | 160 | } |
160 | 161 | ||
161 | void AbTable::columnClicked( int col ) | 162 | void AbTable::columnClicked( int col ) |
162 | { | 163 | { |
163 | if ( !sorting() ) | 164 | if ( !sorting() ) |
164 | return; | 165 | return; |
165 | 166 | ||
166 | if ( lastSortCol == -1 ) | 167 | if ( lastSortCol == -1 ) |
167 | lastSortCol = col; | 168 | lastSortCol = col; |
168 | 169 | ||
169 | if ( col == lastSortCol ) { | 170 | if ( col == lastSortCol ) { |
170 | asc = !asc; | 171 | asc = !asc; |
171 | } else { | 172 | } else { |
172 | lastSortCol = col; | 173 | lastSortCol = col; |
173 | asc = TRUE; | 174 | asc = TRUE; |
174 | } | 175 | } |
175 | //QMessageBox::information( this, "resort", "columnClicked" ); | 176 | //QMessageBox::information( this, "resort", "columnClicked" ); |
176 | resort(); | 177 | resort(); |
177 | } | 178 | } |
178 | 179 | ||
179 | void AbTable::resort() | 180 | void AbTable::resort() |
180 | { | 181 | { |
181 | if ( sorting() ) { | 182 | if ( sorting() ) { |
182 | if ( lastSortCol == -1 ) | 183 | if ( lastSortCol == -1 ) |
183 | lastSortCol = 0; | 184 | lastSortCol = 0; |
184 | sortColumn( lastSortCol, asc, TRUE ); | 185 | sortColumn( lastSortCol, asc, TRUE ); |
185 | //QMessageBox::information( this, "resort", "resort" ); | 186 | //QMessageBox::information( this, "resort", "resort" ); |
186 | updateVisible(); | 187 | updateVisible(); |
187 | } | 188 | } |
188 | } | 189 | } |
189 | 190 | ||
190 | OContact AbTable::currentEntry() | 191 | OContact AbTable::currentEntry() |
191 | { | 192 | { |
192 | OContact cnt; | 193 | OContact cnt; |
193 | AbTableItem *abItem; | 194 | AbTableItem *abItem; |
194 | abItem = static_cast<AbTableItem*>(item( currentRow(), 0 )); | 195 | abItem = static_cast<AbTableItem*>(item( currentRow(), 0 )); |
195 | if ( abItem ) { | 196 | if ( abItem ) { |
196 | cnt = contactList[abItem]; | 197 | cnt = contactList[abItem]; |
197 | //cnt = contactList[currentRow()]; | 198 | //cnt = contactList[currentRow()]; |
198 | } | 199 | } |
199 | return cnt; | 200 | return cnt; |
200 | } | 201 | } |
201 | 202 | ||
202 | void AbTable::replaceCurrentEntry( const OContact &newContact ) | 203 | void AbTable::replaceCurrentEntry( const OContact &newContact ) |
203 | { | 204 | { |
204 | int row = currentRow(); | 205 | int row = currentRow(); |
205 | updateVisible(); | 206 | updateVisible(); |
206 | 207 | ||
207 | journalFreeReplace( newContact, row ); | 208 | journalFreeReplace( newContact, row ); |
208 | 209 | ||
209 | } | 210 | } |
210 | 211 | ||
211 | void AbTable::deleteCurrentEntry() | 212 | void AbTable::deleteCurrentEntry() |
212 | { | 213 | { |
213 | int row = currentRow(); | 214 | int row = currentRow(); |
214 | 215 | ||
215 | // a little wasteful, but it ensure's there is only one place | 216 | // a little wasteful, but it ensure's there is only one place |
216 | // where we delete. | 217 | // where we delete. |
217 | journalFreeRemove( row ); | 218 | journalFreeRemove( row ); |
218 | updateVisible(); | 219 | updateVisible(); |
219 | 220 | ||
220 | if ( numRows() == 0 ) | 221 | if ( numRows() == 0 ) |
221 | emit empty( TRUE ); | 222 | emit empty( TRUE ); |
222 | 223 | ||
223 | } | 224 | } |
224 | 225 | ||
225 | void AbTable::clear() | 226 | void AbTable::clear() |
226 | { | 227 | { |
227 | contactList.clear(); | 228 | contactList.clear(); |
228 | for ( int r = 0; r < numRows(); ++r ) { | 229 | for ( int r = 0; r < numRows(); ++r ) { |
229 | for ( int c = 0; c < numCols(); ++c ) { | 230 | for ( int c = 0; c < numCols(); ++c ) { |
230 | if ( cellWidget( r, c ) ) | 231 | if ( cellWidget( r, c ) ) |
231 | clearCellWidget( r, c ); | 232 | clearCellWidget( r, c ); |
232 | clearCell( r, c ); | 233 | clearCell( r, c ); |
233 | } | 234 | } |
234 | } | 235 | } |
235 | setNumRows( 0 ); | 236 | setNumRows( 0 ); |
236 | } | 237 | } |
237 | 238 | ||
238 | void AbTable::refresh() | 239 | void AbTable::refresh() |
239 | { | 240 | { |
240 | int rows = numRows(); | 241 | int rows = numRows(); |
241 | QString value; | 242 | QString value; |
242 | AbTableItem *abi; | 243 | AbTableItem *abi; |
243 | 244 | ||
244 | // hide columns so no flashing ? | 245 | // hide columns so no flashing ? |
245 | if ( showBk == "Cards" ) { | 246 | if ( showBk == "Cards" ) { |
246 | hideColumn(0); | 247 | hideColumn(0); |
247 | hideColumn(1); | 248 | hideColumn(1); |
248 | } | 249 | } |
249 | for ( int r = 0; r < rows; ++r ) { | 250 | for ( int r = 0; r < rows; ++r ) { |
250 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 251 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
251 | value = findContactContact( contactList[abi], r ); | 252 | value = findContactContact( contactList[abi], r ); |
252 | static_cast<AbTableItem*>( item(r, 1) )->setItem( value, abi->text() ); | 253 | static_cast<AbTableItem*>( item(r, 1) )->setItem( value, abi->text() ); |
253 | } | 254 | } |
254 | resort(); | 255 | resort(); |
255 | } | 256 | } |
256 | 257 | ||
257 | void AbTable::keyPressEvent( QKeyEvent *e ) | 258 | void AbTable::keyPressEvent( QKeyEvent *e ) |
258 | { | 259 | { |
259 | char key = toupper( e->ascii() ); | 260 | char key = toupper( e->ascii() ); |
260 | 261 | ||
261 | if ( key >= 'A' && key <= 'Z' ) | 262 | if ( key >= 'A' && key <= 'Z' ) |
262 | moveTo( key ); | 263 | moveTo( key ); |
263 | 264 | ||
264 | if ( m_inSearch ) { | 265 | if ( m_inSearch ) { |
265 | // Running in seach-mode, therefore we will interprete | 266 | // Running in seach-mode, therefore we will interprete |
266 | // some key differently | 267 | // some key differently |
267 | qWarning("Received key in search mode"); | 268 | qWarning("Received key in search mode"); |
268 | switch( e->key() ) { | 269 | switch( e->key() ) { |
269 | case Qt::Key_Space: | 270 | case Qt::Key_Space: |
270 | case Qt::Key_Return: | 271 | case Qt::Key_Return: |
271 | case Qt::Key_Enter: | 272 | case Qt::Key_Enter: |
272 | emit details(); | 273 | emit details(); |
273 | break; | 274 | break; |
274 | case Qt::Key_Up: | 275 | case Qt::Key_Up: |
275 | qWarning("a"); | 276 | qWarning("a"); |
276 | emit signalSearchBackward(); | 277 | emit signalSearchBackward(); |
277 | break; | 278 | break; |
278 | case Qt::Key_Down: | 279 | case Qt::Key_Down: |
279 | qWarning("b"); | 280 | qWarning("b"); |
280 | emit signalSearchNext(); | 281 | emit signalSearchNext(); |
281 | break; | 282 | break; |
282 | default: | 283 | default: |
283 | QTable::keyPressEvent( e ); | 284 | QTable::keyPressEvent( e ); |
284 | } | 285 | } |
285 | 286 | ||
286 | } else { | 287 | } else { |
287 | qWarning("Received key in NON search mode"); | 288 | qWarning("Received key in NON search mode"); |
288 | 289 | ||
289 | switch( e->key() ) { | 290 | switch( e->key() ) { |
290 | case Qt::Key_Space: | 291 | case Qt::Key_Space: |
291 | case Qt::Key_Return: | 292 | case Qt::Key_Return: |
292 | case Qt::Key_Enter: | 293 | case Qt::Key_Enter: |
293 | emit details(); | 294 | emit details(); |
294 | break; | 295 | break; |
295 | default: | 296 | default: |
296 | QTable::keyPressEvent( e ); | 297 | QTable::keyPressEvent( e ); |
297 | } | 298 | } |
298 | } | 299 | } |
299 | } | 300 | } |
300 | 301 | ||
301 | void AbTable::moveTo( char c ) | 302 | void AbTable::moveTo( char c ) |
302 | { | 303 | { |
303 | 304 | ||
304 | int rows = numRows(); | 305 | int rows = numRows(); |
305 | QString value; | 306 | QString value; |
306 | AbTableItem *abi; | 307 | AbTableItem *abi; |
307 | int r; | 308 | int r; |
308 | if ( asc ) { | 309 | if ( asc ) { |
309 | r = 0; | 310 | r = 0; |
310 | while ( r < rows-1) { | 311 | while ( r < rows-1) { |
311 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 312 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
312 | QChar first = abi->key()[0]; | 313 | QChar first = abi->key()[0]; |
313 | //### is there a bug in QChar to char comparison??? | 314 | //### is there a bug in QChar to char comparison??? |
314 | if ( first.row() || first.cell() >= c ) | 315 | if ( first.row() || first.cell() >= c ) |
315 | break; | 316 | break; |
316 | r++; | 317 | r++; |
317 | } | 318 | } |
318 | } else { | 319 | } else { |
319 | //### should probably disable reverse sorting instead | 320 | //### should probably disable reverse sorting instead |
320 | r = rows - 1; | 321 | r = rows - 1; |
321 | while ( r > 0 ) { | 322 | while ( r > 0 ) { |
322 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 323 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
323 | QChar first = abi->key()[0]; | 324 | QChar first = abi->key()[0]; |
324 | //### is there a bug in QChar to char comparison??? | 325 | //### is there a bug in QChar to char comparison??? |
325 | if ( first.row() || first.cell() >= c ) | 326 | if ( first.row() || first.cell() >= c ) |
326 | break; | 327 | break; |
327 | r--; | 328 | r--; |
328 | } | 329 | } |
329 | } | 330 | } |
330 | setCurrentCell( r, currentColumn() ); | 331 | setCurrentCell( r, currentColumn() ); |
331 | } | 332 | } |
332 | 333 | ||
333 | 334 | ||
334 | QString AbTable::findContactName( const OContact &entry ) | 335 | QString AbTable::findContactName( const OContact &entry ) |
335 | { | 336 | { |
336 | // We use the fileAs, then company, defaultEmail | 337 | // We use the fileAs, then company, defaultEmail |
337 | QString str; | 338 | QString str; |
338 | str = entry.fileAs(); | 339 | str = entry.fileAs(); |
339 | if ( str.isEmpty() ) { | 340 | if ( str.isEmpty() ) { |
340 | str = entry.company(); | 341 | str = entry.company(); |
341 | if ( str.isEmpty() ) { | 342 | if ( str.isEmpty() ) { |
342 | str = entry.defaultEmail(); | 343 | str = entry.defaultEmail(); |
343 | } | 344 | } |
344 | } | 345 | } |
345 | return str; | 346 | return str; |
346 | } | 347 | } |
347 | 348 | ||
348 | QString AbTable::findContactContact( const OContact &entry, int /* row */ ) | 349 | QString AbTable::findContactContact( const OContact &entry, int /* row */ ) |
349 | { | 350 | { |
350 | QString value; | 351 | QString value; |
351 | value = ""; | 352 | value = ""; |
352 | for ( QValueList<int>::ConstIterator it = intFields->begin(); | 353 | for ( QValueList<int>::ConstIterator it = intFields->begin(); |
353 | it != intFields->end(); ++it ) { | 354 | it != intFields->end(); ++it ) { |
354 | switch ( *it ) { | 355 | switch ( *it ) { |
355 | default: | 356 | default: |
356 | break; | 357 | break; |
357 | case Qtopia::Title: | 358 | case Qtopia::Title: |
358 | value = entry.title(); | 359 | value = entry.title(); |
359 | break; | 360 | break; |
360 | case Qtopia::Suffix: | 361 | case Qtopia::Suffix: |
361 | value = entry.suffix(); | 362 | value = entry.suffix(); |
362 | break; | 363 | break; |
363 | case Qtopia::FileAs: | 364 | case Qtopia::FileAs: |
364 | value = entry.fileAs(); | 365 | value = entry.fileAs(); |
365 | break; | 366 | break; |
366 | case Qtopia::DefaultEmail: | 367 | case Qtopia::DefaultEmail: |
367 | value = entry.defaultEmail(); | 368 | value = entry.defaultEmail(); |
368 | case Qtopia::Emails: | 369 | case Qtopia::Emails: |
369 | value = entry.emails(); | 370 | value = entry.emails(); |
370 | break; | 371 | break; |
371 | case Qtopia::HomeStreet: | 372 | case Qtopia::HomeStreet: |
372 | value = entry.homeStreet(); | 373 | value = entry.homeStreet(); |
373 | break; | 374 | break; |
374 | case Qtopia::HomeCity: | 375 | case Qtopia::HomeCity: |
375 | value = entry.homeCity(); | 376 | value = entry.homeCity(); |
376 | break; | 377 | break; |
377 | case Qtopia::HomeState: | 378 | case Qtopia::HomeState: |
378 | value = entry.homeState(); | 379 | value = entry.homeState(); |
379 | break; | 380 | break; |
380 | case Qtopia::HomeZip: | 381 | case Qtopia::HomeZip: |
381 | value = entry.homeZip(); | 382 | value = entry.homeZip(); |
382 | break; | 383 | break; |
383 | case Qtopia::HomeCountry: | 384 | case Qtopia::HomeCountry: |
384 | value = entry.homeCountry(); | 385 | value = entry.homeCountry(); |
385 | break; | 386 | break; |
386 | case Qtopia::HomePhone: | 387 | case Qtopia::HomePhone: |
387 | value = entry.homePhone(); | 388 | value = entry.homePhone(); |
388 | break; | 389 | break; |
389 | case Qtopia::HomeFax: | 390 | case Qtopia::HomeFax: |
390 | value = entry.homeFax(); | 391 | value = entry.homeFax(); |
391 | break; | 392 | break; |
392 | case Qtopia::HomeMobile: | 393 | case Qtopia::HomeMobile: |
393 | value = entry.homeMobile(); | 394 | value = entry.homeMobile(); |
394 | break; | 395 | break; |
395 | case Qtopia::HomeWebPage: | 396 | case Qtopia::HomeWebPage: |
396 | value = entry.homeWebpage(); | 397 | value = entry.homeWebpage(); |
397 | break; | 398 | break; |
398 | case Qtopia::Company: | 399 | case Qtopia::Company: |
399 | value = entry.company(); | 400 | value = entry.company(); |
400 | break; | 401 | break; |
401 | case Qtopia::BusinessCity: | 402 | case Qtopia::BusinessCity: |
402 | value = entry.businessCity(); | 403 | value = entry.businessCity(); |
403 | break; | 404 | break; |
404 | case Qtopia::BusinessStreet: | 405 | case Qtopia::BusinessStreet: |
405 | value = entry.businessStreet(); | 406 | value = entry.businessStreet(); |
406 | break; | 407 | break; |
407 | case Qtopia::BusinessZip: | 408 | case Qtopia::BusinessZip: |
408 | value = entry.businessZip(); | 409 | value = entry.businessZip(); |
409 | break; | 410 | break; |
410 | case Qtopia::BusinessCountry: | 411 | case Qtopia::BusinessCountry: |
411 | value = entry.businessCountry(); | 412 | value = entry.businessCountry(); |
412 | break; | 413 | break; |
413 | case Qtopia::BusinessWebPage: | 414 | case Qtopia::BusinessWebPage: |
414 | value = entry.businessWebpage(); | 415 | value = entry.businessWebpage(); |
415 | break; | 416 | break; |
416 | case Qtopia::JobTitle: | 417 | case Qtopia::JobTitle: |
417 | value = entry.jobTitle(); | 418 | value = entry.jobTitle(); |
418 | break; | 419 | break; |
419 | case Qtopia::Department: | 420 | case Qtopia::Department: |
420 | value = entry.department(); | 421 | value = entry.department(); |
421 | break; | 422 | break; |
422 | case Qtopia::Office: | 423 | case Qtopia::Office: |
423 | value = entry.office(); | 424 | value = entry.office(); |
424 | break; | 425 | break; |
425 | case Qtopia::BusinessPhone: | 426 | case Qtopia::BusinessPhone: |
426 | value = entry.businessPhone(); | 427 | value = entry.businessPhone(); |
427 | break; | 428 | break; |
428 | case Qtopia::BusinessFax: | 429 | case Qtopia::BusinessFax: |
429 | value = entry.businessFax(); | 430 | value = entry.businessFax(); |
430 | break; | 431 | break; |
431 | case Qtopia::BusinessMobile: | 432 | case Qtopia::BusinessMobile: |
432 | value = entry.businessMobile(); | 433 | value = entry.businessMobile(); |
433 | break; | 434 | break; |
434 | case Qtopia::BusinessPager: | 435 | case Qtopia::BusinessPager: |
435 | value = entry.businessPager(); | 436 | value = entry.businessPager(); |
436 | break; | 437 | break; |
437 | case Qtopia::Profession: | 438 | case Qtopia::Profession: |
438 | value = entry.profession(); | 439 | value = entry.profession(); |
439 | break; | 440 | break; |
440 | case Qtopia::Assistant: | 441 | case Qtopia::Assistant: |
441 | value = entry.assistant(); | 442 | value = entry.assistant(); |
442 | break; | 443 | break; |
443 | case Qtopia::Manager: | 444 | case Qtopia::Manager: |
444 | value = entry.manager(); | 445 | value = entry.manager(); |
445 | break; | 446 | break; |
446 | case Qtopia::Spouse: | 447 | case Qtopia::Spouse: |
447 | value = entry.spouse(); | 448 | value = entry.spouse(); |
448 | break; | 449 | break; |
449 | case Qtopia::Gender: | 450 | case Qtopia::Gender: |
450 | value = entry.gender(); | 451 | value = entry.gender(); |
451 | break; | 452 | break; |
452 | case Qtopia::Birthday: | 453 | case Qtopia::Birthday: |
453 | value = entry.birthday(); | 454 | value = TimeString::numberDateString( entry.birthday() ); |
454 | break; | 455 | break; |
455 | case Qtopia::Anniversary: | 456 | case Qtopia::Anniversary: |
456 | value = entry.anniversary(); | 457 | value = TimeString::numberDateString( entry.anniversary() ); |
457 | break; | 458 | break; |
458 | case Qtopia::Nickname: | 459 | case Qtopia::Nickname: |
459 | value = entry.nickname(); | 460 | value = entry.nickname(); |
460 | break; | 461 | break; |
461 | case Qtopia::Children: | 462 | case Qtopia::Children: |
462 | value = entry.children(); | 463 | value = entry.children(); |
463 | break; | 464 | break; |
464 | case Qtopia::Notes: | 465 | case Qtopia::Notes: |
465 | value = entry.notes(); | 466 | value = entry.notes(); |
466 | break; | 467 | break; |
467 | } | 468 | } |
468 | if ( !value.isEmpty() ) | 469 | if ( !value.isEmpty() ) |
469 | break; | 470 | break; |
470 | } | 471 | } |
471 | return value; | 472 | return value; |
472 | } | 473 | } |
473 | 474 | ||
474 | void AbTable::addEntry( const OContact &newCnt ) | 475 | void AbTable::addEntry( const OContact &newCnt ) |
475 | { | 476 | { |
476 | int row = numRows(); | 477 | int row = numRows(); |
477 | 478 | ||
478 | setNumRows( row + 1 ); | 479 | setNumRows( row + 1 ); |
479 | insertIntoTable( newCnt, row ); | 480 | insertIntoTable( newCnt, row ); |
480 | 481 | ||
481 | qWarning("abtable:AddContact"); | 482 | qWarning("abtable:AddContact"); |
482 | m_contactdb.add ( newCnt ); | 483 | m_contactdb.add ( newCnt ); |
483 | 484 | ||
484 | setCurrentCell( row, 0 ); | 485 | setCurrentCell( row, 0 ); |
485 | // updateVisible(); | 486 | // updateVisible(); |
486 | } | 487 | } |
487 | 488 | ||
488 | void AbTable::resizeRows() { | 489 | void AbTable::resizeRows() { |
489 | /* | 490 | /* |
490 | if (numRows()) { | 491 | if (numRows()) { |
491 | for (int i = 0; i < numRows(); i++) { | 492 | for (int i = 0; i < numRows(); i++) { |
492 | setRowHeight( i, size ); | 493 | setRowHeight( i, size ); |
493 | } | 494 | } |
494 | } | 495 | } |
495 | updateVisible(); | 496 | updateVisible(); |
496 | */ | 497 | */ |
497 | } | 498 | } |
498 | 499 | ||
499 | 500 | ||
500 | bool AbTable::save() | 501 | bool AbTable::save() |
501 | { | 502 | { |
502 | // QTime t; | 503 | // QTime t; |
503 | // t.start(); | 504 | // t.start(); |
504 | qWarning("abtable:Save data"); | 505 | qWarning("abtable:Save data"); |
505 | 506 | ||
506 | return m_contactdb.save(); | 507 | return m_contactdb.save(); |
507 | } | 508 | } |
508 | 509 | ||
509 | void AbTable::load() | 510 | void AbTable::load() |
510 | { | 511 | { |
511 | setSorting( false ); | 512 | setSorting( false ); |
512 | setUpdatesEnabled( FALSE ); | 513 | setUpdatesEnabled( FALSE ); |
513 | 514 | ||
514 | qWarning("abtable:Load data"); | 515 | qWarning("abtable:Load data"); |
515 | 516 | ||
516 | OContactAccess::List list = m_contactdb.allRecords(); | 517 | OContactAccess::List list = m_contactdb.allRecords(); |
517 | OContactAccess::List::Iterator it; | 518 | OContactAccess::List::Iterator it; |
518 | setNumRows( list.count() ); | 519 | setNumRows( list.count() ); |
519 | int row = 0; | 520 | int row = 0; |
520 | for ( it = list.begin(); it != list.end(); ++it ) | 521 | for ( it = list.begin(); it != list.end(); ++it ) |
521 | insertIntoTable( *it, row++ ); | 522 | insertIntoTable( *it, row++ ); |
522 | 523 | ||
523 | setUpdatesEnabled( TRUE ); | 524 | setUpdatesEnabled( TRUE ); |
524 | 525 | ||
525 | setSorting( true ); | 526 | setSorting( true ); |
526 | resort(); | 527 | resort(); |
527 | } | 528 | } |
528 | 529 | ||
529 | 530 | ||
530 | void AbTable::reload() | 531 | void AbTable::reload() |
531 | { | 532 | { |
532 | m_contactdb.reload(); | 533 | m_contactdb.reload(); |
533 | load(); | 534 | load(); |
534 | } | 535 | } |
535 | 536 | ||
536 | void AbTable::realignTable( int row ) | 537 | void AbTable::realignTable( int row ) |
537 | { | 538 | { |
538 | QTableItem *ti1, | 539 | QTableItem *ti1, |
539 | *ti2; | 540 | *ti2; |
540 | int totalRows = numRows(); | 541 | int totalRows = numRows(); |
541 | for ( int curr = row; curr < totalRows - 1; curr++ ) { | 542 | for ( int curr = row; curr < totalRows - 1; curr++ ) { |
542 | // the same info from the todo list still applies, but I | 543 | // the same info from the todo list still applies, but I |
543 | // don't think it is _too_ bad. | 544 | // don't think it is _too_ bad. |
544 | ti1 = item( curr + 1, 0 ); | 545 | ti1 = item( curr + 1, 0 ); |
545 | ti2 = item( curr + 1, 1 ); | 546 | ti2 = item( curr + 1, 1 ); |
546 | takeItem( ti1 ); | 547 | takeItem( ti1 ); |
547 | takeItem( ti2 ); | 548 | takeItem( ti2 ); |
548 | setItem( curr, 0, ti1 ); | 549 | setItem( curr, 0, ti1 ); |
549 | setItem( curr, 1, ti2 ); | 550 | setItem( curr, 1, ti2 ); |
550 | } | 551 | } |
551 | setNumRows( totalRows - 1 ); | 552 | setNumRows( totalRows - 1 ); |
552 | resort(); | 553 | resort(); |
553 | } | 554 | } |
554 | 555 | ||
555 | // Add contact into table. | 556 | // Add contact into table. |
556 | void AbTable::insertIntoTable( const OContact &cnt, int row ) | 557 | void AbTable::insertIntoTable( const OContact &cnt, int row ) |
557 | { | 558 | { |
558 | QString strName, | 559 | QString strName, |
559 | strContact; | 560 | strContact; |
560 | 561 | ||
561 | strName = findContactName( cnt ); | 562 | strName = findContactName( cnt ); |
562 | strContact = findContactContact( cnt, row ); | 563 | strContact = findContactContact( cnt, row ); |
563 | 564 | ||
564 | AbTableItem *ati; | 565 | AbTableItem *ati; |
565 | ati = new AbTableItem( this, QTableItem::Never, strName, strContact); | 566 | ati = new AbTableItem( this, QTableItem::Never, strName, strContact); |
566 | contactList.insert( ati, cnt ); | 567 | contactList.insert( ati, cnt ); |
567 | setItem( row, 0, ati ); | 568 | setItem( row, 0, ati ); |
568 | ati = new AbTableItem( this, QTableItem::Never, strContact, strName); | 569 | ati = new AbTableItem( this, QTableItem::Never, strContact, strName); |
569 | setItem( row, 1, ati ); | 570 | setItem( row, 1, ati ); |
570 | 571 | ||
571 | //### cannot do this; table only has two columns at this point | 572 | //### cannot do this; table only has two columns at this point |
572 | // setItem( row, 2, new AbPickItem( this ) ); | 573 | // setItem( row, 2, new AbPickItem( this ) ); |
573 | 574 | ||
574 | // resort at some point? | 575 | // resort at some point? |
575 | } | 576 | } |
576 | 577 | ||
577 | 578 | ||
578 | // Replace or add an entry | 579 | // Replace or add an entry |
579 | void AbTable::journalFreeReplace( const OContact &cnt, int row ) | 580 | void AbTable::journalFreeReplace( const OContact &cnt, int row ) |
580 | { | 581 | { |
581 | QString strName, | 582 | QString strName, |
582 | strContact; | 583 | strContact; |
583 | AbTableItem *ati = 0l; | 584 | AbTableItem *ati = 0l; |
584 | 585 | ||
585 | strName = findContactName( cnt ); | 586 | strName = findContactName( cnt ); |
586 | strContact = findContactContact( cnt, row ); | 587 | strContact = findContactContact( cnt, row ); |
587 | ati = static_cast<AbTableItem*>(item(row, 0)); | 588 | ati = static_cast<AbTableItem*>(item(row, 0)); |
588 | 589 | ||
589 | // Replace element if found in row "row" | 590 | // Replace element if found in row "row" |
590 | // or add this element if not. | 591 | // or add this element if not. |
591 | if ( ati != 0 ) { // replace | 592 | if ( ati != 0 ) { // replace |
592 | // :SX db access -> replace | 593 | // :SX db access -> replace |
593 | qWarning ("Replace Contact in DB ! UID: %d", contactList[ati].uid() ); | 594 | qWarning ("Replace Contact in DB ! UID: %d", contactList[ati].uid() ); |
594 | m_contactdb.replace ( cnt ); | 595 | m_contactdb.replace ( cnt ); |
595 | 596 | ||
596 | contactList.remove( ati ); | 597 | contactList.remove( ati ); |
597 | ati->setItem( strName, strContact ); | 598 | ati->setItem( strName, strContact ); |
598 | contactList.insert( ati, cnt ); | 599 | contactList.insert( ati, cnt ); |
599 | 600 | ||
600 | ati = static_cast<AbTableItem*>(item(row, 1)); | 601 | ati = static_cast<AbTableItem*>(item(row, 1)); |
601 | ati->setItem( strContact, strName ); | 602 | ati->setItem( strContact, strName ); |
602 | 603 | ||
603 | }else{ // add | 604 | }else{ // add |
604 | int myrows = numRows(); | 605 | int myrows = numRows(); |
605 | setNumRows( myrows + 1 ); | 606 | setNumRows( myrows + 1 ); |
606 | insertIntoTable( cnt, myrows ); | 607 | insertIntoTable( cnt, myrows ); |
607 | // gets deleted when returning -- Why ? (se) | 608 | // gets deleted when returning -- Why ? (se) |
608 | // :SX db access -> add | 609 | // :SX db access -> add |
609 | qWarning ("Are you sure to add to database ? -> Currently disabled !!"); | 610 | qWarning ("Are you sure to add to database ? -> Currently disabled !!"); |
610 | // m_contactdb.add( cnt ); | 611 | // m_contactdb.add( cnt ); |
611 | } | 612 | } |
612 | } | 613 | } |
613 | 614 | ||
614 | // Remove entry | 615 | // Remove entry |
615 | void AbTable::journalFreeRemove( int row ) | 616 | void AbTable::journalFreeRemove( int row ) |
616 | { | 617 | { |
617 | AbTableItem *ati; | 618 | AbTableItem *ati; |
618 | ati = static_cast<AbTableItem*>(item(row, 0)); | 619 | ati = static_cast<AbTableItem*>(item(row, 0)); |
619 | if ( !ati ) | 620 | if ( !ati ) |
620 | return; | 621 | return; |
621 | 622 | ||
622 | // :SX db access -> remove | 623 | // :SX db access -> remove |
623 | qWarning ("Remove Contact from DB ! UID: %d",contactList[ati].uid() ); | 624 | qWarning ("Remove Contact from DB ! UID: %d",contactList[ati].uid() ); |
624 | m_contactdb.remove( contactList[ati].uid() ); | 625 | m_contactdb.remove( contactList[ati].uid() ); |
625 | 626 | ||
626 | contactList.remove( ati ); | 627 | contactList.remove( ati ); |
627 | 628 | ||
628 | realignTable( row ); | 629 | realignTable( row ); |
629 | 630 | ||
630 | } | 631 | } |
631 | 632 | ||
632 | #if QT_VERSION <= 230 | 633 | #if QT_VERSION <= 230 |
633 | #ifndef SINGLE_APP | 634 | #ifndef SINGLE_APP |
634 | void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) | 635 | void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) |
635 | { | 636 | { |
636 | // Region of the rect we should draw | 637 | // Region of the rect we should draw |
637 | QRegion reg( QRect( cx, cy, cw, ch ) ); | 638 | QRegion reg( QRect( cx, cy, cw, ch ) ); |
638 | // Subtract the table from it | 639 | // Subtract the table from it |
639 | reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) ); | 640 | reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) ); |
640 | // And draw the rectangles (transformed as needed) | 641 | // And draw the rectangles (transformed as needed) |
641 | QArray<QRect> r = reg.rects(); | 642 | QArray<QRect> r = reg.rects(); |
642 | for (unsigned int i=0; i<r.count(); i++) | 643 | for (unsigned int i=0; i<r.count(); i++) |
643 | p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) ); | 644 | p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) ); |
644 | } | 645 | } |
645 | #endif | 646 | #endif |
646 | #endif | 647 | #endif |
647 | 648 | ||
648 | 649 | ||
649 | // int AbTable::rowHeight( int ) const | 650 | // int AbTable::rowHeight( int ) const |
650 | // { | 651 | // { |
651 | // return 18; | 652 | // return 18; |
652 | // } | 653 | // } |
653 | 654 | ||
654 | // int AbTable::rowPos( int row ) const | 655 | // int AbTable::rowPos( int row ) const |
655 | // { | 656 | // { |
656 | // return 18*row; | 657 | // return 18*row; |
657 | // } | 658 | // } |
658 | 659 | ||
659 | // int AbTable::rowAt( int pos ) const | 660 | // int AbTable::rowAt( int pos ) const |
660 | // { | 661 | // { |
661 | // return QMIN( pos/18, numRows()-1 ); | 662 | // return QMIN( pos/18, numRows()-1 ); |
662 | // } | 663 | // } |
663 | 664 | ||
664 | void AbTable::slotDoFind( const QString &findString, bool caseSensitive, bool useRegExp, | 665 | void AbTable::slotDoFind( const QString &findString, bool caseSensitive, bool useRegExp, |
665 | bool backwards, QString cat /* int category */ ) | 666 | bool backwards, QString cat /* int category */ ) |
666 | { | 667 | { |
667 | int category = 0; | 668 | int category = 0; |
668 | 669 | ||
669 | // Use the current Category if nothing else selected | 670 | // Use the current Category if nothing else selected |
670 | if ( cat.isEmpty() ) | 671 | if ( cat.isEmpty() ) |
671 | category = mCat.id( "Contacts", showCat ); | 672 | category = mCat.id( "Contacts", showCat ); |
672 | else{ | 673 | else{ |
673 | category = mCat.id("Contacts", cat ); | 674 | category = mCat.id("Contacts", cat ); |
674 | } | 675 | } |
675 | 676 | ||
676 | qWarning ("Found in Category %d", category); | 677 | qWarning ("Found in Category %d", category); |
677 | 678 | ||
678 | if ( currFindRow < -1 ) | 679 | if ( currFindRow < -1 ) |
679 | currFindRow = - 1; | 680 | currFindRow = - 1; |
680 | 681 | ||
681 | clearSelection( TRUE ); | 682 | clearSelection( TRUE ); |
682 | int rows, row; | 683 | int rows, row; |
683 | AbTableItem *ati; | 684 | AbTableItem *ati; |
684 | QRegExp r( findString ); | 685 | QRegExp r( findString ); |
685 | r.setCaseSensitive( caseSensitive ); | 686 | r.setCaseSensitive( caseSensitive ); |
686 | r.setWildcard( !useRegExp ); | 687 | r.setWildcard( !useRegExp ); |
687 | rows = numRows(); | 688 | rows = numRows(); |
688 | static bool wrapAround = true; | 689 | static bool wrapAround = true; |
689 | bool try_again = false; | 690 | bool try_again = false; |
690 | 691 | ||
691 | // We will loop until we found an entry or found nothing. | 692 | // We will loop until we found an entry or found nothing. |
692 | do { | 693 | do { |
693 | if ( !backwards ) { | 694 | if ( !backwards ) { |
694 | for ( row = currFindRow + 1; row < rows; row++ ) { | 695 | for ( row = currFindRow + 1; row < rows; row++ ) { |
695 | ati = static_cast<AbTableItem*>( item(row, 0) ); | 696 | ati = static_cast<AbTableItem*>( item(row, 0) ); |
696 | if ( contactCompare( contactList[ati], r, category ) ){ | 697 | if ( contactCompare( contactList[ati], r, category ) ){ |
697 | try_again = false; | 698 | try_again = false; |
698 | break; | 699 | break; |
699 | } | 700 | } |
700 | } | 701 | } |
701 | } else { | 702 | } else { |
702 | for ( row = currFindRow - 1; row > -1; row-- ) { | 703 | for ( row = currFindRow - 1; row > -1; row-- ) { |
703 | ati = static_cast<AbTableItem*>( item(row, 0) ); | 704 | ati = static_cast<AbTableItem*>( item(row, 0) ); |
704 | if ( contactCompare( contactList[ati], r, category ) ){ | 705 | if ( contactCompare( contactList[ati], r, category ) ){ |
705 | try_again = false; | 706 | try_again = false; |
706 | break; | 707 | break; |
707 | } | 708 | } |
708 | } | 709 | } |
709 | } | 710 | } |
710 | if ( row >= rows || row < 0 ) { | 711 | if ( row >= rows || row < 0 ) { |
711 | if ( row < 0 ) | 712 | if ( row < 0 ) |
712 | currFindRow = rows; | 713 | currFindRow = rows; |
713 | else | 714 | else |
714 | currFindRow = -1; | 715 | currFindRow = -1; |
715 | 716 | ||
716 | if ( wrapAround ){ | 717 | if ( wrapAround ){ |
717 | emit signalWrapAround(); | 718 | emit signalWrapAround(); |
718 | try_again = true; | 719 | try_again = true; |
719 | }else{ | 720 | }else{ |
720 | emit signalNotFound(); | 721 | emit signalNotFound(); |
721 | try_again = false; | 722 | try_again = false; |
722 | } | 723 | } |
723 | 724 | ||
724 | wrapAround = !wrapAround; | 725 | wrapAround = !wrapAround; |
725 | } else { | 726 | } else { |
726 | currFindRow = row; | 727 | currFindRow = row; |
727 | QTableSelection foundSelection; | 728 | QTableSelection foundSelection; |
728 | foundSelection.init( currFindRow, 0 ); | 729 | foundSelection.init( currFindRow, 0 ); |
729 | foundSelection.expandTo( currFindRow, numCols() - 1 ); | 730 | foundSelection.expandTo( currFindRow, numCols() - 1 ); |
730 | addSelection( foundSelection ); | 731 | addSelection( foundSelection ); |
731 | setCurrentCell( currFindRow, 0 /* numCols() - 1 */ ); | 732 | setCurrentCell( currFindRow, 0 /* numCols() - 1 */ ); |
732 | wrapAround = true; | 733 | wrapAround = true; |
733 | try_again = false; | 734 | try_again = false; |
734 | } | 735 | } |
735 | } while ( try_again ); | 736 | } while ( try_again ); |
736 | } | 737 | } |
737 | 738 | ||
738 | static bool contactCompare( const OContact &cnt, const QRegExp &r, int category ) | 739 | static bool contactCompare( const OContact &cnt, const QRegExp &r, int category ) |
739 | { | 740 | { |
740 | bool returnMe; | 741 | bool returnMe; |
741 | QArray<int> cats; | 742 | QArray<int> cats; |
742 | cats = cnt.categories(); | 743 | cats = cnt.categories(); |
743 | 744 | ||
744 | returnMe = false; | 745 | returnMe = false; |
745 | if ( (cats.count() == 0) || (category == 0) ) | 746 | if ( (cats.count() == 0) || (category == 0) ) |
746 | returnMe = cnt.match( r ); | 747 | returnMe = cnt.match( r ); |
747 | else { | 748 | else { |
748 | int i; | 749 | int i; |
749 | for ( i = 0; i < int(cats.count()); i++ ) { | 750 | for ( i = 0; i < int(cats.count()); i++ ) { |
750 | if ( cats[i] == category ) { | 751 | if ( cats[i] == category ) { |
751 | returnMe = cnt.match( r ); | 752 | returnMe = cnt.match( r ); |
752 | break; | 753 | break; |
753 | } | 754 | } |
754 | } | 755 | } |
755 | } | 756 | } |
756 | 757 | ||
757 | return returnMe; | 758 | return returnMe; |
758 | } | 759 | } |
759 | 760 | ||
760 | void AbTable::fitColumns() | 761 | void AbTable::fitColumns() |
761 | { | 762 | { |
762 | int contentsWidth = visibleWidth() / 2; | 763 | int contentsWidth = visibleWidth() / 2; |
763 | 764 | ||
764 | if ( showBk == "Cards" ) { | 765 | if ( showBk == "Cards" ) { |
765 | showColumn(1); | 766 | showColumn(1); |
766 | //adjustColumn(1); | 767 | //adjustColumn(1); |
767 | setColumnWidth( 1, visibleWidth() ); | 768 | setColumnWidth( 1, visibleWidth() ); |
768 | columnVisible = false; | 769 | columnVisible = false; |
769 | } else { | 770 | } else { |
770 | if ( columnVisible == false ){ | 771 | if ( columnVisible == false ){ |
771 | showColumn(0); | 772 | showColumn(0); |
772 | columnVisible = true; | 773 | columnVisible = true; |
773 | } | 774 | } |
774 | setColumnWidth( 0, contentsWidth ); | 775 | setColumnWidth( 0, contentsWidth ); |
775 | adjustColumn(1); | 776 | adjustColumn(1); |
776 | if ( columnWidth(1) < contentsWidth ) | 777 | if ( columnWidth(1) < contentsWidth ) |
777 | setColumnWidth( 1, contentsWidth ); | 778 | setColumnWidth( 1, contentsWidth ); |
778 | } | 779 | } |
779 | } | 780 | } |
780 | 781 | ||
781 | void AbTable::show() | 782 | void AbTable::show() |
782 | { | 783 | { |
783 | fitColumns(); | 784 | fitColumns(); |
784 | QTable::show(); | 785 | QTable::show(); |
785 | } | 786 | } |
786 | 787 | ||
787 | void AbTable::setChoiceNames( const QStringList& list) | 788 | void AbTable::setChoiceNames( const QStringList& list) |
788 | { | 789 | { |
789 | choicenames = list; | 790 | choicenames = list; |
790 | if ( choicenames.isEmpty() ) { | 791 | if ( choicenames.isEmpty() ) { |
791 | // hide pick column | 792 | // hide pick column |
792 | setNumCols( 2 ); | 793 | setNumCols( 2 ); |
793 | } else { | 794 | } else { |
794 | // show pick column | 795 | // show pick column |
795 | setNumCols( 3 ); | 796 | setNumCols( 3 ); |
796 | setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 ); | 797 | setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 ); |
797 | horizontalHeader()->setLabel( 2, tr( "Pick" )); | 798 | horizontalHeader()->setLabel( 2, tr( "Pick" )); |
798 | } | 799 | } |
799 | fitColumns(); | 800 | fitColumns(); |
800 | } | 801 | } |
801 | 802 | ||
802 | void AbTable::itemClicked(int,int col) | 803 | void AbTable::itemClicked(int,int col) |
803 | { | 804 | { |
804 | if ( col == 2 ) { | 805 | if ( col == 2 ) { |
805 | return; | 806 | return; |
806 | } else { | 807 | } else { |
807 | emit details(); | 808 | emit details(); |
808 | } | 809 | } |
809 | } | 810 | } |
810 | 811 | ||
811 | QStringList AbTable::choiceNames() const | 812 | QStringList AbTable::choiceNames() const |
812 | { | 813 | { |
813 | return choicenames; | 814 | return choicenames; |
814 | } | 815 | } |
815 | 816 | ||
816 | void AbTable::setChoiceSelection(int /*index*/, const QStringList& /*list*/) | 817 | void AbTable::setChoiceSelection(int /*index*/, const QStringList& /*list*/) |
817 | { | 818 | { |
818 | /* ###### | 819 | /* ###### |
819 | 820 | ||
820 | QString selname = choicenames.at(index); | 821 | QString selname = choicenames.at(index); |
821 | for (each row) { | 822 | for (each row) { |
822 | OContact *c = contactForRow(row); | 823 | OContact *c = contactForRow(row); |
823 | if ( list.contains(c->email) ) { | 824 | if ( list.contains(c->email) ) { |
824 | list.remove(c->email); | 825 | list.remove(c->email); |
825 | setText(row, 2, selname); | 826 | setText(row, 2, selname); |
826 | } | 827 | } |
827 | } | 828 | } |
828 | for (remaining list items) { | 829 | for (remaining list items) { |
829 | OContact *c = new contact(item); | 830 | OContact *c = new contact(item); |
830 | setText(newrow, 2, selname); | 831 | setText(newrow, 2, selname); |
831 | } | 832 | } |
832 | 833 | ||
833 | */ | 834 | */ |
834 | } | 835 | } |
835 | 836 | ||
836 | QStringList AbTable::choiceSelection(int /*index*/) const | 837 | QStringList AbTable::choiceSelection(int /*index*/) const |
837 | { | 838 | { |
838 | QStringList r; | 839 | QStringList r; |
839 | /* ###### | 840 | /* ###### |
840 | 841 | ||
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp index 52ab0f2..e034b35 100644 --- a/core/pim/addressbook/contacteditor.cpp +++ b/core/pim/addressbook/contacteditor.cpp | |||
@@ -1,386 +1,387 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org> | 2 | * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org> |
3 | * Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) | ||
3 | * | 4 | * |
4 | * This file is an add-on for the OPIE Palmtop Environment | 5 | * This file is an add-on for the OPIE Palmtop Environment |
5 | * | 6 | * |
6 | * This file may be distributed and/or modified under the terms of the | 7 | * This file may be distributed and/or modified under the terms of the |
7 | * GNU General Public License version 2 as published by the Free Software | 8 | * GNU General Public License version 2 as published by the Free Software |
8 | * Foundation and appearing in the file LICENSE.GPL included in the pacakaging | 9 | * Foundation and appearing in the file LICENSE.GPL included in the pacakaging |
9 | * of this file. | 10 | * of this file. |
10 | * | 11 | * |
11 | * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | * | 14 | * |
14 | * | 15 | * |
15 | * This is a rewrite of the abeditor.h file, modified to provide a more | 16 | * This is a rewrite of the abeditor.h file, modified to provide a more |
16 | * intuitive interface to TrollTech's original Address Book editor. This | 17 | * intuitive interface to TrollTech's original Address Book editor. This |
17 | * is made to operate exactly in interface with the exception of name. | 18 | * is made to operate exactly in interface with the exception of name. |
18 | * | 19 | * |
19 | */ | 20 | */ |
20 | 21 | ||
21 | #include "contacteditor.h" | 22 | #include "contacteditor.h" |
22 | #include "addresspicker.h" | 23 | #include "addresspicker.h" |
23 | 24 | ||
24 | #include <qpe/categoryselect.h> | 25 | #include <qpe/categoryselect.h> |
25 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/qpedialog.h> | 27 | #include <qpe/qpedialog.h> |
27 | #include <qpe/timeconversion.h> | 28 | #include <qpe/timeconversion.h> |
28 | 29 | ||
29 | #include <qcombobox.h> | 30 | #include <qcombobox.h> |
30 | #include <qlabel.h> | 31 | #include <qlabel.h> |
31 | #include <qtabwidget.h> | 32 | #include <qtabwidget.h> |
32 | #include <qlayout.h> | 33 | #include <qlayout.h> |
33 | #include <qlineedit.h> | 34 | #include <qlineedit.h> |
34 | #include <qmultilineedit.h> | 35 | #include <qmultilineedit.h> |
35 | #include <qscrollview.h> | 36 | #include <qscrollview.h> |
36 | #include <qtoolbutton.h> | 37 | #include <qtoolbutton.h> |
37 | #include <qpushbutton.h> | 38 | #include <qpushbutton.h> |
38 | #include <qmainwindow.h> | 39 | #include <qmainwindow.h> |
39 | #include <qvaluelist.h> | 40 | #include <qvaluelist.h> |
40 | #include <qpopupmenu.h> | 41 | #include <qpopupmenu.h> |
41 | #include <qlistbox.h> | 42 | #include <qlistbox.h> |
42 | 43 | ||
43 | static inline bool containsAlphaNum( const QString &str ); | 44 | static inline bool containsAlphaNum( const QString &str ); |
44 | static inline bool constainsWhiteSpace( const QString &str ); | 45 | static inline bool constainsWhiteSpace( const QString &str ); |
45 | 46 | ||
46 | // helper functions, convert our comma delimited list to proper | 47 | // helper functions, convert our comma delimited list to proper |
47 | // file format... | 48 | // file format... |
48 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, | 49 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, |
49 | QString &strAll ); | 50 | QString &strAll ); |
50 | 51 | ||
51 | // helper convert from file format to comma delimited... | 52 | // helper convert from file format to comma delimited... |
52 | void parseEmailTo( const QString &strDefaultEmail, | 53 | void parseEmailTo( const QString &strDefaultEmail, |
53 | const QString &strOtherEmail, QString &strBack ); | 54 | const QString &strOtherEmail, QString &strBack ); |
54 | 55 | ||
55 | ContactEditor::ContactEditor(const OContact &entry, | 56 | ContactEditor::ContactEditor(const OContact &entry, |
56 | const QValueList<int> *newOrderedValues, | 57 | const QValueList<int> *newOrderedValues, |
57 | QStringList *slNewOrdered, | 58 | QStringList *slNewOrdered, |
58 | QWidget *parent, | 59 | QWidget *parent, |
59 | const char *name, | 60 | const char *name, |
60 | WFlags fl ) | 61 | WFlags fl ) |
61 | : QDialog( parent, name, TRUE, fl ), | 62 | : QDialog( parent, name, TRUE, fl ), |
62 | orderedValues( newOrderedValues ), | 63 | orderedValues( newOrderedValues ), |
63 | slOrdered( *slNewOrdered ), | 64 | slOrdered( *slNewOrdered ), |
64 | m_personalView ( false ) | 65 | m_personalView ( false ) |
65 | { | 66 | { |
66 | 67 | ||
67 | init(); | 68 | init(); |
68 | initMap(); | 69 | initMap(); |
69 | setEntry( entry ); | 70 | setEntry( entry ); |
70 | qDebug("finish"); | 71 | qDebug("finish"); |
71 | } | 72 | } |
72 | 73 | ||
73 | ContactEditor::~ContactEditor() { | 74 | ContactEditor::~ContactEditor() { |
74 | } | 75 | } |
75 | 76 | ||
76 | void ContactEditor::init() { | 77 | void ContactEditor::init() { |
77 | 78 | ||
78 | useFullName = TRUE; | 79 | useFullName = TRUE; |
79 | 80 | ||
80 | int i = 0; | 81 | int i = 0; |
81 | /** SHut up and stop leaking | 82 | /** SHut up and stop leaking |
82 | slHomeAddress = new QStringList; | 83 | slHomeAddress = new QStringList; |
83 | slBusinessAddress = new QStringList; | 84 | slBusinessAddress = new QStringList; |
84 | slChooserNames = new QStringList; | 85 | slChooserNames = new QStringList; |
85 | slChooserValues = new QStringList; | 86 | slChooserValues = new QStringList; |
86 | 87 | ||
87 | slDynamicEntries = new QStringList; | 88 | slDynamicEntries = new QStringList; |
88 | */ | 89 | */ |
89 | //*slDynamicEntries = *slOrdered; | 90 | //*slDynamicEntries = *slOrdered; |
90 | 91 | ||
91 | QStringList trlChooserNames; | 92 | QStringList trlChooserNames; |
92 | 93 | ||
93 | for (i = 0; i <= 6; i++) { | 94 | for (i = 0; i <= 6; i++) { |
94 | slHomeAddress.append( "" ); | 95 | slHomeAddress.append( "" ); |
95 | slBusinessAddress.append( "" ); | 96 | slBusinessAddress.append( "" ); |
96 | } | 97 | } |
97 | 98 | ||
98 | { | 99 | { |
99 | hasGender = FALSE; | 100 | hasGender = FALSE; |
100 | hasTitle = FALSE; | 101 | hasTitle = FALSE; |
101 | hasCompany = FALSE; | 102 | hasCompany = FALSE; |
102 | hasNotes = FALSE; | 103 | hasNotes = FALSE; |
103 | hasStreet = FALSE; | 104 | hasStreet = FALSE; |
104 | hasStreet2 = FALSE; | 105 | hasStreet2 = FALSE; |
105 | hasPOBox = FALSE; | 106 | hasPOBox = FALSE; |
106 | hasCity = FALSE; | 107 | hasCity = FALSE; |
107 | hasState = FALSE; | 108 | hasState = FALSE; |
108 | hasZip = FALSE; | 109 | hasZip = FALSE; |
109 | hasCountry = FALSE; | 110 | hasCountry = FALSE; |
110 | 111 | ||
111 | QStringList::ConstIterator it = slOrdered.begin(); | 112 | QStringList::ConstIterator it = slOrdered.begin(); |
112 | 113 | ||
113 | for ( i = 0; it != slOrdered.end(); i++, ++it ) { | 114 | for ( i = 0; it != slOrdered.end(); i++, ++it ) { |
114 | 115 | ||
115 | if ( (*it) == "Business Fax" ) { | 116 | if ( (*it) == "Business Fax" ) { |
116 | trlChooserNames.append( tr( "Business Fax" ) ); | 117 | trlChooserNames.append( tr( "Business Fax" ) ); |
117 | slChooserNames.append( *it ); | 118 | slChooserNames.append( *it ); |
118 | slChooserValues.append("" ); | 119 | slChooserValues.append("" ); |
119 | //slDynamicEntries->remove( it ); | 120 | //slDynamicEntries->remove( it ); |
120 | continue; | 121 | continue; |
121 | } | 122 | } |
122 | 123 | ||
123 | if ( (*it) == "Home Fax" ) { | 124 | if ( (*it) == "Home Fax" ) { |
124 | trlChooserNames.append( tr( "Home Fax" ) ); | 125 | trlChooserNames.append( tr( "Home Fax" ) ); |
125 | slChooserNames.append( *it ); | 126 | slChooserNames.append( *it ); |
126 | slChooserValues.append("" ); | 127 | slChooserValues.append("" ); |
127 | //slDynamicEntries->remove( it ); | 128 | //slDynamicEntries->remove( it ); |
128 | continue; | 129 | continue; |
129 | } | 130 | } |
130 | 131 | ||
131 | 132 | ||
132 | if ( (*it) == "Business Phone" ) { | 133 | if ( (*it) == "Business Phone" ) { |
133 | trlChooserNames.append( tr( "Business Phone" ) ); | 134 | trlChooserNames.append( tr( "Business Phone" ) ); |
134 | slChooserNames.append( *it ); | 135 | slChooserNames.append( *it ); |
135 | slChooserValues.append( "" ); | 136 | slChooserValues.append( "" ); |
136 | //slDynamicEntries->remove( it ); | 137 | //slDynamicEntries->remove( it ); |
137 | continue; | 138 | continue; |
138 | } | 139 | } |
139 | 140 | ||
140 | if ( (*it) == "Home Phone" ) { | 141 | if ( (*it) == "Home Phone" ) { |
141 | trlChooserNames.append( tr( "Home Phone" ) ); | 142 | trlChooserNames.append( tr( "Home Phone" ) ); |
142 | slChooserNames.append( *it ); | 143 | slChooserNames.append( *it ); |
143 | slChooserValues.append( "" ); | 144 | slChooserValues.append( "" ); |
144 | //slDynamicEntries->remove( it ); | 145 | //slDynamicEntries->remove( it ); |
145 | continue; | 146 | continue; |
146 | } | 147 | } |
147 | 148 | ||
148 | /* | 149 | /* |
149 | if ( (*it).right( 2 ) == tr( "IM" ) ) { | 150 | if ( (*it).right( 2 ) == tr( "IM" ) ) { |
150 | slChooserNames.append( *it ); | 151 | slChooserNames.append( *it ); |
151 | slChooserValues.append( "" ); | 152 | slChooserValues.append( "" ); |
152 | //slDynamicEntries->remove( it ); | 153 | //slDynamicEntries->remove( it ); |
153 | continue; | 154 | continue; |
154 | } */ | 155 | } */ |
155 | 156 | ||
156 | if ( (*it) == "Business Mobile" ) { | 157 | if ( (*it) == "Business Mobile" ) { |
157 | trlChooserNames.append( tr( "Business Mobile" ) ); | 158 | trlChooserNames.append( tr( "Business Mobile" ) ); |
158 | slChooserNames.append( *it ); | 159 | slChooserNames.append( *it ); |
159 | slChooserValues.append( "" ); | 160 | slChooserValues.append( "" ); |
160 | //slDynamicEntries->remove( it ); | 161 | //slDynamicEntries->remove( it ); |
161 | continue; | 162 | continue; |
162 | } | 163 | } |
163 | 164 | ||
164 | if ( (*it) == "Home Mobile" ) { | 165 | if ( (*it) == "Home Mobile" ) { |
165 | trlChooserNames.append( tr( "Home Mobile" ) ); | 166 | trlChooserNames.append( tr( "Home Mobile" ) ); |
166 | slChooserNames.append( *it ); | 167 | slChooserNames.append( *it ); |
167 | slChooserValues.append( "" ); | 168 | slChooserValues.append( "" ); |
168 | //slDynamicEntries->remove( it ); | 169 | //slDynamicEntries->remove( it ); |
169 | continue; | 170 | continue; |
170 | } | 171 | } |
171 | 172 | ||
172 | 173 | ||
173 | if ( (*it) == "Business WebPage" ) { | 174 | if ( (*it) == "Business WebPage" ) { |
174 | trlChooserNames.append( tr( "Business WebPage" ) ); | 175 | trlChooserNames.append( tr( "Business WebPage" ) ); |
175 | slChooserNames.append( *it ); | 176 | slChooserNames.append( *it ); |
176 | slChooserValues.append( "" ); | 177 | slChooserValues.append( "" ); |
177 | //slDynamicEntries->remove( it ); | 178 | //slDynamicEntries->remove( it ); |
178 | continue; | 179 | continue; |
179 | } | 180 | } |
180 | 181 | ||
181 | if ( (*it) == "Home Web Page" ) { | 182 | if ( (*it) == "Home Web Page" ) { |
182 | trlChooserNames.append( tr( "Home Web Page" ) ); | 183 | trlChooserNames.append( tr( "Home Web Page" ) ); |
183 | slChooserNames.append( *it ); | 184 | slChooserNames.append( *it ); |
184 | slChooserValues.append( "" ); | 185 | slChooserValues.append( "" ); |
185 | //slDynamicEntries->remove( it ); | 186 | //slDynamicEntries->remove( it ); |
186 | continue; | 187 | continue; |
187 | } | 188 | } |
188 | 189 | ||
189 | if ( (*it) == "Business Pager" ) { | 190 | if ( (*it) == "Business Pager" ) { |
190 | trlChooserNames.append( tr( "Business Pager" ) ); | 191 | trlChooserNames.append( tr( "Business Pager" ) ); |
191 | slChooserNames.append( *it ); | 192 | slChooserNames.append( *it ); |
192 | slChooserValues.append( "" ); | 193 | slChooserValues.append( "" ); |
193 | //slDynamicEntries->remove( it ); | 194 | //slDynamicEntries->remove( it ); |
194 | continue; | 195 | continue; |
195 | } | 196 | } |
196 | 197 | ||
197 | if ( *it == "Default Email" ) { | 198 | if ( *it == "Default Email" ) { |
198 | trlChooserNames.append( tr( "Default Email" ) ); | 199 | trlChooserNames.append( tr( "Default Email" ) ); |
199 | slChooserNames.append( *it ); | 200 | slChooserNames.append( *it ); |
200 | slChooserValues.append( "" ); | 201 | slChooserValues.append( "" ); |
201 | //slDynamicEntries->remove( it ); | 202 | //slDynamicEntries->remove( it ); |
202 | continue; | 203 | continue; |
203 | } | 204 | } |
204 | 205 | ||
205 | if ( *it == "Emails" ) { | 206 | if ( *it == "Emails" ) { |
206 | trlChooserNames.append( tr( "Emails" ) ); | 207 | trlChooserNames.append( tr( "Emails" ) ); |
207 | slChooserNames.append( *it ); | 208 | slChooserNames.append( *it ); |
208 | slChooserValues.append( "" ); | 209 | slChooserValues.append( "" ); |
209 | //slDynamicEntries->remove( it ); | 210 | //slDynamicEntries->remove( it ); |
210 | continue; | 211 | continue; |
211 | } | 212 | } |
212 | 213 | ||
213 | if ( *it == "Name Title" || | 214 | if ( *it == "Name Title" || |
214 | *it == "First Name" || | 215 | *it == "First Name" || |
215 | *it == "Middle Name" || | 216 | *it == "Middle Name" || |
216 | *it == "Last Name" || | 217 | *it == "Last Name" || |
217 | *it == "File As" || | 218 | *it == "File As" || |
218 | *it == "Default Email" || | 219 | *it == "Default Email" || |
219 | *it == "Emails" || | 220 | *it == "Emails" || |
220 | *it == "Groups" || | 221 | *it == "Groups" || |
221 | *it == "Anniversary" || | 222 | *it == "Anniversary" || |
222 | *it == "Birthday" ) | 223 | *it == "Birthday" ) |
223 | continue; | 224 | continue; |
224 | 225 | ||
225 | if ( *it == "Name Title" ) { | 226 | if ( *it == "Name Title" ) { |
226 | //slDynamicEntries->remove( it ); | 227 | //slDynamicEntries->remove( it ); |
227 | continue; | 228 | continue; |
228 | } | 229 | } |
229 | 230 | ||
230 | if ( *it == "First Name" ) { | 231 | if ( *it == "First Name" ) { |
231 | //slDynamicEntries->remove( it ); | 232 | //slDynamicEntries->remove( it ); |
232 | continue; | 233 | continue; |
233 | } | 234 | } |
234 | 235 | ||
235 | if ( *it == "Middle Name" ) { | 236 | if ( *it == "Middle Name" ) { |
236 | //slDynamicEntries->remove( it ); | 237 | //slDynamicEntries->remove( it ); |
237 | continue; | 238 | continue; |
238 | } | 239 | } |
239 | 240 | ||
240 | if ( *it == "Last Name" ) { | 241 | if ( *it == "Last Name" ) { |
241 | //slDynamicEntries->remove( it ); | 242 | //slDynamicEntries->remove( it ); |
242 | continue; | 243 | continue; |
243 | } | 244 | } |
244 | 245 | ||
245 | if ( *it == "Suffix" ) { | 246 | if ( *it == "Suffix" ) { |
246 | //slDynamicEntries->remove( it ); | 247 | //slDynamicEntries->remove( it ); |
247 | continue; | 248 | continue; |
248 | } | 249 | } |
249 | 250 | ||
250 | if ( *it == "File As" ) { | 251 | if ( *it == "File As" ) { |
251 | //slDynamicEntries->remove( it ); | 252 | //slDynamicEntries->remove( it ); |
252 | continue; | 253 | continue; |
253 | } | 254 | } |
254 | 255 | ||
255 | if ( *it == "Gender" ) { | 256 | if ( *it == "Gender" ) { |
256 | hasGender = TRUE; | 257 | hasGender = TRUE; |
257 | //slDynamicEntries->remove( it ); | 258 | //slDynamicEntries->remove( it ); |
258 | continue; | 259 | continue; |
259 | } | 260 | } |
260 | 261 | ||
261 | if ( *it == "Job Title" ) { | 262 | if ( *it == "Job Title" ) { |
262 | hasTitle = TRUE; | 263 | hasTitle = TRUE; |
263 | //slDynamicEntries->remove( it ); | 264 | //slDynamicEntries->remove( it ); |
264 | continue; | 265 | continue; |
265 | } | 266 | } |
266 | 267 | ||
267 | if ( ( *it == "Company") || (*it == "Organization" ) ) { | 268 | if ( ( *it == "Company") || (*it == "Organization" ) ) { |
268 | hasCompany = TRUE; | 269 | hasCompany = TRUE; |
269 | //slDynamicEntries->remove( it ); | 270 | //slDynamicEntries->remove( it ); |
270 | continue; | 271 | continue; |
271 | } | 272 | } |
272 | 273 | ||
273 | if ( *it == "Notes" ) { | 274 | if ( *it == "Notes" ) { |
274 | hasNotes = TRUE; | 275 | hasNotes = TRUE; |
275 | //slDynamicEntries->remove( it ); | 276 | //slDynamicEntries->remove( it ); |
276 | continue; | 277 | continue; |
277 | } | 278 | } |
278 | 279 | ||
279 | if ( *it == "Groups" ) { | 280 | if ( *it == "Groups" ) { |
280 | //slDynamicEntries->remove( it ); | 281 | //slDynamicEntries->remove( it ); |
281 | continue; | 282 | continue; |
282 | } | 283 | } |
283 | 284 | ||
284 | if ( (*it) == "Business Street" ) { | 285 | if ( (*it) == "Business Street" ) { |
285 | hasStreet = TRUE; | 286 | hasStreet = TRUE; |
286 | //slDynamicEntries->remove( it ); | 287 | //slDynamicEntries->remove( it ); |
287 | continue; | 288 | continue; |
288 | } | 289 | } |
289 | 290 | ||
290 | if ( (*it) == "Home Street" ) { | 291 | if ( (*it) == "Home Street" ) { |
291 | hasStreet = TRUE; | 292 | hasStreet = TRUE; |
292 | //slDynamicEntries->remove( it ); | 293 | //slDynamicEntries->remove( it ); |
293 | continue; | 294 | continue; |
294 | } | 295 | } |
295 | /* | 296 | /* |
296 | if ( (*it).right( 8 ) == tr( "Street 2" ) ) { | 297 | if ( (*it).right( 8 ) == tr( "Street 2" ) ) { |
297 | hasStreet2 = TRUE; | 298 | hasStreet2 = TRUE; |
298 | //slDynamicEntries->remove( it ); | 299 | //slDynamicEntries->remove( it ); |
299 | continue; | 300 | continue; |
300 | } | 301 | } |
301 | 302 | ||
302 | if ( (*it).right( 8 ) == tr( "P.O. Box" ) ) { | 303 | if ( (*it).right( 8 ) == tr( "P.O. Box" ) ) { |
303 | hasPOBox = TRUE; | 304 | hasPOBox = TRUE; |
304 | //slDynamicEntries->remove( it ); | 305 | //slDynamicEntries->remove( it ); |
305 | continue; | 306 | continue; |
306 | } */ | 307 | } */ |
307 | 308 | ||
308 | if ( (*it) == "Business City" ) { | 309 | if ( (*it) == "Business City" ) { |
309 | hasCity = TRUE; | 310 | hasCity = TRUE; |
310 | //slDynamicEntries->remove( it ); | 311 | //slDynamicEntries->remove( it ); |
311 | continue; | 312 | continue; |
312 | } | 313 | } |
313 | 314 | ||
314 | if ( (*it) == "Business State" ) { | 315 | if ( (*it) == "Business State" ) { |
315 | hasState = TRUE; | 316 | hasState = TRUE; |
316 | //slDynamicEntries->remove( it ); | 317 | //slDynamicEntries->remove( it ); |
317 | continue; | 318 | continue; |
318 | } | 319 | } |
319 | 320 | ||
320 | if ( (*it) == "Business Zip" ) { | 321 | if ( (*it) == "Business Zip" ) { |
321 | hasZip = TRUE; | 322 | hasZip = TRUE; |
322 | //slDynamicEntries->remove( it ); | 323 | //slDynamicEntries->remove( it ); |
323 | continue; | 324 | continue; |
324 | } | 325 | } |
325 | 326 | ||
326 | if ( (*it) == "Business Country" ) { | 327 | if ( (*it) == "Business Country" ) { |
327 | hasCountry = TRUE; | 328 | hasCountry = TRUE; |
328 | //slDynamicEntries->remove( it ); | 329 | //slDynamicEntries->remove( it ); |
329 | continue; | 330 | continue; |
330 | } | 331 | } |
331 | 332 | ||
332 | if ( (*it) == "Home City" ) { | 333 | if ( (*it) == "Home City" ) { |
333 | hasCity = TRUE; | 334 | hasCity = TRUE; |
334 | //slDynamicEntries->remove( it ); | 335 | //slDynamicEntries->remove( it ); |
335 | continue; | 336 | continue; |
336 | } | 337 | } |
337 | 338 | ||
338 | if ( (*it) == "Home State" ) { | 339 | if ( (*it) == "Home State" ) { |
339 | hasState = TRUE; | 340 | hasState = TRUE; |
340 | //slDynamicEntries->remove( it ); | 341 | //slDynamicEntries->remove( it ); |
341 | continue; | 342 | continue; |
342 | } | 343 | } |
343 | 344 | ||
344 | if ( (*it) == "Home Zip" ) { | 345 | if ( (*it) == "Home Zip" ) { |
345 | hasZip = TRUE; | 346 | hasZip = TRUE; |
346 | //slDynamicEntries->remove( it ); | 347 | //slDynamicEntries->remove( it ); |
347 | continue; | 348 | continue; |
348 | } | 349 | } |
349 | 350 | ||
350 | if ( (*it) == "Home Country" ) { | 351 | if ( (*it) == "Home Country" ) { |
351 | hasCountry = TRUE; | 352 | hasCountry = TRUE; |
352 | //slDynamicEntries->remove( it ); | 353 | //slDynamicEntries->remove( it ); |
353 | continue; | 354 | continue; |
354 | } | 355 | } |
355 | 356 | ||
356 | slDynamicEntries.append( *it ); | 357 | slDynamicEntries.append( *it ); |
357 | } | 358 | } |
358 | } | 359 | } |
359 | 360 | ||
360 | QVBoxLayout *vb = new QVBoxLayout( this ); | 361 | QVBoxLayout *vb = new QVBoxLayout( this ); |
361 | 362 | ||
362 | tabMain = new QTabWidget( this ); | 363 | tabMain = new QTabWidget( this ); |
363 | vb->addWidget( tabMain ); | 364 | vb->addWidget( tabMain ); |
364 | 365 | ||
365 | QWidget *tabViewport = new QWidget ( tabMain ); | 366 | QWidget *tabViewport = new QWidget ( tabMain ); |
366 | 367 | ||
367 | vb = new QVBoxLayout( tabViewport ); | 368 | vb = new QVBoxLayout( tabViewport ); |
368 | 369 | ||
369 | svGeneral = new QScrollView( tabViewport ); | 370 | svGeneral = new QScrollView( tabViewport ); |
370 | vb->addWidget( svGeneral, 0, 0 ); | 371 | vb->addWidget( svGeneral, 0, 0 ); |
371 | svGeneral->setResizePolicy( QScrollView::AutoOneFit ); | 372 | svGeneral->setResizePolicy( QScrollView::AutoOneFit ); |
372 | svGeneral->setFrameStyle( QFrame::NoFrame ); | 373 | svGeneral->setFrameStyle( QFrame::NoFrame ); |
373 | 374 | ||
374 | QWidget *container = new QWidget( svGeneral->viewport() ); | 375 | QWidget *container = new QWidget( svGeneral->viewport() ); |
375 | svGeneral->addChild( container ); | 376 | svGeneral->addChild( container ); |
376 | 377 | ||
377 | QGridLayout *gl = new QGridLayout( container, 1, 1, 2, 4 ); | 378 | QGridLayout *gl = new QGridLayout( container, 1, 1, 2, 4 ); |
378 | gl->setResizeMode( QLayout::FreeResize ); | 379 | gl->setResizeMode( QLayout::FreeResize ); |
379 | 380 | ||
380 | btnFullName = new QPushButton( tr( "Full Name..." ), container ); | 381 | btnFullName = new QPushButton( tr( "Full Name..." ), container ); |
381 | gl->addWidget( btnFullName, 0, 0 ); | 382 | gl->addWidget( btnFullName, 0, 0 ); |
382 | txtFullName = new QLineEdit( container ); | 383 | txtFullName = new QLineEdit( container ); |
383 | gl->addWidget( txtFullName, 0, 1 ); | 384 | gl->addWidget( txtFullName, 0, 1 ); |
384 | 385 | ||
385 | QLabel *l = new QLabel( tr( "Job Title" ), container ); | 386 | QLabel *l = new QLabel( tr( "Job Title" ), container ); |
386 | gl->addWidget( l, 1, 0 ); | 387 | gl->addWidget( l, 1, 0 ); |
@@ -727,1178 +728,1177 @@ void ContactEditor::init() { | |||
727 | svDetails->setResizePolicy( QScrollView::AutoOneFit ); | 728 | svDetails->setResizePolicy( QScrollView::AutoOneFit ); |
728 | svDetails->setFrameStyle( QFrame::NoFrame ); | 729 | svDetails->setFrameStyle( QFrame::NoFrame ); |
729 | 730 | ||
730 | container = new QWidget( svDetails->viewport() ); | 731 | container = new QWidget( svDetails->viewport() ); |
731 | svDetails->addChild( container ); | 732 | svDetails->addChild( container ); |
732 | 733 | ||
733 | gl = new QGridLayout( container, 1, 2, 2, 4 ); | 734 | gl = new QGridLayout( container, 1, 2, 2, 4 ); |
734 | 735 | ||
735 | int counter = 0; | 736 | int counter = 0; |
736 | 737 | ||
737 | // Birthday | 738 | // Birthday |
738 | l = new QLabel( tr("Birthday"), container ); | 739 | l = new QLabel( tr("Birthday"), container ); |
739 | gl->addWidget( l, counter, 0 ); | 740 | gl->addWidget( l, counter, 0 ); |
740 | 741 | ||
741 | QPopupMenu* m1 = new QPopupMenu( container ); | 742 | QPopupMenu* m1 = new QPopupMenu( container ); |
742 | birthdayPicker = new DateBookMonth( m1, 0, TRUE ); | 743 | birthdayPicker = new DateBookMonth( m1, 0, TRUE ); |
743 | m1->insertItem( birthdayPicker ); | 744 | m1->insertItem( birthdayPicker ); |
744 | 745 | ||
745 | birthdayButton= new QToolButton( container, "buttonStart" ); | 746 | birthdayButton= new QToolButton( container, "buttonStart" ); |
746 | birthdayButton->setPopup( m1 ); | 747 | birthdayButton->setPopup( m1 ); |
747 | birthdayButton->setPopupDelay(0); | 748 | birthdayButton->setPopupDelay(0); |
748 | gl->addWidget( birthdayButton, counter , 1 ); | 749 | gl->addWidget( birthdayButton, counter , 1 ); |
749 | connect( birthdayPicker, SIGNAL( dateClicked( int, int, int ) ), | 750 | connect( birthdayPicker, SIGNAL( dateClicked( int, int, int ) ), |
750 | this, SLOT( slotBirthdayDateChanged( int, int, int ) ) ); | 751 | this, SLOT( slotBirthdayDateChanged( int, int, int ) ) ); |
751 | 752 | ||
752 | ++counter; | 753 | ++counter; |
753 | 754 | ||
754 | // Anniversary | 755 | // Anniversary |
755 | l = new QLabel( tr("Anniversary"), container ); | 756 | l = new QLabel( tr("Anniversary"), container ); |
756 | gl->addWidget( l, counter, 0 ); | 757 | gl->addWidget( l, counter, 0 ); |
757 | 758 | ||
758 | m1 = new QPopupMenu( container ); | 759 | m1 = new QPopupMenu( container ); |
759 | anniversaryPicker = new DateBookMonth( m1, 0, TRUE ); | 760 | anniversaryPicker = new DateBookMonth( m1, 0, TRUE ); |
760 | m1->insertItem( anniversaryPicker ); | 761 | m1->insertItem( anniversaryPicker ); |
761 | 762 | ||
762 | anniversaryButton= new QToolButton( container, "buttonStart" ); | 763 | anniversaryButton= new QToolButton( container, "buttonStart" ); |
763 | anniversaryButton->setPopup( m1 ); | 764 | anniversaryButton->setPopup( m1 ); |
764 | anniversaryButton->setPopupDelay(0); | 765 | anniversaryButton->setPopupDelay(0); |
765 | gl->addWidget( anniversaryButton, counter , 1 ); | 766 | gl->addWidget( anniversaryButton, counter , 1 ); |
766 | connect( anniversaryPicker, SIGNAL( dateClicked( int, int, int ) ), | 767 | connect( anniversaryPicker, SIGNAL( dateClicked( int, int, int ) ), |
767 | this, SLOT( slotAnniversaryDateChanged( int, int, int ) ) ); | 768 | this, SLOT( slotAnniversaryDateChanged( int, int, int ) ) ); |
768 | 769 | ||
769 | ++counter; | 770 | ++counter; |
770 | 771 | ||
771 | // Gender | 772 | // Gender |
772 | l = new QLabel( tr("Gender"), container ); | 773 | l = new QLabel( tr("Gender"), container ); |
773 | gl->addWidget( l, counter, 0 ); | 774 | gl->addWidget( l, counter, 0 ); |
774 | cmbGender = new QComboBox( container ); | 775 | cmbGender = new QComboBox( container ); |
775 | cmbGender->insertItem( "", 0 ); | 776 | cmbGender->insertItem( "", 0 ); |
776 | cmbGender->insertItem( tr("Male"), 1); | 777 | cmbGender->insertItem( tr("Male"), 1); |
777 | cmbGender->insertItem( tr("Female"), 2); | 778 | cmbGender->insertItem( tr("Female"), 2); |
778 | gl->addWidget( cmbGender, counter, 1 ); | 779 | gl->addWidget( cmbGender, counter, 1 ); |
779 | 780 | ||
780 | ++counter; | 781 | ++counter; |
781 | 782 | ||
782 | // Create Labels and lineedit fields for every dynamic entry | 783 | // Create Labels and lineedit fields for every dynamic entry |
783 | QStringList::ConstIterator it = slDynamicEntries.begin(); | 784 | QStringList::ConstIterator it = slDynamicEntries.begin(); |
784 | for (i = counter; it != slDynamicEntries.end(); i++, ++it) { | 785 | for (i = counter; it != slDynamicEntries.end(); i++, ++it) { |
785 | l = new QLabel( QString::null , container ); | 786 | l = new QLabel( QString::null , container ); |
786 | listName.append( l ); | 787 | listName.append( l ); |
787 | gl->addWidget( l, i, 0 ); | 788 | gl->addWidget( l, i, 0 ); |
788 | QLineEdit *e = new QLineEdit( container ); | 789 | QLineEdit *e = new QLineEdit( container ); |
789 | listValue.append( e ); | 790 | listValue.append( e ); |
790 | gl->addWidget( e, i, 1); | 791 | gl->addWidget( e, i, 1); |
791 | } | 792 | } |
792 | // Fill labels with names.. | 793 | // Fill labels with names.. |
793 | loadFields(); | 794 | loadFields(); |
794 | 795 | ||
795 | 796 | ||
796 | tabMain->insertTab( tabViewport, tr( "Details" ) ); | 797 | tabMain->insertTab( tabViewport, tr( "Details" ) ); |
797 | 798 | ||
798 | dlgNote = new QDialog( this, "Note Dialog", TRUE ); | 799 | dlgNote = new QDialog( this, "Note Dialog", TRUE ); |
799 | dlgNote->setCaption( tr("Enter Note") ); | 800 | dlgNote->setCaption( tr("Enter Note") ); |
800 | QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); | 801 | QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); |
801 | txtNote = new QMultiLineEdit( dlgNote ); | 802 | txtNote = new QMultiLineEdit( dlgNote ); |
802 | vbNote->addWidget( txtNote ); | 803 | vbNote->addWidget( txtNote ); |
803 | connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) ); | 804 | connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) ); |
804 | 805 | ||
805 | dlgName = new QDialog( this, "Name Dialog", TRUE ); | 806 | dlgName = new QDialog( this, "Name Dialog", TRUE ); |
806 | dlgName->setCaption( tr("Edit Name") ); | 807 | dlgName->setCaption( tr("Edit Name") ); |
807 | gl = new QGridLayout( dlgName, 5, 2, 2, 3 ); | 808 | gl = new QGridLayout( dlgName, 5, 2, 2, 3 ); |
808 | 809 | ||
809 | l = new QLabel( tr("First Name"), dlgName ); | 810 | l = new QLabel( tr("First Name"), dlgName ); |
810 | gl->addWidget( l, 0, 0 ); | 811 | gl->addWidget( l, 0, 0 ); |
811 | txtFirstName = new QLineEdit( dlgName ); | 812 | txtFirstName = new QLineEdit( dlgName ); |
812 | gl->addWidget( txtFirstName, 0, 1 ); | 813 | gl->addWidget( txtFirstName, 0, 1 ); |
813 | 814 | ||
814 | l = new QLabel( tr("Middle Name"), dlgName ); | 815 | l = new QLabel( tr("Middle Name"), dlgName ); |
815 | gl->addWidget( l, 1, 0 ); | 816 | gl->addWidget( l, 1, 0 ); |
816 | txtMiddleName = new QLineEdit( dlgName ); | 817 | txtMiddleName = new QLineEdit( dlgName ); |
817 | gl->addWidget( txtMiddleName, 1, 1 ); | 818 | gl->addWidget( txtMiddleName, 1, 1 ); |
818 | 819 | ||
819 | l = new QLabel( tr("Last Name"), dlgName ); | 820 | l = new QLabel( tr("Last Name"), dlgName ); |
820 | gl->addWidget( l, 2, 0 ); | 821 | gl->addWidget( l, 2, 0 ); |
821 | txtLastName = new QLineEdit( dlgName ); | 822 | txtLastName = new QLineEdit( dlgName ); |
822 | gl->addWidget( txtLastName, 2, 1 ); | 823 | gl->addWidget( txtLastName, 2, 1 ); |
823 | 824 | ||
824 | l = new QLabel( tr("Suffix"), dlgName ); | 825 | l = new QLabel( tr("Suffix"), dlgName ); |
825 | gl->addWidget( l, 3, 0 ); | 826 | gl->addWidget( l, 3, 0 ); |
826 | txtSuffix = new QLineEdit( dlgName ); | 827 | txtSuffix = new QLineEdit( dlgName ); |
827 | gl->addWidget( txtSuffix, 3, 1 ); | 828 | gl->addWidget( txtSuffix, 3, 1 ); |
828 | space = new QSpacerItem(1,1, | 829 | space = new QSpacerItem(1,1, |
829 | QSizePolicy::Maximum, | 830 | QSizePolicy::Maximum, |
830 | QSizePolicy::MinimumExpanding ); | 831 | QSizePolicy::MinimumExpanding ); |
831 | gl->addItem( space, 4, 0 ); | 832 | gl->addItem( space, 4, 0 ); |
832 | 833 | ||
833 | cmbChooserField1->insertStringList( trlChooserNames ); | 834 | cmbChooserField1->insertStringList( trlChooserNames ); |
834 | cmbChooserField2->insertStringList( trlChooserNames ); | 835 | cmbChooserField2->insertStringList( trlChooserNames ); |
835 | cmbChooserField3->insertStringList( trlChooserNames ); | 836 | cmbChooserField3->insertStringList( trlChooserNames ); |
836 | cmbChooserField4->insertStringList( trlChooserNames ); | 837 | cmbChooserField4->insertStringList( trlChooserNames ); |
837 | 838 | ||
838 | cmbChooserField1->setCurrentItem( 0 ); | 839 | cmbChooserField1->setCurrentItem( 0 ); |
839 | cmbChooserField2->setCurrentItem( 1 ); | 840 | cmbChooserField2->setCurrentItem( 1 ); |
840 | cmbChooserField3->setCurrentItem( 2 ); | 841 | cmbChooserField3->setCurrentItem( 2 ); |
841 | 842 | ||
842 | connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) ); | 843 | connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) ); |
843 | 844 | ||
844 | connect( txtFullName, SIGNAL(textChanged(const QString &)), this, SLOT(slotFullNameChange(const QString &)) ); | 845 | connect( txtFullName, SIGNAL(textChanged(const QString &)), this, SLOT(slotFullNameChange(const QString &)) ); |
845 | 846 | ||
846 | connect( txtChooserField1, SIGNAL(textChanged(const QString &)), | 847 | connect( txtChooserField1, SIGNAL(textChanged(const QString &)), |
847 | this, SLOT(slotChooser1Change(const QString &)) ); | 848 | this, SLOT(slotChooser1Change(const QString &)) ); |
848 | connect( txtChooserField2, SIGNAL(textChanged(const QString &)), | 849 | connect( txtChooserField2, SIGNAL(textChanged(const QString &)), |
849 | this, SLOT(slotChooser2Change(const QString &)) ); | 850 | this, SLOT(slotChooser2Change(const QString &)) ); |
850 | connect( txtChooserField3, SIGNAL(textChanged(const QString &)), | 851 | connect( txtChooserField3, SIGNAL(textChanged(const QString &)), |
851 | this, SLOT(slotChooser3Change(const QString &)) ); | 852 | this, SLOT(slotChooser3Change(const QString &)) ); |
852 | connect( txtChooserField4, SIGNAL(textChanged(const QString &)), | 853 | connect( txtChooserField4, SIGNAL(textChanged(const QString &)), |
853 | this, SLOT(slotChooser4Change(const QString &)) ); | 854 | this, SLOT(slotChooser4Change(const QString &)) ); |
854 | connect( txtAddress, SIGNAL(textChanged(const QString &)), | 855 | connect( txtAddress, SIGNAL(textChanged(const QString &)), |
855 | this, SLOT(slotAddressChange(const QString &)) ); | 856 | this, SLOT(slotAddressChange(const QString &)) ); |
856 | //connect( txtAddress2, SIGNAL(textChanged(const QString &)), this, SLOT(slotAddress2Change(const QString &)) ); | 857 | //connect( txtAddress2, SIGNAL(textChanged(const QString &)), this, SLOT(slotAddress2Change(const QString &)) ); |
857 | //connect( txtPOBox, SIGNAL(textChanged(const QString &)), this, SLOT(slotPOBoxChange(const QString &)) ); | 858 | //connect( txtPOBox, SIGNAL(textChanged(const QString &)), this, SLOT(slotPOBoxChange(const QString &)) ); |
858 | connect( txtCity, SIGNAL(textChanged(const QString &)), | 859 | connect( txtCity, SIGNAL(textChanged(const QString &)), |
859 | this, SLOT(slotCityChange(const QString &)) ); | 860 | this, SLOT(slotCityChange(const QString &)) ); |
860 | connect( txtState, SIGNAL(textChanged(const QString &)), | 861 | connect( txtState, SIGNAL(textChanged(const QString &)), |
861 | this, SLOT(slotStateChange(const QString &)) ); | 862 | this, SLOT(slotStateChange(const QString &)) ); |
862 | connect( txtZip, SIGNAL(textChanged(const QString &)), | 863 | connect( txtZip, SIGNAL(textChanged(const QString &)), |
863 | this, SLOT(slotZipChange(const QString &)) ); | 864 | this, SLOT(slotZipChange(const QString &)) ); |
864 | connect( cmbCountry, SIGNAL(textChanged(const QString &)), | 865 | connect( cmbCountry, SIGNAL(textChanged(const QString &)), |
865 | this, SLOT(slotCountryChange(const QString &)) ); | 866 | this, SLOT(slotCountryChange(const QString &)) ); |
866 | connect( cmbCountry, SIGNAL(activated(const QString &)), | 867 | connect( cmbCountry, SIGNAL(activated(const QString &)), |
867 | this, SLOT(slotCountryChange(const QString &)) ); | 868 | this, SLOT(slotCountryChange(const QString &)) ); |
868 | connect( cmbChooserField1, SIGNAL(activated(int)), | 869 | connect( cmbChooserField1, SIGNAL(activated(int)), |
869 | this, SLOT(slotCmbChooser1Change(int)) ); | 870 | this, SLOT(slotCmbChooser1Change(int)) ); |
870 | connect( cmbChooserField2, SIGNAL(activated(int)), | 871 | connect( cmbChooserField2, SIGNAL(activated(int)), |
871 | this, SLOT(slotCmbChooser2Change(int)) ); | 872 | this, SLOT(slotCmbChooser2Change(int)) ); |
872 | connect( cmbChooserField3, SIGNAL(activated(int)), | 873 | connect( cmbChooserField3, SIGNAL(activated(int)), |
873 | this, SLOT(slotCmbChooser3Change(int)) ); | 874 | this, SLOT(slotCmbChooser3Change(int)) ); |
874 | connect( cmbChooserField4, SIGNAL(activated(int)), | 875 | connect( cmbChooserField4, SIGNAL(activated(int)), |
875 | this, SLOT(slotCmbChooser4Change(int)) ); | 876 | this, SLOT(slotCmbChooser4Change(int)) ); |
876 | connect( cmbAddress, SIGNAL(activated(int)), | 877 | connect( cmbAddress, SIGNAL(activated(int)), |
877 | this, SLOT(slotAddressTypeChange(int)) ); | 878 | this, SLOT(slotAddressTypeChange(int)) ); |
878 | 879 | ||
879 | new QPEDialogListener(this); | 880 | new QPEDialogListener(this); |
880 | } | 881 | } |
881 | 882 | ||
882 | void ContactEditor::initMap() | 883 | void ContactEditor::initMap() |
883 | { | 884 | { |
884 | /* | 885 | /* |
885 | // since the fields and the XML fields exist, create a map | 886 | // since the fields and the XML fields exist, create a map |
886 | // between them... | 887 | // between them... |
887 | Config cfg1( "AddressBook" ); | 888 | Config cfg1( "AddressBook" ); |
888 | Config cfg2( "AddressBook" ); | 889 | Config cfg2( "AddressBook" ); |
889 | QString strCfg1, | 890 | QString strCfg1, |
890 | strCfg2; | 891 | strCfg2; |
891 | int i; | 892 | int i; |
892 | 893 | ||
893 | // This stuff better exist... | 894 | // This stuff better exist... |
894 | cfg1.setGroup( "AddressFields" ); | 895 | cfg1.setGroup( "AddressFields" ); |
895 | o cfg2.setGroup( "XMLFields" ); | 896 | o cfg2.setGroup( "XMLFields" ); |
896 | i = 0; | 897 | i = 0; |
897 | strCfg1 = cfg1.readEntry( "Field" + QString::number(i), QString::null ); | 898 | strCfg1 = cfg1.readEntry( "Field" + QString::number(i), QString::null ); |
898 | strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++), | 899 | strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++), |
899 | QString::null ); | 900 | QString::null ); |
900 | while ( !strCfg1.isNull() && !strCfg2.isNull() ) { | 901 | while ( !strCfg1.isNull() && !strCfg2.isNull() ) { |
901 | mapField.insert( strCfg1, strCfg2 ); | 902 | mapField.insert( strCfg1, strCfg2 ); |
902 | strCfg1 = cfg1.readEntry( "Field" + QString::number(i), | 903 | strCfg1 = cfg1.readEntry( "Field" + QString::number(i), |
903 | QString::null ); | 904 | QString::null ); |
904 | strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++), | 905 | strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++), |
905 | QString::null ); | 906 | QString::null ); |
906 | } | 907 | } |
907 | */ | 908 | */ |
908 | } | 909 | } |
909 | 910 | ||
910 | void ContactEditor::slotChooser1Change( const QString &textChanged ) { | 911 | void ContactEditor::slotChooser1Change( const QString &textChanged ) { |
911 | 912 | ||
912 | int index = cmbChooserField1->currentItem(); | 913 | int index = cmbChooserField1->currentItem(); |
913 | 914 | ||
914 | slChooserValues[index] = textChanged; | 915 | slChooserValues[index] = textChanged; |
915 | 916 | ||
916 | } | 917 | } |
917 | 918 | ||
918 | void ContactEditor::slotChooser2Change( const QString &textChanged ) { | 919 | void ContactEditor::slotChooser2Change( const QString &textChanged ) { |
919 | 920 | ||
920 | int index = cmbChooserField2->currentItem(); | 921 | int index = cmbChooserField2->currentItem(); |
921 | 922 | ||
922 | slChooserValues[index] = textChanged; | 923 | slChooserValues[index] = textChanged; |
923 | 924 | ||
924 | } | 925 | } |
925 | 926 | ||
926 | void ContactEditor::slotChooser3Change( const QString &textChanged ) { | 927 | void ContactEditor::slotChooser3Change( const QString &textChanged ) { |
927 | 928 | ||
928 | int index = cmbChooserField3->currentItem(); | 929 | int index = cmbChooserField3->currentItem(); |
929 | 930 | ||
930 | slChooserValues[index] = textChanged; | 931 | slChooserValues[index] = textChanged; |
931 | 932 | ||
932 | } | 933 | } |
933 | 934 | ||
934 | void ContactEditor::slotChooser4Change( const QString &textChanged ) { | 935 | void ContactEditor::slotChooser4Change( const QString &textChanged ) { |
935 | 936 | ||
936 | int index = cmbChooserField4->currentItem(); | 937 | int index = cmbChooserField4->currentItem(); |
937 | 938 | ||
938 | slChooserValues[index] = textChanged; | 939 | slChooserValues[index] = textChanged; |
939 | 940 | ||
940 | } | 941 | } |
941 | 942 | ||
942 | void ContactEditor::slotAddressChange( const QString &textChanged ) { | 943 | void ContactEditor::slotAddressChange( const QString &textChanged ) { |
943 | 944 | ||
944 | if ( cmbAddress->currentItem() == 0 ) { | 945 | if ( cmbAddress->currentItem() == 0 ) { |
945 | slBusinessAddress[0] = textChanged; | 946 | slBusinessAddress[0] = textChanged; |
946 | } else { | 947 | } else { |
947 | slHomeAddress[0] = textChanged; | 948 | slHomeAddress[0] = textChanged; |
948 | } | 949 | } |
949 | } | 950 | } |
950 | 951 | ||
951 | void ContactEditor::slotAddress2Change( const QString &textChanged ) { | 952 | void ContactEditor::slotAddress2Change( const QString &textChanged ) { |
952 | 953 | ||
953 | if ( cmbAddress->currentItem() == 0 ) { | 954 | if ( cmbAddress->currentItem() == 0 ) { |
954 | slBusinessAddress[1] = textChanged; | 955 | slBusinessAddress[1] = textChanged; |
955 | } else { | 956 | } else { |
956 | slHomeAddress[1] = textChanged; | 957 | slHomeAddress[1] = textChanged; |
957 | } | 958 | } |
958 | } | 959 | } |
959 | 960 | ||
960 | void ContactEditor::slotPOBoxChange( const QString &textChanged ) { | 961 | void ContactEditor::slotPOBoxChange( const QString &textChanged ) { |
961 | 962 | ||
962 | if ( cmbAddress->currentItem() == 0 ) { | 963 | if ( cmbAddress->currentItem() == 0 ) { |
963 | slBusinessAddress[2] = textChanged; | 964 | slBusinessAddress[2] = textChanged; |
964 | } else { | 965 | } else { |
965 | slHomeAddress[2] = textChanged; | 966 | slHomeAddress[2] = textChanged; |
966 | } | 967 | } |
967 | } | 968 | } |
968 | 969 | ||
969 | void ContactEditor::slotCityChange( const QString &textChanged ) { | 970 | void ContactEditor::slotCityChange( const QString &textChanged ) { |
970 | 971 | ||
971 | if ( cmbAddress->currentItem() == 0 ) { | 972 | if ( cmbAddress->currentItem() == 0 ) { |
972 | slBusinessAddress[3] = textChanged; | 973 | slBusinessAddress[3] = textChanged; |
973 | } else { | 974 | } else { |
974 | slHomeAddress[3] = textChanged; | 975 | slHomeAddress[3] = textChanged; |
975 | } | 976 | } |
976 | } | 977 | } |
977 | 978 | ||
978 | void ContactEditor::slotStateChange( const QString &textChanged ) { | 979 | void ContactEditor::slotStateChange( const QString &textChanged ) { |
979 | 980 | ||
980 | 981 | ||
981 | if ( cmbAddress->currentItem() == 0 ) { | 982 | if ( cmbAddress->currentItem() == 0 ) { |
982 | slBusinessAddress[4] = textChanged; | 983 | slBusinessAddress[4] = textChanged; |
983 | } else { | 984 | } else { |
984 | slHomeAddress[4] = textChanged; | 985 | slHomeAddress[4] = textChanged; |
985 | } | 986 | } |
986 | } | 987 | } |
987 | 988 | ||
988 | void ContactEditor::slotZipChange( const QString &textChanged ) { | 989 | void ContactEditor::slotZipChange( const QString &textChanged ) { |
989 | 990 | ||
990 | if ( cmbAddress->currentItem() == 0 ) { | 991 | if ( cmbAddress->currentItem() == 0 ) { |
991 | slBusinessAddress[5] = textChanged; | 992 | slBusinessAddress[5] = textChanged; |
992 | } else { | 993 | } else { |
993 | slHomeAddress[5] = textChanged; | 994 | slHomeAddress[5] = textChanged; |
994 | } | 995 | } |
995 | } | 996 | } |
996 | 997 | ||
997 | void ContactEditor::slotCountryChange( const QString &textChanged ) { | 998 | void ContactEditor::slotCountryChange( const QString &textChanged ) { |
998 | 999 | ||
999 | if ( cmbAddress->currentItem() == 0 ) { | 1000 | if ( cmbAddress->currentItem() == 0 ) { |
1000 | slBusinessAddress[6] = textChanged; | 1001 | slBusinessAddress[6] = textChanged; |
1001 | } else { | 1002 | } else { |
1002 | slHomeAddress[6] = textChanged; | 1003 | slHomeAddress[6] = textChanged; |
1003 | } | 1004 | } |
1004 | } | 1005 | } |
1005 | 1006 | ||
1006 | void ContactEditor::slotCmbChooser1Change( int index ) { | 1007 | void ContactEditor::slotCmbChooser1Change( int index ) { |
1007 | 1008 | ||
1008 | txtChooserField1->setText( slChooserValues[index] ); | 1009 | txtChooserField1->setText( slChooserValues[index] ); |
1009 | txtChooserField1->setFocus(); | 1010 | txtChooserField1->setFocus(); |
1010 | } | 1011 | } |
1011 | 1012 | ||
1012 | void ContactEditor::slotCmbChooser2Change( int index ) { | 1013 | void ContactEditor::slotCmbChooser2Change( int index ) { |
1013 | 1014 | ||
1014 | txtChooserField2->setText( slChooserValues[index] ); | 1015 | txtChooserField2->setText( slChooserValues[index] ); |
1015 | txtChooserField2->setFocus(); | 1016 | txtChooserField2->setFocus(); |
1016 | } | 1017 | } |
1017 | 1018 | ||
1018 | void ContactEditor::slotCmbChooser3Change( int index ) { | 1019 | void ContactEditor::slotCmbChooser3Change( int index ) { |
1019 | 1020 | ||
1020 | txtChooserField3->setText( slChooserValues[index] ); | 1021 | txtChooserField3->setText( slChooserValues[index] ); |
1021 | txtChooserField3->setFocus(); | 1022 | txtChooserField3->setFocus(); |
1022 | 1023 | ||
1023 | } | 1024 | } |
1024 | 1025 | ||
1025 | void ContactEditor::slotCmbChooser4Change( int index ) { | 1026 | void ContactEditor::slotCmbChooser4Change( int index ) { |
1026 | 1027 | ||
1027 | txtChooserField4->setText( slChooserValues[index] ); | 1028 | txtChooserField4->setText( slChooserValues[index] ); |
1028 | txtChooserField4->setFocus(); | 1029 | txtChooserField4->setFocus(); |
1029 | 1030 | ||
1030 | } | 1031 | } |
1031 | 1032 | ||
1032 | void ContactEditor::slotAddressTypeChange( int index ) { | 1033 | void ContactEditor::slotAddressTypeChange( int index ) { |
1033 | 1034 | ||
1034 | if ( index == 0 ) { | 1035 | if ( index == 0 ) { |
1035 | 1036 | ||
1036 | txtAddress->setText( slBusinessAddress[0] ); | 1037 | txtAddress->setText( slBusinessAddress[0] ); |
1037 | //txtAddress2->setText( (*slBusinessAddress)[1] ); | 1038 | //txtAddress2->setText( (*slBusinessAddress)[1] ); |
1038 | //txtPOBox->setText( (*slBusinessAddress)[2] ); | 1039 | //txtPOBox->setText( (*slBusinessAddress)[2] ); |
1039 | txtCity->setText( slBusinessAddress[3] ); | 1040 | txtCity->setText( slBusinessAddress[3] ); |
1040 | txtState->setText( slBusinessAddress[4] ); | 1041 | txtState->setText( slBusinessAddress[4] ); |
1041 | txtZip->setText( slBusinessAddress[5] ); | 1042 | txtZip->setText( slBusinessAddress[5] ); |
1042 | QLineEdit *txtTmp = cmbCountry->lineEdit(); | 1043 | QLineEdit *txtTmp = cmbCountry->lineEdit(); |
1043 | txtTmp->setText( slBusinessAddress[6] ); | 1044 | txtTmp->setText( slBusinessAddress[6] ); |
1044 | 1045 | ||
1045 | } else { | 1046 | } else { |
1046 | 1047 | ||
1047 | txtAddress->setText( slHomeAddress[0] ); | 1048 | txtAddress->setText( slHomeAddress[0] ); |
1048 | //txtAddress2->setText( (*slHomeAddress)[1] ); | 1049 | //txtAddress2->setText( (*slHomeAddress)[1] ); |
1049 | //txtPOBox->setText( (*slHomeAddress)[2] ); | 1050 | //txtPOBox->setText( (*slHomeAddress)[2] ); |
1050 | txtCity->setText( slHomeAddress[3] ); | 1051 | txtCity->setText( slHomeAddress[3] ); |
1051 | txtState->setText( slHomeAddress[4] ); | 1052 | txtState->setText( slHomeAddress[4] ); |
1052 | txtZip->setText( slHomeAddress[5] ); | 1053 | txtZip->setText( slHomeAddress[5] ); |
1053 | QLineEdit *txtTmp = cmbCountry->lineEdit(); | 1054 | QLineEdit *txtTmp = cmbCountry->lineEdit(); |
1054 | txtTmp->setText( slHomeAddress[6] ); | 1055 | txtTmp->setText( slHomeAddress[6] ); |
1055 | 1056 | ||
1056 | } | 1057 | } |
1057 | 1058 | ||
1058 | } | 1059 | } |
1059 | 1060 | ||
1060 | void ContactEditor::slotFullNameChange( const QString &textChanged ) { | 1061 | void ContactEditor::slotFullNameChange( const QString &textChanged ) { |
1061 | 1062 | ||
1062 | int index = cmbFileAs->currentItem(); | 1063 | int index = cmbFileAs->currentItem(); |
1063 | 1064 | ||
1064 | cmbFileAs->clear(); | 1065 | cmbFileAs->clear(); |
1065 | 1066 | ||
1066 | cmbFileAs->insertItem( parseName( textChanged, 0 ) ); | 1067 | cmbFileAs->insertItem( parseName( textChanged, 0 ) ); |
1067 | cmbFileAs->insertItem( parseName( textChanged, 1 ) ); | 1068 | cmbFileAs->insertItem( parseName( textChanged, 1 ) ); |
1068 | cmbFileAs->insertItem( parseName( textChanged, 2 ) ); | 1069 | cmbFileAs->insertItem( parseName( textChanged, 2 ) ); |
1069 | cmbFileAs->insertItem( parseName( textChanged, 3 ) ); | 1070 | cmbFileAs->insertItem( parseName( textChanged, 3 ) ); |
1070 | 1071 | ||
1071 | cmbFileAs->setCurrentItem( index ); | 1072 | cmbFileAs->setCurrentItem( index ); |
1072 | 1073 | ||
1073 | useFullName = TRUE; | 1074 | useFullName = TRUE; |
1074 | 1075 | ||
1075 | } | 1076 | } |
1076 | 1077 | ||
1077 | // Loads the detail fields | 1078 | // Loads the detail fields |
1078 | void ContactEditor::loadFields() { | 1079 | void ContactEditor::loadFields() { |
1079 | 1080 | ||
1080 | QStringList::ConstIterator it; | 1081 | QStringList::ConstIterator it; |
1081 | QListIterator<QLabel> lit( listName ); | 1082 | QListIterator<QLabel> lit( listName ); |
1082 | for ( it = slDynamicEntries.begin(); *lit; ++lit, ++it) { | 1083 | for ( it = slDynamicEntries.begin(); *lit; ++lit, ++it) { |
1083 | 1084 | ||
1084 | if ( *it == "Department" ) | 1085 | if ( *it == "Department" ) |
1085 | (*lit)->setText( tr( "Department" ) ); | 1086 | (*lit)->setText( tr( "Department" ) ); |
1086 | 1087 | ||
1087 | if ( *it == "Company" ) | 1088 | if ( *it == "Company" ) |
1088 | (*lit)->setText( tr( "Company" ) ); | 1089 | (*lit)->setText( tr( "Company" ) ); |
1089 | 1090 | ||
1090 | if ( *it == "Office" ) | 1091 | if ( *it == "Office" ) |
1091 | (*lit)->setText( tr( "Office" ) ); | 1092 | (*lit)->setText( tr( "Office" ) ); |
1092 | 1093 | ||
1093 | if ( *it == "Profession" ) | 1094 | if ( *it == "Profession" ) |
1094 | (*lit)->setText( tr( "Profession" ) ); | 1095 | (*lit)->setText( tr( "Profession" ) ); |
1095 | 1096 | ||
1096 | if ( *it == "Assistant" ) | 1097 | if ( *it == "Assistant" ) |
1097 | (*lit)->setText( tr( "Assistant" ) ); | 1098 | (*lit)->setText( tr( "Assistant" ) ); |
1098 | 1099 | ||
1099 | if ( *it == "Manager" ) | 1100 | if ( *it == "Manager" ) |
1100 | (*lit)->setText( tr( "Manager" ) ); | 1101 | (*lit)->setText( tr( "Manager" ) ); |
1101 | 1102 | ||
1102 | if ( *it == "Spouse" ) | 1103 | if ( *it == "Spouse" ) |
1103 | (*lit)->setText( tr( "Spouse" ) ); | 1104 | (*lit)->setText( tr( "Spouse" ) ); |
1104 | 1105 | ||
1105 | if ( *it == "Nickname" ) | 1106 | if ( *it == "Nickname" ) |
1106 | (*lit)->setText( tr( "Nickname" ) ); | 1107 | (*lit)->setText( tr( "Nickname" ) ); |
1107 | 1108 | ||
1108 | if ( *it == "Children" ) | 1109 | if ( *it == "Children" ) |
1109 | (*lit)->setText( tr( "Children" ) ); | 1110 | (*lit)->setText( tr( "Children" ) ); |
1110 | } | 1111 | } |
1111 | // Set DatePicker | ||
1112 | qWarning ("**Info: %s", ent.birthday().latin1() ); | ||
1113 | if ( !ent.birthday().isEmpty() ){ | ||
1114 | birthdayButton->setText( ent.birthday() ); | ||
1115 | birthdayPicker->setDate( TimeConversion::fromString ( ent.birthday() ) ); | ||
1116 | } else | ||
1117 | birthdayButton->setText( tr ("Unknown") ); | ||
1118 | |||
1119 | qWarning ("**Info: %s", ent.anniversary().latin1() ); | ||
1120 | if ( !ent.anniversary().isEmpty() ){ | ||
1121 | anniversaryButton->setText( ent.anniversary() ); | ||
1122 | anniversaryPicker->setDate( TimeConversion::fromString ( ent.birthday() ) ); | ||
1123 | } else | ||
1124 | anniversaryButton->setText( tr ("Unknown") ); | ||
1125 | 1112 | ||
1126 | } | 1113 | } |
1127 | 1114 | ||
1128 | void ContactEditor::accept() { | 1115 | void ContactEditor::accept() { |
1129 | 1116 | ||
1130 | if ( isEmpty() ) { | 1117 | if ( isEmpty() ) { |
1131 | cleanupFields(); | 1118 | cleanupFields(); |
1132 | reject(); | 1119 | reject(); |
1133 | } else { | 1120 | } else { |
1134 | saveEntry(); | 1121 | saveEntry(); |
1135 | cleanupFields(); | 1122 | cleanupFields(); |
1136 | QDialog::accept(); | 1123 | QDialog::accept(); |
1137 | } | 1124 | } |
1138 | 1125 | ||
1139 | } | 1126 | } |
1140 | 1127 | ||
1141 | void ContactEditor::slotNote() { | 1128 | void ContactEditor::slotNote() { |
1142 | 1129 | ||
1143 | dlgNote->showMaximized(); | 1130 | dlgNote->showMaximized(); |
1144 | if ( !dlgNote->exec() ) { | 1131 | if ( !dlgNote->exec() ) { |
1145 | txtNote->setText( ent.notes() ); | 1132 | txtNote->setText( ent.notes() ); |
1146 | } | 1133 | } |
1147 | } | 1134 | } |
1148 | 1135 | ||
1149 | void ContactEditor::slotName() { | 1136 | void ContactEditor::slotName() { |
1150 | 1137 | ||
1151 | QString tmpName; | 1138 | QString tmpName; |
1152 | if (useFullName == TRUE) { | 1139 | if (useFullName == TRUE) { |
1153 | txtFirstName->setText( parseName(txtFullName->text(), NAME_F) ); | 1140 | txtFirstName->setText( parseName(txtFullName->text(), NAME_F) ); |
1154 | txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) ); | 1141 | txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) ); |
1155 | txtLastName->setText( parseName(txtFullName->text(), NAME_L) ); | 1142 | txtLastName->setText( parseName(txtFullName->text(), NAME_L) ); |
1156 | txtSuffix->setText( parseName(txtFullName->text(), NAME_S) ); | 1143 | txtSuffix->setText( parseName(txtFullName->text(), NAME_S) ); |
1157 | } | 1144 | } |
1158 | dlgName->showMaximized(); | 1145 | dlgName->showMaximized(); |
1159 | if ( dlgName->exec() ) { | 1146 | if ( dlgName->exec() ) { |
1160 | 1147 | ||
1161 | tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text() + " " + txtSuffix->text(); | 1148 | tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text() + " " + txtSuffix->text(); |
1162 | txtFullName->setText( tmpName.simplifyWhiteSpace() ); | 1149 | txtFullName->setText( tmpName.simplifyWhiteSpace() ); |
1163 | slotFullNameChange( txtFullName->text() ); | 1150 | slotFullNameChange( txtFullName->text() ); |
1164 | useFullName = FALSE; | 1151 | useFullName = FALSE; |
1165 | } | 1152 | } |
1166 | 1153 | ||
1167 | } | 1154 | } |
1168 | 1155 | ||
1169 | void ContactEditor::setNameFocus() { | 1156 | void ContactEditor::setNameFocus() { |
1170 | 1157 | ||
1171 | txtFullName->setFocus(); | 1158 | txtFullName->setFocus(); |
1172 | 1159 | ||
1173 | } | 1160 | } |
1174 | 1161 | ||
1175 | bool ContactEditor::isEmpty() { | 1162 | bool ContactEditor::isEmpty() { |
1176 | // Test and see if the record should be saved. | 1163 | // Test and see if the record should be saved. |
1177 | // More strict than the original qtopia, needs name or fileas to save | 1164 | // More strict than the original qtopia, needs name or fileas to save |
1178 | 1165 | ||
1179 | QString t = txtFullName->text(); | 1166 | QString t = txtFullName->text(); |
1180 | if ( !t.isEmpty() && containsAlphaNum( t ) ) | 1167 | if ( !t.isEmpty() && containsAlphaNum( t ) ) |
1181 | return false; | 1168 | return false; |
1182 | 1169 | ||
1183 | t = cmbFileAs->currentText(); | 1170 | t = cmbFileAs->currentText(); |
1184 | if ( !t.isEmpty() && containsAlphaNum( t ) ) | 1171 | if ( !t.isEmpty() && containsAlphaNum( t ) ) |
1185 | return false; | 1172 | return false; |
1186 | 1173 | ||
1187 | return true; | 1174 | return true; |
1188 | 1175 | ||
1189 | } | 1176 | } |
1190 | 1177 | ||
1191 | QString ContactEditor::parseName( const QString fullName, int type ) { | 1178 | QString ContactEditor::parseName( const QString fullName, int type ) { |
1192 | 1179 | ||
1193 | QString simplifiedName( fullName.simplifyWhiteSpace() ); | 1180 | QString simplifiedName( fullName.simplifyWhiteSpace() ); |
1194 | QString strFirstName; | 1181 | QString strFirstName; |
1195 | QString strMiddleName; | 1182 | QString strMiddleName; |
1196 | QString strLastName; | 1183 | QString strLastName; |
1197 | QString strSuffix; | 1184 | QString strSuffix; |
1198 | QString strTitle; | 1185 | QString strTitle; |
1199 | int commapos; | 1186 | int commapos; |
1200 | int spCount; | 1187 | int spCount; |
1201 | int spPos; | 1188 | int spPos; |
1202 | int spPos2; | 1189 | int spPos2; |
1203 | 1190 | ||
1204 | 1191 | ||
1205 | commapos = simplifiedName.find( ',', 0, TRUE); | 1192 | commapos = simplifiedName.find( ',', 0, TRUE); |
1206 | spCount = simplifiedName.contains( ' ', TRUE ); | 1193 | spCount = simplifiedName.contains( ' ', TRUE ); |
1207 | 1194 | ||
1208 | if ( commapos == -1 ) { | 1195 | if ( commapos == -1 ) { |
1209 | 1196 | ||
1210 | switch (spCount) { | 1197 | switch (spCount) { |
1211 | case 0: | 1198 | case 0: |
1212 | //return simplifiedName; | 1199 | //return simplifiedName; |
1213 | if (txtLastName->text() != "") { | 1200 | if (txtLastName->text() != "") { |
1214 | strLastName = simplifiedName; | 1201 | strLastName = simplifiedName; |
1215 | break; | 1202 | break; |
1216 | } | 1203 | } |
1217 | if (txtMiddleName->text() != "") { | 1204 | if (txtMiddleName->text() != "") { |
1218 | strMiddleName = simplifiedName; | 1205 | strMiddleName = simplifiedName; |
1219 | break; | 1206 | break; |
1220 | } | 1207 | } |
1221 | if (txtSuffix->text() != "") { | 1208 | if (txtSuffix->text() != "") { |
1222 | strSuffix = simplifiedName; | 1209 | strSuffix = simplifiedName; |
1223 | break; | 1210 | break; |
1224 | } | 1211 | } |
1225 | strFirstName = simplifiedName; | 1212 | strFirstName = simplifiedName; |
1226 | break; | 1213 | break; |
1227 | 1214 | ||
1228 | case 1: | 1215 | case 1: |
1229 | spPos = simplifiedName.find( ' ', 0, TRUE ); | 1216 | spPos = simplifiedName.find( ' ', 0, TRUE ); |
1230 | strFirstName = simplifiedName.left( spPos ); | 1217 | strFirstName = simplifiedName.left( spPos ); |
1231 | strLastName = simplifiedName.mid( spPos + 1 ); | 1218 | strLastName = simplifiedName.mid( spPos + 1 ); |
1232 | break; | 1219 | break; |
1233 | 1220 | ||
1234 | case 2: | 1221 | case 2: |
1235 | spPos = simplifiedName.find( ' ', 0, TRUE ); | 1222 | spPos = simplifiedName.find( ' ', 0, TRUE ); |
1236 | strFirstName = simplifiedName.left( spPos ); | 1223 | strFirstName = simplifiedName.left( spPos ); |
1237 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 1224 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
1238 | strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 1225 | strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
1239 | strLastName = simplifiedName.mid( spPos2 + 1 ); | 1226 | strLastName = simplifiedName.mid( spPos2 + 1 ); |
1240 | break; | 1227 | break; |
1241 | 1228 | ||
1242 | case 3: | 1229 | case 3: |
1243 | spPos = simplifiedName.find( ' ', 0, TRUE ); | 1230 | spPos = simplifiedName.find( ' ', 0, TRUE ); |
1244 | strFirstName = simplifiedName.left( spPos ); | 1231 | strFirstName = simplifiedName.left( spPos ); |
1245 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 1232 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
1246 | strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 1233 | strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
1247 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); | 1234 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); |
1248 | strLastName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); | 1235 | strLastName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); |
1249 | strSuffix = simplifiedName.mid( spPos + 1 ); | 1236 | strSuffix = simplifiedName.mid( spPos + 1 ); |
1250 | break; | 1237 | break; |
1251 | 1238 | ||
1252 | case 4: | 1239 | case 4: |
1253 | spPos = simplifiedName.find( ' ', 0, TRUE ); | 1240 | spPos = simplifiedName.find( ' ', 0, TRUE ); |
1254 | strTitle = simplifiedName.left( spPos ); | 1241 | strTitle = simplifiedName.left( spPos ); |
1255 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 1242 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
1256 | strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 1243 | strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
1257 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); | 1244 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); |
1258 | strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); | 1245 | strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); |
1259 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 1246 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
1260 | strLastName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 1247 | strLastName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
1261 | strSuffix = simplifiedName.mid( spPos2 + 1 ); | 1248 | strSuffix = simplifiedName.mid( spPos2 + 1 ); |
1262 | break; | 1249 | break; |
1263 | 1250 | ||
1264 | default: | 1251 | default: |
1265 | spPos = simplifiedName.find( ' ', 0, TRUE ); | 1252 | spPos = simplifiedName.find( ' ', 0, TRUE ); |
1266 | strTitle = simplifiedName.left( spPos ); | 1253 | strTitle = simplifiedName.left( spPos ); |
1267 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 1254 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
1268 | strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 1255 | strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
1269 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); | 1256 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); |
1270 | strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); | 1257 | strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); |
1271 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 1258 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
1272 | strLastName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 1259 | strLastName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
1273 | strSuffix = simplifiedName.mid( spPos2 + 1 ); | 1260 | strSuffix = simplifiedName.mid( spPos2 + 1 ); |
1274 | break; | 1261 | break; |
1275 | } | 1262 | } |
1276 | } else { | 1263 | } else { |
1277 | simplifiedName.replace( commapos, 1, " " ); | 1264 | simplifiedName.replace( commapos, 1, " " ); |
1278 | simplifiedName = simplifiedName.simplifyWhiteSpace(); | 1265 | simplifiedName = simplifiedName.simplifyWhiteSpace(); |
1279 | 1266 | ||
1280 | switch (spCount) { | 1267 | switch (spCount) { |
1281 | case 0: | 1268 | case 0: |
1282 | //return simplifiedName; | 1269 | //return simplifiedName; |
1283 | if (txtLastName->text() != "") { | 1270 | if (txtLastName->text() != "") { |
1284 | strLastName = simplifiedName; | 1271 | strLastName = simplifiedName; |
1285 | break; | 1272 | break; |
1286 | } | 1273 | } |
1287 | if (txtMiddleName->text() != "") { | 1274 | if (txtMiddleName->text() != "") { |
1288 | strMiddleName = simplifiedName; | 1275 | strMiddleName = simplifiedName; |
1289 | break; | 1276 | break; |
1290 | } | 1277 | } |
1291 | if (txtSuffix->text() != "") { | 1278 | if (txtSuffix->text() != "") { |
1292 | strSuffix = simplifiedName; | 1279 | strSuffix = simplifiedName; |
1293 | break; | 1280 | break; |
1294 | } | 1281 | } |
1295 | strFirstName = simplifiedName; | 1282 | strFirstName = simplifiedName; |
1296 | break; | 1283 | break; |
1297 | 1284 | ||
1298 | case 1: | 1285 | case 1: |
1299 | spPos = simplifiedName.find( ' ', 0, TRUE ); | 1286 | spPos = simplifiedName.find( ' ', 0, TRUE ); |
1300 | strLastName = simplifiedName.left( spPos ); | 1287 | strLastName = simplifiedName.left( spPos ); |
1301 | strFirstName = simplifiedName.mid( spPos + 1 ); | 1288 | strFirstName = simplifiedName.mid( spPos + 1 ); |
1302 | break; | 1289 | break; |
1303 | 1290 | ||
1304 | case 2: | 1291 | case 2: |
1305 | spPos = simplifiedName.find( ' ', 0, TRUE ); | 1292 | spPos = simplifiedName.find( ' ', 0, TRUE ); |
1306 | strLastName = simplifiedName.left( spPos ); | 1293 | strLastName = simplifiedName.left( spPos ); |
1307 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 1294 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
1308 | strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 1295 | strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
1309 | strMiddleName = simplifiedName.mid( spPos2 + 1 ); | 1296 | strMiddleName = simplifiedName.mid( spPos2 + 1 ); |
1310 | break; | 1297 | break; |
1311 | 1298 | ||
1312 | case 3: | 1299 | case 3: |
1313 | spPos = simplifiedName.find( ' ', 0, TRUE ); | 1300 | spPos = simplifiedName.find( ' ', 0, TRUE ); |
1314 | strLastName = simplifiedName.left( spPos ); | 1301 | strLastName = simplifiedName.left( spPos ); |
1315 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 1302 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
1316 | strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 1303 | strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
1317 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); | 1304 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); |
1318 | strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); | 1305 | strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); |
1319 | strSuffix = simplifiedName.mid( spPos + 1 ); | 1306 | strSuffix = simplifiedName.mid( spPos + 1 ); |
1320 | break; | 1307 | break; |
1321 | 1308 | ||
1322 | case 4: | 1309 | case 4: |
1323 | spPos = simplifiedName.find( ' ', 0, TRUE ); | 1310 | spPos = simplifiedName.find( ' ', 0, TRUE ); |
1324 | strLastName = simplifiedName.left( spPos ); | 1311 | strLastName = simplifiedName.left( spPos ); |
1325 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 1312 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
1326 | strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 1313 | strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
1327 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); | 1314 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); |
1328 | strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); | 1315 | strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); |
1329 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 1316 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
1330 | strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 1317 | strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
1331 | strSuffix = simplifiedName.mid( spPos2 + 1 ); | 1318 | strSuffix = simplifiedName.mid( spPos2 + 1 ); |
1332 | break; | 1319 | break; |
1333 | 1320 | ||
1334 | default: | 1321 | default: |
1335 | spPos = simplifiedName.find( ' ', 0, TRUE ); | 1322 | spPos = simplifiedName.find( ' ', 0, TRUE ); |
1336 | strLastName = simplifiedName.left( spPos ); | 1323 | strLastName = simplifiedName.left( spPos ); |
1337 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 1324 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
1338 | strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 1325 | strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
1339 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); | 1326 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); |
1340 | strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos ); | 1327 | strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos ); |
1341 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 1328 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
1342 | strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 1329 | strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
1343 | strSuffix = simplifiedName.mid( spPos2 + 1 ); | 1330 | strSuffix = simplifiedName.mid( spPos2 + 1 ); |
1344 | break; | 1331 | break; |
1345 | } | 1332 | } |
1346 | } | 1333 | } |
1347 | switch (type) { | 1334 | switch (type) { |
1348 | case NAME_FL: | 1335 | case NAME_FL: |
1349 | return strFirstName + " " + strLastName; | 1336 | return strFirstName + " " + strLastName; |
1350 | 1337 | ||
1351 | case NAME_LF: | 1338 | case NAME_LF: |
1352 | return strLastName + ", " + strFirstName; | 1339 | return strLastName + ", " + strFirstName; |
1353 | 1340 | ||
1354 | case NAME_LFM: | 1341 | case NAME_LFM: |
1355 | return strLastName + ", " + strFirstName + " " + strMiddleName; | 1342 | return strLastName + ", " + strFirstName + " " + strMiddleName; |
1356 | 1343 | ||
1357 | case NAME_FMLS: | 1344 | case NAME_FMLS: |
1358 | return strFirstName + " " + strMiddleName + " " + strLastName + " " + strSuffix; | 1345 | return strFirstName + " " + strMiddleName + " " + strLastName + " " + strSuffix; |
1359 | 1346 | ||
1360 | case NAME_F: | 1347 | case NAME_F: |
1361 | return strFirstName; | 1348 | return strFirstName; |
1362 | 1349 | ||
1363 | case NAME_M: | 1350 | case NAME_M: |
1364 | return strMiddleName; | 1351 | return strMiddleName; |
1365 | 1352 | ||
1366 | case NAME_L: | 1353 | case NAME_L: |
1367 | return strLastName; | 1354 | return strLastName; |
1368 | 1355 | ||
1369 | case NAME_S: | 1356 | case NAME_S: |
1370 | return strSuffix; | 1357 | return strSuffix; |
1371 | 1358 | ||
1372 | } | 1359 | } |
1373 | return QString::null; | 1360 | return QString::null; |
1374 | } | 1361 | } |
1375 | 1362 | ||
1376 | void ContactEditor::cleanupFields() { | 1363 | void ContactEditor::cleanupFields() { |
1377 | 1364 | ||
1378 | QStringList::Iterator it = slChooserValues.begin(); | 1365 | QStringList::Iterator it = slChooserValues.begin(); |
1379 | for ( int i = 0; it != slChooserValues.end(); i++, ++it ) { | 1366 | for ( int i = 0; it != slChooserValues.end(); i++, ++it ) { |
1380 | (*it) = ""; | 1367 | (*it) = ""; |
1381 | } | 1368 | } |
1382 | 1369 | ||
1383 | for ( int i = 0; i < 7; i++ ) { | 1370 | for ( int i = 0; i < 7; i++ ) { |
1384 | slHomeAddress[i] = ""; | 1371 | slHomeAddress[i] = ""; |
1385 | slBusinessAddress[i] = ""; | 1372 | slBusinessAddress[i] = ""; |
1386 | } | 1373 | } |
1387 | 1374 | ||
1388 | QStringList::ConstIterator cit; | 1375 | QStringList::ConstIterator cit; |
1389 | QListIterator<QLineEdit> itLE( listValue ); | 1376 | QListIterator<QLineEdit> itLE( listValue ); |
1390 | for ( cit = slDynamicEntries.begin(); cit != slDynamicEntries.end(); ++cit, ++itLE) { | 1377 | for ( cit = slDynamicEntries.begin(); cit != slDynamicEntries.end(); ++cit, ++itLE) { |
1391 | (*itLE)->setText( "" ); | 1378 | (*itLE)->setText( "" ); |
1392 | } | 1379 | } |
1393 | 1380 | ||
1394 | txtFirstName->setText(""); | 1381 | txtFirstName->setText(""); |
1395 | txtMiddleName->setText(""); | 1382 | txtMiddleName->setText(""); |
1396 | txtLastName->setText(""); | 1383 | txtLastName->setText(""); |
1397 | txtSuffix->setText(""); | 1384 | txtSuffix->setText(""); |
1398 | txtNote->setText(""); | 1385 | txtNote->setText(""); |
1399 | txtFullName->setText(""); | 1386 | txtFullName->setText(""); |
1400 | txtJobTitle->setText(""); | 1387 | txtJobTitle->setText(""); |
1401 | txtOrganization->setText(""); | 1388 | txtOrganization->setText(""); |
1402 | txtChooserField1->setText(""); | 1389 | txtChooserField1->setText(""); |
1403 | txtChooserField2->setText(""); | 1390 | txtChooserField2->setText(""); |
1404 | txtChooserField3->setText(""); | 1391 | txtChooserField3->setText(""); |
1405 | txtAddress->setText(""); | 1392 | txtAddress->setText(""); |
1406 | //txtAddress2->setText(""); | 1393 | //txtAddress2->setText(""); |
1407 | txtCity->setText(""); | 1394 | txtCity->setText(""); |
1408 | //txtPOBox->setText(""); | 1395 | //txtPOBox->setText(""); |
1409 | txtState->setText(""); | 1396 | txtState->setText(""); |
1410 | txtZip->setText(""); | 1397 | txtZip->setText(""); |
1411 | QLineEdit *txtTmp = cmbCountry->lineEdit(); | 1398 | QLineEdit *txtTmp = cmbCountry->lineEdit(); |
1412 | txtTmp->setText(""); | 1399 | txtTmp->setText(""); |
1413 | txtTmp = cmbFileAs->lineEdit(); | 1400 | txtTmp = cmbFileAs->lineEdit(); |
1414 | txtTmp->setText(""); | 1401 | txtTmp->setText(""); |
1415 | 1402 | ||
1416 | } | 1403 | } |
1417 | 1404 | ||
1418 | void ContactEditor::setEntry( const OContact &entry ) { | 1405 | void ContactEditor::setEntry( const OContact &entry ) { |
1419 | 1406 | ||
1420 | cleanupFields(); | 1407 | cleanupFields(); |
1421 | 1408 | ||
1422 | 1409 | ||
1423 | ent = entry; | 1410 | ent = entry; |
1424 | 1411 | ||
1425 | useFullName = FALSE; | 1412 | useFullName = FALSE; |
1426 | txtFirstName->setText( ent.firstName() ); | 1413 | txtFirstName->setText( ent.firstName() ); |
1427 | txtMiddleName->setText( ent.middleName() ); | 1414 | txtMiddleName->setText( ent.middleName() ); |
1428 | txtLastName->setText( ent.lastName() ); | 1415 | txtLastName->setText( ent.lastName() ); |
1429 | txtSuffix->setText( ent.suffix() ); | 1416 | txtSuffix->setText( ent.suffix() ); |
1430 | 1417 | ||
1431 | QString *tmpString = new QString; | 1418 | QString *tmpString = new QString; |
1432 | *tmpString = ent.firstName() + " " + ent.middleName() + | 1419 | *tmpString = ent.firstName() + " " + ent.middleName() + |
1433 | + " " + ent.lastName() + " " + ent.suffix(); | 1420 | + " " + ent.lastName() + " " + ent.suffix(); |
1434 | 1421 | ||
1435 | txtFullName->setText( tmpString->simplifyWhiteSpace() ); | 1422 | txtFullName->setText( tmpString->simplifyWhiteSpace() ); |
1436 | 1423 | ||
1437 | cmbFileAs->setEditText( ent.fileAs() ); | 1424 | cmbFileAs->setEditText( ent.fileAs() ); |
1438 | 1425 | ||
1439 | if (hasTitle) | 1426 | if (hasTitle) |
1440 | txtJobTitle->setText( ent.jobTitle() ); | 1427 | txtJobTitle->setText( ent.jobTitle() ); |
1441 | 1428 | ||
1442 | if (hasCompany) | 1429 | if (hasCompany) |
1443 | txtOrganization->setText( ent.company() ); | 1430 | txtOrganization->setText( ent.company() ); |
1444 | 1431 | ||
1445 | if (hasNotes) | 1432 | if (hasNotes) |
1446 | txtNote->setText( ent.notes() ); | 1433 | txtNote->setText( ent.notes() ); |
1447 | 1434 | ||
1448 | if (hasStreet) { | 1435 | if (hasStreet) { |
1449 | slHomeAddress[0] = ent.homeStreet(); | 1436 | slHomeAddress[0] = ent.homeStreet(); |
1450 | slBusinessAddress[0] = ent.businessStreet(); | 1437 | slBusinessAddress[0] = ent.businessStreet(); |
1451 | } | 1438 | } |
1452 | /* | 1439 | /* |
1453 | if (hasStreet2) { | 1440 | if (hasStreet2) { |
1454 | (*slHomeAddress)[1] = ent.homeStreet2(); | 1441 | (*slHomeAddress)[1] = ent.homeStreet2(); |
1455 | (*slBusinessAddress)[1] = ent.businessStreet2(); | 1442 | (*slBusinessAddress)[1] = ent.businessStreet2(); |
1456 | } | 1443 | } |
1457 | 1444 | ||
1458 | if (hasPOBox) { | 1445 | if (hasPOBox) { |
1459 | (*slHomeAddress)[2] = ent.homePOBox(); | 1446 | (*slHomeAddress)[2] = ent.homePOBox(); |
1460 | (*slBusinessAddress)[2] = ent.businessPOBox(); | 1447 | (*slBusinessAddress)[2] = ent.businessPOBox(); |
1461 | } | 1448 | } |
1462 | */ | 1449 | */ |
1463 | if (hasCity) { | 1450 | if (hasCity) { |
1464 | slHomeAddress[3] = ent.homeCity(); | 1451 | slHomeAddress[3] = ent.homeCity(); |
1465 | slBusinessAddress[3] = ent.businessCity(); | 1452 | slBusinessAddress[3] = ent.businessCity(); |
1466 | } | 1453 | } |
1467 | 1454 | ||
1468 | if (hasState) { | 1455 | if (hasState) { |
1469 | slHomeAddress[4] = ent.homeState(); | 1456 | slHomeAddress[4] = ent.homeState(); |
1470 | slBusinessAddress[4] = ent.businessState(); | 1457 | slBusinessAddress[4] = ent.businessState(); |
1471 | } | 1458 | } |
1472 | 1459 | ||
1473 | if (hasZip) { | 1460 | if (hasZip) { |
1474 | slHomeAddress[5] = ent.homeZip(); | 1461 | slHomeAddress[5] = ent.homeZip(); |
1475 | slBusinessAddress[5] = ent.businessZip(); | 1462 | slBusinessAddress[5] = ent.businessZip(); |
1476 | } | 1463 | } |
1477 | 1464 | ||
1478 | if (hasCountry) { | 1465 | if (hasCountry) { |
1479 | slHomeAddress[6] = ent.homeCountry(); | 1466 | slHomeAddress[6] = ent.homeCountry(); |
1480 | slBusinessAddress[6] = ent.businessCountry(); | 1467 | slBusinessAddress[6] = ent.businessCountry(); |
1481 | } | 1468 | } |
1482 | 1469 | ||
1483 | QStringList::ConstIterator it; | 1470 | QStringList::ConstIterator it; |
1484 | QListIterator<QLineEdit> itLE( listValue ); | 1471 | QListIterator<QLineEdit> itLE( listValue ); |
1485 | for ( it = slDynamicEntries.begin(); it != slDynamicEntries.end(); ++it, ++itLE) { | 1472 | for ( it = slDynamicEntries.begin(); it != slDynamicEntries.end(); ++it, ++itLE) { |
1486 | if ( *it == "Department" ) | 1473 | if ( *it == "Department" ) |
1487 | (*itLE)->setText( ent.department() ); | 1474 | (*itLE)->setText( ent.department() ); |
1488 | 1475 | ||
1489 | if ( *it == "Company" ) | 1476 | if ( *it == "Company" ) |
1490 | (*itLE)->setText( ent.company() ); | 1477 | (*itLE)->setText( ent.company() ); |
1491 | 1478 | ||
1492 | if ( *it == "Office" ) | 1479 | if ( *it == "Office" ) |
1493 | (*itLE)->setText( ent.office() ); | 1480 | (*itLE)->setText( ent.office() ); |
1494 | 1481 | ||
1495 | if ( *it == "Profession" ) | 1482 | if ( *it == "Profession" ) |
1496 | (*itLE)->setText( ent.profession() ); | 1483 | (*itLE)->setText( ent.profession() ); |
1497 | 1484 | ||
1498 | if ( *it == "Assistant" ) | 1485 | if ( *it == "Assistant" ) |
1499 | (*itLE)->setText( ent.assistant() ); | 1486 | (*itLE)->setText( ent.assistant() ); |
1500 | 1487 | ||
1501 | if ( *it == "Manager" ) | 1488 | if ( *it == "Manager" ) |
1502 | (*itLE)->setText( ent.manager() ); | 1489 | (*itLE)->setText( ent.manager() ); |
1503 | 1490 | ||
1504 | if ( *it == "Spouse" ) | 1491 | if ( *it == "Spouse" ) |
1505 | (*itLE)->setText( ent.spouse() ); | 1492 | (*itLE)->setText( ent.spouse() ); |
1506 | 1493 | ||
1507 | if ( *it == "Nickname" ) | 1494 | if ( *it == "Nickname" ) |
1508 | (*itLE)->setText( ent.nickname() ); | 1495 | (*itLE)->setText( ent.nickname() ); |
1509 | 1496 | ||
1510 | if ( *it == "Children" ) | 1497 | if ( *it == "Children" ) |
1511 | (*itLE)->setText( ent.children() ); | 1498 | (*itLE)->setText( ent.children() ); |
1512 | 1499 | ||
1513 | } | 1500 | } |
1514 | 1501 | ||
1515 | QStringList::Iterator itV; | 1502 | QStringList::Iterator itV; |
1516 | for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) { | 1503 | for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) { |
1517 | 1504 | ||
1518 | if ( ( *it == "Business Phone") || ( *it == "Work Phone" ) ) | 1505 | if ( ( *it == "Business Phone") || ( *it == "Work Phone" ) ) |
1519 | *itV = ent.businessPhone(); | 1506 | *itV = ent.businessPhone(); |
1520 | /* | 1507 | /* |
1521 | if ( *it == "Business 2 Phone" ) | 1508 | if ( *it == "Business 2 Phone" ) |
1522 | *itV = ent.business2Phone(); | 1509 | *itV = ent.business2Phone(); |
1523 | */ | 1510 | */ |
1524 | if ( ( *it == "Business Fax") || ( *it == "Work Fax" ) ) | 1511 | if ( ( *it == "Business Fax") || ( *it == "Work Fax" ) ) |
1525 | *itV = ent.businessFax(); | 1512 | *itV = ent.businessFax(); |
1526 | 1513 | ||
1527 | if ( ( *it == "Business Mobile" ) || ( *it == "work Mobile" ) ) | 1514 | if ( ( *it == "Business Mobile" ) || ( *it == "work Mobile" ) ) |
1528 | *itV = ent.businessMobile(); | 1515 | *itV = ent.businessMobile(); |
1529 | /* | 1516 | /* |
1530 | if ( *it == "Company Phone" ) | 1517 | if ( *it == "Company Phone" ) |
1531 | *itV = ent.companyPhone(); | 1518 | *itV = ent.companyPhone(); |
1532 | */ | 1519 | */ |
1533 | if ( *it == "Default Email" ) | 1520 | if ( *it == "Default Email" ) |
1534 | *itV = ent.defaultEmail(); | 1521 | *itV = ent.defaultEmail(); |
1535 | 1522 | ||
1536 | if ( *it == "Emails" ) | 1523 | if ( *it == "Emails" ) |
1537 | *itV = ent.emailList().join(", "); // :SX | 1524 | *itV = ent.emailList().join(", "); // :SX |
1538 | 1525 | ||
1539 | if ( *it == "Home Phone" ) | 1526 | if ( *it == "Home Phone" ) |
1540 | *itV = ent.homePhone(); | 1527 | *itV = ent.homePhone(); |
1541 | /* | 1528 | /* |
1542 | if ( *it == "Home 2 Phone" ) | 1529 | if ( *it == "Home 2 Phone" ) |
1543 | *itV = ent.home2Phone(); | 1530 | *itV = ent.home2Phone(); |
1544 | */ | 1531 | */ |
1545 | if ( *it == "Home Fax" ) | 1532 | if ( *it == "Home Fax" ) |
1546 | *itV = ent.homeFax(); | 1533 | *itV = ent.homeFax(); |
1547 | 1534 | ||
1548 | if ( *it == "Home Mobile" ) | 1535 | if ( *it == "Home Mobile" ) |
1549 | *itV = ent.homeMobile(); | 1536 | *itV = ent.homeMobile(); |
1550 | /* | 1537 | /* |
1551 | if ( *it == "Car Phone" ) | 1538 | if ( *it == "Car Phone" ) |
1552 | *itV = ent.carPhone(); | 1539 | *itV = ent.carPhone(); |
1553 | 1540 | ||
1554 | if ( *it == "ISDN Phone" ) | 1541 | if ( *it == "ISDN Phone" ) |
1555 | *itV = ent.ISDNPhone(); | 1542 | *itV = ent.ISDNPhone(); |
1556 | 1543 | ||
1557 | if ( *it == "Other Phone" ) | 1544 | if ( *it == "Other Phone" ) |
1558 | *itV = ent.otherPhone(); | 1545 | *itV = ent.otherPhone(); |
1559 | */ | 1546 | */ |
1560 | if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) ) | 1547 | if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) ) |
1561 | *itV = ent.businessPager(); | 1548 | *itV = ent.businessPager(); |
1562 | /* | 1549 | /* |
1563 | if ( *it == "Home Pager") | 1550 | if ( *it == "Home Pager") |
1564 | *itV = ent.homePager(); | 1551 | *itV = ent.homePager(); |
1565 | 1552 | ||
1566 | if ( *it == "AIM IM" ) | 1553 | if ( *it == "AIM IM" ) |
1567 | *itV = ent.AIMIM(); | 1554 | *itV = ent.AIMIM(); |
1568 | 1555 | ||
1569 | if ( *it == "ICQ IM" ) | 1556 | if ( *it == "ICQ IM" ) |
1570 | *itV = ent.ICQIM(); | 1557 | *itV = ent.ICQIM(); |
1571 | 1558 | ||
1572 | if ( *it == "Jabber IM" ) | 1559 | if ( *it == "Jabber IM" ) |
1573 | *itV = ent.jabberIM(); | 1560 | *itV = ent.jabberIM(); |
1574 | 1561 | ||
1575 | if ( *it == "MSN IM" ) | 1562 | if ( *it == "MSN IM" ) |
1576 | *itV = ent.MSNIM(); | 1563 | *itV = ent.MSNIM(); |
1577 | 1564 | ||
1578 | if ( *it == "Yahoo IM" ) | 1565 | if ( *it == "Yahoo IM" ) |
1579 | *itV = ent.yahooIM(); | 1566 | *itV = ent.yahooIM(); |
1580 | */ | 1567 | */ |
1581 | if ( *it == "Home Web Page" ) | 1568 | if ( *it == "Home Web Page" ) |
1582 | *itV = ent.homeWebpage(); | 1569 | *itV = ent.homeWebpage(); |
1583 | 1570 | ||
1584 | if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) ) | 1571 | if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) ) |
1585 | *itV = ent.businessWebpage(); | 1572 | *itV = ent.businessWebpage(); |
1586 | 1573 | ||
1587 | 1574 | ||
1588 | } | 1575 | } |
1589 | 1576 | ||
1590 | 1577 | ||
1591 | cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") ); | 1578 | cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") ); |
1592 | 1579 | ||
1593 | QString gender = ent.gender(); | 1580 | QString gender = ent.gender(); |
1594 | cmbGender->setCurrentItem( gender.toInt() ); | 1581 | cmbGender->setCurrentItem( gender.toInt() ); |
1595 | 1582 | ||
1596 | txtNote->setText( ent.notes() ); | 1583 | txtNote->setText( ent.notes() ); |
1597 | 1584 | ||
1598 | slotCmbChooser1Change( cmbChooserField1->currentItem() ); | 1585 | slotCmbChooser1Change( cmbChooserField1->currentItem() ); |
1599 | slotCmbChooser2Change( cmbChooserField2->currentItem() ); | 1586 | slotCmbChooser2Change( cmbChooserField2->currentItem() ); |
1600 | slotCmbChooser3Change( cmbChooserField3->currentItem() ); | 1587 | slotCmbChooser3Change( cmbChooserField3->currentItem() ); |
1601 | 1588 | ||
1602 | slotAddressTypeChange( cmbAddress->currentItem() ); | 1589 | slotAddressTypeChange( cmbAddress->currentItem() ); |
1603 | 1590 | ||
1604 | loadFields(); | 1591 | // loadFields(); :SX |
1592 | |||
1593 | // Set DatePicker | ||
1594 | if ( !ent.birthday().isNull() ){ | ||
1595 | birthdayButton->setText( TimeString::numberDateString( ent.birthday() ) ); | ||
1596 | birthdayPicker->setDate( ent.birthday() ); | ||
1597 | } else | ||
1598 | birthdayButton->setText( tr ("Unknown") ); | ||
1599 | |||
1600 | if ( !ent.anniversary().isNull() ){ | ||
1601 | anniversaryButton->setText( TimeString::numberDateString( ent.anniversary() ) ); | ||
1602 | anniversaryPicker->setDate( ent.anniversary() ); | ||
1603 | } else | ||
1604 | anniversaryButton->setText( tr ("Unknown") ); | ||
1605 | 1605 | ||
1606 | } | 1606 | } |
1607 | 1607 | ||
1608 | void ContactEditor::saveEntry() { | 1608 | void ContactEditor::saveEntry() { |
1609 | 1609 | ||
1610 | if ( useFullName == TRUE ) { | 1610 | if ( useFullName == TRUE ) { |
1611 | txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) ); | 1611 | txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) ); |
1612 | txtMiddleName->setText( parseName( txtFullName->text(), NAME_M ) ); | 1612 | txtMiddleName->setText( parseName( txtFullName->text(), NAME_M ) ); |
1613 | txtLastName->setText( parseName( txtFullName->text(), NAME_L ) ); | 1613 | txtLastName->setText( parseName( txtFullName->text(), NAME_L ) ); |
1614 | txtSuffix->setText( parseName( txtFullName->text(), NAME_S ) ); | 1614 | txtSuffix->setText( parseName( txtFullName->text(), NAME_S ) ); |
1615 | 1615 | ||
1616 | useFullName = FALSE; | 1616 | useFullName = FALSE; |
1617 | } | 1617 | } |
1618 | 1618 | ||
1619 | /*if ( ent.firstName() != txtFirstName->text() || | 1619 | /*if ( ent.firstName() != txtFirstName->text() || |
1620 | ent.lastName != txtLastName->text() || | 1620 | ent.lastName != txtLastName->text() || |
1621 | ent.middleName != txtMiddleName->text() ) { | 1621 | ent.middleName != txtMiddleName->text() ) { |
1622 | */ | 1622 | */ |
1623 | ent.setFirstName( txtFirstName->text() ); | 1623 | ent.setFirstName( txtFirstName->text() ); |
1624 | ent.setLastName( txtLastName->text() ); | 1624 | ent.setLastName( txtLastName->text() ); |
1625 | ent.setMiddleName( txtMiddleName->text() ); | 1625 | ent.setMiddleName( txtMiddleName->text() ); |
1626 | ent.setSuffix( txtSuffix->text() ); | 1626 | ent.setSuffix( txtSuffix->text() ); |
1627 | 1627 | ||
1628 | //} | 1628 | //} |
1629 | 1629 | ||
1630 | ent.setFileAs( cmbFileAs->currentText() ); | 1630 | ent.setFileAs( cmbFileAs->currentText() ); |
1631 | 1631 | ||
1632 | ent.setCategories( cmbCat->currentCategories() ); | 1632 | ent.setCategories( cmbCat->currentCategories() ); |
1633 | 1633 | ||
1634 | if (hasTitle) | 1634 | if (hasTitle) |
1635 | ent.setJobTitle( txtJobTitle->text() ); | 1635 | ent.setJobTitle( txtJobTitle->text() ); |
1636 | 1636 | ||
1637 | if (hasCompany) | 1637 | if (hasCompany) |
1638 | ent.setCompany( txtOrganization->text() ); | 1638 | ent.setCompany( txtOrganization->text() ); |
1639 | 1639 | ||
1640 | if (hasNotes) | 1640 | if (hasNotes) |
1641 | ent.setNotes( txtNote->text() ); | 1641 | ent.setNotes( txtNote->text() ); |
1642 | 1642 | ||
1643 | if (hasStreet) { | 1643 | if (hasStreet) { |
1644 | ent.setHomeStreet( slHomeAddress[0] ); | 1644 | ent.setHomeStreet( slHomeAddress[0] ); |
1645 | ent.setBusinessStreet( slBusinessAddress[0] ); | 1645 | ent.setBusinessStreet( slBusinessAddress[0] ); |
1646 | } | 1646 | } |
1647 | /* | 1647 | /* |
1648 | if (hasStreet2) { | 1648 | if (hasStreet2) { |
1649 | ent.setHomeStreet2( (*slHomeAddress)[1] ); | 1649 | ent.setHomeStreet2( (*slHomeAddress)[1] ); |
1650 | ent.setBusinessStreet2( (*slBusinessAddress)[1] ); | 1650 | ent.setBusinessStreet2( (*slBusinessAddress)[1] ); |
1651 | } | 1651 | } |
1652 | 1652 | ||
1653 | if (hasPOBox) { | 1653 | if (hasPOBox) { |
1654 | ent.setHomePOBox( (*slHomeAddress)[2] ); | 1654 | ent.setHomePOBox( (*slHomeAddress)[2] ); |
1655 | ent.setBusinessPOBox( (*slBusinessAddress)[2] ); | 1655 | ent.setBusinessPOBox( (*slBusinessAddress)[2] ); |
1656 | } | 1656 | } |
1657 | */ | 1657 | */ |
1658 | if (hasCity) { | 1658 | if (hasCity) { |
1659 | ent.setHomeCity( slHomeAddress[3] ); | 1659 | ent.setHomeCity( slHomeAddress[3] ); |
1660 | ent.setBusinessCity( slBusinessAddress[3] ); | 1660 | ent.setBusinessCity( slBusinessAddress[3] ); |
1661 | } | 1661 | } |
1662 | 1662 | ||
1663 | if (hasState) { | 1663 | if (hasState) { |
1664 | ent.setHomeState( slHomeAddress[4] ); | 1664 | ent.setHomeState( slHomeAddress[4] ); |
1665 | ent.setBusinessState( slBusinessAddress[4] ); | 1665 | ent.setBusinessState( slBusinessAddress[4] ); |
1666 | } | 1666 | } |
1667 | 1667 | ||
1668 | if (hasZip) { | 1668 | if (hasZip) { |
1669 | ent.setHomeZip( slHomeAddress[5] ); | 1669 | ent.setHomeZip( slHomeAddress[5] ); |
1670 | ent.setBusinessZip( slBusinessAddress[5] ); | 1670 | ent.setBusinessZip( slBusinessAddress[5] ); |
1671 | } | 1671 | } |
1672 | 1672 | ||
1673 | if (hasCountry) { | 1673 | if (hasCountry) { |
1674 | ent.setHomeCountry( slHomeAddress[6] ); | 1674 | ent.setHomeCountry( slHomeAddress[6] ); |
1675 | ent.setBusinessCountry( slBusinessAddress[6] ); | 1675 | ent.setBusinessCountry( slBusinessAddress[6] ); |
1676 | } | 1676 | } |
1677 | 1677 | ||
1678 | QStringList::ConstIterator it; | 1678 | QStringList::ConstIterator it; |
1679 | QListIterator<QLineEdit> itLE( listValue ); | 1679 | QListIterator<QLineEdit> itLE( listValue ); |
1680 | for ( it = slDynamicEntries.begin(); it != slDynamicEntries.end(); ++it, ++itLE) { | 1680 | for ( it = slDynamicEntries.begin(); it != slDynamicEntries.end(); ++it, ++itLE) { |
1681 | if ( *it == "Department" ) | 1681 | if ( *it == "Department" ) |
1682 | ent.setDepartment( (*itLE)->text() ); | 1682 | ent.setDepartment( (*itLE)->text() ); |
1683 | 1683 | ||
1684 | if ( *it == "Company" ) | 1684 | if ( *it == "Company" ) |
1685 | ent.setCompany( (*itLE)->text() ); | 1685 | ent.setCompany( (*itLE)->text() ); |
1686 | 1686 | ||
1687 | if ( *it == "Office" ) | 1687 | if ( *it == "Office" ) |
1688 | ent.setOffice( (*itLE)->text() ); | 1688 | ent.setOffice( (*itLE)->text() ); |
1689 | 1689 | ||
1690 | if ( *it == "Profession" ) | 1690 | if ( *it == "Profession" ) |
1691 | ent.setProfession( (*itLE)->text() ); | 1691 | ent.setProfession( (*itLE)->text() ); |
1692 | 1692 | ||
1693 | if ( *it == "Assistant" ) | 1693 | if ( *it == "Assistant" ) |
1694 | ent.setAssistant( (*itLE)->text() ); | 1694 | ent.setAssistant( (*itLE)->text() ); |
1695 | 1695 | ||
1696 | if ( *it == "Manager" ) | 1696 | if ( *it == "Manager" ) |
1697 | ent.setManager( (*itLE)->text() ); | 1697 | ent.setManager( (*itLE)->text() ); |
1698 | 1698 | ||
1699 | if ( *it == "Spouse" ) | 1699 | if ( *it == "Spouse" ) |
1700 | ent.setSpouse( (*itLE)->text() ); | 1700 | ent.setSpouse( (*itLE)->text() ); |
1701 | 1701 | ||
1702 | if ( *it == "Nickname" ) | 1702 | if ( *it == "Nickname" ) |
1703 | ent.setNickname( (*itLE)->text() ); | 1703 | ent.setNickname( (*itLE)->text() ); |
1704 | 1704 | ||
1705 | if ( *it == "Children" ) | 1705 | if ( *it == "Children" ) |
1706 | ent.setChildren( (*itLE)->text() ); | 1706 | ent.setChildren( (*itLE)->text() ); |
1707 | 1707 | ||
1708 | } | 1708 | } |
1709 | 1709 | ||
1710 | QStringList::ConstIterator itV; | 1710 | QStringList::ConstIterator itV; |
1711 | for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) { | 1711 | for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) { |
1712 | 1712 | ||
1713 | if ( ( *it == "Business Phone" ) || ( *it == "Work Phone" ) ) | 1713 | if ( ( *it == "Business Phone" ) || ( *it == "Work Phone" ) ) |
1714 | ent.setBusinessPhone( *itV ); | 1714 | ent.setBusinessPhone( *itV ); |
1715 | /* | 1715 | /* |
1716 | if ( *it == tr("Business 2 Phone" ) | 1716 | if ( *it == tr("Business 2 Phone" ) |
1717 | ent.setBusiness2Phone( *itV ); | 1717 | ent.setBusiness2Phone( *itV ); |
1718 | */ | 1718 | */ |
1719 | if ( ( *it == "Business Fax" ) || ( *it == "Work Fax" ) ) | 1719 | if ( ( *it == "Business Fax" ) || ( *it == "Work Fax" ) ) |
1720 | ent.setBusinessFax( *itV ); | 1720 | ent.setBusinessFax( *itV ); |
1721 | 1721 | ||
1722 | if ( ( *it == "Business Mobile" ) || ( *it == "Work Mobile" ) ) | 1722 | if ( ( *it == "Business Mobile" ) || ( *it == "Work Mobile" ) ) |
1723 | ent.setBusinessMobile( *itV ); | 1723 | ent.setBusinessMobile( *itV ); |
1724 | /* | 1724 | /* |
1725 | if ( *it == "Company Phone" ) | 1725 | if ( *it == "Company Phone" ) |
1726 | ent.setCompanyPhone( *itV ); | 1726 | ent.setCompanyPhone( *itV ); |
1727 | */ | 1727 | */ |
1728 | //if ( *it == "Default Email" ) | 1728 | //if ( *it == "Default Email" ) |
1729 | //ent.setDefaultEmail( *itV ); | 1729 | //ent.setDefaultEmail( *itV ); |
1730 | 1730 | ||
1731 | if ( *it == "Emails" ){ | 1731 | if ( *it == "Emails" ){ |
1732 | QString allemail; | 1732 | QString allemail; |
1733 | QString defaultmail; | 1733 | QString defaultmail; |
1734 | parseEmailFrom( *itV, defaultmail, allemail ); | 1734 | parseEmailFrom( *itV, defaultmail, allemail ); |
1735 | // ent.clearEmails(); | 1735 | // ent.clearEmails(); |
1736 | ent.setDefaultEmail( defaultmail ); | 1736 | ent.setDefaultEmail( defaultmail ); |
1737 | ent.setEmails( allemail ); | 1737 | ent.setEmails( allemail ); |
1738 | } | 1738 | } |
1739 | 1739 | ||
1740 | if ( *it == "Home Phone" ) | 1740 | if ( *it == "Home Phone" ) |
1741 | ent.setHomePhone( *itV ); | 1741 | ent.setHomePhone( *itV ); |
1742 | /* | 1742 | /* |
1743 | if ( *it == "Home 2 Phone" ) | 1743 | if ( *it == "Home 2 Phone" ) |
1744 | ent.setHome2Phone( *itV ); | 1744 | ent.setHome2Phone( *itV ); |
1745 | */ | 1745 | */ |
1746 | if ( *it == "Home Fax" ) | 1746 | if ( *it == "Home Fax" ) |
1747 | ent.setHomeFax( *itV ); | 1747 | ent.setHomeFax( *itV ); |
1748 | 1748 | ||
1749 | if ( *it == "Home Mobile" ) | 1749 | if ( *it == "Home Mobile" ) |
1750 | ent.setHomeMobile( *itV ); | 1750 | ent.setHomeMobile( *itV ); |
1751 | /* | 1751 | /* |
1752 | if ( *it == "Car Phone" ) | 1752 | if ( *it == "Car Phone" ) |
1753 | ent.setCarPhone( *itV ); | 1753 | ent.setCarPhone( *itV ); |
1754 | 1754 | ||
1755 | if ( *it == "ISDN Phone" ) | 1755 | if ( *it == "ISDN Phone" ) |
1756 | ent.setISDNPhone( *itV ); | 1756 | ent.setISDNPhone( *itV ); |
1757 | 1757 | ||
1758 | if ( *it == "Other Phone" ) | 1758 | if ( *it == "Other Phone" ) |
1759 | ent.setOtherPhone( *itV ); | 1759 | ent.setOtherPhone( *itV ); |
1760 | */ | 1760 | */ |
1761 | if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) ) | 1761 | if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) ) |
1762 | ent.setBusinessPager( *itV ); | 1762 | ent.setBusinessPager( *itV ); |
1763 | /* | 1763 | /* |
1764 | if ( *it == "Home Pager" ) | 1764 | if ( *it == "Home Pager" ) |
1765 | ent.setHomePager( *itV ); | 1765 | ent.setHomePager( *itV ); |
1766 | 1766 | ||
1767 | if ( *it == "AIM IM" ) | 1767 | if ( *it == "AIM IM" ) |
1768 | ent.setAIMIM( *itV ); | 1768 | ent.setAIMIM( *itV ); |
1769 | 1769 | ||
1770 | if ( *it == "ICQ IM" ) | 1770 | if ( *it == "ICQ IM" ) |
1771 | ent.setICQIM( *itV ); | 1771 | ent.setICQIM( *itV ); |
1772 | 1772 | ||
1773 | if ( *it == "Jabber IM" ) | 1773 | if ( *it == "Jabber IM" ) |
1774 | ent.setJabberIM( *itV ); | 1774 | ent.setJabberIM( *itV ); |
1775 | 1775 | ||
1776 | if ( *it == "MSN IM" ) | 1776 | if ( *it == "MSN IM" ) |
1777 | ent.setMSNIM( *itV ); | 1777 | ent.setMSNIM( *itV ); |
1778 | 1778 | ||
1779 | if ( *it == "Yahoo IM" ) | 1779 | if ( *it == "Yahoo IM" ) |
1780 | ent.setYahooIM( *itV ); | 1780 | ent.setYahooIM( *itV ); |
1781 | */ | 1781 | */ |
1782 | if ( *it == "Home Web Page" ) | 1782 | if ( *it == "Home Web Page" ) |
1783 | ent.setHomeWebpage( *itV ); | 1783 | ent.setHomeWebpage( *itV ); |
1784 | 1784 | ||
1785 | if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) ) | 1785 | if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) ) |
1786 | ent.setBusinessWebpage( *itV ); | 1786 | ent.setBusinessWebpage( *itV ); |
1787 | 1787 | ||
1788 | 1788 | ||
1789 | } | 1789 | } |
1790 | 1790 | ||
1791 | int gender = cmbGender->currentItem(); | 1791 | int gender = cmbGender->currentItem(); |
1792 | ent.setGender( QString::number( gender ) ); | 1792 | ent.setGender( QString::number( gender ) ); |
1793 | 1793 | ||
1794 | QString str = txtNote->text(); | 1794 | QString str = txtNote->text(); |
1795 | if ( !str.isNull() ) | 1795 | if ( !str.isNull() ) |
1796 | ent.setNotes( str ); | 1796 | ent.setNotes( str ); |
1797 | 1797 | ||
1798 | } | 1798 | } |
1799 | 1799 | ||
1800 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, | 1800 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, |
1801 | QString &strAll ) | 1801 | QString &strAll ) |
1802 | { | 1802 | { |
1803 | int where, | 1803 | int where, |
1804 | start; | 1804 | start; |
1805 | if ( txt.isEmpty() ) | 1805 | if ( txt.isEmpty() ) |
1806 | return; | 1806 | return; |
1807 | // find the first | 1807 | // find the first |
1808 | where = txt.find( ',' ); | 1808 | where = txt.find( ',' ); |
1809 | if ( where < 0 ) { | 1809 | if ( where < 0 ) { |
1810 | strDefaultEmail = txt; | 1810 | strDefaultEmail = txt; |
1811 | strAll = txt; | 1811 | strAll = txt; |
1812 | } else { | 1812 | } else { |
1813 | strDefaultEmail = txt.left( where ).stripWhiteSpace(); | 1813 | strDefaultEmail = txt.left( where ).stripWhiteSpace(); |
1814 | strAll = strDefaultEmail; | 1814 | strAll = strDefaultEmail; |
1815 | while ( where > -1 ) { | 1815 | while ( where > -1 ) { |
1816 | strAll.append(" "); | 1816 | strAll.append(" "); |
1817 | start = where; | 1817 | start = where; |
1818 | where = txt.find( ',', where + 1 ); | 1818 | where = txt.find( ',', where + 1 ); |
1819 | if ( where > - 1 ) | 1819 | if ( where > - 1 ) |
1820 | strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() ); | 1820 | strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() ); |
1821 | else // grab until the end... | 1821 | else // grab until the end... |
1822 | strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() ); | 1822 | strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() ); |
1823 | } | 1823 | } |
1824 | } | 1824 | } |
1825 | } | 1825 | } |
1826 | 1826 | ||
1827 | void parseEmailTo( const QString &strDefaultEmail, | 1827 | void parseEmailTo( const QString &strDefaultEmail, |
1828 | const QString &strOtherEmail, QString &strBack ) | 1828 | const QString &strOtherEmail, QString &strBack ) |
1829 | { | 1829 | { |
1830 | // create a comma dilimeted set of emails... | 1830 | // create a comma dilimeted set of emails... |
1831 | // use the power of short circuiting... | 1831 | // use the power of short circuiting... |
1832 | bool foundDefault = false; | 1832 | bool foundDefault = false; |
1833 | QString strTmp; | 1833 | QString strTmp; |
1834 | int start = 0; | 1834 | int start = 0; |
1835 | int where; | 1835 | int where; |
1836 | // start at the beginng. | 1836 | // start at the beginng. |
1837 | strBack = strDefaultEmail; | 1837 | strBack = strDefaultEmail; |
1838 | where = 0; | 1838 | where = 0; |
1839 | while ( where > -1 ) { | 1839 | while ( where > -1 ) { |
1840 | start = where; | 1840 | start = where; |
1841 | where = strOtherEmail.find( ' ', where + 1 ); | 1841 | where = strOtherEmail.find( ' ', where + 1 ); |
1842 | if ( where > 0 ) { | 1842 | if ( where > 0 ) { |
1843 | strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace(); | 1843 | strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace(); |
1844 | } else | 1844 | } else |
1845 | strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace(); | 1845 | strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace(); |
1846 | if ( foundDefault || strTmp != strDefaultEmail ) { | 1846 | if ( foundDefault || strTmp != strDefaultEmail ) { |
1847 | strBack.append( ", " ); | 1847 | strBack.append( ", " ); |
1848 | strBack.append( strTmp ); | 1848 | strBack.append( strTmp ); |
1849 | } else | 1849 | } else |
1850 | foundDefault = true; | 1850 | foundDefault = true; |
1851 | } | 1851 | } |
1852 | } | 1852 | } |
1853 | 1853 | ||
1854 | 1854 | ||
1855 | static inline bool containsAlphaNum( const QString &str ) | 1855 | static inline bool containsAlphaNum( const QString &str ) |
1856 | { | 1856 | { |
1857 | int i, | 1857 | int i, |
1858 | count = str.length(); | 1858 | count = str.length(); |
1859 | for ( i = 0; i < count; i++ ) | 1859 | for ( i = 0; i < count; i++ ) |
1860 | if ( !str[i].isSpace() ) | 1860 | if ( !str[i].isSpace() ) |
1861 | return TRUE; | 1861 | return TRUE; |
1862 | return FALSE; | 1862 | return FALSE; |
1863 | } | 1863 | } |
1864 | 1864 | ||
1865 | static inline bool constainsWhiteSpace( const QString &str ) | 1865 | static inline bool constainsWhiteSpace( const QString &str ) |
1866 | { | 1866 | { |
1867 | int i, | 1867 | int i, |
1868 | count = str.length(); | 1868 | count = str.length(); |
1869 | for (i = 0; i < count; i++ ) | 1869 | for (i = 0; i < count; i++ ) |
1870 | if ( str[i].isSpace() ) | 1870 | if ( str[i].isSpace() ) |
1871 | return TRUE; | 1871 | return TRUE; |
1872 | return FALSE; | 1872 | return FALSE; |
1873 | } | 1873 | } |
1874 | 1874 | ||
1875 | void ContactEditor::setPersonalView( bool personal ) | 1875 | void ContactEditor::setPersonalView( bool personal ) |
1876 | { | 1876 | { |
1877 | m_personalView = personal; | 1877 | m_personalView = personal; |
1878 | if ( personal ){ | 1878 | if ( personal ){ |
1879 | cmbCat->hide(); | 1879 | cmbCat->hide(); |
1880 | labCat->hide(); | 1880 | labCat->hide(); |
1881 | } else{ | 1881 | } else{ |
1882 | cmbCat->show(); | 1882 | cmbCat->show(); |
1883 | labCat->show(); | 1883 | labCat->show(); |
1884 | 1884 | ||
1885 | } | 1885 | } |
1886 | } | 1886 | } |
1887 | 1887 | ||
1888 | void ContactEditor::slotAnniversaryDateChanged( int year, int month, int day) | 1888 | void ContactEditor::slotAnniversaryDateChanged( int year, int month, int day) |
1889 | { | 1889 | { |
1890 | QDate date; | 1890 | QDate date; |
1891 | date.setYMD( year, month, day ); | 1891 | date.setYMD( year, month, day ); |
1892 | QString dateString = TimeString::numberDateString( date ); | 1892 | QString dateString = TimeString::numberDateString( date ); |
1893 | anniversaryButton->setText( dateString ); | 1893 | anniversaryButton->setText( dateString ); |
1894 | ent.setAnniversary ( dateString ); | 1894 | ent.setAnniversary ( date ); |
1895 | } | 1895 | } |
1896 | 1896 | ||
1897 | void ContactEditor::slotBirthdayDateChanged( int year, int month, int day) | 1897 | void ContactEditor::slotBirthdayDateChanged( int year, int month, int day) |
1898 | { | 1898 | { |
1899 | QDate date; | 1899 | QDate date; |
1900 | date.setYMD( year, month, day ); | 1900 | date.setYMD( year, month, day ); |
1901 | QString dateString = TimeString::numberDateString( date ); | 1901 | QString dateString = TimeString::numberDateString( date ); |
1902 | birthdayButton->setText( dateString ); | 1902 | birthdayButton->setText( dateString ); |
1903 | ent.setBirthday ( dateString ); | 1903 | ent.setBirthday ( date ); |
1904 | } | 1904 | } |