KHtml

khtml_iface.cpp
1 /* This file is part of the KDE project
2  *
3  * Copyright (C) 2002 Stephan Kulow <[email protected]>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #include "khtml_iface.h"
22 #include "khtml_part.h"
23 #include "khtmlview.h"
24 #include "khtml_ext.h"
25 #include <kio/global.h>
26 #include <QApplication>
27 #include <QVariant>
28 #include <QKeyEvent>
29 
30 KHTMLPartIface::KHTMLPartIface(KHTMLPart *_part)
31  : QDBusAbstractAdaptor(_part), part(_part)
32 {
33 }
34 
35 KHTMLPartIface::~KHTMLPartIface()
36 {
37 }
38 
40 {
41  return part->url().toString();
42 }
43 
45 {
46  part->setJScriptEnabled(enable);
47 }
48 
50 {
51  return part->jScriptEnabled();
52 }
53 
54 bool KHTMLPartIface::closeUrl()
55 {
56  return part->closeUrl();
57 }
58 
60 {
61  return part->metaRefreshEnabled();
62 }
63 
65 {
66  part->setDNDEnabled(b);
67 }
68 
69 bool KHTMLPartIface::dndEnabled() const
70 {
71  return part->dndEnabled();
72 }
73 
75 {
76  part->setJavaEnabled(enable);
77 }
78 
79 bool KHTMLPartIface::javaEnabled() const
80 {
81  return part->javaEnabled();
82 }
83 
85 {
86  part->setPluginsEnabled(enable);
87 }
88 
90 {
91  return part->pluginsEnabled();
92 }
93 
95 {
96  part->setAutoloadImages(enable);
97 }
98 
100 {
101  return part->autoloadImages();
102 }
103 
105 {
106  part->setOnlyLocalReferences(enable);
107 }
108 
110 {
111  part->setMetaRefreshEnabled(enable);
112 }
113 
115 {
116  return part->onlyLocalReferences();
117 }
118 
120 {
121  return part->setEncoding(name);
122 }
123 
125 {
126  return part->encoding();
127 }
128 
130 {
131  part->setFixedFont(name);
132 
133 }
134 
136 {
137  return part->gotoAnchor(name);
138 }
139 
141 {
142  return part->nextAnchor();
143 }
144 
146 {
147  return part->prevAnchor();
148 }
149 
151 {
152  KParts::ReadOnlyPart *p = part->currentFrame();
153  if (p && p->widget()) {
154  QKeyEvent ev(QKeyEvent::KeyPress, Qt::Key_Return, nullptr, "\n");
155  QApplication::sendEvent(p->widget(), &ev);
156  }
157 }
158 
160 {
161  part->selectAll();
162 }
163 
165 {
166  return part->lastModified();
167 }
168 
169 void KHTMLPartIface::debugRenderTree()
170 {
171  part->slotDebugRenderTree();
172 }
173 
174 void KHTMLPartIface::debugDOMTree()
175 {
176  part->slotDebugDOMTree();
177 }
178 
180 {
181  part->slotStopAnimations();
182 }
183 
184 void KHTMLPartIface::viewDocumentSource()
185 {
186  part->slotViewDocumentSource();
187 }
188 
189 void KHTMLPartIface::saveBackground(const QString &destination)
190 {
191  QUrl back = part->backgroundURL();
192  if (back.isEmpty()) {
193  return;
194  }
195 
196  KIO::MetaData metaData;
197  metaData["referrer"] = part->referrer();
198  KHTMLPopupGUIClient::saveURL(part->widget(), back, QUrl(destination), metaData);
199 }
200 
201 void KHTMLPartIface::saveDocument(const QString &destination)
202 {
203  QUrl srcURL(part->url());
204 
205  if (srcURL.fileName().isEmpty()) {
206  srcURL.setPath(srcURL.path() + "index.html");
207  }
208 
209  KIO::MetaData metaData;
210  // Referrer unknown?
211  KHTMLPopupGUIClient::saveURL(part->widget(), srcURL, QUrl(destination), metaData, part->cacheId());
212 }
213 
215 {
216  part->setUserStyleSheet(styleSheet);
217 }
218 
220 {
221  return part->selectedText();
222 }
223 
224 void KHTMLPartIface::viewFrameSource()
225 {
226  part->slotViewFrameSource();
227 }
228 
230 {
231  return part->executeScript(DOM::Node(), script).toString();
232 }
233 
234 void KHTMLPartIface::print(bool quick)
235 {
236  part->view()->print(quick);
237 }
238 
void setAutoloadImages(bool enable)
Specifies whether images contained in the document should be loaded automatically or not...
Definition: khtml_iface.cpp:94
The Node interface is the primary datatype for the entire Document Object Model.
Definition: dom_node.h:278
void setFixedFont(const QString &name)
Sets the fixed font style.
bool setEncoding(const QString &name)
Sets the encoding the page uses.
bool nextAnchor()
Go to next Anchor.
QString evalJS(const QString &script)
Evaluate a given piece of Javascript code.
This class is khtml&#39;s main class.
Definition: khtml_part.h:208
Q_NOREPLY void print(bool quick)
Print the contents of the current html view.
void setUserStyleSheet(const QString &styleSheet)
Sets a user defined style sheet to be used on top of the HTML 4 default style sheet.
virtual QWidget * widget()
bool isEmpty() const const
bool metaRefreshEnabled() const
Returns true if automtaic forwarding is enabled.
bool dndEnabled() const
Returns whether Dragn&#39;n&#39;Drop support is enabled or not.
void setPath(const QString &path, QUrl::ParsingMode mode)
void activateNode()
Activate the node that currently has the focus (emulates pressing Return)
bool javaEnabled() const
Return if Java applet support is enabled/disabled.
QString encoding() const
Returns the encoding the page currently uses.
void setDndEnabled(bool b)
Enables or disables Drag&#39;n&#39;Drop support.
Definition: khtml_iface.cpp:64
QString lastModified() const
Last-modified date (in raw string format), if received in the [HTTP] headers.
void setMetaRefreshEnabled(bool enable)
Enable/disable the automatic forwarding by <meta http-equiv="refresh" ....
bool sendEvent(QObject *receiver, QEvent *event)
bool pluginsEnabled() const
Returns trie if plugins are enabled/disabled.
void setOnlyLocalReferences(bool enable)
Security option.
bool onlyLocalReferences() const
Returns whether references should be loaded ( default false )
QString url() const
bool jScriptEnabled() const
Returns true if Javascript support is enabled or false otherwise.
void selectAll()
Marks all text in the document as selected.
bool prevAnchor()
Go to previous Anchor.
void setPluginsEnabled(bool enable)
Enables or disables plugins via, default is enabled.
Definition: khtml_iface.cpp:84
QString selectedText() const
Returns the text the user has marked.
void setJScriptEnabled(bool enable)
Enable/disable Javascript support.
Definition: khtml_iface.cpp:44
bool gotoAnchor(const QString &name)
Finds the anchor named name.
void setJavaEnabled(bool enable)
Enables/disables Java applet support.
Definition: khtml_iface.cpp:74
bool autoloadImages() const
Returns whether images contained in the document are loaded automatically or not. ...
void stopAnimations()
Stops display of animated images.
Key_Return
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:48:04 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.