00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _CALPRINTER_H
00024 #define _CALPRINTER_H
00025
00026 #include <unistd.h>
00027
00028 #include <qfile.h>
00029 #include <qdialog.h>
00030
00031 #include <kprinter.h>
00032 #include <kprocess.h>
00033
00034 #include <libkcal/calendar.h>
00035
00036 class KDateEdit;
00037 class QButtonGroup;
00038 class CalPrintDialog;
00039 class KTempFile;
00040
00041 using namespace KCal;
00042
00048 class CalPrinter : public QObject
00049 {
00050 Q_OBJECT
00051 public:
00052 enum PrintType { Day, Week, Month, Todolist, TimeTable };
00053 CalPrinter(QWidget *par, Calendar *cal);
00054 virtual ~CalPrinter();
00055
00056 void setupPrinter();
00057 void preview(PrintType pt, const QDate &fd, const QDate &td);
00058 void print(PrintType pt, const QDate &fd, const QDate &td);
00059
00060 public slots:
00061 void updateConfig();
00062 void printDay(const QDate &fd, const QDate &td);
00063 void printWeek(const QDate &fd, const QDate &td);
00064 void printMonth(const QDate &fd, const QDate &td);
00065 void printTodo(const QDate &fd, const QDate &td);
00066 void printTimeTable(const QDate &fd, const QDate &td);
00067
00068 private slots:
00069 void doPreview(int, QDate, QDate);
00070 void doPrint(int, QDate, QDate);
00071
00072 private:
00073 void drawHeader(QPainter &p, const QDate &fd, const QDate &td,
00074 const QDate &cd,
00075 int width, int height, PrintType pt = Month);
00076 void drawDayBox(QPainter &p, const QDate &qd,
00077 int x, int y, int width, int height,
00078 bool fullDate = FALSE);
00079 void drawTTDayBox(QPainter &p, const QDate &qd,
00080 int x, int y, int width, int height,
00081 bool fullDate = FALSE);
00082 void drawDay(QPainter &p, const QDate &qd, int width, int height);
00083 void drawWeek(QPainter &p, const QDate &qd, int width, int height);
00084 void drawTimeTable(QPainter &p, const QDate &qd, int width, int height);
00085 void drawMonth(QPainter &p, const QDate &qd, int width, int height);
00086 void drawSmallMonth(QPainter &p, const QDate &qd,
00087 int x, int y, int width, int height);
00088 void drawDaysOfWeekBox(QPainter &p, const QDate &qd,
00089 int x, int y, int width, int height);
00090 void drawDaysOfWeek(QPainter &p, const QDate &qd, int width, int height);
00091 void drawTodo(int count, Todo *item,QPainter &p,int level=0, QRect *r=0);
00092
00093 KPrinter *mPrinter;
00094 Calendar *mCalendar;
00095 QWidget *mParent;
00096 int mHeaderHeight;
00097 int mSubHeaderHeight;
00098 int mStartHour;
00099 int mCurrentLinePos;
00100 CalPrintDialog *mPrintDialog;
00101 };
00102
00103 class CalPrintDialog : public QDialog
00104 {
00105 Q_OBJECT
00106 public:
00107 CalPrintDialog(KPrinter *p, QWidget *parent=0, const char *name=0);
00108 virtual ~CalPrintDialog();
00109
00110 QDate fromDate() const;
00111 QDate toDate() const;
00112 CalPrinter::PrintType printType() const;
00113
00114 void setRange(const QDate &from, const QDate &to);
00115 void setPreview(bool);
00116
00117 public slots:
00118 void setPrintDay();
00119 void setPrintWeek();
00120 void setPrintMonth();
00121 void setPrintTodo();
00122 void setPrintTimeTable();
00123
00124 private:
00125 KPrinter *mPrinter;
00126
00127 QPushButton *mOkButton;
00128 QButtonGroup *mTypeGroup;
00129 KDateEdit *mFromDateEdit;
00130 KDateEdit *mToDateEdit;
00131 CalPrinter::PrintType mPrintType;
00132 };
00133
00134 #endif // _CALPRINTER_H