Merge remote-tracking branch 'origin/development' into commandRefactor
This commit is contained in:
@@ -20,51 +20,84 @@
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from service.port.eft import EFT_OPTIONS
|
||||
from service.settings import SettingsProvider
|
||||
|
||||
|
||||
class CopySelectDialog(wx.Dialog):
|
||||
copyFormatEft = 0
|
||||
copyFormatEftImps = 1
|
||||
copyFormatXml = 2
|
||||
copyFormatDna = 3
|
||||
copyFormatEsi = 4
|
||||
copyFormatMultiBuy = 5
|
||||
copyFormatEfs = 6
|
||||
copyFormatXml = 1
|
||||
copyFormatDna = 2
|
||||
copyFormatEsi = 3
|
||||
copyFormatMultiBuy = 4
|
||||
copyFormatEfs = 5
|
||||
|
||||
def __init__(self, parent):
|
||||
wx.Dialog.__init__(self, parent, id=wx.ID_ANY, title="Select a format", size=(-1, -1),
|
||||
style=wx.DEFAULT_DIALOG_STYLE)
|
||||
mainSizer = wx.BoxSizer(wx.VERTICAL)
|
||||
|
||||
copyFormats = ["EFT", "EFT (Implants)", "XML", "DNA", "ESI", "MultiBuy", "EFS"]
|
||||
copyFormatTooltips = {CopySelectDialog.copyFormatEft: "EFT text format",
|
||||
CopySelectDialog.copyFormatEftImps: "EFT text format",
|
||||
CopySelectDialog.copyFormatXml: "EVE native XML format",
|
||||
CopySelectDialog.copyFormatDna: "A one-line text format",
|
||||
CopySelectDialog.copyFormatEsi: "A JSON format used for ESI",
|
||||
CopySelectDialog.copyFormatMultiBuy: "MultiBuy text format",
|
||||
CopySelectDialog.copyFormatEfs: "JSON data format used by EFS"}
|
||||
selector = wx.RadioBox(self, wx.ID_ANY, label="Copy to the clipboard using:", choices=copyFormats,
|
||||
style=wx.RA_SPECIFY_ROWS)
|
||||
selector.Bind(wx.EVT_RADIOBOX, self.Selected)
|
||||
for format, tooltip in copyFormatTooltips.items():
|
||||
selector.SetItemToolTip(format, tooltip)
|
||||
self.settings = SettingsProvider.getInstance().getSettings("pyfaExport", {"format": 0, "options": 0})
|
||||
|
||||
self.copyFormat = CopySelectDialog.copyFormatEft
|
||||
selector.SetSelection(self.copyFormat)
|
||||
self.copyFormats = {
|
||||
"EFT": CopySelectDialog.copyFormatEft,
|
||||
"XML": CopySelectDialog.copyFormatXml,
|
||||
"DNA": CopySelectDialog.copyFormatDna,
|
||||
"ESI": CopySelectDialog.copyFormatEsi,
|
||||
"MultiBuy": CopySelectDialog.copyFormatMultiBuy,
|
||||
"EFS": CopySelectDialog.copyFormatEfs
|
||||
}
|
||||
|
||||
mainSizer.Add(selector, 0, wx.EXPAND | wx.ALL, 5)
|
||||
self.options = {}
|
||||
|
||||
for i, format in enumerate(self.copyFormats.keys()):
|
||||
if i == 0:
|
||||
rdo = wx.RadioButton(self, wx.ID_ANY, format, style=wx.RB_GROUP)
|
||||
else:
|
||||
rdo = wx.RadioButton(self, wx.ID_ANY, format)
|
||||
rdo.Bind(wx.EVT_RADIOBUTTON, self.Selected)
|
||||
if self.settings['format'] == self.copyFormats[format]:
|
||||
rdo.SetValue(True)
|
||||
self.copyFormat = self.copyFormats[format]
|
||||
mainSizer.Add(rdo, 0, wx.EXPAND | wx.ALL, 5)
|
||||
|
||||
if format == "EFT":
|
||||
bsizer = wx.BoxSizer(wx.VERTICAL)
|
||||
|
||||
for x, v in EFT_OPTIONS.items():
|
||||
ch = wx.CheckBox(self, -1, v['name'])
|
||||
self.options[x] = ch
|
||||
if self.settings['options'] & x:
|
||||
ch.SetValue(True)
|
||||
bsizer.Add(ch, 1, wx.EXPAND | wx.TOP | wx.BOTTOM, 3)
|
||||
mainSizer.Add(bsizer, 1, wx.EXPAND | wx.LEFT, 20)
|
||||
|
||||
buttonSizer = self.CreateButtonSizer(wx.OK | wx.CANCEL)
|
||||
if buttonSizer:
|
||||
mainSizer.Add(buttonSizer, 0, wx.EXPAND | wx.ALL, 5)
|
||||
|
||||
self.toggleOptions()
|
||||
self.SetSizer(mainSizer)
|
||||
self.Fit()
|
||||
self.Center()
|
||||
|
||||
def Selected(self, event):
|
||||
self.copyFormat = event.GetSelection()
|
||||
obj = event.GetEventObject()
|
||||
format = obj.GetLabel()
|
||||
self.copyFormat = self.copyFormats[format]
|
||||
self.toggleOptions()
|
||||
self.Fit()
|
||||
|
||||
def toggleOptions(self):
|
||||
for ch in self.options.values():
|
||||
ch.Enable(self.GetSelected() == CopySelectDialog.copyFormatEft)
|
||||
|
||||
def GetSelected(self):
|
||||
return self.copyFormat
|
||||
|
||||
def GetOptions(self):
|
||||
i = 0
|
||||
for x, v in self.options.items():
|
||||
if v.IsChecked():
|
||||
i = i ^ x
|
||||
return i
|
||||
|
||||
@@ -15,7 +15,7 @@ import gui.globalEvents as GE
|
||||
from logbook import Logger
|
||||
from service.esi import Esi
|
||||
from service.esiAccess import APIException
|
||||
from service.port import ESIExportException
|
||||
from service.port.esi import ESIExportException
|
||||
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
|
||||
@@ -76,8 +76,7 @@ from service.esiAccess import SsoMode
|
||||
from eos.modifiedAttributeDict import ModifiedAttributeDict
|
||||
from eos.db.saveddata.loadDefaultDatabaseValues import DefaultDatabaseValues
|
||||
from eos.db.saveddata.queries import getFit as db_getFit
|
||||
from service.port import Port, IPortUser
|
||||
from service.efsPort import EfsPort
|
||||
from service.port import Port, IPortUser, EfsPort
|
||||
from service.settings import HTMLExportSettings
|
||||
|
||||
from time import gmtime, strftime
|
||||
@@ -711,31 +710,31 @@ class MainFrame(wx.Frame):
|
||||
else:
|
||||
self.marketBrowser.search.Focus()
|
||||
|
||||
def clipboardEft(self):
|
||||
def clipboardEft(self, options):
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
toClipboard(Port.exportEft(fit))
|
||||
toClipboard(Port.exportEft(fit, options))
|
||||
|
||||
def clipboardEftImps(self):
|
||||
def clipboardEftImps(self, options):
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
toClipboard(Port.exportEftImps(fit))
|
||||
|
||||
def clipboardDna(self):
|
||||
def clipboardDna(self, options):
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
toClipboard(Port.exportDna(fit))
|
||||
|
||||
def clipboardEsi(self):
|
||||
def clipboardEsi(self, options):
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
toClipboard(Port.exportESI(fit))
|
||||
|
||||
def clipboardXml(self):
|
||||
def clipboardXml(self, options):
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
toClipboard(Port.exportXml(None, fit))
|
||||
|
||||
def clipboardMultiBuy(self):
|
||||
def clipboardMultiBuy(self, options):
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
toClipboard(Port.exportMultiBuy(fit))
|
||||
|
||||
def clipboardEfs(self):
|
||||
def clipboardEfs(self, options):
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
toClipboard(EfsPort.exportEfs(fit, 0))
|
||||
|
||||
@@ -750,7 +749,7 @@ class MainFrame(wx.Frame):
|
||||
|
||||
def exportToClipboard(self, event):
|
||||
CopySelectDict = {CopySelectDialog.copyFormatEft: self.clipboardEft,
|
||||
CopySelectDialog.copyFormatEftImps: self.clipboardEftImps,
|
||||
# CopySelectDialog.copyFormatEftImps: self.clipboardEftImps,
|
||||
CopySelectDialog.copyFormatXml: self.clipboardXml,
|
||||
CopySelectDialog.copyFormatDna: self.clipboardDna,
|
||||
CopySelectDialog.copyFormatEsi: self.clipboardEsi,
|
||||
@@ -759,8 +758,13 @@ class MainFrame(wx.Frame):
|
||||
dlg = CopySelectDialog(self)
|
||||
dlg.ShowModal()
|
||||
selected = dlg.GetSelected()
|
||||
options = dlg.GetOptions()
|
||||
|
||||
CopySelectDict[selected]()
|
||||
settings = SettingsProvider.getInstance().getSettings("pyfaExport")
|
||||
settings["format"] = selected
|
||||
settings["options"] = options
|
||||
|
||||
CopySelectDict[selected](options)
|
||||
|
||||
try:
|
||||
dlg.Destroy()
|
||||
|
||||
Reference in New Issue
Block a user