Use the new save/delete/commit methods from the backend

This commit is contained in:
cncfanatics
2010-09-06 11:02:43 +02:00
parent e71004f703
commit 8aa099d146
4 changed files with 38 additions and 19 deletions

View File

@@ -32,7 +32,7 @@ class Character():
def getCharacterList(self):
baseChars = [eos.types.Character.getAll0(), eos.types.Character.getAll5()]
# Flush incase all0 & all5 weren't in the db yet
eos.db.saveddata_session.commit()
eos.db.commit()
return map(lambda c: (c.ID, c.name), eos.db.getCharacterList())
def getSkillGroups(self):

View File

@@ -44,26 +44,23 @@ class Fit(object):
fit = eos.types.Fit()
fit.ship = eos.types.Ship(eos.db.getItem(shipID))
fit.name = name
eos.db.saveddata_session.add(fit)
eos.db.saveddata_session.commit()
eos.db.save(fit)
fit.calculateModifiedAttributes()
return fit.ID
def renameFit(self, fitID, newName):
fit = eos.db.getFit(fitID)
fit.name = newName
eos.db.saveddata_session.commit()
eos.db.commit()
def deleteFit(self, fitID):
fit = eos.db.getFit(fitID)
eos.db.saveddata_session.delete(fit)
eos.db.saveddata_session.commit()
eos.db.remove(fit)
def copyFit(self, fitID):
fit = eos.db.getFit(fitID)
newFit = copy.deepcopy(fit)
eos.db.saveddata_session.add(newFit)
eos.db.saveddata_session.commit()
eos.db.save(newFit)
return newFit.ID
def getFit(self, fitID):
@@ -72,7 +69,7 @@ class Fit(object):
fit = eos.db.getFit(fitID)
fit.fill()
eos.db.saveddata_session.commit()
eos.db.commit()
return fit
def appendModule(self, fitID, itemID):
@@ -86,7 +83,7 @@ class Fit(object):
if m.fits(fit):
fit.modules.append(m)
eos.db.saveddata_session.commit()
eos.db.commit()
fit.clear()
fit.calculateModifiedAttributes()
return fit
@@ -94,7 +91,7 @@ class Fit(object):
def removeModule(self, fitID, position):
fit = eos.db.getFit(fitID)
fit.modules.toDummy(position)
eos.db.saveddata_session.commit()
eos.db.commit()
fit.clear()
fit.calculateModifiedAttributes()
return fit
@@ -112,7 +109,7 @@ class Fit(object):
fit.drones.append(d)
d.amount += 1
eos.db.saveddata_session.commit()
eos.db.commit()
fit.clear()
fit.calculateModifiedAttributes()
@@ -128,7 +125,7 @@ class Fit(object):
if d.amount == 0:
del fit.drones[i]
eos.db.saveddata_session.commit()
eos.db.commit()
fit.clear()
fit.calculateModifiedAttributes()
return fit
@@ -141,7 +138,7 @@ class Fit(object):
else:
d.amountActive = d.amount
eos.db.saveddata_session.commit()
eos.db.commit()
fit.clear()
fit.calculateModifiedAttributes()
return fit

2
eos

Submodule eos updated: bd22e5b149...7bf91ab2a6

View File

@@ -77,11 +77,12 @@ class CharacterEditor (wx.Dialog):
mainSizer.Add(self.viewsNBContainer, 1, wx.EXPAND | wx.ALL, 5)
sbSizerDescription = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, u"Description"), wx.HORIZONTAL)
self.descriptionBox = wx.StaticBox(self, wx.ID_ANY, u"Description")
sbSizerDescription = wx.StaticBoxSizer(self.descriptionBox, wx.HORIZONTAL)
self.m_staticText7 = wx.StaticText(self, wx.ID_ANY, u"Insert descriptions here", wx.DefaultPosition, wx.DefaultSize, 0)
self.m_staticText7.Wrap(-1)
sbSizerDescription.Add(self.m_staticText7, 0, wx.ALL, 5)
self.description = wx.StaticText(self, wx.ID_ANY, u"Insert descriptions here", wx.DefaultPosition, wx.DefaultSize, 0)
self.description.Wrap(-1)
sbSizerDescription.Add(self.description, 0, wx.ALL, 2)
mainSizer.Add(sbSizerDescription, 0, wx.ALL | wx.EXPAND, 5)
@@ -95,9 +96,13 @@ class CharacterEditor (wx.Dialog):
mainSizer.Add(bSizerButtons, 0, wx.ALIGN_RIGHT, 5)
self.SetSizer(mainSizer)
self.Layout()
self.description.Hide()
self.descriptionBox.Hide()
self.Centre(wx.BOTH)
self.registerEvents()
@@ -105,6 +110,7 @@ class CharacterEditor (wx.Dialog):
def registerEvents(self):
self.Bind(wx.EVT_CLOSE, self.closeEvent)
self.skillTreeChoice.Bind(wx.EVT_CHOICE, self.charChanged)
self.sview.SkillTreeCtrl.Bind(wx.EVT_TREE_SEL_CHANGED, self.updateDescription)
def closeEvent(self, event):
pass
@@ -112,6 +118,22 @@ class CharacterEditor (wx.Dialog):
def charChanged(self, event):
pass
def updateDescription(self, event):
root = event.Item
tree = self.sview.SkillTreeCtrl
if tree.GetChildrenCount(root) == 0:
cChar = controller.Character.getInstance()
self.description.SetLabel(cChar.getDescription(tree.GetPyData(root)))
self.description.Wrap(620)
self.description.Show()
self.descriptionBox.Show()
else:
self.description.Hide()
self.descriptionBox.Hide()
self.Layout()
class NewCharacter (wx.Dialog):
def __init__(self, parent):
wx.Dialog.__init__ (self, parent, id=wx.ID_ANY, title=u"Create new character", pos=wx.DefaultPosition, size=wx.Size(344, 89), style=wx.DEFAULT_DIALOG_STYLE)