Skip to content

Commit

Permalink
Refs #9077 Refactored save check code
Browse files Browse the repository at this point in the history
Some of the save check code has now been refeactored into a separate method. One check messages couldn't be refactored as it's asking a different question.
  • Loading branch information
keithnbrown committed Feb 24, 2014
1 parent 57030f8 commit 03c7ab5
Showing 1 changed file with 15 additions and 21 deletions.
36 changes: 15 additions & 21 deletions Code/Mantid/scripts/Interface/ui/reflectometer/refl_gui.py
Expand Up @@ -116,20 +116,23 @@ def setupUi(self, windowRefl):
self.initTable()
self.populateList()
self.connectSlots()


def savecheck(self):
msgBox = QtGui.QMessageBox()
msgBox.setText("The table has been modified. Do you want to save your changes?")
msgBox.setStandardButtons(QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard | QtGui.QMessageBox.Cancel)
msgBox.setIcon(QtGui.QMessageBox.Question)
msgBox.setDefaultButton(QtGui.QMessageBox.Save)
msgBox.setEscapeButton(QtGui.QMessageBox.Cancel)
ret = msgBox.exec_()
if ret == QtGui.QMessageBox.Save:
self.save()
return ret

def initTable(self):
#first check if the table has been changed before clearing it
if self.windowRefl.modFlag:
msgBox = QtGui.QMessageBox()
msgBox.setText("The table has been modified. Do you want to save your changes?")
msgBox.setStandardButtons(QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard | QtGui.QMessageBox.Cancel)
msgBox.setIcon(QtGui.QMessageBox.Question)
msgBox.setDefaultButton(QtGui.QMessageBox.Save)
msgBox.setEscapeButton(QtGui.QMessageBox.Cancel)
ret = msgBox.exec_()
if ret == QtGui.QMessageBox.Save:
self.save()
elif ret == QtGui.QMessageBox.Cancel:
if self.savecheck() == QtGui.QMessageBox.Cancel:
return
self.currentTable = None
self.accMethod = None
Expand Down Expand Up @@ -553,16 +556,7 @@ def loadTable(self):
try:
#before loading make sure you give them a chance to save
if self.windowRefl.modFlag:
msgBox = QtGui.QMessageBox()
msgBox.setText("The table has been modified. Do you want to save your changes?")
msgBox.setStandardButtons(QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard | QtGui.QMessageBox.Cancel)
msgBox.setIcon(QtGui.QMessageBox.Question)
msgBox.setDefaultButton(QtGui.QMessageBox.Save)
msgBox.setEscapeButton(QtGui.QMessageBox.Cancel)
ret = msgBox.exec_()
if ret == QtGui.QMessageBox.Save:
self.save()
elif ret == QtGui.QMessageBox.Cancel:
if self.savecheck() == QtGui.QMessageBox.Cancel:
#if they hit cancel abort the load
self.loading = False
return
Expand Down

0 comments on commit 03c7ab5

Please sign in to comment.