QGIS API Documentation  3.22.4-Białowieża (ce8e65e95e)
qgsnewdatabasetablenamewidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsnewdatabasetablenamewidget.h - QgsNewDatabaseTableNameWidget
3 
4  ---------------------
5  begin : 9.3.2020
6  copyright : (C) 2020 by Alessandro Pasotti
7  email : elpaso at itopen dot it
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 #ifndef QGSNEWDATABASETABLENAMEWIDGET_H
17 #define QGSNEWDATABASETABLENAMEWIDGET_H
18 
19 
20 #include "ui_qgsnewdatabasetablenamewidget.h"
21 
22 #include "qgis_gui.h"
23 #include "qgsbrowserguimodel.h"
24 #include "qgsbrowserproxymodel.h"
25 #include "qgspanelwidget.h"
26 
27 #include <QWidget>
28 #include <QDialog>
29 
44 class GUI_EXPORT QgsNewDatabaseTableNameWidget : public QgsPanelWidget, private Ui::QgsNewDatabaseTableNameWidget
45 {
46  Q_OBJECT
47 
48  public:
49 
59  explicit QgsNewDatabaseTableNameWidget( QgsBrowserGuiModel *browserModel = nullptr,
60  const QStringList &providersFilter = QStringList(),
61  QWidget *parent = nullptr );
62 
68  void setAcceptButtonVisible( bool visible );
69 
73  QString schema() const;
74 
79  QString uri() const;
80 
84  QString table() const;
85 
89  QString dataProviderKey() const;
90 
94  bool isValid() const;
95 
99  QString validationError() const;
100 
102  void showEvent( QShowEvent *e ) override;
103 
104  signals:
105 
111  void validationChanged( bool isValid );
112 
118  void schemaNameChanged( const QString &schemaName );
119 
125  void tableNameChanged( const QString &tableName );
126 
133  void providerKeyChanged( const QString &providerKey );
134 
140  void uriChanged( const QString &uri );
141 
145  void accepted();
146 
147  private:
148 
149  void updateUri();
150  void validate();
151  QStringList tableNames();
152  void refreshModel( const QModelIndex &index );
153 
154  QgsBrowserProxyModel mBrowserProxyModel;
155  QgsBrowserGuiModel *mBrowserModel = nullptr;
156  QString mDataProviderKey;
157  QString mTableName;
158  QString mSchemaName;
159  QString mConnectionName;
160  bool mIsFilePath = false;
161  QString mUri;
163  QSet<QString> mShownProviders;
164  bool mIsValid = false;
165  QString mValidationError;
167  QMap<QString, QStringList> mTableNamesCache;
168 
169  static QStringList FILESYSTEM_BASED_DATAITEM_PROVIDERS;
170 
171  // For testing:
172  friend class TestQgsNewDatabaseTableNameWidget;
173 
174 };
175 
176 
190 class GUI_EXPORT QgsNewDatabaseTableNameDialog: public QDialog
191 {
192  Q_OBJECT
193 
194  public:
195 
205  explicit QgsNewDatabaseTableNameDialog( QgsBrowserGuiModel *browserModel = nullptr,
206  const QStringList &providersFilter = QStringList(),
207  QWidget *parent = nullptr );
208 
212  QString schema() const;
213 
218  QString uri() const;
219 
223  QString table() const;
224 
228  QString dataProviderKey() const;
229 
233  bool isValid() const;
234 
238  QString validationError() const;
239 
240  private:
241 
242  QgsNewDatabaseTableNameWidget *mWidget = nullptr;
243 
244 };
245 #endif // QGSNEWDATABASETABLENAMEWIDGET_H
A model for showing available data sources and other items in a structured tree.
A QSortFilterProxyModel subclass for filtering and sorting browser model items.
QgsNewDatabaseTableNameDialog is a dialog which allows selection of a DB schema and a new table name.
The QgsNewDatabaseTableNameWidget class embeds the browser view to select a DB schema and a new table...
void uriChanged(const QString &uri)
This signal is emitted when the URI of the new table changes, whether or not it is a valid one.
void providerKeyChanged(const QString &providerKey)
This signal is emitted when the selects a data provider or a schema name that has a different data pr...
void tableNameChanged(const QString &tableName)
This signal is emitted when the user enters a table name.
void accepted()
Emitted when the OK/accept button is clicked.
void validationChanged(bool isValid)
This signal is emitted whenever the validation status of the widget changes.
void schemaNameChanged(const QString &schemaName)
This signal is emitted when the user selects a schema (or file path for filesystem-based DBs like spa...
Base class for any widget that can be shown as a inline panel.