From e7c4d8009c52fd412d9c7b31a08b16b28936ca72 Mon Sep 17 00:00:00 2001 From: ailurupoda Date: Wed, 26 Dec 2018 11:06:59 +0100 Subject: [PATCH] Delete comment with NULL + Remove useless comment --- .../plugins/db_manager/dlg_import_vector.py | 15 +---- .../db_manager/dlg_table_properties.py | 6 +- .../plugins/db_manager/ui/DlgImportVector.ui | 66 ++++++++++++------- .../db_manager/ui/DlgTableProperties.ui | 6 +- 4 files changed, 49 insertions(+), 44 deletions(-) diff --git a/python/plugins/db_manager/dlg_import_vector.py b/python/plugins/db_manager/dlg_import_vector.py index 954cda949c9..80c8a0385e7 100644 --- a/python/plugins/db_manager/dlg_import_vector.py +++ b/python/plugins/db_manager/dlg_import_vector.py @@ -39,7 +39,6 @@ from qgis.core import (QgsDataSourceUri, from qgis.gui import QgsMessageViewer from qgis.utils import OverrideCursor -import psycopg2 from .ui.ui_DlgImportVector import Ui_DbManagerDlgImportVector as Ui_Dialog @@ -52,7 +51,6 @@ class DlgImportVector(QDialog, Ui_Dialog): self.db = outDb self.outUri = outUri self.setupUi(self) - print(self.db) self.default_pk = "id" self.default_geom = "geom" @@ -82,9 +80,7 @@ class DlgImportVector(QDialog, Ui_Dialog): if mode == self.ASK_FOR_INPUT_MODE: self.btnChooseInputFile.clicked.connect(self.chooseInputFile) - # self.cboInputLayer.lineEdit().editingFinished.connect(self.updateInputLayer) - self.cboInputLayer.editTextChanged.connect(self.inputPathChanged) - # self.cboInputLayer.currentIndexChanged.connect(self.updateInputLayer) + self.cboInputLayer.currentTextChanged.connect(self.updateInputLayer) self.btnUpdateInputLayer.clicked.connect(self.updateInputLayer) self.editPrimaryKey.setText(self.default_pk) @@ -162,13 +158,6 @@ class DlgImportVector(QDialog, Ui_Dialog): self.cboInputLayer.setEditText(filename) - def inputPathChanged(self, path): - if self.cboInputLayer.currentIndex() < 0: - return - self.cboInputLayer.blockSignals(True) - self.cboInputLayer.setCurrentIndex(-1) - self.cboInputLayer.setEditText(path) - self.cboInputLayer.blockSignals(False) def reloadInputLayer(self): """ create the input layer and update available options """ @@ -383,7 +372,7 @@ class DlgImportVector(QDialog, Ui_Dialog): #Add comment on table if self.chkCom.isEnabled() and self.chkCom.isChecked(): #Using connector executing COMMENT ON TABLE query (with editCome.text() value) - self.db.connector._execute(None, 'COMMENT ON TABLE "{0}"."{1}" IS E\'{2}E\' '.format(schema, table ,self.editCom.text())) + self.db.connector._execute(None, 'COMMENT ON TABLE "{0}"."{1}" IS E\'{2}E\''.format(schema, table ,self.editCom.text())) self.db.connection().reconnect() self.db.refresh() diff --git a/python/plugins/db_manager/dlg_table_properties.py b/python/plugins/db_manager/dlg_table_properties.py index f3a385897a6..1e512d4de05 100644 --- a/python/plugins/db_manager/dlg_table_properties.py +++ b/python/plugins/db_manager/dlg_table_properties.py @@ -336,7 +336,7 @@ class DlgTableProperties(QDialog, Ui_Dialog): #Function that add a comment to the selected table try: #Using the db connector, executing de SQL query Comment on table - self.db.connector._execute(None, 'COMMENT ON TABLE "{0}"."{1}" IS E\'{2}\' '.format(self.table.schema().name, self.table.name ,self.viewComment.text())) + self.db.connector._execute(None, 'COMMENT ON TABLE "{0}"."{1}" IS E\'{2}\';'.format(self.table.schema().name, self.table.name ,self.viewComment.text())) except DbError as e: DlgDbError.showError(e, self) return @@ -348,8 +348,8 @@ class DlgTableProperties(QDialog, Ui_Dialog): def deleteComment(self): #Function that drop the comment to the selected table try: - #Using the db connector, executing de SQL query Comment on table. Comment is void '' - self.db.connector._execute(None, 'COMMENT ON TABLE "{0}"."{1}" IS E\'\' '.format(self.table.schema().name, self.table.name)) + #Using the db connector, executing de SQL query Comment on table using the NULL definition + self.db.connector._execute(None, 'COMMENT ON TABLE "{0}"."{1}" IS NULL;'.format(self.table.schema().name, self.table.name)) except DbError as e: DlgDbError.showError(e, self) return diff --git a/python/plugins/db_manager/ui/DlgImportVector.ui b/python/plugins/db_manager/ui/DlgImportVector.ui index a1cd308b9ef..a172377047e 100755 --- a/python/plugins/db_manager/ui/DlgImportVector.ui +++ b/python/plugins/db_manager/ui/DlgImportVector.ui @@ -262,7 +262,7 @@ - + false @@ -324,8 +324,8 @@ reject() - 334 - 486 + 343 + 617 286 @@ -340,12 +340,12 @@ setEnabled(bool) - 129 - 239 + 155 + 268 - 460 - 239 + 463 + 272 @@ -356,12 +356,12 @@ setEnabled(bool) - 141 - 265 + 167 + 306 - 442 - 265 + 463 + 310 @@ -372,12 +372,12 @@ setEnabled(bool) - 119 - 343 + 145 + 404 - 455 - 343 + 463 + 406 @@ -388,8 +388,8 @@ accept() - 461 - 486 + 470 + 617 508 @@ -404,12 +404,12 @@ setEnabled(bool) - 134 - 281 + 160 + 341 - 357 - 281 + 463 + 341 @@ -420,12 +420,28 @@ setEnabled(bool) - 134 - 307 + 160 + 372 - 357 - 307 + 463 + 372 + + + + + chkCom + toggled(bool) + editComment + setEnabled(bool) + + + 64 + 549 + + + 215 + 552 diff --git a/python/plugins/db_manager/ui/DlgTableProperties.ui b/python/plugins/db_manager/ui/DlgTableProperties.ui index 3cfa9ebc955..38cc29d2479 100755 --- a/python/plugins/db_manager/ui/DlgTableProperties.ui +++ b/python/plugins/db_manager/ui/DlgTableProperties.ui @@ -17,7 +17,7 @@ - 3 + 0 @@ -219,7 +219,7 @@ - Add index + Add comment @@ -239,7 +239,7 @@ - Delete index + Delete comment