diff --git a/eos b/eos index dd3cadec0..86eaf2caf 160000 --- a/eos +++ b/eos @@ -1 +1 @@ -Subproject commit dd3cadec0f0320c22bce42867f18b4a98c931f89 +Subproject commit 86eaf2caf0d7ea508ff039e3e6d5fb53962a1580 diff --git a/gui/mainFrame.py b/gui/mainFrame.py index f69109ad0..08508a79a 100644 --- a/gui/mainFrame.py +++ b/gui/mainFrame.py @@ -183,6 +183,8 @@ class MainFrame(wx.Frame): self.Bind(wx.EVT_MENU, self.showExportDialog, id=wx.ID_SAVEAS) # Import from Clipboard self.Bind(wx.EVT_MENU, self.importFromClipboard, id=wx.ID_PASTE) + # Backup fits + self.Bind(wx.EVT_MENU, self.backupToXml, id=menuBar.backupFitsId) # Preference dialog self.Bind(wx.EVT_MENU, self.showPreferenceDialog, id=wx.ID_PREFERENCES) @@ -227,6 +229,21 @@ class MainFrame(wx.Frame): else: clip.Close() return None + + def backupToXml(self, event): + sFit = service.Fit.getInstance() + saveDialog = wx.FileDialog( + self, + "Choose where to save the backup: ", + wildcard = "EvE XML fitting file (*.xml)|*.xml", + style = wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) + if (saveDialog.ShowModal() == wx.ID_OK): + filePath = saveDialog.GetPath() + allFits = map(lambda x: x[0], sFit.getAllFits()) + backedUpFits = sFit.exportXml(*allFits) + backupFile = open(filePath, "w") + backupFile.write(backedUpFits) + backupFile.close() def toggleShipBrowser(self, event): self.GetToolBar().toggleShipBrowser(event) diff --git a/gui/mainMenuBar.py b/gui/mainMenuBar.py index 134390867..f69a27736 100644 --- a/gui/mainMenuBar.py +++ b/gui/mainMenuBar.py @@ -26,12 +26,14 @@ class MainMenuBar(wx.MenuBar): def __init__(self): self.characterEditorId = wx.NewId() self.damagePatternEditorId = wx.NewId() + self.backupFitsId = wx.NewId() wx.MenuBar.__init__(self) # File menu fileMenu = wx.Menu() self.Append(fileMenu, "&File") + fileMenu.Append(self.backupFitsId, "&Backup fits", "Backup all fittings to a XML file") if 'wxMSW' in wx.PlatformInfo: fileMenu.Append(wx.ID_CLOSE, "&Close\tCTRL+W", "Close the currently open fit") else: diff --git a/service/fit.py b/service/fit.py index f55ca07a3..7893521ce 100644 --- a/service/fit.py +++ b/service/fit.py @@ -31,6 +31,14 @@ class Fit(object): cls.instance = Fit() return cls.instance + + def getAllFits(self): + fits = eos.db.getFitList() + names = [] + for fit in fits: + names.append((fit.ID, fit.name)) + + return names def getFitsWithShip(self, id):