本文整理汇总了C++中QContactId::setManagerUri方法的典型用法代码示例。如果您正苦于以下问题:C++ QContactId::setManagerUri方法的具体用法?C++ QContactId::setManagerUri怎么用?C++ QContactId::setManagerUri使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QContactId
的用法示例。
在下文中一共展示了QContactId::setManagerUri方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveContact
bool DummyEngine::saveContact(QContact* contact, bool batch, QContactManager::Error* error)
{
// ensure that the contact's details conform to their definitions
if (!validateContact(*contact, error)) {
*error = QContactManager::InvalidDetailError;
return false;
}
// success!
QContactId newId;
newId.setManagerUri(managerUri());
newId.setLocalId(5);
contact->setId(newId);
*error = QContactManager::NoError;
// if we need to emit signals (ie, this isn't part of a batch operation)
// then emit the correct one.
if (!batch) {
QList<QContactLocalId> emitList;
emitList.append(contact->id().localId());
emit contactsAdded(emitList);
}
return true;
}
示例2: insertWithGroups
/*! Adds contacts in \a newContacts into \a manager, converting categories specified
with tags into group membership relationships. Note that this implementation uses the
synchronous API of QContactManager for clarity. It is recommended that the asynchronous
API is used in practice.
Relationships are added so that if a contact, A, has a tag "b", then a HasMember relationship is
created between a group contact in the manager, B with display label "b", and contact A. If there
does not exist a group contact with display label "b", one is created.
*/
void insertWithGroups(const QList<QContact>& newContacts, QContactManager* manager)
{
// Cache map from group names to QContactIds
QMap<QString, QContactId> groupMap;
foreach (QContact contact, newContacts) {
if (!manager->saveContact(&contact))
continue; // In practice, better error handling may be required
foreach (const QContactTag& tag, contact.details<QContactTag>()) {
QString groupName = tag.tag();
QContactId groupId;
if (groupMap.contains(groupName)) {
// We've already seen a group with the right name
groupId = groupMap.value(groupName);
} else {
QContactDetailFilter groupFilter;
groupFilter.setDetailDefinitionName(QContactType::DefinitionName);
groupFilter.setValue(QLatin1String(QContactType::TypeGroup));
groupFilter.setMatchFlags(QContactFilter::MatchExactly);
// In practice, some detail other than the display label could be used
QContactDetailFilter nameFilter = QContactDisplayLabel::match(groupName);
QList<QContactLocalId> matchingGroups = manager->contactIds(groupFilter & nameFilter);
if (!matchingGroups.isEmpty()) {
// Found an existing group in the manager
QContactId groupId;
groupId.setManagerUri(manager->managerUri());
groupId.setLocalId(matchingGroups.first());
groupMap.insert(groupName, groupId);
}
else {
// Make a new group
QContact groupContact;
QContactName name;
name.setCustomLabel(groupName);
// Beware that not all managers support custom label
groupContact.saveDetail(&name);
if (!manager->saveContact(&groupContact))
continue; // In practice, better error handling may be required
groupId = groupContact.id();
groupMap.insert(groupName, groupId);
}
}
// Add the relationship
QContactRelationship rel;
rel.setFirst(groupId);
rel.setRelationshipType(QContactRelationship::HasMember);
rel.setSecond(contact.id());
manager->saveRelationship(&rel);
}
}
}
示例3: error
/*!
* The leaving function that queries the SQL database
*
* \a aSqlQuery An SQL query
* \return the list of matched contact ids
*/
QList<QContact> CntSymbianSrvConnection::searchContactNamesL(const TDesC& aSqlQuery)
{
readContactsToBufferL(aSqlQuery, CntSymbianSrvConnection::CntSearchResultList);
RBufReadStream readStream;
QList<QContact> contacts;
TInt id;
TBuf<256> firstName;
TBuf<256> lastName;
TBuf<256> company;
readStream.Open(*m_buffer);
while ((id = readStream.ReadInt32L()) != 0) {
readStream >> firstName;
readStream >> lastName;
readStream >> company;
QContact contact, tempContact;
QContactName name;
name.setFirstName(QString::fromUtf16(firstName.Ptr(), firstName.Length()));
name.setLastName(QString::fromUtf16(lastName.Ptr(), lastName.Length()));
tempContact.saveDetail(&name);
QContactOrganization organization;
organization.setName(QString::fromUtf16(company.Ptr(), company.Length()));
tempContact.saveDetail(&organization);
QContactManager::Error error(QContactManager::NoError);
QString label = m_manager->synthesizedDisplayLabel(tempContact, &error);
if (error != QContactManager::NoError) {
continue;
}
tempContact.clearDetails();
m_manager->setContactDisplayLabel(&contact, label);
QContactId contactId;
contactId.setLocalId(id);
contactId.setManagerUri(m_manager->managerUri());
contact.setId(contactId);
contacts << contact;
}
return contacts;
}
示例4: RunL
void CntSimStorePrivate::RunL()
{
//qDebug() << "CntSimStorePrivate::RunL()" << m_state << iStatus.Int();
m_asyncError = iStatus.Int();
User::LeaveIfError(iStatus.Int());
// NOTE: It is assumed that emitting signals is queued
switch (m_state)
{
case ReadState:
{
QList<QContact> contacts = decodeSimContactsL(m_buffer);
// set sync target and read only access constraint and display label
QList<QContact>::iterator i;
for (i = contacts.begin(); i != contacts.end(); ++i) {
QContactSyncTarget syncTarget;
syncTarget.setSyncTarget(KSimSyncTarget);
m_engine.setReadOnlyAccessConstraint(&syncTarget);
i->saveDetail(&syncTarget);
QContactType contactType = i->detail(QContactType::DefinitionName);
m_engine.setReadOnlyAccessConstraint(&contactType);
i->saveDetail(&contactType);
m_engine.updateDisplayLabel(*i);
}
emit m_simStore.readComplete(contacts, QContactManager::NoError);
}
break;
case WriteState:
{
// save id
QContactId contactId;
contactId.setLocalId(m_writeIndex);
contactId.setManagerUri(m_managerUri);
m_convertedContact.setId(contactId);
// set sync target
if(m_convertedContact.detail(QContactSyncTarget::DefinitionName).isEmpty()) {
QContactSyncTarget syncTarget = m_convertedContact.detail(QContactSyncTarget::DefinitionName);
syncTarget.setSyncTarget(KSimSyncTarget);
m_engine.setReadOnlyAccessConstraint(&syncTarget);
m_convertedContact.saveDetail(&syncTarget);
}
// set type as read only
QContactType contactType = m_convertedContact.detail(QContactType::DefinitionName);
m_engine.setReadOnlyAccessConstraint(&contactType);
m_convertedContact.saveDetail(&contactType);
emit m_simStore.writeComplete(m_convertedContact, QContactManager::NoError);
}
break;
case DeleteState:
{
emit m_simStore.removeComplete(QContactManager::NoError);
}
break;
case ReadReservedSlotsState:
{
QList<int> reservedSlots = decodeReservedSlotsL(m_buffer);
emit m_simStore.getReservedSlotsComplete(reservedSlots, QContactManager::NoError);
}
break;
default:
{
User::Leave(KErrUnknown);
}
break;
}
m_state = InactiveState;
}