Eneboo - Documentación para desarrolladores
|
00001 /*************************************************************************** 00002 mreportviewer.h - Kugar QT report viewer widget 00003 ------------------- 00004 begin : Fri Aug 13 1999 00005 copyright : (C) 1999 by Mutiny Bay Software 00006 email : info@mutinybaysoftware.com 00007 copyright : (C) 2002 Alexander Dymo 00008 email : cloudtemple@mksat.net 00009 copyright : (C) 2002-2004 InfoSiAL S.L. 00010 email : mail@infosial.com 00011 ***************************************************************************/ 00012 00013 #ifndef MREPORTVIEWER_H 00014 #define MREPORTVIEWER_H 00015 00016 #include <qapplication.h> 00017 #include <qwidget.h> 00018 #include <qscrollview.h> 00019 #include <qpixmap.h> 00020 #include <qpainter.h> 00021 #include <qpaintdevicemetrics.h> 00022 #include <qprogressdialog.h> 00023 #include <qapplication.h> 00024 #include <qmessagebox.h> 00025 #include <qprinter.h> 00026 #include <qprocess.h> 00027 #include <qtimer.h> 00028 00029 #include "mreportengine.h" 00030 #include "mpagecollection.h" 00031 #include "mpagedisplay.h" 00032 00033 #define M_PROGRESS_DELAY 1000 // Number of ms to delay progress dialog display 00034 00035 #if defined(Q_OS_WIN32) || defined(Q_OS_MACX) 00036 class PSPrinter; 00037 #endif 00038 00039 class FLPosPrinter; 00040 00046 class FL_EXPORT MReportViewer: public QWidget 00047 { 00048 00049 Q_OBJECT 00050 00051 Q_ENUMS(RenderReportFlags) 00052 00053 public: 00054 00055 // Si cambias este Enum hazlo tambien en mreportengine.h 00056 enum RenderReportFlags { 00057 Append = 0x00000001, 00058 Display = 0x00000002, 00059 PageBreak = 0x00000004, 00060 FillRecords = 0x00000008 00061 }; 00062 00063 MReportViewer(QWidget *parent = 0, const char *name = 0); 00064 virtual ~ MReportViewer(); 00065 00066 bool setReportData(const QString &); 00067 bool setReportData(QIODevice *); 00068 bool setReportTemplate(const QString &); 00069 bool setReportTemplate(QIODevice *); 00070 bool renderReport(int initRow = 0, int initCol = 0, 00071 bool append = false, bool display = true); 00072 bool renderReport(int initRow = 0, int initCol = 0, 00073 uint flags = MReportViewer::Display); 00074 void clearReport(); 00075 bool printReport(); 00076 bool printReportToPS(const QString &); 00077 bool printReportToPDF(const QString &); 00078 00079 QSize sizeHint() const; 00080 00081 void setNumCopies(const int numCopies); 00082 void setPrintToPos(bool ptp); 00083 void setPrinterName(const QString &pName); 00084 00085 void setResolution(int dpi); 00086 int resolution() const { 00087 return dpi_; 00088 } 00089 00090 void setReportPages(MPageCollection *pgs); 00091 MPageCollection *reportPages(); 00092 00093 public slots: 00094 00095 void setReportEngine(MReportEngine * = 0); 00096 void slotFirstPage(); 00097 void slotNextPage(); 00098 void slotPrevPage(); 00099 void slotLastPage(); 00100 void slotZoomUp(); 00101 void slotZoomDown(); 00102 void slotUpdateDisplay(); 00103 00104 signals: 00105 00106 void preferedTemplate(const QString &); 00107 00108 private slots: 00109 00110 void slotCancelPrinting(); 00111 void slotRenderProgress(int); 00112 00113 protected: 00114 00115 void paintEvent(QPaintEvent *event); 00116 void resizeEvent(QResizeEvent *event); 00117 00118 bool printGhostReport(); 00119 bool printGhostReportToPS(const QString &); 00120 bool printPosReport(); 00121 00122 QScrollView *scroller; 00123 MPageDisplay *display; 00124 MReportEngine *rptEngine; 00125 MPageCollection *report; 00126 QPrinter *printer; 00127 FLPosPrinter *posprinter; 00128 #if defined(Q_OS_WIN32) || defined(Q_OS_MACX) 00129 PSPrinter *psprinter; 00130 #endif 00131 QProgressDialog *progress; 00132 int totalSteps; 00133 int numCopies_; 00134 bool printToPos_; 00135 QString printerName_; 00136 int dpi_; 00137 }; 00138 00139 inline void MReportViewer::setNumCopies(const int numCopies) 00140 { 00141 numCopies_ = numCopies; 00142 } 00143 00144 inline void MReportViewer::setPrintToPos(bool ptp) 00145 { 00146 printToPos_ = ptp; 00147 } 00148 00149 inline void MReportViewer::setPrinterName(const QString &pName) 00150 { 00151 printerName_ = pName; 00152 } 00153 00154 inline void MReportViewer::setResolution(int dpi) 00155 { 00156 dpi_ = dpi; 00157 } 00158 00159 inline MPageCollection *MReportViewer::reportPages() 00160 { 00161 return report; 00162 } 00163 #endif