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

KParts

  • sources
  • kde-4.14
  • kdelibs
  • 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 
28 class KUrl;
29 
30 namespace KParts
31 {
32 
33 class ReadOnlyPart;
34 class HtmlExtensionPrivate;
35 class SelectorInterfacePrivate;
36 
45 class KPARTS_EXPORT HtmlExtension : public QObject
46 {
47  Q_OBJECT
48 public:
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 
74 private:
75  // for future extensions
76  HtmlExtensionPrivate* const d;
77 };
78 
89 class KPARTS_EXPORT SelectorInterface
90 {
91 public:
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 
245 class KPARTS_EXPORT HtmlSettingsInterface
246 {
247 public:
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 
381 inline void qSwap( KParts::SelectorInterface::Element & lhs, KParts::SelectorInterface::Element & rhs )
382 {
383  lhs.swap( rhs );
384 }
385 
386 Q_DECLARE_OPERATORS_FOR_FLAGS(KParts::SelectorInterface::QueryMethods)
387 
388 Q_DECLARE_TYPEINFO(KParts::SelectorInterface::Element, Q_MOVABLE_TYPE);
389 
390 Q_DECLARE_INTERFACE(KParts::SelectorInterface,
391  "org.kde.KParts.SelectorInterface")
392 Q_DECLARE_INTERFACE(KParts::HtmlSettingsInterface,
393  "org.kde.KParts.HtmlSettingsInterface")
394 
395 
396 #endif /* KPARTS_HTMLEXTENSION_H */
KParts::HtmlSettingsInterface::JavaEnabled
Definition: htmlextension.h:254
KParts::HtmlSettingsInterface::JavaScriptAccept
Definition: htmlextension.h:272
copy
KAction * copy(const QObject *recvr, const char *slot, QObject *parent)
KParts::HtmlSettingsInterface::JSWindowMovePolicy
JSWindowMovePolicy
This enum specifies the policy for window.moveBy and .moveTo.
Definition: htmlextension.h:303
name
const char * name(StandardAction id)
KParts::HtmlSettingsInterface::AutoLoadImages
Definition: htmlextension.h:252
KUrl
KParts::HtmlSettingsInterface::OfflineWebApplicationCacheEnabled
Definition: htmlextension.h:260
None
KParts::SelectorInterface::Element
Definition: htmlextension.h:149
KParts::HtmlSettingsInterface::JSWindowFocusPolicy
JSWindowFocusPolicy
This enum specifies the policy for window.focus.
Definition: htmlextension.h:323
KParts::HtmlSettingsInterface::JavaScriptAdvice
JavaScriptAdvice
This enum specifies whether Java/JavaScript execution is allowed.
Definition: htmlextension.h:270
KParts::HtmlSettingsInterface::JSWindowOpenAsk
Definition: htmlextension.h:283
QObject
KParts::HtmlSettingsInterface::JSWindowResizePolicy
JSWindowResizePolicy
This enum specifies the policy for window.resizeBy and .resizeTo.
Definition: htmlextension.h:313
qSwap
void qSwap(KParts::SelectorInterface::Element &lhs, KParts::SelectorInterface::Element &rhs)
Definition: htmlextension.h:381
KParts::HtmlSettingsInterface::MetaRefreshEnabled
Definition: htmlextension.h:256
KParts::SelectorInterface::Element::swap
void swap(Element &other)
Swaps the contents of other with the contents of this.
Definition: htmlextension.h:207
KParts::HtmlSettingsInterface::JSWindowStatusPolicy
JSWindowStatusPolicy
This enum specifies the policy for window.status and .defaultStatus.
Definition: htmlextension.h:293
QString
QList
Definition: browserextension.h:34
KParts::HtmlSettingsInterface::PluginsEnabled
Definition: htmlextension.h:257
QStringList
Q_DECLARE_TYPEINFO
Q_DECLARE_TYPEINFO(KParts::SelectorInterface::Element, Q_MOVABLE_TYPE)
KParts::HtmlSettingsInterface::JavascriptEnabled
Definition: htmlextension.h:255
KParts::HtmlSettingsInterface::HtmlSettingsType
HtmlSettingsType
Settings attribute types.
Definition: htmlextension.h:251
KParts::HtmlExtension
an extension for KParts to provide HTML-related features
Definition: htmlextension.h:45
KParts::SelectorInterface::Element::operator=
Element & operator=(const Element &other)
Assignment operator.
Definition: htmlextension.h:214
KParts::SelectorInterface::QueryMethod
QueryMethod
Query methods.
Definition: htmlextension.h:98
KParts::SelectorInterface
Optional base class for HtmlExtension-derived classes Provides DOM Selector like API: querySelector a...
Definition: htmlextension.h:89
KParts::HtmlSettingsInterface::JSWindowOpenDeny
Definition: htmlextension.h:284
KParts::HtmlSettingsInterface::LocalStorageEnabled
Definition: htmlextension.h:261
KParts::HtmlSettingsInterface::~HtmlSettingsInterface
virtual ~HtmlSettingsInterface()
Destructor.
Definition: htmlextension.h:331
KParts::HtmlSettingsInterface::OfflineStorageDatabaseEnabled
Definition: htmlextension.h:259
KParts::HtmlSettingsInterface::DnsPrefetchEnabled
Definition: htmlextension.h:253
KParts::HtmlSettingsInterface
An interface for modifying the settings of browser engines.
Definition: htmlextension.h:245
KParts::HtmlSettingsInterface::PrivateBrowsingEnabled
Definition: htmlextension.h:258
QSharedDataPointer< ElementPrivate >
defaultValue
QString defaultValue(const QString &t)
KParts::ReadOnlyPart
Base class for any "viewer" part.
Definition: part.h:488
KParts::HtmlSettingsInterface::JSWindowOpenPolicy
JSWindowOpenPolicy
This enum specifies the policy for window.open.
Definition: htmlextension.h:281
QVariant
kparts_export.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:25:36 by doxygen 1.8.7 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 API Reference

Skip menu "kdelibs 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

Search



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