16#ifndef QGSQUERYRESULTWIDGET_H
17#define QGSQUERYRESULTWIDGET_H
21#include "ui_qgsqueryresultwidgetbase.h"
28#include <QtConcurrent>
29#include <QStyledItemDelegate>
38class GUI_EXPORT QgsQueryResultItemDelegate:
public QStyledItemDelegate
45 explicit QgsQueryResultItemDelegate( QObject *parent =
nullptr );
47 QString displayText(
const QVariant &value,
const QLocale &locale )
const override;
54class GUI_EXPORT QgsConnectionsApiFetcher:
public QObject
61 QgsConnectionsApiFetcher(
const QString &uri,
const QString &providerKey )
63 , mProviderKey( providerKey )
75 void tokensReady(
const QStringList &newTokens );
78 void fetchingFinished();
84 QAtomicInt mStopFetching = 0;
85 std::unique_ptr< QgsFeedback > mFeedback;
120 SqlQueryMode = 1 << 0,
121 QueryLayerUpdateMode = 1 << 1,
123 Q_ENUM( QueryWidgetMode )
140 void setWidgetMode( QueryWidgetMode widgetMode );
150 void setQuery(
const QString &sql );
158 void notify(
const QString &title,
const QString &text,
Qgis::MessageLevel level = Qgis::MessageLevel::Info );
169 void showError(
const QString &title,
const QString &message,
bool isSqlError =
false );
174 void tokensReady(
const QStringList &tokens );
188 void copyResults(
int fromRow,
int toRow,
int fromColumn,
int toColumn );
211 void updateButtons();
213 void showCellContextMenu( QPoint point );
215 void copySelection();
219 std::unique_ptr<QgsAbstractDatabaseProviderConnection> mConnection;
220 std::unique_ptr<QgsQueryResultModel> mModel;
221 std::unique_ptr<QgsFeedback> mFeedback;
223 QPointer< QgsConnectionsApiFetcher > mApiFetcher;
225 bool mWasCanceled =
false;
227 bool mFirstRowFetched =
false;
228 QFutureWatcher<QgsAbstractDatabaseProviderConnection::QueryResult> mQueryResultWatcher;
229 QString mSqlErrorMessage;
230 long long mActualRowCount = -1;
231 long long mFetchedRowsBatchCount = 0;
233 long long mCurrentHistoryEntryId = -1;
238 void updateSqlLayerColumns();
243 void cancelRunningQuery();
248 void cancelApiFetcher();
253 void startFetching();
261 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.