1 | /**********************************************************************
|
---|
2 | ** Copyright (C) 2005-2007 Trolltech ASA. All rights reserved.
|
---|
3 | **
|
---|
4 | ** This file is part of Qt Designer.
|
---|
5 | **
|
---|
6 | ** This file may be distributed and/or modified under the terms of the
|
---|
7 | ** GNU General Public License version 2 as published by the Free Software
|
---|
8 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
9 | ** packaging of this file.
|
---|
10 | **
|
---|
11 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
---|
12 | ** licenses may use this file in accordance with the Qt Commercial License
|
---|
13 | ** Agreement provided with the Software.
|
---|
14 | **
|
---|
15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
17 | **
|
---|
18 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
19 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
20 | ** information about Qt Commercial License Agreements.
|
---|
21 | **
|
---|
22 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
23 | ** not clear to you.
|
---|
24 | **
|
---|
25 | **********************************************************************/
|
---|
26 |
|
---|
27 | #ifndef EDITOR_H
|
---|
28 | #define EDITOR_H
|
---|
29 |
|
---|
30 | #include <qtextedit.h>
|
---|
31 |
|
---|
32 | struct Config;
|
---|
33 | class ParenMatcher;
|
---|
34 | class EditorCompletion;
|
---|
35 | class EditorBrowser;
|
---|
36 | class QAccel;
|
---|
37 |
|
---|
38 | class Editor : public QTextEdit
|
---|
39 | {
|
---|
40 | Q_OBJECT
|
---|
41 |
|
---|
42 | public:
|
---|
43 | enum Selection {
|
---|
44 | Error = 3,
|
---|
45 | Step = 4
|
---|
46 | };
|
---|
47 |
|
---|
48 | Editor( const QString &fn, QWidget *parent, const char *name );
|
---|
49 | ~Editor();
|
---|
50 | virtual void load( const QString &fn );
|
---|
51 | virtual void save( const QString &fn );
|
---|
52 | QTextDocument *document() const { return QTextEdit::document(); }
|
---|
53 | void placeCursor( const QPoint &p, QTextCursor *c ) { QTextEdit::placeCursor( p, c ); }
|
---|
54 | void setDocument( QTextDocument *doc ) { QTextEdit::setDocument( doc ); }
|
---|
55 | QTextCursor *textCursor() const { return QTextEdit::textCursor(); }
|
---|
56 | void repaintChanged() { QTextEdit::repaintChanged(); }
|
---|
57 |
|
---|
58 | virtual EditorCompletion *completionManager() { return 0; }
|
---|
59 | virtual EditorBrowser *browserManager() { return 0; }
|
---|
60 | virtual void configChanged();
|
---|
61 |
|
---|
62 | Config *config() { return cfg; }
|
---|
63 |
|
---|
64 | void setErrorSelection( int line );
|
---|
65 | void setStepSelection( int line );
|
---|
66 | void clearStepSelection();
|
---|
67 | void clearSelections();
|
---|
68 |
|
---|
69 | virtual bool supportsErrors() const { return TRUE; }
|
---|
70 | virtual bool supportsBreakPoints() const { return TRUE; }
|
---|
71 | virtual void makeFunctionVisible( QTextParagraph * ) {}
|
---|
72 |
|
---|
73 | void drawCursor( bool b ) { QTextEdit::drawCursor( b ); }
|
---|
74 |
|
---|
75 | QPopupMenu *createPopupMenu( const QPoint &p );
|
---|
76 | bool eventFilter( QObject *o, QEvent *e );
|
---|
77 |
|
---|
78 | void setEditable( bool b ) { editable = b; }
|
---|
79 |
|
---|
80 | protected:
|
---|
81 | void doKeyboardAction( KeyboardAction action );
|
---|
82 | void keyPressEvent( QKeyEvent *e );
|
---|
83 |
|
---|
84 | signals:
|
---|
85 | void clearErrorMarker();
|
---|
86 | void intervalChanged();
|
---|
87 |
|
---|
88 | private slots:
|
---|
89 | void cursorPosChanged( QTextCursor *c );
|
---|
90 | void doChangeInterval();
|
---|
91 | void commentSelection();
|
---|
92 | void uncommentSelection();
|
---|
93 |
|
---|
94 | protected:
|
---|
95 | ParenMatcher *parenMatcher;
|
---|
96 | QString filename;
|
---|
97 | Config *cfg;
|
---|
98 | bool hasError;
|
---|
99 | QAccel *accelComment, *accelUncomment;
|
---|
100 | bool editable;
|
---|
101 |
|
---|
102 | };
|
---|
103 |
|
---|
104 | #endif
|
---|