ginebra2/PageSnippet.cpp
changeset 6 1c3b8676e58c
parent 5 0f2326c2a325
child 15 73c48011b8c7
equal deleted inserted replaced
5:0f2326c2a325 6:1c3b8676e58c
    20 */
    20 */
    21 
    21 
    22 #include "PageSnippet.h"
    22 #include "PageSnippet.h"
    23 #include "PageItem.h"
    23 #include "PageItem.h"
    24 #include "Utilities.h"
    24 #include "Utilities.h"
    25 #include "ObjectCharm.h"
    25 #include "ExternalEventCharm.h"
    26 
    26 
    27 #include <QGraphicsWebView>
    27 #include <QGraphicsWebView>
    28 #include <QVariant>
    28 #include <QVariant>
    29 
    29 
    30 namespace GVA {
    30 namespace GVA {
    45 // PageSnippet
    45 // PageSnippet
    46 // ----------------------------
    46 // ----------------------------
    47 
    47 
    48 PageSnippet::PageSnippet(const QString & elementId, ChromeWidget * chrome,
    48 PageSnippet::PageSnippet(const QString & elementId, ChromeWidget * chrome,
    49                          QGraphicsWidget * widget, const QWebElement & element)
    49                          QGraphicsWidget * widget, const QWebElement & element)
    50   : ChromeSnippet(elementId, chrome, widget, element)
    50   : ChromeSnippet(elementId, chrome, widget, element),
       
    51     m_externalEventCharm(0)
    51 {
    52 {
    52 }
    53 }
    53 
    54 
    54 void PageSnippet::setWidget(QGraphicsWidget * widget) {
    55 PageSnippet::~PageSnippet() {
    55     ChromeSnippet::setWidget(widget);
    56     delete m_externalEventCharm;
    56     ExternalEventCharm *charm = new ExternalEventCharm(widget);  // auto deleted
    57 }
    57     safe_connect(charm, SIGNAL(externalMouseEvent(int, const QString &, const QString &)),
    58 
    58                  this, SIGNAL(externalMouseEvent(int, const QString &, const QString &)));
    59 PageSnippet * PageSnippet::instance(const QString& elementId, ChromeWidget * chrome, const QWebElement & element)
       
    60 {
       
    61     PageSnippet* that = new PageSnippet(elementId, chrome, 0, element);
       
    62     that->setChromeWidget( new PageItem( that, chrome ) );
       
    63     return that;
       
    64 }
       
    65 
       
    66 void PageSnippet::setChromeWidget(QGraphicsWidget * widget) {
       
    67     ChromeSnippet::setChromeWidget(widget);
       
    68     m_externalEventCharm = new ExternalEventCharm(widget);
       
    69     safe_connect(m_externalEventCharm, SIGNAL(externalMouseEvent(QEvent*, const QString &, const QString &)),
       
    70                  this, SIGNAL(externalMouseEvent(QEvent*, const QString &, const QString &)));
    59 }
    71 }
    60 
    72 
    61 void PageSnippet::setVisible(bool visiblity, bool animate) {
    73 void PageSnippet::setVisible(bool visiblity, bool animate) {
    62     qDebug() << "PageSnippet::setVisible: " << visiblity;
       
    63     ChromeSnippet::setVisible(visiblity, animate);
    74     ChromeSnippet::setVisible(visiblity, animate);
    64 }
       
    65 
       
    66 void PageSnippet::onLoadFinished(bool ok) {  // slot
       
    67     qDebug() << "PageSnippet::onLoadFinished: " << ok;
       
    68 }
    75 }
    69 
    76 
    70 QString PageSnippet::url() const {
    77 QString PageSnippet::url() const {
    71     return constPageItem()->url();
    78     return constPageItem()->url();
    72 }
    79 }
    73 
    80 
    74 void PageSnippet::setUrl(const QString &url) {
    81 void PageSnippet::setUrl(const QString &url) {
    75     qDebug() << "PageSnippet::setUrl: " << url;
       
    76     pageItem()->setUrl(url);
    82     pageItem()->setUrl(url);
    77 }
    83 }
    78 
    84 
    79 void PageSnippet::setHtml(const QString &value) {
    85 void PageSnippet::setHtml(const QString &value) {
    80     pageItem()->setHtml(value);
    86     pageItem()->setHtml(value);