예제 #1
0
    def _findIn(self, object, dialog):
        # find Label
        foundLabel = True
        findLabel = dialog.label()
        if findLabel != "":
            label = self.dataAccessor().label(object)
            #logging.debug(__name__ +': _findIn: ' + label)
            if not dialog.caseSensitive():
                label = label.lower()
                findLabel = findLabel.lower()
            if dialog.exactMatch():
                foundLabel = findLabel == "" or findLabel == label
            else:
                foundLabel = findLabel in label

        # find property
        foundProperties = True
        findProperties = dialog.properties()
        if len(findProperties) > 0 and (findProperties[0][0] != ""
                                        or findProperties[0][1] != ""):
            properties = [(p[1], p[2])
                          for p in self.dataAccessor().properties(object)]
            if not dialog.caseSensitive():
                properties = [(str(property[0]).lower(),
                               str(property[1]).lower())
                              for property in properties]
                findProperties = [(str(property[0]).lower(),
                                   str(property[1]).lower())
                                  for property in findProperties]
            if dialog.exactMatch():
                for findProperty in findProperties:
                    foundProperties=(foundProperties and\
                        True in [(findProperty[0]=="" or findProperty[0]==p[0]) and\
                                 (findProperty[1]=="" or findProperty[1]==p[1]) for p in properties])
            else:
                for findProperty in findProperties:
                    foundProperties=(foundProperties and\
                        True in [findProperty[0] in p[0] and\
                                 findProperty[1] in p[1] for p in properties])

        # find property
        findScripts = dialog.scripts()
        foundScripts = True
        if len(findScripts) > 0 and findScripts[0] != "":
            dataAccessorObject = BasicDataAccessorInterface(
                object, self.dataAccessor())
            for findScript in findScripts:
                try:
                    foundScripts=(foundScripts and\
                       (findScript=="" or dataAccessorObject.runScript(findScript)))
                except Exception, e:
                    foundScripts = False
                    logging.info("Error in script: " + exception_traceback())
                    self._message = "Error in script: " + str(e)
예제 #2
0
    def createBoxesRecursive(self,
                             operationId,
                             objects,
                             widgetParent,
                             positionName="0"):
        """ Creates a box from an object.
        
        All children of this object are created recursively.
        """
        #logging.debug(__name__ + ": createBoxesRecursive")
        if self._sortBeforeArranging and self.arrangeUsingRelations():
            thread = ThreadChain(self._sortByRelations, objects)
            while thread.isRunning():
                if not Application.NO_PROCESS_EVENTS:
                    QCoreApplication.instance().processEvents()
            objects = thread.returnValue()

        i = 1
        for object in objects:
            if operationId != self._operationId:
                return None
            # Process application event loop in order to accept user input during time consuming drawing operation
            self._updateCounter += 1
            if self._updateCounter >= self.UPDATE_EVERY:
                self._updateCounter = 0
                if not Application.NO_PROCESS_EVENTS:
                    QCoreApplication.instance().processEvents()
            # create box
            text = ""
            if self._boxContentScript != "":
                dataAccessorObject = BasicDataAccessorInterface(
                    object, self.dataAccessor(), False)
                try:
                    text = dataAccessorObject.runScript(
                        self._boxContentScript).replace("None", "")
                except Exception, e:
                    logging.info("Error in script: " + exception_traceback())
                    text = ""
            widget = self.createBox(widgetParent,
                                    self.dataAccessor().isContainer(object),
                                    self.dataAccessor().label(object), text)
            child_positionName = positionName + "-" + str(i)
            self.addWidget(widget, object, child_positionName)
            i += 1