[addresses #167] started fixing the multiple phase saving issue

This commit is contained in:
Sebastian Wehling-Benatelli 2015-08-28 16:01:42 +02:00
parent 497ca39c91
commit 1f7049691c
3 changed files with 21 additions and 7 deletions

View File

@ -405,13 +405,16 @@ class MainWindow(QMainWindow):
except OverwriteError: except OverwriteError:
msgBox = QMessageBox() msgBox = QMessageBox()
msgBox.setText("Picks have been modified!") msgBox.setText("Picks have been modified!")
msgBox.setInformativeText("Do you want to overwrite the picks and save?") msgBox.setInformativeText("Do you want to save the changes and overwrite the picks?")
msgBox.setStandardButtons(QMessageBox.Save | QMessageBox.Discard | msgBox.setDetailedText(self.getData().getPicksStr())
QMessageBox.Cancel) msgBox.setStandardButtons(QMessageBox.Save | QMessageBox.Cancel)
msgBox.setDefaultButton(QMessageBox.Save) msgBox.setDefaultButton(QMessageBox.Save)
ret = msgBox.exec_() ret = msgBox.exec_()
if ret == QMessageBox.Save: if ret == QMessageBox.Save:
print('Overwrite and Save') self.getData().resetPicks()
self.saveData()
elif ret == QMessageBox.Cancel:
return False
try: try:
self.getData().exportEvent(self.fname, exform) self.getData().exportEvent(self.fname, exform)
except FormatError: except FormatError:
@ -425,6 +428,8 @@ class MainWindow(QMainWindow):
fbasename, exform = os.path.splitext(fname[0]) fbasename, exform = os.path.splitext(fname[0])
if not fbasename: if not fbasename:
return False return False
elif not exform:
exform = fname[1].split('*')[1][:-1]
self.getData().exportEvent(fbasename, exform) self.getData().exportEvent(fbasename, exform)
return True return True

View File

@ -1 +1 @@
1abc-dirty 497c-dirty

View File

@ -52,6 +52,13 @@ class Data(object):
def __str__(self): def __str__(self):
return str(self.wfdata) return str(self.wfdata)
def getPicksStr(self):
picks_str = ''
for pick in self.getEvtData().picks:
picks_str += str(pick) + '\n'
return picks_str
def getParent(self): def getParent(self):
""" """
@ -360,9 +367,11 @@ class Data(object):
def applyPicks(picks): def applyPicks(picks):
""" """
Creates ObsPy pick objects and append it to the picks list from the
PyLoT dictionary contain all picks.
:param picks: :param picks:
:raise OverwriteError: :raise OverwriteError: raises an OverwriteError if the picks list is
not empty. The GUI will then ask for a decision.
""" """
firstonset = None firstonset = None
if self.getEvtData().picks: if self.getEvtData().picks: