Ejemplo n.º 1
0
static QString getAccountId(const KContacts::Addressee &addressee)
{
    return addressee.custom(QStringLiteral("FATCRM"), QStringLiteral("X-AccountId"));
}
Ejemplo n.º 2
0
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);
}
Ejemplo n.º 3
0
static QString getDeleted(const KContacts::Addressee &addressee)
{
    return addressee.custom(QStringLiteral("FATCRM"), QStringLiteral("X-Deleted"));
}
Ejemplo n.º 4
0
static QString getDoNotCall(const KContacts::Addressee &addressee)
{
    return addressee.custom(QStringLiteral("FATCRM"), QStringLiteral("X-DoNotCall"));
}
Ejemplo n.º 5
0
static QString getOpportunityRoleFields(const KContacts::Addressee &addressee)
{
    return addressee.custom(QStringLiteral("FATCRM"), QStringLiteral("X-OpportunityRoleFields"));
}
Ejemplo n.º 6
0
static QString getMAcceptStatusFields(const KContacts::Addressee &addressee)
{
    return addressee.custom(QStringLiteral("FATCRM"), QStringLiteral("X-MacceptStatusFields"));
}
Ejemplo n.º 7
0
static QString getCreatedById(const KContacts::Addressee &addressee)
{
    return addressee.custom(QStringLiteral("FATCRM"), QStringLiteral("X-CreatedById"));
}
Ejemplo n.º 8
0
static QString getSalutation(const KContacts::Addressee &addressee)
{
    return addressee.custom(QStringLiteral("FATCRM"), QStringLiteral("X-Salutation"));
}
Ejemplo n.º 9
0
static QString getReportsToUserId(const KContacts::Addressee &addressee)
{
    return addressee.custom(QStringLiteral("FATCRM"), QStringLiteral("X-ReportsToUserId"));
}
Ejemplo n.º 10
0
static QString getModifiedUserId(const KContacts::Addressee &addressee)
{
    return addressee.custom(QStringLiteral("FATCRM"), QStringLiteral("X-ModifiedUserId"));
}
Ejemplo n.º 11
0
static QString getAssignedUserName(const KContacts::Addressee &addressee)
{
    return addressee.custom(QStringLiteral("FATCRM"), QStringLiteral("X-AssignedUserName"));
}
Ejemplo n.º 12
0
static QString getCampaignName(const KContacts::Addressee &addressee)
{
    return addressee.custom(QStringLiteral("FATCRM"), QStringLiteral("X-CampaignName"));
}
Ejemplo n.º 13
0
static QString getLeadSourceName(const KContacts::Addressee &addressee)
{
    return addressee.custom(QStringLiteral("FATCRM"), QStringLiteral("X-LeadSourceName"));
}
Ejemplo n.º 14
0
static QString getAssistantPhone(const KContacts::Addressee &addressee)
{
    return addressee.custom(QStringLiteral("FATCRM"), QStringLiteral("X-AssistantsPhone"));
}
Ejemplo n.º 15
0
static QString getAssistantName(const KContacts::Addressee &addressee)
{
    return addressee.custom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("X-AssistantsName"));
}