QGIS API Documentation 3.39.0-Master (47f7b3a4989)
Loading...
Searching...
No Matches
Public Slots | Signals | Public Member Functions | List of all members
QgsCodeEditorWidget Class Reference

A widget which wraps a QgsCodeEditor in additional functionality. More...

#include <qgscodeeditorwidget.h>

Inheritance diagram for QgsCodeEditorWidget:
Inheritance graph
[legend]

Public Slots

void hideSearchBar ()
 Hides the search bar.
 
bool loadFile (const QString &path)
 Loads the file at the specified path into the widget, replacing the code editor's content with that from the file.
 
bool openInExternalEditor (int line=-1, int column=-1)
 Attempts to opens the script from the editor in an external text editor.
 
void setFilePath (const QString &path)
 Sets the widget's associated file path.
 
void setReplaceBarVisible (bool visible)
 Sets whether the replace bar is visible.
 
void setSearchBarVisible (bool visible)
 Sets whether the search bar is visible.
 
bool shareOnGist (bool isPublic)
 Shares the contents of the code editor on GitHub Gist.
 
void showSearchBar ()
 Shows the search bar.
 
void triggerFind ()
 Triggers a find operation, using the default behavior.
 
- Public Slots inherited from QgsPanelWidget
void acceptPanel ()
 Accept the panel.
 
void openPanel (QgsPanelWidget *panel)
 Open a panel or dialog depending on dock mode setting If dock mode is true this method will emit the showPanel signal for connected slots to handle the open event.
 

Signals

void filePathChanged (const QString &path)
 Emitted when the widget's associated file path is changed.
 
void loadedExternalChanges ()
 Emitted when the widget loads in text from the associated file to bring in changes made externally to the file.
 
void searchBarToggled (bool visible)
 Emitted when the visibility of the search bar is changed.
 
- Signals inherited from QgsPanelWidget
void panelAccepted (QgsPanelWidget *panel)
 Emitted when the panel is accepted by the user.
 
void showPanel (QgsPanelWidget *panel)
 Emit when you require a panel to be show in the interface.
 
void widgetChanged ()
 Emitted when the widget state changes.
 

Public Member Functions

 QgsCodeEditorWidget (QgsCodeEditor *editor, QgsMessageBar *messageBar=nullptr, QWidget *parent=nullptr)
 Constructor for QgsCodeEditorWidget, wrapping the specified editor widget.
 
 ~QgsCodeEditorWidget () override
 
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.
 
QgsCodeEditoreditor ()
 Returns the wrapped code editor.
 
bool eventFilter (QObject *obj, QEvent *event) override
 
QString filePath () const
 Returns the widget's associated file path.
 
bool isSearchBarVisible () const
 Returns true if the search bar is visible.
 
QgsMessageBarmessageBar ()
 Returns the message bar associated with the widget, to use for user feedback.
 
void resizeEvent (QResizeEvent *event) override
 
QgsScrollBarHighlightControllerscrollbarHighlightController ()
 Returns the scrollbar highlight controller, which can be used to add highlights in the code editor scrollbar.
 
void showEvent (QShowEvent *event) override
 
- Public Member Functions inherited from QgsPanelWidget
 QgsPanelWidget (QWidget *parent=nullptr)
 Base class for any widget that can be shown as a inline panel.
 
virtual bool applySizeConstraintsToStack () const
 Returns true if the size constraints and hints for the panel widget should be applied to the parent QgsPanelWidgetStack which this panel is shown in.
 
bool autoDelete ()
 The the auto delete property on the widget.
 
void connectChildPanel (QgsPanelWidget *panel)
 Connect the given sub panel widgets showPanel signals to this current panels main showPanel event to bubble up to the user.
 
void connectChildPanels (const QList< QgsPanelWidget * > &panels)
 Connect the given sub panel widgets showPanel signals to this current panels main showPanel event to bubble up to the user.
 
bool dockMode ()
 Returns the dock mode state.
 
