コード例 #1
0
ファイル: main.py プロジェクト: miano-kamuru/sailfish-engine
 def addEntityAttribute_Float(self, objectName, property_name,
                              property_description, minimum,
                              maximum):  #New float attribute
     if (project.getAttributeIdThroughName(
             objectName,
             property_name) == "error"):  #attribute does not exist
         if (
                 project.getEntityIdThroughName(objectName) != "error"
         ):  #if object exists #will get object currently selected in comboBox
             objectId = project.getEntityIdThroughName(
                 objectName)  #get object id
             project.addEntityAttribute(id=objectId,
                                        name=property_name,
                                        aType="Float",
                                        interface="textbox (default)",
                                        description=property_description,
                                        labels=[minimum, maximum])
             if (objectName == self._currentEntitySelected
                 ):  #if the object is currently selected
                 object = project.getEntityById(objectId)
                 attrib = object.attributes[-1]
                 msg = QVariant([
                     attrib.name, attrib.type, attrib.interface,
                     str(attrib.description)
                 ])
                 QMetaObject.invokeMethod(self.object,
                                          "appendPropertiesModel",
                                          Q_ARG(QVariant, msg))
     else:
         QMetaObject.invokeMethod(
             self.object, "attributeExistsError"
         )  #will be invoked if attribute with the same name exists --JAVASCRIPT FUNCTION
コード例 #2
0
ファイル: main.py プロジェクト: miano-kamuru/sailfish-engine
 def addEntityAttribute_String(self, objectName, property_name,
                               property_description, property_interface,
                               plabels):  #add a string attribute
     if (project.getAttributeIdThroughName(
             objectName,
             property_name) == "error"):  #attribute does not exist
         if (project.getEntityIdThroughName(objectName) !=
                 "error"):  #if object exists
             objectId = project.getEntityIdThroughName(
                 objectName)  #get object id
             project.addEntityAttribute(id=objectId,
                                        name=property_name,
                                        aType="String",
                                        interface=property_interface,
                                        description=property_description,
                                        labels=plabels)
             if (objectName == self._currentEntitySelected
                 ):  #if the object is currently selected
                 object = project.getEntityById(objectId)
                 attrib = object.attributes[-1]
                 msg = QVariant([
                     attrib.name, attrib.type, attrib.interface,
                     str(attrib.description)
                 ])
                 QMetaObject.invokeMethod(self.object,
                                          "appendPropertiesModel",
                                          Q_ARG(QVariant, msg))
     else:
         QMetaObject.invokeMethod(self.object, "attributeExistsError")
コード例 #3
0
ファイル: main.py プロジェクト: miano-kamuru/sailfish-engine
    def triggerAtrributeDelete(
            self, row):  #invoked when user wants to delete attribute
        if (project.getEntityCount()):  #if object count > 0
            if (self._currentEntitySelected != None):
                if (
                        row == -1
                ):  #if no row is selected --Row is the currentRow in table view
                    QMetaObject.invokeMethod(
                        self.object, "selectAttributeError"
                    )  #invoked if no attribute is selected --Error
                else:
                    msg = QVariant(row)  #pass properties view current row
                    attributeName = QVariant()
                    attributeName = QMetaObject.invokeMethod(
                        self.object, "getCurrentProperty",
                        Q_RETURN_ARG(QVariant),
                        Q_ARG(QVariant, msg))  #get attribute name
                    attributeId = project.getAttributeIdThroughName(
                        self._currentEntitySelected, attributeName)
                    edit = project.EditAttribute(attributeId)
                    edit.delete()
                    QMetaObject.invokeMethod(self.object,
                                             "removePropertiesModel",
                                             Q_ARG(QVariant, msg))

            else:
                QMetaObject.invokeMethod(
                    self.object,
                    "selectObjectError")  #invoked if no object is selected
        else:
            QMetaObject.invokeMethod(
                self.object,
                "noObjectExists")  #invoke noObjectExists javascript function
コード例 #4
0
ファイル: main.py プロジェクト: miano-kamuru/sailfish-engine
 def renameSelectedAttribute(self, row, attributeName,
                             newName):  #handler for attribute rename
     if (project.getAttributeIdThroughName(
             self._currentEntitySelected,
             newName) == 'error'):  #check if attribute exists
         attributeId = project.getAttributeIdThroughName(
             self._currentEntitySelected, attributeName)
         edit = project.EditAttribute(attributeId)
         edit.name(newName)
         arg1 = QVariant(row)
         arg2 = QVariant(newName)
         msg = QVariant([arg1, arg2])
         QMetaObject.invokeMethod(
             self.object, "setPropertiesModel",
             Q_ARG(QVariant,
                   msg))  #---invoke JAVASCRIPT METHOD to update Model
     else:
         QMetaObject.invokeMethod(
             self.object, "attributeNameError"
         )  #invoked if attribute with that name exists