25 : QsciScintilla( parent )
26 , mWidgetTitle( title )
30 if ( !parent && mWidgetTitle.
isEmpty() )
32 setWindowTitle(
"Text Editor" );
33 setMinimumSize( 800, 300 );
37 setWindowTitle( mWidgetTitle );
40 setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded );
47 void QgsCodeEditor::setSciWidget()
50 setCaretLineVisible(
true );
51 setCaretLineBackgroundColor(
QColor(
"#fcf3ed" ) );
53 setBraceMatching( QsciScintilla::SloppyBraceMatch );
54 setMatchedBraceBackgroundColor(
QColor(
"#b7f907" ) );
60 setAutoIndent(
true );
61 setIndentationWidth( 4 );
62 setTabIndents(
true );
63 setBackspaceUnindents(
true );
66 setAutoCompletionThreshold( 2 );
67 setAutoCompletionSource( QsciScintilla::AcsAPIs );
72 setWindowTitle( title );
80 QFont marginFont(
"Courier", 10 );
81 setMarginLineNumbers( 1,
true );
82 setMarginsFont( marginFont );
83 setMarginWidth( 1,
"00000" );
84 setMarginsForegroundColor(
QColor(
"#3E3EE3" ) );
85 setMarginsBackgroundColor(
QColor(
"#f9f9f9" ) );
89 setMarginWidth( 0, 0 );
90 setMarginWidth( 1, 0 );
91 setMarginWidth( 2, 0 );
100 setFolding( QsciScintilla::PlainFoldStyle );
101 setFoldMarginColors(
QColor(
"#f4f4f4" ),
QColor(
"#f4f4f4" ) );
105 setFolding( QsciScintilla::NoFoldStyle );
112 if ( hasSelectedText() )
114 replaceSelectedText( theText );
119 getCursorPosition( &line, &index );
120 insertAt( theText, line, index );
121 setCursorPosition( line, index + theText.
length() );
134 QString loadFont = settings.
value(
"pythonConsole/fontfamilytextEditor",
"Monospace" ).
toString();
135 int fontSize = settings.
value(
"pythonConsole/fontsizeEditor", 10 ).
toInt();
137 QFont font( loadFont );
void setPointSize(int pointSize)
void setFoldingVisible(bool folding)
Set folding visible state.
void setBold(bool enable)
QgsCodeEditor(QWidget *parent=0, const QString &title="", bool folding=false, bool margin=false)
Construct a new code editor.
int toInt(bool *ok) const
void setStyleHint(StyleHint hint, StyleStrategy strategy)
void setMarginVisible(bool margin)
Set margin visible state.
QVariant value(const QString &key, const QVariant &defaultValue) const
void setTitle(const QString &title)
Set the widget title.
bool isFixedPitch(const QFont &font)
void setLetterSpacing(SpacingType type, qreal spacing)
void setFixedPitch(bool enable)
void insertText(const QString &theText)
Insert text at cursor position, or replace any selected text if user has made a selection.
void setStretch(int factor)