Add a "Remove" button to Configure Blocks
This commit is contained in:
parent
8833815a01
commit
4533ce5f3d
@ -66,6 +66,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="removeBlockButton">
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -229,6 +229,13 @@ class ConfigureBlocksItemModel(QtCore.QAbstractItemModel):
|
||||
log.info("Appended")
|
||||
self.endInsertRows()
|
||||
|
||||
def removeBlock(self, row):
|
||||
if row >= len(self.definedBlocks):
|
||||
return
|
||||
self.beginRemoveRows(QtCore.QModelIndex(), row, row)
|
||||
del self.definedBlocks[row]
|
||||
self.endRemoveRows()
|
||||
|
||||
def setBlockModelPath(self, row, modelPath):
|
||||
blockDef = self.definedBlocks[row]
|
||||
blockDef.modelPath = modelPath
|
||||
@ -249,6 +256,7 @@ class ConfigureBlocksDialog(QtGui.QDialog):
|
||||
self.blocksView.clicked.connect(self.currentBlockClicked)
|
||||
|
||||
self.addBlockButton.clicked.connect(self.addBlock)
|
||||
self.removeBlockButton.clicked.connect(self.removeBlock)
|
||||
|
||||
headerWidths = [
|
||||
48,
|
||||
@ -427,6 +435,15 @@ class ConfigureBlocksDialog(QtGui.QDialog):
|
||||
# self.internalNameBox.removeItem(index)
|
||||
self.model.addBlock(internalName)
|
||||
|
||||
def removeBlock(self):
|
||||
index = self.blocksView.currentIndex()
|
||||
if not index.isValid():
|
||||
return
|
||||
|
||||
row = index.row()
|
||||
self.model.removeBlock(row)
|
||||
|
||||
|
||||
def done(self, result):
|
||||
self.model.writeToJson()
|
||||
super(ConfigureBlocksDialog, self).done(result)
|
||||
|
Reference in New Issue
Block a user