loadData changed; now uses information from the sender to evaluate the fname to read

This commit is contained in:
Sebastian Wehling-Benatelli 2014-12-01 12:37:52 +01:00
parent 9d38ed9771
commit 4acf634f8d

View File

@ -99,24 +99,46 @@ class MainWindow(QMainWindow):
action.setCheckable(True) action.setCheckable(True)
return action return action
def createMenus(self): def updateFileMenu(self):
fileMenu = self.menuBar().addMenu("&File") self.fileMenu.clear()
fileMenu.addAction(self.openEventAction) self.addActions(self.fileMenu, self.fileMenuActions[:-1])
fileMenu.addAction(self.saveEventAction) current = self.data.evtdata.getEventID()
fileMenu.addAction(self.printAction) recentEvents = []
fileMenu.addSeparator() for eventID in self.recentEvents:
fileMenu.addAction(self.quitAction) fname = fnConstructor(eventID)
if eventID != current and QFile.exists(fname):
recentEvents.append(eventID)
if recentEvents:
self.fileMenu.addSeparator()
for i, eventID in enumerate(recentEvents):
fname = fnConstructor(eventID)
action = QAction(QIcon(":/icon.png"),
"&{0} {1}".format(i + 1,
QFileInfo(fname).fileName()),
self)
action.setData(fname)
self.connect(action, SIGNAL("triggered()"),
self.loadData)
self.fileMenu.addAction(action)
self.fileMenu.addSeparator()
self.fileMenu.addAction(self.fileMenuActions[-1])
editMenu = self.menuBar().addMenu("&Edit")
editMenu.addAction(self.filterAction)
editMenu.addAction(self.filterEditAction)
editMenu.addSeparator()
editMenu.addAction(self.selectPAction)
editMenu.addAction(self.selectSAction)
def loadData(self): def loadData(self, fname=None):
self.data = None if fname is None:
action = self.sender()
if isinstance(action, QAction):
if action.data() is None:
fname = QFileDialog()
else:
fname = unicode(action.data().toString())
if not self.okToContinue():
return
else:
return
if fname:
self.data = Data(evtdata=fname)
def saveData(self): def saveData(self):
pass pass