本文整理汇总了C++中QContact::type方法的典型用法代码示例。如果您正苦于以下问题:C++ QContact::type方法的具体用法?C++ QContact::type怎么用?C++ QContact::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QContact
的用法示例。
在下文中一共展示了QContact::type方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: synthesizedDisplayLabel
/*!
* Returns a synthesised display label of a contact
* \a contact to read the data from .
* \a error On return, contains the possible error.
* \return synthesised display label
*/
QString CntDisplayLabel::synthesizedDisplayLabel(const QContact& contact, QContactManager::Error* error)
{
QString displayLabel;
*error = QContactManager::NoError;
int value = m_settings->getValue();
if (value != -1 && value != m_nameOrder) {
m_nameOrder = value;
setDisplayLabelDetails();
}
//contact
if(contact.type() == QContactType::TypeContact) {
displayLabel = generateDisplayLabel(contact, m_contactDisplayLabelDetails);
}
//group
else if (contact.type() == QContactType::TypeGroup) {
displayLabel = generateDisplayLabel(contact, m_groupDisplayLabelDetails);
}
//invalid type
else {
*error = QContactManager::InvalidContactTypeError;
}
return displayLabel;
}
示例2: makeIri
QTM_USE_NAMESPACE
static QString makeIri(const QContact &contact)
{
QContactLocalId localId = contact.localId();
static QContactLocalId lastLocalId = 0;
if (0 == lastLocalId) {
localId = ++lastLocalId;
}
if (QContactType::TypeContact == contact.type()) {
return QString("contact:%1").arg(localId);
}
if (QContactType::TypeGroup == contact.type()) {
return QString("contactgroup:%1").arg(localId);
}
return QString("invalid:%1").arg(localId);
}
示例3: createTagsFromGroups
/*! Adds QContactTag details to the \a contacts, based on the \a relationships.
Tags are created such that if a group contact, B with display label "b", has a HasMember
relationship with a contact, A, then a QContactTag, "b", is added to A.
Group contacts can be passed in with the \a contacts list. If a contact is part of a group which
is not in \a contacts, the \a manager is queried to find them.
*/
void createTagsFromGroups(QList<QContact>* contacts,
const QList<QContactRelationship>& relationships,
const QContactManager* manager)
{
// Map from QContactIds to group names
QMap<QContactId, QString> groupMap;
// Map from QContactIds to indices into the contacts list
QMap<QContactId, int> indexMap;
// Build up groupMap and indexMap
for (int i = 0; i < contacts->size(); ++i) {
QContact contact = contacts->at(i);
if (contact.type() == QContactType::TypeGroup) {
// In practice, you may want to check that there aren't two distinct groups with the
// same name, and you may want to use a field other than display label.
groupMap.insert(contact.id(), contact.displayLabel());
}
indexMap.insert(contact.id(), i);
}
// Now add all the tags specified by the group relationships
foreach (const QContactRelationship& rel, relationships) {
if (rel.relationshipType() == QContactRelationship::HasMember
&& indexMap.contains(rel.second())) {
QString groupName = groupMap.value(rel.first()); // Have we seen the group before?
if (groupName.isEmpty()) {
// Try and find the group in the manager
QContactId groupId = rel.second();
QContactFetchHint fetchHint;
fetchHint.setDetailDefinitionsHint(QStringList(QContactDisplayLabel::DefinitionName));
QContact contact = manager->contact(groupId.localId(), fetchHint);
if (!contact.isEmpty()) {
groupName = contact.displayLabel();
groupMap.insert(groupId, groupName); // Cache the group id/name
}
}
if (!groupName.isEmpty()) {
// Add the tag
QContactTag tag;
tag.setTag(groupName);
(*contacts)[indexMap.value(rel.second())].saveDetail(&tag);
}
}
}
}