virtual QMenu * menuButtonMenu ()
 Returns the menu to use for the menu button for this panel, or nullptr if no menu button is required.
 
virtual QString menuButtonTooltip () const
 Returns the (translated) tooltip text to use for the menu button for this panel.
 
QString panelTitle ()
 The title of the panel.
 
void setAutoDelete (bool autoDelete)
 The the auto delete property on the widget.
 
virtual void setDockMode (bool dockMode)
 Set the widget in dock mode which tells the widget to emit panel widgets and not open dialogs.
 
void setPanelTitle (const QString &panelTitle)
 Set the title of the panel when shown in the interface.
 

Additional Inherited Members

- Static Public Member Functions inherited from QgsPanelWidget
static QgsPanelWidgetfindParentPanel (QWidget *widget)
 Traces through the parents of a widget to find if it is contained within a QgsPanelWidget widget.
 
- Protected Member Functions inherited from QgsPanelWidget
void keyPressEvent (QKeyEvent *event) override
 Overridden key press event to handle the esc event on the widget.
 

Detailed Description

A widget which wraps a QgsCodeEditor in additional functionality.

This widget wraps an existing QgsCodeEditor object in a widget which provides additional standard functionality, such as search/replace tools. The caller must create an unparented QgsCodeEditor object (or a subclass of QgsCodeEditor) first, and then construct a QgsCodeEditorWidget passing this object to the constructor.

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

Definition at line 48 of file qgscodeeditorwidget.h.

Constructor & Destructor Documentation

◆ QgsCodeEditorWidget()

QgsCodeEditorWidget::QgsCodeEditorWidget ( QgsCodeEditor editor,
QgsMessageBar messageBar = nullptr,
QWidget *  parent = nullptr 
)

Constructor for QgsCodeEditorWidget, wrapping the specified editor widget.

Ownership of editor will be transferred to this widget.

If an explicit messageBar is specified then it will be used to provide feedback, otherwise an integrated message bar will be used.

Definition at line 41 of file qgscodeeditorwidget.cpp.

◆ ~QgsCodeEditorWidget()

QgsCodeEditorWidget::~QgsCodeEditorWidget ( )
overridedefault

Member Function Documentation

◆ addWarning()

void QgsCodeEditorWidget::addWarning ( int  lineNumber,
const QString &  warning 
)

Adds a warning message and indicator to the specified a lineNumber.

This method calls QgsCodeEditor::addWarning(), but also automatically adds highlights to the widget scrollbars locating the warning location.

See also
clearWarnings()

Definition at line 316 of file qgscodeeditorwidget.cpp.

◆ clearWarnings()

void QgsCodeEditorWidget::clearWarnings ( )

Clears all warning messages from the editor.

This method calls QgsCodeEditor::clearWarnings(), but also removes highlights from the widget scrollbars at the warning locations.

See also
addWarning()

Definition at line 330 of file qgscodeeditorwidget.cpp.

◆ editor()

QgsCodeEditor * QgsCodeEditorWidget::editor ( )
inline

Returns the wrapped code editor.

Definition at line 74 of file qgscodeeditorwidget.h.

◆ eventFilter()

bool QgsCodeEditorWidget::eventFilter ( QObject *  obj,
QEvent *  event 
)
override

Definition at line 254 of file qgscodeeditorwidget.cpp.

◆ filePath()

QString QgsCodeEditorWidget::filePath ( ) const
inline

Returns the widget's associated file path.

See also
setFilePath()
filePathChanged()

Definition at line 118 of file qgscodeeditorwidget.h.

◆ filePathChanged

void QgsCodeEditorWidget::filePathChanged ( const QString &  path)
signal

Emitted when the widget's associated file path is changed.

See also
setFilePath()
filePath()

◆ hideSearchBar

void QgsCodeEditorWidget::hideSearchBar ( )
slot

Hides the search bar.

See also
showSearchBar()
setSearchBarVisible()

Definition at line 352 of file qgscodeeditorwidget.cpp.

◆ isSearchBarVisible()

bool QgsCodeEditorWidget::isSearchBarVisible ( ) const

