DND modules test
This commit is contained in:
@@ -38,17 +38,43 @@ class FittingView(d.Display):
|
|||||||
"Max range",
|
"Max range",
|
||||||
"Module Ammo"]
|
"Module Ammo"]
|
||||||
|
|
||||||
|
class FittingViewDrop(wx.PyDropTarget):
|
||||||
|
def __init__(self, dropFn):
|
||||||
|
wx.PyDropTarget.__init__(self)
|
||||||
|
self.dropFn = dropFn
|
||||||
|
# this is really transferring an EvE itemID
|
||||||
|
self.dropData = wx.PyTextDataObject()
|
||||||
|
self.SetDataObject(self.dropData)
|
||||||
|
|
||||||
|
def OnData(self, x, y, t):
|
||||||
|
if self.GetData():
|
||||||
|
self.dropFn(x, y, int(self.dropData.GetText()))
|
||||||
|
return t
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
d.Display.__init__(self, parent)
|
d.Display.__init__(self, parent)
|
||||||
self.mainFrame.Bind(FIT_CHANGED, self.fitChanged)
|
self.mainFrame.Bind(FIT_CHANGED, self.fitChanged)
|
||||||
self.Bind(wx.EVT_LEFT_DCLICK, self.removeItem)
|
self.Bind(wx.EVT_LEFT_DCLICK, self.removeItem)
|
||||||
|
self.Bind(wx.EVT_LIST_BEGIN_DRAG, self.startDrag)
|
||||||
if "__WXGTK__" in wx.PlatformInfo:
|
if "__WXGTK__" in wx.PlatformInfo:
|
||||||
self.Bind(wx.EVT_RIGHT_UP, self.scheduleMenu)
|
self.Bind(wx.EVT_RIGHT_UP, self.scheduleMenu)
|
||||||
else:
|
else:
|
||||||
self.Bind(wx.EVT_RIGHT_DOWN, self.scheduleMenu)
|
self.Bind(wx.EVT_RIGHT_DOWN, self.scheduleMenu)
|
||||||
|
|
||||||
|
self.SetDropTarget(self.FittingViewDrop(self.swapItems))
|
||||||
self.activeFitID = None
|
self.activeFitID = None
|
||||||
|
|
||||||
|
def startDrag(self, event):
|
||||||
|
data = wx.PyTextDataObject()
|
||||||
|
row = event.GetIndex()
|
||||||
|
data.SetText(str(self.GetItemData(row)))
|
||||||
|
|
||||||
|
dropSource = wx.DropSource(self)
|
||||||
|
dropSource.SetData(data)
|
||||||
|
res = dropSource.DoDragDrop()
|
||||||
|
|
||||||
|
# We always copy drag
|
||||||
|
|
||||||
self.Bind(wx.EVT_KEY_UP, self.kbEvent)
|
self.Bind(wx.EVT_KEY_UP, self.kbEvent)
|
||||||
|
|
||||||
def kbEvent(self,event):
|
def kbEvent(self,event):
|
||||||
@@ -104,6 +130,24 @@ class FittingView(d.Display):
|
|||||||
if populate: self.slotsChanged()
|
if populate: self.slotsChanged()
|
||||||
wx.PostEvent(self.mainFrame, FitChanged(fitID=self.activeFitID))
|
wx.PostEvent(self.mainFrame, FitChanged(fitID=self.activeFitID))
|
||||||
|
|
||||||
|
def swapItems(self, x, y, itemID):
|
||||||
|
|
||||||
|
srcRow = self.FindItemData(-1,itemID)
|
||||||
|
dstRow, _ = self.HitTest((x, y))
|
||||||
|
if srcRow != -1 and dstRow != -1:
|
||||||
|
cFit = service.Fit.getInstance()
|
||||||
|
# populate = cFit.swapModules(self.activeFitID, self.mods[self.GetItemData(srcRow)].position, self.mods[self.GetItemData(dstRow)].position)
|
||||||
|
# cFit.swapModules(self.GetItemData(srcRow), self.GetItemData(dstRow))
|
||||||
|
src = self.mods[self.GetItemData(srcRow)].position
|
||||||
|
dest = self.mods[self.GetItemData(dstRow)].position
|
||||||
|
self.mods[self.GetItemData(dstRow)].position = src
|
||||||
|
self.mods[self.GetItemData(srcRow)].position = dest
|
||||||
|
|
||||||
|
# if populate is not None:
|
||||||
|
self.slotsChanged()
|
||||||
|
wx.PostEvent(self.mainFrame, FitChanged(fitID=self.activeFitID))
|
||||||
|
|
||||||
|
|
||||||
def generateMods(self):
|
def generateMods(self):
|
||||||
cFit = service.Fit.getInstance()
|
cFit = service.Fit.getInstance()
|
||||||
fit = cFit.getFit(self.activeFitID)
|
fit = cFit.getFit(self.activeFitID)
|
||||||
|
|||||||
@@ -180,6 +180,19 @@ class Fit(object):
|
|||||||
eos.db.commit()
|
eos.db.commit()
|
||||||
return numSlots != len(fit.modules)
|
return numSlots != len(fit.modules)
|
||||||
|
|
||||||
|
def swapModules(self, position1, position2):
|
||||||
|
return True
|
||||||
|
fit = eos.db.getFit(fitID)
|
||||||
|
if fit.modules[position1].isEmpty or fit.modules[position2].isEmpty:
|
||||||
|
return None
|
||||||
|
|
||||||
|
# fit.modules[position1], fit.modules[position2] = fit.modules[position2], fit.modules[position1]
|
||||||
|
fit.modules[position1].position = position2
|
||||||
|
fit.modules[position2].position = position1
|
||||||
|
print position1,position2
|
||||||
|
eos.db.commit()
|
||||||
|
return True
|
||||||
|
|
||||||
def addDrone(self, fitID, itemID):
|
def addDrone(self, fitID, itemID):
|
||||||
if fitID == None:
|
if fitID == None:
|
||||||
return False
|
return False
|
||||||
|
|||||||
Reference in New Issue
Block a user