QGIS API Documentation 3.39.0-Master (bca3cdb6021)
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Friends | List of all members
QgsCodeEditorSQL Class Reference

A SQL editor based on QScintilla2. More...

#include <qgscodeeditorsql.h>

Inheritance diagram for QgsCodeEditorSQL:
Inheritance graph
[legend]

Public Member Functions

 QgsCodeEditorSQL (QWidget *parent=nullptr)
 Constructor for QgsCodeEditorSQL.
 
virtual ~QgsCodeEditorSQL ()
 
QStringList extraKeywords () const
 Returns the extra keywords.
 
QStringList fieldNames () const
 Returns field names from the lexer API.
 
Qgis::ScriptLanguage language () const override
 Returns the associated scripting language.
 
void setExtraKeywords (const QStringList &extraKeywords)
 Set extra keywords to extraKeywords.
 
void setFieldNames (const QStringList &fieldNames)
 Set field names to fieldNames to be added to the lexer API.
 
void setFields (const QgsFields &fields)
 Set field names to be added to the lexer API.
 
- Public Member Functions inherited from QgsCodeEditor
 QgsCodeEditor (QWidget *parent=nullptr, const QString &title=QString(), bool folding=false, bool margin=false, QgsCodeEditor::Flags flags=QgsCodeEditor::Flags(), QgsCodeEditor::Mode mode=QgsCodeEditor::Mode::ScriptEditor)
 Construct a new code editor.
 
void addWarning (int lineNumber, const QString &warning)
 Adds a warning message and indicator to the specified a lineNumber.
 
void clearWarnings ()
 Clears all warning messages from the editor.
 
bool foldingVisible ()
 Returns true if the folding controls are visible in the editor.
 
QStringList history () const
 Returns the list of commands previously executed in the editor.
 
void insertText (const QString &text)
 Insert text at cursor position, or replace any selected text if user has made a selection.
 
QgsCodeInterpreterinterpreter () const
 Returns the attached code interpreter, or nullptr if not set.
 
bool isCursorOnLastLine () const
 Returns true if the cursor is on the last line of the document.
 
virtual Qgis::ScriptLanguageCapabilities languageCapabilities () const
 Returns the associated scripting language capabilities.
 
int linearPosition () const
 Convenience function to return the cursor position as a linear index.
 
bool lineNumbersVisible () const
 Returns whether line numbers are visible in the editor.
 
Q_DECL_DEPRECATED bool marginVisible ()
 Returns whether margins are in a visible state.
 
QgsCodeEditor::Mode mode () const
 Returns the code editor mode.
 
int selectionEnd () const
 Convenience function to return the end of the selection as a linear index Contrary to the getSelection method, this method returns the cursor position if no selection is made.
 
int selectionStart () const
 Convenience function to return the start of the selection as a linear index Contrary to the getSelection method, this method returns the cursor position if no selection is made.
 
void setCustomAppearance (const QString &scheme=QString(), const QMap< QgsCodeEditorColorScheme::ColorRole, QColor > &customColors=QMap< QgsCodeEditorColorScheme::ColorRole, QColor >(), const QString &fontFamily=QString(), int fontSize=0)
 Sets a custom appearance for the widget, disconnecting it from using the standard appearance taken from QSettings.
 
void setFoldingVisible (bool folding)
 Set whether the folding controls are visible in the editor.
 
void setHistoryFilePath (const QString &path)
 Sets the file path to use for recording and retrieving previously executed commands.
 
void setInterpreter (QgsCodeInterpreter *newInterpreter)
 Sets an attached code interpreter for executing commands when the editor is in the QgsCodeEditor::Mode::CommandInput mode.
 
void setLinearPosition (int position)
 Convenience function to set the cursor position as a linear index.
 
void setLinearSelection (int start, int end)
 Convenience function to set the selection using linear indexes.
 
