コード例 #1
0
/*!
 * Do the actual writing and set the error and state appropriately.
 */
void QVersitWriterPrivate::write()
{
    bool canceled = false;
    foreach (const QVersitDocument& document, mInput) {
        if (isCanceling()) {
            canceled = true;
            break;
        }
        QScopedPointer<QVersitDocumentWriter> writer(writerForType(document.type()));
        QTextCodec* codec = mDefaultCodec;
        if (codec == NULL) {
            if (document.type() == QVersitDocument::VCard21Type)
                codec = QTextCodec::codecForName("ISO-8859-1");
            else
                codec = QTextCodec::codecForName("UTF-8");
        }
        writer->setCodec(codec);
        writer->setDevice(mIoDevice);
        writer->encodeVersitDocument(document);
        if (!writer->mSuccessful) {
            setError(QVersitWriter::IOError);
            break;
        }
    }
    if (canceled)
        setState(QVersitWriter::CanceledState);
    else
        setState(QVersitWriter::FinishedState);
}
コード例 #2
0
/*!
 * Do the actual writing and set the error and state appropriately.
 */
void QVersitWriterPrivate::write()
{
    bool canceled = false;

    // Try to get the type from the parameter to startWriting...
    QVersitDocument::VersitType type = documentType();

    foreach (const QVersitDocument& document, mInput) {
        if (isCanceling()) {
            canceled = true;
            break;
        }

        // Get type from the document if not specified in startWriting
        if (type == QVersitDocument::InvalidType)
            type = document.type();

        QScopedPointer<QVersitDocumentWriter> writer(writerForType(type, document));
        QTextCodec* codec = mDefaultCodec;
        if (codec == NULL) {
            if (type == QVersitDocument::VCard21Type) {
                codec = QTextCodec::codecForName("ISO-8859-1");
                writer->setAsciiCodec();
            } else {
                codec = QTextCodec::codecForName("UTF-8");
            }
        }
        writer->setCodec(codec);
        writer->setDevice(mIoDevice);
        if (!writer->encodeVersitDocument(document)) {
            setError(QVersitWriter::IOError);
            break;
        }
    }
    if (canceled)
        setState(QVersitWriter::CanceledState);
    else
        setState(QVersitWriter::FinishedState);
}
コード例 #3
0
ファイル: ggiofactory.cpp プロジェクト: kingnak/GameGenerator
GGViewProjectSerializer *GGIOFactory::viewSerializer(QIODevice *device, GGIOFactory::SerializationType type)
{
    GGAbstractSerializationWriter *writer = writerForType(type, device);
    return new GGViewProjectSerializer(writer, new GGDefaultSerializationProcessor);
}