Skip to content
Permalink
Browse files

[dbmanager] Try to set sensible default column choice for sql window

  • Loading branch information
nyalldawson committed Sep 15, 2014
1 parent 3bf6f3e commit 4e3510edec9310535d776c3803e9fd8ea8674377
Showing with 20 additions and 0 deletions.
  1. +20 −0 python/plugins/db_manager/dlg_sql_window.py
@@ -244,11 +244,31 @@ def fillColumnCombos(self):
if c:
c.close()
del c

# get sensible default columns. do this before sorting in case there's hints in the column order (eg, id is more likely to be first)
try:
defaultGeomCol = next(col for col in cols if col in ['geom','geometry','the_geom'])
except:
defaultGeomCol = None
try:
defaultUniqueCol = [col for col in cols if 'id' in col][0]
except:
defaultUniqueCol = None

cols.sort()
self.uniqueCombo.addItems( cols )
self.geomCombo.addItems( cols )

# set sensible default columns
try:
self.geomCombo.setCurrentIndex( cols.index(defaultGeomCol) )
except:
pass
try:
self.uniqueCombo.setCurrentIndex( cols.index(defaultUniqueCol) )
except:
pass

QApplication.restoreOverrideCursor()

def copySelectedResults(self):

0 comments on commit 4e3510e

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