summaryrefslogtreecommitdiff
path: root/core/pim/addressbook/abtable.cpp
Unidiff
Diffstat (limited to 'core/pim/addressbook/abtable.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/abtable.cpp40
1 files changed, 20 insertions, 20 deletions
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp
index 00335ae..aec390d 100644
--- a/core/pim/addressbook/abtable.cpp
+++ b/core/pim/addressbook/abtable.cpp
@@ -117,56 +117,56 @@ void AbPickItem::setContentFromEditor( QWidget *w )
117 \brief QTable based class for showing a list of entries 117 \brief QTable based class for showing a list of entries
118*/ 118*/
119 119
120AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name ) 120AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name )
121 : QTable( parent, name ), 121 : QTable( parent, name ),
122 lastSortCol( -1 ), 122 lastSortCol( -1 ),
123 asc( TRUE ), 123 asc( TRUE ),
124 intFields( order ), 124 intFields( order ),
125 enablePainting( true ), 125 enablePainting( true ),
126 columnVisible( true ), 126 columnVisible( true ),
127 countNested( 0 ) 127 countNested( 0 )
128{ 128{
129 qWarning("C'tor start"); 129 //qWarning("C'tor start");
130 130
131 setSelectionMode( NoSelection ); 131 setSelectionMode( NoSelection );
132 init(); 132 init();
133 setSorting( TRUE ); 133 setSorting( TRUE );
134 connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), 134 connect( this, SIGNAL(clicked(int,int,int,const QPoint &)),
135 this, SLOT(itemClicked(int,int)) ); 135 this, SLOT(itemClicked(int,int)) );
136 136
137 contactList.clear(); 137 contactList.clear();
138 qWarning("C'tor end"); 138 //qWarning("C'tor end");
139} 139}
140 140
141AbTable::~AbTable() 141AbTable::~AbTable()
142{ 142{
143} 143}
144 144
145void AbTable::init() 145void AbTable::init()
146{ 146{
147 // :SX showChar = '\0'; 147 // :SX showChar = '\0';
148 setNumRows( 0 ); 148 setNumRows( 0 );
149 setNumCols( 2 ); 149 setNumCols( 2 );
150 150
151 horizontalHeader()->setLabel( 0, tr( "Full Name" )); 151 horizontalHeader()->setLabel( 0, tr( "Full Name" ));
152 horizontalHeader()->setLabel( 1, tr( "Contact" )); 152 horizontalHeader()->setLabel( 1, tr( "Contact" ));
153 setLeftMargin( 0 ); 153 setLeftMargin( 0 );
154 verticalHeader()->hide(); 154 verticalHeader()->hide();
155 columnVisible = true; 155 columnVisible = true;
156} 156}
157 157
158void AbTable::setContacts( const OContactAccess::List& viewList ) 158void AbTable::setContacts( const OContactAccess::List& viewList )
159{ 159{
160 qWarning("AbTable::setContacts()"); 160 //qWarning("AbTable::setContacts()");
161 161
162 clear(); 162 clear();
163 m_viewList = viewList; 163 m_viewList = viewList;
164 164
165 setSorting( false ); 165 setSorting( false );
166 setPaintingEnabled( FALSE ); 166 setPaintingEnabled( FALSE );
167 167
168 OContactAccess::List::Iterator it; 168 OContactAccess::List::Iterator it;
169 setNumRows( m_viewList.count() ); 169 setNumRows( m_viewList.count() );
170 int row = 0; 170 int row = 0;
171 for ( it = m_viewList.begin(); it != m_viewList.end(); ++it ) 171 for ( it = m_viewList.begin(); it != m_viewList.end(); ++it )
172 insertIntoTable( *it, row++ ); 172 insertIntoTable( *it, row++ );
@@ -174,25 +174,25 @@ void AbTable::setContacts( const OContactAccess::List& viewList )
174 setSorting( true ); 174 setSorting( true );
175 175
176 resort(); 176 resort();
177 177
178 updateVisible(); 178 updateVisible();
179 179
180 setPaintingEnabled( TRUE ); 180 setPaintingEnabled( TRUE );
181 181
182} 182}
183 183
184bool AbTable::selectContact( int UID ) 184bool AbTable::selectContact( int UID )
185{ 185{
186 qWarning( "AbTable::selectContact( %d )", UID ); 186 //qWarning( "AbTable::selectContact( %d )", UID );
187 int rows = numRows(); 187 int rows = numRows();
188 AbTableItem *abi; 188 AbTableItem *abi;
189 OContact* foundContact = 0l; 189 OContact* foundContact = 0l;
190 bool found = false; 190 bool found = false;
191 191
192 setPaintingEnabled( FALSE ); 192 setPaintingEnabled( FALSE );
193 for ( int r = 0; r < rows; ++r ) { 193 for ( int r = 0; r < rows; ++r ) {
194 abi = static_cast<AbTableItem*>( item(r, 0) ); 194 abi = static_cast<AbTableItem*>( item(r, 0) );
195 foundContact = &contactList[abi]; 195 foundContact = &contactList[abi];
196 if ( foundContact -> uid() == UID ){ 196 if ( foundContact -> uid() == UID ){
197 ensureCellVisible( r, 0 ); 197 ensureCellVisible( r, 0 );
198 setCurrentCell( r, 0 ); 198 setCurrentCell( r, 0 );
@@ -204,25 +204,25 @@ bool AbTable::selectContact( int UID )
204 if ( !found ){ 204 if ( !found ){
205 ensureCellVisible( 0,0 ); 205 ensureCellVisible( 0,0 );
206 setCurrentCell( 0, 0 ); 206 setCurrentCell( 0, 0 );
207 } 207 }
208 208
209 setPaintingEnabled( TRUE ); 209 setPaintingEnabled( TRUE );
210 210
211 return true; 211 return true;
212} 212}
213 213
214void AbTable::insertIntoTable( const OContact& cnt, int row ) 214void AbTable::insertIntoTable( const OContact& cnt, int row )
215{ 215{
216 qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row ); 216 //qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row );
217 QString strName, 217 QString strName,
218 strContact; 218 strContact;
219 219
220 strName = findContactName( cnt ); 220 strName = findContactName( cnt );
221 strContact = findContactContact( cnt, row ); 221 strContact = findContactContact( cnt, row );
222 222
223 AbTableItem *ati; 223 AbTableItem *ati;
224 ati = new AbTableItem( this, QTableItem::Never, strName, strContact); 224 ati = new AbTableItem( this, QTableItem::Never, strName, strContact);
225 contactList.insert( ati, cnt ); 225 contactList.insert( ati, cnt );
226 setItem( row, 0, ati ); 226 setItem( row, 0, ati );
227 ati = new AbTableItem( this, QTableItem::Never, strContact, strName); 227 ati = new AbTableItem( this, QTableItem::Never, strContact, strName);
228 setItem( row, 1, ati ); 228 setItem( row, 1, ati );
@@ -245,97 +245,97 @@ void AbTable::columnClicked( int col )
245 if ( col == lastSortCol ) { 245 if ( col == lastSortCol ) {
246 asc = !asc; 246 asc = !asc;
247 } else { 247 } else {
248 lastSortCol = col; 248 lastSortCol = col;
249 asc = TRUE; 249 asc = TRUE;
250 } 250 }
251 //QMessageBox::information( this, "resort", "columnClicked" ); 251 //QMessageBox::information( this, "resort", "columnClicked" );
252 resort(); 252 resort();
253} 253}
254 254
255void AbTable::resort() 255void AbTable::resort()
256{ 256{
257 qWarning( "void AbTable::resort()" ); 257 //qWarning( "void AbTable::resort()" );
258 setPaintingEnabled( FALSE ); 258 setPaintingEnabled( FALSE );
259 if ( sorting() ) { 259 if ( sorting() ) {
260 if ( lastSortCol == -1 ) 260 if ( lastSortCol == -1 )
261 lastSortCol = 0; 261 lastSortCol = 0;
262 sortColumn( lastSortCol, asc, TRUE ); 262 sortColumn( lastSortCol, asc, TRUE );
263 //QMessageBox::information( this, "resort", "resort" ); 263 //QMessageBox::information( this, "resort", "resort" );
264 updateVisible(); 264 updateVisible();
265 } 265 }
266 setPaintingEnabled( TRUE ); 266 setPaintingEnabled( TRUE );
267} 267}
268 268
269OContact AbTable::currentEntry() 269OContact AbTable::currentEntry()
270{ 270{
271 qWarning( "OContact AbTable::currentEntry()" ); 271 //qWarning( "OContact AbTable::currentEntry()" );
272 OContact cnt; 272 OContact cnt;
273 AbTableItem *abItem; 273 AbTableItem *abItem;
274 abItem = static_cast<AbTableItem*>(item( currentRow(), 0 )); 274 abItem = static_cast<AbTableItem*>(item( currentRow(), 0 ));
275 if ( abItem ) { 275 if ( abItem ) {
276 cnt = contactList[abItem]; 276 cnt = contactList[abItem];
277 //cnt = contactList[currentRow()]; 277 //cnt = contactList[currentRow()];
278 } 278 }
279 return cnt; 279 return cnt;
280} 280}
281 281
282int AbTable::currentEntry_UID() 282int AbTable::currentEntry_UID()
283{ 283{
284 return ( currentEntry().uid() ); 284 return ( currentEntry().uid() );
285} 285}
286 286
287void AbTable::clear() 287void AbTable::clear()
288{ 288{
289 qWarning( "void AbTable::clear()" ); 289 //qWarning( "void AbTable::clear()" );
290 contactList.clear(); 290 contactList.clear();
291 291
292 setPaintingEnabled( FALSE ); 292 setPaintingEnabled( FALSE );
293 for ( int r = 0; r < numRows(); ++r ) { 293 for ( int r = 0; r < numRows(); ++r ) {
294 for ( int c = 0; c < numCols(); ++c ) { 294 for ( int c = 0; c < numCols(); ++c ) {
295 if ( cellWidget( r, c ) ) 295 if ( cellWidget( r, c ) )
296 clearCellWidget( r, c ); 296 clearCellWidget( r, c );
297 clearCell( r, c ); 297 clearCell( r, c );
298 } 298 }
299 } 299 }
300 setNumRows( 0 ); 300 setNumRows( 0 );
301 setPaintingEnabled( TRUE ); 301 setPaintingEnabled( TRUE );
302} 302}
303 303
304// Refresh updates column 2 if the contactsettings changed 304// Refresh updates column 2 if the contactsettings changed
305void AbTable::refresh() 305void AbTable::refresh()
306{ 306{
307 qWarning( "void AbTable::refresh()" ); 307 //qWarning( "void AbTable::refresh()" );
308 int rows = numRows(); 308 int rows = numRows();
309 QString value; 309 QString value;
310 AbTableItem *abi; 310 AbTableItem *abi;
311 311
312 setPaintingEnabled( FALSE ); 312 setPaintingEnabled( FALSE );
313 for ( int r = 0; r < rows; ++r ) { 313 for ( int r = 0; r < rows; ++r ) {
314 abi = static_cast<AbTableItem*>( item(r, 0) ); 314 abi = static_cast<AbTableItem*>( item(r, 0) );
315 value = findContactContact( contactList[abi], r ); 315 value = findContactContact( contactList[abi], r );
316 static_cast<AbTableItem*>( item(r, 1) )->setItem( value, abi->text() ); 316 static_cast<AbTableItem*>( item(r, 1) )->setItem( value, abi->text() );
317 } 317 }
318 resort(); 318 resort();
319 setPaintingEnabled( TRUE ); 319 setPaintingEnabled( TRUE );
320} 320}
321 321
322void AbTable::keyPressEvent( QKeyEvent *e ) 322void AbTable::keyPressEvent( QKeyEvent *e )
323{ 323{
324 char key = toupper( e->ascii() ); 324 char key = toupper( e->ascii() );
325 325
326 if ( key >= 'A' && key <= 'Z' ) 326 if ( key >= 'A' && key <= 'Z' )
327 moveTo( key ); 327 moveTo( key );
328 328
329 qWarning("Received key .."); 329 //qWarning("Received key ..");
330 switch( e->key() ) { 330 switch( e->key() ) {
331 case Qt::Key_Space: 331 case Qt::Key_Space:
332 case Qt::Key_Return: 332 case Qt::Key_Return:
333 case Qt::Key_Enter: 333 case Qt::Key_Enter:
334 emit signalSwitch(); 334 emit signalSwitch();
335 break; 335 break;
336 // case Qt::Key_Up: 336 // case Qt::Key_Up:
337 // qWarning("a"); 337 // qWarning("a");
338 // emit signalKeyUp(); 338 // emit signalKeyUp();
339 // break; 339 // break;
340 // case Qt::Key_Down: 340 // case Qt::Key_Down:
341 // qWarning("b"); 341 // qWarning("b");
@@ -402,25 +402,25 @@ void AbTable::resizeRows() {
402 if (numRows()) { 402 if (numRows()) {
403 for (int i = 0; i < numRows(); i++) { 403 for (int i = 0; i < numRows(); i++) {
404 setRowHeight( i, size ); 404 setRowHeight( i, size );
405 } 405 }
406 } 406 }
407 updateVisible(); 407 updateVisible();
408 */ 408 */
409} 409}
410 410
411 411
412void AbTable::realignTable() 412void AbTable::realignTable()
413{ 413{
414 qWarning( "void AbTable::realignTable()" ); 414 //qWarning( "void AbTable::realignTable()" );
415 415
416 setPaintingEnabled( FALSE ); 416 setPaintingEnabled( FALSE );
417 417
418 resizeRows(); 418 resizeRows();
419 fitColumns(); 419 fitColumns();
420 420
421 setPaintingEnabled( TRUE ); 421 setPaintingEnabled( TRUE );
422 422
423} 423}
424 424
425 425
426 426
@@ -452,75 +452,75 @@ void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch )
452// return 18*row; 452// return 18*row;
453// } 453// }
454 454
455// int AbTable::rowAt( int pos ) const 455// int AbTable::rowAt( int pos ) const
456// { 456// {
457// return QMIN( pos/18, numRows()-1 ); 457// return QMIN( pos/18, numRows()-1 );
458// } 458// }
459 459
460 460
461 461
462void AbTable::fitColumns() 462void AbTable::fitColumns()
463{ 463{
464 qWarning( "void AbTable::fitColumns()" ); 464 //qWarning( "void AbTable::fitColumns()" );
465 int contentsWidth = visibleWidth() / 2; // :SX Why too low 465 int contentsWidth = visibleWidth() / 2; // :SX Why too low
466 // Fix to better value 466 // Fix to better value
467 // contentsWidth = 130; 467 // contentsWidth = 130;
468 468
469 setPaintingEnabled( FALSE ); 469 setPaintingEnabled( FALSE );
470 470
471 if ( columnVisible == false ){ 471 if ( columnVisible == false ){
472 showColumn(0); 472 showColumn(0);
473 columnVisible = true; 473 columnVisible = true;
474 } 474 }
475 475
476 qWarning("Width: %d", contentsWidth); 476 //qWarning("Width: %d", contentsWidth);
477 477
478 setColumnWidth( 0, contentsWidth ); 478 setColumnWidth( 0, contentsWidth );
479 adjustColumn(1); 479 adjustColumn(1);
480 if ( columnWidth(1) < contentsWidth ) 480 if ( columnWidth(1) < contentsWidth )
481 setColumnWidth( 1, contentsWidth ); 481 setColumnWidth( 1, contentsWidth );
482 482
483 setPaintingEnabled( TRUE ); 483 setPaintingEnabled( TRUE );
484} 484}
485 485
486void AbTable::show() 486void AbTable::show()
487{ 487{
488 qWarning( "void AbTable::show()" ); 488 //qWarning( "void AbTable::show()" );
489 realignTable(); 489 realignTable();
490 QTable::show(); 490 QTable::show();
491} 491}
492 492
493void AbTable::setChoiceNames( const QStringList& list) 493void AbTable::setChoiceNames( const QStringList& list)
494{ 494{
495 choicenames = list; 495 choicenames = list;
496 if ( choicenames.isEmpty() ) { 496 if ( choicenames.isEmpty() ) {
497 // hide pick column 497 // hide pick column
498 setNumCols( 2 ); 498 setNumCols( 2 );
499 } else { 499 } else {
500 // show pick column 500 // show pick column
501 setNumCols( 3 ); 501 setNumCols( 3 );
502 setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 ); 502 setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 );
503 horizontalHeader()->setLabel( 2, tr( "Pick" )); 503 horizontalHeader()->setLabel( 2, tr( "Pick" ));
504 } 504 }
505 fitColumns(); 505 fitColumns();
506} 506}
507 507
508void AbTable::itemClicked(int,int col) 508void AbTable::itemClicked(int,int col)
509{ 509{
510 qWarning( "AbTable::itemClicked(int, col:%d)", col); 510 //qWarning( "AbTable::itemClicked(int, col:%d)", col);
511 if ( col == 2 ) { 511 if ( col == 2 ) {
512 return; 512 return;
513 } else { 513 } else {
514 qWarning ("Emitting signalSwitch()"); 514 // qWarning ("Emitting signalSwitch()");
515 emit signalSwitch(); 515 emit signalSwitch();
516 } 516 }
517} 517}
518 518
519QStringList AbTable::choiceNames() const 519QStringList AbTable::choiceNames() const
520{ 520{
521 return choicenames; 521 return choicenames;
522} 522}
523 523
524void AbTable::setChoiceSelection( const QValueList<int>& list ) 524void AbTable::setChoiceSelection( const QValueList<int>& list )
525{ 525{
526 intFields = list; 526 intFields = list;
@@ -539,25 +539,25 @@ QStringList AbTable::choiceSelection(int /*index*/) const
539 } 539 }
540 } 540 }
541 541
542 */ 542 */
543 return r; 543 return r;
544} 544}
545 545
546 546
547 547
548 548
549void AbTable::updateVisible() 549void AbTable::updateVisible()
550{ 550{
551 qWarning("void AbTable::updateVisible()"); 551 //qWarning("void AbTable::updateVisible()");
552 552
553 int visible, 553 int visible,
554 totalRows, 554 totalRows,
555 row, 555 row,
556 selectedRow = 0; 556 selectedRow = 0;
557 557
558 visible = 0; 558 visible = 0;
559 559
560 setPaintingEnabled( FALSE ); 560 setPaintingEnabled( FALSE );
561 561
562 realignTable(); 562 realignTable();
563 563
@@ -577,45 +577,45 @@ void AbTable::updateVisible()
577 577
578 if ( !visible ) 578 if ( !visible )
579 setCurrentCell( -1, 0 ); 579 setCurrentCell( -1, 0 );
580 580
581 setPaintingEnabled( TRUE ); 581 setPaintingEnabled( TRUE );
582 582
583 583
584} 584}
585 585
586 586
587void AbTable::setPaintingEnabled( bool e ) 587void AbTable::setPaintingEnabled( bool e )
588{ 588{
589 qWarning("IN void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested ); 589 //qWarning("IN void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested );
590 590
591 if ( e ) { 591 if ( e ) {
592 if ( countNested > 0 ) 592 if ( countNested > 0 )
593 --countNested; 593 --countNested;
594 if ( ! countNested ){ 594 if ( ! countNested ){
595 setUpdatesEnabled( true ); 595 setUpdatesEnabled( true );
596 enablePainting = true; 596 enablePainting = true;
597 rowHeightChanged( 0 ); 597 rowHeightChanged( 0 );
598 viewport()->update(); 598 viewport()->update();
599 } 599 }
600 } else { 600 } else {
601 ++countNested; 601 ++countNested;
602 enablePainting = false; 602 enablePainting = false;
603 setUpdatesEnabled( false ); 603 setUpdatesEnabled( false );
604 } 604 }
605 qWarning("OUT void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested ); 605 //qWarning("OUT void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested );
606} 606}
607 607
608void AbTable::viewportPaintEvent( QPaintEvent* e ) { 608void AbTable::viewportPaintEvent( QPaintEvent* e ) {
609 qWarning(" void AbTable::viewportPaintEvent( QPaintEvent* e ) -> %d", enablePainting); 609 //qWarning(" void AbTable::viewportPaintEvent( QPaintEvent* e ) -> %d", enablePainting);
610 if ( enablePainting ) 610 if ( enablePainting )
611 QTable::viewportPaintEvent( e ); 611 QTable::viewportPaintEvent( e );
612} 612}
613 613
614 614
615 615
616void AbTable::rowHeightChanged( int row ) 616void AbTable::rowHeightChanged( int row )
617{ 617{
618 if ( enablePainting ) 618 if ( enablePainting )
619 QTable::rowHeightChanged( row ); 619 QTable::rowHeightChanged( row );
620} 620}
621QString AbTable::findContactContact( const OContact &entry, int /* row */ ) 621QString AbTable::findContactContact( const OContact &entry, int /* row */ )