Skip to content
Snippets Groups Projects
Commit e219ba43 authored by Alan De Smet's avatar Alan De Smet
Browse files

when gui loads a file, guess at default variable

If we had a file open in that "slot" (A or B) already, and the selected variable name is also present in the new file, pick that.
If that doesn't work, check to see if the selected variable name in the other file (B or A) is present, and if so pick that.
Otherwise stick with the existing default: the first item.

This should speed things up a little bit when bouncing between files, as the variable the user is most likely interested will already be selected.
parent ae766fa0
No related branches found
No related tags found
No related merge requests found
......@@ -252,7 +252,7 @@ class GlanceGUIView (QtGui.QWidget) :
variableSelection = QtGui.QComboBox()
variableSelection.setDisabled(True)
variableSelection.currentIndexChanged.connect(partial(self.reportVariableSelected, file_prefix=file_prefix))
variableSelection.lastSelected = None
variableSelection.lastSelected = "InvalidStringThatShouldNeverExist"
self.widgetInfo[file_prefix]['variable'] = variableSelection
grid_layout.addWidget(variableSelection, currentRow, 2, 1, 3)
......@@ -891,13 +891,32 @@ class GlanceGUIView (QtGui.QWidget) :
# if we got a new variable list, set up the appropriate drop down list
if variable_list is not None :
# Cache now, because clear/addItems will change it as a side effect
last_selected = self.widgetInfo[file_prefix]['variable'].lastSelected
# set up the list of selectable variables for analysis
self.widgetInfo[file_prefix]['variable'].clear()
self.widgetInfo[file_prefix]['variable'].addItems(variable_list)
# If the new file has the same variable name we were just
# displaying, default to it.
i = self.widgetInfo[file_prefix]['variable'].findText(last_selected)
if i != -1:
selected_variable = last_selected
else:
# That didn't work? Well, can we find a variable name
# matching what the other field is displaying?
if file_prefix == A_CONST: other = B_CONST
else: other = A_CONST
other_string = self.widgetInfo[other]['variable'].currentText()
i = self.widgetInfo[file_prefix]['variable'].findText(other_string)
if i != -1:
selected_variable = last_selected
# set the selected variable
tempPosition = self.widgetInfo[file_prefix]['variable'].findText(selected_variable)
self.widgetInfo[file_prefix]['variable'].setCurrentIndex(tempPosition)
self.widgetInfo[file_prefix]['variable'].lastSelected = selected_variable
# set the override
self.widgetInfo[file_prefix]['override'].setChecked(use_fill_override)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment