diff --git a/datamodel.py b/datamodel.py index ab655d1..72c8db7 100644 --- a/datamodel.py +++ b/datamodel.py @@ -170,6 +170,10 @@ def RemoveAll(self): self.data.clear() self.Cleared() + def get_all(self): + """Get tall items.""" + return self.data + def get_reference(self, item): """Get the reference of an item.""" return self.ItemToObject(item)[REF_COL] diff --git a/mainwindow.py b/mainwindow.py index 127cba6..77c2c63 100644 --- a/mainwindow.py +++ b/mainwindow.py @@ -864,6 +864,7 @@ def paste_part_lcsc(self, *_): def add_part_rot(self, e): """Add part rotation for the current part.""" + return for item in self.footprint_list.GetSelections(): row = self.footprint_list.ItemToRow(item) if row == -1: @@ -879,15 +880,15 @@ def add_part_rot(self, e): def save_all_mappings(self, *_): """Save all mappings.""" - for r in range(self.footprint_list.GetItemCount()): - footp = self.footprint_list.GetTextValue(r, 2) - partval = self.footprint_list.GetTextValue(r, 1) - lcscpart = self.footprint_list.GetTextValue(r, 3) - if footp != "" and partval != "" and lcscpart != "": - if self.library.get_mapping_data(footp, partval): - self.library.update_mapping_data(footp, partval, lcscpart) + for item in self.partlist_data_model.get_all(): + value = item[1] + footprint = item[2] + lcsc = item[3] + if footprint != "" and value != "" and lcsc != "": + if self.library.get_mapping_data(footprint, value): + self.library.update_mapping_data(footprint, value, lcsc) else: - self.library.insert_mapping_data(footp, partval, lcscpart) + self.library.insert_mapping_data(footprint, value, lcsc) self.logger.info("All mappings saved") def export_to_schematic(self, *_):