Diffstat (limited to 'core/pim/addressbook/abtable.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/addressbook/abtable.cpp | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp index 3fb2214..30d749c 100644 --- a/core/pim/addressbook/abtable.cpp +++ b/core/pim/addressbook/abtable.cpp | |||
@@ -100,141 +100,141 @@ void AbPickItem::setContentFromEditor( QWidget *w ) | |||
100 | { | 100 | { |
101 | if ( w->inherits("QComboBox") ) | 101 | if ( w->inherits("QComboBox") ) |
102 | setText( ( (QComboBox*)w )->currentText() ); | 102 | setText( ( (QComboBox*)w )->currentText() ); |
103 | else | 103 | else |
104 | QTableItem::setContentFromEditor( w ); | 104 | QTableItem::setContentFromEditor( w ); |
105 | } | 105 | } |
106 | 106 | ||
107 | #endif | 107 | #endif |
108 | 108 | ||
109 | /*! | 109 | /*! |
110 | \class AbTable abtable.h | 110 | \class AbTable abtable.h |
111 | 111 | ||
112 | \brief QTable based class for showing a list of entries | 112 | \brief QTable based class for showing a list of entries |
113 | */ | 113 | */ |
114 | 114 | ||
115 | AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name ) | 115 | AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name ) |
116 | : QTable( parent, name ), | 116 | : QTable( parent, name ), |
117 | lastSortCol( -1 ), | 117 | lastSortCol( -1 ), |
118 | asc( TRUE ), | 118 | asc( TRUE ), |
119 | intFields( order ), | 119 | intFields( order ), |
120 | enablePainting( true ), | 120 | enablePainting( true ), |
121 | columnVisible( true ), | 121 | columnVisible( true ), |
122 | countNested( 0 ) | 122 | countNested( 0 ) |
123 | { | 123 | { |
124 | //owarn << "C'tor start" << oendl; | 124 | //odebug << "C'tor start" << oendl; |
125 | setSelectionMode( NoSelection ); | 125 | setSelectionMode( NoSelection ); |
126 | init(); | 126 | init(); |
127 | setSorting( TRUE ); | 127 | setSorting( TRUE ); |
128 | connect( this, SIGNAL(clicked(int,int,int,const QPoint&)), | 128 | connect( this, SIGNAL(clicked(int,int,int,const QPoint&)), |
129 | this, SLOT(itemClicked(int,int)) ); | 129 | this, SLOT(itemClicked(int,int)) ); |
130 | 130 | ||
131 | // contactList.clear(); | 131 | // contactList.clear(); |
132 | //owarn << "C'tor end" << oendl; | 132 | //odebug << "C'tor end" << oendl; |
133 | } | 133 | } |
134 | 134 | ||
135 | AbTable::~AbTable() | 135 | AbTable::~AbTable() |
136 | { | 136 | { |
137 | } | 137 | } |
138 | 138 | ||
139 | void AbTable::init() | 139 | void AbTable::init() |
140 | { | 140 | { |
141 | // :SX showChar = '\0'; | 141 | // :SX showChar = '\0'; |
142 | setNumRows( 0 ); | 142 | setNumRows( 0 ); |
143 | setNumCols( 2 ); | 143 | setNumCols( 2 ); |
144 | 144 | ||
145 | horizontalHeader()->setLabel( 0, tr( "Full Name" )); | 145 | horizontalHeader()->setLabel( 0, tr( "Full Name" )); |
146 | horizontalHeader()->setLabel( 1, tr( "Contact" )); | 146 | horizontalHeader()->setLabel( 1, tr( "Contact" )); |
147 | setLeftMargin( 0 ); | 147 | setLeftMargin( 0 ); |
148 | verticalHeader()->hide(); | 148 | verticalHeader()->hide(); |
149 | columnVisible = true; | 149 | columnVisible = true; |
150 | } | 150 | } |
151 | 151 | ||
152 | void AbTable::setContacts( const Opie::OPimContactAccess::List& viewList ) | 152 | void AbTable::setContacts( const Opie::OPimContactAccess::List& viewList ) |
153 | { | 153 | { |
154 | owarn << "AbTable::setContacts()" << oendl; | 154 | odebug << "AbTable::setContacts()" << oendl; |
155 | 155 | ||
156 | clear(); | 156 | clear(); |
157 | m_viewList = viewList; | 157 | m_viewList = viewList; |
158 | 158 | ||
159 | setSorting( false ); | 159 | setSorting( false ); |
160 | setPaintingEnabled( FALSE ); | 160 | setPaintingEnabled( FALSE ); |
161 | 161 | ||
162 | Opie::OPimContactAccess::List::Iterator it; | 162 | Opie::OPimContactAccess::List::Iterator it; |
163 | setNumRows( m_viewList.count() ); | 163 | setNumRows( m_viewList.count() ); |
164 | //int row = 0; | 164 | //int row = 0; |
165 | // for ( it = m_viewList.begin(); it != m_viewList.end(); ++it ) | 165 | // for ( it = m_viewList.begin(); it != m_viewList.end(); ++it ) |
166 | // insertIntoTable( *it, row++ ); | 166 | // insertIntoTable( *it, row++ ); |
167 | 167 | ||
168 | // setSorting( true ); | 168 | // setSorting( true ); |
169 | 169 | ||
170 | // resort(); | 170 | // resort(); |
171 | 171 | ||
172 | updateVisible(); | 172 | updateVisible(); |
173 | 173 | ||
174 | setPaintingEnabled( TRUE ); | 174 | setPaintingEnabled( TRUE ); |
175 | 175 | ||
176 | } | 176 | } |
177 | 177 | ||
178 | void AbTable::setOrderedList( const QValueList<int> ordered ) | 178 | void AbTable::setOrderedList( const QValueList<int> ordered ) |
179 | { | 179 | { |
180 | intFields = ordered; | 180 | intFields = ordered; |
181 | } | 181 | } |
182 | 182 | ||
183 | 183 | ||
184 | bool AbTable::selectContact( int UID ) | 184 | bool AbTable::selectContact( int UID ) |
185 | { | 185 | { |
186 | owarn << "AbTable::selectContact( " << UID << " )" << oendl; | 186 | odebug << "AbTable::selectContact( " << UID << " )" << oendl; |
187 | int rows = numRows(); | 187 | int rows = numRows(); |
188 | Opie::OPimContact* foundContact = 0l; | 188 | Opie::OPimContact* foundContact = 0l; |
189 | bool found = false; | 189 | bool found = false; |
190 | 190 | ||
191 | setPaintingEnabled( FALSE ); | 191 | setPaintingEnabled( FALSE ); |
192 | owarn << "Search start" << oendl; | 192 | odebug << "Search start" << oendl; |
193 | for ( int r = 0; r < rows; ++r ) { | 193 | for ( int r = 0; r < rows; ++r ) { |
194 | if ( m_viewList.uidAt( r ) == UID ){ | 194 | if ( m_viewList.uidAt( r ) == UID ){ |
195 | ensureCellVisible( r, 0 ); | 195 | ensureCellVisible( r, 0 ); |
196 | setCurrentCell( r, 0 ); | 196 | setCurrentCell( r, 0 ); |
197 | found = true; | 197 | found = true; |
198 | break; | 198 | break; |
199 | } | 199 | } |
200 | } | 200 | } |
201 | owarn << "Search end" << oendl; | 201 | odebug << "Search end" << oendl; |
202 | 202 | ||
203 | if ( !found ){ | 203 | if ( !found ){ |
204 | ensureCellVisible( 0,0 ); | 204 | ensureCellVisible( 0,0 ); |
205 | setCurrentCell( 0, 0 ); | 205 | setCurrentCell( 0, 0 ); |
206 | } | 206 | } |
207 | 207 | ||
208 | setPaintingEnabled( TRUE ); | 208 | setPaintingEnabled( TRUE ); |
209 | 209 | ||
210 | return true; | 210 | return true; |
211 | } | 211 | } |
212 | 212 | ||
213 | #if 0 | 213 | #if 0 |
214 | void AbTable::insertIntoTable( const Opie::OPimContact& cnt, int row ) | 214 | void AbTable::insertIntoTable( const Opie::OPimContact& cnt, int row ) |
215 | { | 215 | { |
216 | owarn << "void AbTable::insertIntoTable( const Opie::OPimContact& cnt, " | 216 | odebug << "void AbTable::insertIntoTable( const Opie::OPimContact& cnt, " |
217 | << row << " )" << oendl; | 217 | << row << " )" << oendl; |
218 | QString strName; | 218 | QString strName; |
219 | ContactItem contactItem; | 219 | ContactItem contactItem; |
220 | 220 | ||
221 | strName = findContactName( cnt ); | 221 | strName = findContactName( cnt ); |
222 | contactItem = findContactContact( cnt, row ); | 222 | contactItem = findContactContact( cnt, row ); |
223 | 223 | ||
224 | AbTableItem *ati; | 224 | AbTableItem *ati; |
225 | ati = new AbTableItem( this, QTableItem::Never, strName, contactItem.value ); | 225 | ati = new AbTableItem( this, QTableItem::Never, strName, contactItem.value ); |
226 | contactList.insert( ati, cnt ); | 226 | contactList.insert( ati, cnt ); |
227 | setItem( row, 0, ati ); | 227 | setItem( row, 0, ati ); |
228 | ati = new AbTableItem( this, QTableItem::Never, contactItem.value, strName); | 228 | ati = new AbTableItem( this, QTableItem::Never, contactItem.value, strName); |
229 | if ( !contactItem.icon.isNull() ) | 229 | if ( !contactItem.icon.isNull() ) |
230 | ati->setPixmap( contactItem.icon ); | 230 | ati->setPixmap( contactItem.icon ); |
231 | setItem( row, 1, ati ); | 231 | setItem( row, 1, ati ); |
232 | 232 | ||
233 | //### cannot do this; table only has two columns at this point | 233 | //### cannot do this; table only has two columns at this point |
234 | // setItem( row, 2, new AbPickItem( this ) ); | 234 | // setItem( row, 2, new AbPickItem( this ) ); |
235 | 235 | ||
236 | } | 236 | } |
237 | #endif | 237 | #endif |
238 | 238 | ||
239 | 239 | ||
240 | void AbTable::columnClicked( int col ) | 240 | void AbTable::columnClicked( int col ) |
@@ -262,49 +262,49 @@ void AbTable::resort() | |||
262 | setPaintingEnabled( FALSE ); | 262 | setPaintingEnabled( FALSE ); |
263 | if ( sorting() ) { | 263 | if ( sorting() ) { |
264 | if ( lastSortCol == -1 ) | 264 | if ( lastSortCol == -1 ) |
265 | lastSortCol = 0; | 265 | lastSortCol = 0; |
266 | sortColumn( lastSortCol, asc, TRUE ); | 266 | sortColumn( lastSortCol, asc, TRUE ); |
267 | //QMessageBox::information( this, "resort", "resort" ); | 267 | //QMessageBox::information( this, "resort", "resort" ); |
268 | updateVisible(); | 268 | updateVisible(); |
269 | } | 269 | } |
270 | setPaintingEnabled( TRUE ); | 270 | setPaintingEnabled( TRUE ); |
271 | #endif | 271 | #endif |
272 | } | 272 | } |
273 | 273 | ||
274 | Opie::OPimContact AbTable::currentEntry() | 274 | Opie::OPimContact AbTable::currentEntry() |
275 | { | 275 | { |
276 | return m_viewList[currentRow()]; | 276 | return m_viewList[currentRow()]; |
277 | } | 277 | } |
278 | 278 | ||
279 | int AbTable::currentEntry_UID() | 279 | int AbTable::currentEntry_UID() |
280 | { | 280 | { |
281 | return ( currentEntry().uid() ); | 281 | return ( currentEntry().uid() ); |
282 | } | 282 | } |
283 | 283 | ||
284 | void AbTable::clear() | 284 | void AbTable::clear() |
285 | { | 285 | { |
286 | owarn << "void AbTable::clear()" << oendl; | 286 | odebug << "void AbTable::clear()" << oendl; |
287 | // contactList.clear(); | 287 | // contactList.clear(); |
288 | 288 | ||
289 | setPaintingEnabled( FALSE ); | 289 | setPaintingEnabled( FALSE ); |
290 | for ( int r = 0; r < numRows(); ++r ) { | 290 | for ( int r = 0; r < numRows(); ++r ) { |
291 | for ( int c = 0; c < numCols(); ++c ) { | 291 | for ( int c = 0; c < numCols(); ++c ) { |
292 | if ( cellWidget( r, c ) ) | 292 | if ( cellWidget( r, c ) ) |
293 | clearCellWidget( r, c ); | 293 | clearCellWidget( r, c ); |
294 | clearCell( r, c ); | 294 | clearCell( r, c ); |
295 | } | 295 | } |
296 | } | 296 | } |
297 | setNumRows( 0 ); | 297 | setNumRows( 0 ); |
298 | setPaintingEnabled( TRUE ); | 298 | setPaintingEnabled( TRUE ); |
299 | } | 299 | } |
300 | 300 | ||
301 | // Refresh updates column 2 if the contactsettings changed | 301 | // Refresh updates column 2 if the contactsettings changed |
302 | void AbTable::refresh() | 302 | void AbTable::refresh() |
303 | { | 303 | { |
304 | owarn << "void AbTable::refresh() NOT IMPLEMENTED !!" << oendl; | 304 | owarn << "void AbTable::refresh() NOT IMPLEMENTED !!" << oendl; |
305 | 305 | ||
306 | #if 0 | 306 | #if 0 |
307 | int rows = numRows(); | 307 | int rows = numRows(); |
308 | AbTableItem *abi; | 308 | AbTableItem *abi; |
309 | ContactItem contactItem; | 309 | ContactItem contactItem; |
310 | 310 | ||
@@ -313,72 +313,72 @@ void AbTable::refresh() | |||
313 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 313 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
314 | contactItem = findContactContact( contactList[abi], r ); | 314 | contactItem = findContactContact( contactList[abi], r ); |
315 | static_cast<AbTableItem*>( item(r, 1) )->setItem( contactItem.value, abi->text() ); | 315 | static_cast<AbTableItem*>( item(r, 1) )->setItem( contactItem.value, abi->text() ); |
316 | if ( !contactItem.icon.isNull() ){ | 316 | if ( !contactItem.icon.isNull() ){ |
317 | static_cast<AbTableItem*>( item(r, 1) )-> | 317 | static_cast<AbTableItem*>( item(r, 1) )-> |
318 | setPixmap( contactItem.icon ); | 318 | setPixmap( contactItem.icon ); |
319 | }else{ | 319 | }else{ |
320 | static_cast<AbTableItem*>( item(r, 1) )-> | 320 | static_cast<AbTableItem*>( item(r, 1) )-> |
321 | setPixmap( QPixmap() ); | 321 | setPixmap( QPixmap() ); |
322 | } | 322 | } |
323 | } | 323 | } |
324 | resort(); | 324 | resort(); |
325 | setPaintingEnabled( TRUE ); | 325 | setPaintingEnabled( TRUE ); |
326 | 326 | ||
327 | #endif | 327 | #endif |
328 | } | 328 | } |
329 | 329 | ||
330 | void AbTable::keyPressEvent( QKeyEvent *e ) | 330 | void AbTable::keyPressEvent( QKeyEvent *e ) |
331 | { | 331 | { |
332 | char key = toupper( e->ascii() ); | 332 | char key = toupper( e->ascii() ); |
333 | 333 | ||
334 | if ( key >= 'A' && key <= 'Z' ) | 334 | if ( key >= 'A' && key <= 'Z' ) |
335 | moveTo( key ); | 335 | moveTo( key ); |
336 | 336 | ||
337 | // owarn << "Received key .." << oendl; | 337 | // odebug << "Received key .." << oendl; |
338 | switch( e->key() ) { | 338 | switch( e->key() ) { |
339 | case Qt::Key_Space: | 339 | case Qt::Key_Space: |
340 | case Qt::Key_Return: | 340 | case Qt::Key_Return: |
341 | case Qt::Key_Enter: | 341 | case Qt::Key_Enter: |
342 | emit signalSwitch(); | 342 | emit signalSwitch(); |
343 | break; | 343 | break; |
344 | // case Qt::Key_Up: | 344 | // case Qt::Key_Up: |
345 | // owarn << "a" << oendl; | 345 | // odebug << "a" << oendl; |
346 | // emit signalKeyUp(); | 346 | // emit signalKeyUp(); |
347 | // break; | 347 | // break; |
348 | // case Qt::Key_Down: | 348 | // case Qt::Key_Down: |
349 | // owarn << "b" << oendl; | 349 | // odebug << "b" << oendl; |
350 | // emit signalKeyDown(); | 350 | // emit signalKeyDown(); |
351 | // break; | 351 | // break; |
352 | default: | 352 | default: |
353 | QTable::keyPressEvent( e ); | 353 | QTable::keyPressEvent( e ); |
354 | } | 354 | } |
355 | 355 | ||
356 | } | 356 | } |
357 | 357 | ||
358 | void AbTable::moveTo( char c ) | 358 | void AbTable::moveTo( char c ) |
359 | { | 359 | { |
360 | owarn << "void AbTable::moveTo( char c ) NOT IMPLEMENTED !!" << oendl; | 360 | odebug << "void AbTable::moveTo( char c ) NOT IMPLEMENTED !!" << oendl; |
361 | 361 | ||
362 | #if 0 | 362 | #if 0 |
363 | int rows = numRows(); | 363 | int rows = numRows(); |
364 | QString value; | 364 | QString value; |
365 | AbTableItem *abi; | 365 | AbTableItem *abi; |
366 | int r; | 366 | int r; |
367 | if ( asc ) { | 367 | if ( asc ) { |
368 | r = 0; | 368 | r = 0; |
369 | while ( r < rows-1) { | 369 | while ( r < rows-1) { |
370 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 370 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
371 | QChar first = abi->key()[0]; | 371 | QChar first = abi->key()[0]; |
372 | //### is there a bug in QChar to char comparison??? | 372 | //### is there a bug in QChar to char comparison??? |
373 | if ( first.row() || first.cell() >= c ) | 373 | if ( first.row() || first.cell() >= c ) |
374 | break; | 374 | break; |
375 | r++; | 375 | r++; |
376 | } | 376 | } |
377 | } else { | 377 | } else { |
378 | //### should probably disable reverse sorting instead | 378 | //### should probably disable reverse sorting instead |
379 | r = rows - 1; | 379 | r = rows - 1; |
380 | while ( r > 0 ) { | 380 | while ( r > 0 ) { |
381 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 381 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
382 | QChar first = abi->key()[0]; | 382 | QChar first = abi->key()[0]; |
383 | //### is there a bug in QChar to char comparison??? | 383 | //### is there a bug in QChar to char comparison??? |
384 | if ( first.row() || first.cell() >= c ) | 384 | if ( first.row() || first.cell() >= c ) |
@@ -402,49 +402,49 @@ QString AbTable::findContactName( const Opie::OPimContact &entry ) | |||
402 | str = entry.company(); | 402 | str = entry.company(); |
403 | if ( str.isEmpty() ) { | 403 | if ( str.isEmpty() ) { |
404 | str = entry.defaultEmail(); | 404 | str = entry.defaultEmail(); |
405 | } | 405 | } |
406 | } | 406 | } |
407 | return str; | 407 | return str; |
408 | } | 408 | } |
409 | #endif | 409 | #endif |
410 | 410 | ||
411 | 411 | ||
412 | void AbTable::resizeRows() { | 412 | void AbTable::resizeRows() { |
413 | /* | 413 | /* |
414 | if (numRows()) { | 414 | if (numRows()) { |
415 | for (int i = 0; i < numRows(); i++) { | 415 | for (int i = 0; i < numRows(); i++) { |
416 | setRowHeight( i, size ); | 416 | setRowHeight( i, size ); |
417 | } | 417 | } |
418 | } | 418 | } |
419 | updateVisible(); | 419 | updateVisible(); |
420 | */ | 420 | */ |
421 | } | 421 | } |
422 | 422 | ||
423 | 423 | ||
424 | void AbTable::realignTable() | 424 | void AbTable::realignTable() |
425 | { | 425 | { |
426 | //owarn << "void AbTable::realignTable()" << oendl; | 426 | //odebug << "void AbTable::realignTable()" << oendl; |
427 | 427 | ||
428 | setPaintingEnabled( FALSE ); | 428 | setPaintingEnabled( FALSE ); |
429 | 429 | ||
430 | resizeRows(); | 430 | resizeRows(); |
431 | fitColumns(); | 431 | fitColumns(); |
432 | 432 | ||
433 | setPaintingEnabled( TRUE ); | 433 | setPaintingEnabled( TRUE ); |
434 | 434 | ||
435 | } | 435 | } |
436 | 436 | ||
437 | 437 | ||
438 | 438 | ||
439 | 439 | ||
440 | #if QT_VERSION <= 230 | 440 | #if QT_VERSION <= 230 |
441 | #ifndef SINGLE_APP | 441 | #ifndef SINGLE_APP |
442 | void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) | 442 | void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) |
443 | { | 443 | { |
444 | // Region of the rect we should draw | 444 | // Region of the rect we should draw |
445 | QRegion reg( QRect( cx, cy, cw, ch ) ); | 445 | QRegion reg( QRect( cx, cy, cw, ch ) ); |
446 | // Subtract the table from it | 446 | // Subtract the table from it |
447 | reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) ); | 447 | reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) ); |
448 | // And draw the rectangles (transformed as needed) | 448 | // And draw the rectangles (transformed as needed) |
449 | QArray<QRect> r = reg.rects(); | 449 | QArray<QRect> r = reg.rects(); |
450 | for (unsigned int i=0; i<r.count(); i++) | 450 | for (unsigned int i=0; i<r.count(); i++) |
@@ -452,207 +452,207 @@ void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) | |||
452 | } | 452 | } |
453 | #endif | 453 | #endif |
454 | #endif | 454 | #endif |
455 | 455 | ||
456 | 456 | ||
457 | // int AbTable::rowHeight( int ) const | 457 | // int AbTable::rowHeight( int ) const |
458 | // { | 458 | // { |
459 | // return 18; | 459 | // return 18; |
460 | // } | 460 | // } |
461 | 461 | ||
462 | // int AbTable::rowPos( int row ) const | 462 | // int AbTable::rowPos( int row ) const |
463 | // { | 463 | // { |
464 | // return 18*row; | 464 | // return 18*row; |
465 | // } | 465 | // } |
466 | 466 | ||
467 | // int AbTable::rowAt( int pos ) const | 467 | // int AbTable::rowAt( int pos ) const |
468 | // { | 468 | // { |
469 | // return QMIN( pos/18, numRows()-1 ); | 469 | // return QMIN( pos/18, numRows()-1 ); |
470 | // } | 470 | // } |
471 | 471 | ||
472 | 472 | ||
473 | 473 | ||
474 | void AbTable::fitColumns() | 474 | void AbTable::fitColumns() |
475 | { | 475 | { |
476 | owarn << "void AbTable::fitColumns()" << oendl; | 476 | odebug << "void AbTable::fitColumns()" << oendl; |
477 | int contentsWidth = visibleWidth() / 2; | 477 | int contentsWidth = visibleWidth() / 2; |
478 | // Fix to better value | 478 | // Fix to better value |
479 | // contentsWidth = 130; | 479 | // contentsWidth = 130; |
480 | 480 | ||
481 | setPaintingEnabled( FALSE ); | 481 | setPaintingEnabled( FALSE ); |
482 | 482 | ||
483 | if ( columnVisible == false ){ | 483 | if ( columnVisible == false ){ |
484 | showColumn(0); | 484 | showColumn(0); |
485 | columnVisible = true; | 485 | columnVisible = true; |
486 | } | 486 | } |
487 | 487 | ||
488 | //owarn << "Width: " << contentsWidth << oendl; | 488 | //odebug << "Width: " << contentsWidth << oendl; |
489 | 489 | ||
490 | setColumnWidth( 0, contentsWidth ); | 490 | setColumnWidth( 0, contentsWidth ); |
491 | adjustColumn(1); | 491 | adjustColumn(1); |
492 | if ( columnWidth(1) < contentsWidth ) | 492 | if ( columnWidth(1) < contentsWidth ) |
493 | setColumnWidth( 1, contentsWidth ); | 493 | setColumnWidth( 1, contentsWidth ); |
494 | 494 | ||
495 | setPaintingEnabled( TRUE ); | 495 | setPaintingEnabled( TRUE ); |
496 | } | 496 | } |
497 | 497 | ||
498 | void AbTable::show() | 498 | void AbTable::show() |
499 | { | 499 | { |
500 | //owarn << "void AbTable::show()" << oendl; | 500 | //odebug << "void AbTable::show()" << oendl; |
501 | realignTable(); | 501 | realignTable(); |
502 | QTable::show(); | 502 | QTable::show(); |
503 | } | 503 | } |
504 | 504 | ||
505 | #if 0 | 505 | #if 0 |
506 | void AbTable::setChoiceNames( const QStringList& list) | 506 | void AbTable::setChoiceNames( const QStringList& list) |
507 | { | 507 | { |
508 | choicenames = list; | 508 | choicenames = list; |
509 | if ( choicenames.isEmpty() ) { | 509 | if ( choicenames.isEmpty() ) { |
510 | // hide pick column | 510 | // hide pick column |
511 | setNumCols( 2 ); | 511 | setNumCols( 2 ); |
512 | } else { | 512 | } else { |
513 | // show pick column | 513 | // show pick column |
514 | setNumCols( 3 ); | 514 | setNumCols( 3 ); |
515 | setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 ); | 515 | setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 ); |
516 | horizontalHeader()->setLabel( 2, tr( "Pick" )); | 516 | horizontalHeader()->setLabel( 2, tr( "Pick" )); |
517 | } | 517 | } |
518 | fitColumns(); | 518 | fitColumns(); |
519 | } | 519 | } |
520 | #endif | 520 | #endif |
521 | 521 | ||
522 | void AbTable::itemClicked(int,int col) | 522 | void AbTable::itemClicked(int,int col) |
523 | { | 523 | { |
524 | //owarn << "AbTable::itemClicked(int, col: " << col << ")" << oendl; | 524 | //odebug << "AbTable::itemClicked(int, col: " << col << ")" << oendl; |
525 | if ( col == 2 ) { | 525 | if ( col == 2 ) { |
526 | return; | 526 | return; |
527 | } else { | 527 | } else { |
528 | //owarn << "Emitting signalSwitch()" << oendl; | 528 | //odebug << "Emitting signalSwitch()" << oendl; |
529 | emit signalSwitch(); | 529 | emit signalSwitch(); |
530 | } | 530 | } |
531 | } | 531 | } |
532 | 532 | ||
533 | #if 0 | 533 | #if 0 |
534 | QStringList AbTable::choiceNames() const | 534 | QStringList AbTable::choiceNames() const |
535 | { | 535 | { |
536 | return choicenames; | 536 | return choicenames; |
537 | } | 537 | } |
538 | 538 | ||
539 | #endif | 539 | #endif |
540 | void AbTable::setChoiceSelection( const QValueList<int>& list ) | 540 | void AbTable::setChoiceSelection( const QValueList<int>& list ) |
541 | { | 541 | { |
542 | intFields = list; | 542 | intFields = list; |
543 | } | 543 | } |
544 | 544 | ||
545 | QStringList AbTable::choiceSelection(int /*index*/) const | 545 | QStringList AbTable::choiceSelection(int /*index*/) const |
546 | { | 546 | { |
547 | QStringList r; | 547 | QStringList r; |
548 | /* ###### | 548 | /* ###### |
549 | 549 | ||
550 | QString selname = choicenames.at(index); | 550 | QString selname = choicenames.at(index); |
551 | for (each row) { | 551 | for (each row) { |
552 | Opie::OPimContact *c = contactForRow(row); | 552 | Opie::OPimContact *c = contactForRow(row); |
553 | if ( text(row,2) == selname ) { | 553 | if ( text(row,2) == selname ) { |
554 | r.append(c->email); | 554 | r.append(c->email); |
555 | } | 555 | } |
556 | } | 556 | } |
557 | 557 | ||
558 | */ | 558 | */ |
559 | return r; | 559 | return r; |
560 | } | 560 | } |
561 | 561 | ||
562 | 562 | ||
563 | void AbTable::updateVisible() | 563 | void AbTable::updateVisible() |
564 | { | 564 | { |
565 | //owarn << "void AbTable::updateVisible()" << oendl; | 565 | //odebug << "void AbTable::updateVisible()" << oendl; |
566 | 566 | ||
567 | int visible, | 567 | int visible, |
568 | totalRows, | 568 | totalRows, |
569 | row, | 569 | row, |
570 | selectedRow = 0; | 570 | selectedRow = 0; |
571 | 571 | ||
572 | visible = 0; | 572 | visible = 0; |
573 | 573 | ||
574 | setPaintingEnabled( FALSE ); | 574 | setPaintingEnabled( FALSE ); |
575 | 575 | ||
576 | realignTable(); | 576 | realignTable(); |
577 | 577 | ||
578 | totalRows = numRows(); | 578 | totalRows = numRows(); |
579 | for ( row = 0; row < totalRows; row++ ) { | 579 | for ( row = 0; row < totalRows; row++ ) { |
580 | if ( rowHeight(row) == 0 ) { | 580 | if ( rowHeight(row) == 0 ) { |
581 | showRow( row ); | 581 | showRow( row ); |
582 | adjustRow( row ); | 582 | adjustRow( row ); |
583 | if ( isSelected( row,0 ) || isSelected( row,1 ) ) | 583 | if ( isSelected( row,0 ) || isSelected( row,1 ) ) |
584 | selectedRow = row; | 584 | selectedRow = row; |
585 | } | 585 | } |
586 | visible++; | 586 | visible++; |
587 | } | 587 | } |
588 | 588 | ||
589 | if ( selectedRow ) | 589 | if ( selectedRow ) |
590 | setCurrentCell( selectedRow, 0 ); | 590 | setCurrentCell( selectedRow, 0 ); |
591 | 591 | ||
592 | if ( !visible ) | 592 | if ( !visible ) |
593 | setCurrentCell( -1, 0 ); | 593 | setCurrentCell( -1, 0 ); |
594 | 594 | ||
595 | setPaintingEnabled( TRUE ); | 595 | setPaintingEnabled( TRUE ); |
596 | } | 596 | } |
597 | 597 | ||
598 | 598 | ||
599 | void AbTable::setPaintingEnabled( bool e ) | 599 | void AbTable::setPaintingEnabled( bool e ) |
600 | { | 600 | { |
601 | //owarn << "IN void AbTable::setPaintingEnabled( " << e << " )->Nested: " | 601 | //odebug << "IN void AbTable::setPaintingEnabled( " << e << " )->Nested: " |
602 | // << countNested << oendl; | 602 | // << countNested << oendl; |
603 | 603 | ||
604 | if ( e ) { | 604 | if ( e ) { |
605 | if ( countNested > 0 ) | 605 | if ( countNested > 0 ) |
606 | --countNested; | 606 | --countNested; |
607 | if ( ! countNested ){ | 607 | if ( ! countNested ){ |
608 | setUpdatesEnabled( true ); | 608 | setUpdatesEnabled( true ); |
609 | enablePainting = true; | 609 | enablePainting = true; |
610 | rowHeightChanged( 0 ); | 610 | rowHeightChanged( 0 ); |
611 | viewport()->update(); | 611 | viewport()->update(); |
612 | } | 612 | } |
613 | } else { | 613 | } else { |
614 | ++countNested; | 614 | ++countNested; |
615 | enablePainting = false; | 615 | enablePainting = false; |
616 | setUpdatesEnabled( false ); | 616 | setUpdatesEnabled( false ); |
617 | } | 617 | } |
618 | //owarn << "OUT void AbTable::setPaintingEnabled( " << e << " )->Nested: " | 618 | //odebug << "OUT void AbTable::setPaintingEnabled( " << e << " )->Nested: " |
619 | // << countNested << oendl; | 619 | // << countNested << oendl; |
620 | } | 620 | } |
621 | 621 | ||
622 | void AbTable::viewportPaintEvent( QPaintEvent* e ) { | 622 | void AbTable::viewportPaintEvent( QPaintEvent* e ) { |
623 | //owarn << "void AbTable::viewportPaintEvent( QPaintEvent* e ) -> " | 623 | //odebug << "void AbTable::viewportPaintEvent( QPaintEvent* e ) -> " |
624 | // << enablePainting << oendl; | 624 | // << enablePainting << oendl; |
625 | if ( enablePainting ) | 625 | if ( enablePainting ) |
626 | QTable::viewportPaintEvent( e ); | 626 | QTable::viewportPaintEvent( e ); |
627 | } | 627 | } |
628 | 628 | ||
629 | void AbTable::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { | 629 | void AbTable::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { |
630 | const QColorGroup &cg = colorGroup(); | 630 | const QColorGroup &cg = colorGroup(); |
631 | 631 | ||
632 | p->save(); | 632 | p->save(); |
633 | 633 | ||
634 | //owarn << "Paint row: " << row << oendl; | 634 | //odebug << "Paint row: " << row << oendl; |
635 | 635 | ||
636 | Opie::OPimContact act_contact = m_viewList[row]; | 636 | Opie::OPimContact act_contact = m_viewList[row]; |
637 | 637 | ||
638 | // Paint alternating background bars | 638 | // Paint alternating background bars |
639 | if ( (row % 2 ) == 0 ) { | 639 | if ( (row % 2 ) == 0 ) { |
640 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); | 640 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); |
641 | p->setPen( QPen( cg.text() ) ); | 641 | p->setPen( QPen( cg.text() ) ); |
642 | } | 642 | } |
643 | else { | 643 | else { |
644 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) ); | 644 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) ); |
645 | p->setPen( QPen( cg.buttonText() ) ); | 645 | p->setPen( QPen( cg.buttonText() ) ); |
646 | } | 646 | } |
647 | 647 | ||
648 | QFont f = p->font(); | 648 | QFont f = p->font(); |
649 | QFontMetrics fm(f); | 649 | QFontMetrics fm(f); |
650 | 650 | ||
651 | int marg = 2; | 651 | int marg = 2; |
652 | int x = 0; | 652 | int x = 0; |
653 | int y = ( cr.height() - 14 ) / 2; | 653 | int y = ( cr.height() - 14 ) / 2; |
654 | 654 | ||
655 | QString nameText = act_contact.fileAs(); | 655 | QString nameText = act_contact.fileAs(); |
656 | 656 | ||
657 | switch( col ){ | 657 | switch( col ){ |
658 | case 0: | 658 | case 0: |