本文整理汇总了C++中QVersitProperty::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ QVersitProperty::clear方法的具体用法?C++ QVersitProperty::clear怎么用?C++ QVersitProperty::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVersitProperty
的用法示例。
在下文中一共展示了QVersitProperty::clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: document
void tst_QVCard30Writer::testEncodeVersitProperty_data()
{
QTest::addColumn<QVersitProperty>("property");
QTest::addColumn<QByteArray>("expectedResult");
QVersitProperty property;
QByteArray expectedResult;
// No parameters
expectedResult = "FN:John Citizen\r\n";
property.setName(QString::fromAscii("FN"));
property.setValue(QString::fromAscii("John Citizen"));
QTest::newRow("No parameters") << property << expectedResult;
// With parameter(s)
expectedResult = "TEL;TYPE=HOME:123\r\n";
property.setName(QString::fromAscii("TEL"));
property.setValue(QString::fromAscii("123"));
property.insertParameter(QString::fromAscii("TYPE"),QString::fromAscii("HOME"));
QTest::newRow("With parameters, plain value") << property << expectedResult;
// normal FN property is backslash escaped
property.clear();
property.setName(QLatin1String("FN"));
property.setValue(QLatin1String(";,:\\"));
// semicolons, commas and backslashes are escaped (not colons, as per RFC2426)
expectedResult = "FN:\\;\\,:\\\\\r\n";
QTest::newRow("FN property") << property << expectedResult;
// Structured N
property.setName(QLatin1String("N"));
property.setValue(QStringList()
<< QLatin1String("La;st") // needs to be backslash escaped
<< QLatin1String("Fi,rst")
<< QLatin1String("Mi:ddle")
<< QLatin1String("Pr\\efix") // needs to be QP encoded
<< QLatin1String("Suffix"));
property.setValueType(QVersitProperty::CompoundType);
expectedResult = "N:La\\;st;Fi\\,rst;Mi:ddle;Pr\\\\efix;Suffix\r\n";
QTest::newRow("N property") << property << expectedResult;
// Structured CATEGORIES
property.setName(QLatin1String("CATEGORIES"));
property.setValue(QStringList()
<< QLatin1String("re;d")
<< QLatin1String("gr,een")
<< QLatin1String("bl:ue")
<< QLatin1String("ye\\llow"));
property.setValueType(QVersitProperty::ListType);
expectedResult = "CATEGORIES:re\\;d,gr\\,een,bl:ue,ye\\\\llow\r\n";
QTest::newRow("CATEGORIES property") << property << expectedResult;
// Convert X-NICKNAME to NICKNAME
expectedResult = "NICKNAME:Jack\r\n";
property.setParameters(QMultiHash<QString,QString>());
property.setName(QString::fromAscii("X-NICKNAME"));
property.setValue(QString::fromAscii("Jack"));
QTest::newRow("NICKNAME property") << property << expectedResult;
// Convert X-IMPP to IMPP;
expectedResult = "IMPP:msn:msn-address\r\n";
property.setParameters(QMultiHash<QString,QString>());
property.setName(QString::fromAscii("X-IMPP"));
property.setValue(QString::fromAscii("msn:msn-address"));
QTest::newRow("IMPP property") << property << expectedResult;
// AGENT property
expectedResult = "AGENT:BEGIN:VCARD\\nVERSION:3.0\\nFN:Secret Agent\\nEND:VCARD\\n\r\n";
property.setName(QString::fromAscii("AGENT"));
property.setValue(QString());
QVersitDocument document(QVersitDocument::VCard30Type);
document.setComponentType(QLatin1String("VCARD"));
QVersitProperty embeddedProperty;
embeddedProperty.setName(QString(QString::fromAscii("FN")));
embeddedProperty.setValue(QString::fromAscii("Secret Agent"));
document.addProperty(embeddedProperty);
property.setValue(QVariant::fromValue(document));
QTest::newRow("AGENT property") << property << expectedResult;
// Value is base64 encoded.
QByteArray value("value");
expectedResult = "Springfield.HOUSE.PHOTO;ENCODING=b:" + value.toBase64() + "\r\n";
QStringList groups(QString::fromAscii("Springfield"));
groups.append(QString::fromAscii("HOUSE"));
property.setGroups(groups);
property.setParameters(QMultiHash<QString,QString>());
property.setName(QString::fromAscii("PHOTO"));
property.setValue(value);
QTest::newRow("base64 encoded") << property << expectedResult;
// Characters other than ASCII:
expectedResult = "ORG:" + KATAKANA_NOKIA.toUtf8() + "\r\n";
property = QVersitProperty();
property.setName(QLatin1String("ORG"));
property.setValue(KATAKANA_NOKIA);
QTest::newRow("non-ASCII") << property << expectedResult;
// No CHARSET and QUOTED-PRINTABLE parameters
expectedResult = "EMAIL:[email protected]" + KATAKANA_NOKIA.toUtf8() + ".com\r\n";
property = QVersitProperty();
//.........这里部分代码省略.........