Skip to content

Commit

Permalink
Delete comment with NULL + Remove useless comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Ailurupoda committed Dec 26, 2018
1 parent 09a6b33 commit e7c4d80
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 44 deletions.
15 changes: 2 additions & 13 deletions python/plugins/db_manager/dlg_import_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
from qgis.gui import QgsMessageViewer
from qgis.utils import OverrideCursor

import psycopg2
from .ui.ui_DlgImportVector import Ui_DbManagerDlgImportVector as Ui_Dialog


Expand All @@ -52,7 +51,6 @@ def __init__(self, inLayer, outDb, outUri, parent=None):
self.db = outDb
self.outUri = outUri
self.setupUi(self)
print(self.db)

self.default_pk = "id"
self.default_geom = "geom"
Expand Down Expand Up @@ -82,9 +80,7 @@ def setupWorkingMode(self, mode):

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)
Expand Down Expand Up @@ -162,13 +158,6 @@ def chooseInputFile(self):

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 """
Expand Down Expand Up @@ -383,7 +372,7 @@ def accept(self):
#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()
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/db_manager/dlg_table_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def createComment(self):
#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
Expand All @@ -348,8 +348,8 @@ def createComment(self):
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
Expand Down
66 changes: 41 additions & 25 deletions python/plugins/db_manager/ui/DlgImportVector.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand All @@ -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>
Expand All @@ -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>
Expand All @@ -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>
Expand All @@ -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>
Expand All @@ -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>
Expand All @@ -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>
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/db_manager/ui/DlgTableProperties.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down Expand Up @@ -219,7 +219,7 @@
<item>
<widget class="QPushButton" name="btnAddComment">
<property name="text">
<string>Add index</string>
<string>Add comment</string>
</property>
</widget>
</item>
Expand All @@ -239,7 +239,7 @@
<item>
<widget class="QPushButton" name="btnDeleteComment">
<property name="text">
<string>Delete index</string>
<string>Delete comment</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit e7c4d80

Please sign in to comment.