KVIrc  4.9.2
DeveloperAPIs
KvsObject_webView.h
Go to the documentation of this file.
1 #ifndef _CLASS_WEVBIEW_H_
2 #define _CLASS_WEVBIEW_H_
3 //=============================================================================
4 //
5 // File : KvsObject_webView.h
6 // Creation date : Wed Mar 9 23:45:48 CEST 2011
7 // by Alessandro Carbone(Noldor)
8 //
9 // This file is part of the KVIrc IRC client distribution
10 // Copyright (C) 2011 Alessandro Carbone (elfonol at gmail dot com)
11 //
12 // This program is FREE software. You can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the HOPE that it will be USEFUL,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 // See the GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program. If not, write to the Free Software Foundation,
24 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 //
26 //=============================================================================
27 
28 #include "kvi_settings.h"
29 #if defined(COMPILE_WEBKIT_SUPPORT)
30 #include "object_macros.h"
31 #include <QFile>
32 #include <QNetworkAccessManager>
33 #include <QWebView>
34 #include <QWebFrame>
35 #include <QWebElement>
36 #include <QMouseEvent>
37 #include <QContextMenuEvent>
38 
39 class KvsObject_webView;
40 class KviKvsWebView : public QWebView
41 {
42  Q_OBJECT
43 public:
44  KviKvsWebView(QWidget * par, const char * name, KvsObject_webView *);
45  //void accept();
46  //void reject();
47  virtual ~KviKvsWebView();
48 
49 protected:
50  KvsObject_webView * m_pParentScript;
51 
52 protected:
53  virtual void mouseMoveEvent(QMouseEvent * ev);
54  virtual void contextMenuEvent(QContextMenuEvent *);
55  virtual bool event(QEvent * e);
56  /*protected slots:
57  void slotNextClicked();
58  void slotBackClicked();
59  */
60 };
61 
62 class KvsObject_webView : public KviKvsObject
63 {
64  Q_OBJECT
65 public:
66  KVSO_DECLARE_OBJECT(KvsObject_webView)
67 protected:
68  KviKvsRunTimeContext * m_pContext;
69  int elementMapId;
70  int insertElement(const QWebElement & ele);
71  QWebElement getElement(int iIdx);
72  int getElementId(const QWebElement &);
73  QHash<int, QWebElement> m_elementMapper;
74  KviPointerList<KviKvsObject> * lWebelement;
75  QHash<QString, QWebElement *> m_dictCache;
76  KviPointerList<QNetworkReply> * m_pReplyList;
77  QNetworkAccessManager * m_pNetworkManager;
78  QWebElementCollection m_webElementCollection;
79  QWebElement m_currentElement;
80 
81 public:
82  QWidget * widget() { return (QWidget *)object(); }
83 protected:
84  void getFrames(QWebFrame * pCurFrame, QStringList & szFramesNames);
85  QWebFrame * findFrame(QWebFrame * pCurFrame, QString & szFrameName);
86  virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams);
87  bool removeFromDocument(KviKvsObjectFunctionCall * c);
88  bool makePreview(KviKvsObjectFunctionCall * c);
89 
90  bool removeClass(KviKvsObjectFunctionCall * c);
91  bool addClass(KviKvsObjectFunctionCall * c);
92 
93  bool classes(KviKvsObjectFunctionCall * c);
94 
95  bool firstChild(KviKvsObjectFunctionCall * c);
96  bool lastChild(KviKvsObjectFunctionCall * c);
97  bool parentElement(KviKvsObjectFunctionCall * c);
98  bool nextSibling(KviKvsObjectFunctionCall * c);
99 
100  bool toPlainText(KviKvsObjectFunctionCall * c);
101  bool setPlainText(KviKvsObjectFunctionCall * c);
102  bool load(KviKvsObjectFunctionCall * c);
103  bool setHtml(KviKvsObjectFunctionCall * c);
104  bool getDocumentElement(KviKvsObjectFunctionCall * c);
105  bool elementTagName(KviKvsObjectFunctionCall * c);
106  bool findAll(KviKvsObjectFunctionCall * c);
107  bool appendInside(KviKvsObjectFunctionCall * c);
108  bool appendOutside(KviKvsObjectFunctionCall * c);
109 
110  bool findFirst(KviKvsObjectFunctionCall * c);
111  bool findText(KviKvsObjectFunctionCall * c);
112 
113  bool hitTestContent(KviKvsObjectFunctionCall * c);
114 
115  bool elementAttributeNames(KviKvsObjectFunctionCall * c);
116  bool setLinkDelegationPolicy(KviKvsObjectFunctionCall * c);
117  bool setElementAttribute(KviKvsObjectFunctionCall * c);
118  bool setWebSetting(KviKvsObjectFunctionCall * c);
119  bool elementAttribute(KviKvsObjectFunctionCall * c);
120  bool frames(KviKvsObjectFunctionCall * c);
121 
122  bool setStyleProperty(KviKvsObjectFunctionCall * c);
123  bool styleProperty(KviKvsObjectFunctionCall * c);
124  bool appendWebViewActionToMenu(KviKvsObjectFunctionCall * c);
125 
126  bool loadStartedEvent(KviKvsObjectFunctionCall * c);
127  bool linkClickedEvent(KviKvsObjectFunctionCall * c);
128  bool loadFinishedEvent(KviKvsObjectFunctionCall * c);
129  bool loadProgressEvent(KviKvsObjectFunctionCall * c);
130  bool downloadCompletedEvent(KviKvsObjectFunctionCall * c);
131  bool downloadProgressEvent(KviKvsObjectFunctionCall * c);
132  bool downloadRequestEvent(KviKvsObjectFunctionCall * c);
133  bool addToJavaScriptWindowObject(KviKvsObjectFunctionCall * c);
134  bool evaluateJavaScript(KviKvsObjectFunctionCall * c);
135 
136  //
137  bool setEventFilter(KviKvsObjectFunctionCall * c);
138  bool jsChangeEvent(KviKvsObjectFunctionCall * c);
139  bool jsSubmitEvent(KviKvsObjectFunctionCall * c);
140  bool jsClickEvent(KviKvsObjectFunctionCall * c);
141  bool jsMouseOverEvent(KviKvsObjectFunctionCall * c);
142  bool jsMouseOutEvent(KviKvsObjectFunctionCall * c);
143 protected slots:
144  void slotLoadFinished(bool);
145  void slotLoadProgress(int);
146  void slotLoadStarted();
147  void slotDownloadRequest(const QNetworkRequest &);
148  void slotLinkClicked(const QUrl &);
149 
150  void slotOnChange(QString);
151  void slotOnSubmit(QString);
152  void slotOnClick(QString);
153  void slotOnMouseOver(QString);
154  void slotOnMouseOut(QString);
155 };
156 
157 class KviKvsDownloadHandler : public QObject
158 {
159  Q_OBJECT
160 public:
161  KviKvsDownloadHandler(KvsObject_webView * pParent, QFile * pFile, QNetworkReply * pNetReply, int iId);
162 
163  virtual ~KviKvsDownloadHandler();
164 
165 protected:
166  KvsObject_webView * m_pParentScript;
167  QFile * m_pFile;
168  QNetworkReply * m_pReply;
169  int m_Id;
170 protected slots:
171  void slotReadyRead();
172  void slotReplyFinished();
173 };
174 
175 #endif // COMPILE_WEBKIT_SUPPORT
176 #endif // _CLASS_WEBVIEW_H_
char s char s char s s s s s char char c s *s c s s s d c s *s d c d d d d c
Definition: KviIrcNumericCodes.h:391
Class to handle variant variables lists.
Definition: KviKvsVariantList.h:41
Definition: KviKvsObjectFunctionCall.h:33
Definition: KviKvsObject.h:50
#define e
Definition: detector.cpp:69
m_pFile
Definition: KvsObject_file.cpp:191
#define KVSO_DECLARE_OBJECT(__className)
Definition: object_macros.h:33
UrlDlgList * findFrame()
Definition: libkviurl.cpp:649
QObject * object() const
Definition: KviKvsObject.h:94
A template double linked list of pointers.
Definition: KviPointerList.h:55
Definition: KviKvsRunTimeContext.h:103
virtual bool init(KviKvsRunTimeContext *pContext, KviKvsVariantList *pParams)
Definition: KviKvsObject.cpp:774
QString name()
Definition: KviRuntimeInfo.cpp:655
This file contains compile time settings.