本文整理汇总了C++中QContactDetailDefinition::insertField方法的典型用法代码示例。如果您正苦于以下问题:C++ QContactDetailDefinition::insertField方法的具体用法?C++ QContactDetailDefinition::insertField怎么用?C++ QContactDetailDefinition::insertField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QContactDetailDefinition
的用法示例。
在下文中一共展示了QContactDetailDefinition::insertField方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: performRequests
//.........这里部分代码省略.........
m_contactFetchRequest.waitForFinished();
//! [Creating a new relationship between two contacts]
// first, create the group and the group member
QContact exampleGroup;
exampleGroup.setType(QContactType::TypeGroup);
QContactNickname groupName;
groupName.setNickname("Example Group");
exampleGroup.saveDetail(&groupName);
QContact exampleGroupMember;
QContactName groupMemberName;
groupMemberName.setFirstName("Member");
exampleGroupMember.saveDetail(&groupMemberName);
// second, save those contacts in the manager
QList<QContact> saveList;
saveList << exampleGroup << exampleGroupMember;
m_contactSaveRequest.setContacts(saveList);
m_contactSaveRequest.start();
m_contactSaveRequest.waitForFinished();
// third, create the relationship between those contacts
QContactRelationship groupRelationship;
groupRelationship.setFirst(exampleGroup.id());
groupRelationship.setRelationshipType(QContactRelationship::HasMember);
groupRelationship.setSecond(exampleGroupMember.id());
// finally, save the relationship in the manager
connect(&m_relationshipSaveRequest, SIGNAL(stateChanged(QContactAbstractRequest::State)), this, SLOT(relationshipSaveRequestStateChanged(QContactAbstractRequest::State)));
m_relationshipSaveRequest.setManager(m_manager);
m_relationshipSaveRequest.setRelationships(QList<QContactRelationship>() << groupRelationship);
m_relationshipSaveRequest.start();
//! [Creating a new relationship between two contacts]
m_contactFetchRequest.waitForFinished();
//! [Retrieving relationships between contacts]
connect(&m_relationshipFetchRequest, SIGNAL(stateChanged(QContactAbstractRequest::State)), this, SLOT(relationshipFetchRequestStateChanged(QContactAbstractRequest::State)));
m_relationshipFetchRequest.setManager(m_manager);
// retrieve the list of relationships between the example group contact and the example member contact
// where the group contact is the first contact in the relationship, and the member contact is the
// second contact in the relationship. In order to fetch all relationships between them, another
// relationship fetch must be performed with their roles reversed, and the results added together.
m_relationshipFetchRequest.setFirst(exampleGroup.id());
m_relationshipFetchRequest.setSecond(exampleGroupMember.id());
m_relationshipFetchRequest.start();
//! [Retrieving relationships between contacts]
m_contactFetchRequest.waitForFinished();
//! [Providing a fetch hint]
QContactFetchHint hasMemberRelationshipsOnly;
hasMemberRelationshipsOnly.setRelationshipTypesHint(QStringList(QContactRelationship::HasMember));
m_contactFetchRequest.setManager(m_manager);
m_contactFetchRequest.setFilter(QContactFilter()); // all contacts
m_contactFetchRequest.setFetchHint(hasMemberRelationshipsOnly);
m_contactFetchRequest.start();
//! [Providing a fetch hint]
//! [Removing a relationship]
connect(&m_relationshipRemoveRequest, SIGNAL(stateChanged(QContactAbstractRequest::State)), this, SLOT(relationshipRemoveRequestStateChanged(QContactAbstractRequest::State)));
m_relationshipRemoveRequest.setManager(m_manager);
m_relationshipRemoveRequest.setRelationships(QList<QContactRelationship>() << groupRelationship);
m_relationshipRemoveRequest.start();
//! [Removing a relationship]
connect(&m_definitionFetchRequest, SIGNAL(stateChanged(QContactAbstractRequest::State)), this, SLOT(definitionFetchRequestStateChanged(QContactAbstractRequest::State)));
//! [Querying the schema supported by a manager]
m_definitionFetchRequest.setManager(m_manager);
m_definitionFetchRequest.setDefinitionNames(QStringList(QContactName::DefinitionName));
m_definitionFetchRequest.start();
m_definitionFetchRequest.waitForFinished();
QMap<QString, QContactDetailDefinition> definitions = m_definitionFetchRequest.definitions();
qDebug() << "This manager"
<< (definitions.value(QContactName::DefinitionName).fields().contains(QContactName::FieldCustomLabel) ? "supports" : "does not support")
<< "the custom label field of QContactName";
//! [Querying the schema supported by a manager]
connect(&m_definitionSaveRequest, SIGNAL(stateChanged(QContactAbstractRequest::State)), this, SLOT(definitionSaveRequestStateChanged(QContactAbstractRequest::State)));
connect(&m_definitionRemoveRequest, SIGNAL(stateChanged(QContactAbstractRequest::State)), this, SLOT(definitionRemoveRequestStateChanged(QContactAbstractRequest::State)));
//! [Modifying the schema supported by a manager]
// modify the name definition, adding a patronym field
QContactDetailDefinition nameDefinition = definitions.value(QContactName::DefinitionName);
QContactDetailFieldDefinition fieldPatronym;
fieldPatronym.setDataType(QVariant::String);
nameDefinition.insertField("Patronym", fieldPatronym);
// save the updated definition in the manager if supported...
if (m_manager->hasFeature(QContactManager::MutableDefinitions)) {
m_definitionSaveRequest.setManager(m_manager);
m_definitionSaveRequest.setContactType(QContactType::TypeContact);
m_definitionSaveRequest.setDefinitions(QList<QContactDetailDefinition>() << nameDefinition);
m_definitionSaveRequest.start();
}
//! [Modifying the schema supported by a manager]
QCoreApplication::exit(0);
}