Subversion Repositories svn1

Rev

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