QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
|
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 | copyResults () |
Copies the query results to the clipboard, as a formatted table. More... | |
void | copyResults (int fromRow, int toRow, int fromColumn, int toColumn) |
Copies a range of the query results to the clipboard, as a formatted table. More... | |
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 108 of file qgsqueryresultwidget.h.
|
strong |
The QueryWidgetMode enum represents various modes for the widget appearance.
Definition at line 118 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 33 of file qgsqueryresultwidget.cpp.
|
virtual |
Definition at line 118 of file qgsqueryresultwidget.cpp.
|
slot |
Copies the query results to the clipboard, as a formatted table.
Definition at line 449 of file qgsqueryresultwidget.cpp.
|
slot |
Copies a range of the query results to the clipboard, as a formatted table.
Definition at line 456 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 166 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 576 of file qgsqueryresultwidget.cpp.
void QgsQueryResultWidget::setConnection | ( | QgsAbstractDatabaseProviderConnection * | connection | ) |
Sets the connection to connection, ownership is transferred to the widget.
Definition at line 528 of file qgsqueryresultwidget.cpp.
void QgsQueryResultWidget::setQuery | ( | const QString & | sql | ) |
Convenience method to set the SQL editor text to sql.
Definition at line 571 of file qgsqueryresultwidget.cpp.
void QgsQueryResultWidget::setSqlVectorLayerOptions | ( | const QgsAbstractDatabaseProviderConnection::SqlVectorLayerOptions & | options | ) |
Initializes the widget from options.
Definition at line 124 of file qgsqueryresultwidget.cpp.
void QgsQueryResultWidget::setWidgetMode | ( | QueryWidgetMode | widgetMode | ) |
Sets the widget mode to widgetMode, default is SqlQueryMode.
Definition at line 148 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 426 of file qgsqueryresultwidget.cpp.
|
slot |
Triggered when the threaded API fetcher has new tokens to add.
Definition at line 443 of file qgsqueryresultwidget.cpp.
|
friend |
Definition at line 261 of file qgsqueryresultwidget.h.