~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to editors/qeditor/qeditor_view.h

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2006-05-23 18:39:42 UTC
  • Revision ID: james.westby@ubuntu.com-20060523183942-hucifbvh68k2bwz7
Tags: upstream-3.3.2
Import upstream version 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright (C) 2001 Roberto Raggi (roberto@kdevelop.org)
 
3
 *
 
4
 *  This program is free software; you can redistribute it and/or
 
5
 *  modify it under the terms of the GNU 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 program 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
 *  General Public License for more details.
 
13
 *
 
14
 *  You should have received a copy of the GNU General Public License
 
15
 *  along with this program; see the file COPYING.  If not, write to
 
16
 *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
17
 *  Boston, MA 02111-1307, USA.
 
18
 *
 
19
 */
 
20
#ifndef qeditor_view_h
 
21
#define qeditor_view_h
 
22
 
 
23
#include <kdeversion.h>
 
24
#include <ktexteditor/view.h>
 
25
#include <ktexteditor/viewcursorinterface.h>
 
26
#include <ktexteditor/clipboardinterface.h>
 
27
 
 
28
class QPopupMenu;
 
29
#include <ktexteditor/popupmenuinterface.h>
 
30
#include <ktexteditor/codecompletioninterface.h>
 
31
#if defined(KDE_MAKE_VERSION)
 
32
# if KDE_VERSION >= KDE_MAKE_VERSION(3,1,90)
 
33
#  include <ktexteditor/texthintinterface.h>
 
34
# else
 
35
#  include "kde30x_texthintinterface.h"
 
36
# endif
 
37
#else
 
38
# include "kde30x_texthintinterface.h"
 
39
#endif
 
40
 
 
41
class QEditor;
 
42
class QEditorPart;
 
43
class QEditorCodeCompletion;
 
44
class LineNumberWidget;
 
45
class MarkerWidget;
 
46
class LevelWidget;
 
47
class KoFindDialog;
 
48
class KoReplaceDialog;
 
49
class KoFind;
 
50
class KoReplace;
 
51
class QTextParagraph;
 
52
class QEditorTextHint;
 
53
 
 
54
class QEditorView:
 
55
    public KTextEditor::View,
 
56
    public KTextEditor::ClipboardInterface,
 
57
    public KTextEditor::ViewCursorInterface,
 
58
    public KTextEditor::PopupMenuInterface,
 
59
    public KTextEditor::CodeCompletionInterface,
 
60
    public KTextEditor::TextHintInterface
 
