本文整理汇总了C++中kcontacts::Addressee::insertCustom方法的典型用法代码示例。如果您正苦于以下问题:C++ Addressee::insertCustom方法的具体用法?C++ Addressee::insertCustom怎么用?C++ Addressee::insertCustom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kcontacts::Addressee
的用法示例。
在下文中一共展示了Addressee::insertCustom方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: itemFromEntry
Akonadi::Item ContactsHandler::itemFromEntry(const KDSoapGenerated::TNS__Entry_value &entry, const Akonadi::Collection &parentCollection, bool &deleted)
{
Akonadi::Item item;
const QList<KDSoapGenerated::TNS__Name_value> valueList = entry.name_value_list().items();
if (valueList.isEmpty()) {
qCWarning(FATCRM_SUGARCRMRESOURCE_LOG) << "Contacts entry for id=" << entry.id() << "has no values";
return item;
}
item.setRemoteId(entry.id());
item.setParentCollection(parentCollection);
item.setMimeType(KContacts::Addressee::mimeType());
KContacts::Addressee addressee;
addressee.setUid(entry.id());
KContacts::Address workAddress, homeAddress;
workAddress.setType(KContacts::Address::Work | KContacts::Address::Pref);
homeAddress.setType(KContacts::Address::Home);
const AccessorHash accessors = accessorHash();
Q_FOREACH (const KDSoapGenerated::TNS__Name_value &namedValue, valueList) {
const QString crmFieldName = sugarFieldToCrmField(namedValue.name());
const AccessorHash::const_iterator accessIt = accessors.constFind(crmFieldName);
if (accessIt == accessors.constEnd()) { // no accessor for regular field
const QString customCrmFieldName = customSugarFieldToCrmField(namedValue.name());
addressee.insertCustom(QStringLiteral("FATCRM"), QStringLiteral("X-Custom-%1").arg(customCrmFieldName), KDCRMUtils::decodeXML(namedValue.value()));
continue;
}
const QString value = KDCRMUtils::decodeXML(namedValue.value());
if (isAddressValue(crmFieldName)) {
KContacts::Address &address =
isPrimaryAddressValue(crmFieldName) ? workAddress : homeAddress;
(*accessIt).setter.aSetter(value, address);
} else {
(*accessIt).setter.vSetter(value, addressee);
}
}
addressee.insertAddress(workAddress);
addressee.insertAddress(homeAddress);
item.setPayload<KContacts::Addressee>(addressee);
item.setRemoteRevision(getDateModified(addressee));
deleted = getDeleted(addressee) == QLatin1String("1");
return item;
}
示例2: storeContact
void CustomFieldsListWidget::storeContact(KContacts::Addressee &contact) const
{
const CustomField::List customFields = mModel->customFields();
for (const CustomField &customField : customFields) {
// write back values for local and global scope, leave external untouched
if (customField.scope() != CustomField::ExternalScope) {
if (!customField.value().isEmpty()) {
contact.insertCustom(QStringLiteral("KADDRESSBOOK"), customField.key(), customField.value());
} else {
contact.removeCustom(QStringLiteral("KADDRESSBOOK"), customField.key());
}
}
}
// Now remove all fields that were available in loadContact (these are stored in mLocalCustomFields)
// but are not part of customFields now, which means they have been removed or renamed by the user
// in the editor dialog.
for (const CustomField &oldCustomField : qAsConst(mLocalCustomFields)) {
if (oldCustomField.scope() != CustomField::ExternalScope) {
bool fieldStillExists = false;
for (const CustomField &newCustomField : qAsConst(customFields)) {
if (newCustomField.scope() != CustomField::ExternalScope) {
if (newCustomField.key() == oldCustomField.key()) {
fieldStillExists = true;
break;
}
}
}
if (!fieldStillExists) {
contact.removeCustom(QStringLiteral("KADDRESSBOOK"), oldCustomField.key());
}
}
}
// And store the global custom fields descriptions as well
CustomField::List globalCustomFields;
for (const CustomField &customField : qAsConst(customFields)) {
if (customField.scope() == CustomField::GlobalScope) {
globalCustomFields << customField;
}
}
CustomFieldManager::setGlobalCustomFieldDescriptions(globalCustomFields);
}
示例3: customFieldsTest
void AddresseeTest::customFieldsTest()
{
KContacts::Addressee a;
// test for empty
QVERIFY(a.customs().isEmpty());
// test insert
a.insertCustom(QStringLiteral("MyApp"), QStringLiteral("MyKey"), QStringLiteral("MyValue"));
QCOMPARE(a.customs().count(), 1);
QCOMPARE(a.custom(QStringLiteral("MyApp"), QStringLiteral("MyKey")), QStringLiteral("MyValue"));
a.insertCustom(QStringLiteral("MyApp"), QStringLiteral("MyKey"), QStringLiteral("YourValue"));
QCOMPARE(a.customs().count(), 1); // still one, we overwrite...
QCOMPARE(a.custom(QStringLiteral("MyApp"), QStringLiteral("MyKey")), QStringLiteral("YourValue"));
// test query non-existing app/key
QCOMPARE(a.custom(QStringLiteral("MyApp"), QStringLiteral("UnknownKey")), QString());
QCOMPARE(a.custom(QStringLiteral("UnknownApp"), QStringLiteral("MyKey")), QString());
// test insert with different key
a.insertCustom(QStringLiteral("MyApp"), QStringLiteral("AnotherKey"), QStringLiteral("OtherValue"));
QCOMPARE(a.customs().count(), 2);
QCOMPARE(a.custom(QStringLiteral("MyApp"), QStringLiteral("AnotherKey")), QStringLiteral("OtherValue"));
QCOMPARE(a.custom(QStringLiteral("MyApp"), QStringLiteral("MyKey")), QStringLiteral("YourValue"));
// test insert with different app
a.insertCustom(QStringLiteral("OtherApp"), QStringLiteral("OtherKey"), QStringLiteral("OurValue"));
QCOMPARE(a.customs().count(), 3);
QCOMPARE(a.custom(QStringLiteral("OtherApp"), QStringLiteral("OtherKey")), QStringLiteral("OurValue"));
QCOMPARE(a.custom(QStringLiteral("MyApp"), QStringLiteral("AnotherKey")), QStringLiteral("OtherValue"));
QCOMPARE(a.custom(QStringLiteral("MyApp"), QStringLiteral("MyKey")), QStringLiteral("YourValue"));
#if 0 //Order is not defined now as we use a QHash
// test customs
QCOMPARE(a.customs().at(0), QStringLiteral("MyApp-MyKey:YourValue"));
QCOMPARE(a.customs().at(1), QStringLiteral("MyApp-AnotherKey:OtherValue"));
QCOMPARE(a.customs().at(2), QStringLiteral("OtherApp-OtherKey:OurValue"));
#endif
// test equal operator
KContacts::Addressee b;
b.setUid(a.uid());
b.insertCustom(QStringLiteral("OtherApp"), QStringLiteral("OtherKey"), QStringLiteral("OurValue"));
b.insertCustom(QStringLiteral("MyApp"), QStringLiteral("MyKey"), QStringLiteral("YourValue"));
b.insertCustom(QStringLiteral("MyApp"), QStringLiteral("AnotherKey"), QStringLiteral("OtherValue"));
QCOMPARE(a, b);
b.insertCustom(QStringLiteral("MyApp"), QStringLiteral("AnotherKey"), QStringLiteral("WrongValue"));
QVERIFY(a != b);
// test setCustoms
KContacts::Addressee c;
c.insertCustom(QStringLiteral("ThisApp"), QStringLiteral("ShouldNotBe"), QStringLiteral("There"));
QCOMPARE(c.customs().count(), 1);
const QStringList testData = QStringList() << QStringLiteral("FirstApp-FirstKey:FirstValue")
<< QStringLiteral("SecondApp-SecondKey:SecondValue")
<< QStringLiteral("ThirdApp-ThirdKey:ThirdValue");
c.setCustoms(testData);
QCOMPARE(c.customs().count(), 3);
QCOMPARE(c.custom(QStringLiteral("FirstApp"), QStringLiteral("FirstKey")), QStringLiteral("FirstValue"));
QCOMPARE(c.custom(QStringLiteral("SecondApp"), QStringLiteral("SecondKey")), QStringLiteral("SecondValue"));
QCOMPARE(c.custom(QStringLiteral("ThirdApp"), QStringLiteral("ThirdKey")), QStringLiteral("ThirdValue"));
// test remove
QCOMPARE(c.customs().count(), 3);
c.removeCustom(QStringLiteral("UnknownApp"), QStringLiteral("FirstKey"));
QCOMPARE(c.customs().count(), 3);
c.removeCustom(QStringLiteral("FirstApp"), QStringLiteral("UnknownKey"));
QCOMPARE(c.customs().count(), 3);
c.removeCustom(QStringLiteral("FirstApp"), QStringLiteral("FirstKey"));
QCOMPARE(c.customs().count(), 2);
}
示例4: setDoNotCall
static void setDoNotCall(const QString &value, KContacts::Addressee &addressee)
{
addressee.insertCustom(QStringLiteral("FATCRM"), QStringLiteral("X-DoNotCall"), value);
}
示例5: setOpportunityRoleFields
static void setOpportunityRoleFields(const QString &value, KContacts::Addressee &addressee)
{
addressee.insertCustom(QStringLiteral("FATCRM"), QStringLiteral("X-OpportunityRoleFields"), value);
}
示例6: setMAcceptStatusFields
static void setMAcceptStatusFields(const QString &value, KContacts::Addressee &addressee)
{
addressee.insertCustom(QStringLiteral("FATCRM"), QStringLiteral("X-MacceptStatusFields"), value);
}
示例7: setCreatedById
static void setCreatedById(const QString &value, KContacts::Addressee &addressee)
{
addressee.insertCustom(QStringLiteral("FATCRM"), QStringLiteral("X-CreatedById"), value);
}
示例8: setSalutation
static void setSalutation(const QString &value, KContacts::Addressee &addressee)
{
addressee.insertCustom(QStringLiteral("FATCRM"), QStringLiteral("X-Salutation"), value);
}
示例9: setModifiedUserId
static void setModifiedUserId(const QString &value, KContacts::Addressee &addressee)
{
addressee.insertCustom(QStringLiteral("FATCRM"), QStringLiteral("X-ModifiedUserId"), value);
}
示例10: setReportsToUserName
static void setReportsToUserName(const QString &value, KContacts::Addressee &addressee)
{
addressee.insertCustom(QStringLiteral("FATCRM"), QStringLiteral("X-ReportsToUserName"), value);
}
示例11: setCampaignName
static void setCampaignName(const QString &value, KContacts::Addressee &addressee)
{
addressee.insertCustom(QStringLiteral("FATCRM"), QStringLiteral("X-CampaignName"), value);
}
示例12: setAssistantPhone
static void setAssistantPhone(const QString &value, KContacts::Addressee &addressee)
{
addressee.insertCustom(QStringLiteral("FATCRM"), QStringLiteral("X-AssistantsPhone"), value);
}
示例13: setAssistantName
static void setAssistantName(const QString &value, KContacts::Addressee &addressee)
{
addressee.insertCustom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("X-AssistantsName"), value);
}