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


C++ QContactName类代码示例

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


在下文中一共展示了QContactName类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: first

void SymbianPluginPerfomance::createSimpleContacts()
{
    // Create N contacts
    QList<QContact> contactsList;

    for(int i=0; i<NO_OF_CONTACTS; i++) {
        QString c = QString::number(i);
        QString first("Alice");
        QContact alice;

        // Contact details
        QContactName aliceName;
        aliceName.setFirstName(first.append(c));
        alice.saveDetail(&aliceName);

        contactsList.append(alice);
    }

    // Save the contacts
    mTime.start();
    mCntMng->saveContacts(&contactsList, 0);
    int elapsed = mTime.elapsed();
    qDebug() << "Created " << contactsList.count() << " simple contacts in"
        << elapsed / 1000 << "s" << elapsed % 1000 << "ms";
}
开发者ID:bavanisp,项目名称:qtmobility-1.1.0,代码行数:25,代码来源:performance.cpp

示例2: setTitle

void SeasidePerson::setTitle(const QString &name)
{
    QContactName nameDetail = mContact.detail<QContactName>();
    nameDetail.setPrefix(name);
    mContact.saveDetail(&nameDetail);
    emit titleChanged();
}
开发者ID:pgerdt,项目名称:nemo-qml-plugins,代码行数:7,代码来源:seasideperson.cpp

示例3: setFirstName

void SeasideCache::setFirstName(FilterType filterType, int index, const QString &firstName)
{
#ifdef USING_QTPIM
    CacheItem &cacheItem = m_cache[m_cacheIndices[m_contacts[filterType].at(index)]];
#else
    CacheItem &cacheItem = m_cache[m_contacts[filterType].at(index) - 1];
#endif

    QContactName name = cacheItem.contact.detail<QContactName>();
    name.setFirstName(firstName);
    cacheItem.contact.saveDetail(&name);

    QString fullName = name.firstName() + QChar::fromLatin1(' ') + name.lastName();
    cacheItem.nameGroup = determineNameGroup(&cacheItem);
    cacheItem.displayLabel = fullName;

    ItemListener *listener(cacheItem.listeners);
    while (listener) {
        listener->itemUpdated(&cacheItem);
        listener = listener->next;
    }

    if (m_models[filterType])
        m_models[filterType]->sourceDataChanged(index, index);
}
开发者ID:adenexter,项目名称:nemo-qml-plugin-contacts,代码行数:25,代码来源:seasidecache.cpp

示例4: QVERIFY

/*!
 * This function will be called before the first testfunction is executed.
 */
void Ut_NotificationManager::initTestCase()
{
    nm = NotificationManager::instance();
    nm->m_Notifications.clear();

    nm->m_pMWIListener->disconnect(nm);

    // Create the contacts we need
    QContactOnlineAccount qcoa;
    qcoa.setValue(QContactOnlineAccount__FieldAccountPath, DUT_ACCOUNT_PATH);
    qcoa.setValue(QContactOnlineAccount::FieldAccountUri, CONTACT_1_REMOTE_ID);
    QVERIFY(contact1.saveDetail(&qcoa));

    QContactName name;
    name.setPrefix(CONTACT_1_REMOTE_ID);
    QVERIFY(contact1.saveDetail(&name));

    QVERIFY(nm->contactManager()->saveContact(&contact1));

    qcoa = QContactOnlineAccount();
    qcoa.setValue(QContactOnlineAccount__FieldAccountPath, DUT_ACCOUNT_PATH);
    qcoa.setValue(QContactOnlineAccount::FieldAccountUri, CONTACT_2_REMOTE_ID);
    QVERIFY(contact2.saveDetail(&qcoa));

    name = QContactName();
    name.setPrefix(CONTACT_2_REMOTE_ID);
    QVERIFY(contact2.saveDetail(&name));

    QVERIFY(nm->contactManager()->saveContact(&contact2));
}
开发者ID:jpetrell,项目名称:commhistory-daemon,代码行数:33,代码来源:ut_notificationmanager.cpp

示例5: exporter

