From 507b362d42d5eed6277ad17422b6ba61acca636e Mon Sep 17 00:00:00 2001 From: zautrix Date: Sun, 16 Jan 2005 22:19:12 +0000 Subject: print AB --- (limited to 'kaddressbook/views') diff --git a/kaddressbook/views/contactlistview.cpp b/kaddressbook/views/contactlistview.cpp index 23b091c..e75810e 100644 --- a/kaddressbook/views/contactlistview.cpp +++ b/kaddressbook/views/contactlistview.cpp @@ -277,6 +277,33 @@ ContactListView::ContactListView(KAddressBookTableView *view, new DynamicTip( this ); } +void ContactListView::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 ); + qDebug("scale %f ", scale); + drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); + p.end(); + qDebug("Why does it not print??? "); +#endif +} void ContactListView::setAlternateColor(const QColor &m_AlternateColor) { diff --git a/kaddressbook/views/contactlistview.h b/kaddressbook/views/contactlistview.h index fad7f38..9d1a672 100644 --- a/kaddressbook/views/contactlistview.h +++ b/kaddressbook/views/contactlistview.h @@ -105,6 +105,7 @@ protected slots: void itemDropped(QDropEvent *e); public slots: + void printMe(); signals: void startAddresseeDrag(); diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp index 2d7ed08..107be59 100644 --- a/kaddressbook/views/kaddressbookcardview.cpp +++ b/kaddressbook/views/kaddressbookcardview.cpp @@ -38,6 +38,7 @@ #include "kabprefs.h" #include "viewmanager.h" + #include "kaddressbookcardview.h" #ifndef KAB_EMBEDDED @@ -116,6 +117,32 @@ AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) AddresseeCardView::~AddresseeCardView() { } +void AddresseeCardView::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(); + repaint(); +#endif +} void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) @@ -164,6 +191,8 @@ KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, this, SIGNAL(dropped(QDropEvent*))); connect(mCardView, SIGNAL(startAddresseeDrag()), this, SIGNAL(startDrag())); + connect(this, SIGNAL(printView()), + mCardView , SLOT(printMe())); } KAddressBookCardView::~KAddressBookCardView() diff --git a/kaddressbook/views/kaddressbookcardview.h b/kaddressbook/views/kaddressbookcardview.h index 8f22d54..2a71f7e 100644 --- a/kaddressbook/views/kaddressbookcardview.h +++ b/kaddressbook/views/kaddressbookcardview.h @@ -85,6 +85,8 @@ class AddresseeCardView : public CardView public: AddresseeCardView(QWidget *parent, const char *name = 0); ~AddresseeCardView(); +public slots: + void printMe(); signals: void startAddresseeDrag(); diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp index 61703ee..ecd6f05 100644 --- a/kaddressbook/views/kaddressbooktableview.cpp +++ b/kaddressbook/views/kaddressbooktableview.cpp @@ -89,6 +89,8 @@ void KAddressBookTableView::reconstructListView() mListView = new ContactListView( this, addressBook(), viewWidget() ); + connect(this, SIGNAL(printView()), + mListView , SLOT(printMe())); //US set singleClick manually, because it is no global configparameter in embedded space mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick); -- cgit v0.9.0.2