- in Tools Database - clicking the header sections of the TreeWidget for columns Target and Diameter will sort the tools by that criteria

This commit is contained in:
Marius Stanciu
2020-11-26 22:02:40 +02:00
committed by Marius
parent ab81591a40
commit 9ecc2dc9ac
3 changed files with 20 additions and 8 deletions

View File

@@ -13,6 +13,7 @@ CHANGELOG for FlatCAM beta
- 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 added a Sort by Target context menu entry and functionality; fixed the Sort by Dia functionality
- in Tools Database - clicking the header sections of the TreeWidget for columns Target and Diameter will sort the tools by that criteria
25.11.2020

View File

@@ -1613,9 +1613,11 @@ class ToolsDB2(QtWidgets.QWidget):
self.ui.tree_widget.currentItemChanged.connect(self.on_list_selection_change)
self.ui.tree_widget.itemChanged.connect(self.on_list_item_edited)
self.ui.tree_widget.customContextMenuRequested.connect(self.on_menu_request)
self.ui.tree_widget.itemDoubleClicked.connect(self.on_item_double_clicked)
self.ui.tree_widget.tree_header.setSectionsClickable(True)
self.ui.tree_widget.tree_header.sectionPressed.connect(self.on_header_clicked)
self.ui.tool_op_combo.currentIndexChanged.connect(self.on_tool_target_changed)
self.setup_db_ui()
@@ -1702,6 +1704,13 @@ class ToolsDB2(QtWidgets.QWidget):
self.build_db_ui()
self.on_tools_db_edited()
def on_header_clicked(self, column):
if column == 2:
self.on_sort_target()
if column == 3:
self.on_sort_dia()
def storage_to_form(self, dict_storage):
self.ui_disconnect()
for form_key in self.form_fields:

View File

@@ -164,9 +164,11 @@ class FCTree(QtWidgets.QTreeWidget):
def __init__(self, parent=None, columns=2, header_hidden=True, extended_sel=False, protected_column=None):
super(FCTree, self).__init__(parent)
self.tree_header = self.header()
self.setColumnCount(columns)
self.setHeaderHidden(header_hidden)
self.header().setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents)
self.tree_header.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents)
self.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Expanding)
palette = QtGui.QPalette()
@@ -185,7 +187,8 @@ class FCTree(QtWidgets.QTreeWidget):
self.protected_column = protected_column
self.itemDoubleClicked.connect(self.on_double_click)
self.header().sectionDoubleClicked.connect(self.on_header_double_click)
self.tree_header.sectionDoubleClicked.connect(self.on_header_double_click)
self.resize_sig.connect(self.on_resize)
def on_double_click(self, item, column):
@@ -197,11 +200,10 @@ class FCTree(QtWidgets.QTreeWidget):
item.setFlags(tmp_flags ^ QtCore.Qt.ItemIsEditable)
def on_header_double_click(self, column):
header = self.header()
header.setSectionResizeMode(column, QtWidgets.QHeaderView.ResizeToContents)
width = header.sectionSize(column)
header.setSectionResizeMode(column, QtWidgets.QHeaderView.Interactive)
header.resizeSection(column, width)
self.tree_header.setSectionResizeMode(column, QtWidgets.QHeaderView.ResizeToContents)
width = self.tree_header.sectionSize(column)
self.tree_header.setSectionResizeMode(column, QtWidgets.QHeaderView.Interactive)
self.tree_header.resizeSection(column, width)
def is_editable(self, tested_col):
try: