Skip to content
Permalink
Browse files

Db_Manager keeps the selected columns for primary key and geometry wh…

…en running the query or rereading the columns if the selected columns still exist.
  • Loading branch information
SebDieBln committed Oct 17, 2015
1 parent 724a5bd commit d8deb8c081d0b37d8079e063d0facda66498e7b2
Showing with 13 additions and 4 deletions.
  1. +13 −4 python/plugins/db_manager/dlg_sql_window.py
@@ -309,29 +309,38 @@ def setColumnCombos(self, cols, quotedCols):
colNames = zip(cols, quotedCols)
colNames.sort()
newItems = []
uniqueIsFilled = False
for (col, quotedCol) in colNames:
item = QStandardItem(col)
item.setData(quotedCol)
item.setEnabled(True)
item.setCheckable(True)
item.setSelectable(False)
item.setCheckState(Qt.Unchecked)
matchingItems = self.uniqueModel.findItems(col)
if matchingItems:
item.setCheckState(matchingItems[0].checkState())
uniqueIsFilled = uniqueIsFilled or matchingItems[0].checkState() == Qt.Checked
else:
item.setCheckState(Qt.Unchecked)
newItems.append(item)
self.uniqueModel.clear()
self.uniqueModel.appendColumn(newItems)
self.uniqueChanged()

oldGeometryColumn = self.geomCombo.currentText()
self.geomCombo.clear()
self.geomCombo.addItems(cols)
self.geomCombo.setCurrentIndex(self.geomCombo.findText(oldGeometryColumn, Qt.MatchExactly))

# set sensible default columns
# set sensible default columns if the columns are not already set
try:
self.geomCombo.setCurrentIndex(cols.index(defaultGeomCol))
if self.geomCombo.currentIndex() == -1:
self.geomCombo.setCurrentIndex(cols.index(defaultGeomCol))
except:
pass
try:
items = self.uniqueModel.findItems(defaultUniqueCol)
if items:
if items and not uniqueIsFilled:
items[0].setCheckState(Qt.Checked)
except:
pass

0 comments on commit d8deb8c

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