OSDN Git Service

Move the directories
[kita/kita.git] / src / htmlpart.h
1 /***************************************************************************
2 *   Copyright (C) 2004 by Kita Developers                                 *
3 *   ikemo@users.sourceforge.jp                                            *
4 *                                                                         *
5 *   This program is free software; you can redistribute it and/or modify  *
6 *   it under the terms of the GNU General Public License as published by  *
7 *   the Free Software Foundation; either version 2 of the License, or     *
8 *   (at your option) any later version.                                   *
9 ***************************************************************************/
10 #ifndef KITAHTMLPART_H
11 #define KITAHTMLPART_H
12
13 #include <QtCore/QEvent>
14
15 #include <khtml_part.h>
16
17 /* mode */
18 enum {
19     /* on main window */
20     HTMLPART_MODE_MAINPART,
21
22     /* on popup       */
23     HTMLPART_MODE_POPUP
24 };
25
26 /* ID of user defined event */
27 const int EVENT_GotoAnchor = QEvent::User + 100;
28
29 class KUrl;
30
31 namespace DOM
32 {
33     class Node;
34 }
35
36 namespace Kita
37 {
38     class DomTree;
39     class ResPopup;
40
41     class HTMLPart : public KHTMLPart
42     {
43         Q_OBJECT
44
45         DomTree* m_domtree;
46         ResPopup* m_popup;
47
48         /* basic information */
49         int m_mode;
50         KUrl m_datUrl;
51         bool m_updatedKokoyon;
52
53
54         /* cache */
55         bool m_firstReceive;
56         int m_centerNum;
57
58         /* goto anchor */
59         QStringList m_anchorStack;
60         int m_jumpNumAfterLoading; /* see also slotFinishLoad() */
61
62         /* mouse event */
63         bool m_pushctrl;
64         bool m_pushmidbt;
65         bool m_pushrightbt;
66
67         /* search */
68         DOM::Node m_findNode;
69         int m_findPos;
70         int m_find_y;
71
72         /* res popup */
73         bool m_multiPopup;
74
75     public:
76
77         HTMLPart(QWidget* parent);
78         ~HTMLPart();
79         bool setup(int mode , const KUrl& url);
80
81         /* rendering */
82         void showResponses(int startnum, int endnum);
83         void parseResponses(int startnum, int endnum);
84         void showAll();
85         void updateScreen(bool showHeaderEtc, bool clock);
86         void setInnerHTML(const QString& innerHTML);
87
88         /* cache */
89         bool load(int centerNum);
90         bool reload(int jumpNum);
91
92         /* goto anchor */
93         bool gotoAnchor(const QString& anc, bool pushPosition);
94
95         /* search */
96         bool findText(const QString &query, bool reverse);
97
98         /* popup */
99         bool isPopupVisible();
100
101     public slots:
102
103         /* rendering */
104         void slotSetFaceOfHTMLPart();
105
106         /* cache */
107         void slotReceiveData();
108         void slotFinishLoad();
109
110         /* goto anchor */
111         void slotGotoKokoyon();
112         void slotGobackAnchor();
113
114         /* Tugi100, Mae100 etc.  */
115         void slotClickGotoFooter();
116
117         /* res popup */
118         void slotDeletePopup();
119         void slotShowResPopup(const QPoint& point, int refNum, int refNum2);
120
121     private:
122
123         void clearPart();
124         void redrawHTMLPart(const KUrl& datUrl, bool force);
125
126         /* setup */
127         void connectSignals();
128         void createHTMLDocument();
129
130         /* goto anchor */
131         void pushCurrentPosition();
132         QString getCurrentIdOfNode();
133
134         /* popup menu */
135         void showPopupMenu(const KUrl& kurl);
136
137         /* click */
138         void clickAnchor(const KUrl& urlin);
139         void showWritePopupMenu(const QString& refstr);
140         void showIdPopup(const QString& refstr);
141         void showBePopupMenu(const QString& refstr);
142
143         /* search */
144         void findTextInit();
145
146         /* res popup */
147         void showPopup(const KUrl& url, const QString& innerHTML);
148         void showPopupCore(const KUrl& url, const QString& innerHTML,
149                 const QPoint& point);
150         bool startMultiPopup();
151         bool isMultiPopupMode();
152         void hidePopup();
153         bool isUnderMouse(int mrgwd, int mrght);
154         bool showSelectedDigitPopup();
155
156         HTMLPart(const HTMLPart&);
157         HTMLPart& operator=(const HTMLPart&);
158
159     protected:
160
161         /* user event */
162         virtual void customEvent(QEvent * e);
163
164         /* mouse event */
165         virtual void khtmlMousePressEvent(khtml::MousePressEvent* e);
166
167
168     private slots:
169
170         /* click */
171         void slotOpenUrlRequest(const KUrl&, const KParts::OpenUrlArguments&);
172
173         /* res popup */
174         void slotLeave();
175         void slotVSliderReleased();
176         void slotHSliderReleased();
177         void slotHideChildPopup();
178         void slotOnUrl(const QString& url);
179
180
181     signals:
182         void mousePressed(); /* to ThreadView */
183
184         /* cache */
185         void receiveData();
186         void finishReload();
187
188         /* res popup */
189         void hideChildPopup();
190     };
191
192     /* user defined events */
193     class GotoAnchorEvent : public QEvent
194     {
195         QString m_anc;
196
197     public:
198
199         GotoAnchorEvent(const QString& anc)
200                 : QEvent(QEvent::Type(EVENT_GotoAnchor)), m_anc(anc) {};
201
202         const QString& getAnc() const { return m_anc; }
203     };
204 }
205
206 #endif