def AddShapeRowLayer(self, shape, parent_item):
icon = QIcon()
icon.addPixmap(QPixmap(":/images/shape.png"))
item_col_0 = QStandardItem(icon, "")
item_col_0.setData(QVariantShape(shape), SHAPE_OBJECT) # store a ref in our treeView element
item_col_1 = QStandardItem(shape.type)
item_col_2 = QStandardItem(str(shape.nr))
item_col_3 = QStandardItem()
parent_item.appendRow([item_col_0, item_col_1, item_col_2, item_col_3])
# Deal with the checkboxes (shape enabled or disabled / send shape to TSP optimizer)
item_col_0.setCheckState(QtCore.Qt.Unchecked if shape.isDisabled() else QtCore.Qt.Checked)
item_col_3.setCheckState(QtCore.Qt.Checked if shape.isToolPathOptimized() else QtCore.Qt.Unchecked)
flags = QtCore.Qt.ItemIsDragEnabled | QtCore.Qt.ItemIsSelectable
if shape.allowedToChange:
flags |= QtCore.Qt.ItemIsEnabled
item_col_0.setFlags(flags | QtCore.Qt.ItemIsUserCheckable)
item_col_1.setFlags(flags)
item_col_2.setFlags(flags)
item_col_3.setFlags(flags | QtCore.Qt.ItemIsUserCheckable)
评论列表
文章目录