@@ -43,7 +43,7 @@ def __init__(self, inLayer, outDb, outUri, parent=None):
43
43
44
44
self .default_pk = "id"
45
45
self .default_geom = "geom"
46
-
46
+
47
47
# updates of UI
48
48
for widget in [self .radCreate , self .chkDropTable , self .radAppend ,
49
49
self .chkPrimaryKey , self .chkGeomColumn , self .chkSpatialIndex ,
@@ -58,11 +58,14 @@ def __init__(self, inLayer, outDb, outUri, parent=None):
58
58
self .populateEncodings ()
59
59
self .updateUi ()
60
60
61
+ # set default values
61
62
self .cboTable .setEditText (self .outUri .table ())
63
+
62
64
pk = self .outUri .keyColumn ()
63
65
self .editPrimaryKey .setText (pk if pk != "" else self .default_pk )
64
66
geom = self .outUri .geometryColumn ()
65
67
self .editGeomColumn .setText (geom if geom != "" else self .default_geom )
68
+
66
69
inCrs = self .inLayer .crs ()
67
70
srid = inCrs .postgisSrid () if inCrs .isValid () else 4236
68
71
self .editSourceSrid .setText ( "%s" % srid )
@@ -73,7 +76,7 @@ def __init__(self, inLayer, outDb, outUri, parent=None):
73
76
74
77
def checkSupports (self ):
75
78
allowSpatial = self .db .connector .hasSpatialSupport ()
76
- self .chkGeomColumn .setEnabled (allowSpatial )
79
+ self .chkGeomColumn .setEnabled (allowSpatial and self . inLayer . hasGeometryType () )
77
80
self .chkSourceSrid .setEnabled (allowSpatial )
78
81
self .chkTargetSrid .setEnabled (allowSpatial )
79
82
self .chkSpatialIndex .setEnabled (allowSpatial )
@@ -168,12 +171,11 @@ def importLayer(self):
168
171
schema = self .outUri .schema () if not self .cboSchema .isEnabled () else self .cboSchema .currentText ()
169
172
table = self .cboTable .currentText ()
170
173
174
+ # get pk and geom field names from the source layer or use the
175
+ # ones defined by the user
171
176
pk = self .outUri .keyColumn () if not self .chkPrimaryKey .isChecked () else self .editPrimaryKey .text ()
172
- pk = pk if pk != "" else self .default_pk
173
-
174
177
geom = self .outUri .geometryColumn () if not self .chkGeomColumn .isChecked () else self .editGeomColumn .text ()
175
- if self .inLayer .hasGeometryType ():
176
- geom = geom if geom != "" else self .default_geom
178
+ geom = geom if geom != "" else self .default_geom
177
179
178
180
self .outUri .setDataSource ( schema , table , geom , QString (), pk )
179
181
uri = self .outUri .uri ()
0 commit comments