void setLineNumbersVisible (bool visible)
 Sets whether line numbers should be visible in the editor.
 
Q_DECL_DEPRECATED void setMarginVisible (bool margin)
 Set margin visible state.
 
void setTitle (const QString &title)
 Set the widget title.
 

Protected Member Functions

void initializeLexer () override
 Called when the dialect specific code lexer needs to be initialized (or reinitialized).
 
- Protected Member Functions inherited from QgsCodeEditor
void contextMenuEvent (QContextMenuEvent *event) override
 
bool eventFilter (QObject *watched, QEvent *event) override
 
void focusOutEvent (QFocusEvent *event) override
 
void keyPressEvent (QKeyEvent *event) override
 
QColor lexerColor (QgsCodeEditorColorScheme::ColorRole role) const
 Returns the color to use in the lexer for the specified role.
 
QFont lexerFont () const
 Returns the font to use in the lexer.
 
virtual void populateContextMenu (QMenu *menu)
 Called when the context menu for the widget is about to be shown, after it has been fully populated with the standard actions created by the base class.
 
virtual QString reformatCodeString (const QString &string)
 Applies code reformatting to a string and returns the result.
 
void runPostLexerConfigurationTasks ()
 Performs tasks which must be run after a lexer has been set for the widget.
 
virtual void showMessage (const QString &title, const QString &message, Qgis::MessageLevel level)
 Shows a user facing message (eg a warning message).
 
void updatePrompt ()
 Triggers an update of the interactive prompt part of the editor.
 
void updateSoftHistory ()
 Updates the soft history by storing the current editor text in the history.
 

Friends

class TestQgsQueryResultWidget
 

Additional Inherited Members

- Public Types inherited from QgsCodeEditor
enum class  Flag : int { CodeFolding = 1 << 0 , ImmediatelyUpdateHistory = 1 << 1 }
 Flags controlling behavior of code editor. More...
 
typedef QFlags< FlagFlags
 Flags controlling behavior of code editor.
 
enum class  MarginRole : int { LineNumbers = 0 , ErrorIndicators = 1 , FoldingControls = 2 }
 Margin roles. More...
 
enum class  Mode { ScriptEditor , OutputDisplay , CommandInput }
 Code editor modes. More...
 
- Public Slots inherited from QgsCodeEditor
virtual bool checkSyntax ()
 Applies syntax checking to the editor.
 
void clearPersistentHistory ()
 Clears the entire persistent history of commands run in the editor.
 
void clearSessionHistory ()
 Clears the history of commands run in the current session.
 
virtual void moveCursorToEnd ()
 Moves the cursor to the end of the document and scrolls to ensure it is visible.
 
virtual void moveCursorToStart ()
 Moves the cursor to the start of the document and scrolls to ensure it is visible.
 
void reformatCode ()
 Applies code reformatting to the editor.
 
void removeHistoryCommand (int index)
 Removes the command at the specified index from the history of the code editor.
 
void runCommand (const QString &command, bool skipHistory=false)
 Runs a command in the editor.
 
void showHistory ()
 Shows the command history dialog.
 
void showNextCommand ()
 Shows the next command from the session in the editor.
 
void showPreviousCommand ()
 Shows the previous command from the session in the editor.
 
virtual void toggleComment ()
 Toggle comment for the selected text.
 
bool writeHistoryFile ()
 Stores the commands executed in the editor to the persistent history file.
 
- Signals inherited from QgsCodeEditor
void persistentHistoryCleared ()
 Emitted when the persistent history of commands run in the editor is cleared.
 
void sessionHistoryCleared ()
 Emitted when the history of commands run in the current session is cleared.
 
- Static Public Member Functions inherited from QgsCodeEditor
static QColor color (QgsCodeEditorColorScheme::ColorRole role)
 Returns the color to use in the editor for the specified role.
 
static QColor defaultColor (QgsCodeEditorColorScheme::ColorRole role, const QString &theme=QString())
 Returns the default color for the specified role.
 
