本文整理汇总了C++中QContact::setPreferredDetail方法的典型用法代码示例。如果您正苦于以下问题:C++ QContact::setPreferredDetail方法的具体用法?C++ QContact::setPreferredDetail怎么用?C++ QContact::setPreferredDetail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QContact
的用法示例。
在下文中一共展示了QContact::setPreferredDetail方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createComplexContacts
void SymbianPluginPerfomance::createComplexContacts()
{
// Create N contacts
QList<QContact> contactsList;
for(int i=0; i<NO_OF_CONTACTS; i++) {
QContact alice;
// Contact details
QString c = QString::number(i);
QString first("Alice");
QString last("Jones");
QContactName aliceName;
aliceName.setFirstName(first.append(c));
aliceName.setLastName(last.append(c));
alice.saveDetail(&aliceName);
QContactPhoneNumber number;
number.setContexts("Home");
number.setSubTypes("Mobile");
number.setNumber("12345678");
alice.saveDetail(&number);
alice.setPreferredDetail("DialAction", number);
QContactPhoneNumber number2;
number2.setContexts("Work");
number2.setSubTypes("Landline");
number2.setNumber("555-4444");
alice.saveDetail(&number2);
QContactAddress add;
add.setStreet("Leeds West Yorkshire");
add.setPostcode("10087");
add.setRegion("New York");
add.setCountry("United States");
alice.saveDetail(&add);
/* Commented out to ensure compatibility with pre-10.1 platforms
QContactGender gender;
gender.setGender("Female");
alice.saveDetail(&gender);
*/
QContactBirthday bday;
bday.setDate(QDate(25,10,1978));
alice.saveDetail(&bday);
/* Commented out to ensure compatibility with pre-10.1 platforms
QContactOnlineAccount acc;
acc.setAccountUri("sips:[email protected]");
acc.setSubTypes(QContactOnlineAccount::SubTypeSip);
alice.saveDetail(&acc);
*/
QContactEmailAddress email;
email.setEmailAddress("mailto:[email protected]");
alice.saveDetail(&email);
QContactOrganization org;
org.setDepartment(QStringList("Services"));
org.setTitle("Assistant Manager");
// Commented out to ensure compatibility with pre-10.1 platforms
//org.setLocation("Nokia Cyber Park");
alice.saveDetail(&org);
contactsList.append(alice);
}
// Save the contacts
mTime.restart();
QMap<int, QContactManager::Error> errors;
mCntMng->saveContacts(&contactsList, &errors);
foreach(QContactManager::Error error, errors) {
QCOMPARE(error, QContactManager::NoError);
}
示例2: saveContactWithPreferredDetails
void TestSymbianEngine::saveContactWithPreferredDetails()
{
QContactManager::Error err;
//save a contact with preferred details
QContact c;
c.setType(QContactType::TypeContact);
QContactPhoneNumber number1;
number1.setNumber("123");
number1.setSubTypes(QContactPhoneNumber::SubTypeMobile);
c.saveDetail(&number1);
c.setPreferredDetail("call", number1);
QContactPhoneNumber number2;
number2.setNumber("456");
number2.setSubTypes(QContactPhoneNumber::SubTypeMobile);
c.saveDetail(&number2);
c.setPreferredDetail("videocall", number2);
QContactPhoneNumber number3;
number3.setNumber("789");
number3.setSubTypes(QContactPhoneNumber::SubTypeMobile);
c.saveDetail(&number3);
c.setPreferredDetail("message", number3);
QContactEmailAddress email;
email.setEmailAddress("dummyemail");
c.saveDetail(&email);
c.setPreferredDetail("email", email);
QContactOnlineAccount onlineAccount;
onlineAccount.setAccountUri("dummy");
onlineAccount.setSubTypes(QContactOnlineAccount::SubTypeImpp);
c.saveDetail(&onlineAccount);
c.setPreferredDetail("OnlineAccountActions", onlineAccount);
QContactUrl url;
url.setUrl("http://dummy");
c.saveDetail(&url);
c.setPreferredDetail("url", url);
QVERIFY(m_engine->saveContact(&c, &err));
QVERIFY(err == QContactManager::NoError);
//fetch the saved contact and check preferred details
QContactFetchHint hint = QContactFetchHint();
QContact fetched = m_engine->contact(c.localId(), hint, &err);
QVERIFY(err == QContactManager::NoError);
QContactDetail callDetail1 = fetched.preferredDetail("call");
QVERIFY(callDetail1.definitionName() == QContactPhoneNumber::DefinitionName);
QContactPhoneNumber fetchedNumber1 = static_cast<QContactPhoneNumber>(callDetail1);
QVERIFY(fetchedNumber1.number() == "123");
QContactDetail callDetail2 = fetched.preferredDetail("videocall");
QVERIFY(callDetail2.definitionName() == QContactPhoneNumber::DefinitionName);
QContactPhoneNumber fetchedNumber2 = static_cast<QContactPhoneNumber>(callDetail2);
QVERIFY(fetchedNumber2.number() == "456");
QContactDetail callDetail3 = fetched.preferredDetail("message");
QVERIFY(callDetail3.definitionName() == QContactPhoneNumber::DefinitionName);
QContactPhoneNumber fetchedNumber3 = static_cast<QContactPhoneNumber>(callDetail3);
QVERIFY(fetchedNumber3.number() == "789");
QContactDetail emailDetail = fetched.preferredDetail("email");
QVERIFY(emailDetail.definitionName() == QContactEmailAddress::DefinitionName);
QContactEmailAddress fetchedEmail = static_cast<QContactEmailAddress>(emailDetail);
QVERIFY(fetchedEmail.emailAddress() == "dummyemail");
QContactDetail onlineAccountDetail = fetched.preferredDetail("OnlineAccountActions");
QVERIFY(onlineAccountDetail.definitionName() == QContactOnlineAccount::DefinitionName);
QContactOnlineAccount fetchedOnlineAccount = static_cast<QContactOnlineAccount>(onlineAccountDetail);
QVERIFY(fetchedOnlineAccount.accountUri() == "dummy");
QContactDetail urlDetail = fetched.preferredDetail("url");
QVERIFY(urlDetail.definitionName() == QContactUrl::DefinitionName);
QContactUrl fetchedUrl = static_cast<QContactUrl>(urlDetail);
QVERIFY(fetchedUrl.url() == "http://dummy");
//save a contact with one preferred details for several actions
QContact c2;
c2.setType(QContactType::TypeContact);
c2.saveDetail(&number1);
c2.setPreferredDetail("call", number1);
c2.setPreferredDetail("videocall", number1);
c2.setPreferredDetail("message", number1);
QVERIFY(m_engine->saveContact(&c2, &err));
QVERIFY(err == QContactManager::NoError);
//fetch the saved contact and check preferred details
QContact fetched2 = m_engine->contact(c2.localId(), hint, &err);
QVERIFY(err == QContactManager::NoError);
QContactDetail callDetail4 = fetched2.preferredDetail("call");
QVERIFY(callDetail4.definitionName() == QContactPhoneNumber::DefinitionName);
QContactPhoneNumber fetchedNumber4 = static_cast<QContactPhoneNumber>(callDetail4);
QVERIFY(fetchedNumber4.number() == "123");
//.........这里部分代码省略.........