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
47 explicit QgsQueryResultItemDelegate( QObject *parent =
nullptr );
49 QString displayText(
const QVariant &value,
const QLocale &locale )
const override;
56class 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();
86 QAtomicInt mStopFetching = 0;
87 std::unique_ptr< QgsFeedback > mFeedback;
110class GUI_EXPORT QgsQueryResultWidget:
public QWidget,
private Ui::QgsQueryResultWidgetBase
122 SqlQueryMode = 1 << 0,
123 QueryLayerUpdateMode = 1 << 1,
125 Q_ENUM( QueryWidgetMode )
132 virtual ~QgsQueryResultWidget();
142 void setWidgetMode( QueryWidgetMode widgetMode );
152 void setQuery(
const QString &sql );
171 void showError(
const QString &title,
const QString &message,
bool isSqlError =
false );
176 void tokensReady(
const QStringList &tokens );
190 void copyResults(
int fromRow,
int toRow,
int fromColumn,
int toColumn );
206 void firstResultBatchFetched();
213 void updateButtons();
215 void showCellContextMenu( QPoint point );
217 void copySelection();
224 std::unique_ptr<QgsAbstractDatabaseProviderConnection> mConnection;
225 std::unique_ptr<QgsQueryResultModel> mModel;
226 std::unique_ptr<QgsFeedback> mFeedback;
228 QPointer< QgsConnectionsApiFetcher > mApiFetcher;
230 bool mWasCanceled =
false;
232 bool mFirstRowFetched =
false;
233 QFutureWatcher<QgsAbstractDatabaseProviderConnection::QueryResult> mQueryResultWatcher;
234 QString mSqlErrorMessage;
235 long long mActualRowCount = -1;
236 long long mFetchedRowsBatchCount = 0;
237 QueryWidgetMode mQueryWidgetMode = QueryWidgetMode::SqlQueryMode;
238 long long mCurrentHistoryEntryId = -1;
243 void updateSqlLayerColumns();
248 void cancelRunningQuery();
253 void cancelApiFetcher();
258 void startFetching();
266 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.