Initial support for import stage in shipBrowser. Few bugs, see issue #93
This commit is contained in:
@@ -42,7 +42,7 @@ from gui.additionsPane import AdditionsPane
|
||||
from gui.marketBrowser import MarketBrowser
|
||||
from gui.multiSwitch import MultiSwitch
|
||||
from gui.statsPane import StatsPane
|
||||
from gui.shipBrowser import ShipBrowser, FitSelected
|
||||
from gui.shipBrowser import ShipBrowser, FitSelected, ImportSelected, Stage3Selected
|
||||
from gui.characterEditor import CharacterEditor
|
||||
from gui.characterSelection import CharacterSelection
|
||||
from gui.patternEditor import DmgPatternEditorDlg
|
||||
@@ -540,8 +540,7 @@ class MainFrame(wx.Frame):
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
ids = tuple(fit.ID for fit in fits)
|
||||
self._openAfterImport(len(fits), ids)
|
||||
self._openAfterImport(fits)
|
||||
|
||||
def exportToClipboard(self, event):
|
||||
CopySelectDict = {CopySelectDialog.copyFormatEft: self.clipboardEft,
|
||||
@@ -571,33 +570,39 @@ class MainFrame(wx.Frame):
|
||||
" "*100, # set some arbitrary spacing to create wifth in window
|
||||
parent=self, style = wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME)
|
||||
self.progressDialog.message = None
|
||||
sFit.importFitsThreaded(dlg.GetPaths(), self.importCallback)
|
||||
sFit.importFitsThreaded(dlg.GetPaths(), self.fileImportCallback)
|
||||
self.progressDialog.ShowModal()
|
||||
dlg.Destroy()
|
||||
|
||||
def importCallback(self, info):
|
||||
def fileImportCallback(self, info, fits=None):
|
||||
"""
|
||||
While importing fits from file, the logic calls back to this function to
|
||||
update progress bar to show activity. If -1, closes dialog. If None,
|
||||
simply Pulse()s progress. If there is a message to show new activity,
|
||||
overwrites cached message and updates dialog
|
||||
update progress bar to show activity. XML files can contain multiple
|
||||
ships with multiple fits, whereas EFT cfg files contain many fits of
|
||||
a single ship. When iterating through the files, we update the message
|
||||
when we start a new file, and then Pulse the progress bar with every fit
|
||||
that is processed.
|
||||
"""
|
||||
|
||||
if info == -1:
|
||||
# Done processing
|
||||
self.progressDialog.Hide()
|
||||
self._openAfterImport(fits)
|
||||
elif info != self.progressDialog.message and info is not None:
|
||||
# New message, overwrite cached message and update
|
||||
self.progressDialog.message = info
|
||||
self.progressDialog.Pulse(info)
|
||||
else:
|
||||
# Simply Pulse() if we don't have anything else to do
|
||||
self.progressDialog.Pulse()
|
||||
|
||||
# @todo: modify _openAfterImport
|
||||
#self._openAfterImport(len(fits), IDs)
|
||||
|
||||
def _openAfterImport(self, importCount, fitIDs):
|
||||
if importCount == 1:
|
||||
wx.PostEvent(self, FitSelected(fitID=fitIDs[0]))
|
||||
|
||||
self.shipBrowser.RefreshContent()
|
||||
def _openAfterImport(self, fits):
|
||||
if len(fits) > 0:
|
||||
if len(fits) == 1:
|
||||
wx.PostEvent(self, FitSelected(fitID=fits[0].ID))
|
||||
wx.PostEvent(self.shipBrowser, Stage3Selected(shipID=fits[0].shipID, back=False))
|
||||
else:
|
||||
wx.PostEvent(self.shipBrowser, ImportSelected(fits=fits, back=False))
|
||||
|
||||
def backupToXml(self, event):
|
||||
""" Back up all fits to EVE XML file """
|
||||
|
||||
@@ -29,6 +29,7 @@ Stage1Selected, EVT_SB_STAGE1_SEL = wx.lib.newevent.NewEvent()
|
||||
Stage2Selected, EVT_SB_STAGE2_SEL = wx.lib.newevent.NewEvent()
|
||||
Stage3Selected, EVT_SB_STAGE3_SEL = wx.lib.newevent.NewEvent()
|
||||
SearchSelected, EVT_SB_SEARCH_SEL = wx.lib.newevent.NewEvent()
|
||||
ImportSelected, EVT_SB_IMPORT_SEL = wx.lib.newevent.NewEvent()
|
||||
|
||||
class PFWidgetsContainer(PFListPane):
|
||||
def __init__(self,parent):
|
||||
@@ -607,6 +608,7 @@ class ShipBrowser(wx.Panel):
|
||||
self.Bind(EVT_SB_STAGE1_SEL, self.stage1)
|
||||
self.Bind(EVT_SB_STAGE3_SEL, self.stage3)
|
||||
self.Bind(EVT_SB_SEARCH_SEL, self.searchStage)
|
||||
self.Bind(EVT_SB_IMPORT_SEL, self.importStage)
|
||||
|
||||
self.mainFrame.Bind(GE.FIT_CHANGED, self.RefreshList)
|
||||
|
||||
@@ -867,11 +869,11 @@ class ShipBrowser(wx.Panel):
|
||||
self.navpanel.ShowSwitchEmptyGroupsButton(False)
|
||||
|
||||
if not event.back:
|
||||
if self._activeStage !=4:
|
||||
if len(self.browseHist) >0:
|
||||
self.browseHist.append( (self._activeStage, self.lastdata) )
|
||||
if self._activeStage != 4:
|
||||
if len(self.browseHist) > 0:
|
||||
self.browseHist.append((self._activeStage, self.lastdata))
|
||||
else:
|
||||
self.browseHist.append((1,0))
|
||||
self.browseHist.append((1, 0))
|
||||
self._lastStage = self._activeStage
|
||||
self._activeStage = 4
|
||||
|
||||
@@ -902,6 +904,44 @@ class ShipBrowser(wx.Panel):
|
||||
self.raceselect.Show(False)
|
||||
self.Layout()
|
||||
|
||||
def importStage(self, event):
|
||||
self.lpane.ShowLoading(False)
|
||||
|
||||
self.navpanel.ShowNewFitButton(False)
|
||||
self.navpanel.ShowSwitchEmptyGroupsButton(False)
|
||||
|
||||
if not event.back:
|
||||
if self._activeStage != 5:
|
||||
if len(self.browseHist) > 0:
|
||||
self.browseHist.append((self._activeStage, self.lastdata))
|
||||
else:
|
||||
self.browseHist.append((1, 0))
|
||||
self._lastStage = self._activeStage
|
||||
self._activeStage = 5
|
||||
|
||||
fits = event.fits
|
||||
self.lpane.Freeze()
|
||||
self.lpane.RemoveAllChildren()
|
||||
|
||||
if fits:
|
||||
for fit in fits:
|
||||
self.lpane.AddWidget(FitItem(
|
||||
self.lpane,
|
||||
fit.ID, (
|
||||
fit.ship.item.name,
|
||||
fit.name,
|
||||
fit.booster,
|
||||
fit.timestamp),
|
||||
fit.ship.item.ID))
|
||||
self.lpane.RefreshList(doFocus=False)
|
||||
self.lpane.Thaw()
|
||||
|
||||
self.raceselect.RebuildRaces(self.RACE_ORDER)
|
||||
|
||||
if self.showRacesFilterInStage2Only:
|
||||
self.raceselect.Show(False)
|
||||
self.Layout()
|
||||
|
||||
class PFStaticText(wx.Panel):
|
||||
def __init__(self, parent, label=wx.EmptyString):
|
||||
wx.Panel.__init__ (self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size = parent.GetSize())
|
||||
|
||||
@@ -63,10 +63,10 @@ class FitImportThread(threading.Thread):
|
||||
|
||||
def run(self):
|
||||
sFit = Fit.getInstance()
|
||||
sFit.importFitFromFiles(self.paths, self.callback)
|
||||
fits = sFit.importFitFromFiles(self.paths, self.callback)
|
||||
|
||||
# Send done signal to GUI
|
||||
wx.CallAfter(self.callback, -1)
|
||||
wx.CallAfter(self.callback, -1, fits)
|
||||
|
||||
|
||||
class Fit(object):
|
||||
@@ -810,7 +810,11 @@ class Fit(object):
|
||||
eos.db.save(fit)
|
||||
IDs.append(fit.ID)
|
||||
if callback: # Pulse
|
||||
wx.CallAfter(callback, "Saving fit\n%d/%d"%(i+1, numFits))
|
||||
wx.CallAfter(
|
||||
callback,
|
||||
"Processing complete, saving fits to database\n(%d/%d)" %
|
||||
(i+1, numFits)
|
||||
)
|
||||
|
||||
return fits
|
||||
|
||||
|
||||
Reference in New Issue
Block a user