Subversion Repositories svn1

Rev

Rev 280 | Go to most recent revision | 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);
204 - 28
 
29
private:
30
    QTabWidget *tabWidget;
31
    QLineEdit *tabPath;
207 - 32
    QAction *pb_original;
33
    QAction *pb_back;
34
    QAction *pb_forward;
280 david 35
    QAction *pb_explore;
36
    QAction *pb_openExternal;
207 - 37
    QAction *pb_print;
258 - 38
    QDoubleSpinBox *pb_size;
205 - 39
    QmWebView *currentWebView;
211 - 40
    QPrintPreviewDialog *printPreviewDialog;
258 - 41
    QmWebView *currentWebViewPrinter;
42
    QPrinter *printer;
204 - 43
 
44
private slots:
45
    void deleteTab(int tab);
46
    void tabChanged(int tab);
47
    void back(void);
205 - 48
    void forward(void);
49
    void home(void);
207 - 50
    void print(void);
51
    void printPreview(QPrinter * printer);
280 david 52
    void openLocation(void);
53
    void openExternal(void);
156 - 54
};
55
 
205 - 56
class QmWebView : public QWebView
57
{
283 david 58
    Q_OBJECT
59
 
205 - 60
public:
283 david 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));
70
        QWebView::setUrl(QUrl(url,QUrl::TolerantMode));
71
    }
72
 
73
    void setTab (const int utab) { tab = utab; }
205 - 74
    void home(void) { QWebView::setUrl(QUrl(homeUrl,QUrl::TolerantMode)); }
75
    QString homeUrl;
283 david 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
        }
205 - 110
};
111
 
156 - 112
#endif // QMREPORTWINDOW_H