Skip to content

Commit

Permalink
Adapte save all footprint mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
Bouni committed Aug 7, 2024
1 parent 21c59d6 commit 6bd8d94
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
4 changes: 4 additions & 0 deletions datamodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
17 changes: 9 additions & 8 deletions mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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, *_):
Expand Down

0 comments on commit 6bd8d94

Please sign in to comment.