Subversion Repositories svn1

Rev

Rev 211 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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