summaryrefslogtreecommitdiffabout
path: root/korganizer/kowhatsnextview.cpp
authorzautrix <zautrix>2005-01-16 22:19:12 (UTC)
committer zautrix <zautrix>2005-01-16 22:19:12 (UTC)
commit507b362d42d5eed6277ad17422b6ba61acca636e (patch) (side-by-side diff)
treed3d29451d37649b102c3e171e2927437925f8ce8 /korganizer/kowhatsnextview.cpp
parenta704468d5fd02d30cf962c8b2d6815c7e9208e5d (diff)
downloadkdepimpi-507b362d42d5eed6277ad17422b6ba61acca636e.zip
kdepimpi-507b362d42d5eed6277ad17422b6ba61acca636e.tar.gz
kdepimpi-507b362d42d5eed6277ad17422b6ba61acca636e.tar.bz2
print AB
Diffstat (limited to 'korganizer/kowhatsnextview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kowhatsnextview.cpp42
1 files changed, 29 insertions, 13 deletions
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp
index 219f7c3..7166a01 100644
--- a/korganizer/kowhatsnextview.cpp
+++ b/korganizer/kowhatsnextview.cpp
@@ -24,7 +24,9 @@
#include <qlabel.h>
#include <qapplication.h>
-
+#ifdef DESKTOP_VERSION
+#include <qpaintdevicemetrics.h>
+#endif
#include <kglobal.h>
#include <klocale.h>
#include <kdebug.h>
@@ -56,6 +58,31 @@ void WhatsNextTextBrowser::setSource(const QString& n)
QTextBrowser::setSource(n);
}
}
+void WhatsNextTextBrowser::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
+}
KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent,
const char *name)
@@ -114,18 +141,7 @@ QPtrList<Incidence> KOWhatsNextView::selectedIncidences()
void KOWhatsNextView::printMe()
{
#ifdef DESKTOP_VERSION
- QPrinter printer;
- if (!printer.setup() )
- return;
- QTextBrowser tb;
- tb.setFixedSize( 600, 4000 );
- QPainter::redirect ( tb.viewport(), &printer );
- updateView();
- tb.setText( mText );
- tb.show();
- tb.repaint();
- tb.hide();
- KMessageBox::information( this, i18n("Printing What's Next View!\n\nPlease close after\nprinting is finished."));
+ mView->printMe();
#endif
}
void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd,