Diffstat (limited to 'core/pim/addressbook/abtable.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/addressbook/abtable.cpp | 137 |
1 files changed, 85 insertions, 52 deletions
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp index aec390d..55b1ba1 100644 --- a/core/pim/addressbook/abtable.cpp +++ b/core/pim/addressbook/abtable.cpp @@ -4,48 +4,49 @@ ** ** This file is part of Qt Palmtop Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include <qpe/categoryselect.h> #include <qpe/config.h> #include <qpe/stringutil.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/timestring.h> +#include <qpe/resource.h> #include <opie/orecordlist.h> #include <qasciidict.h> #include <qdatetime.h> #include <qfile.h> #include <qregexp.h> #include <qmessagebox.h> #include "abtable.h" #include <errno.h> #include <fcntl.h> #include <unistd.h> #include <stdlib.h> #include <ctype.h> //toupper() for key hack /*! \class AbTableItem abtable.h \brief QTableItem based class for showing a field of an entry */ @@ -193,59 +194,61 @@ bool AbTable::selectContact( int UID ) for ( int r = 0; r < rows; ++r ) { abi = static_cast<AbTableItem*>( item(r, 0) ); foundContact = &contactList[abi]; if ( foundContact -> uid() == UID ){ ensureCellVisible( r, 0 ); setCurrentCell( r, 0 ); found = true; break; } } if ( !found ){ ensureCellVisible( 0,0 ); setCurrentCell( 0, 0 ); } setPaintingEnabled( TRUE ); return true; } void AbTable::insertIntoTable( const OContact& cnt, int row ) { // qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row ); - QString strName, - strContact; + QString strName; + ContactItem contactItem; strName = findContactName( cnt ); - strContact = findContactContact( cnt, row ); + contactItem = findContactContact( cnt, row ); AbTableItem *ati; - ati = new AbTableItem( this, QTableItem::Never, strName, strContact); + ati = new AbTableItem( this, QTableItem::Never, strName, contactItem.value ); contactList.insert( ati, cnt ); setItem( row, 0, ati ); - ati = new AbTableItem( this, QTableItem::Never, strContact, strName); + ati = new AbTableItem( this, QTableItem::Never, contactItem.value, strName); + if ( !contactItem.icon.isNull() ) + ati->setPixmap( contactItem.icon ); setItem( row, 1, ati ); //### cannot do this; table only has two columns at this point // setItem( row, 2, new AbPickItem( this ) ); } void AbTable::columnClicked( int col ) { if ( !sorting() ) return; if ( lastSortCol == -1 ) lastSortCol = col; if ( col == lastSortCol ) { asc = !asc; } else { lastSortCol = col; asc = TRUE; } //QMessageBox::information( this, "resort", "columnClicked" ); @@ -285,56 +288,60 @@ int AbTable::currentEntry_UID() } void AbTable::clear() { // qWarning( "void AbTable::clear()" ); contactList.clear(); setPaintingEnabled( FALSE ); for ( int r = 0; r < numRows(); ++r ) { for ( int c = 0; c < numCols(); ++c ) { if ( cellWidget( r, c ) ) clearCellWidget( r, c ); clearCell( r, c ); } } setNumRows( 0 ); setPaintingEnabled( TRUE ); } // Refresh updates column 2 if the contactsettings changed void AbTable::refresh() { // qWarning( "void AbTable::refresh()" ); int rows = numRows(); - QString value; AbTableItem *abi; + ContactItem contactItem; setPaintingEnabled( FALSE ); for ( int r = 0; r < rows; ++r ) { abi = static_cast<AbTableItem*>( item(r, 0) ); - value = findContactContact( contactList[abi], r ); - static_cast<AbTableItem*>( item(r, 1) )->setItem( value, abi->text() ); + contactItem = findContactContact( contactList[abi], r ); + static_cast<AbTableItem*>( item(r, 1) )->setItem( contactItem.value, abi->text() ); + if ( !contactItem.icon.isNull() ) + static_cast<AbTableItem*>( item(r, 1) )-> + setPixmap( contactItem.icon ); + } resort(); setPaintingEnabled( TRUE ); } void AbTable::keyPressEvent( QKeyEvent *e ) { char key = toupper( e->ascii() ); if ( key >= 'A' && key <= 'Z' ) moveTo( key ); // qWarning("Received key .."); switch( e->key() ) { case Qt::Key_Space: case Qt::Key_Return: case Qt::Key_Enter: emit signalSwitch(); break; // case Qt::Key_Up: // qWarning("a"); // emit signalKeyUp(); // break; // case Qt::Key_Down: @@ -597,151 +604,177 @@ void AbTable::setPaintingEnabled( bool e ) rowHeightChanged( 0 ); viewport()->update(); } } else { ++countNested; enablePainting = false; setUpdatesEnabled( false ); } // qWarning("OUT void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested ); } void AbTable::viewportPaintEvent( QPaintEvent* e ) { // qWarning(" void AbTable::viewportPaintEvent( QPaintEvent* e ) -> %d", enablePainting); if ( enablePainting ) QTable::viewportPaintEvent( e ); } void AbTable::rowHeightChanged( int row ) { if ( enablePainting ) QTable::rowHeightChanged( row ); } -QString AbTable::findContactContact( const OContact &entry, int /* row */ ) +ContactItem AbTable::findContactContact( const OContact &entry, int /* row */ ) { - QString value; - value = ""; + + ContactItem item; + + item.value = ""; + for ( QValueList<int>::ConstIterator it = intFields.begin(); it != intFields.end(); ++it ) { switch ( *it ) { default: break; case Qtopia::Title: - value = entry.title(); + item.value = entry.title(); break; case Qtopia::Suffix: - value = entry.suffix(); + item.value = entry.suffix(); break; case Qtopia::FileAs: - value = entry.fileAs(); + item.value = entry.fileAs(); break; case Qtopia::DefaultEmail: - value = entry.defaultEmail(); + item.value = entry.defaultEmail(); + if ( !item.value.isEmpty() ) + item.icon = Resource::loadPixmap( "addressbook/email" ); + break; case Qtopia::Emails: - value = entry.emails(); + item.value = entry.emails(); + if ( !item.value.isEmpty() ) + item.icon = Resource::loadPixmap( "addressbook/email" ); break; case Qtopia::HomeStreet: - value = entry.homeStreet(); + item.value = entry.homeStreet(); break; case Qtopia::HomeCity: - value = entry.homeCity(); + item.value = entry.homeCity(); break; case Qtopia::HomeState: - value = entry.homeState(); + item.value = entry.homeState(); break; case Qtopia::HomeZip: - value = entry.homeZip(); + item.value = entry.homeZip(); break; case Qtopia::HomeCountry: - value = entry.homeCountry(); + item.value = entry.homeCountry(); break; case Qtopia::HomePhone: - value = entry.homePhone(); + item.value = entry.homePhone(); + if ( !item.value.isEmpty() ) + item.icon = Resource::loadPixmap( "addressbook/phonehome" ); break; case Qtopia::HomeFax: - value = entry.homeFax(); + item.value = entry.homeFax(); + if ( !item.value.isEmpty() ) + item.icon = Resource::loadPixmap( "addressbook/faxhome" ); break; case Qtopia::HomeMobile: - value = entry.homeMobile(); + item.value = entry.homeMobile(); + if ( !item.value.isEmpty() ) + item.icon = Resource::loadPixmap( "addressbook/mobilehome" ); break; case Qtopia::HomeWebPage: - value = entry.homeWebpage(); + item.value = entry.homeWebpage(); + if ( !item.value.isEmpty() ) + item.icon = Resource::loadPixmap( "addressbook/webpagehome" ); break; case Qtopia::Company: - value = entry.company(); + item.value = entry.company(); break; case Qtopia::BusinessCity: - value = entry.businessCity(); + item.value = entry.businessCity(); break; case Qtopia::BusinessStreet: - value = entry.businessStreet(); + item.value = entry.businessStreet(); break; case Qtopia::BusinessZip: - value = entry.businessZip(); + item.value = entry.businessZip(); break; case Qtopia::BusinessCountry: - value = entry.businessCountry(); + item.value = entry.businessCountry(); break; case Qtopia::BusinessWebPage: - value = entry.businessWebpage(); + item.value = entry.businessWebpage(); + if ( !item.value.isEmpty() ) + item.icon = Resource::loadPixmap( "addressbook/webpagework" ); break; case Qtopia::JobTitle: - value = entry.jobTitle(); + item.value = entry.jobTitle(); break; case Qtopia::Department: - value = entry.department(); + item.value = entry.department(); break; case Qtopia::Office: - value = entry.office(); + item.value = entry.office(); break; case Qtopia::BusinessPhone: - value = entry.businessPhone(); + item.value = entry.businessPhone(); + if ( !item.value.isEmpty() ) + item.icon = Resource::loadPixmap( "addressbook/phonework" ); break; case Qtopia::BusinessFax: - value = entry.businessFax(); + item.value = entry.businessFax(); + if ( !item.value.isEmpty() ) + item.icon = Resource::loadPixmap( "addressbook/faxwork" ); break; case Qtopia::BusinessMobile: - value = entry.businessMobile(); + item.value = entry.businessMobile(); + if ( !item.value.isEmpty() ) + item.icon = Resource::loadPixmap( "addressbook/mobilework" ); break; case Qtopia::BusinessPager: - value = entry.businessPager(); + item.value = entry.businessPager(); break; case Qtopia::Profession: - value = entry.profession(); + item.value = entry.profession(); break; case Qtopia::Assistant: - value = entry.assistant(); + item.value = entry.assistant(); break; case Qtopia::Manager: - value = entry.manager(); + item.value = entry.manager(); break; case Qtopia::Spouse: - value = entry.spouse(); + item.value = entry.spouse(); break; case Qtopia::Gender: - value = entry.gender(); + item.value = entry.gender(); break; case Qtopia::Birthday: - if ( ! entry.birthday().isNull() ) - value = TimeString::numberDateString( entry.birthday() ); + if ( ! entry.birthday().isNull() ){ + item.value = TimeString::numberDateString( entry.birthday() ); + } break; case Qtopia::Anniversary: - if ( ! entry.anniversary().isNull() ) - value = TimeString::numberDateString( entry.anniversary() ); + if ( ! entry.anniversary().isNull() ){ + item.value = TimeString::numberDateString( entry.anniversary() ); + } break; case Qtopia::Nickname: - value = entry.nickname(); + item.value = entry.nickname(); break; case Qtopia::Children: - value = entry.children(); + item.value = entry.children(); break; case Qtopia::Notes: - value = entry.notes(); + item.value = entry.notes(); break; } - if ( !value.isEmpty() ) + if ( !item.value.isEmpty() ) break; } - return value; + return item; } |