Skip to content
Permalink
Browse files

DBManager: avoid loading a query as layer with missing fields (fix #1…

…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 2a57b170685a45cb939457933b1474ac02d78ee5
Showing with 13 additions and 4 deletions.
  1. +13 −4 python/plugins/db_manager/dlg_sql_window.py
@@ -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()
@@ -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()
@@ -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()

0 comments on commit 2a57b17

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