本文整理汇总了C++中QContact::localId方法的典型用法代码示例。如果您正苦于以下问题:C++ QContact::localId方法的具体用法?C++ QContact::localId怎么用?C++ QContact::localId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QContact
的用法示例。
在下文中一共展示了QContact::localId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removePerson
void SeasideCache::removePerson(SeasidePerson *person)
{
QContact contact = person->contact();
instance->m_contactsToRemove.append(contact.localId());
instance->removeContactData(contact.localId(), SeasideFilteredModel::FilterFavorites);
instance->removeContactData(contact.localId(), SeasideFilteredModel::FilterOnline);
instance->removeContactData(contact.localId(), SeasideFilteredModel::FilterAll);
instance->requestUpdate();
}
示例2: contactsAvailable
void SeasideCache::contactsAvailable()
{
if (m_fetchFilter == SeasideFilteredModel::FilterFavorites
|| m_fetchFilter == SeasideFilteredModel::FilterOnline
|| m_fetchFilter == SeasideFilteredModel::FilterAll) {
// Part of an initial query.
appendContacts(m_fetchRequest.contacts());
} else {
// An update.
const QList<QContact> contacts = m_fetchRequest.contacts();
for (int i = m_resultsRead; i < contacts.count(); ++i) {
QContact contact = contacts.at(i);
SeasideCacheItem &item = m_people[contact.localId()];
QContactName oldName = item.contact.detail<QContactName>();
QContactName newName = contact.detail<QContactName>();
if (newName.customLabel().isEmpty()) {
newName.setCustomLabel(oldName.customLabel());
contact.saveDetail(&newName);
}
const bool roleDataChanged = newName != oldName
|| contact.detail<QContactAvatar>().imageUrl() != item.contact.detail<QContactAvatar>().imageUrl();
item.contact = contact;
item.hasCompleteContact = true;
if (item.person) {
item.person->setContact(contact);
item.person->setComplete(true);
}
QList<QContactPhoneNumber> phoneNumbers = contact.details<QContactPhoneNumber>();
for (int j = 0; j < phoneNumbers.count(); ++j) {
m_phoneNumberIds[phoneNumbers.at(j).number()] = contact.localId();
}
if (roleDataChanged) {
instance->updateContactData(contact.localId(), SeasideFilteredModel::FilterFavorites);
instance->updateContactData(contact.localId(), SeasideFilteredModel::FilterOnline);
instance->updateContactData(contact.localId(), SeasideFilteredModel::FilterAll);
}
}
m_resultsRead = contacts.count();
}
}
示例3: appendContacts
void SeasideCache::appendContacts(const QList<QContact> &contacts)
{
QVector<QContactLocalId> &cacheIds = m_contacts[m_fetchFilter];
QList<SeasideFilteredModel *> &models = m_models[m_fetchFilter];
cacheIds.reserve(contacts.count());
const int begin = cacheIds.count();
int end = contacts.count() - 1;
#ifndef SEASIDE_SPARQL_QUERIES
// Exclude the self contact Id.
for (int i = cacheIds.count(); i < contacts.count(); ++i) {
if (contacts.at(i).localId() == m_selfId) {
--end;
break;
}
}
#endif
for (int i = 0; i < models.count(); ++i)
models.at(i)->sourceAboutToInsertItems(begin, end);
for (int i = cacheIds.count(); i < contacts.count(); ++i) {
QContact contact = contacts.at(i);
#ifndef SEASIDE_SPARQL_QUERIES
if (contact.localId() == m_selfId)
continue;
#endif
cacheIds.append(contact.localId());
SeasideCacheItem &cacheItem = m_people[contact.localId()];
cacheItem.contact = contact;
cacheItem.filterKey = QStringList();
QList<QContactPhoneNumber> phoneNumbers = contact.details<QContactPhoneNumber>();
for (int j = 0; j < phoneNumbers.count(); ++j)
m_phoneNumberIds[phoneNumbers.at(j).number()] = contact.localId();
}
for (int i = 0; i < models.count(); ++i)
models.at(i)->sourceItemsInserted(begin, end);
}
示例4: savePerson
bool SeasideCache::savePerson(SeasidePerson *person)
{
QContact contact = person->contact();
if (contact.localId()) {
instance->m_contactsToSave[contact.localId()] = contact;
instance->m_people[contact.localId()] = contact;
instance->updateContactData(contact.localId(), SeasideFilteredModel::FilterFavorites);
instance->updateContactData(contact.localId(), SeasideFilteredModel::FilterOnline);
instance->updateContactData(contact.localId(), SeasideFilteredModel::FilterAll);
} else {
instance->m_contactsToCreate.append(contact);
}
instance->requestUpdate();
return true;
}
示例5: write
bool CntSimStorePrivate::write(const QContact &contact, QContactManager::Error *error)
{
if (IsActive()) {
*error = QContactManager::LockedError;
return false;
}
if (m_storeInfo.m_readOnlyAccess) {
*error = QContactManager::NotSupportedError;
return false;
}
// get index
m_writeIndex = KErrNotFound;
if (contact.id().managerUri() == m_managerUri &&
contact.localId() > 0) {
m_writeIndex = contact.localId();
// TODO: check that the contact exist in the sim
}
// encode
m_buffer.Zero();
m_buffer.ReAlloc(KOneSimContactBufferSize);
m_convertedContact = QContact(contact);
TRAPD(err, encodeSimContactL(&m_convertedContact, m_buffer));
if (err != KErrNone) {
CntSymbianSimTransformError::transformError(err, error);
return false;
}
// start writing
m_etelStore.Write(iStatus, m_buffer, m_writeIndex);
SetActive();
m_state = WriteState;
*error = QContactManager::NoError;
return true;
}
示例6: savePerson
bool SeasidePeopleModel::savePerson(SeasidePerson *person)
{
QContact contact = person->contact();
priv->contactsPendingSave.append(contact);
if (contact.localId()) {
// we save the contact to our model as well; if it existed previously.
// this covers our QContactManager being slow at informing us about saves
// with the slight problem that our data may be a little inconsistent if
// the QContactManager decides to save differently from what we asked
// it to - but this is ok, because the save request finishing will fix that.
int rowId = priv->idToIndex.value(contact.localId());
emit dataChanged(index(rowId, 0), index(rowId, 0));
MODEL_DEBUG() << Q_FUNC_INFO << "Faked save for " << contact.localId() << " row " << rowId;
}
// TODO: in a more complicated implementation, we'd only save
// on a timer instead of flushing all the time
priv->savePendingContacts();
return true;
}
示例7: 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);
}
示例8: retrievalId
static QContactLocalId retrievalId(const QContact &contact) { return contact.localId(); }
示例9: foreach
foreach(const QContact& c, contacts) {
QVERIFY(c.id() == empty);
QVERIFY(c.localId() == 0);
}
示例10: saveContactWithPreferredDetails
void TestSymbianEngine::saveContactWithPreferredDetails()
{
QContactManager::Error err;
//save a contact with preferred details
QContact c;
c.setType(QContactType::TypeContact);
QContactPhoneNumber number1;
number1.setNumber("123");
number1.setSubTypes(QContactPhoneNumber::SubTypeMobile);
c.saveDetail(&number1);
c.setPreferredDetail("call", number1);
QContactPhoneNumber number2;
number2.setNumber("456");
number2.setSubTypes(QContactPhoneNumber::SubTypeMobile);
c.saveDetail(&number2);
c.setPreferredDetail("videocall", number2);
QContactPhoneNumber number3;
number3.setNumber("789");
number3.setSubTypes(QContactPhoneNumber::SubTypeMobile);
c.saveDetail(&number3);
c.setPreferredDetail("message", number3);
QContactEmailAddress email;
email.setEmailAddress("dummyemail");
c.saveDetail(&email);
c.setPreferredDetail("email", email);
QContactOnlineAccount onlineAccount;
onlineAccount.setAccountUri("dummy");
onlineAccount.setSubTypes(QContactOnlineAccount::SubTypeImpp);
c.saveDetail(&onlineAccount);
c.setPreferredDetail("OnlineAccountActions", onlineAccount);
QContactUrl url;
url.setUrl("http://dummy");
c.saveDetail(&url);
c.setPreferredDetail("url", url);
QVERIFY(m_engine->saveContact(&c, &err));
QVERIFY(err == QContactManager::NoError);
//fetch the saved contact and check preferred details
QContactFetchHint hint = QContactFetchHint();
QContact fetched = m_engine->contact(c.localId(), hint, &err);
QVERIFY(err == QContactManager::NoError);
QContactDetail callDetail1 = fetched.preferredDetail("call");
QVERIFY(callDetail1.definitionName() == QContactPhoneNumber::DefinitionName);
QContactPhoneNumber fetchedNumber1 = static_cast<QContactPhoneNumber>(callDetail1);
QVERIFY(fetchedNumber1.number() == "123");
QContactDetail callDetail2 = fetched.preferredDetail("videocall");
QVERIFY(callDetail2.definitionName() == QContactPhoneNumber::DefinitionName);
QContactPhoneNumber fetchedNumber2 = static_cast<QContactPhoneNumber>(callDetail2);
QVERIFY(fetchedNumber2.number() == "456");
QContactDetail callDetail3 = fetched.preferredDetail("message");
QVERIFY(callDetail3.definitionName() == QContactPhoneNumber::DefinitionName);
QContactPhoneNumber fetchedNumber3 = static_cast<QContactPhoneNumber>(callDetail3);
QVERIFY(fetchedNumber3.number() == "789");
QContactDetail emailDetail = fetched.preferredDetail("email");
QVERIFY(emailDetail.definitionName() == QContactEmailAddress::DefinitionName);
QContactEmailAddress fetchedEmail = static_cast<QContactEmailAddress>(emailDetail);
QVERIFY(fetchedEmail.emailAddress() == "dummyemail");
QContactDetail onlineAccountDetail = fetched.preferredDetail("OnlineAccountActions");
QVERIFY(onlineAccountDetail.definitionName() == QContactOnlineAccount::DefinitionName);
QContactOnlineAccount fetchedOnlineAccount = static_cast<QContactOnlineAccount>(onlineAccountDetail);
QVERIFY(fetchedOnlineAccount.accountUri() == "dummy");
QContactDetail urlDetail = fetched.preferredDetail("url");
QVERIFY(urlDetail.definitionName() == QContactUrl::DefinitionName);
QContactUrl fetchedUrl = static_cast<QContactUrl>(urlDetail);
QVERIFY(fetchedUrl.url() == "http://dummy");
//save a contact with one preferred details for several actions
QContact c2;
c2.setType(QContactType::TypeContact);
c2.saveDetail(&number1);
c2.setPreferredDetail("call", number1);
c2.setPreferredDetail("videocall", number1);
c2.setPreferredDetail("message", number1);
QVERIFY(m_engine->saveContact(&c2, &err));
QVERIFY(err == QContactManager::NoError);
//fetch the saved contact and check preferred details
QContact fetched2 = m_engine->contact(c2.localId(), hint, &err);
QVERIFY(err == QContactManager::NoError);
QContactDetail callDetail4 = fetched2.preferredDetail("call");
QVERIFY(callDetail4.definitionName() == QContactPhoneNumber::DefinitionName);
QContactPhoneNumber fetchedNumber4 = static_cast<QContactPhoneNumber>(callDetail4);
QVERIFY(fetchedNumber4.number() == "123");
//.........这里部分代码省略.........
示例11: saveContact
void TestSymbianEngine::saveContact()
{
QContactManager::Error err;
QList<QContactSortOrder> sortOrders;
QContactId empty;
QContactFilter defaultFilter = QContactFilter();
int init_count = m_engine->contactIds(defaultFilter, sortOrders, &err).count();
QVERIFY(err == QContactManager::NoError);
// Save a "NULL" contact
QVERIFY(!m_engine->saveContact(NULL, &err));
QVERIFY(err == QContactManager::BadArgumentError);
int current_count = m_engine->contactIds(defaultFilter, sortOrders, &err).count();
QVERIFY(err == QContactManager::NoError);
QVERIFY(init_count == current_count);
// Save a contact that is not in database
QContact invaId;
QVERIFY(m_engine->saveContact(&invaId, &err)); // Add to db
QVERIFY(err == QContactManager::NoError);
QContactId cId = invaId.id();
m_engine->removeContact(invaId.localId(), &err); // Ensure not in db
QVERIFY(err == QContactManager::NoError);
invaId.setId(cId);
QVERIFY(!m_engine->saveContact(&invaId, &err)); // Update non existent contact
QVERIFY(err == QContactManager::DoesNotExistError);
current_count = m_engine->contactIds(defaultFilter, sortOrders, &err).count();
QVERIFY(err == QContactManager::NoError);
QVERIFY(init_count == current_count);
QContact alice;
alice.setType("Jargon");
// Save a "non contact(Jargon) type" contact
QVERIFY(!m_engine->saveContact(&alice, &err));
QVERIFY(err == QContactManager::InvalidDetailError);
QVERIFY(alice.id() == empty);
QVERIFY(alice.localId() == 0);
current_count = m_engine->contactIds(defaultFilter, sortOrders, &err).count();
QVERIFY(err == QContactManager::NoError);
QVERIFY(init_count == current_count);
// Save a valid contact
alice.setType(QContactType::TypeContact);
QVERIFY(m_engine->saveContact(&alice, &err));
QVERIFY(err == QContactManager::NoError);
QVERIFY(alice.id() != empty);
QVERIFY(alice.localId() != 0);
QString uri = QString(QLatin1String(CNT_SYMBIAN_MANAGER_NAME));
QVERIFY(alice.id().managerUri().contains(uri, Qt::CaseInsensitive));
current_count = m_engine->contactIds(defaultFilter, sortOrders, &err).count();
QVERIFY(err == QContactManager::NoError);
QVERIFY(init_count + 1 == current_count);
// Save a valid contact
QContact g;
g.setType(QContactType::TypeGroup);
QContactName en;
en.setCustomLabel("ccc");
QVERIFY(g.saveDetail(&en));
QVERIFY(m_engine->saveContact(&g, &err));
QVERIFY(err == QContactManager::NoError);
QVERIFY(g.id() != empty);
QVERIFY(g.localId() != 0);
QVERIFY(g.id().managerUri().contains(uri, Qt::CaseInsensitive));
}
示例12: performRequests
void AsyncRequestExample::performRequests()
{
//! [Creating a new contact in a manager]
QContact exampleContact;
QContactName nameDetail;
nameDetail.setFirstName("Adam");
nameDetail.setLastName("Unlikely");
QContactPhoneNumber phoneNumberDetail;
phoneNumberDetail.setNumber("+123 4567");
exampleContact.saveDetail(&nameDetail);
exampleContact.saveDetail(&phoneNumberDetail);
// save the newly created contact in the manager
connect(&m_contactSaveRequest, SIGNAL(stateChanged(QContactAbstractRequest::State)), this, SLOT(contactSaveRequestStateChanged(QContactAbstractRequest::State)));
m_contactSaveRequest.setManager(m_manager);
m_contactSaveRequest.setContacts(QList<QContact>() << exampleContact);
m_contactSaveRequest.start();
//! [Creating a new contact in a manager]
m_contactSaveRequest.waitForFinished();
//! [Creating a new contact in a manager waiting until finished]
m_contactSaveRequest.setManager(m_manager);
m_contactSaveRequest.setContacts(QList<QContact>() << exampleContact);
m_contactSaveRequest.start();
m_contactSaveRequest.waitForFinished();
QList<QContact> savedContacts = m_contactSaveRequest.contacts();
//! [Creating a new contact in a manager waiting until finished]
//! [Filtering contacts from a manager]
connect(&m_contactFetchRequest, SIGNAL(stateChanged(QContactAbstractRequest::State)), this, SLOT(contactFetchRequestStateChanged(QContactAbstractRequest::State)));
m_contactFetchRequest.setManager(m_manager);
m_contactFetchRequest.setFilter(QContactPhoneNumber::match("+123 4567"));
m_contactFetchRequest.start();
//! [Filtering contacts from a manager]
m_contactFetchRequest.waitForFinished();
//! [Retrieving an existing contact from a manager]
QContactLocalIdFilter idListFilter;
idListFilter.setIds(QList<QContactLocalId>() << exampleContact.localId());
m_contactFetchRequest.setManager(m_manager);
m_contactFetchRequest.setFilter(idListFilter);
m_contactFetchRequest.start();
//! [Retrieving an existing contact from a manager]
m_contactFetchRequest.waitForFinished();
//! [Updating an existing contact in a manager]
phoneNumberDetail.setNumber("+123 9876");
exampleContact.saveDetail(&phoneNumberDetail);
m_contactSaveRequest.setManager(m_manager);
m_contactSaveRequest.setContacts(QList<QContact>() << exampleContact);
m_contactSaveRequest.start();
//! [Updating an existing contact in a manager]
m_contactFetchRequest.waitForFinished();
//! [Removing a contact from a manager]
connect(&m_contactRemoveRequest, SIGNAL(stateChanged(QContactAbstractRequest::State)), this, SLOT(contactRemoveRequestStateChanged(QContactAbstractRequest::State)));
m_contactRemoveRequest.setManager(m_manager);
m_contactRemoveRequest.setContactIds(QList<QContactLocalId>() << exampleContact.localId());
m_contactRemoveRequest.start();
//! [Removing a contact from a manager]
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);
//.........这里部分代码省略.........
示例13: apiId
QContactLocalId apiId(const QContact &contact) { return contact.localId(); }
示例14: bufPtr
//.........这里部分代码省略.........
m_engine.setReadOnlyAccessConstraint(&lastNumber);
currentContact.saveDetail(&lastNumber);
}
}
}
// We have rearched to the end of the number,
// invalidate additional number flag.
isAdditionalNumber = false;
break;
}
case RMobilePhoneBookStore::ETagPBText:
{
if (pbBuffer->GetValue(bufPtr) == KErrNone) {
if (isAdditionalNumber) {
// For additional number bufPtr contains number alpha string,
// this is ignored currently
}
else {
// Contact name otherwise
QContactName name;
QString nameString = QString::fromUtf16(bufPtr.Ptr(), bufPtr.Length());
name.setCustomLabel(nameString);
if (m_storeInfo.m_readOnlyAccess)
m_engine.setReadOnlyAccessConstraint(&name);
currentContact.saveDetail(&name);
QContactManager::Error error(QContactManager::NoError);
m_engine.setContactDisplayLabel(¤tContact, m_engine.synthesizedDisplayLabel(currentContact, &error));
}
}
break;
}
case RMobilePhoneBookStore::ETagPBSecondName:
{
if (pbBuffer->GetValue(bufPtr) == KErrNone) {
QContactNickname nickName;
QString name = QString::fromUtf16(bufPtr.Ptr(), bufPtr.Length());
nickName.setNickname(name);
if (m_storeInfo.m_readOnlyAccess)
m_engine.setReadOnlyAccessConstraint(&nickName);
currentContact.saveDetail(&nickName);
}
break;
}
case RMobilePhoneBookStore::ETagPBNumber:
{
if (pbBuffer->GetValue(bufPtr) == KErrNone) {
QContactPhoneNumber phoneNumber;
QString number = QString::fromUtf16(bufPtr.Ptr(), bufPtr.Length());
phoneNumber.setNumber(number);
if (m_storeInfo.m_readOnlyAccess)
m_engine.setReadOnlyAccessConstraint(&phoneNumber);
currentContact.saveDetail(&phoneNumber);
}
break;
}
case RMobilePhoneBookStore::ETagPBAnrStart:
{
// This tag should precede every additional number entry
isAdditionalNumber = true;
break;
}
case RMobilePhoneBookStore::ETagPBEmailAddress:
{
if (pbBuffer->GetValue(bufPtr) == KErrNone) {
QContactEmailAddress email;
QString emailAddress = QString::fromUtf16(bufPtr.Ptr(), bufPtr.Length());
email.setEmailAddress(emailAddress);
if (m_storeInfo.m_readOnlyAccess)
m_engine.setReadOnlyAccessConstraint(&email);
currentContact.saveDetail(&email);
}
break;
}
case RMobilePhoneBookStore::ETagPBNewEntry:
{
// This signals the end of the entry and is a special case
// which will be handled below.
break;
}
default:
{
// An unsupported field type - just skip this value
pbBuffer->SkipValue(dataType);
break;
}
} //switch
// save contact to the array of contact to be returned if the whole entry was extracted
if ((tagValue == RMobilePhoneBookStore::ETagPBNewEntry && currentContact.localId() > 0) ||
(pbBuffer->RemainingReadLength() == 0 && currentContact.localId() > 0)) {
fetchedContacts.append(currentContact);
//clear current contact
currentContact.clearDetails();
QScopedPointer<QContactId> contactId(new QContactId());
contactId->setLocalId(0);
contactId->setManagerUri(QString());
currentContact.setId(*contactId);
}
} //while
示例15: foreach
foreach (const QContact& contact, sortedAndFiltered) {
rtn.append(contact.localId());
}