Public Slots | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
QCodeEditor Class Reference

Class, that describes code editor. More...

#include <QCodeEditor.hpp>

Inheritance diagram for QCodeEditor:
Inheritance graph
[legend]

Public Slots

void insertCompletion (QString s)
 Slot, that performs insertion of completion info into code. More...
 
void onSelectionChanged ()
 Slot, that will be called on selection change. More...
 
void updateExtraSelection ()
 Slot, that will proceed extra selection for current cursor position. More...
 
void updateLineNumberArea (const QRect &rect)
 Slot, that performs update of some part of line number area. More...
 
void updateLineNumberAreaWidth (int)
 Slot, that performs update of internal editor viewport based on line number area width. More...
 
void updateStyle ()
 Slot, that will update editor style. More...
 

Public Member Functions

bool autoIndentation () const
 Method for getting is auto indentation enabled. Default: true. More...
 
bool autoParentheses () const
 Method for getting is auto parentheses enabled. Default value: true. More...
 
QCompleter * completer () const
 Method for getting completer. More...
 
int getFirstVisibleBlock ()
 Method for getting first visible block index. More...
 
QCodeEditoroperator= (const QCodeEditor &)=delete
 
 QCodeEditor (const QCodeEditor &)=delete
 
 QCodeEditor (QWidget *widget=nullptr)
 Constructor. More...
 
void setAutoIndentation (bool enabled)
 Method for setting auto indentation enabled. More...
 
void setAutoParentheses (bool enabled)
 Method setting auto parentheses enabled. More...
 
void setCompleter (QCompleter *completer)
 Method for setting completer. More...
 
void setHighlighter (QStyleSyntaxHighlighter *highlighter)
 Method for setting highlighter. More...
 
void setSyntaxStyle (QSyntaxStyle *style)
 Method for setting syntax sty.e. More...
 
void setTabReplace (bool enabled)
 Method for setting tab replacing enabled. More...
 
void setTabReplaceSize (int val)
 Method for setting amount of spaces, that will replace tab. More...
 
bool tabReplace () const
 Method for getting is tab replacing enabled. Default value: true. More...
 
int tabReplaceSize () const
 Method for getting number of spaces, that will replace tab if tabReplace is true. Default: 4. More...
 

Protected Member Functions

void focusInEvent (QFocusEvent *e) override
 Method, that's called on focus into widget. It's required for setting this widget to set completer. More...
 
void insertFromMimeData (const QMimeData *source) override
 Method, that's called on any text insertion of mimedata into editor. If it's text - it inserts text as plain text. More...
 
void keyPressEvent (QKeyEvent *e) override
 Method, that's called on any key press, posted into code editor widget. This method is overloaded for: More...
 
void paintEvent (QPaintEvent *e) override
 Method, that's called on editor painting. This method if overloaded for line number area redraw. More...
 
void resizeEvent (QResizeEvent *e) override
 Method, that's called on any widget resize. This method if overloaded for line number area resizing. More...
 

Private Member Functions

QChar charUnderCursor (int offset=0) const
 Method for getting character under cursor. More...
 
int getIndentationSpaces ()
 Method for getting number of indentation spaces in current line. Tabs will be treated as tabWidth / spaceWidth More...
 
void handleSelectionQuery (QTextCursor cursor)
 Method, that performs selection frame selection. More...
 
void highlightCurrentLine (QList< QTextEdit::ExtraSelection > &extraSelection)
 Method, that adds highlighting of currently selected line to extra selection list. More...
 
void highlightParenthesis (QList< QTextEdit::ExtraSelection > &extraSelection)
 Method, that adds highlighting of parenthesis if available. More...
 
void initDocumentLayoutHandlers ()
 Method for initializing document layout handlers. More...
 
void initFont ()
 Method for initializing default monospace font. More...
 
void performConnections ()
 Method for performing connection of objects. More...
 
bool proceedCompleterBegin (QKeyEvent *e)
 Method, that performs completer processing. Returns true if event has to be dropped. More...
 
void proceedCompleterEnd (QKeyEvent *e)
 
void updateLineGeometry ()
 Method for updating geometry of line number area. More...
 
QString wordUnderCursor () const
 Method for getting word under cursor. More...
 

Private Attributes

bool m_autoIndentation
 
bool m_autoParentheses
 
QCompleter * m_completer
 
QFramedTextAttributem_framedAttribute
 
QStyleSyntaxHighlighterm_highlighter
 
QLineNumberAream_lineNumberArea
 
bool m_replaceTab
 
QSyntaxStylem_syntaxStyle
 
