1 /************************************************************************
3 * Copyright 2010 Jakob Leben (jakob.leben@gmail.com)
5 * This file is part of SuperCollider Qt GUI.
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ************************************************************************/
25 #include "../QcHelper.h"
29 class QcTextEdit
: public QTextEdit
, QcHelper
32 Q_PROPERTY( QString document READ documentFilename WRITE setDocument
);
33 Q_PROPERTY( int selectionStart READ selectionStart
);
34 Q_PROPERTY( int selectionSize READ selectionSize
);
35 Q_PROPERTY( QString selectedString READ selectedString WRITE replaceSelectedText
);
36 Q_PROPERTY( QFont textFont READ dummyFont WRITE setTextFont
);
37 Q_PROPERTY( QColor textColor READ dummyColor WRITE setTextColor
);
38 Q_PROPERTY( VariantList rangeColor
39 READ dummyVariantList WRITE setRangeColor
);
40 Q_PROPERTY( VariantList rangeFont
41 READ dummyVariantList WRITE setRangeFont
);
42 Q_PROPERTY( VariantList rangeText
43 READ dummyVariantList WRITE setRangeText
);
44 Q_PROPERTY( bool enterInterpretsSelection
45 READ interpretSelection WRITE setInterpretSelection
);
49 QString
documentFilename() const;
50 void setDocument( const QString
& );
51 int selectionStart() const;
52 int selectionSize() const;
53 Q_INVOKABLE
void select( int start
, int size
);
54 QString
selectedString() const;
55 void replaceSelectedText( const QString
& );
56 bool interpretSelection() const { return _interpretSelection
; }
57 void setInterpretSelection( bool b
) { _interpretSelection
= b
; }
58 void setTextFont( const QFont
& );
59 void setTextColor( const QColor
& );
60 void setRangeColor( const VariantList
& );
61 void setRangeFont( const VariantList
& );
62 void setRangeText( const VariantList
& );
65 void interpret( const QString
& code
);
68 virtual void keyPressEvent( QKeyEvent
* );
69 virtual void insertFromMimeData ( const QMimeData
* );
72 QString
& prepareText( QString
& str
) const;
75 bool _interpretSelection
;