QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgscodeeditor.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscodeeditor.h - A base code editor for QGIS and plugins. Provides
3  a base editor using QScintilla for editors
4  --------------------------------------
5  Date : 06-Oct-2013
6  Copyright : (C) 2013 by Salvatore Larosa
7  Email : lrssvtml (at) gmail (dot) com
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #ifndef QGSCODEEDITOR_H
18 #define QGSCODEEDITOR_H
19 
20 #include <QString>
21 // qscintilla includes
22 #include <Qsci/qsciapis.h>
23 #include "qgis_sip.h"
24 #include "qgis_gui.h"
25 
26 
27 SIP_IF_MODULE( HAVE_QSCI_SIP )
28 
29 
30 class QWidget;
31 
38 class GUI_EXPORT QgsCodeEditor : public QsciScintilla
39 {
40  Q_OBJECT
41 
42  public:
43 
53  QgsCodeEditor( QWidget *parent SIP_TRANSFERTHIS = nullptr, const QString &title = QString(), bool folding = false, bool margin = false );
54 
59  void setTitle( const QString &title );
60 
65  void setMarginVisible( bool margin );
66  bool marginVisible() { return mMargin; }
67 
72  void setFoldingVisible( bool folding );
73  bool foldingVisible() { return mFolding; }
74 
80  void insertText( const QString &text );
81 
82  protected:
83 
84  bool isFixedPitch( const QFont &font );
85 
86  void focusOutEvent( QFocusEvent *event ) override;
87  void keyPressEvent( QKeyEvent *event ) override;
88 
89  QFont getMonospaceFont();
90 
91  private:
92 
93  void setSciWidget();
94 
95  QString mWidgetTitle;
96  bool mFolding;
97  bool mMargin;
98 };
99 
100 // clazy:excludeall=qstring-allocations
101 
102 #endif
QgsCodeEditor
Definition: qgscodeeditor.h:38
QgsCodeEditor::foldingVisible
bool foldingVisible()
Definition: qgscodeeditor.h:73
qgis_sip.h
SIP_IF_MODULE
#define SIP_IF_MODULE(condition)
Definition: qgis_sip.h:28
QgsCodeEditor::marginVisible
bool marginVisible()
Definition: qgscodeeditor.h:66
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53