16#ifndef QGSQUERYRESULTWIDGET_H
17#define QGSQUERYRESULTWIDGET_H
21#include "ui_qgsqueryresultwidgetbase.h"
28#include <QtConcurrent>
29#include <QStyledItemDelegate>
42class GUI_EXPORT QgsQueryResultItemDelegate :
public QStyledItemDelegate
48 explicit QgsQueryResultItemDelegate( QObject *parent =
nullptr );
50 QString displayText(
const QVariant &value,
const QLocale &locale )
const override;
57class GUI_EXPORT QgsConnectionsApiFetcher :
public QObject
63 QgsConnectionsApiFetcher(
const QString &uri,
const QString &providerKey )
65 , mProviderKey( providerKey )
77 void tokensReady(
const QStringList &newTokens );
80 void fetchingFinished();
85 QAtomicInt mStopFetching = 0;
86 std::unique_ptr<QgsFeedback> mFeedback;
108class GUI_EXPORT QgsQueryResultWidget :
public QWidget,
private Ui::QgsQueryResultWidgetBase
125 SqlQueryMode = 1 << 0,
126 QueryLayerUpdateMode = 1 << 1,
128 Q_ENUM( QueryWidgetMode )
135 virtual ~QgsQueryResultWidget();
145 void setWidgetMode( QueryWidgetMode widgetMode );
155 void setQuery(
const QString &sql );
157 SIP_SKIP bool promptUnsavedChanges();
175 void showError(
const QString &title,
const QString &message,
bool isSqlError =
false );
180 void tokensReady(
const QStringList &tokens );
194 void copyResults(
int fromRow,
int toRow,
int fromColumn,
int toColumn );
210 void firstResultBatchFetched();
212 SIP_SKIP void requestDialogTitleUpdate(
const QString &filename );
219 void updateButtons();
221 void showCellContextMenu( QPoint point );
222 void copySelection();
224 void saveQuery(
bool saveAs );
225 void setHasChanged(
bool hasChanged );
226 void populatePresetQueryMenu();
231 QMenu *mPresetQueryMenu =
nullptr;
233 std::unique_ptr<QgsAbstractDatabaseProviderConnection> mConnection;
234 std::unique_ptr<QgsQueryResultModel> mModel;
235 std::unique_ptr<QgsFeedback> mFeedback;
237 QPointer<QgsConnectionsApiFetcher> mApiFetcher;
239 bool mWasCanceled =
false;
241 bool mFirstRowFetched =
false;
242 QFutureWatcher<QgsAbstractDatabaseProviderConnection::QueryResult> mQueryResultWatcher;
243 QString mSqlErrorMessage;
244 long long mActualRowCount = -1;
245 long long mFetchedRowsBatchCount = 0;
246 QueryWidgetMode mQueryWidgetMode = QueryWidgetMode::SqlQueryMode;
247 long long mCurrentHistoryEntryId = -1;
249 bool mHasChangedFileContents =
false;
254 void updateSqlLayerColumns();
259 void cancelRunningQuery();
264 void cancelApiFetcher();
269 void startFetching();
276 void updateDialogTitle();
279 friend class TestQgsQueryResultWidget;
293class GUI_EXPORT QgsQueryResultDialog :
public QDialog
308 QgsQueryResultWidget *resultWidget() {
return mWidget; }
310 void closeEvent( QCloseEvent *event )
override;
313 QgsQueryResultWidget *mWidget =
nullptr;
327class GUI_EXPORT QgsQueryResultMainWindow :
public QMainWindow
342 QgsQueryResultWidget *resultWidget() {
return mWidget; }
344 void closeEvent( QCloseEvent *event )
override;
347 QgsQueryResultWidget *mWidget =
nullptr;
348 QString mIdentifierName;
350 void updateWindowTitle(
const QString &fileName );
MessageLevel
Level for messages This will be used both for message log and message bar in application.
@ Info
Information message.
QueryStorageBackend
Stored query storage backends.
The QgsAbstractDatabaseProviderConnection class provides common functionality for DB based connection...
A SQL editor based on QScintilla2.
QgsSettingsTreeNode is a tree node for the settings tree to help organizing and introspecting the tre...
QgsSettingsTreeNode * createChildNode(const QString &key)
Creates a normal tree node It will return the existing child node if it exists at the given key.
static QgsSettingsTreeNode * sTreeGui
#define SIP_ENUM_BASETYPE(type)
The SqlVectorLayerOptions stores all information required to create a SQL (query) layer.