Skip to content
Permalink
Browse files

Merge pull request #37832 from elpaso/browser-create-table

Browser create database table
  • Loading branch information
elpaso committed Jul 18, 2020
2 parents 407fd19 + 850826c commit 3af038f8612ea0abf77651fd449f51f2fe1626df
Showing with 2,529 additions and 264 deletions.
  1. +3 −0 python/core/auto_additions/qgsabstractdatabaseproviderconnection.py
  2. +27 −1 python/core/auto_generated/qgsabstractdatabaseproviderconnection.sip.in
  3. +71 −0 python/core/auto_generated/qgsdataitem.sip.in
  4. +9 −0 python/gui/auto_generated/qgsdataitemguiprovider.sip.in
  5. +124 −0 python/gui/auto_generated/qgsnewvectortabledialog.sip.in
  6. +1 −0 python/gui/gui_auto.sip
  7. +113 −30 src/app/browser/qgsinbuiltdataitemproviders.cpp
  8. +16 −0 src/app/browser/qgsinbuiltdataitemproviders.h
  9. +1 −0 src/app/qgisapp.cpp
  10. +1 −1 src/core/providers/ogr/qgsgeopackagedataitems.cpp
  11. +1 −1 src/core/providers/ogr/qgsgeopackagedataitems.h
  12. +40 −1 src/core/providers/ogr/qgsgeopackageproviderconnection.cpp
  13. +3 −0 src/core/providers/ogr/qgsgeopackageproviderconnection.h
  14. +6 −0 src/core/qgsabstractdatabaseproviderconnection.cpp
  15. +32 −2 src/core/qgsabstractdatabaseproviderconnection.h
  16. +24 −0 src/core/qgsdataitem.cpp
  17. +64 −0 src/core/qgsdataitem.h
  18. +1 −1 src/core/vectortile/qgsvectortiledataitems.cpp
  19. +1 −1 src/core/vectortile/qgsvectortiledataitems.h
  20. +4 −0 src/gui/CMakeLists.txt
  21. +10 −11 src/gui/providers/gdal/qgsgdalguiprovider.cpp
  22. +1 −1 src/gui/providers/gdal/qgsgdalguiprovider.h
  23. +0 −20 src/gui/providers/ogr/qgsgeopackageitemguiprovider.cpp
  24. +13 −13 src/gui/providers/ogr/qgsogritemguiprovider.cpp
  25. +3 −2 src/gui/providers/ogr/qgsogritemguiprovider.h
  26. +64 −1 src/gui/qgsdataitemguiprovider.cpp
  27. +9 −0 src/gui/qgsdataitemguiprovider.h
  28. +1 −0 src/gui/qgsnewgeopackagelayerdialog.cpp
  29. +813 −0 src/gui/qgsnewvectortabledialog.cpp
  30. +210 −0 src/gui/qgsnewvectortabledialog.h
  31. +1 −1 src/providers/arcgisrest/qgsafsdataitems.cpp
  32. +1 −1 src/providers/arcgisrest/qgsafsdataitems.h
  33. +1 −1 src/providers/arcgisrest/qgsamsdataitems.cpp
  34. +1 −1 src/providers/arcgisrest/qgsamsdataitems.h
  35. +1 −1 src/providers/db2/qgsdb2dataitems.cpp
  36. +1 −1 src/providers/db2/qgsdb2dataitems.h
  37. +1 −1 src/providers/geonode/qgsgeonodedataitems.cpp
  38. +1 −1 src/providers/geonode/qgsgeonodedataitems.h
  39. +30 −0 src/providers/mssql/qgsmssqlconnection.cpp
  40. +7 −0 src/providers/mssql/qgsmssqlconnection.h
  41. +4 −4 src/providers/mssql/qgsmssqldataitemguiprovider.cpp
  42. +8 −2 src/providers/mssql/qgsmssqldataitems.cpp
  43. +3 −3 src/providers/mssql/qgsmssqldataitems.h
  44. +3 −28 src/providers/mssql/qgsmssqlprovider.cpp
  45. +11 −0 src/providers/mssql/qgsmssqlproviderconnection.cpp
  46. +4 −0 src/providers/mssql/qgsmssqlproviderconnection.h
  47. +1 −1 src/providers/oracle/qgsoracledataitems.cpp
  48. +1 −1 src/providers/oracle/qgsoracledataitems.h
  49. +2 −2 src/providers/oracle/qgsoracleprovider.cpp
  50. +1 −1 src/providers/ows/qgsowsdataitems.cpp
  51. +1 −1 src/providers/ows/qgsowsdataitems.h
  52. +52 −0 src/providers/postgres/qgspostgresconn.cpp
  53. +7 −0 src/providers/postgres/qgspostgresconn.h
  54. +7 −6 src/providers/postgres/qgspostgresdataitemguiprovider.cpp
  55. +2 −2 src/providers/postgres/qgspostgresdataitems.cpp
  56. +2 −2 src/providers/postgres/qgspostgresdataitems.h
  57. +3 −51 src/providers/postgres/qgspostgresprovider.cpp
  58. +0 −1 src/providers/postgres/qgspostgresprovider.h
  59. +45 −5 src/providers/postgres/qgspostgresproviderconnection.cpp
  60. +5 −0 src/providers/postgres/qgspostgresproviderconnection.h
  61. +18 −0 src/providers/spatialite/qgsspatialiteconnection.cpp
  62. +10 −0 src/providers/spatialite/qgsspatialiteconnection.h
  63. +5 −5 src/providers/spatialite/qgsspatialitedataitemguiprovider.cpp
  64. +1 −1 src/providers/spatialite/qgsspatialitedataitems.cpp
  65. +1 −1 src/providers/spatialite/qgsspatialitedataitems.h
  66. +7 −20 src/providers/spatialite/qgsspatialiteprovider.cpp
  67. +36 −3 src/providers/spatialite/qgsspatialiteproviderconnection.cpp
  68. +3 −1 src/providers/spatialite/qgsspatialiteproviderconnection.h
  69. +1 −1 src/providers/wcs/qgswcsdataitems.cpp
  70. +1 −1 src/providers/wcs/qgswcsdataitems.h
  71. +1 −1 src/providers/wfs/qgswfsdataitems.cpp
  72. +1 −1 src/providers/wfs/qgswfsdataitems.h
  73. +3 −3 src/providers/wms/qgswmsdataitems.cpp
  74. +3 −3 src/providers/wms/qgswmsdataitems.h
  75. +416 −0 src/ui/qgsnewvectortabledialogbase.ui
  76. +8 −0 tests/src/gui/testqgsnewdatabasetablewidget.cpp
  77. +1 −0 tests/src/python/CMakeLists.txt
  78. +7 −19 tests/src/python/test_provider_mssql.py
  79. +123 −0 tests/src/python/test_qgsnewvectortabledialog.py
  80. +10 −0 tests/src/python/test_qgsproviderconnection_base.py
