本文整理汇总了C++中QContact::categories方法的典型用法代码示例。如果您正苦于以下问题:C++ QContact::categories方法的具体用法?C++ QContact::categories怎么用?C++ QContact::categories使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QContact
的用法示例。
在下文中一共展示了QContact::categories方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findRingTone
QString RingControl::findRingTone()
{
QString ringTone;
if(DialerControl::instance()->hasIncomingCall()) {
QPhoneCall call = DialerControl::instance()->incomingCall();
QString numberOrName = call.number();
QContact cnt;
QContactModel *m = ServerContactModel::instance();
if (!call.contact().isNull()) {
cnt = m->contact(call.contact());
} else if (!numberOrName.isEmpty()) {
cnt = m->matchPhoneNumber(numberOrName);
}
if (!cnt.uid().isNull()) {
numberOrName = cnt.label();
// video ringtone
ringTone = cnt.customField( "videotone" );
if ( !ringTone.isEmpty() ) {
d->videoTone = true;
} else { // normal ringtone
ringTone = cnt.customField( "tone" );
d->videoTone = false;
}
if ( ringTone.isEmpty() ) {
// check if the contacts category has a ringtone
QList<QString> catList = cnt.categories();
if ( catList.count() ) {
QCategoryManager catManager;
ringTone = catManager.ringTone( catList.at( 0 ) );
}
d->videoTone = false;
}
}
}
return ringTone;
}
示例2: merge
QContact GoogleSession::merge(QContact contact, GoogleContact gContact)
{
qDebug() << "==";
qDebug() << contact.label() << gContact.label();
// merge email lists
QStringList gl = gContact.emailList();
QStringList el = contact.emailList();
for (int i=0; i<gl.size(); ++i) {
if ( el.contains( gl.at(i) ) )
qDebug() << "already have email" << gl.at(i) ;
else
contact.insertEmail( gl.at(i) );
}
// merge phone number lists
QMap<QContact::PhoneType, QString> nums = contact.phoneNumbers();
QMap<QContact::PhoneType, QString> gNums = gContact.phoneNumbers();
// iterate google data
QMapIterator<QContact::PhoneType, QString> gNumIt(gNums);
while (gNumIt.hasNext()) {
gNumIt.next();
QString phone = gNumIt.value();
QContact::PhoneType type = gNumIt.key();
if (! nums.values().contains( phone ) ) {
gContact.setPhoneNumber(type, phone);
qDebug () << "adding phone" << phone << "of type" << type;
} else {
// iterate qtopia data
QMapIterator<QContact::PhoneType, QString> it(nums);
while (it.hasNext()) {
it.next();
qDebug() << "contacts has phone" << it.value() << "of type" << it.key();
qDebug() << "comparing to google" << phone << "of type" << type;
if (it.value() == phone && it.key() != type ) {
bool updatedef = (contact.defaultPhoneNumber() == phone);
nums.remove(it.key() );
nums.remove(type); // FIXME
nums.insert(type, phone);
contact.setPhoneNumbers(nums);
if (updatedef)
contact.setDefaultPhoneNumber(type);
qDebug() << "replaced phone of type" << type << phone << updatedef;
break;
}
}
qDebug () << "skipping phone" << phone << type ;
}
}
QStringList googleGroupList = gContact.categories();
for (int i=0; i<googleGroupList.size(); ++i) {
QString googleGroupId = googleGroupList.at(i);
QString googleGroupName = groups[googleGroupId];
QString googleGroupQId = "category." + googleGroupName;
qDebug() << "Group id" <<googleGroupId << "name" << googleGroupName ;
if (googleGroupName.isEmpty())
continue;
QList<QString> qGroupList = contact.categories();
if (! qGroupList.contains(googleGroupQId) ) {
qGroupList << googleGroupQId;
qDebug() << "Adding group" << googleGroupName ;
contact.setCategories(qGroupList);
} else {
qDebug() << "Skipping group" << googleGroupName;
}
qDebug() << "group count" << qGroupList.count();
}
qDebug() << "\n";
return contact;
}