mirror of
				https://github.com/qgis/QGIS.git
				synced 2025-10-31 00:06:02 -04:00 
			
		
		
		
	
		
			
				
	
	
		
			519 lines
		
	
	
		
			12 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			519 lines
		
	
	
		
			12 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| /************************************************************************
 | |
|  * This file has been generated automatically from                      *
 | |
|  *                                                                      *
 | |
|  * src/gui/codeeditors/qgscodeeditor.h                                  *
 | |
|  *                                                                      *
 | |
|  * Do not edit manually ! Edit header and run scripts/sipify.pl again   *
 | |
|  ************************************************************************/
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| class QgsCodeInterpreter
 | |
| {
 | |
| %Docstring(signature="appended")
 | |
| An interface for code interpreters.
 | |
| 
 | |
| .. versionadded:: 3.30
 | |
| %End
 | |
| 
 | |
| %TypeHeaderCode
 | |
| #include "qgscodeeditor.h"
 | |
| %End
 | |
|   public:
 | |
| 
 | |
|     virtual ~QgsCodeInterpreter();
 | |
| 
 | |
|     int exec( const QString &command );
 | |
| %Docstring
 | |
| Executes a ``command`` in the interpreter.
 | |
| 
 | |
| Returns an interpreter specific state value.
 | |
| %End
 | |
| 
 | |
|     virtual int currentState() const;
 | |
| %Docstring
 | |
| Returns the current interpreter state.
 | |
| 
 | |
| The actual interpretation of the returned values depend on
 | |
| the interpreter subclass.
 | |
| %End
 | |
| 
 | |
|     virtual QString promptForState( int state ) const = 0;
 | |
| %Docstring
 | |
| Returns the interactive prompt string to use for the
 | |
| interpreter, given a ``state``.
 | |
| %End
 | |
| 
 | |
|   protected:
 | |
| 
 | |
|     virtual int execCommandImpl( const QString &command ) = 0;
 | |
| %Docstring
 | |
| Pure virtual method for executing commands in the interpreter.
 | |
| 
 | |
| Subclasses must implement this method. It will be called internally
 | |
| whenever the public :py:func:`~QgsCodeInterpreter.exec` method is called.
 | |
| %End
 | |
| 
 | |
| };
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| class QgsCodeEditor : QsciScintilla
 | |
