Esempio n. 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_()
Esempio n. 2
0
    def addRow(self):
        """Checks if the current number of rows in the TagTable widget is less
        than 50, if it is, a row is added to the lines table on the server and 
        an empty row is added to the TagTable widget.
        """
        if self.rowCount() < 50:
            server = Server()
            server.addLine("", "", "", "", "NULL", self.id)

            for value in [
                    line[0] for line in server.getLinesFromList(self.id)
            ]:
                if value not in self.lineIds:
                    newId = value

            self.insertRow(self.rowCount())
            for column in range(0, self.columnCount()):
                item = TagTableWidgetItem("", newId)
                self.setItem(self.rowCount(), column, item)
        else:
            error = QtWidgets.QErrorMessage()
            message = "O número máximo de linhas permitidas em uma lista é 50!"
            error.showMessage(message)
            error.exec_()
Esempio n. 3
0
from server.server import Server

if __name__ == '__main__':
    path = "./server/database/teste.db"
    server = Server(path)
    server.addProject("Projeto 1")
    server.addList("Lista 1", 1)
    server.addLine("AHH3DF", "Causa", "Analógico", "Pressão alta H", 1, 1)
    server.addLine("ASGG4", "Causa", "Digital", "Pressão baixa L", 2, 1)
    server.addLine("ADH33", "Causa", "Analógico", "Pressão alta H", 1, 1)
    server.addLine("AF5GG", "Causa", "Analógico", "Falha na válvula", 5, 1)
    server.addLine("AKJJ7", "Causa", "Digital", "Falha", 4, 1)
    server.addList("Lista 2", 1)
    server.addLine("ADA33", "Causa", "Analógico", "Pressão alta H", 3, 2)
    server.addLine("131DD", "Efeito", "Digital", "Redução da pressão", 3, 2)
    server.addLine("ADHH4", "Causa", "Analógico", "Pressão alta H", 3, 2)
    server.addLine("HUJU7", "Causa", "Analógico", "Falha na válvula", 3, 2)
    server.addLine("FFF44F", "Efeito", "Digital", "Falha", 3, 2)