3
|
1 |
/*
|
|
2 |
* SuperPageView.cpp
|
|
3 |
*
|
|
4 |
* Created on: Jun 11, 2010
|
|
5 |
* Author: lewontin
|
|
6 |
*/
|
|
7 |
|
|
8 |
#include "SuperPageView.h"
|
|
9 |
#include "GWebContentView.h"
|
|
10 |
|
|
11 |
namespace GVA {
|
|
12 |
|
|
13 |
SuperPageView::SuperPageView(GWebContentView * contentView, QObject * parent, const QString &objectName)
|
|
14 |
: ControllableViewBase(parent),
|
|
15 |
m_contentView(contentView)
|
|
16 |
{
|
|
17 |
setObjectName(objectName);
|
|
18 |
}
|
|
19 |
|
|
20 |
SuperPageView::~SuperPageView(){
|
|
21 |
|
|
22 |
}
|
|
23 |
|
|
24 |
QGraphicsWidget* SuperPageView::widget() const
|
|
25 |
{
|
|
26 |
//SuperPageView's widget is the content view widget
|
|
27 |
return m_contentView->widget();
|
|
28 |
}
|
|
29 |
|
|
30 |
void SuperPageView::show(){
|
|
31 |
//Ask the content view to show the super page
|
|
32 |
m_contentView->showSuperPage(objectName());
|
|
33 |
ControllableViewBase::activate();
|
|
34 |
}
|
|
35 |
|
|
36 |
QList<QAction*> SuperPageView::getContext() {
|
|
37 |
return m_actions.values();
|
|
38 |
}
|
|
39 |
|
|
40 |
//Creates an action, visible to JavaScript as name. If the script parameter is supplied, the
|
|
41 |
//the action will invoke the supplied script in the context of the super page main frame
|
|
42 |
//(not in the context of the caller).
|
|
43 |
|
|
44 |
void SuperPageView::addAction(const QString & name, const QString & script){
|
|
45 |
QAction* action;
|
|
46 |
action = m_actions[name] = new QAction(name, this);
|
|
47 |
action->setObjectName(name);
|
|
48 |
if(!script.isNull()){
|
|
49 |
action->setData(script);
|
|
50 |
connect(action, SIGNAL(triggered()), this, SLOT(invokeScriptAction()));
|
|
51 |
}
|
|
52 |
}
|
|
53 |
|
|
54 |
void SuperPageView::invokeScriptAction() {
|
|
55 |
QAction * action = static_cast<QAction*>(sender());
|
|
56 |
QString script = action->data().toString();
|
|
57 |
m_contentView->webWidget()->page()->mainFrame()->evaluateJavaScript(script);
|
|
58 |
}
|
|
59 |
|
16
|
60 |
QString SuperPageView::title() const {
|
|
61 |
return m_contentView ? m_contentView->title() : QString::null;
|
3
|
62 |
}
|
16
|
63 |
}
|