| {
 | |
| %Docstring(signature="appended")
 | |
| A text editor based on QScintilla2.
 | |
| 
 | |
| .. note::
 | |
| 
 | |
|    may not be available in Python bindings, depending on platform support
 | |
| 
 | |
| .. versionadded:: 2.6
 | |
| %End
 | |
| 
 | |
| %TypeHeaderCode
 | |
| #include "qgscodeeditor.h"
 | |
| %End
 | |
|   public:
 | |
| 
 | |
|     enum class Mode
 | |
|     {
 | |
|       ScriptEditor,
 | |
|       OutputDisplay,
 | |
|       CommandInput,
 | |
|     };
 | |
| 
 | |
|     enum class MarginRole
 | |
|       {
 | |
|       LineNumbers,
 | |
|       ErrorIndicators,
 | |
|       FoldingControls,
 | |
|     };
 | |
| 
 | |
|     enum class Flag
 | |
|     {
 | |
|       CodeFolding,
 | |
|     };
 | |
| 
 | |
|     typedef QFlags<QgsCodeEditor::Flag> Flags;
 | |
| 
 | |
| 
 | |
|     QgsCodeEditor( QWidget * parent /TransferThis/ = 0, const QString & title = QString(), bool folding = false, bool margin = false, QgsCodeEditor::Flags flags = QgsCodeEditor::Flags(), QgsCodeEditor::Mode mode = QgsCodeEditor::Mode::ScriptEditor );
 | |
| %Docstring
 | |
| Construct a new code editor.
 | |
| 
 | |
| :param parent: The parent QWidget
 | |
| :param title: The title to show in the code editor dialog
 | |
| :param folding: ``False``: Enable folding for code editor (deprecated, use ``flags`` instead)
 | |
| :param margin: ``False``: Enable margin for code editor (deprecated)
 | |
| :param flags: flags controlling behavior of code editor (since QGIS 3.28)
 | |
| :param mode: code editor mode (since QGIS 3.30)
 | |
| 
 | |
| .. versionadded:: 2.6
 | |
| %End
 | |
| 
 | |
|     void setTitle( const QString & title );
 | |
| %Docstring
 | |
| Set the widget title
 | |
| 
 | |
| :param title: widget title
 | |
| %End
 | |
| 
 | |
|     virtual Qgis::ScriptLanguage language() const;
 | |
| %Docstring
 | |
| Returns the associated scripting language.
 | |
| 
 | |
| .. versionadded:: 3.30
 | |
| %End
 | |
| 
 | |
|     static QString languageToString( Qgis::ScriptLanguage language );
 | |
| %Docstring
 | |
| Returns a user-friendly, translated name of the specified script ``language``.
 | |
| 
 | |
| .. versionadded:: 3.30
 | |
| %End
 | |
| 
 | |
|  void setMarginVisible( bool margin ) /Deprecated/;
 | |
| %Docstring
 | |
| Set margin visible state
 | |
| 
 | |
| :param margin: Set margin in the editor
 | |
| 
 | |
| .. deprecated::
 | |
|    Use base class methods for individual margins instead, or :py:func:`~QgsCodeEditor.setLineNumbersVisible`
 | |
| %End
 | |
| 
 | |
|  bool marginVisible() /Deprecated/;
 | |
| %Docstring
 | |
| Returns whether margins are in a visible state
 | |
| 
 | |
| .. deprecated::
 | |
|    Use base class methods for individual margins instead, or :py:func:`~QgsCodeEditor.lineNumbersVisible`
 | |
| %End
 | |
| 
 | |
|     void setLineNumbersVisible( bool visible );
 | |
| %Docstring
 | |
| Sets whether line numbers should be visible in the editor.
 | |
| 
 | |
| Defaults to ``False``.
 | |
| 
 | |
| .. seealso:: :py:func:`lineNumbersVisible`
 | |
| 
 | |
| .. versionadded:: 3.16
 | |
| %End
 | |
| 
 | |
|     bool lineNumbersVisible() const;
 | |
| %Docstring
 | |
| Returns whether line numbers are visible in the editor.
 | |
| 
 | |
| .. seealso:: :py:func:`setLineNumbersVisible`
 | |
| 
 | |
| .. versionadded:: 3.16
 | |
| %End
 | |
| 
 | |
|     void setFoldingVisible( bool folding );
 | |
| %Docstring
 | |
| Set whether the folding controls are visible in the editor.
 | |
| 
 | |
| .. seealso:: :py:func:`foldingVisible`
 | |
| %End
 | |
| 
 | |
|     bool foldingVisible();
 | |
| %Docstring
 | |
| Returns ``True`` if the folding controls are visible in the editor.
 | |
| 
 | |
| .. seealso:: :py:func:`setFoldingVisible`
 | |
| %End
 | |
| 
 | |
|     void insertText( const QString & text );
 | |
| %Docstring
 | |
| Insert text at cursor position, or replace any selected text if user has
 | |
| made a selection.
 | |
| 
 | |
| :param text: The text to be inserted
 | |
| %End
 | |
| 
 | |
|     static QColor defaultColor( QgsCodeEditorColorScheme::ColorRole role, const QString & theme = QString() );
 | |
| %Docstring
 | |
| Returns the default color for the specified ``role``.
 | |
| 
 | |
| The optional ``theme`` argument can be used to specify a color ``theme``. A blank
 | |
| ``theme`` indicates the default color scheme.
 | |
| 
 | |
| Available themes are stored in :py:class:`QgsCodeEditorColorSchemeRegistry`, and can be retrieved
 | |
| via :py:func:`QgsGui.codeEditorColorSchemeRegistry()`.
 | |
| 
 | |
| .. versionadded:: 3.16
 | |
| %End
 | |
| 
 | |
|     static QColor color( QgsCodeEditorColorScheme::ColorRole role );
 | |
| %Docstring
 | |
| Returns the color to use in the editor for the specified ``role``.
 | |
| 
 | |
| This color will be the default theme color for the role, unless the user has manually
 | |
| selected a custom color scheme for the editor.
 | |
| 
 | |
| .. seealso:: :py:func:`setColor`
 | |
| 
 | |
| .. versionadded:: 3.16
 | |
| %End
 | |
| 
 | |
|     static void setColor( QgsCodeEditorColorScheme::ColorRole role, const QColor & color );
 | |
| %Docstring
 | |
| Sets the ``color`` to use in the editor for the specified ``role``.
 | |
| 
 | |
| This color will be stored as the new default color for the role, to be used for all code editors.
 | |
| 
 | |
| Set ``color`` to an invalid QColor in order to clear the stored color value and reset it to
 | |
| the default color.
 | |
| 
 | |
| .. seealso:: :py:func:`color`
 | |
| 
 | |
| .. versionadded:: 3.16
 | |
| %End
 | |
| 
 | |
|     static QFont getMonospaceFont();
 | |
| %Docstring
 | |
| Returns the monospaced font to use for code editors.
 | |
| 
 | |
| .. versionadded:: 3.16
 | |
| %End
 | |
| 
 | |
| 
 | |
|     void addWarning( int lineNumber, const QString & warning );
 | |
| %Docstring
 | |
| Adds a ``warning`` message and indicator to the specified a ``lineNumber``.
 | |
| 
 | |
| .. seealso:: :py:func:`clearWarnings`
 | |
| 
 | |
| .. versionadded:: 3.16
 | |
| %End
 | |
| 
 | |
|     void clearWarnings();
 | |
| %Docstring
 | |
| Clears all warning messages from the editor.
 | |
| 
 | |
| .. seealso:: :py:func:`addWarning`
 | |
| 
 | |
| .. versionadded:: 3.16
 | |
| %End
 | |
| 
 | |
|     QgsCodeEditor::Mode mode() const;
 | |
| %Docstring
 | |
| Returns the code editor mode.
 | |
| 
 | |
| .. versionadded:: 3.30
 | |
| %End
 | |
| 
 | |
|     bool isCursorOnLastLine() const;
 | |
| %Docstring
 | |
| Returns ``True`` if the cursor is on the last line of the document.
 | |
| 
 | |
| .. versionadded:: 3.28
 | |
| %End
 | |
| 
 | |
|     void setHistoryFilePath( const QString &path );
 | |
| %Docstring
 | |
| Sets the file path to use for recording and retrieving previously
 | |
| executed commands.
 | |
| 
 | |
| .. note::
 | |
| 
 | |
|    Applies to code editors in the QgsCodeEditor.Mode.CommandInput mode only.
 | |
| 
 | |
| .. versionadded:: 3.30
 | |
| %End
 | |
| 
 | |
|     QStringList history() const;
 | |
| %Docstring
 | |
| Returns the list of commands previously executed in the editor.
 | |
| 
 | |
| .. note::
 | |
| 
 | |
|    Applies to code editors in the QgsCodeEditor.Mode.CommandInput mode only.
 | |
| 
 | |
| .. versionadded:: 3.30
 | |
| %End
 | |
| 
 | |
|     QgsCodeInterpreter *interpreter() const;
 | |
| %Docstring
 | |
| Returns the attached code interpreter, or ``None`` if not set.
 | |
| 
 | |
| .. seealso:: :py:func:`setInterpreter`
 | |
| 
 | |
| .. versionadded:: 3.30
 | |
| %End
 | |
| 
 | |
|     void setInterpreter( QgsCodeInterpreter *newInterpreter );
 | |
| %Docstring
 | |
| Sets an attached code interpreter for executing commands when the editor
 | |
| is in the QgsCodeEditor.Mode.CommandInput mode.
 | |
| 
 | |
| .. seealso:: :py:func:`interpreter`
 | |
| 
 | |
| .. versionadded:: 3.30
 | |
| %End
 | |
| 
 | |
|   public slots:
 | |
| 
 | |
|     void runCommand( const QString &command );
 | |
| %Docstring
 | |
| Runs a command in the editor.
 | |
| 
 | |
| An :py:func:`~QgsCodeEditor.interpreter` must be set.
 | |
| 
 | |
| .. versionadded:: 3.30
 | |
| %End
 | |
| 
 | |
|     virtual void moveCursorToStart();
 | |
| %Docstring
 | |
| Moves the cursor to the start of the document and scrolls to ensure
 | |
| it is visible.
 | |
| 
 | |
| .. versionadded:: 3.28
 | |
| %End
 | |
| 
 | |
|     virtual void moveCursorToEnd();
 | |
| %Docstring
 | |
| Moves the cursor to the end of the document and scrolls to ensure
 | |
| it is visible.
 | |
| 
 | |
| .. versionadded:: 3.28
 | |
| %End
 | |
| 
 | |
|     void showPreviousCommand();
 | |
| %Docstring
 | |
| Shows the previous command from the session in the editor.
 | |
| 
 | |
| .. note::
 | |
| 
 | |
|    Applies to code editors in the QgsCodeEditor.Mode.CommandInput mode only.
 | |
| 
 | |
| .. versionadded:: 3.30
 | |
| %End
 | |
| 
 | |
|     void showNextCommand();
 | |
| %Docstring
 | |
| Shows the next command from the session in the editor.
 | |
| 
 | |
| .. note::
 | |
| 
 | |
|    Applies to code editors in the QgsCodeEditor.Mode.CommandInput mode only.
 | |
| 
 | |
| .. versionadded:: 3.30
 | |
| %End
 | |
| 
 | |
|     void showHistory();
 | |
| %Docstring
 | |
| Shows the command history dialog.
 | |
| 
 | |
| .. note::
 | |
| 
 | |
|    Applies to code editors in the QgsCodeEditor.Mode.CommandInput mode only.
 | |
| 
 | |
| .. versionadded:: 3.30
 | |
| %End
 | |
| 
 | |
|     void removeHistoryCommand( int index );
 | |
| %Docstring
 | |
| Removes the command at the specified ``index`` from the history of the code editor.
 | |
| 
 | |
| .. versionadded:: 3.30
 | |
| %End
 | |
| 
 | |
|     void clearSessionHistory();
 | |
| %Docstring
 | |
| Clears the history of commands run in the current session.
 | |
| 
 | |
| .. note::
 | |
| 
 | |
|    Applies to code editors in the QgsCodeEditor.Mode.CommandInput mode only.
 | |
| 
 | |
| .. versionadded:: 3.30
 | |
| %End
 | |
| 
 | |
|     void clearPersistentHistory();
 | |
| %Docstring
 | |
| Clears the entire persistent history of commands run in the editor.
 | |
| 
 | |
| .. note::
 | |
| 
 | |
|    Applies to code editors in the QgsCodeEditor.Mode.CommandInput mode only.
 | |
| 
 | |
| .. versionadded:: 3.30
 | |
| %End
 | |
| 
 | |
|     bool writeHistoryFile();
 | |
| %Docstring
 | |
| Stores the commands executed in the editor to the persistent history file.
 | |
| 
 | |
| .. versionadded:: 3.30
 | |
| %End
 | |
| 
 | |
|   signals:
 | |
| 
 | |
|     void sessionHistoryCleared();
 | |
| %Docstring
 | |
| Emitted when the history of commands run in the current session is cleared.
 | |
| 
 | |
| .. versionadded:: 3.30
 | |
| %End
 | |
| 
 | |
|     void persistentHistoryCleared();
 | |
| %Docstring
 | |
| Emitted when the persistent history of commands run in the editor is cleared.
 | |
| 
 | |
| .. versionadded:: 3.30
 | |
| %End
 | |
| 
 | |
|   protected:
 | |
| 
 | |
|     static bool isFixedPitch( const QFont &font );
 | |
| %Docstring
 | |
| Returns ``True`` if a ``font`` is a fixed pitch font.
 | |
| %End
 | |
| 
 | |
|     virtual void focusOutEvent( QFocusEvent *event );
 | |
| 
 | |
|     virtual void keyPressEvent( QKeyEvent *event );
 | |
| 
 | |
|     virtual void contextMenuEvent( QContextMenuEvent *event );
 | |
| 
 | |
| 
 | |
|     virtual void initializeLexer();
 | |
| %Docstring
 | |
| Called when the dialect specific code lexer needs to be initialized (or reinitialized).
 | |
| 
 | |
| The default implementation does nothing.
 | |
| 
 | |
| .. versionadded:: 3.16
 | |
| %End
 | |
| 
 | |
|     QColor lexerColor( QgsCodeEditorColorScheme::ColorRole role ) const;
 | |
| %Docstring
 | |
| Returns the color to use in the lexer for the specified ``role``.
 | |
| 
 | |
| .. versionadded:: 3.16
 | |
| %End
 | |
| 
 | |
|     QFont lexerFont() const;
 | |
| %Docstring
 | |
| Returns the font to use in the lexer.
 | |
| 
 | |
| .. versionadded:: 3.16
 | |
| %End
 | |
| 
 | |
|     void runPostLexerConfigurationTasks();
 | |
| %Docstring
 | |
| Performs tasks which must be run after a lexer has been set for the widget.
 | |
| 
 | |
| .. versionadded:: 3.16
 | |
| %End
 | |
| 
 | |
|     void updateSoftHistory();
 | |
| %Docstring
 | |
| Updates the soft history by storing the current editor text in the history.
 | |
| 
 | |
| .. versionadded:: 3.30
 | |
| %End
 | |
| 
 | |
|     void updatePrompt();
 | |
| %Docstring
 | |
| Triggers an update of the interactive prompt part of the editor.
 | |
| 
 | |
| .. note::
 | |
| 
 | |
|    Applies to code editors in the QgsCodeEditor.Mode.CommandInput mode only.
 | |
| 
 | |
| .. versionadded:: 3.30
 | |
| %End
 | |
| 
 | |
|     virtual void populateContextMenu( QMenu *menu );
 | |
| %Docstring
 | |
| 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.
 | |
| 
 | |
| This method provides an opportunity for subclasses to add additional non-standard
 | |
| actions to the context menu.
 | |
| 
 | |
| .. versionadded:: 3.30
 | |
| %End
 | |
| 
 | |
| };
 | |
| 
 | |
| QFlags<QgsCodeEditor::Flag> operator|(QgsCodeEditor::Flag f1, QFlags<QgsCodeEditor::Flag> f2);
 | |
| 
 | |
| 
 | |
| 
 | |
| /************************************************************************
 | |
|  * This file has been generated automatically from                      *
 | |
|  *                                                                      *
 | |
|  * src/gui/codeeditors/qgscodeeditor.h                                  *
 | |
|  *                                                                      *
 | |
|  * Do not edit manually ! Edit header and run scripts/sipify.pl again   *
 | |
|  ************************************************************************/
 |