Changeset View
Changeset View
Standalone View
Standalone View
src/plugins/web/KReportItemWeb.cpp
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 42 | { | |||
---|---|---|---|---|---|
43 | createProperties(); | 43 | createProperties(); | ||
44 | init(); | 44 | init(); | ||
45 | QDomNodeList nl = element.childNodes(); | 45 | QDomNodeList nl = element.childNodes(); | ||
46 | QString n; | 46 | QString n; | ||
47 | QDomNode node; | 47 | QDomNode node; | ||
48 | QDomElement e = element.toElement(); | 48 | QDomElement e = element.toElement(); | ||
49 | 49 | | |||
50 | m_controlSource->setValue(element.toElement().attribute(QLatin1String("report:item-data-source"))); | 50 | m_controlSource->setValue(element.toElement().attribute(QLatin1String("report:item-data-source"))); | ||
51 | m_name->setValue(element.toElement().attribute(QLatin1String("report:name"))); | 51 | nameProperty()->setValue(element.toElement().attribute(QLatin1String("report:name"))); | ||
52 | Z = element.toElement().attribute(QLatin1String("report:z-index")).toDouble(); | 52 | setZ(element.toElement().attribute(QLatin1String("report:z-index")).toDouble()); | ||
53 | parseReportRect(element.toElement(), &m_pos, &m_size); | 53 | parseReportRect(element.toElement()); | ||
54 | for (int i = 0; i < nl.count(); i++) { | 54 | for (int i = 0; i < nl.count(); i++) { | ||
55 | node = nl.item(i); | 55 | node = nl.item(i); | ||
56 | n = node.nodeName(); | 56 | n = node.nodeName(); | ||
57 | } | 57 | } | ||
58 | } | 58 | } | ||
59 | 59 | | |||
60 | void KReportItemWeb::init() | 60 | void KReportItemWeb::init() | ||
61 | { | 61 | { | ||
62 | m_webPage = new QWebPage(); | 62 | m_webPage = new QWebPage(); | ||
63 | 63 | | |||
64 | connect(m_webPage, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool))); | 64 | connect(m_webPage, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool))); | ||
65 | } | 65 | } | ||
66 | 66 | | |||
67 | void KReportItemWeb::createProperties() | 67 | void KReportItemWeb::createProperties() | ||
68 | { | 68 | { | ||
69 | m_set = new KPropertySet; | | |||
70 | | ||||
71 | m_controlSource = new KProperty("item-data-source", QStringList(), | 69 | m_controlSource = new KProperty("item-data-source", QStringList(), | ||
72 | QStringList(), QString(), tr("Data Source")); | 70 | QStringList(), QString(), tr("Data Source")); | ||
73 | m_set->addProperty(m_controlSource); | 71 | propertySet()->addProperty(m_controlSource); | ||
74 | addDefaultProperties(); | | |||
75 | } | 72 | } | ||
76 | 73 | | |||
77 | KReportItemWeb::~KReportItemWeb() | 74 | KReportItemWeb::~KReportItemWeb() | ||
78 | { | 75 | { | ||
79 | delete m_set; | | |||
80 | } | 76 | } | ||
77 | | ||||
81 | QString KReportItemWeb::typeName() const | 78 | QString KReportItemWeb::typeName() const | ||
82 | { | 79 | { | ||
83 | return QLatin1String("web"); | 80 | return QLatin1String("web"); | ||
84 | } | 81 | } | ||
85 | 82 | | |||
86 | void KReportItemWeb::loadFinished(bool) | 83 | void KReportItemWeb::loadFinished(bool) | ||
87 | { | 84 | { | ||
88 | //kreportpluginDebug() << m_rendering; | 85 | //kreportpluginDebug() << m_rendering; | ||
89 | if (m_rendering) { | 86 | if (m_rendering) { | ||
90 | OROPicture * pic = new OROPicture(); | 87 | OROPicture * pic = new OROPicture(); | ||
91 | m_webPage->setViewportSize(m_size.toScene().toSize()); | 88 | m_webPage->setViewportSize(sceneSize(size()).toSize()); | ||
92 | m_webPage->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); | 89 | m_webPage->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); | ||
93 | m_webPage->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); | 90 | m_webPage->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); | ||
94 | 91 | | |||
95 | QPainter p(pic->picture()); | 92 | QPainter p(pic->picture()); | ||
96 | 93 | | |||
97 | m_webPage->mainFrame()->render(&p); | 94 | m_webPage->mainFrame()->render(&p); | ||
98 | 95 | | |||
99 | QPointF pos = m_pos.toScene(); | 96 | QPointF pos = scenePosition(position()); | ||
100 | QSizeF size = m_size.toScene(); | 97 | QSizeF siz = sceneSize(size()); | ||
101 | 98 | | |||
102 | pos += m_targetOffset; | 99 | pos += m_targetOffset; | ||
103 | 100 | | |||
104 | pic->setPosition(pos); | 101 | pic->setPosition(pos); | ||
105 | pic->setSize(size); | 102 | pic->setSize(siz); | ||
106 | if (m_targetPage) m_targetPage->addPrimitive(pic, false, true); | 103 | if (m_targetPage) m_targetPage->addPrimitive(pic, false, true); | ||
107 | 104 | | |||
108 | OROPicture *p2 = dynamic_cast<OROPicture*>(pic->clone()); | 105 | OROPicture *p2 = dynamic_cast<OROPicture*>(pic->clone()); | ||
109 | if (p2) { | 106 | if (p2) { | ||
110 | p2->setPosition(m_pos.toPoint()); | 107 | p2->setPosition(scenePosition(position())); | ||
111 | if (m_targetSection) { | 108 | if (m_targetSection) { | ||
112 | m_targetSection->addPrimitive(p2); | 109 | m_targetSection->addPrimitive(p2); | ||
113 | } | 110 | } | ||
114 | } | 111 | } | ||
112 | | ||||
115 | m_rendering = false; | 113 | m_rendering = false; | ||
116 | emit(finishedRendering()); | 114 | emit(finishedRendering()); | ||
117 | } | 115 | } | ||
118 | } | 116 | } | ||
119 | 117 | | |||
120 | int KReportItemWeb::renderSimpleData(OROPage *page, OROSection *section, const QPointF &offset, | 118 | int KReportItemWeb::renderSimpleData(OROPage *page, OROSection *section, const QPointF &offset, | ||
121 | const QVariant &data, KReportScriptHandler *script) | 119 | const QVariant &data, KReportScriptHandler *script) | ||
122 | { | 120 | { | ||
Show All 24 Lines |