QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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 <QDialog>
28#include <QWidget>
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
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:
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.
QString uri() const
Returns the (possibly blank) string representation of the new table data source URI.
QString dataProviderKey() const
Returns the currently selected data item provider key.
QString schema() const
Returns the currently selected schema or file path (in case of filesystem-based DBs like spatialite o...
QString validationError() const
Returns the validation error or an empty string is the widget status is valid.
QgsNewDatabaseTableNameDialog(QgsBrowserGuiModel *browserModel=nullptr, const QStringList &providersFilter=QStringList(), QWidget *parent=nullptr)
Constructs a new QgsNewDatabaseTableNameDialog.
bool isValid() const
Returns true if the widget contains a valid new table name.
QString table() const
Returns the current name of the new table.
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.
bool isValid() const
Returns true if the widget contains a valid new table name.
QString table() const
Returns the current name of the new table.
void showEvent(QShowEvent *e) override
Scroll to last selected index and expand it's children.
QString dataProviderKey() const
Returns the currently selected data item provider key.
void setAcceptButtonVisible(bool visible)
Sets whether the optional "Ok"/accept button should be visible.
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...
QString validationError() const
Returns the validation error or an empty string is the widget status is valid.
QString schema() const
Returns the currently selected schema or file path (in case of filesystem-based DBs like spatialite o...
QgsNewDatabaseTableNameWidget(QgsBrowserGuiModel *browserModel=nullptr, const QStringList &providersFilter=QStringList(), QWidget *parent=nullptr)
Constructs a new QgsNewDatabaseTableNameWidget.
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.
QString uri() const
Returns the (possibly blank) string representation of the new table data source URI.
void schemaNameChanged(const QString &schemaName)
This signal is emitted when the user selects a schema (or file path for filesystem-based DBs like spa...
QgsPanelWidget(QWidget *parent=nullptr)
Base class for any widget that can be shown as an inline panel.