本文整理汇总了C++中QContactEmailAddress::setContexts方法的典型用法代码示例。如果您正苦于以下问题:C++ QContactEmailAddress::setContexts方法的具体用法?C++ QContactEmailAddress::setContexts怎么用?C++ QContactEmailAddress::setContexts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QContactEmailAddress
的用法示例。
在下文中一共展示了QContactEmailAddress::setContexts方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setEmailAddressType
void SeasidePerson::setEmailAddressType(int which, SeasidePerson::DetailTypes type)
{
const QList<QContactEmailAddress> &emails = mContact.details<QContactEmailAddress>();
if (which >= emails.length()) {
qWarning() << "Unable to set type for email address: invalid index specified. Aborting.";
return;
}
QContactEmailAddress email = emails.at(which);
if (type == SeasidePerson::EmailHomeType) {
email.setContexts(QContactDetail::ContextHome);
} else if (type == SeasidePerson::EmailWorkType) {
email.setContexts(QContactDetail::ContextWork);
} else if (type == SeasidePerson::EmailOtherType) {
email.setContexts(QContactDetail::ContextOther);
} else {
qWarning() << "Warning: Could not save email type '" << type << "'";
}
mContact.saveDetail(&email);
emit emailAddressTypesChanged();
}
示例2: indexChanged
void CntEmailEditorViewItem::indexChanged( int aIndex )
{
QString context = mItem->comboBox()->itemData( aIndex, DetailContext ).toString();
// check that if current QContactDetail contains the changed subtype
HbDataFormModel* model = static_cast<HbDataFormModel*>(itemView()->model());
CntDetailModelItem* item = static_cast<CntDetailModelItem*>( model->itemFromIndex(modelIndex()) );
QStringList contextList;
if ( !context.isEmpty() )
contextList << context;
QContactEmailAddress address = item->detail();
address.setContexts( contextList );
item->setDetail( address );
}
示例3: generateContact
QContact generateContact(const QString &syncTarget = QString(QLatin1String("local")), bool possiblyAggregate = false)
{
static const QStringList firstNames(generateFirstNamesList());
static const QStringList middleNames(generateMiddleNamesList());
static const QStringList lastNames(generateLastNamesList());
static const QStringList nonOverlappingFirstNames(generateNonOverlappingFirstNamesList());
static const QStringList nonOverlappingLastNames(generateNonOverlappingLastNamesList());
static const QStringList phoneNumbers(generatePhoneNumbersList());
static const QStringList emailProviders(generateEmailProvidersList());
static const QStringList avatars(generateAvatarsList());
static const QStringList hobbies(generateHobbiesList());
// we randomly determine whether to generate various details
// to ensure that we have heterogeneous contacts in the db.
QContact retn;
int random = qrand();
bool preventAggregate = (syncTarget != QLatin1String("local") && !possiblyAggregate);
// We always have a sync target.
QContactSyncTarget synctarget;
synctarget.setSyncTarget(syncTarget);
retn.saveDetail(&synctarget);
// We always have a name. Select an overlapping name if the sync target
// is something other than "local" and possiblyAggregate is true.
QContactName name;
name.setFirstName(preventAggregate ?
nonOverlappingFirstNames.at(random % nonOverlappingFirstNames.size()) :
firstNames.at(random % firstNames.size()));
name.setLastName(preventAggregate ?
nonOverlappingLastNames.at(random % nonOverlappingLastNames.size()) :
lastNames.at(random % lastNames.size()));
if ((random % 6) == 0) name.setMiddleName(middleNames.at(random % middleNames.size()));
if ((random % 17) == 0) name.setPrefix(QLatin1String("Dr."));
retn.saveDetail(&name);
// Favorite
if ((random % 31) == 0) {
QContactFavorite fav;
fav.setFavorite(true);
retn.saveDetail(&fav);
}
// Phone number
if ((random % 3) == 0) {
QContactPhoneNumber phn;
QString randomPhn = phoneNumbers.at(random % phoneNumbers.size());
phn.setNumber(preventAggregate ? QString(QString::number(random % 500000) + randomPhn) : randomPhn);
if ((random % 9) == 0) phn.setContexts(QContactDetail::ContextWork);
retn.saveDetail(&phn);
}
// Email
if ((random % 2) == 0) {
QContactEmailAddress em;
em.setEmailAddress(QString(QLatin1String("%1%2%3%4"))
.arg(preventAggregate ? QString(QString::number(random % 500000) + syncTarget) : QString())
.arg(name.firstName()).arg(name.lastName())
.arg(emailProviders.at(random % emailProviders.size())));
if (random % 9) em.setContexts(QContactDetail::ContextWork);
retn.saveDetail(&em);
}
// Avatar
if ((random % 5) == 0) {
QContactAvatar av;
av.setImageUrl(name.firstName() + avatars.at(random % avatars.size()));
retn.saveDetail(&av);
}
// Hobby
if ((random % 21) == 0) {
QContactHobby h1;
h1.setHobby(hobbies.at(random % hobbies.size()));
retn.saveDetail(&h1);
int newRandom = qrand();
if ((newRandom % 2) == 0) {
QContactHobby h2;
h2.setHobby(hobbies.at(newRandom % hobbies.size()));
retn.saveDetail(&h2);
}
}
return retn;
}