QGIS API Documentation 3.41.0-Master (3440c17df1d)
|
A widget which wraps a QgsCodeEditor in additional functionality. More...
#include <qgscodeeditorwidget.h>
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. | |
QgsCodeEditor * | editor () |
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. | |
QgsMessageBar * | messageBar () |
Returns the message bar associated with the widget, to use for user feedback. | |
void | resizeEvent (QResizeEvent *event) override |
bool | save (const QString &path=QString()) |
Saves the code editor content into the file path. | |
QgsScrollBarHighlightController * | scrollbarHighlightController () |
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 QgsPanelWidget * | findParentPanel (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. | |
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.
Definition at line 48 of file qgscodeeditorwidget.h.
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 42 of file qgscodeeditorwidget.cpp.
|
overridedefault |
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.
Definition at line 328 of file qgscodeeditorwidget.cpp.
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.
Definition at line 342 of file qgscodeeditorwidget.cpp.
|
inline |
Returns the wrapped code editor.
Definition at line 74 of file qgscodeeditorwidget.h.
|
override |
Definition at line 255 of file qgscodeeditorwidget.cpp.
|
inline |
Returns the widget's associated file path.
Definition at line 118 of file qgscodeeditorwidget.h.
|
signal |
Emitted when the widget's associated file path is changed.
|
slot |
Hides the search bar.
Definition at line 364 of file qgscodeeditorwidget.cpp.
bool QgsCodeEditorWidget::isSearchBarVisible | ( | ) | const |
Returns true
if the search bar is visible.
Definition at line 313 of file qgscodeeditorwidget.cpp.
|
signal |
Emitted when the widget loads in text from the associated file to bring in changes made externally to the file.
|
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 411 of file qgscodeeditorwidget.cpp.
QgsMessageBar * QgsCodeEditorWidget::messageBar | ( | ) |
Returns the message bar associated with the widget, to use for user feedback.
Definition at line 318 of file qgscodeeditorwidget.cpp.
|
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.
true
if the file was opened successfully. Definition at line 462 of file qgscodeeditorwidget.cpp.
|
override |
Definition at line 243 of file qgscodeeditorwidget.cpp.
bool QgsCodeEditorWidget::save | ( | const QString & | path = QString() | ) |
Saves the code editor content into the file path.
false
if the file path has not previously been set, or if writing the file fails. Definition at line 441 of file qgscodeeditorwidget.cpp.
QgsScrollBarHighlightController * QgsCodeEditorWidget::scrollbarHighlightController | ( | ) |
Returns the scrollbar highlight controller, which can be used to add highlights in the code editor scrollbar.
Definition at line 323 of file qgscodeeditorwidget.cpp.
|
signal |
Emitted when the visibility of the search bar is changed.
|
slot |
Sets the widget's associated file path.
Definition at line 430 of file qgscodeeditorwidget.cpp.
|
slot |
Sets whether the replace bar is visible.
Definition at line 379 of file qgscodeeditorwidget.cpp.
|
slot |
Sets whether the search bar is visible.
Definition at line 371 of file qgscodeeditorwidget.cpp.
|
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.
false
if the user has not configured a GitHub personal access token. Definition at line 535 of file qgscodeeditorwidget.cpp.
|
override |
Definition at line 249 of file qgscodeeditorwidget.cpp.
|
slot |
Shows the search bar.
Definition at line 351 of file qgscodeeditorwidget.cpp.
|
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 397 of file qgscodeeditorwidget.cpp.