1/* This file is part of the KDE project
2 *
3 * Copyright (C) 2000-2003 Simon Hausmann <hausmann@kde.org>
4 * 2001-2003 George Staikos <staikos@kde.org>
5 * 2001-2003 Laurent Montel <montel@kde.org>
6 * 2001-2003 Dirk Mueller <mueller@kde.org>
7 * 2001-2003 Waldo Bastian <bastian@kde.org>
8 * 2001-2003 David Faure <faure@kde.org>
9 * 2001-2003 Daniel Naber <dnaber@kde.org>
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details.
20 *
21 * You should have received a copy of the GNU Library General Public License
22 * along with this library; see the file COPYING.LIB. If not, write to
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301, USA.
25 */
26
27#ifndef __khtml_ext_h__
28#define __khtml_ext_h__
29
30#include "khtml_part.h"
31
32#include <QtCore/QPointer>
33
34#include <kselectaction.h>
35#include <kparts/textextension.h>
36#include <kparts/htmlextension.h>
37#include <kio/global.h>
38
39/**
40 * This is the BrowserExtension for a KHTMLPart document. Please see the KParts documentation for
41 * more information about the BrowserExtension.
42 */
43class KHTMLPartBrowserExtension : public KParts::BrowserExtension
44{
45 Q_OBJECT
46 friend class KHTMLPart;
47 friend class KHTMLView;
48public:
49 KHTMLPartBrowserExtension( KHTMLPart *parent );
50
51 virtual int xOffset();
52 virtual int yOffset();
53
54 virtual void saveState( QDataStream &stream );
55 virtual void restoreState( QDataStream &stream );
56
57 // internal
58 void editableWidgetFocused( QWidget *widget );
59 void editableWidgetBlurred( QWidget *widget );
60
61 void setExtensionProxy( KParts::BrowserExtension *proxyExtension );
62
63public Q_SLOTS:
64 void cut();
65 void copy();
66 void paste();
67 void searchProvider();
68 void reparseConfiguration();
69 void print();
70 void disableScrolling();
71
72 // internal . updates the state of the cut/copt/paste action based
73 // on whether data is available in the clipboard
74 void updateEditActions();
75
76private Q_SLOTS:
77 // connected to a frame's browserextensions enableAction signal
78 void extensionProxyActionEnabled( const char *action, bool enable );
79 void extensionProxyEditableWidgetFocused();
80 void extensionProxyEditableWidgetBlurred();
81
82Q_SIGNALS:
83 void editableWidgetFocused();
84 void editableWidgetBlurred();
85private:
86 void callExtensionProxyMethod( const char *method );
87
88 KHTMLPart *m_part;
89 QPointer<QWidget> m_editableFormWidget;
90 QPointer<KParts::BrowserExtension> m_extensionProxy;
91 bool m_connectedToClipboard;
92};
93
94class KHTMLPartBrowserHostExtension : public KParts::BrowserHostExtension
95{
96public:
97 KHTMLPartBrowserHostExtension( KHTMLPart *part );
98 virtual ~KHTMLPartBrowserHostExtension();
99
100 virtual QStringList frameNames() const;
101
102 virtual const QList<KParts::ReadOnlyPart*> frames() const;
103
104 virtual BrowserHostExtension* findFrameParent( KParts::ReadOnlyPart *callingPart, const QString &frame );
105
106 virtual bool openUrlInFrame(const KUrl &url, const KParts::OpenUrlArguments& arguments, const KParts::BrowserArguments &browserArguments);
107
108private:
109 KHTMLPart *m_part;
110};
111
112/**
113 * @internal
114 * INTERNAL class. *NOT* part of the public API.
115 */
116class KHTMLPopupGUIClient : public QObject
117{
118 Q_OBJECT
119public:
120 KHTMLPopupGUIClient( KHTMLPart *khtml, const KUrl &url );
121 virtual ~KHTMLPopupGUIClient();
122
123 KParts::BrowserExtension::ActionGroupMap actionGroups() const;
124
125 static void saveURL( QWidget *parent, const QString &caption, const KUrl &url,
126 const QMap<QString, QString> &metaData = KIO::MetaData(),
127 const QString &filter = QString(), long cacheId = 0,
128 const QString &suggestedFilename = QString() );
129
130 static void saveURL( QWidget* parent, const KUrl &url, const KUrl &destination,
131 const QMap<QString, QString> &metaData = KIO::MetaData(),
132 long cacheId = 0 );
133
134 static QString selectedTextAsOneLine(KHTMLPart* part);
135
136private Q_SLOTS:
137 void slotSaveLinkAs();
138 void slotSaveImageAs();
139 void slotCopyLinkLocation();
140 void slotSendImage();
141 void slotStopAnimations();
142 void slotCopyImageLocation();
143 void slotCopyImage();
144 void slotViewImage();
145 void slotReloadFrame();
146 void slotFrameInWindow();
147 void slotFrameInTop();
148 void slotFrameInTab();
149 void slotBlockImage();
150 void slotBlockHost();
151 void slotBlockIFrame();
152 void openSelection();
153
154private:
155 void addSearchActions(QList<QAction *>& editActions);
156
157 class KHTMLPopupGUIClientPrivate;
158 KHTMLPopupGUIClientPrivate* const d;
159};
160
161class KHTMLZoomFactorAction : public KSelectAction
162{
163 Q_OBJECT
164public:
165 KHTMLZoomFactorAction(KHTMLPart *part, bool direction, const QString& iconName, const QString& text, QObject *parent);
166 virtual ~KHTMLZoomFactorAction();
167
168protected Q_SLOTS:
169 void slotTriggered(QAction* action);
170private:
171 void init(KHTMLPart *part, bool direction);
172private:
173 bool m_direction;
174 KHTMLPart *m_part;
175};
176
177/**
178 * @internal
179 * Implements the TextExtension interface
180 */
181class KHTMLTextExtension : public KParts::TextExtension
182{
183 Q_OBJECT
184public:
185 KHTMLTextExtension(KHTMLPart* part);
186
187 virtual bool hasSelection() const;
188 virtual QString selectedText(Format format) const;
189 virtual QString completeText(Format format) const;
190
191 KHTMLPart* part() const;
192};
193
194/**
195 * @internal
196 * Implements the HtmlExtension interface
197 */
198class KHTMLHtmlExtension : public KParts::HtmlExtension,
199 public KParts::SelectorInterface,
200 public KParts::HtmlSettingsInterface
201{
202 Q_OBJECT
203 Q_INTERFACES(KParts::SelectorInterface)
204 Q_INTERFACES(KParts::HtmlSettingsInterface)
205
206public:
207 KHTMLHtmlExtension(KHTMLPart* part);
208
209 // HtmlExtension
210 virtual KUrl baseUrl() const;
211 virtual bool hasSelection() const;
212
213 // SelectorInterface
214 virtual QueryMethods supportedQueryMethods() const;
215 virtual Element querySelector(const QString& query, QueryMethod method) const;
216 virtual QList<Element> querySelectorAll(const QString& query, QueryMethod method) const;
217
218 // SettingsInterface
219 virtual QVariant htmlSettingsProperty(HtmlSettingsType type) const;
220 virtual bool setHtmlSettingsProperty(HtmlSettingsType type, const QVariant& value);
221
222 KHTMLPart* part() const;
223};
224
225#endif
226