author | zautrix <zautrix> | 2005-01-16 22:19:12 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-16 22:19:12 (UTC) |
commit | 507b362d42d5eed6277ad17422b6ba61acca636e (patch) (unidiff) | |
tree | d3d29451d37649b102c3e171e2927437925f8ce8 /kaddressbook/views | |
parent | a704468d5fd02d30cf962c8b2d6815c7e9208e5d (diff) | |
download | kdepimpi-507b362d42d5eed6277ad17422b6ba61acca636e.zip kdepimpi-507b362d42d5eed6277ad17422b6ba61acca636e.tar.gz kdepimpi-507b362d42d5eed6277ad17422b6ba61acca636e.tar.bz2 |
print AB
-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 | |||
@@ -277,6 +277,33 @@ ContactListView::ContactListView(KAddressBookTableView *view, | |||
277 | 277 | ||
278 | new DynamicTip( this ); | 278 | new DynamicTip( this ); |
279 | } | 279 | } |
280 | void ContactListView::printMe() | ||
281 | { | ||
282 | #ifdef DESKTOP_VERSION | ||
283 | QPrinter printer; | ||
284 | if (!printer.setup() ) | ||
285 | return; | ||
286 | QPainter p; | ||
287 | p.begin ( &printer ); | ||
288 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | ||
289 | float dx, dy; | ||
290 | int wid = (m.width() * 9)/10; | ||
291 | dx = (float) wid/(float)contentsWidth (); | ||
292 | dy = (float)(m.height()) / (float)contentsHeight (); | ||
293 | float scale; | ||
294 | // scale to fit the width or height of the paper | ||
295 | if ( dx < dy ) | ||
296 | scale = dx; | ||
297 | else | ||
298 | scale = dy; | ||
299 | p.translate( m.width()/10,0 ); | ||
300 | p.scale( scale, scale ); | ||
301 | qDebug("scale %f ", scale); | ||
302 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); | ||
303 | p.end(); | ||
304 | qDebug("Why does it not print??? "); | ||
305 | #endif | ||
306 | } | ||
280 | 307 | ||
281 | void ContactListView::setAlternateColor(const QColor &m_AlternateColor) | 308 | void ContactListView::setAlternateColor(const QColor &m_AlternateColor) |
282 | { | 309 | { |
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: | |||
105 | void itemDropped(QDropEvent *e); | 105 | void itemDropped(QDropEvent *e); |
106 | 106 | ||
107 | public slots: | 107 | public slots: |
108 | void printMe(); | ||
108 | 109 | ||
109 | signals: | 110 | signals: |
110 | void startAddresseeDrag(); | 111 | 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 @@ | |||
38 | #include "kabprefs.h" | 38 | #include "kabprefs.h" |
39 | #include "viewmanager.h" | 39 | #include "viewmanager.h" |
40 | 40 | ||
41 | |||
41 | #include "kaddressbookcardview.h" | 42 | #include "kaddressbookcardview.h" |
42 | 43 | ||
43 | #ifndef KAB_EMBEDDED | 44 | #ifndef KAB_EMBEDDED |
@@ -116,6 +117,32 @@ AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) | |||
116 | AddresseeCardView::~AddresseeCardView() | 117 | AddresseeCardView::~AddresseeCardView() |
117 | { | 118 | { |
118 | } | 119 | } |
120 | void AddresseeCardView::printMe() | ||
121 | { | ||
122 | #ifdef DESKTOP_VERSION | ||
123 | QPrinter printer; | ||
124 | if (!printer.setup() ) | ||
125 | return; | ||
126 | QPainter p; | ||
127 | p.begin ( &printer ); | ||
128 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | ||
129 | float dx, dy; | ||
130 | int wid = (m.width() * 9)/10; | ||
131 | dx = (float) wid/(float)contentsWidth (); | ||
132 | dy = (float)(m.height()) / (float)contentsHeight (); | ||
133 | float scale; | ||
134 | // scale to fit the width or height of the paper | ||
135 | if ( dx < dy ) | ||
136 | scale = dx; | ||
137 | else | ||
138 | scale = dy; | ||
139 | p.translate( m.width()/10,0 ); | ||
140 | p.scale( scale, scale ); | ||
141 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); | ||
142 | p.end(); | ||
143 | repaint(); | ||
144 | #endif | ||
145 | } | ||
119 | 146 | ||
120 | 147 | ||
121 | void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) | 148 | void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) |
@@ -164,6 +191,8 @@ KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, | |||
164 | this, SIGNAL(dropped(QDropEvent*))); | 191 | this, SIGNAL(dropped(QDropEvent*))); |
165 | connect(mCardView, SIGNAL(startAddresseeDrag()), | 192 | connect(mCardView, SIGNAL(startAddresseeDrag()), |
166 | this, SIGNAL(startDrag())); | 193 | this, SIGNAL(startDrag())); |
194 | connect(this, SIGNAL(printView()), | ||
195 | mCardView , SLOT(printMe())); | ||
167 | } | 196 | } |
168 | 197 | ||
169 | KAddressBookCardView::~KAddressBookCardView() | 198 | 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 | |||
85 | public: | 85 | public: |
86 | AddresseeCardView(QWidget *parent, const char *name = 0); | 86 | AddresseeCardView(QWidget *parent, const char *name = 0); |
87 | ~AddresseeCardView(); | 87 | ~AddresseeCardView(); |
88 | public slots: | ||
89 | void printMe(); | ||
88 | 90 | ||
89 | signals: | 91 | signals: |
90 | void startAddresseeDrag(); | 92 | 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() | |||
89 | 89 | ||
90 | mListView = new ContactListView( this, addressBook(), viewWidget() ); | 90 | mListView = new ContactListView( this, addressBook(), viewWidget() ); |
91 | 91 | ||
92 | connect(this, SIGNAL(printView()), | ||
93 | mListView , SLOT(printMe())); | ||
92 | //US set singleClick manually, because it is no global configparameter in embedded space | 94 | //US set singleClick manually, because it is no global configparameter in embedded space |
93 | mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick); | 95 | mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick); |
94 | 96 | ||