QGIS API Documentation 3.38.0-Grenoble (exported)
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
196 signals:
197
201 void searchBarToggled( bool visible );
202
209 void filePathChanged( const QString &path );
210
216
217 private slots:
218
219 bool findNext();
220 void findPrevious();
221 void textSearchChanged( const QString &text );
222 void updateSearch();
223 void replace();
224 void replaceSelection();
225 void replaceAll();
226
227 private:
228
229 void clearSearchHighlights();
230 void addSearchHighlights();
231 int searchFlags() const;
232 bool findText( bool forward, bool findFirst );
233 void updateHighlightController();
234 void searchMatchCountChanged( int matchCount );
235
236 enum HighlightCategory
237 {
238 SearchMatch = 0,
239 Warning = 1
240 };
241
242 QgsCodeEditor *mEditor = nullptr;
243 QWidget *mFindWidget = nullptr;
244 QgsFilterLineEdit *mLineEditFind = nullptr;
245 QgsFilterLineEdit *mLineEditReplace = nullptr;
246 QToolButton *mFindPrevButton = nullptr;
247 QToolButton *mFindNextButton = nullptr;
248 QToolButton *mCaseSensitiveButton = nullptr;
249 QToolButton *mWholeWordButton = nullptr;
250 QToolButton *mRegexButton = nullptr;
251 QToolButton *mWrapAroundButton = nullptr;
252 QToolButton *mShowReplaceBarButton = nullptr;
253 QToolButton *mReplaceButton = nullptr;
254 QToolButton *mReplaceAllButton = nullptr;
255 int mBlockSearching = 0;
256 QgsMessageBar *mMessageBar = nullptr;
257 std::unique_ptr< QgsScrollBarHighlightController > mHighlightController;
258 QString mFilePath;
259 QDateTime mLastModified;
260};
261
262#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