summaryrefslogtreecommitdiff
path: root/core/pim/addressbook/abtable.cpp
Unidiff
Diffstat (limited to 'core/pim/addressbook/abtable.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/pim/addressbook/abtable.cpp101
1 files changed, 64 insertions, 37 deletions
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp
index a2617fa..4705c78 100644
--- a/core/pim/addressbook/abtable.cpp
+++ b/core/pim/addressbook/abtable.cpp
@@ -44,6 +44,8 @@
44 44
45#include <ctype.h> //toupper() for key hack 45#include <ctype.h> //toupper() for key hack
46 46
47#if 0
48
47/*! 49/*!
48 \class AbTableItem abtable.h 50 \class AbTableItem abtable.h
49 51
@@ -112,6 +114,8 @@ void AbPickItem::setContentFromEditor( QWidget *w )
112 QTableItem::setContentFromEditor( w ); 114 QTableItem::setContentFromEditor( w );
113} 115}
114 116
117#endif
118
115/*! 119/*!
116 \class AbTable abtable.h 120 \class AbTable abtable.h
117 121
@@ -135,7 +139,7 @@ AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name
135 connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), 139 connect( this, SIGNAL(clicked(int,int,int,const QPoint &)),
136 this, SLOT(itemClicked(int,int)) ); 140 this, SLOT(itemClicked(int,int)) );
137 141
138 contactList.clear(); 142 // contactList.clear();
139 //qWarning("C'tor end"); 143 //qWarning("C'tor end");
140} 144}
141 145
@@ -158,7 +162,7 @@ void AbTable::init()
158 162
159void AbTable::setContacts( const OContactAccess::List& viewList ) 163void AbTable::setContacts( const OContactAccess::List& viewList )
160{ 164{
161 //qWarning("AbTable::setContacts()"); 165 qWarning("AbTable::setContacts()");
162 166
163 clear(); 167 clear();
164 m_viewList = viewList; 168 m_viewList = viewList;
@@ -168,13 +172,13 @@ void AbTable::setContacts( const OContactAccess::List& viewList )
168 172
169 OContactAccess::List::Iterator it; 173 OContactAccess::List::Iterator it;
170 setNumRows( m_viewList.count() ); 174 setNumRows( m_viewList.count() );
171 int row = 0; 175 //int row = 0;
172 for ( it = m_viewList.begin(); it != m_viewList.end(); ++it ) 176 // for ( it = m_viewList.begin(); it != m_viewList.end(); ++it )
173 insertIntoTable( *it, row++ ); 177 // insertIntoTable( *it, row++ );
174 178
175 setSorting( true ); 179 // setSorting( true );
176 180
177 resort(); 181 // resort();
178 182
179 updateVisible(); 183 updateVisible();
180 184
@@ -190,23 +194,22 @@ void AbTable::setOrderedList( const QValueList<int> ordered )
190 194
191bool AbTable::selectContact( int UID ) 195bool AbTable::selectContact( int UID )
192{ 196{
193 //qWarning( "AbTable::selectContact( %d )", UID ); 197 qWarning( "AbTable::selectContact( %d )", UID );
194 int rows = numRows(); 198 int rows = numRows();
195 AbTableItem *abi;
196 OContact* foundContact = 0l; 199 OContact* foundContact = 0l;
197 bool found = false; 200 bool found = false;
198 201
199 setPaintingEnabled( FALSE ); 202 setPaintingEnabled( FALSE );
203 qWarning( "search start" );
200 for ( int r = 0; r < rows; ++r ) { 204 for ( int r = 0; r < rows; ++r ) {
201 abi = static_cast<AbTableItem*>( item(r, 0) ); 205 if ( m_viewList.uidAt( r ) == UID ){
202 foundContact = &contactList[abi];
203 if ( foundContact -> uid() == UID ){
204 ensureCellVisible( r, 0 ); 206 ensureCellVisible( r, 0 );
205 setCurrentCell( r, 0 ); 207 setCurrentCell( r, 0 );
206 found = true; 208 found = true;
207 break; 209 break;
208 } 210 }
209 } 211 }
212 qWarning( "search end" );
210 213
211 if ( !found ){ 214 if ( !found ){
212 ensureCellVisible( 0,0 ); 215 ensureCellVisible( 0,0 );
@@ -218,9 +221,10 @@ bool AbTable::selectContact( int UID )
218 return true; 221 return true;
219} 222}
220 223
224#if 0
221void AbTable::insertIntoTable( const OContact& cnt, int row ) 225void AbTable::insertIntoTable( const OContact& cnt, int row )
222{ 226{
223 //qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row ); 227 qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row );
224 QString strName; 228 QString strName;
225 ContactItem contactItem; 229 ContactItem contactItem;
226 230
@@ -240,7 +244,7 @@ void AbTable::insertIntoTable( const OContact& cnt, int row )
240 // setItem( row, 2, new AbPickItem( this ) ); 244 // setItem( row, 2, new AbPickItem( this ) );
241 245
242} 246}
243 247#endif
244 248
245 249
246void AbTable::columnClicked( int col ) 250void AbTable::columnClicked( int col )
@@ -263,7 +267,8 @@ void AbTable::columnClicked( int col )
263 267
264void AbTable::resort() 268void AbTable::resort()
265{ 269{
266 //qWarning( "void AbTable::resort()" ); 270 qWarning( "void AbTable::resort() NOT POSSIBLE !!" );
271#if 0
267 setPaintingEnabled( FALSE ); 272 setPaintingEnabled( FALSE );
268 if ( sorting() ) { 273 if ( sorting() ) {
269 if ( lastSortCol == -1 ) 274 if ( lastSortCol == -1 )
@@ -273,19 +278,12 @@ void AbTable::resort()
273 updateVisible(); 278 updateVisible();
274 } 279 }
275 setPaintingEnabled( TRUE ); 280 setPaintingEnabled( TRUE );
281#endif
276} 282}
277 283
278OContact AbTable::currentEntry() 284OContact AbTable::currentEntry()
279{ 285{
280 //qWarning( "OContact AbTable::currentEntry()" ); 286 return m_viewList[currentRow()];
281 OContact cnt;
282 AbTableItem *abItem;
283 abItem = static_cast<AbTableItem*>(item( currentRow(), 0 ));
284 if ( abItem ) {
285 cnt = contactList[abItem];
286 //cnt = contactList[currentRow()];
287 }
288 return cnt;
289} 287}
290 288
291int AbTable::currentEntry_UID() 289int AbTable::currentEntry_UID()
@@ -295,8 +293,8 @@ int AbTable::currentEntry_UID()
295 293
296void AbTable::clear() 294void AbTable::clear()
297{ 295{
298 //qWarning( "void AbTable::clear()" ); 296 qWarning( "void AbTable::clear()" );
299 contactList.clear(); 297 // contactList.clear();
300 298
301 setPaintingEnabled( FALSE ); 299 setPaintingEnabled( FALSE );
302 for ( int r = 0; r < numRows(); ++r ) { 300 for ( int r = 0; r < numRows(); ++r ) {
@@ -313,7 +311,9 @@ void AbTable::clear()
313// Refresh updates column 2 if the contactsettings changed 311// Refresh updates column 2 if the contactsettings changed
314void AbTable::refresh() 312void AbTable::refresh()
315{ 313{
316 //qWarning( "void AbTable::refresh()" ); 314 qWarning( "void AbTable::refresh() NOT IMPLEMENTED !!" );
315
316#if 0
317 int rows = numRows(); 317 int rows = numRows();
318 AbTableItem *abi; 318 AbTableItem *abi;
319 ContactItem contactItem; 319 ContactItem contactItem;
@@ -333,6 +333,8 @@ void AbTable::refresh()
333 } 333 }
334 resort(); 334 resort();
335 setPaintingEnabled( TRUE ); 335 setPaintingEnabled( TRUE );
336
337#endif
336} 338}
337 339
338void AbTable::keyPressEvent( QKeyEvent *e ) 340void AbTable::keyPressEvent( QKeyEvent *e )
@@ -365,8 +367,9 @@ void AbTable::keyPressEvent( QKeyEvent *e )
365 367
366void AbTable::moveTo( char c ) 368void AbTable::moveTo( char c )
367{ 369{
368 qWarning( "void AbTable::moveTo( char c )" ); 370 qWarning( "void AbTable::moveTo( char c ) NOT IMPLEMENTED !!" );
369 371
372#if 0
370 int rows = numRows(); 373 int rows = numRows();
371 QString value; 374 QString value;
372 AbTableItem *abi; 375 AbTableItem *abi;
@@ -394,9 +397,12 @@ void AbTable::moveTo( char c )
394 } 397 }
395 } 398 }
396 setCurrentCell( r, currentColumn() ); 399 setCurrentCell( r, currentColumn() );
397}
398 400
401#endif
402}
399 403
404#if 0
405// Useless.. Nobody uses it .. (se)
400QString AbTable::findContactName( const OContact &entry ) 406QString AbTable::findContactName( const OContact &entry )
401{ 407{
402 // We use the fileAs, then company, defaultEmail 408 // We use the fileAs, then company, defaultEmail
@@ -410,7 +416,7 @@ QString AbTable::findContactName( const OContact &entry )
410 } 416 }
411 return str; 417 return str;
412} 418}
413 419#endif
414 420
415 421
416void AbTable::resizeRows() { 422void AbTable::resizeRows() {
@@ -506,6 +512,7 @@ void AbTable::show()
506 QTable::show(); 512 QTable::show();
507} 513}
508 514
515#if 0
509void AbTable::setChoiceNames( const QStringList& list) 516void AbTable::setChoiceNames( const QStringList& list)
510{ 517{
511 choicenames = list; 518 choicenames = list;
@@ -520,6 +527,7 @@ void AbTable::setChoiceNames( const QStringList& list)
520 } 527 }
521 fitColumns(); 528 fitColumns();
522} 529}
530#endif
523 531
524void AbTable::itemClicked(int,int col) 532void AbTable::itemClicked(int,int col)
525{ 533{
@@ -532,11 +540,13 @@ void AbTable::itemClicked(int,int col)
532 } 540 }
533} 541}
534 542
543#if 0
535QStringList AbTable::choiceNames() const 544QStringList AbTable::choiceNames() const
536{ 545{
537 return choicenames; 546 return choicenames;
538} 547}
539 548
549#endif
540void AbTable::setChoiceSelection( const QValueList<int>& list ) 550void AbTable::setChoiceSelection( const QValueList<int>& list )
541{ 551{
542 intFields = list; 552 intFields = list;
@@ -560,8 +570,6 @@ QStringList AbTable::choiceSelection(int /*index*/) const
560} 570}
561 571
562 572
563
564
565void AbTable::updateVisible() 573void AbTable::updateVisible()
566{ 574{
567 //qWarning("void AbTable::updateVisible()"); 575 //qWarning("void AbTable::updateVisible()");
@@ -630,6 +638,10 @@ void AbTable::paintCell(QPainter* p, int row, int col, const QRect& cr, bool )
630 638
631 p->save(); 639 p->save();
632 640
641 //qWarning( "Paint row: %d", row );
642
643 OContact act_contact = m_viewList[row];
644
633 // Paint alternating background bars 645 // Paint alternating background bars
634 if ( (row % 2 ) == 0 ) { 646 if ( (row % 2 ) == 0 ) {
635 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); 647 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) );
@@ -647,17 +659,32 @@ void AbTable::paintCell(QPainter* p, int row, int col, const QRect& cr, bool )
647 int x = 0; 659 int x = 0;
648 int y = ( cr.height() - 14 ) / 2; 660 int y = ( cr.height() - 14 ) / 2;
649 661
650 QPixmap pic = pixmap( row, col ); 662 QString nameText = act_contact.fileAs();
651 if ( !pic.isNull() ) 663
664 switch( col ){
665 case 0:
666 p->drawText( x + marg,2 + fm.ascent(), nameText );
667 break;
668 case 1:{
669
670 ContactItem contactItem = findContactContact( act_contact, 0 );
671 QPixmap contactPic = contactItem.icon; /* pixmap( row, col ); */
672 QString contactText = contactItem.value;
673
674 if ( !contactPic.isNull() )
652 { 675 {
653 p->drawPixmap( x + marg, y, pixmap( row, col ) ); 676 p->drawPixmap( x + marg, y, contactPic );
654 p->drawText( x + marg + pixmap( row, col ).width() + 4,2 + fm.ascent(), text( row, col ) ); 677 p->drawText( x + marg + contactPic.width()
678 + 4,2 + fm.ascent(), contactText );
655 } 679 }
656 else 680 else
657 { 681 {
658 p->drawText( x + marg,2 + fm.ascent(), text( row, col ) ); 682 p->drawText( x + marg,2 + fm.ascent(), contactText );
659 } 683 }
684 }
685 break;
660 686
687 }
661 p->restore(); 688 p->restore();
662} 689}
663 690