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); |