Beispiel #1
0
    def accept(self):
        """
        Add the list to the lists table on the database. Add a empty line to the
        list in the table lines of the database. Checks if the name is used or 
        if the name is an empty string.Updates the tree interface with the new 
        list, if the project is open.
        """
        self.close()

        isProjectEmpty = not self.projectBox.currentText()
        if isProjectEmpty:
            return -1

        isNameUsed = self.checkListNameIsUsed()
        isNameEmpty = self.name.text().isspace() or not self.name.text()
        if not isNameUsed and not isNameEmpty:
            server = Server()
            listName = self.name.text()
            projectId = self.projectDict[self.projectBox.currentText()]
            server.addList(listName, projectId)

            listId = server.getListIdFromProject(listName, projectId)
            server.addLine("", "", "", "", "NULL", listId)

            self.updateTree(self.projectBox.currentText())
        elif isNameEmpty:
            error = QtWidgets.QErrorMessage()
            error.showMessage("O campo nome é obrigatório!")
            error.exec_()
        elif isNameUsed:
            error = QtWidgets.QErrorMessage()
            error.showMessage("Este nome já está sendo utilizado!")
            error.exec_()
Beispiel #2
0
 def checkListNameIsUsed(self):
     """Checks if the project has a list with the same name used in the 
     form.
     """
     server = Server()
     listName = self.name.text()
     projectId = self.projectDict[self.projectBox.currentText()]
     id = server.getListIdFromProject(listName, projectId)
     return id > 0
Beispiel #3
0
 def onItemDoubleClicked(self, it: QtWidgets.QTreeWidgetItem, col: int):
     """When a item in ProjectTree is double clicked this function is 
     activated. The function checks if QTreeWidgetItem has a parent, if the 
     item has a parent the function will search the list id in the database
     and it will create a TagTable in the Tab widget.
     """
     if it.parent() is not None:
         server = Server()
         listName = it.text(col)
         projectId = self.projectIds[str(it.parent().text(col))]
         listId = server.getListIdFromProject(listName, projectId)
         self.openList(listId)