Skip to content

Commit

Permalink
DBManager: avoid loading a query as layer with missing fields (fix #1…
Browse files Browse the repository at this point in the history
…1037),

restore combo style and label when multiple unique fields for view are not supported (follow 8e45da9)
  • Loading branch information
brushtyler committed Oct 22, 2015
1 parent ef8f3d3 commit 2a57b17
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions python/plugins/db_manager/dlg_sql_window.py
Expand Up @@ -61,6 +61,11 @@ def __init__(self, iface, db, parent=None):

self.defaultLayerName = 'QueryLayer'

if self.allowMultiColumnPk:
self.uniqueColumnCheck.setText(self.trUtf8("Column(s) with unique values"))
else:
self.uniqueColumnCheck.setText(self.trUtf8("Column with unique values"))

self.editSql.setFocus()
self.editSql.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
self.initCompleter()
Expand All @@ -82,15 +87,17 @@ def __init__(self, iface, db, parent=None):

self.updatePresetsCombobox()

self.uniqueCombo.setItemDelegate(QStyledItemDelegate())
self.geomCombo.setEditable(True)
self.geomCombo.lineEdit().setReadOnly(True)

self.uniqueCombo.setEditable(True)
self.uniqueCombo.lineEdit().setReadOnly(True)
self.uniqueModel = QStandardItemModel(self.uniqueCombo)
self.uniqueCombo.setModel(self.uniqueModel)
if self.allowMultiColumnPk:
self.uniqueCombo.setEditable(True)
self.uniqueCombo.lineEdit().setReadOnly(True)
self.uniqueCombo.setItemDelegate(QStyledItemDelegate())
self.uniqueModel.itemChanged.connect(self.uniqueChanged) # react to the (un)checking of an item
self.uniqueCombo.lineEdit().textChanged.connect(self.uniqueTextChanged) # there are other events that change the displayed text and some of them can not be caught directly
self.uniqueChanged

# hide the load query as layer if feature is not supported
self._loadAsLayerAvailable = self.db.connector.hasCustomQuerySupport()
Expand Down Expand Up @@ -154,6 +161,8 @@ def loadPreset(self, name):
def loadAsLayerToggled(self, checked):
self.loadAsLayerGroup.setChecked(checked)
self.loadAsLayerWidget.setVisible(checked)
if checked:
self.fillColumnCombos()

def clearSql(self):
self.editSql.clear()
Expand Down

0 comments on commit 2a57b17

Please sign in to comment.