void tst_QVersitContactPlugins::testExporterPlugins() {
    QVersitContactExporter exporter("Test");
    QContact contact;
    QContactName name;
    name.setFirstName("first name");
    contact.saveDetail(&name);
    QVERIFY(exporter.exportContacts(QList<QContact>() << contact));
    QCOMPARE(exporter.documents().size(), 1);
    QList<QVersitProperty> properties(exporter.documents().first().properties());

    // The plugins have had their index set such that they should be executed in reverse order
    // Check that they are all loaded, and run in the correct order
    int n = 0;
    foreach (QVersitProperty property, properties) {
        if (property.name() == "TEST-PROPERTY") {
            switch (n) {
                case 0: QCOMPARE(property.value(), QLatin1String("5")); break;
                case 1: QCOMPARE(property.value(), QLatin1String("4")); break;
                case 2: QCOMPARE(property.value(), QLatin1String("3")); break;
                case 3: QCOMPARE(property.value(), QLatin1String("2")); break;
                case 4: QCOMPARE(property.value(), QLatin1String("1")); break;
            }
            n++;
        }
    }
    QCOMPARE(n, 5);
}
开发者ID:,项目名称:,代码行数:27,代码来源:

示例6: exportOwnContact

void MT_CntVersitMyCardPlugin::exportOwnContact()
{
    //create contact
    QContact phonecontact;
    QContactName contactName;
    contactName.setFirstName("Jo");
    contactName.setLastName("Black");
    phonecontact.saveDetail(&contactName);
    QContactPhoneNumber number;
    number.setContexts("Home");
    number.setSubTypes("Mobile");
    number.setNumber("+02644424429");
    phonecontact.saveDetail(&number);
    
    //set MyCard detail
    QContactDetail myCard(MYCARD_DEFINTION_NAME);
    phonecontact.saveDetail(&myCard);
    
    //export
    QList<QContact> list;
    list.append(phonecontact);
    QVersitContactExporter exporter;
    QVERIFY(exporter.exportContacts(list, QVersitDocument::VCard21Type));
    QList<QVersitDocument> documents = exporter.documents();
    
    //X-SELF property is exported if MyCard
    QVersitDocument document  = documents.first();
    QVersitProperty property;
    property.setName(QLatin1String("X-SELF"));
    property.setValue("0");
    bool propertyFound = document.properties().contains(property);
    QVERIFY(propertyFound);
}
开发者ID:,项目名称:,代码行数:33,代码来源:

示例7: Q_UNUSED

/* Synthesise the display label of a contact */
QString QContactWinCEEngine::synthesizedDisplayLabel(const QContact& contact, QContactManager::Error* error) const
{
    Q_UNUSED(error)
    // The POOM API (well, lack thereof) makes this a bit strange.
    // It's basically just "Last, First" or "Company", if "FileAs" is not set.
    QContactName name = contact.detail<QContactName>();
    QContactOrganization org = contact.detail<QContactOrganization>();

    // Basically we ignore any existing labels for this contact, since we're being
    // asked what the synthesized label would be

    // XXX For greatest accuracy we might be better off converting this contact to
    // a real item (but don't save it), and then retrieve it...
    if (!name.customLabel().isEmpty()) {
        return name.customLabel();
    }
    else if (!name.lastName().isEmpty()) {
        if (!name.firstName().isEmpty()) {
            return QString(QLatin1String("%1, %2")).arg(name.lastName()).arg(name.firstName());
        } else {
            // Just last
            return name.lastName();
        }
    } else if (!name.firstName().isEmpty()) {
        return name.firstName();
    } else if (!org.name().isEmpty()) {
        return org.name();
    } else {
        // XXX grargh.
        return QLatin1String("Unnamed");
    }
}
开发者ID:kuailexs,项目名称:symbiandump-mw3,代码行数:33,代码来源:qcontactwincebackend.cpp

示例8: setLastName

void SeasidePerson::setLastName(const QString &name)
{
    QContactName nameDetail = mContact.detail<QContactName>();
    nameDetail.setLastName(name);
    mContact.saveDetail(&nameDetail);
    emit lastNameChanged();
    recalculateDisplayLabel();
}
开发者ID:blammit,项目名称:nemo-qml-plugins,代码行数:8,代码来源:seasideperson.cpp

示例9: onEntryPkg

