当前位置: 首页>>代码示例>>C++>>正文


C++ QContactId类代码示例

本文整理汇总了C++中QContactId的典型用法代码示例。如果您正苦于以下问题:C++ QContactId类的具体用法?C++ QContactId怎么用?C++ QContactId使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QContactId类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例2: foreach

void CntFavoritesMemberView::handleManageFavorites(QSet<QContactLocalId> aIds)
{
    for (int i = 0; i < 2; ++i) {
        // first iteration processes added members, second removed members
        QSet<QContactLocalId> members = (i == 0 ? aIds - mOriginalGroupMembers
                                                : mOriginalGroupMembers - aIds);
        QList<QContactRelationship> memberships;

        foreach (QContactLocalId id, members) {
            QContactId contactId;
            contactId.setLocalId(id);
            QContactRelationship membership;
            membership.setRelationshipType(QContactRelationship::HasMember);
            membership.setFirst(mContact->id());
            membership.setSecond(contactId);
            memberships.append(membership);
        }

        if (!memberships.isEmpty()) {
            if (i == 0) {
                getContactManager()->saveRelationships(&memberships, NULL);
            }
            else {
                getContactManager()->removeRelationships(memberships, NULL);
            }
        }
    }
开发者ID:cdaffara,项目名称:symbiandump-ossapps,代码行数:27,代码来源:cntfavoritesmemberview.cpp

示例3: addContact

void ContactConnection::addContact(QContact contact)
{
    mEngine->setNotifySimulator(false);
    QContactManager::Error error;
    QContactChangeSet changeSet;

    // if the created contact would get a too high id, delete
    // the contacts that the simulator knows nothing about
    QContactMemoryEngineData *edata = QContactMemoryEngineData::data(mEngine);
    if (edata->m_nextContactId + 1 > contact.localId()) {
        for (QContactLocalId id = contact.localId(); id <= edata->m_nextContactId; ++id)
            mEngine->removeContact(id, changeSet, &error);
    }

    // make sure the inserted contact gets the same id as in the simulator
    edata->m_nextContactId = contact.localId() - 1;

    // add (set localid to 0 first, otherwise the engine thinks we want to update a contact)
    QContactId newId = contact.id();
    newId.setLocalId(0);
    contact.setId(newId);
    mEngine->saveContact(&contact, changeSet, &error);

    mEngine->setNotifySimulator(true);
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例4: showPreviousView

void CntFavoritesView::handleMemberSelection( QSet<QContactLocalId> aIds )
{
    if ( aIds.isEmpty() )
    {
        showPreviousView();
    }
    else
    {
        QList<QContactRelationship> memberships;
        foreach (QContactLocalId id, aIds) {
            QContactId contactId;
            contactId.setLocalId(id);
            QContactRelationship membership;
            membership.setRelationshipType(QContactRelationship::HasMember);
            membership.setFirst(mContact->id());
            membership.setSecond(contactId);
            memberships.append(membership);
        }
    
        if (!memberships.isEmpty()) {
            getContactManager()->saveRelationships(&memberships, NULL);
        }
    
        CntViewParameters viewParameters;
        viewParameters.insert(EViewId, favoritesMemberView);
        QVariant var;
        var.setValue(*mContact);
        viewParameters.insert(ESelectedGroupContact, var);
        mViewManager->changeView(viewParameters);
    }
开发者ID:cdaffara,项目名称:symbiandump-ossapps,代码行数:30,代码来源:cntfavoritesview.cpp

示例5:

/*! Returns true if this id is less than the \a other id.
    This id will be considered less than the \a other id if the
    manager URI of this id is alphabetically less than the manager
    URI of the \a other id.  If both ids have the same manager URI,
    this id will be considered less than the \a other id if the
    local id of this id is less than the local id of the \a other id.

    The invalid, empty id consists of an empty manager URI and the
    invalid, zero local id, and hence will be less than any non-invalid
    id.

    This operator is provided primarily to allow use of a QContactId
    as a key in a QMap.
    \since 1.0
 */
bool QContactId::operator<(const QContactId& other) const
{
    const int comp = this->managerUri().compare(other.managerUri());
    if (comp != 0)
        return comp < 0;

    return this->localId() < other.localId();
}
开发者ID:,项目名称:,代码行数:23,代码来源:

示例6: 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);
        }
    }
}
开发者ID:KDE,项目名称:android-qt-mobility,代码行数:60,代码来源:qtversitdocsample.cpp

