mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Merge pull request #6335 from Fanevanjanahary/crs_widget
use crs widget picker in db_manager
This commit is contained in:
commit
eab76e85c7
@ -68,6 +68,8 @@ class DlgImportVector(QDialog, Ui_Dialog):
|
||||
# updates of UI
|
||||
self.setupWorkingMode(self.mode)
|
||||
self.cboSchema.currentIndexChanged.connect(self.populateTables)
|
||||
self.widgetSourceSrid.setCrs(QgsProject.instance().crs())
|
||||
self.widgetTargetSrid.setCrs(QgsProject.instance().crs())
|
||||
|
||||
def setupWorkingMode(self, mode):
|
||||
""" hide the widget to select a layer/file if the input layer is already set """
|
||||
@ -210,9 +212,10 @@ class DlgImportVector(QDialog, Ui_Dialog):
|
||||
self.editGeomColumn.setText(geom)
|
||||
|
||||
srcCrs = self.inLayer.crs()
|
||||
srid = srcCrs.postgisSrid() if srcCrs.isValid() else 4326
|
||||
self.editSourceSrid.setText("%s" % srid)
|
||||
self.editTargetSrid.setText("%s" % srid)
|
||||
if not srcCrs.isValid():
|
||||
srcCrs = QgsCoordinateReferenceSystem(4326)
|
||||
self.widgetSourceSrid.setCrs(srcCrs)
|
||||
self.widgetTargetSrid.setCrs(srcCrs)
|
||||
|
||||
return True
|
||||
|
||||
@ -270,27 +273,23 @@ class DlgImportVector(QDialog, Ui_Dialog):
|
||||
|
||||
# sanity checks
|
||||
if self.inLayer is None:
|
||||
QMessageBox.information(self, self.tr("Import to database"), self.tr("Input layer missing or not valid"))
|
||||
QMessageBox.critical(self, self.tr("Import to Database"), self.tr("Input layer missing or not valid."))
|
||||
return
|
||||
|
||||
if self.cboTable.currentText() == "":
|
||||
QMessageBox.information(self, self.tr("Import to database"), self.tr("Output table name is required"))
|
||||
QMessageBox.critical(self, self.tr("Import to Database"), self.tr("Output table name is required."))
|
||||
return
|
||||
|
||||
if self.chkSourceSrid.isEnabled() and self.chkSourceSrid.isChecked():
|
||||
try:
|
||||
sourceSrid = self.editSourceSrid.text()
|
||||
except ValueError:
|
||||
QMessageBox.information(self, self.tr("Import to database"),
|
||||
self.tr("Invalid source srid: must be an integer"))
|
||||
if not self.widgetSourceSrid.crs().isValid():
|
||||
QMessageBox.critical(self, self.tr("Import to Database"),
|
||||
self.tr("Invalid source srid: must be a valid crs."))
|
||||
return
|
||||
|
||||
if self.chkTargetSrid.isEnabled() and self.chkTargetSrid.isChecked():
|
||||
try:
|
||||
targetSrid = self.editTargetSrid.text()
|
||||
except ValueError:
|
||||
QMessageBox.information(self, self.tr("Import to database"),
|
||||
self.tr("Invalid target srid: must be an integer"))
|
||||
if not self.widgetTargetSrid.crs().isValid():
|
||||
QMessageBox.critical(self, self.tr("Import to Database"),
|
||||
self.tr("Invalid target srid: must be a valid crs."))
|
||||
return
|
||||
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
@ -344,13 +343,11 @@ class DlgImportVector(QDialog, Ui_Dialog):
|
||||
|
||||
outCrs = QgsCoordinateReferenceSystem()
|
||||
if self.chkTargetSrid.isEnabled() and self.chkTargetSrid.isChecked():
|
||||
targetSrid = int(self.editTargetSrid.text())
|
||||
outCrs = QgsCoordinateReferenceSystem(targetSrid)
|
||||
outCrs = self.widgetTargetSrid.crs()
|
||||
|
||||
# update input layer crs and encoding
|
||||
if self.chkSourceSrid.isEnabled() and self.chkSourceSrid.isChecked():
|
||||
sourceSrid = int(self.editSourceSrid.text())
|
||||
inCrs = QgsCoordinateReferenceSystem(sourceSrid)
|
||||
inCrs = self.widgetSourceSrid.crs()
|
||||
self.inLayer.setCrs(inCrs)
|
||||
|
||||
if self.chkEncoding.isEnabled() and self.chkEncoding.isChecked():
|
||||
@ -372,7 +369,7 @@ class DlgImportVector(QDialog, Ui_Dialog):
|
||||
|
||||
if ret != 0:
|
||||
output = QgsMessageViewer()
|
||||
output.setTitle(self.tr("Import to database"))
|
||||
output.setTitle(self.tr("Import to Database"))
|
||||
output.setMessageAsPlainText(self.tr("Error {0}\n{1}").format(ret, errMsg))
|
||||
output.showMessage()
|
||||
return
|
||||
@ -383,7 +380,7 @@ class DlgImportVector(QDialog, Ui_Dialog):
|
||||
|
||||
self.db.connection().reconnect()
|
||||
self.db.refresh()
|
||||
QMessageBox.information(self, self.tr("Import to database"), self.tr("Import was successful."))
|
||||
QMessageBox.information(self, self.tr("Import to Database"), self.tr("Import was successful."))
|
||||
return QDialog.accept(self)
|
||||
|
||||
def closeEvent(self, event):
|
||||
|
@ -153,6 +153,13 @@
|
||||
<string>Options</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="chkDropTable">
|
||||
<property name="text">
|
||||
<string>Replace destination table (if exists)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="chkPrimaryKey">
|
||||
<property name="text">
|
||||
@ -181,62 +188,14 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkSourceSrid">
|
||||
<property name="text">
|
||||
<string>Source SRID</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="editSourceSrid">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkTargetSrid">
|
||||
<property name="text">
|
||||
<string>Target SRID</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="editTargetSrid">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="chkEncoding">
|
||||
<property name="text">
|
||||
<string>Encoding</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="cboEncoding">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
@ -246,34 +205,55 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<item row="7" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="chkSinglePart">
|
||||
<property name="text">
|
||||
<string>Create single-part geometries instead of multi-part</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="2">
|
||||
<item row="9" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="chkSpatialIndex">
|
||||
<property name="text">
|
||||
<string>Create spatial index</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="chkDropTable">
|
||||
<property name="text">
|
||||
<string>Replace destination table (if exists)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<item row="8" column="0">
|
||||
<widget class="QCheckBox" name="chkLowercaseFieldNames">
|
||||
<property name="text">
|
||||
<string>Convert field names to lowercase</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="chkTargetSrid">
|
||||
<property name="text">
|
||||
<string>Target SRID</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QgsProjectionSelectionWidget" name="widgetTargetSrid" native="true">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QgsProjectionSelectionWidget" name="widgetSourceSrid" native="true">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="chkSourceSrid">
|
||||
<property name="text">
|
||||
<string>Source SRID</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -293,14 +273,33 @@
|
||||
<zorder>groupBox_3</zorder>
|
||||
<zorder>wdgInput</zorder>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QgsProjectionSelectionWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>qgis.gui</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>cboInputLayer</tabstop>
|
||||
<tabstop>btnChooseInputFile</tabstop>
|
||||
<tabstop>chkSelectedFeatures</tabstop>
|
||||
<tabstop>btnUpdateInputLayer</tabstop>
|
||||
<tabstop>cboSchema</tabstop>
|
||||
<tabstop>cboTable</tabstop>
|
||||
<tabstop>chkPrimaryKey</tabstop>
|
||||
<tabstop>editPrimaryKey</tabstop>
|
||||
<tabstop>chkGeomColumn</tabstop>
|
||||
<tabstop>editGeomColumn</tabstop>
|
||||
<tabstop>chkSourceSrid</tabstop>
|
||||
<tabstop>editSourceSrid</tabstop>
|
||||
<tabstop>chkTargetSrid</tabstop>
|
||||
<tabstop>chkEncoding</tabstop>
|
||||
<tabstop>cboEncoding</tabstop>
|
||||
<tabstop>chkDropTable</tabstop>
|
||||
<tabstop>chkSinglePart</tabstop>
|
||||
<tabstop>chkLowercaseFieldNames</tabstop>
|
||||
<tabstop>chkSpatialIndex</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
@ -311,8 +310,8 @@
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>325</x>
|
||||
<y>518</y>
|
||||
<x>334</x>
|
||||
<y>486</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
@ -327,12 +326,12 @@
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>108</x>
|
||||
<y>347</y>
|
||||
<x>129</x>
|
||||
<y>239</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>207</x>
|
||||
<y>345</y>
|
||||
<x>460</x>
|
||||
<y>239</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
@ -343,44 +342,12 @@
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>120</x>
|
||||
<y>367</y>
|
||||
<x>141</x>
|
||||
<y>265</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>188</x>
|
||||
<y>367</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>chkSourceSrid</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>editSourceSrid</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>115</x>
|
||||
<y>390</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>166</x>
|
||||
<y>394</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>chkTargetSrid</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>editTargetSrid</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>360</x>
|
||||
<y>396</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>435</x>
|
||||
<y>394</y>
|
||||
<x>442</x>
|
||||
<y>265</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
@ -391,12 +358,12 @@
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>98</x>
|
||||
<y>415</y>
|
||||
<x>119</x>
|
||||
<y>343</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>201</x>
|
||||
<y>414</y>
|
||||
<x>455</x>
|
||||
<y>343</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
@ -407,8 +374,8 @@
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>452</x>
|
||||
<y>505</y>
|
||||
<x>461</x>
|
||||
<y>486</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>508</x>
|
||||
@ -416,5 +383,37 @@
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>chkSourceSrid</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>widgetSourceSrid</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>134</x>
|
||||
<y>281</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>357</x>
|
||||
<y>281</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>chkTargetSrid</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>widgetTargetSrid</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>134</x>
|
||||
<y>307</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>357</x>
|
||||
<y>307</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
Loading…
x
Reference in New Issue
Block a user