bool CntSimStorePrivate::read(int index, int numSlots, QContactManager::Error *error)
{
    if (IsActive()) {
        *error = QContactManager::LockedError;
        return false;
    }
    
    // ON store requires different read approach.
    // fetch ON contacts synchronously since there are usually only couple of them  
    if (m_storeInfo.m_storeName == KParameterValueSimStoreNameOn) {

        TRequestStatus status;
        QList<QContact> fetchedContacts; 
        for (int i = index; i <= numSlots; i++) {
            RMobileONStore::TMobileONEntryV1 onEntry;
            onEntry.iIndex = i;         
            RMobileONStore::TMobileONEntryV1Pckg onEntryPkg(onEntry);
            m_etelOnStore.Read(status, onEntryPkg);
            User::WaitForRequest(status);
            if (status.Int() == KErrNone) {
                QContact c;
                c.setType(QContactType::TypeContact);
                QContactName name;
                name.setCustomLabel(QString::fromUtf16(onEntry.iText.Ptr(),
                        onEntry.iText.Length()));
                c.saveDetail(&name);
                
                QContactPhoneNumber number;
                number.setNumber(QString::fromUtf16(onEntry.iNumber.iTelNumber.Ptr(),
                        onEntry.iNumber.iTelNumber.Length()));
                c.saveDetail(&number);
                
                QScopedPointer<QContactId> contactId(new QContactId());
                contactId->setLocalId(i);
                contactId->setManagerUri(m_managerUri);
                c.setId(*contactId);
                fetchedContacts.append(c);
            }
        }
        emit m_simStore.readComplete(fetchedContacts, QContactManager::NoError);
        *error = QContactManager::NoError;
        return true;
    }        
    
    // start reading
    m_buffer.Zero();
    m_buffer.ReAlloc(KOneSimContactBufferSize*numSlots);
    m_etelStore.Read(iStatus, index, numSlots, m_buffer);
    
    SetActive();
    m_state = ReadState;
    
    *error = QContactManager::NoError;
    return true;
}
开发者ID:Esclapion,项目名称:qt-mobility,代码行数:55,代码来源:cntsimstoreprivate.cpp

示例10: displayLabel

QString SeasidePerson::displayLabel()
{
    if (mDisplayLabel.isEmpty()) {
        QContactName name = mContact.detail<QContactName>();
        mDisplayLabel = name.customLabel();
        if (mDisplayLabel.isEmpty())
            recalculateDisplayLabel();
    }

    return mDisplayLabel;
}
开发者ID:pgerdt,项目名称:nemo-qml-plugins,代码行数:11,代码来源:seasideperson.cpp

示例11: Q_UNUSED

QString CntSymbianSimEngine::synthesizedDisplayLabel(const QContact& contact, QContactManager::Error* error) const
{
    Q_UNUSED(error);

    QContactName name = contact.detail(QContactName::DefinitionName);
    if(!name.customLabel().isEmpty()) {
        return name.customLabel();
    } else {
        return QString("");
    }
}
开发者ID:bavanisp,项目名称:qtmobility-1.1.0,代码行数:11,代码来源:cntsymbiansimengine.cpp

示例12: displayLabelOrderChanged

void SeasideCache::displayLabelOrderChanged()
{
#ifdef HAS_MLITE
    QVariant displayLabelOrder = m_displayLabelOrderConf.value();
    if (displayLabelOrder.isValid() && displayLabelOrder.toInt() != m_displayLabelOrder) {
        m_displayLabelOrder = SeasideFilteredModel::DisplayLabelOrder(displayLabelOrder.toInt());
#ifdef SEASIDE_SPARQL_QUERIES
        m_contactIdRequest.setSortOnFirstName(true);
#else
        QContactSortOrder firstNameOrder;
        firstNameOrder.setDetailDefinitionName(
                    QContactName::DefinitionName, QContactName::FieldFirstName);
        firstNameOrder.setCaseSensitivity(Qt::CaseInsensitive);
        firstNameOrder.setDirection(Qt::AscendingOrder);
        firstNameOrder.setBlankPolicy(QContactSortOrder::BlanksFirst);

        QContactSortOrder secondNameOrder;
        secondNameOrder.setDetailDefinitionName(
                    QContactName::DefinitionName, QContactName::FieldLastName);
        secondNameOrder.setCaseSensitivity(Qt::CaseInsensitive);
        secondNameOrder.setDirection(Qt::AscendingOrder);
        secondNameOrder.setBlankPolicy(QContactSortOrder::BlanksFirst);

        QList<QContactSortOrder> sorting = m_displayLabelOrder == SeasideFilteredModel::FirstNameFirst
                ? (QList<QContactSortOrder>() << firstNameOrder << secondNameOrder)
                : (QList<QContactSortOrder>() << secondNameOrder << firstNameOrder);

        m_fetchRequest.setSorting(sorting);
        m_contactIdRequest.setSorting(sorting);
#endif
        typedef QHash<QContactLocalId, SeasideCacheItem>::iterator iterator;
        for (iterator it = m_people.begin(); it != m_people.begin(); ++it) {
            if (it->person) {
                it->person->recalculateDisplayLabel(SeasideProxyModel::DisplayLabelOrder(m_displayLabelOrder));
                it->contact = it->person->contact();
            } else {
                QContactName name = it->contact.detail<QContactName>();
                name.setCustomLabel(SeasidePerson::generateDisplayLabel(it->contact));
                it->contact.saveDetail(&name);
            }
        }

        for (int i = 0; i < SeasideFilteredModel::FilterTypesCount; ++i) {
            for (int j = 0; j < m_models[i].count(); ++j)
                m_models[i].at(j)->updateDisplayLabelOrder();
        }

        m_refreshRequired = true;
        requestUpdate();
    }
#endif
}
开发者ID:VDVsx,项目名称:nemo-qml-plugins,代码行数:52,代码来源:seasidecache.cpp