示例7: idStr

SeasideCache::CacheItem *SeasideCache::itemById(int id, bool)
{
    if (id == 0)
        return 0;

    // Construct a valid id from this value
    QString idStr(QString::fromLatin1("qtcontacts:org.nemomobile.contacts.sqlite::sql-%1"));
    QContactId contactId = QContactId::fromString(idStr.arg(id));
    if (contactId.isNull()) {
        qWarning() << "Unable to formulate valid ID from:" << id;
        return 0;
    }

    return itemById(contactId);
}
开发者ID:martinjones,项目名称:nemo-qml-plugin-contacts,代码行数:15,代码来源:seasidecache.cpp

示例8: readContactsToBufferL

/*!
 * 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;
}
开发者ID:Esclapion,项目名称:qt-mobility,代码行数:53,代码来源:cntsymbiansrvconnection.cpp

示例9: person

SeasidePerson *SeasideCache::personById(QContactLocalId id)
{
    if (id == 0)
        return 0;

    QHash<QContactLocalId, SeasideCacheItem>::iterator it = instance->m_people.find(id);
    if (it != instance->m_people.end()) {
        return person(&(*it));
    } else {
        // Insert a new item into the cache if the one doesn't exist.
        SeasideCacheItem &cacheItem = instance->m_people[id];
        QContactId contactId;
        contactId.setLocalId(id);
        cacheItem.contact.setId(contactId);
        return person(&cacheItem);
    }
}
开发者ID:VDVsx,项目名称:nemo-qml-plugins,代码行数:17,代码来源:seasidecache.cpp

示例10: 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);
            }
        }
    }
}
开发者ID:KDE,项目名称:android-qt-mobility,代码行数:53,代码来源:qtversitdocsample.cpp

示例11: foreach

void
GContactClient::filterRemoteAddedModifiedDeletedContacts (const QList<GContactEntry *> remoteContacts,
                                                          QList<GContactEntry*>& remoteAddedContacts,
                                                          QList<GContactEntry*>& remoteModifiedContacts,
                                                          QList<GContactEntry*>& remoteDeletedContacts)
{
    FUNCTION_CALL_TRACE;

    foreach (GContactEntry* entry, remoteContacts)
    {
        if (entry->deleted () == true) {
            remoteDeletedContacts.append (entry);
            continue;
        }

        QContactId localId = mContactBackend->entryExists(entry->guid());
        if (!localId.isNull()) {
            remoteModifiedContacts.append (entry);
        } else {
            remoteAddedContacts.append (entry);
        }
    }
}
开发者ID:VDVsx,项目名称:buteo-sync-plugins-google,代码行数:23,代码来源:GContactClient.cpp

示例12: qHash

/*!
 * Returns the hash value for \a key.
 * \since 1.0
 */
uint qHash(const QContactId &key)
{
    return QT_PREPEND_NAMESPACE(qHash)(key.managerUri())
            + QT_PREPEND_NAMESPACE(qHash)(key.localId());
}
开发者ID:,项目名称:,代码行数:9,代码来源:

示例13: switch

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;
}
开发者ID:Esclapion,项目名称:qt-mobility,代码行数:78,代码来源:cntsimstoreprivate.cpp

示例14: validId

bool SeasideCache::validId(const QContactId &id)
{
    return !id.isNull();
}
开发者ID:martinjones,项目名称:nemo-qml-plugin-contacts,代码行数:4,代码来源:seasidecache.cpp

示例15: setSecond

void QDeclarativeContactRelationship::setSecond(QContactLocalId secondId)
{
    QContactId id;
    id.setLocalId(secondId);
    m_relationship.setSecond(id);
}
开发者ID:,项目名称:,代码行数:6,代码来源:


注:本文中的QContactId类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。