rename webpage and webview to swisswebpage and swissswebview to be more specific; refs #115
parent
66f3cad774
commit
7bb38a75f4
7 changed files with 100 additions and 69 deletions
@ -0,0 +1,64 @@ |
|||||||
|
/*! @file
|
||||||
|
|
||||||
|
@id $Id$ |
||||||
|
*/ |
||||||
|
// 1 2 3 4 5 6 7 8
|
||||||
|
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
||||||
|
|
||||||
|
#ifndef SWISSWEBVIEW_HXX |
||||||
|
#define SWISSWEBVIEW_HXX |
||||||
|
|
||||||
|
#include <qbrowserlib/swisswebpage.hxx> |
||||||
|
|
||||||
|
#include <QtWebKit> |
||||||
|
#include <QtDesigner/QDesignerExportWidget> |
||||||
|
|
||||||
|
#include <memory> |
||||||
|
|
||||||
|
//! QWebViev class with additional features.
|
||||||
|
/*! This QWebView class contains a @ref SwissWebPage and adds a new
|
||||||
|
signal @refs newView that sends the view whenever the a new view |
||||||
|
(new window, new tab) must be opened. |
||||||
|
|
||||||
|
\copydetails SwissWebView::newView(SwissWebView*) |
||||||
|
*/
|
||||||
|
class QDESIGNER_WIDGET_EXPORT SwissWebView: public QWebView { |
||||||
|
Q_OBJECT; |
||||||
|
signals: |
||||||
|
//! Signals that a new window (or tab) must be opened
|
||||||
|
/*! @note You @b must connect to @ref newView and assign the new
|
||||||
|
@ref SwissWebView instance to a partent widget or at least |
||||||
|
delete it, otherwise you'll have a memory leak! */ |
||||||
|
void newView(SwissWebView*); |
||||||
|
public: |
||||||
|
//! Default construction, creates new @ref SwissWebView
|
||||||
|
SwissWebView(QWidget *parent=0): QWebView(parent) { |
||||||
|
//! @bugfix, gcc does not yet support constructor calling
|
||||||
|
x(new SwissWebPage); |
||||||
|
} |
||||||
|
//! Construction with externally allocated @ref SwissWebPage
|
||||||
|
/*! SwissWebView takes ownership of SwissWebPage. */ |
||||||
|
SwissWebView(SwissWebPage* webpage) { |
||||||
|
//! @bugfix, gcc does not yet support constructor calling
|
||||||
|
x(webpage);
|
||||||
|
} |
||||||
|
private: |
||||||
|
//! @bugfix, gcc does not yet support constructor calling
|
||||||
|
/*! @see http://en.wikipedia.org/wiki/C++11#Object_construction_improvement
|
||||||
|
*/ |
||||||
|
void x(SwissWebPage* webpage) { |
||||||
|
webpage->setParent(this); |
||||||
|
setPage(webpage); |
||||||
|
// create a new SwissWebView when a new SwissWebPage has been created
|
||||||
|
assert(connect(page(), SIGNAL(newPage(SwissWebPage*)), |
||||||
|
SLOT(newPage(SwissWebPage*)))); |
||||||
|
} |
||||||
|
private slots: |
||||||
|
void newPage(SwissWebPage* p) { |
||||||
|
// memory will be lost if signal is not handled and SwissWebView
|
||||||
|
// is not assigned
|
||||||
|
newView(new SwissWebView(p)); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
#endif |
@ -1,49 +0,0 @@ |
|||||||
/*! @file
|
|
||||||
|
|
||||||
@id $Id$ |
|
||||||
*/ |
|
||||||
// 1 2 3 4 5 6 7 8
|
|
||||||
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
|
||||||
|
|
||||||
#ifndef WEBVIEW_HXX |
|
||||||
#define WEBVIEW_HXX |
|
||||||
|
|
||||||
#include <qbrowserlib/webpage.hxx> |
|
||||||
#include <qbrowserlib/pluginfactory.hxx> |
|
||||||
|
|
||||||
#include <QtWebKit> |
|
||||||
#include <QtDesigner/QDesignerExportWidget> |
|
||||||
|
|
||||||
#include <memory> |
|
||||||
|
|
||||||
class QDESIGNER_WIDGET_EXPORT WebView: public QWebView { |
|
||||||
Q_OBJECT; |
|
||||||
signals: |
|
||||||
void newView(WebView*); |
|
||||||
public: |
|
||||||
WebView(WebPage* webpage) { |
|
||||||
x(webpage); //! @bugfix, gcc does not yet support constructor calling
|
|
||||||
} |
|
||||||
WebView(QWidget *parent=0): QWebView(parent) { |
|
||||||
x(new WebPage); //! @bugfix, gcc does not yet support constructor calling
|
|
||||||
} |
|
||||||
private: |
|
||||||
//! @bugfix, gcc does not yet support constructor calling
|
|
||||||
/*! @see http://en.wikipedia.org/wiki/C++11#Object_construction_improvement
|
|
||||||
*/ |
|
||||||
void x(WebPage* webpage) { |
|
||||||
webpage->setParent(this); |
|
||||||
setPage(webpage); |
|
||||||
page()->setPluginFactory(new PluginFactory); |
|
||||||
page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); |
|
||||||
page()->setForwardUnsupportedContent(true); |
|
||||||
assert(connect(page(), SIGNAL(newPage(WebPage*)), |
|
||||||
SLOT(newPage(WebPage*)))); |
|
||||||
} |
|
||||||
private slots: |
|
||||||
void newPage(WebPage* p) { |
|
||||||
newView(new WebView(p)); |
|
||||||
} |
|
||||||
}; |
|
||||||
|
|
||||||
#endif |
|
Loading…
Reference in new issue