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