16#ifndef QGSQUERYRESULTWIDGET_H
17#define QGSQUERYRESULTWIDGET_H
21#include "ui_qgsqueryresultwidgetbase.h"
28#include <QtConcurrent>
29#include <QStyledItemDelegate>
40class GUI_EXPORT QgsQueryResultItemDelegate :
public QStyledItemDelegate
46 explicit QgsQueryResultItemDelegate( QObject *parent =
nullptr );
48 QString displayText(
const QVariant &value,
const QLocale &locale )
const override;
55class 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();
83 QAtomicInt mStopFetching = 0;
84 std::unique_ptr<QgsFeedback> mFeedback;
106class GUI_EXPORT QgsQueryResultWidget :
public QWidget,
private Ui::QgsQueryResultWidgetBase
116 SqlQueryMode = 1 << 0,
117 QueryLayerUpdateMode = 1 << 1,
119 Q_ENUM( QueryWidgetMode )
126 virtual ~QgsQueryResultWidget();
136 void setWidgetMode( QueryWidgetMode widgetMode );
146 void setQuery(
const QString &sql );
165 void showError(
const QString &title,
const QString &message,
bool isSqlError =
false );
170 void tokensReady(
const QStringList &tokens );
184 void copyResults(
int fromRow,
int toRow,
int fromColumn,
int toColumn );
200 void firstResultBatchFetched();
207 void updateButtons();
209 void showCellContextMenu( QPoint point );
211 void copySelection();
217 std::unique_ptr<QgsAbstractDatabaseProviderConnection> mConnection;
218 std::unique_ptr<QgsQueryResultModel> mModel;
219 std::unique_ptr<QgsFeedback> mFeedback;
221 QPointer<QgsConnectionsApiFetcher> mApiFetcher;
223 bool mWasCanceled =
false;
225 bool mFirstRowFetched =
false;
226 QFutureWatcher<QgsAbstractDatabaseProviderConnection::QueryResult> mQueryResultWatcher;
227 QString mSqlErrorMessage;
228 long long mActualRowCount = -1;
229 long long mFetchedRowsBatchCount = 0;
230 QueryWidgetMode mQueryWidgetMode = QueryWidgetMode::SqlQueryMode;
231 long long mCurrentHistoryEntryId = -1;
236 void updateSqlLayerColumns();
241 void cancelRunningQuery();
246 void cancelApiFetcher();
251 void startFetching();
259 friend class TestQgsQueryResultWidget;
MessageLevel
Level for messages This will be used both for message log and message bar in application.
@ Info
Information message.
The QgsAbstractDatabaseProviderConnection class provides common functionality for DB based connection...
A SQL editor based on QScintilla2.
#define SIP_ENUM_BASETYPE(type)
The SqlVectorLayerOptions stores all information required to create a SQL (query) layer.