2
* Copyright (C) 2001 Roberto Raggi (roberto@kdevelop.org)
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.
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.
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.
20
#ifndef qeditor_view_h
21
#define qeditor_view_h
23
#include <kdeversion.h>
24
#include <ktexteditor/view.h>
25
#include <ktexteditor/viewcursorinterface.h>
26
#include <ktexteditor/clipboardinterface.h>
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>
35
# include "kde30x_texthintinterface.h"
38
# include "kde30x_texthintinterface.h"
43
class QEditorCodeCompletion;
44
class LineNumberWidget;
48
class KoReplaceDialog;
52
class QEditorTextHint;
55
public KTextEditor::View,
56
public KTextEditor::ClipboardInterface,
57
public KTextEditor::ViewCursorInterface,
58
public KTextEditor::PopupMenuInterface,
59
public KTextEditor::CodeCompletionInterface,
60
public KTextEditor::TextHintInterface
64
QEditorView( QEditorPart*, QWidget* =0, const char* =0 );
65
virtual ~QEditorView();
67
KTextEditor::Document* document() const;
68
QEditorPart* doc() const { return m_document; }
69
QEditor* editor() const { return m_editor; }
71
QString currentTextLine() const;
72
void insertText( const QString& );
74
QString language() const;
76
bool isMarkerWidgetVisible() const;
77
void setMarkerWidgetVisible( bool );
78
MarkerWidget* markerWidget() { return m_markerWidget; }
80
bool isLineNumberWidgetVisible() const;
81
void setLineNumberWidgetVisible( bool );
83
bool isLevelWidgetVisible() const;
84
void setLevelWidgetVisible( bool );
87
void setTabStop( int );
92
void setLanguage( const QString& );
96
void ensureTextIsVisible( QTextParagraph* );
97
void expandBlock( QTextParagraph* );
98
void collapseBlock( QTextParagraph* );
99
void expandAllBlocks();
100
void collapseAllBlocks();
103
void highlight( const QString&, int, int, const QRect& );
104
void replace( const QString&, int, int, int, const QRect& );
108
bool find_real( QTextParagraph* firstParag, int firstIndex,
109
QTextParagraph* lastParag, int lastIndex );
110
bool process( const QString& );
112
void internalEnsureVisibleBlock( QTextParagraph* );
113
void internalExpandBlock( QTextParagraph* );
114
void internalCollapseBlock( QTextParagraph* );
120
QTextParagraph* m_currentParag;
121
KoFindDialog* m_findDialog;
122
KoReplaceDialog* m_replaceDialog;
124
KoReplace* m_replace;
128
// ViewCursorInterface ----------------------------------------------------------------------
131
* Get the current cursor coordinates in pixels.
133
virtual QPoint cursorCoordinates ();
136
* Get the cursor position
138
virtual void cursorPosition (unsigned int *line, unsigned int *col);
141
* Get the cursor position, calculated with 1 character per tab
143
virtual void cursorPositionReal (unsigned int *line, unsigned int *col);
146
* Set the cursor position
148
virtual bool setCursorPosition (unsigned int line, unsigned int col);
151
* Set the cursor position, use 1 character per tab
153
virtual bool setCursorPositionReal (unsigned int line, unsigned int col);
155
virtual unsigned int cursorLine ();
156
virtual unsigned int cursorColumn ();
157
virtual unsigned int cursorColumnReal ();
160
void cursorPositionChanged ();
162
// -- ClipboardInterface ----------------------------------------------------------------------
165
* copies selected text
167
virtual void copy ( ) const;
170
* copies selected text
172
virtual void cut ( );
175
* copies selected text
177
virtual void paste ( );
182
virtual void selectAll ( );
184
// -- PopupMenuInterface ----------------------------------------------------------------------
187
Install a Popup Menu. The Popup Menu will be activated on
188
a right mouse button press event.
190
virtual void installPopup ( class QPopupMenu *rmb_Menu );
192
// -- CodeCompletionInterface ----------------------------------------------------------------------
194
* This shows an argument hint.
196
virtual void showArgHint (QStringList functionList, const QString& strWrapping, const QString& strDelimiter);
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.
204
virtual void showCompletionBox (QValueList<KTextEditor::CompletionEntry> complList,int offset=0, bool casesensitive=true);
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.
211
* IMPORTANT: Please check if a connect to this signal worked, and implement some fallback
212
* when the implementation doesn't support it
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
217
void completionAborted();
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.
224
* IMPORTANT: Please check if a connect to this signal worked, and implement some fallback
225
* when the implementation doesn't support it
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
230
void completionDone();
233
* This signal is the same as @ref completionDone(), but additionally it carries
234
* the information which completion item was used.
236
* IMPORTANT: Please check if a connect to this signal worked, and implement some fallback
237
* when the implementation doesn't support it
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
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.
246
void completionDone(KTextEditor::CompletionEntry);
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.
252
* IMPORTANT: Please check if a connect to this signal worked, and implement some fallback
253
* when the implementation doesn't support it
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
258
void argHintHidden();
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.
267
* IMPORTANT: Please check if a connect to this signal worked, and implement some fallback
268
* when the implementation doesn't support it
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
273
void filterInsertString(KTextEditor::CompletionEntry*,QString*);
275
void aboutToShowCompletionBox();
278
QString computeTextHint( int line, int column );
279
void enableTextHints( int timeout );
280
void disableTextHints();
283
void needTextHint( int line, int column, QString& );
287
QEditorPart* m_document;
289
QEditorCodeCompletion* m_pCodeCompletion;
290
LineNumberWidget* m_lineNumberWidget;
291
MarkerWidget* m_markerWidget;
292
LevelWidget* m_levelWidget;
293
QEditorTextHint* m_textHintToolTip;