@@ -4,3 +4,6 @@
QgsAbstractDatabaseProviderConnection.Capability.baseClass = QgsAbstractDatabaseProviderConnection
QgsAbstractDatabaseProviderConnection.Capabilities.baseClass = QgsAbstractDatabaseProviderConnection
Capabilities = QgsAbstractDatabaseProviderConnection # dirty hack since SIP seems to introduce the flags in module
QgsAbstractDatabaseProviderConnection.GeometryColumnCapability.baseClass = QgsAbstractDatabaseProviderConnection
QgsAbstractDatabaseProviderConnection.GeometryColumnCapabilities.baseClass = QgsAbstractDatabaseProviderConnection
GeometryColumnCapabilities = QgsAbstractDatabaseProviderConnection # dirty hack since SIP seems to introduce the flags in module
@@ -238,10 +238,20 @@ This information is calculated from the geometry columns types.
DeleteFieldCascade,
AddField,
};

typedef QFlags<QgsAbstractDatabaseProviderConnection::Capability> Capabilities;


enum GeometryColumnCapability
{
Z,
M,
SinglePart,
Curves
};

typedef QFlags<QgsAbstractDatabaseProviderConnection::GeometryColumnCapability> GeometryColumnCapabilities;


QgsAbstractDatabaseProviderConnection( const QString &name );
%Docstring
Creates a new connection with ``name`` by reading its configuration from the settings.
@@ -263,6 +273,13 @@ The connection is not automatically stored in the settings.
Returns connection capabilities
%End

virtual GeometryColumnCapabilities geometryColumnCapabilities();
%Docstring
Returns connection geomerty column capabilities (Z, M, SinglePart, Curves)

.. versionadded:: 3.16
%End


virtual QString tableUri( const QString &schema, const QString &name ) const throw( QgsProviderConnectionException );
%Docstring
@@ -516,6 +533,15 @@ Raises a QgsProviderConnectionException if any errors are encountered.

.. versionadded:: 3.16

:raises :: py:class:`QgsProviderConnectionException`
%End

virtual QList< QgsVectorDataProvider::NativeType > nativeTypes() const throw( QgsProviderConnectionException ) = 0;
%Docstring
Returns a list of native types supported by the connection.

.. versionadded:: 3.16

:raises :: py:class:`QgsProviderConnectionException`
%End

@@ -654,6 +654,77 @@ Shared home directory icon.
%End
};


