QGIS API Documentation 3.43.0-Master (c67cf405802)
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"
25#include "qgspanelwidget.h"
26
27#include <QWidget>
28#include <QDialog>
29
43class GUI_EXPORT QgsNewDatabaseTableNameWidget : public QgsPanelWidget, private Ui::QgsNewDatabaseTableNameWidget
44{
45 Q_OBJECT
46
47 public:
57 explicit QgsNewDatabaseTableNameWidget( QgsBrowserGuiModel *browserModel = nullptr, const QStringList &providersFilter = QStringList(), QWidget *parent = nullptr );
58
64 void setAcceptButtonVisible( bool visible );
65
69 QString schema() const;
70
75 QString uri() const;
76
80 QString table() const;
81
85 QString dataProviderKey() const;
86
90 bool isValid() const;
91
95 QString validationError() const;
96
98 void showEvent( QShowEvent *e ) override;
99
100 signals:
101
107 void validationChanged( bool isValid );
108
114 void schemaNameChanged( const QString &schemaName );
115
121 void tableNameChanged( const QString &tableName );
122
129 void providerKeyChanged( const QString &providerKey );
130
136 void uriChanged( const QString &uri );
137
141 void accepted();
142
143 private:
144 void updateUri();
145 void validate();
146 QStringList tableNames();
147 void refreshModel( const QModelIndex &index );
148
149 QgsBrowserProxyModel mBrowserProxyModel;
150 QgsBrowserGuiModel *mBrowserModel = nullptr;
151 QString mDataProviderKey;
152 QString mTableName;
153 QString mSchemaName;
154 QString mConnectionName;
155 bool mIsFilePath = false;
156 QString mUri;
158 QSet<QString> mShownProviders;
159 bool mIsValid = false;
160 QString mValidationError;
162 QMap<QString, QStringList> mTableNamesCache;
163
164 static QStringList FILESYSTEM_BASED_DATAITEM_PROVIDERS;
165
166 // For testing:
167 friend class TestQgsNewDatabaseTableNameWidget;
168};
169
170
184class GUI_EXPORT QgsNewDatabaseTableNameDialog : public QDialog
185{
186 Q_OBJECT
187
188 public:
198 explicit QgsNewDatabaseTableNameDialog( QgsBrowserGuiModel *browserModel = nullptr, const QStringList &providersFilter = QStringList(), QWidget *parent = nullptr );
199
203 QString schema() const;
204
209 QString uri() const;
210
214 QString table() const;
215
219 QString dataProviderKey() const;
220
224 bool isValid() const;
225
229 QString validationError() const;
230
231 private:
232 QgsNewDatabaseTableNameWidget *mWidget = nullptr;
233};
234#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.
A dialog which allows selection of a DB schema and a new table name.
A widget which embeds the browser view to select a DB schema and a new table name.
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 an inline panel.