QString m_tabReplace
 

Detailed Description

Class, that describes code editor.

Definition at line 15 of file QCodeEditor.hpp.

Constructor & Destructor Documentation

◆ QCodeEditor() [1/2]

QCodeEditor::QCodeEditor ( QWidget *  widget = nullptr)
explicit

Constructor.

Parameters
widgetPointer to parent widget.

Definition at line 31 of file QCodeEditor.cpp.

◆ QCodeEditor() [2/2]

QCodeEditor::QCodeEditor ( const QCodeEditor )
delete

Member Function Documentation

◆ autoIndentation()

bool QCodeEditor::autoIndentation ( ) const

Method for getting is auto indentation enabled. Default: true.

◆ autoParentheses()

bool QCodeEditor::autoParentheses ( ) const

Method for getting is auto parentheses enabled. Default value: true.

◆ charUnderCursor()

QChar QCodeEditor::charUnderCursor ( int  offset = 0) const
private

Method for getting character under cursor.

Parameters
offsetOffset to cursor.

◆ completer()

QCompleter* QCodeEditor::completer ( ) const

Method for getting completer.

Returns
Pointer to completer.

◆ focusInEvent()

void QCodeEditor::focusInEvent ( QFocusEvent *  e)
overrideprotected

Method, that's called on focus into widget. It's required for setting this widget to set completer.

◆ getFirstVisibleBlock()

int QCodeEditor::getFirstVisibleBlock ( )

Method for getting first visible block index.

Returns
Index.

Definition at line 378 of file QCodeEditor.cpp.

◆ getIndentationSpaces()

int QCodeEditor::getIndentationSpaces ( )
private

Method for getting number of indentation spaces in current line. Tabs will be treated as tabWidth / spaceWidth

◆ handleSelectionQuery()

void QCodeEditor::handleSelectionQuery ( QTextCursor  cursor)
private

Method, that performs selection frame selection.

Definition at line 235 of file QCodeEditor.cpp.

◆ highlightCurrentLine()

void QCodeEditor::highlightCurrentLine ( QList< QTextEdit::ExtraSelection > &  extraSelection)
private

Method, that adds highlighting of currently selected line to extra selection list.

Definition at line 356 of file QCodeEditor.cpp.

◆ highlightParenthesis()

void QCodeEditor::highlightParenthesis ( QList< QTextEdit::ExtraSelection > &  extraSelection)
private

Method, that adds highlighting of parenthesis if available.

Definition at line 259 of file QCodeEditor.cpp.

◆ initDocumentLayoutHandlers()

void QCodeEditor::initDocumentLayoutHandlers ( )
private

Method for initializing document layout handlers.

Definition at line 50 of file QCodeEditor.cpp.

◆ initFont()

void QCodeEditor::initFont ( )
private

Method for initializing default monospace font.

Definition at line 60 of file QCodeEditor.cpp.

◆ insertCompletion

void QCodeEditor::insertCompletion ( QString  s)
slot

Slot, that performs insertion of completion info into code.

Parameters
sData.

◆ insertFromMimeData()

void QCodeEditor::insertFromMimeData ( const QMimeData *  source)
overrideprotected

Method, that's called on any text insertion of mimedata into editor. If it's text - it inserts text as plain text.

◆ keyPressEvent()

void QCodeEditor::keyPressEvent ( QKeyEvent *  e)
overrideprotected

Method, that's called on any key press, posted into code editor widget. This method is overloaded for:

  1. Completion
  2. Tab to spaces
  3. Low indentation
  4. Auto parenthesis

◆ onSelectionChanged

void QCodeEditor::onSelectionChanged ( )
slot

Slot, that will be called on selection change.

Definition at line 165 of file QCodeEditor.cpp.

◆ operator=()

QCodeEditor& QCodeEditor::operator= ( const QCodeEditor )
delete

◆ paintEvent()

void QCodeEditor::paintEvent ( QPaintEvent *  e)
overrideprotected

Method, that's called on editor painting. This method if overloaded for line number area redraw.

Definition at line 372 of file QCodeEditor.cpp.

◆ performConnections()

void QCodeEditor::performConnections ( )
private

Method for performing connection of objects.

Definition at line 69 of file QCodeEditor.cpp.

◆ proceedCompleterBegin()

bool QCodeEditor::proceedCompleterBegin ( QKeyEvent *  e)
private

Method, that performs completer processing. Returns true if event has to be dropped.

Parameters
ePointer to key event.
Returns
Shall event be dropped.

Definition at line 412 of file QCodeEditor.cpp.

◆ proceedCompleterEnd()