class QgsDatabaseSchemaItem : QgsDataCollectionItem
{
%Docstring
A Collection that represents a database schema item

.. versionadded:: 3.16
%End

%TypeHeaderCode
#include "qgsdataitem.h"
%End
public:

QgsDatabaseSchemaItem( QgsDataItem *parent /TransferThis/, const QString &name, const QString &path = QString(), const QString &providerKey = QString() );
%Docstring
Constructor for QgsDatabaseSchemaItem, with the specified ``parent`` item.

The ``name`` argument specifies the text to show in the model for the item. A translated string should
be used wherever appropriate.

The ``path`` argument gives the item path in the browser tree. The ``path`` string can take any form,
but QgsSchemaItem items pointing to different logical locations should always use a different item ``path``.

The optional ``providerKey`` string can be used to specify the key for the QgsDataItemProvider that created this item.
%End

~QgsDatabaseSchemaItem();


static QIcon iconDataCollection();
%Docstring
Returns the standard browser data collection icon.

.. seealso:: :py:func:`iconDir`
%End

};



class QgsConnectionsRootItem : QgsDataCollectionItem
{
%Docstring
A Collection that represents a root group of connections from a single data provider

.. versionadded:: 3.16
%End

%TypeHeaderCode
#include "qgsdataitem.h"
%End
public:

QgsConnectionsRootItem( QgsDataItem *parent /TransferThis/, const QString &name, const QString &path = QString(), const QString &providerKey = QString() );
%Docstring
Constructor for QgsConnectionsRootItem, with the specified ``parent`` item.

The ``name`` argument specifies the text to show in the model for the item. A translated string should
be used wherever appropriate.

The ``path`` argument gives the item path in the browser tree. The ``path`` string can take any form,
but QgsSchemaItem items pointing to different logical locations should always use a different item ``path``.

The optional ``providerKey`` string can be used to specify the key for the QgsDataItemProvider that created this item.
%End

~QgsConnectionsRootItem();
};


class QgsDirectoryItem : QgsDataCollectionItem
{
%Docstring
@@ -156,6 +156,15 @@ Caller takes responsibility of deleting created.
The function is replacement of :py:func:`QgsDataItem.paramWidget()`

.. versionadded:: 3.10
%End

static void notify( const QString &title, const QString &message, QgsDataItemGuiContext context, Qgis::MessageLevel level = Qgis::Info );
%Docstring
Notify the user showing a ``message`` with ``title`` and ``level``
If the context has a message bar the message will be shown in the message bar
else a message dialog will be used.

.. versionadded:: 3.16
%End
};

@@ -0,0 +1,124 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsnewvectortabledialog.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/





class QgsNewVectorTableDialog : QDialog
{
%Docstring
The QgsNewVectorTableDialog class is a provider-agnostic database vector
and aspatial table designer dialog based on the connections API.

It allows to design a new vector or aspatial database table by defining the schema
(if supported by the provider) and table name, the list of QgsFields,
the optional geometry type and SRID.

The actual creation of the table is delegated to the connections API method
:py:func:`QgsAbstractDatabaseProviderConnection.createVectorTable()`

.. versionadded:: 3.16
%End

%TypeHeaderCode
#include "qgsnewvectortabledialog.h"
%End
public:

QgsNewVectorTableDialog( QgsAbstractDatabaseProviderConnection *conn, QWidget *parent /TransferThis/ = 0 );
%Docstring
QgsNewVectorTableDialog constructor

:param connection: DB connection, ownership is NOT transfered
:param parent: optional parent
%End

void setSchemaName( const QString &name );
%Docstring
Sets the schema ``name``
%End

void setTableName( const QString &name );
%Docstring
Sets the table ``name``
%End

void setGeometryType( QgsWkbTypes::Type type );
%Docstring
Sets the geometry ``type``
%End

void setCrs( const QgsCoordinateReferenceSystem &crs );
%Docstring
Sets the CRS to ``crs``
%End

QgsCoordinateReferenceSystem crs() const;
%Docstring
Returns the CRS
%End

QString tableName() const;
%Docstring
Returns the table name
%End

QString schemaName() const;
%Docstring
Returns the schema name
%End

QString geometryColumnName() const;
%Docstring
Returns the geometry column name
%End

QgsFields fields() const;
%Docstring
Returns the fields
%End

QgsWkbTypes::Type geometryType() const;
%Docstring
Returns the geometry type
%End

void setFields( const QgsFields &fields );
%Docstring
Sets the fields to ``fields``
%End

bool createSpatialIndex();
%Docstring
Returns ``True`` if spatialindex checkbox is cheched
@return
%End

QStringList validationErrors() const;
%Docstring
Returns the validation errors or an empty list if the dialog is valid
%End

protected:
virtual void showEvent( QShowEvent *event );

};






/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsnewvectortabledialog.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -156,6 +156,7 @@
%Include auto_generated/qgsnewauxiliaryfielddialog.sip
%Include auto_generated/qgsnewauxiliarylayerdialog.sip
%Include auto_generated/qgsnewgeopackagelayerdialog.sip
%Include auto_generated/qgsnewvectortabledialog.sip
%Include auto_generated/qgsnewhttpconnection.sip
%Include auto_generated/qgsnewmemorylayerdialog.sip
%Include auto_generated/qgsnewnamedialog.sip

0 comments on commit 3af038f

Please sign in to comment.
You can’t perform that action at this time.