Skip to content
Permalink
Browse files

Add "import only selected features" option to db manager

  • Loading branch information
Augustin authored and m-kuhn committed Sep 9, 2015
1 parent 5f19dff commit 2a5f262beb2911774c078781b60223e121b24a6f
Showing with 16 additions and 7 deletions.
  1. +9 −7 python/plugins/db_manager/dlg_import_vector.py
  2. +7 −0 python/plugins/db_manager/ui/DlgImportVector.ui
@@ -69,7 +69,7 @@ def setupWorkingMode(self, mode):
QObject.connect(self.btnChooseInputFile, SIGNAL("clicked()"), self.chooseInputFile)
# QObject.connect( self.cboInputLayer.lineEdit(), SIGNAL("editingFinished()"), self.updateInputLayer )
QObject.connect(self.cboInputLayer, SIGNAL("editTextChanged(const QString &)"), self.inputPathChanged)
#QObject.connect( self.cboInputLayer, SIGNAL("currentIndexChanged(int)"), self.updateInputLayer )
# QObject.connect( self.cboInputLayer, SIGNAL("currentIndexChanged(int)"), self.updateInputLayer )
QObject.connect(self.btnUpdateInputLayer, SIGNAL("clicked()"), self.updateInputLayer)

self.editPrimaryKey.setText(self.default_pk)
@@ -326,12 +326,14 @@ def accept(self):
enc = self.cboEncoding.currentText()
self.inLayer.setProviderEncoding(enc)

onlySelected = self.chkSelectedFeatures.isChecked()

# do the import!
ret, errMsg = qgis.core.QgsVectorLayerImport.importLayer(self.inLayer, uri, providerName, outCrs, False,
ret, errMsg = qgis.core.QgsVectorLayerImport.importLayer(self.inLayer, uri, providerName, outCrs, onlySelected, False, options)
False, options)
except Exception as e:
ret = -1
errMsg = unicode(e)
ret=-1
errMsg=unicode(e)

finally:
# restore input layer crs and encoding
@@ -341,7 +343,7 @@ def accept(self):
QApplication.restoreOverrideCursor()

if ret != 0:
output = qgis.gui.QgsMessageViewer()
output=qgis.gui.QgsMessageViewer()
output.setTitle(self.tr("Import to database"))
output.setMessageAsPlainText(self.tr("Error %d\n%s") % (ret, errMsg))
output.showMessage()
@@ -364,7 +366,7 @@ def closeEvent(self, event):
if __name__ == '__main__':
import sys

a = QApplication(sys.argv)
dlg = DlgImportVector()
a=QApplication(sys.argv)
dlg=DlgImportVector()
dlg.show()
sys.exit(a.exec_())
@@ -62,6 +62,13 @@
</item>
<item row="1" column="0" colspan="4">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="chkSelectedFeatures">
<property name="text">
<string>Import only selected features</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">

0 comments on commit 2a5f262

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