Incorporating comments and functionality frpm JP. Removed need to use tab_change signal, removed inheritance dependency on QAbstractItemModel, implemented option_changed property.
This commit is contained in:
@@ -24,7 +24,7 @@ class DblSidedTool(FlatCAMTool):
|
||||
|
||||
## Layer to mirror
|
||||
self.object_combo = QtGui.QComboBox()
|
||||
self.object_combo.setModel(self.app.collection)
|
||||
self.object_combo.setModel(self.app.collection.model)
|
||||
self.botlay_label = QtGui.QLabel("Bottom Layer:")
|
||||
self.botlay_label.setToolTip(
|
||||
"Layer to be mirrorer."
|
||||
@@ -68,7 +68,7 @@ class DblSidedTool(FlatCAMTool):
|
||||
self.point = EvalEntry()
|
||||
self.point_box_container.addWidget(self.point)
|
||||
self.box_combo = QtGui.QComboBox()
|
||||
self.box_combo.setModel(self.app.collection)
|
||||
self.box_combo.setModel(self.app.collection.model)
|
||||
self.point_box_container.addWidget(self.box_combo)
|
||||
self.box_combo.hide()
|
||||
|
||||
@@ -180,6 +180,12 @@ class DblSidedTool(FlatCAMTool):
|
||||
px = 0.5 * (xmin + xmax)
|
||||
py = 0.5 * (ymin + ymax)
|
||||
|
||||
# Ensure that the selected object will display when it is mirrored.
|
||||
# If an object's plot setting is False it will still be available in
|
||||
# the combo box. If the plot is not enforced to True then the user
|
||||
# gets no feedback of the operation.
|
||||
fcobj.options["plot"] = True;
|
||||
|
||||
fcobj.mirror(axis, [px, py])
|
||||
fcobj.plot()
|
||||
|
||||
|
||||
@@ -555,7 +555,7 @@ class App(QtCore.QObject):
|
||||
self.ui.options_combo.activated.connect(self.on_options_combo_change)
|
||||
self.options_form.units_radio.group_toggle_fn = self.on_toggle_units
|
||||
#Notebook tabs
|
||||
self.ui.notebook.currentChanged.connect(self.on_tab_change)
|
||||
#self.ui.notebook.currentChanged.connect(self.on_tab_change)
|
||||
|
||||
####################
|
||||
### Other setups ###
|
||||
|
||||
@@ -30,6 +30,8 @@ class FlatCAMObj(QtCore.QObject):
|
||||
# Instance of the application to which these are related.
|
||||
# The app should set this value.
|
||||
app = None
|
||||
|
||||
option_changed = QtCore.pyqtSignal(QtCore.QObject, str)
|
||||
|
||||
def __init__(self, name):
|
||||
"""
|
||||
@@ -79,7 +81,8 @@ class FlatCAMObj(QtCore.QObject):
|
||||
setattr(self, attr, d[attr])
|
||||
|
||||
def on_options_change(self, key):
|
||||
self.emit(QtCore.SIGNAL("optionChanged"), key)
|
||||
#self.emit(QtCore.SIGNAL("optionChanged()"), key)
|
||||
self.option_changed.emit(self, key)
|
||||
|
||||
def set_ui(self, ui):
|
||||
self.ui = ui
|
||||
|
||||
@@ -25,7 +25,8 @@ class KeySensitiveListView(QtGui.QListView):
|
||||
self.keyPressed.emit(event.key())
|
||||
|
||||
|
||||
class ObjectCollection(QtCore.QAbstractListModel):
|
||||
#class ObjectCollection(QtCore.QAbstractListModel):
|
||||
class ObjectCollection():
|
||||
"""
|
||||
Object storage and management.
|
||||
"""
|
||||
@@ -45,7 +46,7 @@ class ObjectCollection(QtCore.QAbstractListModel):
|
||||
}
|
||||
|
||||
def __init__(self, parent=None):
|
||||
QtCore.QAbstractListModel.__init__(self, parent=parent)
|
||||
#QtCore.QAbstractListModel.__init__(self, parent=parent)
|
||||
### Icons for the list view
|
||||
self.icons = {}
|
||||
for kind in ObjectCollection.icon_files:
|
||||
@@ -171,9 +172,26 @@ class ObjectCollection(QtCore.QAbstractListModel):
|
||||
|
||||
self.model.appendRow(item)
|
||||
|
||||
obj.option_changed.connect(self.on_object_option_changed)
|
||||
|
||||
# Required after appending (Qt MVC)
|
||||
#self.endInsertRows()
|
||||
|
||||
def on_object_option_changed(self, obj, key):
|
||||
self.model.blockSignals(True)
|
||||
name = obj.options["name"]
|
||||
state = 0 #Qt.Unchecked
|
||||
for index in range(self.model.rowCount()):
|
||||
item = self.model.item(index)
|
||||
if self.object_list[item.row()].options["name"] == name:
|
||||
if obj.options["plot"] == True:
|
||||
state = 2 #Qt.Checked
|
||||
|
||||
item.setCheckState(state)
|
||||
obj.ui.plot_cb.set_value(state)
|
||||
break
|
||||
self.model.blockSignals(False)
|
||||
|
||||
def get_names(self):
|
||||
"""
|
||||
Gets a list of the names of all objects in the collection.
|
||||
@@ -327,13 +345,13 @@ class ObjectCollection(QtCore.QAbstractListModel):
|
||||
def delete_all(self):
|
||||
FlatCAMApp.App.log.debug(str(inspect.stack()[1][3]) + "--> OC.delete_all()")
|
||||
|
||||
self.beginResetModel()
|
||||
# self.beginResetModel()
|
||||
|
||||
self.model.removeRows(0, self.model.rowCount())
|
||||
self.object_list = []
|
||||
self.checked_indexes = []
|
||||
|
||||
self.endResetModel()
|
||||
# self.endResetModel()
|
||||
|
||||
def get_list(self):
|
||||
return self.object_list
|
||||
|
||||
Reference in New Issue
Block a user