QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
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
44class GUI_EXPORT QgsNewDatabaseTableNameWidget : public QgsPanelWidget, private Ui::QgsNewDatabaseTableNameWidget
45{
46 Q_OBJECT
47
48 public:
58 explicit QgsNewDatabaseTableNameWidget( QgsBrowserGuiModel *browserModel = nullptr, const QStringList &providersFilter = QStringList(), QWidget *parent = nullptr );
59
65 void setAcceptButtonVisible( bool visible );
66
70 QString schema() const;
71
76 QString uri() const;
77
81 QString table() const;
82
86 QString dataProviderKey() const;
87
91 bool isValid() const;
92
96 QString validationError() const;
97
99 void showEvent( QShowEvent *e ) override;
100
101 signals:
102
108 void validationChanged( bool isValid );
109
115 void schemaNameChanged( const QString &schemaName );
116
122 void tableNameChanged( const QString &tableName );
123
130 void providerKeyChanged( const QString &providerKey );
131
137 void uriChanged( const QString &uri );
138
142 void accepted();
143
144 private:
145 void updateUri();
146 void validate();
147 QStringList tableNames();
148 void refreshModel( const QModelIndex &index );
149
150 QgsBrowserProxyModel mBrowserProxyModel;
151 QgsBrowserGuiModel *mBrowserModel = nullptr;
152 QString mDataProviderKey;
153 QString mTableName;
154 QString mSchemaName;
155 QString mConnectionName;
156 bool mIsFilePath = false;
157 QString mUri;
159 QSet<QString> mShownProviders;
160 bool mIsValid = false;
161 QString mValidationError;
163 QMap<QString, QStringList> mTableNamesCache;
164
165 static QStringList FILESYSTEM_BASED_DATAITEM_PROVIDERS;
166
167 // For testing:
168 friend class TestQgsNewDatabaseTableNameWidget;
169};
170
171
185class GUI_EXPORT QgsNewDatabaseTableNameDialog : public QDialog
186{
187 Q_OBJECT
188
189 public:
199 explicit QgsNewDatabaseTableNameDialog( QgsBrowserGuiModel *browserModel = nullptr, const QStringList &providersFilter = QStringList(), QWidget *parent = nullptr );
200
204 QString schema() const;
205
210 QString uri() const;
211
215 QString table() const;
216
220 QString dataProviderKey() const;
221
225 bool isValid() const;
226
230 QString validationError() const;
231
232 private:
233 QgsNewDatabaseTableNameWidget *mWidget = nullptr;
234};
235#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.