OSDN Git Service

refactoring.
[kita/kita.git] / kita / 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
11 #ifndef KITAHTMLPART_H
12 #define KITAHTMLPART_H
13
14 #include <khtml_part.h>
15 #include <qframe.h>
16 #include <qevent.h>
17
18 /* mode */
19 enum {
20     /* on main window */
21     HTMLPART_MODE_MAINPART,
22
23     /* on popup       */
24     HTMLPART_MODE_POPUP
25 };
26
27 /* ID of user defined event */
28 #define EVENT_GotoAnchor ( QEvent::User + 100 )
29
30 class KitaDomTree;
31 class KURL;
32
33 namespace Kita
34 {
35     class ResPopup;
36 }
37
38 namespace DOM
39 {
40     class Node;
41 }
42
43
44 /*-------------------------------------------------------------*/
45
46 class KitaHTMLPart : public KHTMLPart
47 {
48     Q_OBJECT
49
50     KitaDomTree* m_domtree;
51     Kita::ResPopup* m_popup;
52
53     /* basic information */
54     int m_mode;
55     KURL m_datURL;
56     bool m_updatedKokoyon;
57
58
59     /* cache */
60     bool m_firstReceive;
61     int m_centerNum;
62
63     /* goto anchor */
64     QStringList m_anchorStack;
65     int m_jumpNumAfterLoading; /* see also slotFinishLoad() */
66
67     /* mouse event */
68     bool m_pushctrl;
69     bool m_pushmidbt;
70     bool m_pushrightbt;
71
72     /* search */
73     DOM::Node m_findNode;
74     int m_findPos;
75     int m_find_y;
76
77     /* res popup */
78     bool m_multiPopup;
79     bool m_kitaIsActive;
80
81
82 public:
83
84     KitaHTMLPart( QWidget* parent, const char* name = 0 );
85     ~KitaHTMLPart();
86     bool setup( int mode , const KURL& url );
87
88     /* rendering */
89     void showResponses( int startnum, int endnum );
90     void parseResponses( int startnum, int endnum );
91     void showAll();
92     void updateScreen( bool showHeaderEtc, bool clock );
93     void setInnerHTML( const QString& innerHTML );
94
95     /* cache */
96     bool load( int centerNum );
97     bool reload( int jumpNum );
98
99     /* goto anchor */
100     bool gotoAnchor( const QString& anc, bool pushPosition );
101
102     /* search */
103     bool findText( const QString &query, bool reverse );
104
105     /* popup */
106     bool isPopupVisible();
107
108 public slots:
109
110     /* rendering */
111     void slotRedrawAllHTMLPart( bool force );
112     void slotSetFaceOfHTMLPart();
113     void slotSetStyleSheetOfHTMLPart();
114
115     /* cache */
116     void slotReceiveData();
117     void slotFinishLoad();
118
119     /* goto anchor */
120     void slotGotoKokoyon();
121     void slotGobackAnchor();
122
123     /* Tugi100, Mae100 etc.  */
124     void slotClickGotoFooter();
125
126     /* res popup */
127     void slotDeletePopup();
128     void slotShowResPopup( QPoint point, int refNum, int refNum2 );
129
130 private:
131
132     void clearPart();
133     void redrawHTMLPart( const KURL& datURL, bool force );
134
135     /* setup */
136     void connectSignals();
137     void createHTMLDocument();
138
139     /* goto anchor */
140     void pushCurrentPosition();
141     QString getCurrentIDofNode();
142
143     /* popup menu */
144     void showPopupMenu( const KURL& kurl );
145
146     /* click */
147     void clickAnchor( const KURL& urlin );
148     void showWritePopupMenu( const QString& refstr );
149     void showIDPopup( const QString& refstr );
150     void showBePopupMenu( const QString& refstr );
151
152     /* search */
153     void findTextInit();
154
155     /* res popup */
156     void showPopup( const KURL& url, const QString& innerHTML );
157     void showPopupCore( const KURL& url, const QString& innerHTML, QPoint point );
158     bool startMultiPopup();
159     bool isMultiPopupMode();
160     void hidePopup();
161     bool isUnderMouse( int mrgwd, int mrght );
162     bool showSelectedDigitPopup();
163
164 protected:
165
166     /* user event */
167     virtual void customEvent( QCustomEvent * e );
168
169     /* mouse event */
170     virtual void khtmlMousePressEvent( khtml::MousePressEvent* e );
171
172
173 private slots:
174
175     /* click */
176     void slotOpenURLRequest( const KURL&, const KParts::URLArgs& );
177
178     /* res popup */
179     void slotLeave();
180     void slotVSliderReleased();
181     void slotHSliderReleased();
182     void slotHideChildPopup();
183     void slotKitaIsActive();
184     void slotOnURL( const QString& url );
185
186
187 signals:
188     void openURLRequestExt( const KURL& url, const QString mimetype = QString::null );
189     void mousePressed(); /* to KitaThreadView */
190
191     /* cache */
192     void receiveData();
193     void finishReload();
194
195     /* res popup */
196     void hideChildPopup();
197     void isKitaActive();
198
199     /* write dock */
200     void activateThreadView( const KURL& );
201     void closeWriteTab( const KURL& );
202
203     /* subject tab */
204     void updateSubjectTab( const KURL& );
205 };
206
207
208
209 /*---------------------------------------------------*/
210 /*---------------------------------------------------*/
211 /*---------------------------------------------------*/
212
213
214
215
216 /* user defined events */
217
218 class GotoAnchorEvent : public QCustomEvent
219 {
220     QString m_anc;
221
222 public:
223
224     GotoAnchorEvent( const QString& anc )
225             : QCustomEvent( EVENT_GotoAnchor ), m_anc( anc ) {};
226
227     const QString& getAnc() const { return m_anc; }
228 };
229
230
231 #endif