Returns true if the search bar is visible.

Definition at line 301 of file qgscodeeditorwidget.cpp.

◆ loadedExternalChanges

void QgsCodeEditorWidget::loadedExternalChanges ( )
signal

Emitted when the widget loads in text from the associated file to bring in changes made externally to the file.

◆ loadFile

bool QgsCodeEditorWidget::loadFile ( const QString &  path)
slot

Loads the file at the specified path into the widget, replacing the code editor's content with that from the file.

This automatically sets the widget's filePath()

Returns true if the file was loaded successfully.

Definition at line 399 of file qgscodeeditorwidget.cpp.

◆ messageBar()

QgsMessageBar * QgsCodeEditorWidget::messageBar ( )

Returns the message bar associated with the widget, to use for user feedback.

Definition at line 306 of file qgscodeeditorwidget.cpp.

◆ openInExternalEditor

bool QgsCodeEditorWidget::openInExternalEditor ( int  line = -1,
int  column = -1 
)
slot

Attempts to opens the script from the editor in an external text editor.

This requires that the widget has an associated filePath() set.

Optionally a target line and column number can be specified to open the editor at the corresponding location. (Not all external editors support this.) Line/column numbers of -1 indicate that the current cursor position should be used. A line number of 0 corresponds to the first line, and a column number of 0 corresponds to the first column.

Returns
true if the file was opened successfully.

Definition at line 427 of file qgscodeeditorwidget.cpp.

◆ resizeEvent()

void QgsCodeEditorWidget::resizeEvent ( QResizeEvent *  event)
override

Definition at line 242 of file qgscodeeditorwidget.cpp.

◆ scrollbarHighlightController()

QgsScrollBarHighlightController * QgsCodeEditorWidget::scrollbarHighlightController ( )

Returns the scrollbar highlight controller, which can be used to add highlights in the code editor scrollbar.

Definition at line 311 of file qgscodeeditorwidget.cpp.

◆ searchBarToggled

void QgsCodeEditorWidget::searchBarToggled ( bool  visible)
signal

Emitted when the visibility of the search bar is changed.

◆ setFilePath

void QgsCodeEditorWidget::setFilePath ( const QString &  path)
slot

Sets the widget's associated file path.

See also
loadFile()
filePathChanged()
filePath()

Definition at line 418 of file qgscodeeditorwidget.cpp.

◆ setReplaceBarVisible

void QgsCodeEditorWidget::setReplaceBarVisible ( bool  visible)
slot

Sets whether the replace bar is visible.

See also
setSearchBarVisible()

Definition at line 367 of file qgscodeeditorwidget.cpp.

◆ setSearchBarVisible

void QgsCodeEditorWidget::setSearchBarVisible ( bool  visible)
slot

Sets whether the search bar is visible.

See also
showSearchBar()
hideSearchBar()
setReplaceBarVisible()

Definition at line 359 of file qgscodeeditorwidget.cpp.

◆ shareOnGist

bool QgsCodeEditorWidget::shareOnGist ( bool  isPublic)
slot

Shares the contents of the code editor on GitHub Gist.

Requires that the user has configured an API token with appropriate permission in advance.

Returns
false if the user has not configured a GitHub personal access token.

Definition at line 500 of file qgscodeeditorwidget.cpp.

◆ showEvent()

void QgsCodeEditorWidget::showEvent ( QShowEvent *  event)
override

Definition at line 248 of file qgscodeeditorwidget.cpp.

◆ showSearchBar

void QgsCodeEditorWidget::showSearchBar ( )
slot

Shows the search bar.

See also
hideSearchBar()
setSearchBarVisible()

Definition at line 339 of file qgscodeeditorwidget.cpp.

◆ triggerFind

void QgsCodeEditorWidget::triggerFind ( )
slot

Triggers a find operation, using the default behavior.

This will automatically open the search bar and start a find operation using the default behavior, e.g. searching for any selected text in the code editor.

Definition at line 385 of file qgscodeeditorwidget.cpp.


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