- fixed bug where for Geometry objects after a successful object rename done in the Object collection view (Project tab), deselect the object and reselect it and then in the Selected tab the name is not the new one but the old one

- for Geometry objects, adding a new tool to the Tools table after a successful rename will now store the new name in the tool data
This commit is contained in:
Marius Stanciu 2019-06-17 17:01:27 +03:00
parent 0244c76605
commit ffa92524f0
4 changed files with 37 additions and 28 deletions

View File

@ -5249,6 +5249,7 @@ class App(QtCore.QObject):
if index.isValid():
if index.internalPointer().parent_item != self.collection.root_item:
self.ui.notebook.setCurrentWidget(self.ui.selected_tab)
self.collection.on_item_activated(index)
def grid_status(self):
if self.ui.grid_snap_btn.isChecked():

View File

@ -68,6 +68,9 @@ class FlatCAMObj(QtCore.QObject):
self.form_fields = {}
# store here the default data for Geometry Data
self.default_data = {}
self.kind = None # Override with proper name
# self.shapes = ShapeCollection(parent=self.app.plotcanvas.vispy_canvas.view.scene)
@ -137,7 +140,7 @@ class FlatCAMObj(QtCore.QObject):
if key == 'plot':
self.visible = self.options['plot']
# self.optionChanged.emit(key)
self.optionChanged.emit(key)
def set_ui(self, ui):
self.ui = ui
@ -199,6 +202,7 @@ class FlatCAMObj(QtCore.QObject):
log.debug("on_name_activate() --> Could not remove the old object name from auto-completer model list")
self.options["name"] = self.ui.name_entry.get_value()
self.default_data["name"] = self.ui.name_entry.get_value()
self.app.collection.update_view()
self.app.inform.emit(_("[success] Name changed from {old} to {new}").format(old=old_name, new=new_name))
@ -1938,10 +1942,6 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
self.ui.tools_table.setColumnWidth(5, 17)
# horizontal_header.setStretchLastSection(True)
# horizontal_header.setColumnWidth(2, QtWidgets.QHeaderView.ResizeToContents)
# horizontal_header.setStretchLastSection(True)
@ -3002,9 +3002,6 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
self.old_pp_state = ''
self.old_toolchangeg_state = ''
# store here the default data for Geometry Data
self.default_data = {}
# Attributes to be included in serialization
# Always append to it because it carries contents
# from predecessors.
@ -3013,7 +3010,6 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
def build_ui(self):
self.ui_disconnect()
FlatCAMObj.build_ui(self)
offset = 0
@ -3151,6 +3147,10 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
self.set_tool_offset_visibility(selected_row)
self.ui_connect()
# HACK: for whatever reasons the name in Selected tab is reverted to the original one after a successful rename
# done in the collection view but only for Geometry objects. Perhaps some references remains. Should be fixed.
self.ui.name_entry.set_value(self.options['name'])
def set_ui(self, ui):
FlatCAMObj.set_ui(self, ui)
@ -3225,7 +3225,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
for def_key in self.default_data:
for opt_key, opt_val in self.options.items():
if def_key == opt_key:
self.default_data[def_key] = opt_val
self.default_data[def_key] = deepcopy(opt_val)
self.tooluid += 1
if not self.tools:
@ -3325,10 +3325,11 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
return
def on_offset_value_edited(self):
'''
This will save the offset_value into self.tools storage whenever the oofset value is edited
"""
This will save the offset_value into self.tools storage whenever the offset value is edited
:return:
'''
"""
for current_row in self.ui.geo_tools_table.selectedItems():
# sometime the header get selected and it has row number -1
# we don't want to do anything with the header :)
@ -3371,7 +3372,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
# works for Entry
try:
self.ui.grid3.itemAt(i).widget().editingFinished.connect(self.gui_form_to_storage)
except:
except Exception as e3:
pass
for row in range(self.ui.geo_tools_table.rowCount()):
@ -3409,56 +3410,56 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
isinstance(self.ui.grid3.itemAt(i).widget(), IntEntry) or \
isinstance(self.ui.grid3.itemAt(i).widget(), FCEntry):
self.ui.grid3.itemAt(i).widget().editingFinished.disconnect()
except:
except Exception as e:
pass
try:
for row in range(self.ui.geo_tools_table.rowCount()):
for col in [2, 3, 4]:
self.ui.geo_tools_table.cellWidget(row, col).currentIndexChanged.disconnect()
except:
except Exception as e:
pass
# I use lambda's because the connected functions have parameters that could be used in certain scenarios
try:
self.ui.addtool_btn.clicked.disconnect()
except:
except Exception as e:
pass
try:
self.ui.copytool_btn.clicked.disconnect()
except:
except Exception as e:
pass
try:
self.ui.deltool_btn.clicked.disconnect()
except:
except Exception as e:
pass
try:
self.ui.geo_tools_table.currentItemChanged.disconnect()
except:
except Exception as e:
pass
try:
self.ui.geo_tools_table.itemChanged.disconnect()
except:
except Exception as e:
pass
try:
self.ui.tool_offset_entry.editingFinished.disconnect()
except:
except Exception as e:
pass
for row in range(self.ui.geo_tools_table.rowCount()):
try:
self.ui.geo_tools_table.cellWidget(row, 6).clicked.disconnect()
except:
except Exception as e:
pass
try:
self.ui.plot_cb.stateChanged.disconnect()
except:
except Exception as e:
pass
def on_tool_add(self, dia=None):
@ -3545,6 +3546,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
}
})
self.tools[self.tooluid]['data']['name'] = self.options['name']
self.ui.tool_offset_entry.hide()
self.ui.tool_offset_lbl.hide()

View File

@ -263,10 +263,9 @@ class ObjectCollection(QtCore.QAbstractItemModel):
# ## GUI Events
self.view.selectionModel().selectionChanged.connect(self.on_list_selection_change)
self.view.activated.connect(self.on_item_activated)
# self.view.keyPressed.connect(self.on_key)
# self.view.activated.connect(self.on_item_activated)
self.view.keyPressed.connect(self.app.ui.keyPressEvent)
self.view.clicked.connect(self.on_mouse_down)
# self.view.clicked.connect(self.on_mouse_down)
self.view.customContextMenuRequested.connect(self.on_menu_request)
self.click_modifier = None
@ -398,8 +397,9 @@ class ObjectCollection(QtCore.QAbstractItemModel):
def setData(self, index, data, role=None):
if index.isValid():
obj = index.internalPointer().obj
if obj:
old_name = obj.options['name']
old_name = deepcopy(obj.options['name'])
new_name = str(data)
if old_name != new_name and new_name != '':
# rename the object

View File

@ -9,6 +9,11 @@ CAD program, and create G-Code for Isolation routing.
=================================================
17.06.2019
- fixed bug where for Geometry objects after a successful object rename done in the Object collection view (Project tab), deselect the object and reselect it and then in the Selected tab the name is not the new one but the old one
- for Geometry objects, adding a new tool to the Tools table after a successful rename will now store the new name in the tool data
15.06.2019
- fixed bug in Gerber parser that made the Gerber files generated by Altium Designer 18 not to be loaded