- in Tools Database added a Sort by Target context menu entry and functionality; fixed the Sort by Dia functionality
This commit is contained in:
@@ -12,6 +12,7 @@ CHANGELOG for FlatCAM beta
|
|||||||
- fixed error in Tools Database when deleting first tool; remade the tool deletion method
|
- fixed error in Tools Database when deleting first tool; remade the tool deletion method
|
||||||
- in Tools Database added tooltips for each column item in the left TreeWidget
|
- in Tools Database added tooltips for each column item in the left TreeWidget
|
||||||
- in Tools Database made sure that editing the Target and Tool diameter in the right side section will update the values in the left TreeWidget
|
- in Tools Database made sure that editing the Target and Tool diameter in the right side section will update the values in the left TreeWidget
|
||||||
|
- in Tools Database added a Sort by Target context menu entry and functionality; fixed the Sort by Dia functionality
|
||||||
|
|
||||||
25.11.2020
|
25.11.2020
|
||||||
|
|
||||||
|
|||||||
@@ -1624,8 +1624,8 @@ class ToolsDB2(QtWidgets.QWidget):
|
|||||||
|
|
||||||
menu = QtWidgets.QMenu()
|
menu = QtWidgets.QMenu()
|
||||||
|
|
||||||
# sort_by_id = menu.addAction(QtGui.QIcon(self.app.resource_location + '/plus16.png'), _("Sort by Operation"))
|
sort_by_id = menu.addAction(QtGui.QIcon(self.app.resource_location + '/desc_sort32.png'), _("Sort by Target"))
|
||||||
# sort_by_id.triggered.connect(self.on_sort_operation)
|
sort_by_id.triggered.connect(self.on_sort_target)
|
||||||
|
|
||||||
sort_by_dia = menu.addAction(QtGui.QIcon
|
sort_by_dia = menu.addAction(QtGui.QIcon
|
||||||
(self.app.resource_location + '/desc_sort32.png'), _("Sort by Diameter"))
|
(self.app.resource_location + '/desc_sort32.png'), _("Sort by Diameter"))
|
||||||
@@ -1674,15 +1674,15 @@ class ToolsDB2(QtWidgets.QWidget):
|
|||||||
elif column == 1:
|
elif column == 1:
|
||||||
self.ui.name_entry.set_value(item.text(1))
|
self.ui.name_entry.set_value(item.text(1))
|
||||||
|
|
||||||
def on_sort_operation(self):
|
def on_sort_target(self):
|
||||||
for tool in self.db_tool_dict.values():
|
|
||||||
dia = tool['tooldia']
|
|
||||||
target = tool['data']['tool_target']
|
|
||||||
|
|
||||||
ordered_by_target = sorted(self.db_tool_dict.items(), key=lambda x: x[1]['data']['tool_target'])
|
ordered_by_target = sorted(self.db_tool_dict.items(), key=lambda x: x[1]['data']['tool_target'])
|
||||||
for td, k in ordered_by_target:
|
new_dict = {}
|
||||||
print(td,k)
|
t_id = 0
|
||||||
|
for __, old_dict in ordered_by_target:
|
||||||
|
t_id += 1
|
||||||
|
new_dict[str(t_id)] = old_dict
|
||||||
|
|
||||||
|
self.db_tool_dict = deepcopy(new_dict)
|
||||||
self.build_db_ui()
|
self.build_db_ui()
|
||||||
self.on_tools_db_edited()
|
self.on_tools_db_edited()
|
||||||
|
|
||||||
@@ -1691,13 +1691,12 @@ class ToolsDB2(QtWidgets.QWidget):
|
|||||||
if dias:
|
if dias:
|
||||||
dias.sort()
|
dias.sort()
|
||||||
|
|
||||||
|
ordered_by_dia = sorted(self.db_tool_dict.items(), key=lambda x: x[1]['tooldia'])
|
||||||
new_dict = {}
|
new_dict = {}
|
||||||
t_id = 0
|
t_id = 0
|
||||||
for dia in dias:
|
for __, old_dict in ordered_by_dia:
|
||||||
for tool in self.db_tool_dict.values():
|
t_id += 1
|
||||||
if tool['tooldia'] == dia:
|
new_dict[str(t_id)] = old_dict
|
||||||
t_id += 1
|
|
||||||
new_dict[str(t_id)] = tool
|
|
||||||
|
|
||||||
self.db_tool_dict = deepcopy(new_dict)
|
self.db_tool_dict = deepcopy(new_dict)
|
||||||
self.build_db_ui()
|
self.build_db_ui()
|
||||||
|
|||||||
Reference in New Issue
Block a user