Subversion Repositories svn1-original

Rev

Rev 284 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
160 - 1
#ifndef QMREPORTWINDOW_H
2
#define QMREPORTWINDOW_H
3
 
4
#include <QTabWidget>
208 - 5
#include <QLineEdit>
6
#include <QPushButton>
209 - 7
#include <QWebView>
8
#include <QUrl>
211 - 9
#include <QAction>
262 - 10
#include <QDoubleSpinBox>
287 david 11
#include <QContextMenuEvent>
160 - 12
 
172 david 13
class QWidget;
211 - 14
class QPrinter;
209 - 15
class QmWebView;
215 - 16
class QPrintPreviewDialog;
160 - 17
 
208 - 18
class QmReportWindow : public QWidget
160 - 19
{
20
    Q_OBJECT
21
 
22
public:
23
    explicit QmReportWindow(QWidget *parent = 0);
24
    ~QmReportWindow();
207 - 25
    void addReport(const QString &report, const QString &name);
287 david 26
    static QmWebView *newTab(void);
27
    static void setTabName(const int tab,const QString &name);
208 - 28
 
29
private:
30
    QTabWidget *tabWidget;
31
    QLineEdit *tabPath;
211 - 32
    QAction *pb_original;
33
    QAction *pb_back;
34
    QAction *pb_forward;
284 david 35
    QAction *pb_explore;
36
    QAction *pb_openExternal;
211 - 37
    QAction *pb_print;
262 - 38
    QDoubleSpinBox *pb_size;
209 - 39
    QmWebView *currentWebView;
215 - 40
    QPrintPreviewDialog *printPreviewDialog;
262 - 41
    QmWebView *currentWebViewPrinter;
42
    QPrinter *printer;
208 - 43
 
44
private slots:
45
    void deleteTab(int tab);
46
    void tabChanged(int tab);
47
    void back(void);
209 - 48
    void forward(void);
49
    void home(void);
211 - 50
    void print(void);
51
    void printPreview(QPrinter * printer);
284 david 52
    void openLocation(void);
53
    void openExternal(void);
160 - 54
};
55
 
209 - 56
class QmWebView : public QWebView
57
{
287 david 58
    Q_OBJECT
59
 
209 - 60
public:
287 david 61
    QmWebView(QWidget * parent = 0 ) : QWebView(parent)
62
    {
63
        tab = 0;
64
        connect(this,SIGNAL(urlChanged(QUrl)), this,SLOT(lurlChanged(QUrl)));
65
    }
66
    void setUrl(const QString &url)
67
    {
68
        homeUrl = url;
69
        //qDebug("QmWebView::setUrl:%s", qPrintable(url));
70
        QWebView::setUrl(QUrl(url,QUrl::TolerantMode));
71
    }
72
 
73
    void setTab (const int utab) { tab = utab; }
209 - 74
    void home(void) { QWebView::setUrl(QUrl(homeUrl,QUrl::TolerantMode)); }
75
    QString homeUrl;
287 david 76
    int tab;
77
    //void contextMenuEvent ( QContextMenuEvent * event )
78
    //{
79
    //    qDebug("QmWebView::contextMenuEvent");
80
    //    QWebView::contextMenuEvent(event);
81
    //}
82
    QWebView * createWindow ( QWebPage::WebWindowType type )
83
    {
84
        //qDebug("QmWebView::createWindow:%d", type);
85
        QWebView *nwv = QmReportWindow::newTab();
86
        //qDebug("QmWebView::createWindow:%p", nwv);
87
        return(nwv);
88
    }
89
 
90
    private slots:
91
        void lurlChanged ( const QUrl & url )
92
        {
93
            //qDebug("urlChanged:%s", qPrintable(url.toString()));
94
 
95
            // If the home URL has never been set
96
            if (homeUrl.isEmpty())
97
            {
98
                // Convert URL to string and remove any tag from the end of it
99
                homeUrl = url.toString();
100
                homeUrl.remove(QRegExp("#.*"));
101
 
102
                // Set the tab name too
103
                // Just retain base file name
104
                QString name(homeUrl);
105
                name.remove(QRegExp(".*/"));
106
                name.remove(QRegExp("\\.html"));
107
                QmReportWindow::setTabName(tab, name);
108
            }
109
        }
209 - 110
};
111
 
160 - 112
#endif // QMREPORTWINDOW_H