QGIS API Documentation 3.41.0-Master (45a0abf3bec)
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
126 bool save( const QString &path = QString() );
127
128 public slots:
129
136 void showSearchBar();
137
144 void hideSearchBar();
145
153 void setSearchBarVisible( bool visible );
154
160 void setReplaceBarVisible( bool visible );
161
168 void triggerFind();
169
178 bool loadFile( const QString &path );
179
187 void setFilePath( const QString &path );
188
202 bool openInExternalEditor( int line = -1, int column = -1 );
203
211 bool shareOnGist( bool isPublic );
212
213 signals:
214
218 void searchBarToggled( bool visible );
219
226 void filePathChanged( const QString &path );
227
233
234 private slots:
235
236 bool findNext();
237 void findPrevious();
238 void textSearchChanged( const QString &text );
239 void updateSearch();
240 void replace();
241 void replaceSelection();
242 void replaceAll();
243
244 private:
245
246 void clearSearchHighlights();
247 void addSearchHighlights();
248 int searchFlags() const;
249 bool findText( bool forward, bool findFirst );
250 void updateHighlightController();
251 void searchMatchCountChanged( int matchCount );
252
253 enum HighlightCategory
254 {
255 SearchMatch = 0,
256 Warning = 1
257 };
258
259 QgsCodeEditor *mEditor = nullptr;
260 QWidget *mFindWidget = nullptr;
261 QgsFilterLineEdit *mLineEditFind = nullptr;
262 QgsFilterLineEdit *mLineEditReplace = nullptr;
263 QToolButton *mFindPrevButton = nullptr;
264 QToolButton *mFindNextButton = nullptr;
265 QToolButton *mCaseSensitiveButton = nullptr;
266 QToolButton *mWholeWordButton = nullptr;
267 QToolButton *mRegexButton = nullptr;
268 QToolButton *mWrapAroundButton = nullptr;
269 QToolButton *mShowReplaceBarButton = nullptr;
270 QToolButton *mReplaceButton = nullptr;
271 QToolButton *mReplaceAllButton = nullptr;
272 int mBlockSearching = 0;
273 QgsMessageBar *mMessageBar = nullptr;
274 std::unique_ptr< QgsScrollBarHighlightController > mHighlightController;
275 QString mFilePath;
276 QDateTime mLastModified;
277};
278
279#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