Beispiel #1
0
    def writeObjectTypes(self, fileName, objectTypes):
        self.mError = ''
        file = QFile(fileName)
        if (not file.open(QIODevice.WriteOnly | QIODevice.Text)):
            self.mError = QCoreApplication.translate(
                        "ObjectTypes", "Could not open file for writing.")
            return False

        writer = QXmlStreamWriter(file)
        writer.setAutoFormatting(True)
        writer.setAutoFormattingIndent(1)
        writer.writeStartDocument()
        writer.writeStartElement("objecttypes")
        for objectType in objectTypes:
            writer.writeStartElement("objecttype")
            writer.writeAttribute("name", objectType.name)
            writer.writeAttribute("color", objectType.color.name())
            writer.writeEndElement()

        writer.writeEndElement()
        writer.writeEndDocument()
        if (file.error() != QFile.NoError):
            self.mError = file.errorString()
            return False

        return True
Beispiel #2
0
    def writeObjectTypes(self, fileName, objectTypes):
        self.mError = ''
        file = QFile(fileName)
        if (not file.open(QIODevice.WriteOnly | QIODevice.Text)):
            self.mError = QCoreApplication.translate(
                "ObjectTypes", "Could not open file for writing.")
            return False

        writer = QXmlStreamWriter(file)
        writer.setAutoFormatting(True)
        writer.setAutoFormattingIndent(1)
        writer.writeStartDocument()
        writer.writeStartElement("objecttypes")
        for objectType in objectTypes:
            writer.writeStartElement("objecttype")
            writer.writeAttribute("name", objectType.name)
            writer.writeAttribute("color", objectType.color.name())
            writer.writeEndElement()

        writer.writeEndElement()
        writer.writeEndDocument()
        if (file.error() != QFile.NoError):
            self.mError = file.errorString()
            return False

        return True
Beispiel #3
0
def createWriter(device):
    writer = QXmlStreamWriter(device)
    writer.setAutoFormatting(True)
    writer.setAutoFormattingIndent(1)
    return writer