QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
qgscodeeditorpython.h
Go to the documentation of this file.
1/***************************************************************************
2 qgscodeeditorpython.h - A Python editor based on QScintilla
3 --------------------------------------
4 Date : 06-Oct-2013
5 Copyright : (C) 2013 by Salvatore Larosa
6 Email : lrssvtml (at) gmail (dot) com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSCODEEDITORPYTHON_H
17#define QGSCODEEDITORPYTHON_H
18
19#include "qgscodeeditor.h"
20#include "qgis_sip.h"
21#include "qgis_gui.h"
22#include <Qsci/qscilexerpython.h>
23
24SIP_IF_MODULE( HAVE_QSCI_SIP )
25
26#ifndef SIP_RUN
28class QgsQsciLexerPython : public QsciLexerPython
29{
30 Q_OBJECT
31 public:
32
33 QgsQsciLexerPython( QObject *parent = nullptr );
34
35 const char *keywords( int set ) const override;
36
37};
39#endif
40
48class GUI_EXPORT QgsCodeEditorPython : public QgsCodeEditor
49{
50 Q_OBJECT
51
52 public:
53
62 QgsCodeEditorPython( QWidget *parent SIP_TRANSFERTHIS = nullptr, const QList<QString> &filenames = QList<QString>(),
64
65 Qgis::ScriptLanguage language() const override;
66
71 void loadAPIs( const QList<QString> &filenames );
72
76 bool loadScript( const QString &script );
77
83 bool isCursorInsideStringLiteralOrComment() const;
84
90 QString characterBeforeCursor() const;
91
97 QString characterAfterCursor() const;
98
99 public slots:
100
106 void searchSelectedTextInPyQGISDocs();
107
113 void toggleComment();
114
115 protected:
116
117 void initializeLexer() override;
118
119 virtual void keyPressEvent( QKeyEvent *event ) override;
120
121 protected slots:
122
128 void autoComplete();
129
130 private:
131
132 QList<QString> mAPISFilesList;
133 QString mPapFile;
134
135 static const QMap<QString, QString> sCompletionPairs;
136
137 // Only used for selected text
138 static const QStringList sCompletionSingleCharacters;
139
140};
141
142#endif
ScriptLanguage
Scripting languages.
Definition: qgis.h:2715
A Python editor based on QScintilla2.
A text editor based on QScintilla2.
Definition: qgscodeeditor.h:93
Mode
Code editor modes.
@ ScriptEditor
Standard mode, allows for display and edit of entire scripts.
void keyPressEvent(QKeyEvent *event) override
virtual void initializeLexer()
Called when the dialect specific code lexer needs to be initialized (or reinitialized).
virtual Qgis::ScriptLanguage language() const
Returns the associated scripting language.
#define SIP_IF_MODULE(condition)
Definition: qgis_sip.h:28
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53