本文整理汇总了C++中QVersitDocument::addProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ QVersitDocument::addProperty方法的具体用法?C++ QVersitDocument::addProperty怎么用?C++ QVersitDocument::addProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVersitDocument
的用法示例。
在下文中一共展示了QVersitDocument::addProperty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testEmbeddedDocument
void tst_QVersitProperty::testEmbeddedDocument()
{
QVersitDocument document;
QVersitProperty property;
property.setName(QLatin1String("X-tension"));
document.addProperty(property);
mVersitProperty->setValue(QVariant::fromValue(document));
QList<QVersitProperty> embeddedDocumentProperties =
mVersitProperty->value<QVersitDocument>().properties();
QCOMPARE(embeddedDocumentProperties.count(),1);
QCOMPARE(embeddedDocumentProperties[0].name(),QLatin1String("X-TENSION"));
}
示例2: importExample
void importExample()
{
//! [Import example]
QVersitContactImporter importer;
QVersitDocument document;
QVersitProperty property;
property.setName(QString::fromAscii("N"));
property.setValue("Citizen;John;Q;;");
document.addProperty(property);
property.setName(QString::fromAscii("X-UNKNOWN-PROPERTY"));
property.setValue("some value");
document.addProperty(property);
if (importer.importDocuments(QList<QVersitDocument>() << document)) {
QList<QContact> contactList = importer.contacts();
// contactList.first() now contains the "N" property as a QContactName
// propertyHandler.mUnknownProperties contains the list of unknown properties
}
//! [Import example]
}
示例3: 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);
}
示例4: testImporterPlugins
void tst_QVersitContactPlugins::testImporterPlugins() {
QVersitContactImporter importer("Test");
QVersitDocument document;
document.setComponentType("VCARD");
QVersitProperty property;
property.setName("FN");
property.setValue("Bob");
document.addProperty(property);
QVERIFY(importer.importDocuments(QList<QVersitDocument>() << document));
QCOMPARE(importer.contacts().size(), 1);
QList<QContactDetail> details(importer.contacts().first().details("TestDetail"));
QCOMPARE(details.size(), 5);
// The plugins have had their index set such that they should be executed in reverse order
// Check that they are all loaded, and run in the correct order
QCOMPARE(details.at(0).value<int>("Plugin"), 5);
QCOMPARE(details.at(1).value<int>("Plugin"), 4);
QCOMPARE(details.at(2).value<int>("Plugin"), 3);
QCOMPARE(details.at(3).value<int>("Plugin"), 2);
QCOMPARE(details.at(4).value<int>("Plugin"), 1);
}