Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

contactitem.cpp

Go to the documentation of this file.
00001 //
00002 //
00003 // C++ Implementation: $MODULE$
00004 //
00005 // Description:
00006 //
00007 //
00008 // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
00009 //
00010 // Copyright: See COPYING file that comes with this distribution
00011 //
00012 //
00013 #include "contactitem.h"
00014 
00015 #include <opie2/oresource.h>
00016 
00017 #include <qpe/qcopenvelope_qws.h>
00018 
00019 
00020 using namespace Opie;
00021 ContactItem::ContactItem(OListViewItem* parent, OPimContact *contact)
00022 : ResultItem(parent)
00023 {
00024         _contact = contact;
00025         setText(0, _contact->toShortText());
00026         setIcon();
00027 }
00028 
00029 void ContactItem::setIcon()
00030 {
00031         QPixmap icon;
00032         switch ( _contact->lastHitField() ) {
00033         case -1:
00034                 icon = Opie::Core::OResource::loadPixmap( "reset", Opie::Core::OResource::SmallIcon );
00035                 break;
00036         case Qtopia::BusinessPhone:
00037         icon = Opie::Core::OResource::loadPixmap( "addressbook/phonework", Opie::Core::OResource::SmallIcon );
00038                 break;
00039         case Qtopia::BusinessFax:
00040         icon = Opie::Core::OResource::loadPixmap( "addressbook/faxwork", Opie::Core::OResource::SmallIcon );
00041                 break;
00042         case Qtopia::BusinessMobile:
00043         icon = Opie::Core::OResource::loadPixmap( "addressbook/mobilework", Opie::Core::OResource::SmallIcon );
00044                 break;
00045         case Qtopia::DefaultEmail:
00046         case Qtopia::Emails:
00047         icon = Opie::Core::OResource::loadPixmap( "addressbook/email", Opie::Core::OResource::SmallIcon );
00048                 break;
00049         case Qtopia::HomePhone:
00050         icon = Opie::Core::OResource::loadPixmap( "addressbook/phonehome", Opie::Core::OResource::SmallIcon );
00051                 break;
00052         case Qtopia::HomeFax:
00053         icon = Opie::Core::OResource::loadPixmap( "addressbook/faxhome", Opie::Core::OResource::SmallIcon );
00054                 break;
00055         case Qtopia::HomeMobile:
00056         icon = Opie::Core::OResource::loadPixmap( "addressbook/mobilehome", Opie::Core::OResource::SmallIcon );
00057                 break;
00058         case Qtopia::HomeWebPage:
00059         icon = Opie::Core::OResource::loadPixmap( "addressbook/webpagehome", Opie::Core::OResource::SmallIcon );
00060                 break;
00061         case Qtopia::BusinessWebPage:
00062         icon = Opie::Core::OResource::loadPixmap( "addressbook/webpagework", Opie::Core::OResource::SmallIcon );
00063                 break;
00064         case Qtopia::Title:
00065         case Qtopia::JobTitle:
00066         case Qtopia::FirstName:
00067         case Qtopia::MiddleName:
00068         case Qtopia::LastName:
00069         case Qtopia::Suffix:
00070         case Qtopia::Nickname:
00071         case Qtopia::FileAs:
00072         icon = Opie::Core::OResource::loadPixmap( "addressbook/identity", Opie::Core::OResource::SmallIcon );
00073                 break;
00074         case Qtopia::HomeStreet:
00075         case Qtopia::HomeCity:
00076         case Qtopia::HomeState:
00077         case Qtopia::HomeZip:
00078         case Qtopia::HomeCountry:
00079         icon = Opie::Core::OResource::loadPixmap( "osearch/addresshome", Opie::Core::OResource::SmallIcon );
00080                 break;
00081         case Qtopia::Company:
00082         case Qtopia::BusinessCity:
00083         case Qtopia::BusinessStreet:
00084         case Qtopia::BusinessZip:
00085         case Qtopia::BusinessCountry:
00086         case Qtopia::Department:
00087         case Qtopia::Office:
00088         case Qtopia::Manager:
00089         case Qtopia::BusinessPager:
00090         case Qtopia::Profession:
00091         icon = Opie::Core::OResource::loadPixmap( "osearch/addresshome", Opie::Core::OResource::SmallIcon );
00092                 break;
00093         case Qtopia::Assistant:
00094         case Qtopia::Spouse:
00095         case Qtopia::Children:
00096         icon = Opie::Core::OResource::loadPixmap( "osearch/personal", Opie::Core::OResource::SmallIcon );
00097                 break;
00098         case Qtopia::Birthday:
00099         case Qtopia::Anniversary:
00100         icon = Opie::Core::OResource::loadPixmap( "osearch/clock", Opie::Core::OResource::SmallIcon );
00101                 break;
00102         case Qtopia::Notes:
00103         icon = Opie::Core::OResource::loadPixmap( "txt", Opie::Core::OResource::SmallIcon );
00104                 break;
00105         default:
00106         icon = Opie::Core::OResource::loadPixmap( "DocsIcon", Opie::Core::OResource::SmallIcon );
00107                 break;
00108         }
00109         setPixmap( 0, icon );
00110 }
00111 
00112 ContactItem::~ContactItem()
00113 {
00114         delete _contact;
00115 }
00116 
00117 
00118 QString ContactItem::toRichText()
00119 {
00120     return _contact->toRichText();
00121 }
00122 
00123 void ContactItem::action( int act )
00124 {
00125 if (act == 0){
00126         QCopEnvelope e("QPE/Application/addressbook", "show(int)");
00127         e << _contact->uid();
00128 }else if(act == 1){
00129         QCopEnvelope e("QPE/Application/addressbook", "edit(int)");
00130         e << _contact->uid();
00131 }
00132 
00133 }
00134 
00135 QIntDict<QString> ContactItem::actions()
00136 {
00137         QIntDict<QString> result;
00138         result.insert( 0, new QString( QObject::tr("show") ) );
00139         result.insert( 1, new QString( QObject::tr("edit") ) );
00140         return result;
00141 
00142 }

Generated on Sat Nov 5 16:15:54 2005 for OPIE by  doxygen 1.4.2