Subversion Repositories svn1-original

Rev

Rev 284 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 284 Rev 287
Line 6... Line 6...
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>
10
#include <QDoubleSpinBox>
-
 
11
#include <QContextMenuEvent>
11
 
12
 
12
class QWidget;
13
class QWidget;
13
class QPrinter;
14
class QPrinter;
14
class QmWebView;
15
class QmWebView;
15
class QPrintPreviewDialog;
16
class QPrintPreviewDialog;
Line 20... Line 21...
20
 
21
 
21
public:
22
public:
22
    explicit QmReportWindow(QWidget *parent = 0);
23
    explicit QmReportWindow(QWidget *parent = 0);
23
    ~QmReportWindow();
24
    ~QmReportWindow();
24
    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);
25
 
28
 
26
private:
29
private:
27
    QTabWidget *tabWidget;
30
    QTabWidget *tabWidget;
28
    QLineEdit *tabPath;
31
    QLineEdit *tabPath;
29
    QAction *pb_original;
32
    QAction *pb_original;
Line 50... Line 53...
50
    void openExternal(void);
53
    void openExternal(void);
51
};
54
};
52
 
55
 
53
class QmWebView : public QWebView
56
class QmWebView : public QWebView
54
{
57
{
-
 
58
    Q_OBJECT
-
 
59
 
55
public:
60
public:
56
    QmWebView(QWidget * parent = 0 ) : QWebView(parent) {}
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));
57
    void setUrl(const QString &url) { homeUrl = url; QWebView::setUrl(QUrl(url,QUrl::TolerantMode)); }
70
        QWebView::setUrl(QUrl(url,QUrl::TolerantMode));
-
 
71
    }
-
 
72
 
-
 
73
    void setTab (const int utab) { tab = utab; }
58
    void home(void) { QWebView::setUrl(QUrl(homeUrl,QUrl::TolerantMode)); }
74
    void home(void) { QWebView::setUrl(QUrl(homeUrl,QUrl::TolerantMode)); }
59
    QString homeUrl;
75
    QString homeUrl;
-
 
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
        }
60
};
110
};
61
 
111
 
62
#endif // QMREPORTWINDOW_H
112
#endif // QMREPORTWINDOW_H