|
@@ -128,12 +128,16 @@ class CustomScene(QGraphicsScene):
|
|
|
item = selected[0]
|
|
|
|
|
|
if isinstance(item, GraphicsNodeItem):
|
|
|
+ # operation valid?
|
|
|
+ if commons.is_type_mandatory(item.get_type()) and commons.count_occurences(item.get_type(), self._cur_model) == 1:
|
|
|
+ self._parent.plainTextEdit.appendPlainText("Error: Type {} mandatory".format(item.get_type()))
|
|
|
+ return
|
|
|
# delete node in model (also deletes edges connected to it in model)
|
|
|
self._parent.plainTextEdit.appendPlainText("Deleting node of type {}".format(item.get_type()))
|
|
|
mvops.delete_node(self._cur_model, item.node_id)
|
|
|
|
|
|
# in view, delete edges that were connected to this node as well
|
|
|
- # modelverse does this on its own so do not delete edges explicitly here
|
|
|
+ # modelverse does this on its own so do not delete edges explicitly in model
|
|
|
for edge in self.items():
|
|
|
if not isinstance(edge, GraphicsEdgeItem):
|
|
|
continue
|
|
@@ -155,21 +159,21 @@ class CustomScene(QGraphicsScene):
|
|
|
if not isinstance(item, GraphicsNodeItem):
|
|
|
return
|
|
|
|
|
|
- # quickly check if attributing of such a node is allowed
|
|
|
+ # ask user for key value
|
|
|
+ key, ok = QInputDialog.getText(self._parent, "New attribute", "Key value")
|
|
|
+ if not ok or not key:
|
|
|
+ return
|
|
|
+
|
|
|
+ # is operation supported?
|
|
|
QApplication.setOverrideCursor(Qt.WaitCursor)
|
|
|
- self._parent.plainTextEdit.appendPlainText("Checking if attributing nodes of type {} is allowed ...".format(item.get_type()))
|
|
|
- if not mvops.is_attributing_allowed(item.get_type()):
|
|
|
- self._parent.plainTextEdit.appendPlainText("Error: Not allowed".format(item.get_type()))
|
|
|
+ self._parent.plainTextEdit.appendPlainText("Checking if attributing node is allowed ...".format(item.get_type()))
|
|
|
+ if not commons.is_attribute_valid(item.get_type(), key):
|
|
|
+ self._parent.plainTextEdit.appendPlainText("Error: Attribute {} not valid for type {}".format(key, item.get_type()))
|
|
|
QApplication.restoreOverrideCursor()
|
|
|
return
|
|
|
QApplication.restoreOverrideCursor()
|
|
|
self._parent.plainTextEdit.appendPlainText("Yes")
|
|
|
|
|
|
- # ask user for key value
|
|
|
- key, ok = QInputDialog.getText(self._parent, "New attribute", "Key value")
|
|
|
- if not ok or not key:
|
|
|
- return
|
|
|
-
|
|
|
# check if key value already used for this node
|
|
|
attrs = commons.get_attributes_of_node(self._cur_model, item.node_id)
|
|
|
for attr in attrs:
|