Diffstat (limited to 'core/pim/addressbook/abtable.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/addressbook/abtable.cpp | 85 |
1 files changed, 42 insertions, 43 deletions
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp index 29f4383..cd77b13 100644 --- a/core/pim/addressbook/abtable.cpp +++ b/core/pim/addressbook/abtable.cpp | |||
@@ -11,44 +11,43 @@ | |||
11 | ** | 11 | ** |
12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
14 | ** | 14 | ** |
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
16 | ** | 16 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 18 | ** not clear to you. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | 21 | ||
22 | 22 | ||
23 | #include <opie2/opimrecordlist.h> | ||
24 | |||
23 | #include <qpe/timestring.h> | 25 | #include <qpe/timestring.h> |
24 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
25 | 27 | ||
26 | #include <opie/orecordlist.h> | ||
27 | |||
28 | |||
29 | #include "abtable.h" | 28 | #include "abtable.h" |
30 | 29 | ||
31 | #include <errno.h> | 30 | #include <errno.h> |
32 | #include <fcntl.h> | 31 | #include <fcntl.h> |
33 | #include <unistd.h> | 32 | #include <unistd.h> |
34 | #include <stdlib.h> | 33 | #include <stdlib.h> |
35 | 34 | ||
36 | #include <ctype.h> //toupper() for key hack | 35 | #include <ctype.h> //toupper() for key hack |
37 | 36 | ||
38 | #if 0 | 37 | #if 0 |
39 | 38 | ||
40 | /*! | 39 | /*! |
41 | \class AbTableItem abtable.h | 40 | \class AbTableItem abtable.h |
42 | 41 | ||
43 | \brief QTableItem based class for showing a field of an entry | 42 | \brief QTableItem based class for showing a field of an entry |
44 | */ | 43 | */ |
45 | 44 | ||
46 | AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s, | 45 | AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s, |
47 | const QString &secondSortKey) | 46 | const QString &secondSortKey) |
48 | : QTableItem( t, et, s ) | 47 | : QTableItem( t, et, s ) |
49 | { | 48 | { |
50 | // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower(); | 49 | // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower(); |
51 | sortKey = Qtopia::buildSortKey( s, secondSortKey ); | 50 | sortKey = Qtopia::buildSortKey( s, secondSortKey ); |
52 | } | 51 | } |
53 | 52 | ||
54 | int AbTableItem::alignment() const | 53 | int AbTableItem::alignment() const |
@@ -57,31 +56,31 @@ int AbTableItem::alignment() const | |||
57 | } | 56 | } |
58 | 57 | ||
59 | QString AbTableItem::key() const | 58 | QString AbTableItem::key() const |
60 | { | 59 | { |
61 | return sortKey; | 60 | return sortKey; |
62 | } | 61 | } |
63 | 62 | ||
64 | // A way to reset the item, without out doing a delete or a new... | 63 | // A way to reset the item, without out doing a delete or a new... |
65 | void AbTableItem::setItem( const QString &txt, const QString &secondKey ) | 64 | void AbTableItem::setItem( const QString &txt, const QString &secondKey ) |
66 | { | 65 | { |
67 | setText( txt ); | 66 | setText( txt ); |
68 | sortKey = Qtopia::buildSortKey( txt, secondKey ); | 67 | sortKey = Qtopia::buildSortKey( txt, secondKey ); |
69 | 68 | ||
70 | // sortKey = txt.lower() + QChar( '\0' ) + secondKey.lower(); | 69 | // sortKey = txt.lower() + QChar( '\0' ) + secondKey.lower(); |
71 | } | 70 | } |
72 | 71 | ||
73 | /*! | 72 | /*! |
74 | \class AbPickItem abtable.h | 73 | \class AbPickItem abtable.h |
75 | 74 | ||
76 | \brief QTableItem based class for showing slection of an entry | 75 | \brief QTableItem based class for showing slection of an entry |
77 | */ | 76 | */ |
78 | 77 | ||
79 | AbPickItem::AbPickItem( QTable *t ) : | 78 | AbPickItem::AbPickItem( QTable *t ) : |
80 | QTableItem(t, WhenCurrent, "?") | 79 | QTableItem(t, WhenCurrent, "?") |
81 | { | 80 | { |
82 | } | 81 | } |
83 | 82 | ||
84 | QWidget *AbPickItem::createEditor() const | 83 | QWidget *AbPickItem::createEditor() const |
85 | { | 84 | { |
86 | QComboBox* combo = new QComboBox( table()->viewport() ); | 85 | QComboBox* combo = new QComboBox( table()->viewport() ); |
87 | ( (AbPickItem*)this )->cb = combo; | 86 | ( (AbPickItem*)this )->cb = combo; |
@@ -100,25 +99,25 @@ QWidget *AbPickItem::createEditor() const | |||
100 | void AbPickItem::setContentFromEditor( QWidget *w ) | 99 | void AbPickItem::setContentFromEditor( QWidget *w ) |
101 | { | 100 | { |
102 | if ( w->inherits("QComboBox") ) | 101 | if ( w->inherits("QComboBox") ) |
103 | setText( ( (QComboBox*)w )->currentText() ); | 102 | setText( ( (QComboBox*)w )->currentText() ); |
104 | else | 103 | else |
105 | QTableItem::setContentFromEditor( w ); | 104 | QTableItem::setContentFromEditor( w ); |
106 | } | 105 | } |
107 | 106 | ||
108 | #endif | 107 | #endif |
109 | 108 | ||
110 | /*! | 109 | /*! |
111 | \class AbTable abtable.h | 110 | \class AbTable abtable.h |
112 | 111 | ||
113 | \brief QTable based class for showing a list of entries | 112 | \brief QTable based class for showing a list of entries |
114 | */ | 113 | */ |
115 | 114 | ||
116 | AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name ) | 115 | AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name ) |
117 | : QTable( parent, name ), | 116 | : QTable( parent, name ), |
118 | lastSortCol( -1 ), | 117 | lastSortCol( -1 ), |
119 | asc( TRUE ), | 118 | asc( TRUE ), |
120 | intFields( order ), | 119 | intFields( order ), |
121 | enablePainting( true ), | 120 | enablePainting( true ), |
122 | columnVisible( true ), | 121 | columnVisible( true ), |
123 | countNested( 0 ) | 122 | countNested( 0 ) |
124 | { | 123 | { |
@@ -134,69 +133,69 @@ AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name | |||
134 | //qWarning("C'tor end"); | 133 | //qWarning("C'tor end"); |
135 | } | 134 | } |
136 | 135 | ||
137 | AbTable::~AbTable() | 136 | AbTable::~AbTable() |
138 | { | 137 | { |
139 | } | 138 | } |
140 | 139 | ||
141 | void AbTable::init() | 140 | void AbTable::init() |
142 | { | 141 | { |
143 | // :SX showChar = '\0'; | 142 | // :SX showChar = '\0'; |
144 | setNumRows( 0 ); | 143 | setNumRows( 0 ); |
145 | setNumCols( 2 ); | 144 | setNumCols( 2 ); |
146 | 145 | ||
147 | horizontalHeader()->setLabel( 0, tr( "Full Name" )); | 146 | horizontalHeader()->setLabel( 0, tr( "Full Name" )); |
148 | horizontalHeader()->setLabel( 1, tr( "Contact" )); | 147 | horizontalHeader()->setLabel( 1, tr( "Contact" )); |
149 | setLeftMargin( 0 ); | 148 | setLeftMargin( 0 ); |
150 | verticalHeader()->hide(); | 149 | verticalHeader()->hide(); |
151 | columnVisible = true; | 150 | columnVisible = true; |
152 | } | 151 | } |
153 | 152 | ||
154 | void AbTable::setContacts( const OContactAccess::List& viewList ) | 153 | void AbTable::setContacts( const Opie::OPimContactAccess::List& viewList ) |
155 | { | 154 | { |
156 | qWarning("AbTable::setContacts()"); | 155 | qWarning("AbTable::setContacts()"); |
157 | 156 | ||
158 | clear(); | 157 | clear(); |
159 | m_viewList = viewList; | 158 | m_viewList = viewList; |
160 | 159 | ||
161 | setSorting( false ); | 160 | setSorting( false ); |
162 | setPaintingEnabled( FALSE ); | 161 | setPaintingEnabled( FALSE ); |
163 | 162 | ||
164 | OContactAccess::List::Iterator it; | 163 | Opie::OPimContactAccess::List::Iterator it; |
165 | setNumRows( m_viewList.count() ); | 164 | setNumRows( m_viewList.count() ); |
166 | //int row = 0; | 165 | //int row = 0; |
167 | // for ( it = m_viewList.begin(); it != m_viewList.end(); ++it ) | 166 | // for ( it = m_viewList.begin(); it != m_viewList.end(); ++it ) |
168 | // insertIntoTable( *it, row++ ); | 167 | // insertIntoTable( *it, row++ ); |
169 | 168 | ||
170 | // setSorting( true ); | 169 | // setSorting( true ); |
171 | 170 | ||
172 | // resort(); | 171 | // resort(); |
173 | 172 | ||
174 | updateVisible(); | 173 | updateVisible(); |
175 | 174 | ||
176 | setPaintingEnabled( TRUE ); | 175 | setPaintingEnabled( TRUE ); |
177 | 176 | ||
178 | } | 177 | } |
179 | 178 | ||
180 | void AbTable::setOrderedList( const QValueList<int> ordered ) | 179 | void AbTable::setOrderedList( const QValueList<int> ordered ) |
181 | { | 180 | { |
182 | intFields = ordered; | 181 | intFields = ordered; |
183 | } | 182 | } |
184 | 183 | ||
185 | 184 | ||
186 | bool AbTable::selectContact( int UID ) | 185 | bool AbTable::selectContact( int UID ) |
187 | { | 186 | { |
188 | qWarning( "AbTable::selectContact( %d )", UID ); | 187 | qWarning( "AbTable::selectContact( %d )", UID ); |
189 | int rows = numRows(); | 188 | int rows = numRows(); |
190 | OContact* foundContact = 0l; | 189 | Opie::OPimContact* foundContact = 0l; |
191 | bool found = false; | 190 | bool found = false; |
192 | 191 | ||
193 | setPaintingEnabled( FALSE ); | 192 | setPaintingEnabled( FALSE ); |
194 | qWarning( "search start" ); | 193 | qWarning( "search start" ); |
195 | for ( int r = 0; r < rows; ++r ) { | 194 | for ( int r = 0; r < rows; ++r ) { |
196 | if ( m_viewList.uidAt( r ) == UID ){ | 195 | if ( m_viewList.uidAt( r ) == UID ){ |
197 | ensureCellVisible( r, 0 ); | 196 | ensureCellVisible( r, 0 ); |
198 | setCurrentCell( r, 0 ); | 197 | setCurrentCell( r, 0 ); |
199 | found = true; | 198 | found = true; |
200 | break; | 199 | break; |
201 | } | 200 | } |
202 | } | 201 | } |
@@ -204,57 +203,57 @@ bool AbTable::selectContact( int UID ) | |||
204 | 203 | ||
205 | if ( !found ){ | 204 | if ( !found ){ |
206 | ensureCellVisible( 0,0 ); | 205 | ensureCellVisible( 0,0 ); |
207 | setCurrentCell( 0, 0 ); | 206 | setCurrentCell( 0, 0 ); |
208 | } | 207 | } |
209 | 208 | ||
210 | setPaintingEnabled( TRUE ); | 209 | setPaintingEnabled( TRUE ); |
211 | 210 | ||
212 | return true; | 211 | return true; |
213 | } | 212 | } |
214 | 213 | ||
215 | #if 0 | 214 | #if 0 |
216 | void AbTable::insertIntoTable( const OContact& cnt, int row ) | 215 | void AbTable::insertIntoTable( const Opie::OPimContact& cnt, int row ) |
217 | { | 216 | { |
218 | qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row ); | 217 | qWarning( "void AbTable::insertIntoTable( const Opie::OPimContact& cnt, %d )", row ); |
219 | QString strName; | 218 | QString strName; |
220 | ContactItem contactItem; | 219 | ContactItem contactItem; |
221 | 220 | ||
222 | strName = findContactName( cnt ); | 221 | strName = findContactName( cnt ); |
223 | contactItem = findContactContact( cnt, row ); | 222 | contactItem = findContactContact( cnt, row ); |
224 | 223 | ||
225 | AbTableItem *ati; | 224 | AbTableItem *ati; |
226 | ati = new AbTableItem( this, QTableItem::Never, strName, contactItem.value ); | 225 | ati = new AbTableItem( this, QTableItem::Never, strName, contactItem.value ); |
227 | contactList.insert( ati, cnt ); | 226 | contactList.insert( ati, cnt ); |
228 | setItem( row, 0, ati ); | 227 | setItem( row, 0, ati ); |
229 | ati = new AbTableItem( this, QTableItem::Never, contactItem.value, strName); | 228 | ati = new AbTableItem( this, QTableItem::Never, contactItem.value, strName); |
230 | if ( !contactItem.icon.isNull() ) | 229 | if ( !contactItem.icon.isNull() ) |
231 | ati->setPixmap( contactItem.icon ); | 230 | ati->setPixmap( contactItem.icon ); |
232 | setItem( row, 1, ati ); | 231 | setItem( row, 1, ati ); |
233 | 232 | ||
234 | //### cannot do this; table only has two columns at this point | 233 | //### cannot do this; table only has two columns at this point |
235 | // setItem( row, 2, new AbPickItem( this ) ); | 234 | // setItem( row, 2, new AbPickItem( this ) ); |
236 | 235 | ||
237 | } | 236 | } |
238 | #endif | 237 | #endif |
239 | 238 | ||
240 | 239 | ||
241 | void AbTable::columnClicked( int col ) | 240 | void AbTable::columnClicked( int col ) |
242 | { | 241 | { |
243 | if ( !sorting() ) | 242 | if ( !sorting() ) |
244 | return; | 243 | return; |
245 | 244 | ||
246 | if ( lastSortCol == -1 ) | 245 | if ( lastSortCol == -1 ) |
247 | lastSortCol = col; | 246 | lastSortCol = col; |
248 | 247 | ||
249 | if ( col == lastSortCol ) { | 248 | if ( col == lastSortCol ) { |
250 | asc = !asc; | 249 | asc = !asc; |
251 | } else { | 250 | } else { |
252 | lastSortCol = col; | 251 | lastSortCol = col; |
253 | asc = TRUE; | 252 | asc = TRUE; |
254 | } | 253 | } |
255 | //QMessageBox::information( this, "resort", "columnClicked" ); | 254 | //QMessageBox::information( this, "resort", "columnClicked" ); |
256 | resort(); | 255 | resort(); |
257 | } | 256 | } |
258 | 257 | ||
259 | void AbTable::resort() | 258 | void AbTable::resort() |
260 | { | 259 | { |
@@ -263,26 +262,26 @@ void AbTable::resort() | |||
263 | setPaintingEnabled( FALSE ); | 262 | setPaintingEnabled( FALSE ); |
264 | if ( sorting() ) { | 263 | if ( sorting() ) { |
265 | if ( lastSortCol == -1 ) | 264 | if ( lastSortCol == -1 ) |
266 | lastSortCol = 0; | 265 | lastSortCol = 0; |
267 | sortColumn( lastSortCol, asc, TRUE ); | 266 | sortColumn( lastSortCol, asc, TRUE ); |
268 | //QMessageBox::information( this, "resort", "resort" ); | 267 | //QMessageBox::information( this, "resort", "resort" ); |
269 | updateVisible(); | 268 | updateVisible(); |
270 | } | 269 | } |
271 | setPaintingEnabled( TRUE ); | 270 | setPaintingEnabled( TRUE ); |
272 | #endif | 271 | #endif |
273 | } | 272 | } |
274 | 273 | ||
275 | OContact AbTable::currentEntry() | 274 | Opie::OPimContact AbTable::currentEntry() |
276 | { | 275 | { |
277 | return m_viewList[currentRow()]; | 276 | return m_viewList[currentRow()]; |
278 | } | 277 | } |
279 | 278 | ||
280 | int AbTable::currentEntry_UID() | 279 | int AbTable::currentEntry_UID() |
281 | { | 280 | { |
282 | return ( currentEntry().uid() ); | 281 | return ( currentEntry().uid() ); |
283 | } | 282 | } |
284 | 283 | ||
285 | void AbTable::clear() | 284 | void AbTable::clear() |
286 | { | 285 | { |
287 | qWarning( "void AbTable::clear()" ); | 286 | qWarning( "void AbTable::clear()" ); |
288 | // contactList.clear(); | 287 | // contactList.clear(); |
@@ -322,53 +321,53 @@ void AbTable::refresh() | |||
322 | setPixmap( QPixmap() ); | 321 | setPixmap( QPixmap() ); |
323 | } | 322 | } |
324 | } | 323 | } |
325 | resort(); | 324 | resort(); |
326 | setPaintingEnabled( TRUE ); | 325 | setPaintingEnabled( TRUE ); |
327 | 326 | ||
328 | #endif | 327 | #endif |
329 | } | 328 | } |
330 | 329 | ||
331 | void AbTable::keyPressEvent( QKeyEvent *e ) | 330 | void AbTable::keyPressEvent( QKeyEvent *e ) |
332 | { | 331 | { |
333 | char key = toupper( e->ascii() ); | 332 | char key = toupper( e->ascii() ); |
334 | 333 | ||
335 | if ( key >= 'A' && key <= 'Z' ) | 334 | if ( key >= 'A' && key <= 'Z' ) |
336 | moveTo( key ); | 335 | moveTo( key ); |
337 | 336 | ||
338 | //qWarning("Received key .."); | 337 | //qWarning("Received key .."); |
339 | switch( e->key() ) { | 338 | switch( e->key() ) { |
340 | case Qt::Key_Space: | 339 | case Qt::Key_Space: |
341 | case Qt::Key_Return: | 340 | case Qt::Key_Return: |
342 | case Qt::Key_Enter: | 341 | case Qt::Key_Enter: |
343 | emit signalSwitch(); | 342 | emit signalSwitch(); |
344 | break; | 343 | break; |
345 | // case Qt::Key_Up: | 344 | // case Qt::Key_Up: |
346 | // qWarning("a"); | 345 | // qWarning("a"); |
347 | // emit signalKeyUp(); | 346 | // emit signalKeyUp(); |
348 | // break; | 347 | // break; |
349 | // case Qt::Key_Down: | 348 | // case Qt::Key_Down: |
350 | // qWarning("b"); | 349 | // qWarning("b"); |
351 | // emit signalKeyDown(); | 350 | // emit signalKeyDown(); |
352 | // break; | 351 | // break; |
353 | default: | 352 | default: |
354 | QTable::keyPressEvent( e ); | 353 | QTable::keyPressEvent( e ); |
355 | } | 354 | } |
356 | 355 | ||
357 | } | 356 | } |
358 | 357 | ||
359 | void AbTable::moveTo( char c ) | 358 | void AbTable::moveTo( char c ) |
360 | { | 359 | { |
361 | qWarning( "void AbTable::moveTo( char c ) NOT IMPLEMENTED !!" ); | 360 | qWarning( "void AbTable::moveTo( char c ) NOT IMPLEMENTED !!" ); |
362 | 361 | ||
363 | #if 0 | 362 | #if 0 |
364 | int rows = numRows(); | 363 | int rows = numRows(); |
365 | QString value; | 364 | QString value; |
366 | AbTableItem *abi; | 365 | AbTableItem *abi; |
367 | int r; | 366 | int r; |
368 | if ( asc ) { | 367 | if ( asc ) { |
369 | r = 0; | 368 | r = 0; |
370 | while ( r < rows-1) { | 369 | while ( r < rows-1) { |
371 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 370 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
372 | QChar first = abi->key()[0]; | 371 | QChar first = abi->key()[0]; |
373 | //### is there a bug in QChar to char comparison??? | 372 | //### is there a bug in QChar to char comparison??? |
374 | if ( first.row() || first.cell() >= c ) | 373 | if ( first.row() || first.cell() >= c ) |
@@ -385,25 +384,25 @@ void AbTable::moveTo( char c ) | |||
385 | if ( first.row() || first.cell() >= c ) | 384 | if ( first.row() || first.cell() >= c ) |
386 | break; | 385 | break; |
387 | r--; | 386 | r--; |
388 | } | 387 | } |
389 | } | 388 | } |
390 | setCurrentCell( r, currentColumn() ); | 389 | setCurrentCell( r, currentColumn() ); |
391 | 390 | ||
392 | #endif | 391 | #endif |
393 | } | 392 | } |
394 | 393 | ||
395 | #if 0 | 394 | #if 0 |
396 | // Useless.. Nobody uses it .. (se) | 395 | // Useless.. Nobody uses it .. (se) |
397 | QString AbTable::findContactName( const OContact &entry ) | 396 | QString AbTable::findContactName( const Opie::OPimContact &entry ) |
398 | { | 397 | { |
399 | // We use the fileAs, then company, defaultEmail | 398 | // We use the fileAs, then company, defaultEmail |
400 | QString str; | 399 | QString str; |
401 | str = entry.fileAs(); | 400 | str = entry.fileAs(); |
402 | if ( str.isEmpty() ) { | 401 | if ( str.isEmpty() ) { |
403 | str = entry.company(); | 402 | str = entry.company(); |
404 | if ( str.isEmpty() ) { | 403 | if ( str.isEmpty() ) { |
405 | str = entry.defaultEmail(); | 404 | str = entry.defaultEmail(); |
406 | } | 405 | } |
407 | } | 406 | } |
408 | return str; | 407 | return str; |
409 | } | 408 | } |
@@ -466,35 +465,35 @@ void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) | |||
466 | // } | 465 | // } |
467 | 466 | ||
468 | // int AbTable::rowAt( int pos ) const | 467 | // int AbTable::rowAt( int pos ) const |
469 | // { | 468 | // { |
470 | // return QMIN( pos/18, numRows()-1 ); | 469 | // return QMIN( pos/18, numRows()-1 ); |
471 | // } | 470 | // } |
472 | 471 | ||
473 | 472 | ||
474 | 473 | ||
475 | void AbTable::fitColumns() | 474 | void AbTable::fitColumns() |
476 | { | 475 | { |
477 | qWarning( "void AbTable::fitColumns()" ); | 476 | qWarning( "void AbTable::fitColumns()" ); |
478 | int contentsWidth = visibleWidth() / 2; | 477 | int contentsWidth = visibleWidth() / 2; |
479 | // Fix to better value | 478 | // Fix to better value |
480 | // contentsWidth = 130; | 479 | // contentsWidth = 130; |
481 | 480 | ||
482 | setPaintingEnabled( FALSE ); | 481 | setPaintingEnabled( FALSE ); |
483 | 482 | ||
484 | if ( columnVisible == false ){ | 483 | if ( columnVisible == false ){ |
485 | showColumn(0); | 484 | showColumn(0); |
486 | columnVisible = true; | 485 | columnVisible = true; |
487 | } | 486 | } |
488 | 487 | ||
489 | //qWarning("Width: %d", contentsWidth); | 488 | //qWarning("Width: %d", contentsWidth); |
490 | 489 | ||
491 | setColumnWidth( 0, contentsWidth ); | 490 | setColumnWidth( 0, contentsWidth ); |
492 | adjustColumn(1); | 491 | adjustColumn(1); |
493 | if ( columnWidth(1) < contentsWidth ) | 492 | if ( columnWidth(1) < contentsWidth ) |
494 | setColumnWidth( 1, contentsWidth ); | 493 | setColumnWidth( 1, contentsWidth ); |
495 | 494 | ||
496 | setPaintingEnabled( TRUE ); | 495 | setPaintingEnabled( TRUE ); |
497 | } | 496 | } |
498 | 497 | ||
499 | void AbTable::show() | 498 | void AbTable::show() |
500 | { | 499 | { |
@@ -538,70 +537,70 @@ QStringList AbTable::choiceNames() const | |||
538 | } | 537 | } |
539 | 538 | ||
540 | #endif | 539 | #endif |
541 | void AbTable::setChoiceSelection( const QValueList<int>& list ) | 540 | void AbTable::setChoiceSelection( const QValueList<int>& list ) |
542 | { | 541 | { |
543 | intFields = list; | 542 | intFields = list; |
544 | } | 543 | } |
545 | 544 | ||
546 | QStringList AbTable::choiceSelection(int /*index*/) const | 545 | QStringList AbTable::choiceSelection(int /*index*/) const |
547 | { | 546 | { |
548 | QStringList r; | 547 | QStringList r; |
549 | /* ###### | 548 | /* ###### |
550 | 549 | ||
551 | QString selname = choicenames.at(index); | 550 | QString selname = choicenames.at(index); |
552 | for (each row) { | 551 | for (each row) { |
553 | OContact *c = contactForRow(row); | 552 | Opie::OPimContact *c = contactForRow(row); |
554 | if ( text(row,2) == selname ) { | 553 | if ( text(row,2) == selname ) { |
555 | r.append(c->email); | 554 | r.append(c->email); |
556 | } | 555 | } |
557 | } | 556 | } |
558 | 557 | ||
559 | */ | 558 | */ |
560 | return r; | 559 | return r; |
561 | } | 560 | } |
562 | 561 | ||
563 | 562 | ||
564 | void AbTable::updateVisible() | 563 | void AbTable::updateVisible() |
565 | { | 564 | { |
566 | //qWarning("void AbTable::updateVisible()"); | 565 | //qWarning("void AbTable::updateVisible()"); |
567 | 566 | ||
568 | int visible, | 567 | int visible, |
569 | totalRows, | 568 | totalRows, |
570 | row, | 569 | row, |
571 | selectedRow = 0; | 570 | selectedRow = 0; |
572 | 571 | ||
573 | visible = 0; | 572 | visible = 0; |
574 | 573 | ||
575 | setPaintingEnabled( FALSE ); | 574 | setPaintingEnabled( FALSE ); |
576 | 575 | ||
577 | realignTable(); | 576 | realignTable(); |
578 | 577 | ||
579 | totalRows = numRows(); | 578 | totalRows = numRows(); |
580 | for ( row = 0; row < totalRows; row++ ) { | 579 | for ( row = 0; row < totalRows; row++ ) { |
581 | if ( rowHeight(row) == 0 ) { | 580 | if ( rowHeight(row) == 0 ) { |
582 | showRow( row ); | 581 | showRow( row ); |
583 | adjustRow( row ); | 582 | adjustRow( row ); |
584 | if ( isSelected( row,0 ) || isSelected( row,1 ) ) | 583 | if ( isSelected( row,0 ) || isSelected( row,1 ) ) |
585 | selectedRow = row; | 584 | selectedRow = row; |
586 | } | 585 | } |
587 | visible++; | 586 | visible++; |
588 | } | 587 | } |
589 | 588 | ||
590 | if ( selectedRow ) | 589 | if ( selectedRow ) |
591 | setCurrentCell( selectedRow, 0 ); | 590 | setCurrentCell( selectedRow, 0 ); |
592 | 591 | ||
593 | if ( !visible ) | 592 | if ( !visible ) |
594 | setCurrentCell( -1, 0 ); | 593 | setCurrentCell( -1, 0 ); |
595 | 594 | ||
596 | setPaintingEnabled( TRUE ); | 595 | setPaintingEnabled( TRUE ); |
597 | } | 596 | } |
598 | 597 | ||
599 | 598 | ||
600 | void AbTable::setPaintingEnabled( bool e ) | 599 | void AbTable::setPaintingEnabled( bool e ) |
601 | { | 600 | { |
602 | //qWarning("IN void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested ); | 601 | //qWarning("IN void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested ); |
603 | 602 | ||
604 | if ( e ) { | 603 | if ( e ) { |
605 | if ( countNested > 0 ) | 604 | if ( countNested > 0 ) |
606 | --countNested; | 605 | --countNested; |
607 | if ( ! countNested ){ | 606 | if ( ! countNested ){ |
@@ -622,78 +621,78 @@ void AbTable::viewportPaintEvent( QPaintEvent* e ) { | |||
622 | //qWarning(" void AbTable::viewportPaintEvent( QPaintEvent* e ) -> %d", enablePainting); | 621 | //qWarning(" void AbTable::viewportPaintEvent( QPaintEvent* e ) -> %d", enablePainting); |
623 | if ( enablePainting ) | 622 | if ( enablePainting ) |
624 | QTable::viewportPaintEvent( e ); | 623 | QTable::viewportPaintEvent( e ); |
625 | } | 624 | } |
626 | 625 | ||
627 | void AbTable::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { | 626 | void AbTable::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { |
628 | const QColorGroup &cg = colorGroup(); | 627 | const QColorGroup &cg = colorGroup(); |
629 | 628 | ||
630 | p->save(); | 629 | p->save(); |
631 | 630 | ||
632 | //qWarning( "Paint row: %d", row ); | 631 | //qWarning( "Paint row: %d", row ); |
633 | 632 | ||
634 | OContact act_contact = m_viewList[row]; | 633 | Opie::OPimContact act_contact = m_viewList[row]; |
635 | 634 | ||
636 | // Paint alternating background bars | 635 | // Paint alternating background bars |
637 | if ( (row % 2 ) == 0 ) { | 636 | if ( (row % 2 ) == 0 ) { |
638 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); | 637 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); |
639 | p->setPen( QPen( cg.text() ) ); | 638 | p->setPen( QPen( cg.text() ) ); |
640 | } | 639 | } |
641 | else { | 640 | else { |
642 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) ); | 641 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) ); |
643 | p->setPen( QPen( cg.buttonText() ) ); | 642 | p->setPen( QPen( cg.buttonText() ) ); |
644 | } | 643 | } |
645 | 644 | ||
646 | QFont f = p->font(); | 645 | QFont f = p->font(); |
647 | QFontMetrics fm(f); | 646 | QFontMetrics fm(f); |
648 | 647 | ||
649 | int marg = 2; | 648 | int marg = 2; |
650 | int x = 0; | 649 | int x = 0; |
651 | int y = ( cr.height() - 14 ) / 2; | 650 | int y = ( cr.height() - 14 ) / 2; |
652 | 651 | ||
653 | QString nameText = act_contact.fileAs(); | 652 | QString nameText = act_contact.fileAs(); |
654 | 653 | ||
655 | switch( col ){ | 654 | switch( col ){ |
656 | case 0: | 655 | case 0: |
657 | p->drawText( x + marg,2 + fm.ascent(), nameText ); | 656 | p->drawText( x + marg,2 + fm.ascent(), nameText ); |
658 | break; | 657 | break; |
659 | case 1:{ | 658 | case 1:{ |
660 | 659 | ||
661 | ContactItem contactItem = findContactContact( act_contact, 0 ); | 660 | ContactItem contactItem = findContactContact( act_contact, 0 ); |
662 | QPixmap contactPic = contactItem.icon; /* pixmap( row, col ); */ | 661 | QPixmap contactPic = contactItem.icon; /* pixmap( row, col ); */ |
663 | QString contactText = contactItem.value; | 662 | QString contactText = contactItem.value; |
664 | 663 | ||
665 | if ( !contactPic.isNull() ) | 664 | if ( !contactPic.isNull() ) |
666 | { | 665 | { |
667 | p->drawPixmap( x + marg, y, contactPic ); | 666 | p->drawPixmap( x + marg, y, contactPic ); |
668 | p->drawText( x + marg + contactPic.width() | 667 | p->drawText( x + marg + contactPic.width() |
669 | + 4,2 + fm.ascent(), contactText ); | 668 | + 4,2 + fm.ascent(), contactText ); |
670 | } | 669 | } |
671 | else | 670 | else |
672 | { | 671 | { |
673 | p->drawText( x + marg,2 + fm.ascent(), contactText ); | 672 | p->drawText( x + marg,2 + fm.ascent(), contactText ); |
674 | } | 673 | } |
675 | } | 674 | } |
676 | break; | 675 | break; |
677 | 676 | ||
678 | } | 677 | } |
679 | p->restore(); | 678 | p->restore(); |
680 | } | 679 | } |
681 | 680 | ||
682 | void AbTable::rowHeightChanged( int row ) | 681 | void AbTable::rowHeightChanged( int row ) |
683 | { | 682 | { |
684 | if ( enablePainting ) | 683 | if ( enablePainting ) |
685 | QTable::rowHeightChanged( row ); | 684 | QTable::rowHeightChanged( row ); |
686 | } | 685 | } |
687 | ContactItem AbTable::findContactContact( const OContact &entry, int /* row */ ) | 686 | ContactItem AbTable::findContactContact( const Opie::OPimContact &entry, int /* row */ ) |
688 | { | 687 | { |
689 | 688 | ||
690 | ContactItem item; | 689 | ContactItem item; |
691 | 690 | ||
692 | item.value = ""; | 691 | item.value = ""; |
693 | 692 | ||
694 | for ( QValueList<int>::ConstIterator it = intFields.begin(); | 693 | for ( QValueList<int>::ConstIterator it = intFields.begin(); |
695 | it != intFields.end(); ++it ) { | 694 | it != intFields.end(); ++it ) { |
696 | switch ( *it ) { | 695 | switch ( *it ) { |
697 | default: | 696 | default: |
698 | break; | 697 | break; |
699 | case Qtopia::Title: | 698 | case Qtopia::Title: |