static QFont getMonospaceFont ()
 Returns the monospaced font to use for code editors.
 
static QString languageToString (Qgis::ScriptLanguage language)
 Returns a user-friendly, translated name of the specified script language.
 
static void setColor (QgsCodeEditorColorScheme::ColorRole role, const QColor &color)
 Sets the color to use in the editor for the specified role.
 
- Static Public Attributes inherited from QgsCodeEditor
static constexpr int SEARCH_RESULT_INDICATOR = QsciScintilla::INDIC_MAX - 1
 Indicator index for search results.
 
static QgsSettingsTreeNodesTreeCodeEditor = QgsSettingsTree::sTreeGui->createChildNode( QStringLiteral( "code-editor" ) )
 
- Static Protected Member Functions inherited from QgsCodeEditor
static bool isFixedPitch (const QFont &font)
 Returns true if a font is a fixed pitch font.
 

Detailed Description

A SQL editor based on QScintilla2.

Adds syntax highlighting and code autocompletion.

Note
may not be available in Python bindings, depending on platform support

Definition at line 33 of file qgscodeeditorsql.h.

Constructor & Destructor Documentation

◆ QgsCodeEditorSQL()

QgsCodeEditorSQL::QgsCodeEditorSQL ( QWidget *  parent = nullptr)

Constructor for QgsCodeEditorSQL.

Definition at line 23 of file qgscodeeditorsql.cpp.

◆ ~QgsCodeEditorSQL()

QgsCodeEditorSQL::~QgsCodeEditorSQL ( )
virtual

Definition at line 39 of file qgscodeeditorsql.cpp.

Member Function Documentation

◆ extraKeywords()

QStringList QgsCodeEditorSQL::extraKeywords ( ) const

Returns the extra keywords.

Extra keywords are usually added from provider connections and represent function and other provider specific keywords.

Since
QGIS 3.22

Definition at line 114 of file qgscodeeditorsql.cpp.

◆ fieldNames()

QStringList QgsCodeEditorSQL::fieldNames ( ) const

Returns field names from the lexer API.

Since
QGIS 3.22

Definition at line 125 of file qgscodeeditorsql.cpp.

◆ initializeLexer()

void QgsCodeEditorSQL::initializeLexer ( )
overrideprotectedvirtual

Called when the dialect specific code lexer needs to be initialized (or reinitialized).

The default implementation does nothing.

Since
QGIS 3.16

Reimplemented from QgsCodeEditor.

Definition at line 47 of file qgscodeeditorsql.cpp.

◆ language()

Qgis::ScriptLanguage QgsCodeEditorSQL::language ( ) const
overridevirtual

Returns the associated scripting language.

Since
QGIS 3.30

Reimplemented from QgsCodeEditor.

Definition at line 34 of file qgscodeeditorsql.cpp.

◆ setExtraKeywords()

void QgsCodeEditorSQL::setExtraKeywords ( const QStringList &  extraKeywords)

Set extra keywords to extraKeywords.

Extra keywords are usually added from provider connections and represent function and other provider specific keywords.

Since
QGIS 3.22

Definition at line 119 of file qgscodeeditorsql.cpp.

◆ setFieldNames()

void QgsCodeEditorSQL::setFieldNames ( const QStringList &  fieldNames)

Set field names to fieldNames to be added to the lexer API.

Since
QGIS 3.18

Definition at line 130 of file qgscodeeditorsql.cpp.

◆ setFields()

void QgsCodeEditorSQL::setFields ( const QgsFields fields)

Set field names to be added to the lexer API.

Since
QGIS 3.14

Definition at line 82 of file qgscodeeditorsql.cpp.

Friends And Related Symbol Documentation

◆ TestQgsQueryResultWidget

friend class TestQgsQueryResultWidget
friend

Definition at line 98 of file qgscodeeditorsql.h.


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