QGIS API Documentation 3.39.0-Master (47f7b3a4989)
Loading...
Searching...
No Matches
qgscodeeditorwidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgscodeeditorwidget.h
3 --------------------------------------
4 Date : May 2024
5 Copyright : (C) 2024 by Nyall Dawson
6 Email : nyall dot dawson 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 QGSCODEEDITORWIDGET_H
17#define QGSCODEEDITORWIDGET_H
18
19#include "qgis_gui.h"
20#include "qgis_sip.h"
21#include "qgspanelwidget.h"
22
23#include <QDateTime>
24
25class QgsCodeEditor;
27class QToolButton;
28class QCheckBox;
29class QgsMessageBar;
31
32SIP_IF_MODULE( HAVE_QSCI_SIP )
33
34
48class GUI_EXPORT QgsCodeEditorWidget : public QgsPanelWidget
49{
50 Q_OBJECT
51
52 public:
53
63 QgsMessageBar *messageBar = nullptr,
64 QWidget *parent SIP_TRANSFERTHIS = nullptr );
66
67 void resizeEvent( QResizeEvent *event ) override;
68 void showEvent( QShowEvent *event ) override;
69 bool eventFilter( QObject *obj, QEvent *event ) override;
70
74 QgsCodeEditor *editor() { return mEditor; }
75
79 bool isSearchBarVisible() const;
80
84 QgsMessageBar *messageBar();
85
90 QgsScrollBarHighlightController *scrollbarHighlightController();
91
100 void addWarning( int lineNumber, const QString &warning );
101
110 void clearWarnings();
111
118 QString filePath() const { return mFilePath; }
119
120 public slots:
121
128 void showSearchBar();
129
136 void hideSearchBar();
137
145 void setSearchBarVisible( bool visible );
146
152 void setReplaceBarVisible( bool visible );
153
160 void triggerFind();
161
170 bool loadFile( const QString &path );
171
179 void setFilePath( const QString &path );
180
194 bool openInExternalEditor( int line = -1, int column = -1 );
195
203 bool shareOnGist( bool isPublic );
204
205 signals:
206
210 void searchBarToggled( bool visible );
211
218 void filePathChanged( const QString &path );
219
225
226 private slots:
227
228 bool findNext();
229 void findPrevious();
230 void textSearchChanged( const QString &text );
231 void updateSearch();
232 void replace();
233 void replaceSelection();
234 void replaceAll();
235
236 private:
237
238 void clearSearchHighlights();
239 void addSearchHighlights();
240 int searchFlags() const;
241 bool findText( bool forward, bool findFirst );
242 void updateHighlightController();
243 void searchMatchCountChanged( int matchCount );
244
245 enum HighlightCategory
246 {
247 SearchMatch = 0,
248 Warning = 1
249 };
250
251 QgsCodeEditor *mEditor = nullptr;
252 QWidget *mFindWidget = nullptr;
253 QgsFilterLineEdit *mLineEditFind = nullptr;
254 QgsFilterLineEdit *mLineEditReplace = nullptr;
255 QToolButton *mFindPrevButton = nullptr;
256 QToolButton *mFindNextButton = nullptr;
257 QToolButton *mCaseSensitiveButton = nullptr;
258 QToolButton *mWholeWordButton = nullptr;
259 QToolButton *mRegexButton = nullptr;
260 QToolButton *mWrapAroundButton = nullptr;
261 QToolButton *mShowReplaceBarButton = nullptr;
262 QToolButton *mReplaceButton = nullptr;
263 QToolButton *mReplaceAllButton = nullptr;
264 int mBlockSearching = 0;
265 QgsMessageBar *mMessageBar = nullptr;
266 std::unique_ptr< QgsScrollBarHighlightController > mHighlightController;
267 QString mFilePath;
268 QDateTime mLastModified;
269};
270
271#endif // QGSCODEEDITORWIDGET_H
A widget which wraps a QgsCodeEditor in additional functionality.
void loadedExternalChanges()
Emitted when the widget loads in text from the associated file to bring in changes made externally to...
void searchBarToggled(bool visible)
Emitted when the visibility of the search bar is changed.
void filePathChanged(const QString &path)
Emitted when the widget's associated file path is changed.
QgsCodeEditor * editor()
Returns the wrapped code editor.
QString filePath() const
Returns the widget's associated file path.
~QgsCodeEditorWidget() override
A text editor based on QScintilla2.
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
A bar for displaying non-blocking messages to the user.
Base class for any widget that can be shown as a inline panel.
Adds highlights (colored markers) to a scrollbar.
#define SIP_IF_MODULE(condition)
Definition qgis_sip.h:28
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_TRANSFER
Definition qgis_sip.h:36