Subversion Repositories svn1

Rev

Rev 331 | 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>
205 - 7
#include <QWebView>
8
#include <QUrl>
207 - 9
#include <QAction>
258 - 10
#include <QDoubleSpinBox>
283 david 11
#include <QContextMenuEvent>
156 - 12
 
168 david 13
class QWidget;
207 - 14
class QPrinter;
205 - 15
class QmWebView;
211 - 16
class QPrintPreviewDialog;
156 - 17
 
204 - 18
class QmReportWindow : public QWidget
156 - 19
{
20
    Q_OBJECT
21
 
22
public:
23
    explicit QmReportWindow(QWidget *parent = 0);
24
    ~QmReportWindow();
203 - 25
    void addReport(const QString &report, const QString &name);
283 david 26
    static QmWebView *newTab(void);
27
    static void setTabName(const int tab,const QString &name);
288 david 28
    static void updateTabPath(void);
204 - 29
 
30
private:
31
    QTabWidget *tabWidget;
32
    QLineEdit *tabPath;
207 - 33
    QAction *pb_original;
34
    QAction *pb_back;
35
    QAction *pb_forward;
280 david 36
    QAction *pb_explore;
37
    QAction *pb_openExternal;
207 - 38
    QAction *pb_print;
258 - 39
    QDoubleSpinBox *pb_size;
205 - 40
    QmWebView *currentWebView;
211 - 41
    QPrintPreviewDialog *printPreviewDialog;
258 - 42
    QmWebView *currentWebViewPrinter;
43
    QPrinter *printer;
204 - 44
 
45
private slots:
46
    void deleteTab(int tab);
47
    void tabChanged(int tab);
48
    void back(void);
205 - 49
    void forward(void);
50
    void home(void);
207 - 51
    void print(void);
52
    void printPreview(QPrinter * printer);
280 david 53
    void openLocation(void);
54
    void openExternal(void);
156 - 55
};
56
 
205 - 57
class QmWebView : public QWebView
58
{
283 david 59
    Q_OBJECT
60
 
205 - 61
public:
283 david 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));
71
        QWebView::setUrl(QUrl(url,QUrl::TolerantMode));
72
    }
73
 
74
    void setTab (const int utab) { tab = utab; }
205 - 75
    void home(void) { QWebView::setUrl(QUrl(homeUrl,QUrl::TolerantMode)); }
76
    QString homeUrl;
283 david 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()));
288 david 95
            QmReportWindow::updateTabPath();
283 david 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
        }
205 - 112
};
113
 
156 - 114
#endif // QMREPORTWINDOW_H