Navigation Menu

Skip to content

Commit

Permalink
[dbmanager] Try to set sensible default column choice for sql window
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 15, 2014
1 parent 3bf6f3e commit 4e3510e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions python/plugins/db_manager/dlg_sql_window.py
Expand Up @@ -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):
Expand Down

0 comments on commit 4e3510e

Please sign in to comment.