QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 
24 
25 class QWidget;
26 
32 class GUI_EXPORT QgsCodeEditor : public QsciScintilla
33 {
34  Q_OBJECT
35 
36  public:
46  QgsCodeEditor( QWidget *parent = nullptr, const QString& title = "", bool folding = false, bool margin = false );
47  ~QgsCodeEditor();
48 
52  void setTitle( const QString& title );
53 
57  void setMarginVisible( bool margin );
58  bool marginVisible() { return mMargin; }
59 
63  void setFoldingVisible( bool folding );
64  bool foldingVisible() { return mFolding; }
65 
70  void insertText( const QString& theText );
71 
72  protected:
73 
74  bool isFixedPitch( const QFont& font );
75 
76  void focusOutEvent( QFocusEvent *event ) override;
77  void keyPressEvent( QKeyEvent * event ) override;
78 
79  QFont getMonospaceFont();
80 
81  private:
82 
83  void setSciWidget();
84 
85  QString mWidgetTitle;
86  bool mFolding;
87  bool mMargin;
88 };
89 
90 #endif
A text editor based on QScintilla2.
Definition: qgscodeeditor.h:32
bool marginVisible()
Definition: qgscodeeditor.h:58
bool foldingVisible()
Definition: qgscodeeditor.h:64