From ffa861fb1fbe93b31e1d0e97ac397668e8d072e2 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sat, 6 Nov 2021 01:26:42 +0200 Subject: [PATCH] - in Geometry Property Tab, clicking the tools table header will toggle the selection for all tools in the table --- CHANGELOG.md | 1 + appObjects/FlatCAMGeometry.py | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79b463b3..7e53b634 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ CHANGELOG for FlatCAM beta - in Isolation Plugin there is no longer auto-switch to Properties Tab - when editing Geometry objects with multiple geometry fixed the issue with the edited geometry always being the one in the first tool +- in Geometry Property Tab, clicking the tools table header will toggle the selection for all tools in the table 1.11.2021 diff --git a/appObjects/FlatCAMGeometry.py b/appObjects/FlatCAMGeometry.py index 6e0663ca..e5573de9 100644 --- a/appObjects/FlatCAMGeometry.py +++ b/appObjects/FlatCAMGeometry.py @@ -395,7 +395,7 @@ class GeometryObject(FlatCAMObj, Geometry): self.set_offset_values() self.ui.geo_tools_table.itemSelectionChanged.connect(self.on_row_changed) - + self.ui.geo_tools_table.horizontalHeader().sectionClicked.connect(self.table_toggle_all) # Show/Hide Advanced Options app_mode = self.app.defaults["global_app_level"] self.change_level(app_mode) @@ -403,6 +403,25 @@ class GeometryObject(FlatCAMObj, Geometry): def on_row_changed(self): pass + def table_toggle_all(self): + """ + Will toggle the selection of all rows in the table + + :return: + """ + sel_model = self.ui.geo_tools_table.selectionModel() + sel_indexes = sel_model.selectedIndexes() + + # it will iterate over all indexes which means all items in all columns too but I'm interested only on rows + sel_rows = set() + for idx in sel_indexes: + sel_rows.add(idx.row()) + + if sel_rows: + self.ui.geo_tools_table.clearSelection() + else: + self.ui.geo_tools_table.selectAll() + def set_offset_values(self): xmin, ymin, xmax, ymax = self.bounds() center_coords = (