QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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.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
A text editor based on QScintilla2.
Definition: qgscodeeditor.h:38
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
#define SIP_IF_MODULE(condition)
Definition: qgis_sip.h:28
bool marginVisible()
Definition: qgscodeeditor.h:66
bool foldingVisible()
Definition: qgscodeeditor.h:73