Subversion Repositories svn1

Rev

Rev 383 | Details | Compare with Previous | Last modification | View Log | RSS feed

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