author | zautrix <zautrix> | 2005-03-28 19:26:15 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-28 19:26:15 (UTC) |
commit | ea070abfcff313cac87dbb4d5c9410784740de21 (patch) (unidiff) | |
tree | 3e95608a0444030016eb6845b95a582e265c1dad /korganizer | |
parent | 57f95bb15f732ede3ddc68b077b6a5476246e971 (diff) | |
download | kdepimpi-ea070abfcff313cac87dbb4d5c9410784740de21.zip kdepimpi-ea070abfcff313cac87dbb4d5c9410784740de21.tar.gz kdepimpi-ea070abfcff313cac87dbb4d5c9410784740de21.tar.bz2 |
print fixes
-rw-r--r-- | korganizer/koeventviewer.cpp | 13 | ||||
-rw-r--r-- | korganizer/koeventviewer.h | 53 | ||||
-rw-r--r-- | korganizer/koeventviewerdialog.cpp | 8 | ||||
-rw-r--r-- | korganizer/kowhatsnextview.cpp | 12 |
4 files changed, 76 insertions, 10 deletions
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp index 445fc86..dbe0668 100644 --- a/korganizer/koeventviewer.cpp +++ b/korganizer/koeventviewer.cpp | |||
@@ -46,82 +46,93 @@ | |||
46 | 46 | ||
47 | #include "koeventviewer.h" | 47 | #include "koeventviewer.h" |
48 | //#ifndef KORG_NOKABC | 48 | //#ifndef KORG_NOKABC |
49 | //#include <kabc/stdaddressbook.h> | 49 | //#include <kabc/stdaddressbook.h> |
50 | //#define size count | 50 | //#define size count |
51 | //#endif | 51 | //#endif |
52 | 52 | ||
53 | #ifdef DESKTOP_VERSION | 53 | #ifdef DESKTOP_VERSION |
54 | #include <kabc/addresseedialog.h> | 54 | #include <kabc/addresseedialog.h> |
55 | #include <kabc/addresseeview.h> | 55 | #include <kabc/addresseeview.h> |
56 | #include <qprinter.h> | 56 | #include <qprinter.h> |
57 | #include <qpainter.h> | 57 | #include <qpainter.h> |
58 | #include <qpaintdevicemetrics.h> | 58 | #include <qpaintdevicemetrics.h> |
59 | #else //DESKTOP_VERSION | 59 | #else //DESKTOP_VERSION |
60 | #include <externalapphandler.h> | 60 | #include <externalapphandler.h> |
61 | #include <qtopia/qcopenvelope_qws.h> | 61 | #include <qtopia/qcopenvelope_qws.h> |
62 | #endif //DESKTOP_VERSION | 62 | #endif //DESKTOP_VERSION |
63 | 63 | ||
64 | KOEventViewer::KOEventViewer(QWidget *parent,const char *name) | 64 | KOEventViewer::KOEventViewer(QWidget *parent,const char *name) |
65 | : QTextBrowser(parent,name) | 65 | : QTextBrowser(parent,name) |
66 | { | 66 | { |
67 | mSyncMode = false; | 67 | mSyncMode = false; |
68 | mColorMode = 0; | 68 | mColorMode = 0; |
69 | } | 69 | } |
70 | 70 | ||
71 | KOEventViewer::~KOEventViewer() | 71 | KOEventViewer::~KOEventViewer() |
72 | { | 72 | { |
73 | } | 73 | } |
74 | 74 | ||
75 | void KOEventViewer::printMe() | 75 | void KOEventViewer::printMe() |
76 | { | 76 | { |
77 | #ifdef DESKTOP_VERSION | 77 | #ifdef DESKTOP_VERSION |
78 | |||
79 | KOPrintPrefs pp ( this ); | ||
80 | if (!pp.exec() ) | ||
81 | return; | ||
82 | int scaleval = pp.printMode() ; | ||
83 | |||
78 | QPrinter printer; | 84 | QPrinter printer; |
79 | if (!printer.setup() ) | 85 | if (!printer.setup() ) |
80 | return; | 86 | return; |
81 | QPainter p; | 87 | QPainter p; |
82 | p.begin ( &printer ); | 88 | p.begin ( &printer ); |
83 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | 89 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); |
84 | float dx, dy; | 90 | float dx, dy; |
85 | int wid = (m.width() * 9)/10; | 91 | int wid = (m.width() * 9)/10; |
86 | dx = (float) wid/(float)contentsWidth (); | 92 | dx = (float) wid/(float)contentsWidth (); |
87 | dy = (float)(m.height()) / (float)contentsHeight (); | 93 | dy = (float)(m.height()) / (float)contentsHeight (); |
88 | float scale; | 94 | float scale; |
89 | // scale to fit the width or height of the paper | 95 | // scale to fit the width or height of the paper |
90 | if ( dx < dy ) | 96 | if ( dx < dy ) |
91 | scale = dx; | 97 | scale = dx; |
92 | else | 98 | else |
93 | scale = dy; | 99 | scale = dy; |
100 | |||
94 | p.translate( m.width()/10,0 ); | 101 | p.translate( m.width()/10,0 ); |
95 | p.scale( scale, scale ); | 102 | qDebug("Scale: %f ", scale ); |
103 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { | ||
104 | qDebug("SCALE "); | ||
105 | p.scale( scale, scale ); | ||
106 | } | ||
96 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); | 107 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); |
97 | p.end(); | 108 | p.end(); |
98 | #endif | 109 | #endif |
99 | 110 | ||
100 | } | 111 | } |
101 | void KOEventViewer::setSource(const QString& n) | 112 | void KOEventViewer::setSource(const QString& n) |
102 | { | 113 | { |
103 | 114 | ||
104 | if ( n.left(3) == "uid" ) | 115 | if ( n.left(3) == "uid" ) |
105 | #ifdef DESKTOP_VERSION | 116 | #ifdef DESKTOP_VERSION |
106 | { | 117 | { |
107 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 118 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
108 | KABC::AddressBook::Iterator it; | 119 | KABC::AddressBook::Iterator it; |
109 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 120 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
110 | // LR I do not understand, why the uid string is different on zaurus and desktop | 121 | // LR I do not understand, why the uid string is different on zaurus and desktop |
111 | QString uid = "uid://"+(*it).uid(); | 122 | QString uid = "uid://"+(*it).uid(); |
112 | 123 | ||
113 | //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); | 124 | //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); |
114 | if (n == uid ) { | 125 | if (n == uid ) { |
115 | //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); | 126 | //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); |
116 | QDialog dia( this,"dia123", true ); | 127 | QDialog dia( this,"dia123", true ); |
117 | dia.setCaption( i18n("Details of attendee") ); | 128 | dia.setCaption( i18n("Details of attendee") ); |
118 | QVBoxLayout lay ( &dia ); | 129 | QVBoxLayout lay ( &dia ); |
119 | KABC::AddresseeView av ( &dia ); | 130 | KABC::AddresseeView av ( &dia ); |
120 | av.setAddressee( (*it) ); | 131 | av.setAddressee( (*it) ); |
121 | lay.addWidget( &av ); | 132 | lay.addWidget( &av ); |
122 | if ( QApplication::desktop()->width() < 480 ) | 133 | if ( QApplication::desktop()->width() < 480 ) |
123 | dia.resize( 220, 240); | 134 | dia.resize( 220, 240); |
124 | else { | 135 | else { |
125 | dia.resize( 400,400); | 136 | dia.resize( 400,400); |
126 | } | 137 | } |
127 | dia.exec(); | 138 | dia.exec(); |
diff --git a/korganizer/koeventviewer.h b/korganizer/koeventviewer.h index ca5bc15..6ecc233 100644 --- a/korganizer/koeventviewer.h +++ b/korganizer/koeventviewer.h | |||
@@ -1,64 +1,117 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | #ifndef KOEVENTVIEWER_H | 19 | #ifndef KOEVENTVIEWER_H |
20 | #define KOEVENTVIEWER_H | 20 | #define KOEVENTVIEWER_H |
21 | // | 21 | // |
22 | // Viewer widget for events. | 22 | // Viewer widget for events. |
23 | // | 23 | // |
24 | 24 | ||
25 | #include <qtextbrowser.h> | 25 | #include <qtextbrowser.h> |
26 | 26 | ||
27 | #include <libkcal/event.h> | 27 | #include <libkcal/event.h> |
28 | #include <libkcal/journal.h> | 28 | #include <libkcal/journal.h> |
29 | 29 | ||
30 | 30 | ||
31 | using namespace KCal; | 31 | using namespace KCal; |
32 | 32 | ||
33 | #ifdef DESKTOP_VERSION | ||
34 | |||
35 | #include <qradiobutton.h> | ||
36 | #include <qpushbutton.h> | ||
37 | #include <qlayout.h> | ||
38 | #include <qdialog.h> | ||
39 | #include <qlabel.h> | ||
40 | #include <qbuttongroup.h> | ||
41 | #include <kglobal.h> | ||
42 | |||
43 | class KOPrintPrefs : public QDialog | ||
44 | { | ||
45 | public: | ||
46 | KOPrintPrefs( QWidget *parent=0, const char *name=0 ) : | ||
47 | QDialog( parent, name, true ) | ||
48 | { | ||
49 | setCaption( i18n("KO/Pi Printout") ); | ||
50 | QVBoxLayout* lay = new QVBoxLayout( this ); | ||
51 | lay->setSpacing( 3 ); | ||
52 | lay->setMargin( 3 ); | ||
53 | QLabel * lab = new QLabel( i18n("This prints the view as you see it.\n(With the complete content, of course.)\nYou may change the print layout by resizing the view.\nPrint unscaled may print several pages\ndepending on the amount of data.\nPrint scaled down will print all on one page.\nPrint scaled up/down will print all on one page,\nbut will scale up the text to page boundaries,\nif the text is smaller than the page.\nYou can select page geometry setup in the next dialog."), this ); | ||
54 | lay->addWidget( lab ); | ||
55 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Printout Mode"), this ); | ||
56 | lay->addWidget( format ); | ||
57 | format->setExclusive ( true ) ; | ||
58 | pmNo = new QRadioButton(i18n("Print unscaled"), format ); | ||
59 | pmScaledDown = new QRadioButton(i18n("Print scaled down to fit one page"), format ); | ||
60 | new QRadioButton(i18n("Print scaled up/down to fit one page"), format ); | ||
61 | pmScaledDown->setChecked( true ); | ||
62 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | ||
63 | lay->addWidget( ok ); | ||
64 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | ||
65 | lay->addWidget( cancel ); | ||
66 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | ||
67 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | ||
68 | resize( 200, 200 ); | ||
69 | } | ||
70 | |||
71 | int printMode() | ||
72 | { | ||
73 | if ( pmNo->isChecked() ) | ||
74 | return 0; | ||
75 | if ( pmScaledDown->isChecked() ) | ||
76 | return 1; | ||
77 | return 2; | ||
78 | } | ||
79 | private: | ||
80 | QRadioButton* pmNo; | ||
81 | QRadioButton* pmScaledDown; | ||
82 | }; | ||
83 | |||
84 | #endif | ||
85 | |||
33 | class KOEventViewer : public QTextBrowser { | 86 | class KOEventViewer : public QTextBrowser { |
34 | Q_OBJECT | 87 | Q_OBJECT |
35 | public: | 88 | public: |
36 | KOEventViewer(QWidget *parent=0,const char *name=0); | 89 | KOEventViewer(QWidget *parent=0,const char *name=0); |
37 | virtual ~KOEventViewer(); | 90 | virtual ~KOEventViewer(); |
38 | 91 | ||
39 | void setSource(const QString &); | 92 | void setSource(const QString &); |
40 | void setEvent(Event *event); | 93 | void setEvent(Event *event); |
41 | void addEvent(Event *event); | 94 | void addEvent(Event *event); |
42 | void setTodo(Todo *event, bool clearV = true ); | 95 | void setTodo(Todo *event, bool clearV = true ); |
43 | void setJournal(Journal *jour, bool clearV = true ); | 96 | void setJournal(Journal *jour, bool clearV = true ); |
44 | 97 | ||
45 | void appendEvent(Event *event, int mode = 0 ); | 98 | void appendEvent(Event *event, int mode = 0 ); |
46 | void appendTodo(Todo *event, int mode = 0 ); | 99 | void appendTodo(Todo *event, int mode = 0 ); |
47 | void appendJournal(Journal *jour, int mode = 0 ); | 100 | void appendJournal(Journal *jour, int mode = 0 ); |
48 | 101 | ||
49 | void clearEvents(bool now=false); | 102 | void clearEvents(bool now=false); |
50 | 103 | ||
51 | void addText(QString text); | 104 | void addText(QString text); |
52 | void setSyncMode( bool ); | 105 | void setSyncMode( bool ); |
53 | void setColorMode( int ); | 106 | void setColorMode( int ); |
54 | void mailToAttendees( bool all ); | 107 | void mailToAttendees( bool all ); |
55 | void printMe(); | 108 | void printMe(); |
56 | 109 | ||
57 | protected: | 110 | protected: |
58 | int mColorMode; | 111 | int mColorMode; |
59 | void addTag(const QString & tag,const QString & text); | 112 | void addTag(const QString & tag,const QString & text); |
60 | 113 | ||
61 | void formatCategories(Incidence *event); | 114 | void formatCategories(Incidence *event); |
62 | void formatAttendees(Incidence *event); | 115 | void formatAttendees(Incidence *event); |
63 | void formatReadOnly(Incidence *event); | 116 | void formatReadOnly(Incidence *event); |
64 | void keyPressEvent ( QKeyEvent * e ); | 117 | void keyPressEvent ( QKeyEvent * e ); |
diff --git a/korganizer/koeventviewerdialog.cpp b/korganizer/koeventviewerdialog.cpp index ec55cca..35d084d 100644 --- a/korganizer/koeventviewerdialog.cpp +++ b/korganizer/koeventviewerdialog.cpp | |||
@@ -64,72 +64,64 @@ KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name) | |||
64 | // } | 64 | // } |
65 | mSyncMode = false; | 65 | mSyncMode = false; |
66 | mSyncResult = 0; | 66 | mSyncResult = 0; |
67 | 67 | ||
68 | } | 68 | } |
69 | 69 | ||
70 | KOEventViewerDialog::~KOEventViewerDialog() | 70 | KOEventViewerDialog::~KOEventViewerDialog() |
71 | { | 71 | { |
72 | //qDebug("-------~KOEventViewerDialog() "); | 72 | //qDebug("-------~KOEventViewerDialog() "); |
73 | } | 73 | } |
74 | void KOEventViewerDialog::showMe() | 74 | void KOEventViewerDialog::showMe() |
75 | { | 75 | { |
76 | 76 | ||
77 | #ifdef DESKTOP_VERSION | 77 | #ifdef DESKTOP_VERSION |
78 | int x,y,w,h; | 78 | int x,y,w,h; |
79 | x = geometry().x(); | 79 | x = geometry().x(); |
80 | y = geometry().y(); | 80 | y = geometry().y(); |
81 | w = width(); | 81 | w = width(); |
82 | h = height(); | 82 | h = height(); |
83 | show(); | 83 | show(); |
84 | setGeometry(x,y,w,h); | 84 | setGeometry(x,y,w,h); |
85 | #else | 85 | #else |
86 | showMaximized(); | 86 | showMaximized(); |
87 | #endif | 87 | #endif |
88 | raise(); | 88 | raise(); |
89 | setActiveWindow(); | 89 | setActiveWindow(); |
90 | mEventViewer->setFocus(); | 90 | mEventViewer->setFocus(); |
91 | //raise(); | 91 | //raise(); |
92 | 92 | ||
93 | } | 93 | } |
94 | void KOEventViewerDialog::print() | 94 | void KOEventViewerDialog::print() |
95 | { | 95 | { |
96 | qDebug("PRINT "); | ||
97 | int km = KMessageBox::warningContinueCancel(this,mIncidence->summary().left(35) + | ||
98 | i18n("\n\nDo you really want to print this item?"), | ||
99 | i18n("KO/Pi Print Confirmation"),i18n("Print")); | ||
100 | if ( km != KMessageBox::Continue ) { | ||
101 | qDebug("cancel "); | ||
102 | return; | ||
103 | } | ||
104 | mEventViewer->printMe(); | 96 | mEventViewer->printMe(); |
105 | 97 | ||
106 | } | 98 | } |
107 | void KOEventViewerDialog::setSyncMode( bool b ) | 99 | void KOEventViewerDialog::setSyncMode( bool b ) |
108 | { | 100 | { |
109 | mSyncMode = b; | 101 | mSyncMode = b; |
110 | //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode ); | 102 | //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode ); |
111 | if ( mSyncMode ) { | 103 | if ( mSyncMode ) { |
112 | findButton( Close )->setText( i18n("Cancel Sync")); | 104 | findButton( Close )->setText( i18n("Cancel Sync")); |
113 | findButton( Ok )->setText( i18n("Remote")); | 105 | findButton( Ok )->setText( i18n("Remote")); |
114 | findButton( User1 )->setText( i18n("Local")); | 106 | findButton( User1 )->setText( i18n("Local")); |
115 | } else { | 107 | } else { |
116 | findButton( Close )->setText( i18n("Close")); | 108 | findButton( Close )->setText( i18n("Close")); |
117 | findButton( Ok )->setText( i18n("Edit")); | 109 | findButton( Ok )->setText( i18n("Edit")); |
118 | findButton( User1 )->setText( i18n("Agenda")); | 110 | findButton( User1 )->setText( i18n("Agenda")); |
119 | } | 111 | } |
120 | mEventViewer->setSyncMode( b ); | 112 | mEventViewer->setSyncMode( b ); |
121 | } | 113 | } |
122 | void KOEventViewerDialog::setColorMode( int m ) | 114 | void KOEventViewerDialog::setColorMode( int m ) |
123 | { | 115 | { |
124 | mEventViewer->setColorMode( m ); | 116 | mEventViewer->setColorMode( m ); |
125 | } | 117 | } |
126 | int KOEventViewerDialog::executeS( bool local ) | 118 | int KOEventViewerDialog::executeS( bool local ) |
127 | { | 119 | { |
128 | mSyncResult = 3; | 120 | mSyncResult = 3; |
129 | if ( local ) | 121 | if ( local ) |
130 | findButton( User1 )->setFocus(); | 122 | findButton( User1 )->setFocus(); |
131 | else | 123 | else |
132 | findButton( Ok )->setFocus(); | 124 | findButton( Ok )->setFocus(); |
133 | exec(); | 125 | exec(); |
134 | return mSyncResult; | 126 | return mSyncResult; |
135 | } | 127 | } |
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp index 66ff75d..53fe7d0 100644 --- a/korganizer/kowhatsnextview.cpp +++ b/korganizer/kowhatsnextview.cpp | |||
@@ -12,102 +12,112 @@ | |||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qlayout.h> | 20 | #include <qlayout.h> |
21 | #include <qtextbrowser.h> | 21 | #include <qtextbrowser.h> |
22 | #include <qtextcodec.h> | 22 | #include <qtextcodec.h> |
23 | #include <qfileinfo.h> | 23 | #include <qfileinfo.h> |
24 | #include <qlabel.h> | 24 | #include <qlabel.h> |
25 | 25 | ||
26 | #include <qapplication.h> | 26 | #include <qapplication.h> |
27 | #ifdef DESKTOP_VERSION | 27 | #ifdef DESKTOP_VERSION |
28 | #include <qpaintdevicemetrics.h> | 28 | #include <qpaintdevicemetrics.h> |
29 | #endif | 29 | #endif |
30 | #include <kglobal.h> | 30 | #include <kglobal.h> |
31 | #include <klocale.h> | 31 | #include <klocale.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <kiconloader.h> | 33 | #include <kiconloader.h> |
34 | #include <kmessagebox.h> | 34 | #include <kmessagebox.h> |
35 | 35 | ||
36 | #include <libkcal/calendar.h> | 36 | #include <libkcal/calendar.h> |
37 | 37 | ||
38 | #ifndef KORG_NOPRINTER | 38 | #ifndef KORG_NOPRINTER |
39 | #include "calprinter.h" | 39 | #include "calprinter.h" |
40 | #endif | 40 | #endif |
41 | #include "koglobals.h" | 41 | #include "koglobals.h" |
42 | #include "koprefs.h" | 42 | #include "koprefs.h" |
43 | #include "koeventviewerdialog.h" | 43 | #include "koeventviewerdialog.h" |
44 | #include "koeventviewer.h" | ||
44 | #include <qstylesheet.h> | 45 | #include <qstylesheet.h> |
45 | #include "kowhatsnextview.h" | 46 | #include "kowhatsnextview.h" |
46 | using namespace KOrg; | 47 | using namespace KOrg; |
47 | 48 | ||
48 | void WhatsNextTextBrowser::setSource(const QString& n) | 49 | void WhatsNextTextBrowser::setSource(const QString& n) |
49 | { | 50 | { |
50 | 51 | ||
51 | if (n.startsWith("event:")) { | 52 | if (n.startsWith("event:")) { |
52 | emit showIncidence(n); | 53 | emit showIncidence(n); |
53 | return; | 54 | return; |
54 | } else if (n.startsWith("todo:")) { | 55 | } else if (n.startsWith("todo:")) { |
55 | emit showIncidence(n); | 56 | emit showIncidence(n); |
56 | return; | 57 | return; |
57 | } else { | 58 | } else { |
58 | QTextBrowser::setSource(n); | 59 | QTextBrowser::setSource(n); |
59 | } | 60 | } |
60 | } | 61 | } |
61 | void WhatsNextTextBrowser::printMe() | 62 | void WhatsNextTextBrowser::printMe() |
62 | { | 63 | { |
63 | #ifdef DESKTOP_VERSION | 64 | #ifdef DESKTOP_VERSION |
65 | KOPrintPrefs pp ( this ); | ||
66 | if (!pp.exec() ) | ||
67 | return; | ||
68 | int scaleval = pp.printMode() ; | ||
69 | |||
64 | QPrinter printer; | 70 | QPrinter printer; |
65 | if (!printer.setup() ) | 71 | if (!printer.setup() ) |
66 | return; | 72 | return; |
67 | QPainter p; | 73 | QPainter p; |
68 | p.begin ( &printer ); | 74 | p.begin ( &printer ); |
69 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | 75 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); |
70 | float dx, dy; | 76 | float dx, dy; |
71 | int wid = (m.width() * 9)/10; | 77 | int wid = (m.width() * 9)/10; |
72 | dx = (float) wid/(float)contentsWidth (); | 78 | dx = (float) wid/(float)contentsWidth (); |
73 | dy = (float)(m.height()) / (float)contentsHeight (); | 79 | dy = (float)(m.height()) / (float)contentsHeight (); |
74 | float scale; | 80 | float scale; |
75 | // scale to fit the width or height of the paper | 81 | // scale to fit the width or height of the paper |
76 | if ( dx < dy ) | 82 | if ( dx < dy ) |
77 | scale = dx; | 83 | scale = dx; |
78 | else | 84 | else |
79 | scale = dy; | 85 | scale = dy; |
80 | p.translate( m.width()/10,0 ); | 86 | p.translate( m.width()/10,0 ); |
81 | p.scale( scale, scale ); | 87 | qDebug("Scale: %f ", scale ); |
88 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { | ||
89 | qDebug("SCALE "); | ||
90 | p.scale( scale, scale ); | ||
91 | } | ||
82 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); | 92 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); |
83 | p.end(); | 93 | p.end(); |
84 | #endif | 94 | #endif |
85 | } | 95 | } |
86 | 96 | ||
87 | KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, | 97 | KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, |
88 | const char *name) | 98 | const char *name) |
89 | : KOrg::BaseView(calendar, parent, name) | 99 | : KOrg::BaseView(calendar, parent, name) |
90 | { | 100 | { |
91 | // mDateLabel = | 101 | // mDateLabel = |
92 | // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); | 102 | // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); |
93 | // mDateLabel->setMargin(2); | 103 | // mDateLabel->setMargin(2); |
94 | // mDateLabel->setAlignment(AlignCenter); | 104 | // mDateLabel->setAlignment(AlignCenter); |
95 | setFont( KOPrefs::instance()->mWhatsNextFont ); | 105 | setFont( KOPrefs::instance()->mWhatsNextFont ); |
96 | mView = new WhatsNextTextBrowser(this); | 106 | mView = new WhatsNextTextBrowser(this); |
97 | connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); | 107 | connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); |
98 | QStyleSheet* stsh = mView->styleSheet(); | 108 | QStyleSheet* stsh = mView->styleSheet(); |
99 | QStyleSheetItem * style ; | 109 | QStyleSheetItem * style ; |
100 | style = stsh->item ("h2" ); | 110 | style = stsh->item ("h2" ); |
101 | if ( style ) { | 111 | if ( style ) { |
102 | style->setMargin(QStyleSheetItem::MarginAll,0); | 112 | style->setMargin(QStyleSheetItem::MarginAll,0); |
103 | } | 113 | } |
104 | style = stsh->item ("h3" ); | 114 | style = stsh->item ("h3" ); |
105 | if ( style ) { | 115 | if ( style ) { |
106 | style->setMargin(QStyleSheetItem::MarginAll,0); | 116 | style->setMargin(QStyleSheetItem::MarginAll,0); |
107 | } | 117 | } |
108 | mEventViewer = 0; | 118 | mEventViewer = 0; |
109 | 119 | ||
110 | QBoxLayout *topLayout = new QVBoxLayout(this); | 120 | QBoxLayout *topLayout = new QVBoxLayout(this); |
111 | // topLayout->addWidget(mDateLabel); | 121 | // topLayout->addWidget(mDateLabel); |
112 | topLayout->addWidget(mView); | 122 | topLayout->addWidget(mView); |
113 | mTimer = new QTimer( this ); | 123 | mTimer = new QTimer( this ); |