Rev 292 | Blame | Compare with Previous | Last modification | View Log | RSS feed
#ifndef QMREPORTWINDOW_H#define QMREPORTWINDOW_H#include <QTabWidget>#include <QLineEdit>#include <QPushButton>#include <QWebView>#include <QUrl>#include <QAction>#include <QDoubleSpinBox>#include <QContextMenuEvent>class QWidget;class QPrinter;class QmWebView;class QPrintPreviewDialog;class QmReportWindow : public QWidget{Q_OBJECTpublic:explicit QmReportWindow(QWidget *parent = 0);~QmReportWindow();void addReport(const QString &report, const QString &name);static QmWebView *newTab(void);static void setTabName(const int tab,const QString &name);static void updateTabPath(void);private:QTabWidget *tabWidget;QLineEdit *tabPath;QAction *pb_original;QAction *pb_back;QAction *pb_forward;QAction *pb_explore;QAction *pb_openExternal;QAction *pb_print;QDoubleSpinBox *pb_size;QmWebView *currentWebView;QPrintPreviewDialog *printPreviewDialog;QmWebView *currentWebViewPrinter;QPrinter *printer;private slots:void deleteTab(int tab);void tabChanged(int tab);void back(void);void forward(void);void home(void);void print(void);void printPreview(QPrinter * printer);void openLocation(void);void openExternal(void);};class QmWebView : public QWebView{Q_OBJECTpublic:QmWebView(QWidget * parent = 0 ) : QWebView(parent){tab = 0;connect(this,SIGNAL(urlChanged(QUrl)), this,SLOT(lurlChanged(QUrl)));}void setUrl(const QString &url){homeUrl = url;//qDebug("QmWebView::setUrl:%s", qPrintable(url));QWebView::setUrl(QUrl(url,QUrl::TolerantMode));}void setTab (const int utab) { tab = utab; }void home(void) { QWebView::setUrl(QUrl(homeUrl,QUrl::TolerantMode)); }QString homeUrl;int tab;//void contextMenuEvent ( QContextMenuEvent * event )//{// qDebug("QmWebView::contextMenuEvent");// QWebView::contextMenuEvent(event);//}QWebView * createWindow ( QWebPage::WebWindowType type ){//qDebug("QmWebView::createWindow:%d", type);QWebView *nwv = QmReportWindow::newTab();//qDebug("QmWebView::createWindow:%p", nwv);return(nwv);}private slots:void lurlChanged ( const QUrl & url ){//qDebug("urlChanged:%s", qPrintable(url.toString()));QmReportWindow::updateTabPath();// If the home URL has never been setif (homeUrl.isEmpty()){// Convert URL to string and remove any tag from the end of ithomeUrl = url.toString();homeUrl.remove(QRegExp("#.*"));// Set the tab name too// Just retain base file nameQString name(homeUrl);name.remove(QRegExp(".*/"));name.remove(QRegExp("\\.html"));QmReportWindow::setTabName(tab, name);}}};#endif // QMREPORTWINDOW_H