当前位置: 首页>>代码示例>>C++>>正文


C++ QVersitDocument::setType方法代码示例

本文整理汇总了C++中QVersitDocument::setType方法的典型用法代码示例。如果您正苦于以下问题:C++ QVersitDocument::setType方法的具体用法?C++ QVersitDocument::setType怎么用?C++ QVersitDocument::setType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QVersitDocument的用法示例。


在下文中一共展示了QVersitDocument::setType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: exportContacts

/*!
 * Converts \a contacts into a list of corresponding QVersitDocuments, using the format given by
 * \a versitType.
 *
 * Returns true on success.  If any of the contacts could not be exported, false is returned and
 * errorMap() will return a list describing the errors that occurred.  The successfully exported
 * documents will still be available via documents().
 *
 * \sa documents(), errorMap()
 */
bool QVersitContactExporter::exportContacts(
    const QList<QContact>& contacts,
    QVersitDocument::VersitType versitType)
{
    int contactIndex = 0;
    d->mDocuments.clear();
    d->mErrors.clear();
    bool ok = true;
    foreach (const QContact& contact, contacts) {
        if (contact.isEmpty()) {
            d->mErrors[contactIndex] = EmptyContactError;
            ok = false;
            continue;
        }

        QVersitDocument versitDocument;
        versitDocument.setType(versitType);
        versitDocument.setComponentType(QLatin1String("VCARD"));
        d->exportContact(contact, versitDocument);
        d->mDocuments.append(versitDocument);
        contactIndex++;
    }

    return ok;
}
开发者ID:,项目名称:,代码行数:35,代码来源:

示例2: testWritingVersions

void tst_QVersitWriter::testWritingVersions()
{
    mWriter->setDevice(mOutputDevice);
    mOutputDevice->open(QBuffer::ReadWrite);

    QVersitDocument document;
    QVersitProperty property;
    property.setName(QString(QString::fromLatin1("FN")));
    property.setValue(QString::fromLatin1("John"));
    document.addProperty(property);

    QByteArray vCard30(
        "BEGIN:VCARD\r\n"
        "VERSION:3.0\r\n"
        "FN:John\r\n"
        "END:VCARD\r\n");
    QByteArray vCard21(
        "BEGIN:VCARD\r\n"
        "VERSION:2.1\r\n"
        "FN:John\r\n"
        "END:VCARD\r\n");

    // Given no type or componentType, it should be vCard 3.0
    QVERIFY(mWriter->startWriting(document));
    mWriter->waitForFinished();
    QCOMPARE(mOutputDevice->buffer(), vCard30);

    // document type should override the guess
    document.setType(QVersitDocument::VCard21Type);
    mOutputDevice->buffer().clear();
    mOutputDevice->seek(0);
    QVERIFY(mWriter->startWriting(document));
    mWriter->waitForFinished();
    QCOMPARE(mOutputDevice->buffer(), vCard21);

    // param to startWriting should override document type
    mOutputDevice->buffer().clear();
    mOutputDevice->seek(0);
    QVERIFY(mWriter->startWriting(document, QVersitDocument::VCard30Type));
    mWriter->waitForFinished();
    QCOMPARE(mOutputDevice->buffer(), vCard30);
}
开发者ID:chriadam,项目名称:qtpim,代码行数:42,代码来源:tst_qversitwriter.cpp

示例3: exportItems

/*!
 * Converts \a items into a QVersitDocument, using the format given by \a versitType.
 * Returns true on success.  If any of the items could not be exported, false is returned and
 * errorMap() will return a list describing the errors that occurred.  The successfully exported
 * components will still be available via document().
 *
 * \sa document(), errorMap()
 */
bool QVersitOrganizerExporter::exportItems(
    const QList<QOrganizerItem>& items,
    QVersitDocument::VersitType versitType)
{
    int itemIndex = 0;
    d->mErrors.clear();
    d->mResult.clear();
    d->mResult.setType(versitType);
    d->mResult.setComponentType(QLatin1String("VCALENDAR"));
    bool ok = true;
    QList<QVersitDocument> results;
    foreach (const QOrganizerItem& item, items) {
        QVersitDocument document;
        document.setType(versitType);
        QVersitOrganizerExporter::Error error;
        if (d->exportItem(item, &document, &error)) {
            results.append(document);
        } else {
            d->mErrors.insert(itemIndex, error);
            ok = false;
        }
        itemIndex++;
    }
开发者ID:,项目名称:,代码行数:31,代码来源:


注:本文中的QVersitDocument::setType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。