QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
|
The QgsQueryResultWidget class allows users to enter and run an SQL query on a DB connection (an instance of QgsAbstractDatabaseProviderConnection). More...
#include <qgsqueryresultwidget.h>
Public Types | |
enum class | QueryWidgetMode : int { SqlQueryMode = 1 << 0 , QueryLayerUpdateMode = 1 << 1 } |
The QueryWidgetMode enum represents various modes for the widget appearance. More... | |
Public Slots | |
void | executeQuery () |
Starts executing the query. More... | |
void | notify (const QString &title, const QString &text, Qgis::MessageLevel level=Qgis::MessageLevel::Info) |
Displays a message with text title and level in the widget's message bar. More... | |
void | showError (const QString &title, const QString &message, bool isSqlError=false) |
Hides the result table and shows the error title and message in the message bar or in the SQL error panel is isSqlError is set. More... | |
void | tokensReady (const QStringList &tokens) |
Triggered when the threaded API fetcher has new tokens to add. More... | |
Signals | |
void | createSqlVectorLayer (const QString &providerKey, const QString &connectionUri, const QgsAbstractDatabaseProviderConnection::SqlVectorLayerOptions &options) |
Emitted when a new vector SQL (query) layer must be created. More... | |
void | firstResultBatchFetched () |
Emitted when the first batch of results has been fetched. More... | |
Public Member Functions | |
QgsQueryResultWidget (QWidget *parent=nullptr, QgsAbstractDatabaseProviderConnection *connection=nullptr) | |
Creates a QgsQueryResultWidget with the given connection, ownership is transferred to the widget. More... | |
virtual | ~QgsQueryResultWidget () |
void | setConnection (QgsAbstractDatabaseProviderConnection *connection) |
Sets the connection to connection, ownership is transferred to the widget. More... | |
void | setQuery (const QString &sql) |
Convenience method to set the SQL editor text to sql. More... | |
void | setSqlVectorLayerOptions (const QgsAbstractDatabaseProviderConnection::SqlVectorLayerOptions &options) |
Initializes the widget from options. More... | |
void | setWidgetMode (QueryWidgetMode widgetMode) |
Sets the widget mode to widgetMode, default is SqlQueryMode. More... | |
Friends | |
class | TestQgsQueryResultWidget |
The QgsQueryResultWidget class allows users to enter and run an SQL query on a DB connection (an instance of QgsAbstractDatabaseProviderConnection).
Query results are displayed in a table view. Query execution and result fetching can be interrupted by pressing the "Stop" push button.
The widget supports a few QueryWidgetMode modes that pre-configure the widget appearance to be used in different contexts like when updating the SQL of an existing query layer.
Definition at line 105 of file qgsqueryresultwidget.h.
|
strong |
The QueryWidgetMode enum represents various modes for the widget appearance.
Definition at line 115 of file qgsqueryresultwidget.h.
QgsQueryResultWidget::QgsQueryResultWidget | ( | QWidget * | parent = nullptr , |
QgsAbstractDatabaseProviderConnection * | connection = nullptr |
||
) |
Creates a QgsQueryResultWidget with the given connection, ownership is transferred to the widget.
Definition at line 24 of file qgsqueryresultwidget.cpp.
|
virtual |
Definition at line 103 of file qgsqueryresultwidget.cpp.
|
signal |
Emitted when a new vector SQL (query) layer must be created.
providerKey | name of the data provider |
connectionUri | the connection URI as returned by QgsAbstractProviderConnection::uri() |
options |
|
slot |
Starts executing the query.
Definition at line 151 of file qgsqueryresultwidget.cpp.
|
signal |
Emitted when the first batch of results has been fetched.
|
slot |
Displays a message with text title and level in the widget's message bar.
Definition at line 432 of file qgsqueryresultwidget.cpp.
void QgsQueryResultWidget::setConnection | ( | QgsAbstractDatabaseProviderConnection * | connection | ) |
Sets the connection to connection, ownership is transferred to the widget.
Definition at line 389 of file qgsqueryresultwidget.cpp.
void QgsQueryResultWidget::setQuery | ( | const QString & | sql | ) |
Convenience method to set the SQL editor text to sql.
Definition at line 427 of file qgsqueryresultwidget.cpp.
void QgsQueryResultWidget::setSqlVectorLayerOptions | ( | const QgsAbstractDatabaseProviderConnection::SqlVectorLayerOptions & | options | ) |
Initializes the widget from options.
Definition at line 109 of file qgsqueryresultwidget.cpp.
void QgsQueryResultWidget::setWidgetMode | ( | QueryWidgetMode | widgetMode | ) |
Sets the widget mode to widgetMode, default is SqlQueryMode.
Definition at line 133 of file qgsqueryresultwidget.cpp.
|
slot |
Hides the result table and shows the error title and message in the message bar or in the SQL error panel is isSqlError is set.
Definition at line 344 of file qgsqueryresultwidget.cpp.
|
slot |
Triggered when the threaded API fetcher has new tokens to add.
Definition at line 361 of file qgsqueryresultwidget.cpp.
|
friend |
Definition at line 238 of file qgsqueryresultwidget.h.