void QCodeEditor::proceedCompleterEnd ( QKeyEvent *  e)
private

Definition at line 438 of file QCodeEditor.cpp.

◆ resizeEvent()

void QCodeEditor::resizeEvent ( QResizeEvent *  e)
overrideprotected

Method, that's called on any widget resize. This method if overloaded for line number area resizing.

Definition at line 195 of file QCodeEditor.cpp.

◆ setAutoIndentation()

void QCodeEditor::setAutoIndentation ( bool  enabled)

Method for setting auto indentation enabled.

◆ setAutoParentheses()

void QCodeEditor::setAutoParentheses ( bool  enabled)

Method setting auto parentheses enabled.

◆ setCompleter()

void QCodeEditor::setCompleter ( QCompleter *  completer)

Method for setting completer.

Parameters
completerPointer to completer object.

◆ setHighlighter()

void QCodeEditor::setHighlighter ( QStyleSyntaxHighlighter highlighter)

Method for setting highlighter.

Parameters
highlighterPointer to syntax highlighter.

Definition at line 99 of file QCodeEditor.cpp.

◆ setSyntaxStyle()

void QCodeEditor::setSyntaxStyle ( QSyntaxStyle style)

Method for setting syntax sty.e.

Parameters
stylePointer to syntax style.

Definition at line 115 of file QCodeEditor.cpp.

◆ setTabReplace()

void QCodeEditor::setTabReplace ( bool  enabled)

Method for setting tab replacing enabled.

◆ setTabReplaceSize()

void QCodeEditor::setTabReplaceSize ( int  val)

Method for setting amount of spaces, that will replace tab.

Parameters
valNumber of spaces.

◆ tabReplace()

bool QCodeEditor::tabReplace ( ) const

Method for getting is tab replacing enabled. Default value: true.

◆ tabReplaceSize()

int QCodeEditor::tabReplaceSize ( ) const

Method for getting number of spaces, that will replace tab if tabReplace is true. Default: 4.

◆ updateExtraSelection

void QCodeEditor::updateExtraSelection ( )
slot

Slot, that will proceed extra selection for current cursor position.

Definition at line 249 of file QCodeEditor.cpp.

◆ updateLineGeometry()

void QCodeEditor::updateLineGeometry ( )
private

Method for updating geometry of line number area.

Definition at line 202 of file QCodeEditor.cpp.

◆ updateLineNumberArea

void QCodeEditor::updateLineNumberArea ( const QRect &  rect)
slot

Slot, that performs update of some part of line number area.

Parameters
rectArea that has to be updated.

Definition at line 219 of file QCodeEditor.cpp.

◆ updateLineNumberAreaWidth

void QCodeEditor::updateLineNumberAreaWidth ( int  )
slot

Slot, that performs update of internal editor viewport based on line number area width.

Definition at line 214 of file QCodeEditor.cpp.

◆ updateStyle

void QCodeEditor::updateStyle ( )
slot

Slot, that will update editor style.

Definition at line 130 of file QCodeEditor.cpp.

◆ wordUnderCursor()

QString QCodeEditor::wordUnderCursor ( ) const
private

Method for getting word under cursor.

Returns
Word under cursor.

Member Data Documentation

◆ m_autoIndentation

bool QCodeEditor::m_autoIndentation
private

Definition at line 268 of file QCodeEditor.hpp.

◆ m_autoParentheses

bool QCodeEditor::m_autoParentheses
private

Definition at line 269 of file QCodeEditor.hpp.

◆ m_completer

QCompleter* QCodeEditor::m_completer
private

Definition at line 264 of file QCodeEditor.hpp.

◆ m_framedAttribute

QFramedTextAttribute* QCodeEditor::m_framedAttribute
private

Definition at line 266 of file QCodeEditor.hpp.

◆ m_highlighter

QStyleSyntaxHighlighter* QCodeEditor::m_highlighter
private

Definition at line 261 of file QCodeEditor.hpp.

◆ m_lineNumberArea

QLineNumberArea* QCodeEditor::m_lineNumberArea
private

Definition at line 263 of file QCodeEditor.hpp.

◆ m_replaceTab

bool QCodeEditor::m_replaceTab
private

Definition at line 270 of file QCodeEditor.hpp.

◆ m_syntaxStyle

QSyntaxStyle* QCodeEditor::m_syntaxStyle
private

Definition at line 262 of file QCodeEditor.hpp.

◆ m_tabReplace

QString QCodeEditor::m_tabReplace
private

Definition at line 271 of file QCodeEditor.hpp.


The documentation for this class was generated from the following files:


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:50