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

Fix inconsistency between column ordering in the GUI and the database reference. #446

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion library.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ def set_order_by(self, n):
"Package",
"Solder Joint",
"Library Type",
"Stock",
Copy link
Collaborator

Choose a reason for hiding this comment

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

commit log mentions this has to match the database order, where is the defined? can we use the same list in both places to avoid having the two lists get out of sync?

Copy link
Contributor Author

@gyohng gyohng Apr 22, 2024

Choose a reason for hiding this comment

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

This, what you're looking at is the database column reference order.

The GUI list is in partselector.py line 368 and on. In theory, one could use a single source for it, but it's going to be a much more involved refactoring:

image

Plugging it right now is more sensible than leaving it unfixed until someone finds enough time to revamp partselector.py, for which there could be a TODO task to fix it in the future.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we pull the list out of 116 as well so there is a single list of columns? Because 116 notes the list in parselector.py (typo), but 86 doesn't.

Copy link
Contributor Author

@gyohng gyohng Apr 22, 2024

Choose a reason for hiding this comment

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

I need to get back to my projects now, cannot spend any more time on this. Please feel free to get inspired by this:

# Defining the structure of each column - put this inside `library.py` and assign to a member of `library`
sel_columns = [
    {"name": "LCSC",         "db_name": "LCSC Part",     "width": 60,  "align": wx.ALIGN_LEFT,   "ellipsize": wx.ELLIPSIZE_NONE},
    {"name": "MFR Number",   "db_name": "MFR.Part",      "width": 140, "align": wx.ALIGN_LEFT,   "ellipsize": wx.ELLIPSIZE_NONE},
    {"name": "Package",      "db_name": "Package",       "width": 100, "align": wx.ALIGN_LEFT,   "ellipsize": wx.ELLIPSIZE_NONE},
    {"name": "Pins",         "db_name": "Pins",          "width": 40,  "align": wx.ALIGN_CENTER, "ellipsize": None},
    {"name": "Type",         "db_name": "Library Type",  "width": 50,  "align": wx.ALIGN_LEFT,   "ellipsize": wx.ELLIPSIZE_NONE},
    {"name": "Stock",        "db_name": "Stock",         "width": 50,  "align": wx.ALIGN_CENTER, "ellipsize": wx.ELLIPSIZE_NONE},
    {"name": "Manufacturer", "db_name": "Manufacturer",  "width": 100, "align": wx.ALIGN_LEFT,   "ellipsize": wx.ELLIPSIZE_NONE},
    {"name": "Description",  "db_name": "Description",   "width": 300, "align": wx.ALIGN_LEFT,   "ellipsize": wx.ELLIPSIZE_NONE},
    {"name": "Price",        "db_name": "Price",         "width": 100, "align": wx.ALIGN_LEFT,   "ellipsize": wx.ELLIPSIZE_NONE}
]
......

    for col in parent.library.sel_columns:
        col_width = int(parent.scale_factor * col["width"])
        renderer = self.part_list.AppendTextColumn(
            col["name"],
            mode=wx.dataview.DATAVIEW_CELL_INERT,
            width=col_width,
            align=col["align"],
            flags=wx.dataview.DATAVIEW_COL_RESIZABLE
        ).GetRenderer()

        if "ellipsize" in col and col["ellipsize"] is not None:
            renderer.EnableEllipsize(col["ellipsize"])

Copy link
Collaborator

Choose a reason for hiding this comment

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

@gyohng yep, I'll pick it up

"Manufacturer",
"Description",
"Price",
"Stock",
]
if self.order_by == order_by[n] and self.order_dir == "ASC":
self.order_dir = "DESC"
Expand Down