-
-
Notifications
You must be signed in to change notification settings - Fork 110
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
Conversation
@@ -89,10 +89,10 @@ def set_order_by(self, n): | |||
"Package", | |||
"Solder Joint", | |||
"Library Type", | |||
"Stock", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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:
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"])
There was a problem hiding this comment.
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
… reference that prevents proper sorting.
9e62d78
to
cc27e0c
Compare
Rebased to the main branch. Please consider merging. |
I'll close this as its already fixed in main. I totally overlooked your PR while I fixed that, sorry 😓 |
This patch addresses an issue where the column ordering in the GUI did not match the order used in database queries. This led to improper sorting functionality within the application in the part selection dialogue. The inconsistency was observed when a header was clicked to sort by a specific field, where the list would be sorted using a wrong field.
The position of the "Stock" field in the ordering array was adjusted to precede the
Manufacturer
,Description
, andPrice
fields in the way it is in the GUI.