Added support for backing up fittings.

This uses the standard EvE XML fitting format.
This commit is contained in:
Lucas Thode
2010-10-26 08:47:12 -05:00
parent 6404d3252b
commit 10f779fa96
4 changed files with 28 additions and 1 deletions

2
eos

Submodule eos updated: dd3cadec0f...86eaf2caf0

View File

@@ -183,6 +183,8 @@ class MainFrame(wx.Frame):
self.Bind(wx.EVT_MENU, self.showExportDialog, id=wx.ID_SAVEAS) self.Bind(wx.EVT_MENU, self.showExportDialog, id=wx.ID_SAVEAS)
# Import from Clipboard # Import from Clipboard
self.Bind(wx.EVT_MENU, self.importFromClipboard, id=wx.ID_PASTE) 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 # Preference dialog
self.Bind(wx.EVT_MENU, self.showPreferenceDialog, id=wx.ID_PREFERENCES) self.Bind(wx.EVT_MENU, self.showPreferenceDialog, id=wx.ID_PREFERENCES)
@@ -228,6 +230,21 @@ class MainFrame(wx.Frame):
clip.Close() clip.Close()
return None 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): def toggleShipBrowser(self, event):
self.GetToolBar().toggleShipBrowser(event) self.GetToolBar().toggleShipBrowser(event)

View File

@@ -26,12 +26,14 @@ class MainMenuBar(wx.MenuBar):
def __init__(self): def __init__(self):
self.characterEditorId = wx.NewId() self.characterEditorId = wx.NewId()
self.damagePatternEditorId = wx.NewId() self.damagePatternEditorId = wx.NewId()
self.backupFitsId = wx.NewId()
wx.MenuBar.__init__(self) wx.MenuBar.__init__(self)
# File menu # File menu
fileMenu = wx.Menu() fileMenu = wx.Menu()
self.Append(fileMenu, "&File") self.Append(fileMenu, "&File")
fileMenu.Append(self.backupFitsId, "&Backup fits", "Backup all fittings to a XML file")
if 'wxMSW' in wx.PlatformInfo: if 'wxMSW' in wx.PlatformInfo:
fileMenu.Append(wx.ID_CLOSE, "&Close\tCTRL+W", "Close the currently open fit") fileMenu.Append(wx.ID_CLOSE, "&Close\tCTRL+W", "Close the currently open fit")
else: else:

View File

@@ -32,6 +32,14 @@ class Fit(object):
return cls.instance 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): def getFitsWithShip(self, id):
fits = eos.db.getFitsWithShip(id) fits = eos.db.getFitsWithShip(id)