diff --git a/gui/copySelectDialog.py b/gui/copySelectDialog.py index d0eba966b..ff992a7f4 100644 --- a/gui/copySelectDialog.py +++ b/gui/copySelectDialog.py @@ -40,37 +40,44 @@ class CopySelectDialog(wx.Dialog): style=wx.DEFAULT_DIALOG_STYLE) mainSizer = wx.BoxSizer(wx.VERTICAL) - self.settings = SettingsProvider.getInstance().getSettings("pyfaExport", {"format": 0, "options": 0}) + self.settings = SettingsProvider.getInstance().getSettings("pyfaExport", {"format": 0, "options": {}}) + # Overwrite older options format which was plain int storing EFT options + if not isinstance(self.settings["options"], dict): + self.settings["options"] = {CopySelectDialog.copyFormatEft: self.settings["options"]} self.copyFormats = OrderedDict(( - ("EFT", CopySelectDialog.copyFormatEft), - ("XML", CopySelectDialog.copyFormatXml), - ("DNA", CopySelectDialog.copyFormatDna), - ("ESI", CopySelectDialog.copyFormatEsi), - ("MultiBuy", CopySelectDialog.copyFormatMultiBuy), - ("EFS", CopySelectDialog.copyFormatEfs), + ("EFT", (CopySelectDialog.copyFormatEft, EFT_OPTIONS)), + ("XML", (CopySelectDialog.copyFormatXml, None)), + ("DNA", (CopySelectDialog.copyFormatDna, None)), + ("ESI", (CopySelectDialog.copyFormatEsi, None)), + ("MultiBuy", (CopySelectDialog.copyFormatMultiBuy, None)), + ("EFS", (CopySelectDialog.copyFormatEfs, None)), )) 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) + initialized = False + for formatName, formatData in self.copyFormats.items(): + formatId, formatOptions = formatData + if not initialized: + rdo = wx.RadioButton(self, wx.ID_ANY, formatName, style=wx.RB_GROUP) + initialized = True else: - rdo = wx.RadioButton(self, wx.ID_ANY, format) + rdo = wx.RadioButton(self, wx.ID_ANY, formatName) rdo.Bind(wx.EVT_RADIOBUTTON, self.Selected) - if self.settings['format'] == self.copyFormats[format]: + if self.settings['format'] == formatId: rdo.SetValue(True) - self.copyFormat = self.copyFormats[format] + self.copyFormat = formatId mainSizer.Add(rdo, 0, wx.EXPAND | wx.ALL, 5) - if format == "EFT": + if formatOptions: bsizer = wx.BoxSizer(wx.VERTICAL) + self.options[formatId] = {} - for optId, optName, optDesc in EFT_OPTIONS: + for optId, optName, optDesc in formatOptions: ch = wx.CheckBox(self, -1, optName) - self.options[optId] = ch - if self.settings['options'] & optId: + self.options[formatId][optId] = ch + if self.settings['options'].get(formatId, 0) & optId: ch.SetValue(True) bsizer.Add(ch, 1, wx.EXPAND | wx.TOP | wx.BOTTOM, 3) mainSizer.Add(bsizer, 1, wx.EXPAND | wx.LEFT, 20) @@ -86,21 +93,25 @@ class CopySelectDialog(wx.Dialog): def Selected(self, event): obj = event.GetEventObject() - format = obj.GetLabel() - self.copyFormat = self.copyFormats[format] + formatName = obj.GetLabel() + self.copyFormat = self.copyFormats[formatName][0] self.toggleOptions() self.Fit() def toggleOptions(self): - for ch in self.options.values(): - ch.Enable(self.GetSelected() == CopySelectDialog.copyFormatEft) + for formatId in self.options: + for optId, checkbox in self.options[formatId].items(): + checkbox.Enable(self.GetSelected() == formatId) 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 + options = {} + for formatId in self.options: + optVal = 0 + for optId, checkbox in self.options[formatId].items(): + if checkbox.IsChecked(): + optVal = optVal ^ optId + options[formatId] = optVal + return options diff --git a/gui/mainFrame.py b/gui/mainFrame.py index 5f3aa6441..669a5f7c6 100644 --- a/gui/mainFrame.py +++ b/gui/mainFrame.py @@ -703,10 +703,6 @@ class MainFrame(wx.Frame): fit = db_getFit(self.getActiveFit()) toClipboard(Port.exportEft(fit, options)) - def clipboardEftImps(self, options): - fit = db_getFit(self.getActiveFit()) - toClipboard(Port.exportEftImps(fit)) - def clipboardDna(self, options): fit = db_getFit(self.getActiveFit()) toClipboard(Port.exportDna(fit)) @@ -744,7 +740,6 @@ class MainFrame(wx.Frame): def exportToClipboard(self, event): CopySelectDict = {CopySelectDialog.copyFormatEft: self.clipboardEft, - # CopySelectDialog.copyFormatEftImps: self.clipboardEftImps, CopySelectDialog.copyFormatXml: self.clipboardXml, CopySelectDialog.copyFormatDna: self.clipboardDna, CopySelectDialog.copyFormatEsi: self.clipboardEsi, @@ -758,8 +753,7 @@ class MainFrame(wx.Frame): settings = SettingsProvider.getInstance().getSettings("pyfaExport") settings["format"] = selected settings["options"] = options - - CopySelectDict[selected](options) + CopySelectDict[selected](options.get(selected)) try: dlg.Destroy()