-rw-r--r-- | kaddressbook/views/contactlistview.cpp | 27 | ||||
-rw-r--r-- | kaddressbook/views/contactlistview.h | 1 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.cpp | 29 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.h | 2 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 2 |
5 files changed, 61 insertions, 0 deletions
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 @@ -278,4 +278,31 @@ 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 @@ -106,4 +106,5 @@ protected slots: public slots: + void printMe(); signals: 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 @@ -39,4 +39,5 @@ #include "viewmanager.h" + #include "kaddressbookcardview.h" @@ -117,4 +118,30 @@ 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 +} @@ -165,4 +192,6 @@ KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, connect(mCardView, SIGNAL(startAddresseeDrag()), this, SIGNAL(startDrag())); + connect(this, SIGNAL(printView()), + mCardView , SLOT(printMe())); } 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 @@ -86,4 +86,6 @@ class AddresseeCardView : public CardView AddresseeCardView(QWidget *parent, const char *name = 0); ~AddresseeCardView(); +public slots: + void printMe(); signals: 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 @@ -90,4 +90,6 @@ 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); |