def renameSelectedObject( self, objectName, newObjectName ): #This function Renames an object ---HANDLE OBJECT RENAME if (newObjectName != objectName): #if object name is not empty if (project.getEntityIdThroughName(objectName) != "error"): #if object exists if (project.getEntityIdThroughName(newObjectName) == "error" ): #if object with a similiar name does not exist obj = project.EditEntity( project.getEntityIdThroughName(objectName)) obj.name(newObjectName) index = project.getEntityNames().index( newObjectName) #get index arg1 = QVariant(index) arg2 = QVariant(newObjectName) msg = QVariant([arg1, arg2]) QMetaObject.invokeMethod( self.object, "setObjectModel", Q_ARG( QVariant, msg)) #---invoke JAVASCRIPT METHOD to update Model if (self._currentEntitySelected == objectName ): #if current entity selected has the old object name self._currentEntitySelected = newObjectName #update entity to new name else: #if object with similar name exists QMetaObject.invokeMethod( self.object, "objectNameError" ) #if object name exists invoke objectNameError dialog
def triggerOneToMany(self): #invoke one to many relationship dialog if (project.getEntityCount()): #if object count > 0 if (project.getEntityCount() > 1): if (self._currentEntitySelected != None): #entity must be selected others = [ ] #these are other entities excluding the currently selected entity for i in project.getEntityNames(): if (i != self._currentEntitySelected): others.append(i) msg = QVariant( dialogs.oneToManyDialog.format( self._currentEntitySelected, others)) QMetaObject.invokeMethod( self.object, "oneToManyDialog", Q_ARG(QVariant, msg)) #invoke one to one relationship dialog else: QMetaObject.invokeMethod( self.object, "selectToCreateRelationshipErr" ) #invoked if no object is selected else: QMetaObject.invokeMethod( self.object, "notEnoughObjectsError") #invoked if object count is <= 1 else: QMetaObject.invokeMethod( self.object, "noObjectExists") #invoke noObjectExists javascript function
def currentEntitySelectedIndex( self ): #this fproperty holds the index of the currently selected entity/object by user which will be used in object dialog combobox if (self._currentEntitySelected != None): self._currentEntitySelectedIndex = project.getEntityNames().index( self._currentEntitySelected ) #get the index of currently selected entity in ui return self._currentEntitySelectedIndex else: #if no object/entity has been selected by user self._currentEntitySelectedIndex = 0 #set the current object index to 0 (default) return self._currentEntitySelectedIndex
def triggerVisualizeEntity(self): if (project.getEntityCount()): #if object count > 0 msg = QVariant( dialogs.visualizeEntityDialog.format(project.getEntityNames()) ) #pass entity names to delete objects dialog combobox QMetaObject.invokeMethod(self.object, "visualizeObjectDialog", Q_ARG(QVariant, msg)) #invoke the delete window else: QMetaObject.invokeMethod( self.object, "noObjectExists") #invoke noObjectExists javascript function
def triggerObjectRename( self): #this slot is called when user wants to rename object if (project.getEntityCount()): #if object count > 0 msg = QVariant( dialogs.renameEntityDialog.format(project.getEntityNames()) ) #pass entity names to rename objects dialog combobox QMetaObject.invokeMethod(self.object, "renameObjectDialog", Q_ARG(QVariant, msg)) #invoke the rename window else: QMetaObject.invokeMethod( self.object, "noObjectExists") #invoke noObjectExists javascript function
def triggerNewFloatProperty( self): #this function invokes the FLOAT property DIALOG if (project.getEntityCount()): #if object count > 0 msg = QVariant( dialogs.new_floatPropertyDialog.format( project.getEntityNames()) ) #pass entity names to new_stringPropertyDialog dialog combobox QMetaObject.invokeMethod( self.object, "newPropertyDialog", Q_ARG(QVariant, msg) ) #invoke the newPropertyDialog function--Javascript function else: QMetaObject.invokeMethod( self.object, "noObjectExists" ) #invoke noObjectxists function --Javascript function
def triggerNewBooleanProperty( self ): #invoke create BOOLEAN property DIALOG --invoke JAVASCRIPT FUNCTION if (project.getEntityCount()): #if object count > 0 msg = QVariant( dialogs.new_booleanPropertyDialog.format( project.getEntityNames()) ) #pass entity names to new_booleanPropertyDialog dialog combobox QMetaObject.invokeMethod(self.object, "newPropertyDialog", Q_ARG(QVariant, msg)) #invoke newPropertyDialog else: QMetaObject.invokeMethod( self.object, "noObjectExists" ) #invoke noObjectxists function --Javascript function
def deleteSelectedObject( self, objectName): #delete the selected objects --HANDLE OBJECT DELETION if (project.getEntityIdThroughName(objectName) != "error"): if (self._currentEntitySelected == objectName ): #if the currently selected object name==(Entity.name) QMetaObject.invokeMethod(self.object, "cleanPropertiesModel") self._currentEntitySelected = None #set current entity selection to None msg = QVariant(project.getEntityNames().index( objectName)) #get index of entity using name QMetaObject.invokeMethod(self.object, "removeObjectItem", Q_ARG(QVariant, msg)) #remove from listview project.EditEntity(project.getEntityIdThroughName( objectName)).delete() #delete object in database