Fill window with actual data

This commit is contained in:
DarkPhoenix
2019-08-01 08:38:45 +03:00
parent 6d50f03396
commit 0f0e544f54
5 changed files with 52 additions and 8 deletions

View File

@@ -24,7 +24,7 @@ from sqlalchemy import desc, select
from sqlalchemy import func
from eos.db import saveddata_session, sd_lock
from eos.db.saveddata.fit import projectedFits_table
from eos.db.saveddata.fit import fits_table, projectedFits_table
from eos.db.util import processEager, processWhere
from eos.saveddata.price import Price
from eos.saveddata.user import User
@@ -33,7 +33,7 @@ from eos.saveddata.damagePattern import DamagePattern
from eos.saveddata.targetProfile import TargetProfile
from eos.saveddata.character import Character
from eos.saveddata.implantSet import ImplantSet
from eos.saveddata.fit import Fit
from eos.saveddata.fit import Fit, FitLite
from eos.saveddata.module import Module
from eos.saveddata.miscData import MiscData
from eos.saveddata.override import Override
@@ -326,6 +326,17 @@ def getFitList(eager=None):
return fits
def getFitListLite():
with sd_lock:
stmt = select([fits_table.c.ID, fits_table.c.name, fits_table.c.shipID])
data = eos.db.saveddata_session.execute(stmt).fetchall()
fits = []
for fitID, fitName, shipID in data:
fit = FitLite(id=fitID, name=fitName, shipID=shipID)
fits.append(fit)
return fits
@cachedQuery(Price, 1, "typeID")
def getPrice(typeID):
if isinstance(typeID, int):

View File

@@ -42,6 +42,18 @@ from eos.utils.stats import DmgTypes
pyfalog = Logger(__name__)
class FitLite:
def __init__(self, id=None, name=None, shipID=None, shipName=None):
self.ID = id
self.name = name
self.shipID = shipID
self.shipName = shipName
def __repr__(self):
return 'FitLite(ID={})'.format(self.ID)
class Fit:
"""Represents a fitting, with modules, ship, implants, etc."""

View File

@@ -3,6 +3,7 @@ import wx
import gui.mainFrame
from gui.contextMenu import ContextMenuUnconditional
from service.fit import Fit
class AddBrowsedFits(ContextMenuUnconditional):
@@ -47,10 +48,10 @@ class FitBrowserLiteDialog(wx.Dialog):
listButtonSizer = wx.BoxSizer(wx.VERTICAL)
listButtonSizer.AddStretchSpacer()
self.addButton = wx.Button(self, wx.ID_ANY, '>>', wx.DefaultPosition, wx.DefaultSize, 0)
listButtonSizer.Add(self.addButton, 0, wx.EXPAND | wx.ALL, 5)
self.removeButton = wx.Button(self, wx.ID_ANY, '<<', wx.DefaultPosition, wx.DefaultSize, 0)
listButtonSizer.Add(self.removeButton, 0, wx.EXPAND | wx.ALL, 5)
addButton = wx.Button(self, wx.ID_ANY, '>>', wx.DefaultPosition, wx.DefaultSize, 0)
listButtonSizer.Add(addButton, 0, wx.EXPAND | wx.ALL, 5)
removeButton = wx.Button(self, wx.ID_ANY, '<<', wx.DefaultPosition, wx.DefaultSize, 0)
listButtonSizer.Add(removeButton, 0, wx.EXPAND | wx.ALL, 5)
listButtonSizer.AddStretchSpacer()
listSizer.Add(listButtonSizer, 0, wx.EXPAND | wx.ALL, 5)
@@ -62,6 +63,10 @@ class FitBrowserLiteDialog(wx.Dialog):
if buttonSizer:
mainSizer.Add(buttonSizer, 0, wx.EXPAND | wx.ALL, 5)
fits = Fit.getInstance().getAllFitsLite()
fits.sort(key=lambda f: (f.shipName, f.name))
fromList.update(fits)
self.SetSizer(mainSizer)
self.CenterOnParent()
self.Fit()

View File

@@ -26,7 +26,7 @@ from eos.saveddata.implant import Implant
from eos.saveddata.drone import Drone
from eos.saveddata.fighter import Fighter
from eos.saveddata.module import Module, Rack
from eos.saveddata.fit import Fit
from eos.saveddata.fit import Fit, FitLite
from eos.saveddata.targetProfile import TargetProfile
from eos.const import FittingSlot
from service.fit import Fit as FitSvc
@@ -71,6 +71,8 @@ class BaseName(ViewColumn):
return "<unknown>"
else:
return "%s (%s)" % (stuff.name, stuff.ship.item.name)
elif isinstance(stuff, FitLite):
return "{} ({})".format(stuff.name, stuff.shipName)
elif isinstance(stuff, Rack):
if FitSvc.getInstance().serviceFittingOptions["rackLabels"]:
if stuff.slot == FittingSlot.MODE:

View File

@@ -54,7 +54,6 @@ class DeferRecalc:
self.sFit.recalc(self.fitID)
# inherits from FitDeprecated so that I can move all the dead shit, but not affect functionality
class Fit:
instance = None
processors = {}
@@ -104,6 +103,21 @@ class Fit:
fits = eos.db.getFitList()
return fits
@staticmethod
def getAllFitsLite():
fits = eos.db.getFitListLite()
shipMap = {f.shipID: None for f in fits}
for shipID in shipMap:
ship = eos.db.getItem(shipID)
if ship is not None:
shipMap[shipID] = ship.name
for fit in fits:
try:
fit.shipName = shipMap[fit.shipID]
except KeyError:
pass
return fits
@staticmethod
def getFitsWithShip(shipID):
""" Lists fits of shipID, used with shipBrowser """