61
{
 
62
    Q_OBJECT
 
63
public:
 
64
    QEditorView( QEditorPart*, QWidget* =0, const char* =0 );
 
65
    virtual ~QEditorView();
 
66
 
 
67
    KTextEditor::Document* document() const;
 
68
    QEditorPart* doc() const { return m_document; }
 
69
    QEditor* editor() const { return m_editor; }
 
70
 
 
71
    QString currentTextLine() const;
 
72
    void insertText( const QString& );
 
73
 
 
74
    QString language() const;
 
75
 
 
76
    bool isMarkerWidgetVisible() const;
 
77
    void setMarkerWidgetVisible( bool );
 
78
    MarkerWidget* markerWidget() { return m_markerWidget; }
 
79
 
 
80
    bool isLineNumberWidgetVisible() const;
 
81
    void setLineNumberWidgetVisible( bool );
 
82
 
 
83
    bool isLevelWidgetVisible() const;
 
84
    void setLevelWidgetVisible( bool );
 
85
 
 
86
    int tabStop() const;
 
87
    void setTabStop( int );
 
88
 
 
89
public slots:
 
90
    void configChanged();
 
91
    void gotoLine();
 
92
    void setLanguage( const QString& );
 
93
    void doFind();
 
94
    void doReplace();
 
95
    void indent();
 
96
    void ensureTextIsVisible( QTextParagraph* );
 
97
    void expandBlock( QTextParagraph* );
 
98
    void collapseBlock( QTextParagraph* );
 
99
    void expandAllBlocks();
 
100
    void collapseAllBlocks();
 
101
 
 
102
protected slots:
 
103
    void highlight( const QString&, int, int, const QRect& );
 
104
    void replace( const QString&, int, int, int, const QRect& );
 
105
 
 
106
protected:
 
107
    void proceed();
 
108
    bool find_real( QTextParagraph* firstParag, int firstIndex,
 
109
                    QTextParagraph* lastParag, int lastIndex );
 
110
    bool process( const QString& );
 
111
    void doRepaint();
 
112
    void internalEnsureVisibleBlock( QTextParagraph* );
 
113
    void internalExpandBlock( QTextParagraph* );
 
114
    void internalCollapseBlock( QTextParagraph* );
 
115
 
 
116
private:
 
117
    void setupActions();
 
118
 
 
119
private:
 
120
    QTextParagraph* m_currentParag;
 
121
    KoFindDialog* m_findDialog;
 
122
    KoReplaceDialog* m_replaceDialog;
 
123
    KoFind* m_find;
 
124
    KoReplace* m_replace;
 
125
    long m_options;
 
126
    int m_offset;
 
127
 
 
128
// ViewCursorInterface ----------------------------------------------------------------------
 
129
public:
 
130
    /**
 
131
     * Get the current cursor coordinates in pixels.
 
132
     */
 
133
    virtual QPoint cursorCoordinates ();
 
134
 
 
135
    /**
 
136
     * Get the cursor position
 
137
     */
 
138
    virtual void cursorPosition (unsigned int *line, unsigned int *col);
 
139
 
 
140
    /**
 
141
     * Get the cursor position, calculated with 1 character per tab
 
142
     */
 
143
    virtual void cursorPositionReal (unsigned int *line, unsigned int *col);
 
144
 
 
145
    /**
 
146
     * Set the cursor position
 
147
     */
 
148
    virtual bool setCursorPosition (unsigned int line, unsigned int col);
 
149
 
 
150
    /**
 
151
     * Set the cursor position, use 1 character per tab
 
152
     */
 
153
    virtual bool setCursorPositionReal (unsigned int line, unsigned int col);
 
154
 
 
155
    virtual unsigned int cursorLine ();
 
156
    virtual unsigned int cursorColumn ();
 
157
    virtual unsigned int cursorColumnReal ();
 
158
 
 
159
signals:
 
160
    void cursorPositionChanged ();
 
161
 
 
162
// -- ClipboardInterface ----------------------------------------------------------------------
 
163
public slots:
 
164
    /**
 
165
     * copies selected text
 
166
     */
 
167
    virtual void copy ( ) const;
 
168
 
 
169
    /**
 
170
     * copies selected text
 
171
     */
 
172
    virtual void cut ( );
 
173
 
 
174
    /**
 
175
     * copies selected text
 
176
     */
 
177
    virtual void paste ( );
 
178
 
 
179
    /**
 
180
     * select all text
 
181
     */
 
182
    virtual void selectAll ( );
 
183
 
 
184
// -- PopupMenuInterface ----------------------------------------------------------------------
 
185
public:
 
186
    /**
 
187
       Install a Popup Menu. The Popup Menu will be activated on
 
188
       a right mouse button press event.
 
189
    */
 
190
    virtual void installPopup ( class QPopupMenu *rmb_Menu );
 
191
 
 
192
// -- CodeCompletionInterface ----------------------------------------------------------------------
 
193
    /**
 
194
     * This shows an argument hint.
 
195
     */
 
196
    virtual void showArgHint (QStringList functionList, const QString& strWrapping, const QString& strDelimiter);
 
197
 
 
198
    /**
 
199
     * This shows a completion list. @p offset is the real start of the text that
 
200
     * should be completed. <code>0</code> means that the text starts at the current cursor
 
201
     * position. if @p casesensitive is @p true, the popup will only contain completions
 
202
     * that match the input text regarding case.
 
203
     */
 
204
    virtual void showCompletionBox (QValueList<KTextEditor::CompletionEntry> complList,int offset=0, bool casesensitive=true);
 
205
 
 
206
signals:
 
207
    /**
 
208
     * This signal is emitted when the completion list disappears and no completion has
 
209
     * been done. This is the case e.g. when the user presses Escape.
 
210
     *
 
211
     * IMPORTANT: Please check if a connect to this signal worked, and implement some fallback
 
212
     * when the implementation doesn't support it
 
213
     *
 
214
     * IMPORTANT FOR IMPLEMENTERS: When you don't support this signal, please just override the inherited
 
215
     * function, if you support it, declare it as a signal
 
216
     */
 
217
    void completionAborted();
 
218
 
 
219
    /**
 
220
     * This signal is emitted when the completion list disappears and a completion has
 
221
     * been inserted into text. This is the case e.g. when the user presses Return
 
222
     * on a selected item in the completion list.
 
223
     *
 
224
     * IMPORTANT: Please check if a connect to this signal worked, and implement some fallback
 
225
     * when the implementation doesn't support it
 
226
     *
 
227
     * IMPORTANT FOR IMPLEMENTERS: When you don't support this signal, please just override the inherited
 
228
     * function, if you support it, declare it as a signal
 
229
     */
 
230
    void completionDone();
 
231
 
 
232
    /**
 
233
     * This signal is the same as @ref completionDone(), but additionally it carries
 
234
     * the information which completion item was used.
 
235
     *
 
236
     * IMPORTANT: Please check if a connect to this signal worked, and implement some fallback
 
237
     * when the implementation doesn't support it
 
238
     *
 
239
     * IMPORTANT: The pointer to the CompleteionEntry, is only valid in the slots connected to this signal
 
240
     * when the connected slots are left, the data element may be destroyed, depending on the implementation
 
241
     *
 
242
     * IMPORTANT FOR IMPLEMENTERS: When you don't support this signal, please just override the inherited
 
243
     * function, if you support it, declare it as a signal.
 
244
     *
 
245
     */
 
246
    void completionDone(KTextEditor::CompletionEntry);
 
247
 
 
248
    /**
 
249
     * This signal is emitted when the argument hint disappears.
 
250
     * This is the case e.g. when the user moves the cursor somewhere else.
 
251
     *
 
252
     * IMPORTANT: Please check if a connect to this signal worked, and implement some fallback
 
253
     * when the implementation doesn't support it
 
254
     *
 
255
     * IMPORTANT FOR IMPLEMENTERS: When you don't support this signal, please just override the inherited
 
256
     * function, if you support it, declare it as a signal
 
257
     */
 
258
    void argHintHidden();
 
259
 
 
260
    /**
 
261
     * This signal is emitted just before a completion takes place.
 
262
     * You can use it to modify the @ref KTextEditor::CompletionEntry. The modified
 
263
     * entry will not be visible in the completion list (because that has
 
264
     * just disappeared) but it will be used when the completion is
 
265
     * inserted into the text.
 
266
     *
 
267
     * IMPORTANT: Please check if a connect to this signal worked, and implement some fallback
 
268
     * when the implementation doesn't support it
 
269
     *
 
270
     * IMPORTANT FOR IMPLEMENTERS: When you don't support this signal, please just override the inherited
 
271
     * function, if you support it, declare it as a signal
 
272
     */
 
273
    void filterInsertString(KTextEditor::CompletionEntry*,QString*);
 
274
 
 
275
    void aboutToShowCompletionBox();
 
276
 
 
277
public:
 
278
    QString computeTextHint( int line, int column );
 
279
    void enableTextHints( int timeout );
 
280
    void disableTextHints();
 
281
 
 
282
signals:
 
283
    void needTextHint( int line, int column, QString& );
 
284
    void newStatus();
 
285
 
 
286
private:
 
287
    QEditorPart* m_document;
 
288
    QEditor* m_editor;
 
289
    QEditorCodeCompletion* m_pCodeCompletion;
 
290
    LineNumberWidget* m_lineNumberWidget;
 
291
    MarkerWidget* m_markerWidget;
 
292
    LevelWidget* m_levelWidget;
 
293
    QEditorTextHint* m_textHintToolTip;
 
294
};
 
295
 
 
296
#endif