16#ifndef QGSQUERYRESULTWIDGET_H 
   17#define QGSQUERYRESULTWIDGET_H 
   21#include "ui_qgsqueryresultwidgetbase.h" 
   22#include "ui_qgsqueryresultpanelwidgetbase.h" 
   30#include <QtConcurrent> 
   31#include <QStyledItemDelegate> 
   37class QgsQueryResultPanelWidget;
 
   47class GUI_EXPORT QgsQueryResultItemDelegate : 
public QStyledItemDelegate
 
   53    explicit QgsQueryResultItemDelegate( QObject *parent = 
nullptr );
 
   55    QString displayText( 
const QVariant &value, 
const QLocale &locale ) 
const override;
 
   62class GUI_EXPORT QgsConnectionsApiFetcher : 
public QObject
 
   68    QgsConnectionsApiFetcher( 
const QString &uri, 
const QString &providerKey )
 
   70      , mProviderKey( providerKey )
 
   82    void tokensReady( 
const QStringList &newTokens );
 
   85    void fetchingFinished();
 
   90    QAtomicInt mStopFetching = 0;
 
   91    std::unique_ptr<QgsFeedback> mFeedback;
 
  113class GUI_EXPORT QgsQueryResultWidget : 
public QWidget, 
private Ui::QgsQueryResultWidgetBase
 
  130      SqlQueryMode = 1 << 0,         
 
  131      QueryLayerUpdateMode = 1 << 1, 
 
  133    Q_ENUM( QueryWidgetMode )
 
  140    virtual ~QgsQueryResultWidget();
 
  150    void setWidgetMode( QueryWidgetMode widgetMode );
 
  160    void setQuery( 
const QString &sql );
 
  162    SIP_SKIP bool promptUnsavedChanges();
 
  180    void showError( 
const QString &title, 
const QString &message, 
bool isSqlError = 
false );
 
  187    Q_DECL_DEPRECATED 
void tokensReady( 
const QStringList &tokens ) 
SIP_DEPRECATED;
 
  201    void copyResults( 
int fromRow, 
int toRow, 
int fromColumn, 
int toColumn );
 
  217    void firstResultBatchFetched();
 
  219    SIP_SKIP void requestDialogTitleUpdate( 
const QString &filename );
 
  226    void updateButtons();
 
  229    void saveQuery( 
bool saveAs );
 
  230    void setHasChanged( 
bool hasChanged );
 
  231    void populatePresetQueryMenu();
 
  232    void showHistoryPanel( 
bool show );
 
  235    QgsQueryResultPanelWidget *mQueryWidget = 
nullptr;
 
  236    QPointer< QgsDatabaseQueryHistoryWidget > mHistoryWidget;
 
  238    QMenu *mPresetQueryMenu = 
nullptr;
 
  240    bool mHasChangedFileContents = 
false;
 
  242    void updateDialogTitle();
 
  245    friend class TestQgsQueryResultWidget;
 
  261class GUI_EXPORT QgsQueryResultPanelWidget : 
public QgsPanelWidget, 
private Ui::QgsQueryResultPanelWidgetBase
 
  271    ~QgsQueryResultPanelWidget() 
override;
 
  291    void setWidgetMode( QgsQueryResultWidget::QueryWidgetMode widgetMode );
 
  301    void setQuery( 
const QString &sql );
 
  319    void showError( 
const QString &title, 
const QString &message, 
bool isSqlError = 
false );
 
  324    void tokensReady( 
const QStringList &tokens );
 
  338    void copyResults( 
int fromRow, 
int toRow, 
int fromColumn, 
int toColumn );
 
  354    void firstResultBatchFetched();
 
  361    void updateButtons();
 
  363    void showCellContextMenu( QPoint point );
 
  364    void copySelection();
 
  370    std::unique_ptr<QgsAbstractDatabaseProviderConnection> mConnection;
 
  371    std::unique_ptr<QgsQueryResultModel> mModel;
 
  372    std::unique_ptr<QgsFeedback> mFeedback;
 
  374    QPointer<QgsConnectionsApiFetcher> mApiFetcher;
 
  376    bool mWasCanceled = 
false;
 
  378    bool mFirstRowFetched = 
false;
 
  379    QFutureWatcher<QgsAbstractDatabaseProviderConnection::QueryResult> mQueryResultWatcher;
 
  380    QString mSqlErrorMessage;
 
  381    long long mActualRowCount = -1;
 
  382    long long mFetchedRowsBatchCount = 0;
 
  383    QgsQueryResultWidget::QueryWidgetMode mQueryWidgetMode = QgsQueryResultWidget::QueryWidgetMode::SqlQueryMode;
 
  384    long long mCurrentHistoryEntryId = -1;
 
  389    void updateSqlLayerColumns();
 
  394    void cancelRunningQuery();
 
  399    void cancelApiFetcher();
 
  404    void startFetching();
 
  413    friend class TestQgsQueryResultWidget;
 
  414    friend class QgsQueryResultWidget;
 
  429class GUI_EXPORT QgsQueryResultDialog : 
public QDialog
 
  444    QgsQueryResultWidget *resultWidget() { 
return mWidget; }
 
  446    void closeEvent( QCloseEvent *event ) 
override;
 
  449    QgsQueryResultWidget *mWidget = 
nullptr;
 
  463class GUI_EXPORT QgsQueryResultMainWindow : 
public QMainWindow
 
  478    QgsQueryResultWidget *resultWidget() { 
return mWidget; }
 
  480    void closeEvent( QCloseEvent *event ) 
override;
 
  483    QgsQueryResultWidget *mWidget = 
nullptr;
 
  484    QString mIdentifierName;
 
  486    void updateWindowTitle( 
const QString &fileName );
 
MessageLevel
Level for messages This will be used both for message log and message bar in application.
 
@ Info
Information message.
 
QueryStorageBackend
Stored query storage backends.
 
Provides common functionality for database based connections.
 
A SQL editor based on QScintilla2.
 
Custom QgsHistoryWidget for use with the database query provider.
 
A tree node for the settings tree to help organizing and introspecting the tree.
 
QgsSettingsTreeNode * createChildNode(const QString &key)
Creates a normal tree node It will return the existing child node if it exists at the given key.
 
static QgsSettingsTreeNode * sTreeGui
 
#define SIP_ENUM_BASETYPE(type)
 
The SqlVectorLayerOptions stores all information required to create a SQL (query) layer.