• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KParts

  • kparts
htmlextension.h
Go to the documentation of this file.
1/* This file is part of the KDE project
2 Copyright (C) 2010 David Faure <faure@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18 */
19
20#ifndef KPARTS_HTMLEXTENSION_H
21#define KPARTS_HTMLEXTENSION_H
22
23#include <QtCore/QSharedDataPointer>
24#include <QtCore/QObject>
25
26#include <kparts/kparts_export.h>
27
28class KUrl;
29
30namespace KParts
31{
32
33class ReadOnlyPart;
34class HtmlExtensionPrivate;
35class SelectorInterfacePrivate;
36
45class KPARTS_EXPORT HtmlExtension : public QObject
46{
47 Q_OBJECT
48public:
49 HtmlExtension(KParts::ReadOnlyPart* parent);
50 ~HtmlExtension();
51
56 static HtmlExtension *childObject( QObject *obj );
57
64 virtual KUrl baseUrl() const = 0;
65
72 virtual bool hasSelection() const;
73
74private:
75 // for future extensions
76 HtmlExtensionPrivate* const d;
77};
78
89class KPARTS_EXPORT SelectorInterface
90{
91public:
92 class ElementPrivate;
93 class Element;
94
98 enum QueryMethod {
99 None = 0x00,
100 EntireContent = 0x01,
101 SelectedContent = 0x02
102 };
103 Q_DECLARE_FLAGS(QueryMethods, QueryMethod)
104
105
108 virtual ~SelectorInterface() {}
109
117 virtual QueryMethods supportedQueryMethods() const;
118
132 virtual Element querySelector(const QString& query, QueryMethod method) const = 0;
133
147 virtual QList<Element> querySelectorAll(const QString& query, QueryMethod method) const = 0;
148
149 class KPARTS_EXPORT Element {
150 public:
154 Element();
155
159 Element(const Element& other);
160
164 ~Element();
165
169 bool isNull() const;
170
174 void setTagName(const QString& tag);
175
179 QString tagName() const;
180
185 void setAttribute(const QString& name, const QString& value);
186
190 QStringList attributeNames() const;
191
195 QString attribute(const QString& name, const QString& defaultValue = QString()) const;
196
200 bool hasAttribute(const QString& name) const;
201
202 // No namespace support yet, could be added with attributeNS, setAttributeNS
203
207 void swap( Element& other ) {
208 d.swap( other.d );
209 }
210
214 Element& operator=(const Element& other) {
215 if ( this != &other ) {
216 Element copy( other );
217 swap( copy );
218 }
219 return *this;
220 }
221
222 private:
223 QSharedDataPointer<ElementPrivate> d;
224 };
225};
226
245class KPARTS_EXPORT HtmlSettingsInterface
246{
247public:
251 enum HtmlSettingsType {
252 AutoLoadImages,
253 DnsPrefetchEnabled,
254 JavaEnabled,
255 JavascriptEnabled,
256 MetaRefreshEnabled,
257 PluginsEnabled,
258 PrivateBrowsingEnabled,
259 OfflineStorageDatabaseEnabled,
260 OfflineWebApplicationCacheEnabled,
261 LocalStorageEnabled,
262 UserDefinedStyleSheetURL
263 };
264
270 enum JavaScriptAdvice {
271 JavaScriptDunno=0,
272 JavaScriptAccept,
273 JavaScriptReject
274 };
275
281 enum JSWindowOpenPolicy {
282 JSWindowOpenAllow=0,
283 JSWindowOpenAsk,
284 JSWindowOpenDeny,
285 JSWindowOpenSmart
286 };
287
293 enum JSWindowStatusPolicy {
294 JSWindowStatusAllow=0,
295 JSWindowStatusIgnore
296 };
297
303 enum JSWindowMovePolicy {
304 JSWindowMoveAllow=0,
305 JSWindowMoveIgnore
306 };
307
313 enum JSWindowResizePolicy {
314 JSWindowResizeAllow=0,
315 JSWindowResizeIgnore
316 };
317
323 enum JSWindowFocusPolicy {
324 JSWindowFocusAllow=0,
325 JSWindowFocusIgnore
326 };
327
331 virtual ~HtmlSettingsInterface() {}
332
336 virtual QVariant htmlSettingsProperty(HtmlSettingsType type) const = 0;
337
341 virtual bool setHtmlSettingsProperty(HtmlSettingsType type, const QVariant& value) = 0;
342
351 static JavaScriptAdvice textToJavascriptAdvice(const QString& text);
352
361 static const char* javascriptAdviceToText(JavaScriptAdvice advice);
362
373 static void splitDomainAdvice(const QString& text,
374 QString& domain,
375 JavaScriptAdvice& javaAdvice,
376 JavaScriptAdvice& javaScriptAdvice);
377};
378
379} // namespace KParts
380
381inline void qSwap( KParts::SelectorInterface::Element & lhs, KParts::SelectorInterface::Element & rhs )
382{
383 lhs.swap( rhs );
384}
385
386Q_DECLARE_OPERATORS_FOR_FLAGS(KParts::SelectorInterface::QueryMethods)
387
388Q_DECLARE_TYPEINFO(KParts::SelectorInterface::Element, Q_MOVABLE_TYPE);
389
390Q_DECLARE_INTERFACE(KParts::SelectorInterface,
391 "org.kde.KParts.SelectorInterface")
392Q_DECLARE_INTERFACE(KParts::HtmlSettingsInterface,
393 "org.kde.KParts.HtmlSettingsInterface")
394
395
396#endif /* KPARTS_HTMLEXTENSION_H */
KParts::HtmlExtension
an extension for KParts to provide HTML-related features
Definition: htmlextension.h:46
KParts::HtmlExtension::baseUrl
virtual KUrl baseUrl() const =0
Returns the current base url of the part that implements this extension.
KParts::HtmlSettingsInterface
An interface for modifying the settings of browser engines.
Definition: htmlextension.h:246
KParts::HtmlSettingsInterface::htmlSettingsProperty
virtual QVariant htmlSettingsProperty(HtmlSettingsType type) const =0
Returns the value of the browser engine's attribute type.
KParts::HtmlSettingsInterface::~HtmlSettingsInterface
virtual ~HtmlSettingsInterface()
Destructor.
Definition: htmlextension.h:331
KParts::HtmlSettingsInterface::JSWindowResizePolicy
JSWindowResizePolicy
This enum specifies the policy for window.resizeBy and .resizeTo.
Definition: htmlextension.h:313
KParts::HtmlSettingsInterface::JSWindowMovePolicy
JSWindowMovePolicy
This enum specifies the policy for window.moveBy and .moveTo.
Definition: htmlextension.h:303
KParts::HtmlSettingsInterface::JSWindowFocusPolicy
JSWindowFocusPolicy
This enum specifies the policy for window.focus.
Definition: htmlextension.h:323
KParts::HtmlSettingsInterface::HtmlSettingsType
HtmlSettingsType
Settings attribute types.
Definition: htmlextension.h:251
KParts::HtmlSettingsInterface::JavascriptEnabled
@ JavascriptEnabled
Definition: htmlextension.h:255
KParts::HtmlSettingsInterface::PrivateBrowsingEnabled
@ PrivateBrowsingEnabled
Definition: htmlextension.h:258
KParts::HtmlSettingsInterface::JavaEnabled
@ JavaEnabled
Definition: htmlextension.h:254
KParts::HtmlSettingsInterface::AutoLoadImages
@ AutoLoadImages
Definition: htmlextension.h:252
KParts::HtmlSettingsInterface::MetaRefreshEnabled
@ MetaRefreshEnabled
Definition: htmlextension.h:256
KParts::HtmlSettingsInterface::OfflineStorageDatabaseEnabled
@ OfflineStorageDatabaseEnabled
Definition: htmlextension.h:259
KParts::HtmlSettingsInterface::DnsPrefetchEnabled
@ DnsPrefetchEnabled
Definition: htmlextension.h:253
KParts::HtmlSettingsInterface::LocalStorageEnabled
@ LocalStorageEnabled
Definition: htmlextension.h:261
KParts::HtmlSettingsInterface::OfflineWebApplicationCacheEnabled
@ OfflineWebApplicationCacheEnabled
Definition: htmlextension.h:260
KParts::HtmlSettingsInterface::PluginsEnabled
@ PluginsEnabled
Definition: htmlextension.h:257
KParts::HtmlSettingsInterface::JSWindowStatusPolicy
JSWindowStatusPolicy
This enum specifies the policy for window.status and .defaultStatus.
Definition: htmlextension.h:293
KParts::HtmlSettingsInterface::JSWindowOpenPolicy
JSWindowOpenPolicy
This enum specifies the policy for window.open.
Definition: htmlextension.h:281
KParts::HtmlSettingsInterface::JSWindowOpenAsk
@ JSWindowOpenAsk
Definition: htmlextension.h:283
KParts::HtmlSettingsInterface::JSWindowOpenDeny
@ JSWindowOpenDeny
Definition: htmlextension.h:284
KParts::HtmlSettingsInterface::setHtmlSettingsProperty
virtual bool setHtmlSettingsProperty(HtmlSettingsType type, const QVariant &value)=0
Sets the value of the browser engine's attribute type to value.
KParts::HtmlSettingsInterface::JavaScriptAdvice
JavaScriptAdvice
This enum specifies whether Java/JavaScript execution is allowed.
Definition: htmlextension.h:270
KParts::HtmlSettingsInterface::JavaScriptAccept
@ JavaScriptAccept
Definition: htmlextension.h:272
KParts::ReadOnlyPart
Base class for any "viewer" part.
Definition: part.h:489
KParts::SelectorInterface::Element
Definition: htmlextension.h:149
KParts::SelectorInterface::Element::operator=
Element & operator=(const Element &other)
Assignment operator.
Definition: htmlextension.h:214
KParts::SelectorInterface::Element::swap
void swap(Element &other)
Swaps the contents of other with the contents of this.
Definition: htmlextension.h:207
KParts::SelectorInterface
Optional base class for HtmlExtension-derived classes Provides DOM Selector like API: querySelector a...
Definition: htmlextension.h:90
KParts::SelectorInterface::querySelector
virtual Element querySelector(const QString &query, QueryMethod method) const =0
Returns the first (in document order) element in this fragment matching the given CSS selector query ...
KParts::SelectorInterface::QueryMethod
QueryMethod
Query methods.
Definition: htmlextension.h:98
KParts::SelectorInterface::querySelectorAll
virtual QList< Element > querySelectorAll(const QString &query, QueryMethod method) const =0
Returns all (in document order) elements in this fragment matching the given CSS selector query and q...
KUrl
QList
QObject
Q_DECLARE_TYPEINFO
Q_DECLARE_TYPEINFO(KParts::SelectorInterface::Element, Q_MOVABLE_TYPE)
qSwap
void qSwap(KParts::SelectorInterface::Element &lhs, KParts::SelectorInterface::Element &rhs)
Definition: htmlextension.h:381
defaultValue
QString defaultValue(const QString &t)
kparts_export.h
KParts
copy
KAction * copy(const QObject *recvr, const char *slot, QObject *parent)
name
const char * name(StandardAction id)
None
None
org
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KParts

Skip menu "KParts"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal