From 8aa099d14655970d8c8d199b0005b17bab6e38be Mon Sep 17 00:00:00 2001 From: cncfanatics Date: Mon, 6 Sep 2010 11:02:43 +0200 Subject: [PATCH] Use the new save/delete/commit methods from the backend --- controller/character.py | 2 +- controller/fit.py | 23 ++++++++++------------- eos | 2 +- gui/characterEditor.py | 30 ++++++++++++++++++++++++++---- 4 files changed, 38 insertions(+), 19 deletions(-) diff --git a/controller/character.py b/controller/character.py index 81efd8e4a..ba5a460b1 100644 --- a/controller/character.py +++ b/controller/character.py @@ -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): diff --git a/controller/fit.py b/controller/fit.py index 5f409a3ab..1c09c124b 100644 --- a/controller/fit.py +++ b/controller/fit.py @@ -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 diff --git a/eos b/eos index bd22e5b14..7bf91ab2a 160000 --- a/eos +++ b/eos @@ -1 +1 @@ -Subproject commit bd22e5b149e4af425e9e5983a288a9e97c4930bd +Subproject commit 7bf91ab2a661d552a776c61a875caa3259f63c68 diff --git a/gui/characterEditor.py b/gui/characterEditor.py index c7679689b..40cfd41c0 100644 --- a/gui/characterEditor.py +++ b/gui/characterEditor.py @@ -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)