Skip to content

Commit

Permalink
Db_Manager keeps the selected columns for primary key and geometry wh…
Browse files Browse the repository at this point in the history
…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 d8deb8c
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 @@ -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
Expand Down

0 comments on commit d8deb8c

Please sign in to comment.