Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve part list #519

Merged
merged 26 commits into from
Aug 8, 2024
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 6 additions & 127 deletions mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,11 @@ def __init__(self, parent, kicad_provider=KicadProvider()):
"Value", 1, width=250, mode=dv.DATAVIEW_CELL_INERT, align=wx.ALIGN_CENTER
)
footprint = self.footprint_list.AppendTextColumn(
"Footprint", 2, width=250, mode=dv.DATAVIEW_CELL_INERT, align=wx.ALIGN_CENTER
"Footprint",
2,
width=250,
mode=dv.DATAVIEW_CELL_INERT,
align=wx.ALIGN_CENTER,
)
lcsc = self.footprint_list.AppendTextColumn(
"LCSC", 3, width=100, mode=dv.DATAVIEW_CELL_INERT, align=wx.ALIGN_CENTER
Expand Down Expand Up @@ -405,91 +409,6 @@ def __init__(self, parent, kicad_provider=KicadProvider()):
rotation.SetSortable(True)
side.SetSortable(True)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh k, could always rebase and fixup the previous change with this one if that makes sense with your git-fu

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea what you mean by that 😅

# self.footprint_list = wx.dataview.DataViewListCtrl(
# self,
# wx.ID_ANY,
# wx.DefaultPosition,
# wx.DefaultSize,
# style=wx.dataview.DV_MULTIPLE,
# )
# self.footprint_list.SetMinSize(HighResWxSize(self.window, wx.Size(750, 400)))
# self.reference = self.footprint_list.AppendTextColumn(
# "Reference",
# mode=wx.dataview.DATAVIEW_CELL_INERT,
# width=int(self.scale_factor * 100),
# align=wx.ALIGN_CENTER,
# flags=wx.dataview.DATAVIEW_COL_RESIZABLE,
# )
# self.value = self.footprint_list.AppendTextColumn(
# "Value",
# mode=wx.dataview.DATAVIEW_CELL_INERT,
# width=int(self.scale_factor * 200),
# align=wx.ALIGN_CENTER,
# flags=wx.dataview.DATAVIEW_COL_RESIZABLE,
# )
# self.footprint = self.footprint_list.AppendTextColumn(
# "Footprint",
# mode=wx.dataview.DATAVIEW_CELL_INERT,
# width=int(self.scale_factor * 300),
# align=wx.ALIGN_CENTER,
# flags=wx.dataview.DATAVIEW_COL_RESIZABLE,
# )
# self.lcsc = self.footprint_list.AppendTextColumn(
# "LCSC",
# mode=wx.dataview.DATAVIEW_CELL_INERT,
# width=int(self.scale_factor * 100),
# align=wx.ALIGN_CENTER,
# flags=wx.dataview.DATAVIEW_COL_RESIZABLE,
# )
# self.type_column = self.footprint_list.AppendTextColumn(
# "Type",
# mode=wx.dataview.DATAVIEW_CELL_INERT,
# width=int(self.scale_factor * 100),
# align=wx.ALIGN_CENTER,
# flags=wx.dataview.DATAVIEW_COL_RESIZABLE,
# )
# self.stock = self.footprint_list.AppendTextColumn(
# "Stock",
# mode=wx.dataview.DATAVIEW_CELL_INERT,
# width=int(self.scale_factor * 100),
# align=wx.ALIGN_CENTER,
# flags=wx.dataview.DATAVIEW_COL_RESIZABLE,
# )
# self.bom = self.footprint_list.AppendIconTextColumn(
# "BOM",
# mode=wx.dataview.DATAVIEW_CELL_INERT,
# width=int(self.scale_factor * 40),
# align=wx.ALIGN_CENTER,
# flags=wx.dataview.DATAVIEW_COL_RESIZABLE,
# )
# self.pos = self.footprint_list.AppendIconTextColumn(
# "POS",
# mode=wx.dataview.DATAVIEW_CELL_INERT,
# width=int(self.scale_factor * 40),
# align=wx.ALIGN_CENTER,
# flags=wx.dataview.DATAVIEW_COL_RESIZABLE,
# )
# self.rot = self.footprint_list.AppendTextColumn(
# "Rotation",
# mode=wx.dataview.DATAVIEW_CELL_INERT,
# width=int(self.scale_factor * 60),
# align=wx.ALIGN_CENTER,
# flags=wx.dataview.DATAVIEW_COL_RESIZABLE,
# )
# self.side = self.footprint_list.AppendTextColumn(
# "Side",
# mode=wx.dataview.DATAVIEW_CELL_INERT,
# width=int(self.scale_factor * 40),
# align=wx.ALIGN_CENTER,
# flags=wx.dataview.DATAVIEW_COL_RESIZABLE,
# )
# self.footprint_list.AppendTextColumn(
# "",
# mode=wx.dataview.DATAVIEW_CELL_INERT,
# align=wx.ALIGN_CENTER,
# width=1,
# flags=wx.dataview.DATAVIEW_COL_RESIZABLE,
# )
table_sizer.Add(self.footprint_list, 20, wx.ALL | wx.EXPAND, 5)

# self.footprint_list.Bind(
Expand Down Expand Up @@ -629,28 +548,10 @@ def get_correction(self, part: dict, corrections: list) -> str:
return "0"

def populate_footprint_list(self, *_):
"""Populate/Refresh list of footprints."""

"""Populate list of footprints."""
if not self.store:
self.init_store()
self.partlist_data_model.RemoveAll()

# icons = {
# 0: wx.dataview.DataViewIconText(
# "",
# loadIconScaled(
# "mdi-check-color.png",
# self.scale_factor,
# ),
# ),
# 1: wx.dataview.DataViewIconText(
# "",
# loadIconScaled(
# "mdi-close-color.png",
# self.scale_factor,
# ),
# ),
# }
details = {}
corrections = self.library.get_all_correction_data()
for part in self.store.read_all():
Expand All @@ -664,7 +565,6 @@ def populate_footprint_list(self, *_):
# don't show the part if hide POS is set
if self.hide_pos_parts and part["exclude_from_pos"]:
continue

self.partlist_data_model.AddEntry(
[
part["reference"],
Expand All @@ -680,27 +580,6 @@ def populate_footprint_list(self, *_):
]
)


# self.footprint_list.AppendItem(
# [
# part["reference"],
# part["value"],
# part["footprint"],
# part["lcsc"],
# details.get(part["lcsc"], {}).get("type", ""), # type
# details.get(part["lcsc"], {}).get("stock", ""), # stock
# icons.get(
# part["exclude_from_bom"], icons.get(0)
# ), # exclude_from_bom icon
# icons.get(
# part["exclude_from_pos"], icons.get(0)
# ), # exclude_from_pos icon
# self.get_correction(part, corrections), # rotation
# "Top" if fp.GetLayer() == 0 else "Bot", # Side
# "",
# ]
# )

def OnSortFootprintList(self, e):
"""Set order_by to the clicked column and trigger list refresh."""
self.store.set_order_by(e.GetColumn())
Expand Down