def addBranches(self, id: int): """Searches for all the lists in the server that have id as their projectId. Creates a QTreeWidgetItem for each list and add the item into the top level QTreeWidgetItem. """ server = Server() name = server.getProjectName(id) branches = server.getListsNameFromProject(id) self.listsOpen[name] = branches for branch in branches: item = QtWidgets.QTreeWidgetItem(branch) self.trees[name].addChild(item) self.trees[name].setExpanded(True)
def isTreeUpdated(self, projectName: str) -> bool: """If any project is currently open in the ProjectTree, the function checks if those projects are update. If the project is updated the function returns true. """ if len(self.listsOpen) > 0: server = Server() dbList = server.getListsNameFromProject( self.projectIds[projectName]) if len(self.listsOpen[projectName]) != len(dbList): return False else: return sorted(self.listsOpen[projectName]) == sorted(dbList) else: return True
def updateTree(self, projectName: str): """Checks if the project with projectName is in the ProjectTree and also if the project is not updated, if both question return true, the fuction searches on the database for the missing list names and add it to the ProjectTree. """ isProjectOpen = projectName in self.projectIds.keys() isTreeUpdated = self.isTreeUpdated(projectName) if isProjectOpen and not isTreeUpdated: server = Server() dbList = server.getListsNameFromProject( self.projectIds[projectName]) openSet = set(self.listsOpen[projectName]) toUpdate = [item for item in dbList if item not in openSet] for value in toUpdate: item = QtWidgets.QTreeWidgetItem(value) self.trees[projectName].addChild(item)