-rw-r--r-- | kabc/addresseeview.cpp | 38 | ||||
-rw-r--r-- | kabc/addresseeview.h | 4 |
2 files changed, 36 insertions, 6 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp index 7a4336b..e85991e 100644 --- a/kabc/addresseeview.cpp +++ b/kabc/addresseeview.cpp @@ -33,29 +33,33 @@ #include <qvbox.h> #include <qlabel.h> #include <qwidget.h> #include <qlayout.h> #include <qapplication.h> #include <qpushbutton.h> +#ifdef DESKTOP_VERSION +#include <qpaintdevicemetrics.h> +#include <qprinter.h> +#include <qpainter.h> +#endif #include "externalapphandler.h" -#include "addresseeview.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 KPIM; +using namespace KABC; AddresseeView::AddresseeView( QWidget *parent, const char *name ) -//US : KTextBrowser( parent, name ) : QTextBrowser( parent, name ) { //US setWrapPolicy( QTextEdit::AtWordBoundary ); setLinkUnderline( false ); @@ -64,13 +68,37 @@ AddresseeView::AddresseeView( QWidget *parent, const char *name ) //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.left( 6 ) == "mailto" ) ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); @@ -208,13 +236,13 @@ void AddresseeView::setAddressee( const KABC::Addressee& mAddressee ) aRole = "<tr>" "<td align=\"left\">" + mAddressee.role() + "</td>" "</tr>"; } if ( true /*!mAddressee.organization().isEmpty()*/ ) { aOrga = "<tr>" - "<td align=\"left\">" + mAddressee.organization() + "</td>" ; + "<td align=\"left\">" + mAddressee.organization() + "</td>" "</tr>"; } mText = ""; QString picString = ""; KABC::Picture picture = mAddressee.photo(); bool picAvailintern = false; diff --git a/kabc/addresseeview.h b/kabc/addresseeview.h index 3800512..e977d8f 100644 --- a/kabc/addresseeview.h +++ b/kabc/addresseeview.h @@ -25,17 +25,18 @@ #include <kabc/addressee.h> #include <kdialogbase.h> //US #include <ktextbrowser.h> #include <qtextbrowser.h> -namespace KPIM { +namespace KABC { //US class AddresseeView : public KTextBrowser class AddresseeView : public QTextBrowser { + public: AddresseeView( QWidget *parent = 0, const char *name = 0 ); /** Sets the addressee object. The addressee is displayed immediately. @@ -44,12 +45,13 @@ class AddresseeView : public QTextBrowser void setAddressee( const KABC::Addressee& addr ); void setSource(const QString& n); /** Returns the current addressee object. */ //KABC::Addressee addressee() const; + void printMe(); private: //KABC::Addressee mAddressee; QString mText; QString getPhoneNumbers( KABC::PhoneNumber::List phones, bool preferred ); void addTag(const QString & tag,const QString & text); |