示例13: 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

示例14: testChangeName

void TestBirthdayPlugin::testChangeName()
{
    const QString contactID = QUuid::createUuid().toString();
    const QDateTime contactBirthDate = QDateTime::currentDateTime();

    // Add contact with birthday to tracker.
    QContactName contactName;
    contactName.setFirstName(contactID);
    QContactBirthday contactBirthday;
    contactBirthday.setDateTime(contactBirthDate);
    QContact contact;
    QVERIFY(contact.saveDetail(&contactName));
    QVERIFY(contact.saveDetail(&contactBirthday));
    QVERIFY2(mManager->saveContact(&contact), "Error saving contact to tracker");

    // Wait until calendar event gets to calendar.
    loopWait(calendarTimeout);

    // Open calendar database.
    mKCal::ExtendedCalendar::Ptr calendar =
        mKCal::ExtendedCalendar::Ptr(new mKCal::ExtendedCalendar(KDateTime::Spec::LocalZone()));
    mKCal::ExtendedStorage::Ptr storage =
        mKCal::ExtendedCalendar::defaultStorage(calendar);
    storage->open();
    QVERIFY2(not storage->notebook(calNotebookId).isNull(), "No calendar database found");

    // Check calendar database for contact.
    QVERIFY2(storage->loadNotebookIncidences(calNotebookId), "Unable to load events from notebook");
    KCalCore::Event::List eventList = calendar->events();
    QCOMPARE(countCalendarEvents(eventList, contact), 1);

    // Change the contact name and see if the calendar is updated.
    const QString newContactID = QUuid::createUuid().toString();
    contactName.setFirstName(newContactID);
    QVERIFY(contact.saveDetail(&contactName));
    // TODO: Should it be necessary to refetch the contact to get the synthesised displayLabel?
    contact = mManager->contact(apiId(contact));
    QVERIFY2(mManager->saveContact(&contact), "Unable to update test contact in tracker");

    // Wait until calendar event gets to calendar.
    loopWait(calendarTimeout);

    // Search for any events in the calendar.
    QVERIFY2(storage->loadNotebookIncidences(calNotebookId), "Unable to load events from notebook");
    eventList = calendar->events();
    QCOMPARE(countCalendarEvents(eventList, contact), 1);

    // Close the calendar.
    QVERIFY2(storage->close(), "Error closing the calendar");
}
开发者ID:plundstr,项目名称:contactsd,代码行数:50,代码来源:test-birthday-plugin.cpp

示例15: generateDisplayLabel

void SeasidePerson::recalculateDisplayLabel(SeasideProxyModel::DisplayLabelOrder order)
{
    QString oldDisplayLabel = mDisplayLabel;
    QString newDisplayLabel = generateDisplayLabel(mContact, order);

    if (oldDisplayLabel != newDisplayLabel) {
        // Save the display label as the custom label.
        QContactName name = mContact.detail<QContactName>();
        name.setCustomLabel(newDisplayLabel);
        mContact.saveDetail(&name);

        mDisplayLabel = newDisplayLabel;
        emit displayLabelChanged();
    }
}
开发者ID:pgerdt,项目名称:nemo-qml-plugins,代码行数:15,代码来源:seasideperson.cpp


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