本文整理汇总了C++中QContactNickname::setNickname方法的典型用法代码示例。如果您正苦于以下问题:C++ QContactNickname::setNickname方法的具体用法?C++ QContactNickname::setNickname怎么用?C++ QContactNickname::setNickname使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QContactNickname
的用法示例。
在下文中一共展示了QContactNickname::setNickname方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testEmpty
void TestSimPlugin::testEmpty()
{
QContactManager &m(m_controller->contactManager());
// Add the Forrest Gump contact manually
QContact forrest;
QContactNickname n;
n.setNickname("Forrest Gump");
forrest.saveDetail(&n);
QContactSyncTarget st;
st.setSyncTarget(QStringLiteral("sim-test"));
forrest.saveDetail(&st);
QVERIFY(m.saveContact(&forrest));
QCOMPARE(getAllSimContacts(m).count(), 1);
QCOMPARE(m_controller->busy(), false);
// Process an empty VCard
m_controller->simPresenceChanged(true);
m_controller->vcardDataAvailable(QString());
QCOMPARE(m_controller->busy(), true);
QTRY_VERIFY(m_controller->busy() == false);
// No-longer-present contact should be removed
QList<QContact> simContacts(getAllSimContacts(m));
QCOMPARE(simContacts.count(), 0);
}
示例2: testAddAndRemove
void TestSimPlugin::testAddAndRemove()
{
QContactManager &m(m_controller->contactManager());
// Add the Forrest Gump contact manually
QContact forrest;
QContactNickname n;
n.setNickname("Forrest Gump");
forrest.saveDetail(&n);
QContactSyncTarget st;
st.setSyncTarget(QStringLiteral("sim-test"));
forrest.saveDetail(&st);
QVERIFY(m.saveContact(&forrest));
QCOMPARE(getAllSimContacts(m).count(), 1);
QCOMPARE(m_controller->busy(), false);
// Process a VCard set not containing Forrest Gump but another contact
m_controller->simPresenceChanged(true);
m_controller->vcardDataAvailable(QStringLiteral(
"BEGIN:VCARD\n"
"VERSION:3.0\n"
"FN:Forrest Whittaker\n"
"TEL;TYPE=HOME,VOICE:(404) 555-1234\n"
"END:VCARD\n"));
QTRY_VERIFY(m_controller->busy() == false);
// Forrest Gump should be removed, Forrest Whittaker added
QList<QContact> simContacts(getAllSimContacts(m));
QCOMPARE(simContacts.count(), 1);
QCOMPARE(simContacts.at(0).detail<QContactNickname>().nickname(), QStringLiteral("Forrest Whittaker"));
}
示例3: setNickname
void SeasidePerson::setNickname(const QString &name)
{
QContactNickname nameDetail = mContact.detail<QContactNickname>();
nameDetail.setNickname(name);
mContact.saveDetail(&nameDetail);
emit nicknameChanged();
recalculateDisplayLabel();
}
示例4: makeUniqueName
void
ut_qtcontacts_trackerplugin_common::setTestNicknameToContact(QContact &contact,
const QString &id) const
{
QContactNickname nicknameDetail;
const QString nickname = makeUniqueName(id);
nicknameDetail.setNickname(nickname);
QVERIFY(contact.saveDetail(&nicknameDetail));
}
示例5: testClear
void TestSimPlugin::testClear()
{
QContactManager &m(m_controller->contactManager());
// Add two contacts manually
QContact gump;
QContactNickname n;
n.setNickname("Forrest Gump");
gump.saveDetail(&n);
QContactSyncTarget st;
st.setSyncTarget(QStringLiteral("sim-test"));
gump.saveDetail(&st);
QContact whittaker;
n.setNickname("Forrest Whittaker");
whittaker.saveDetail(&n);
st.setSyncTarget(QStringLiteral("sim-test"));
whittaker.saveDetail(&st);
QVERIFY(m.saveContact(&gump));
QVERIFY(m.saveContact(&whittaker));
QCOMPARE(getAllSimContacts(m).count(), 2);
QCOMPARE(m_controller->busy(), false);
m_controller->simPresenceChanged(true);
// Report the SIM card removed
m_controller->simPresenceChanged(false);
QCOMPARE(m_controller->busy(), true);
QTRY_VERIFY(m_controller->busy() == false);
// All sim contacts should be removed
QList<QContact> simContacts(getAllSimContacts(m));
QCOMPARE(simContacts.count(), 0);
}
示例6: 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
示例7: main
//.........这里部分代码省略.........
contactToAggregate.saveDetail(&newSyncTarget);
contactToAggregate.saveDetail(&aggName);
contactToAggregate.saveDetail(&newOnlineAcct);
contactsToAggregate.append(contactToAggregate);
}
syncTimer.start();
manager.saveContacts(&contactsToAggregate);
aggregationElapsed = syncTimer.elapsed();
totalAggregatesInDatabase = manager.contactIds().count();
qDebug() << "Average time for aggregation of" << contactsToAggregate.size() << "contacts (with" << totalAggregatesInDatabase << "existing in database):" << aggregationElapsed
<< "milliseconds (" << ((1.0 * aggregationElapsed) / (1.0 * contactsToAggregate.size())) << " msec per aggregated contact )";
elapsedTimeTotal += aggregationElapsed;
// The next test is about updating existing contacts, amongst a large set.
// We're especially interested in presence updates, as these are common.
qDebug() << "\n\nPerforming presence update tests:";
// in the first presence update test, we update a small number of contacts.
QStringList presenceAvatars = generateAvatarsList();
QList<QContact> contactsToUpdate;
for (int i = 0; i < 10; ++i) {
contactsToUpdate.append(prefillData.at(prefillData.size() - 1 - i));
}
// modify the presence, nickname and avatar of the test data
for (int j = 0; j < contactsToUpdate.size(); ++j) {
QString genstr = QString::number(j);
QContact curr = contactsToUpdate[j];
QContactPresence cp = curr.detail<QContactPresence>();
QContactNickname nn = curr.detail<QContactNickname>();
QContactAvatar av = curr.detail<QContactAvatar>();
cp.setNickname(genstr);
cp.setCustomMessage(genstr);
cp.setTimestamp(QDateTime::currentDateTime());
cp.setPresenceState(static_cast<QContactPresence::PresenceState>(qrand() % 4));
nn.setNickname(nn.nickname() + genstr);
av.setImageUrl(genstr + presenceAvatars.at(qrand() % presenceAvatars.size()));
curr.saveDetail(&cp);
curr.saveDetail(&nn);
curr.saveDetail(&av);
contactsToUpdate.replace(j, curr);
}
// perform a batch save.
syncTimer.start();
manager.saveContacts(&contactsToUpdate);
qint64 presenceElapsed = syncTimer.elapsed();
totalAggregatesInDatabase = manager.contactIds().count();
qDebug() << " update ( batch of" << contactsToUpdate.size() << ") presence+nick+avatar (with" << totalAggregatesInDatabase << "existing in database, all overlap):" << presenceElapsed
<< "milliseconds (" << ((1.0 * presenceElapsed) / (1.0 * contactsToUpdate.size())) << " msec per updated contact )";
elapsedTimeTotal += presenceElapsed;
// in the second presence update test, we update ALL of the contacts
// This simulates having a large number of contacts from a single source (eg, a social network)
// where (due to changed connectivity status) presence updates for the entire set become available.
contactsToUpdate.clear();
QDateTime timestamp = QDateTime::currentDateTime();
for (int j = 0; j < prefillData.size(); ++j) {
QContact curr = prefillData.at(j);
QString genstr = QString::number(j) + "2";
QContactPresence cp = curr.detail<QContactPresence>();
QContactNickname nn = curr.detail<QContactNickname>();
QContactAvatar av = curr.detail<QContactAvatar>();
cp.setNickname(genstr);
示例8: 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);
//.........这里部分代码省略.........