summaryrefslogtreecommitdiffstats
path: root/kugar/lib/mreportviewer.h
blob: 1c6f4c0348256e57d96dd303c43dda3adf7ccf2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/***************************************************************************
             mreportviewer.h  -  Kugar QT report viewer widget
             -------------------
   begin     : Fri Aug 13 1999
   copyright : (C) 1999 by Mutiny Bay Software
   email     : [email protected]
   copyright : (C) 2002 Alexander Dymo
   email     : [email protected]
***************************************************************************/

#ifndef MREPORTVIEWER_H
#define MREPORTVIEWER_H

#include <qapplication.h>
#include <qwidget.h>
#include <qscrollview.h>
#include <qpixmap.h>
#include <qpainter.h>
#include <qpaintdevicemetrics.h>
#include <qprogressdialog.h>
#include <qguardedptr.h>
#include <koffice_export.h>
#include "mreportengine.h"
#include "mpagecollection.h"
#include "mpagedisplay.h"

#define M_PROGRESS_DELAY 500            // Number of ms to delay progress dialog display

class KPrinter;

/** Application reference, required for event processing */
extern QApplication *mAppRef;

/**Kugar QT report viewer widget
  *@author Mutiny Bay Software
  */

namespace Kugar
{

class KUGAR_EXPORT MReportViewer : public QWidget
{
    Q_OBJECT

public:
    MReportViewer( QWidget *parent = 0, const char *name = 0 );
    MReportViewer( MReportEngine* engine, QWidget *parent = 0, const char *name = 0 );
    virtual ~MReportViewer();

    bool setReportData( const QString & );
    bool setReportData( QIODevice * );
    bool setReportTemplate( const QString & );
    bool setReportTemplate( QIODevice * );
    bool renderReport();
    void clearReport();
    void printReport();
    void printReport( KPrinter &printer );
    void setupPrinter( KPrinter &printer );
    void printReportSilent( int printFrom = -1, int printTo = -1, int printCopies = -1, QString printerName = QString::null );

    QSize sizeHint() const;

public slots:
    void slotFirstPage();
    void slotNextPage();
    void slotPrevPage();
    void slotLastPage();

signals:
    void preferedTemplate( const QString & );

private slots:
    void slotCancelPrinting();
    void slotRenderProgress( int );

protected:
    void paintEvent( QPaintEvent *event );
    void resizeEvent( QResizeEvent *event );

    QScrollView *scroller;
    MPageDisplay *display;
    MReportEngine *rptEngine;
    QGuardedPtr<MPageCollection> report;
    KPrinter *printer;

private:
    QProgressDialog* progress;
    int totalSteps;
    void init();
};

}

#endif