16 #ifndef QGSQUERYRESULTWIDGET_H
17 #define QGSQUERYRESULTWIDGET_H
21 #include "ui_qgsqueryresultwidgetbase.h"
28 #include <QtConcurrent>
29 #include <QStyledItemDelegate>
38 class GUI_EXPORT QgsQueryResultItemDelegate:
public QStyledItemDelegate
45 explicit QgsQueryResultItemDelegate( QObject *parent =
nullptr );
47 QString displayText(
const QVariant &value,
const QLocale &locale )
const override;
54 class GUI_EXPORT QgsConnectionsApiFetcher:
public QObject
62 : mConnection( connection )
74 void tokensReady(
const QStringList &newTokens );
77 void fetchingFinished();
82 QAtomicInt mStopFetching = 0;
117 SqlQueryMode = 1 << 0,
118 QueryLayerUpdateMode = 1 << 1,
120 Q_ENUM( QueryWidgetMode )
137 void setWidgetMode( QueryWidgetMode widgetMode );
147 void setQuery(
const QString &sql );
155 void notify(
const QString &title,
const QString &text,
Qgis::MessageLevel level = Qgis::MessageLevel::Info );
166 void showError(
const QString &title,
const QString &message,
bool isSqlError =
false );
171 void tokensReady(
const QStringList &tokens );
194 void updateButtons();
198 std::unique_ptr<QgsAbstractDatabaseProviderConnection> mConnection;
199 std::unique_ptr<QgsQueryResultModel> mModel;
200 std::unique_ptr<QgsFeedback> mFeedback;
201 std::unique_ptr<QgsConnectionsApiFetcher> mApiFetcher;
202 QThread mApiFetcherWorkerThread;
203 bool mWasCanceled =
false;
205 bool mFirstRowFetched =
false;
206 QFutureWatcher<QgsAbstractDatabaseProviderConnection::QueryResult> mQueryResultWatcher;
207 QString mSqlErrorMessage;
208 long long mActualRowCount = -1;
209 long long mFetchedRowsBatchCount = 0;
215 void updateSqlLayerColumns();
220 void cancelRunningQuery();
225 void cancelApiFetcher();
230 void startFetching();
238 friend class TestQgsQueryResultWidget;
MessageLevel
Level for messages This will be used both for message log and message bar in application.
The QgsAbstractDatabaseProviderConnection class provides common functionality for DB based connection...
The SqlVectorLayerOptions stores all information required to create a SQL (query) layer.