Delete comment with NULL + Remove useless comment

This commit is contained in:
ailurupoda 2018-12-26 11:06:59 +01:00
parent 09a6b33a32
commit e7c4d8009c
4 changed files with 49 additions and 44 deletions

View File

@ -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()

View File

@ -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

View File

@ -262,7 +262,7 @@
</widget>
</item>
<item row="10" column="1">
<widget class="QLineEdit" name="editCom">
<widget class="QLineEdit" name="editComment">
<property name="enabled">
<bool>false</bool>
</property>
@ -324,8 +324,8 @@
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>334</x>
<y>486</y>
<x>343</x>
<y>617</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
@ -340,12 +340,12 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>129</x>
<y>239</y>
<x>155</x>
<y>268</y>
</hint>
<hint type="destinationlabel">
<x>460</x>
<y>239</y>
<x>463</x>
<y>272</y>
</hint>
</hints>
</connection>
@ -356,12 +356,12 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>141</x>
<y>265</y>
<x>167</x>
<y>306</y>
</hint>
<hint type="destinationlabel">
<x>442</x>
<y>265</y>
<x>463</x>
<y>310</y>
</hint>
</hints>
</connection>
@ -372,12 +372,12 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>119</x>
<y>343</y>
<x>145</x>
<y>404</y>
</hint>
<hint type="destinationlabel">
<x>455</x>
<y>343</y>
<x>463</x>
<y>406</y>
</hint>
</hints>
</connection>
@ -388,8 +388,8 @@
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>461</x>
<y>486</y>
<x>470</x>
<y>617</y>
</hint>
<hint type="destinationlabel">
<x>508</x>
@ -404,12 +404,12 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>134</x>
<y>281</y>
<x>160</x>
<y>341</y>
</hint>
<hint type="destinationlabel">
<x>357</x>
<y>281</y>
<x>463</x>
<y>341</y>
</hint>
</hints>
</connection>
@ -420,12 +420,28 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>134</x>
<y>307</y>
<x>160</x>
<y>372</y>
</hint>
<hint type="destinationlabel">
<x>357</x>
<y>307</y>
<x>463</x>
<y>372</y>
</hint>
</hints>
</connection>
<connection>
<sender>chkCom</sender>
<signal>toggled(bool)</signal>
<receiver>editComment</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>64</x>
<y>549</y>
</hint>
<hint type="destinationlabel">
<x>215</x>
<y>552</y>
</hint>
</hints>
</connection>

View File

@ -17,7 +17,7 @@
<item>
<widget class="QTabWidget" name="tabs">
<property name="currentIndex">
<number>3</number>
<number>0</number>
</property>
<widget class="QWidget" name="tabColumns">
<attribute name="title">
@ -219,7 +219,7 @@
<item>
<widget class="QPushButton" name="btnAddComment">
<property name="text">
<string>Add index</string>
<string>Add comment</string>
</property>
</widget>
</item>
@ -239,7 +239,7 @@
<item>
<widget class="QPushButton" name="btnDeleteComment">
<property name="text">
<string>Delete index</string>
<string>Delete comment</string>
</property>
</widget>
</item>