author | zautrix <zautrix> | 2005-10-29 16:39:40 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-10-29 16:39:40 (UTC) |
commit | 898dbabef6d747447999add46201315d04f85f63 (patch) (side-by-side diff) | |
tree | fb247cbbd99ca6918400547e16484a58a8ba1523 /kabc | |
parent | 1360f8e3b5da58b561f868643d2d5f04b874cee7 (diff) | |
download | kdepimpi-898dbabef6d747447999add46201315d04f85f63.zip kdepimpi-898dbabef6d747447999add46201315d04f85f63.tar.gz kdepimpi-898dbabef6d747447999add46201315d04f85f63.tar.bz2 |
commit
-rw-r--r-- | kabc/addresseeview.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp index aae923c..5c24acf 100644 --- a/kabc/addresseeview.cpp +++ b/kabc/addresseeview.cpp @@ -47,207 +47,209 @@ #include "externalapphandler.h" #include <kabc/addresseeview.h> //US #ifndef DESKTOP_VERSION //US #include <qtopia/qcopenvelope_qws.h> //US #include <qpe/qpeapplication.h> //US #endif //US static int kphoneInstalled = 0; using namespace KABC; bool AddresseeView::sFullDetailsMode = false; AddresseeView::AddresseeView( QWidget *parent, const char *name ) : QTextBrowser( parent, name ) { //US setWrapPolicy( QTextEdit::AtWordBoundary ); setLinkUnderline( false ); // setVScrollBarMode( QScrollView::AlwaysOff ); //setHScrollBarMode( QScrollView::AlwaysOff ); //US QStyleSheet *sheet = styleSheet(); //US QStyleSheetItem *link = sheet->item( "a" ); //US link->setColor( KGlobalSettings::linkColor() ); } void AddresseeView::printMe() { #ifdef DESKTOP_VERSION QPrinter printer; if (!printer.setup() ) return; QPainter p; p.begin ( &printer ); QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); float dx, dy; int wid = (m.width() * 9)/10; dx = (float) wid/(float)contentsWidth (); dy = (float)(m.height()) / (float)contentsHeight (); float scale; // scale to fit the width or height of the paper if ( dx < dy ) scale = dx; else scale = dy; p.translate( m.width()/10,0 ); p.scale( scale, scale ); drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); p.end(); #endif } void AddresseeView::setSource(const QString& n) { //qDebug("********AddresseeView::setSource %s", n.latin1()); if ( n == "allDetails" ) { sFullDetailsMode = true; setAddressee( mCurrentContact ); } else if ( n == "notAllDetails" ) { sFullDetailsMode = false; setAddressee( mCurrentContact ); } else if ( n.left( 6 ) == "mailto" ) ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); else if ( n.left( 7 ) == "phoneto" ) ExternalAppHandler::instance()->callByPhone( n.mid(8) ); else if ( n.left( 5 ) == "faxto" ) ExternalAppHandler::instance()->callByFax( n.mid(6) ); else if ( n.left( 5 ) == "smsto" ) ExternalAppHandler::instance()->callBySMS( n.mid(6) ); else if ( n.left( 7 ) == "pagerto" ) ExternalAppHandler::instance()->callByPager( n.mid(8) ); else if ( n.left( 5 ) == "sipto" ) ExternalAppHandler::instance()->callBySIP( n.mid(6) ); } void AddresseeView::setAddressee( const KABC::Addressee& mAddressee ) { bool kemailAvail = ExternalAppHandler::instance()->isEmailAppAvailable(); // mAddressee = addr; // clear view //setText( QString::null ); mCurrentContact = mAddressee; if ( mAddressee.isEmpty() ) { setText( QString::null); return; } #if 0 QString name = ( mAddressee.assembledName().isEmpty() ? mAddressee.formattedName() : mAddressee.assembledName() ); #endif QString name = mAddressee.realName(); - + QString assName = mAddressee.assembledName(); + if ( assName.isEmpty() ) + assName = name; QString dynamicPart; dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(),true ); QStringList emails = mAddressee.emails(); QStringList::ConstIterator emailIt; QString type = i18n( "Email" ); emailIt = emails.begin(); if ( emailIt != emails.end() ) { if ( kemailAvail ) { dynamicPart += QString( "<tr><td align=\"right\"><b>%1</b></td>" "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) .arg( type ) - .arg( name ) + .arg( assName ) .arg( *emailIt ) .arg( *emailIt ); ++emailIt; } else { dynamicPart += QString( "<tr><td align=\"right\"><b>%1</b></td>" "<td align=\"left\">%2</td></tr>" ) .arg( type ) .arg( *emailIt ); ++emailIt; } } if ( mAddressee.birthday().date().isValid() ) { dynamicPart += QString( "<tr><td align=\"right\"><b>%1</b></td>" "<td align=\"left\">%2</td></tr>" ) .arg( i18n ("Birthday") ) .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) ); } dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(), false ); for ( ; emailIt != emails.end(); ++emailIt ) { if ( kemailAvail ) { dynamicPart += QString( "<tr><td align=\"right\"><b>%1</b></td>" "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) .arg( type ) .arg( name ) .arg( *emailIt ) .arg( *emailIt ); } else { dynamicPart += QString( "<tr><td align=\"right\"><b>%1</b></td>" "<td align=\"left\">%2</td></tr>" ) .arg( type ) .arg( *emailIt ); } } KABC::Address::List addresses = mAddressee.addresses(); KABC::Address::List::ConstIterator addrIt; for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { if ( true /*(*addrIt).label().isEmpty()*/ ) { QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace(); //US formattedAddress = formattedAddress.replace( '\n', "<br>" ); //qDebug("adresss %s ",formattedAddress.latin1() ); formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" ); //qDebug("AddresseeView::setAddressee has to be verified."); dynamicPart += QString( "<tr><td align=\"right\"><b>%1</b></td>" "<td align=\"left\">%2</td></tr>" ) .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) .arg( formattedAddress ); } else { dynamicPart += QString( "<tr><td align=\"right\"><b>%1</b></td>" "<td align=\"left\">%2</td></tr>" ) .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) //US .arg( (*addrIt).label().replace( '\n', "<br>" ) ); .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ ); } } QString notes; if ( sFullDetailsMode ) { notes = QString( "<tr><td align=\"right\"><b>%1</b></td>" "<td align=\"left\"><a href=\"notAllDetails\">%4</a></td></tr>" ) .arg( i18n("Details") ) .arg( i18n("Hide!") ); QString tempX = mAddressee.custom( "KADDRESSBOOK", "X-Gender" ); if ( !tempX.isEmpty() ) { if ( tempX == "male" || tempX == "female" ) { notes += QString( "<tr><td align=\"right\"><b>%1</b></td>" "<td align=\"left\">%2</td></tr>" ) .arg( i18n( "" ) ) .arg( i18n(tempX) ); } } tempX = mAddressee.secrecy().asString(); notes += QString( "<tr><td align=\"right\"><b>%1</b></td>" "<td align=\"left\">%2</td></tr>" ) .arg( "" ) .arg( tempX ); |