author | zautrix <zautrix> | 2005-01-16 22:19:12 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-16 22:19:12 (UTC) |
commit | 507b362d42d5eed6277ad17422b6ba61acca636e (patch) (side-by-side diff) | |
tree | d3d29451d37649b102c3e171e2927437925f8ce8 /kabc | |
parent | a704468d5fd02d30cf962c8b2d6815c7e9208e5d (diff) | |
download | kdepimpi-507b362d42d5eed6277ad17422b6ba61acca636e.zip kdepimpi-507b362d42d5eed6277ad17422b6ba61acca636e.tar.gz kdepimpi-507b362d42d5eed6277ad17422b6ba61acca636e.tar.bz2 |
print AB
-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); |