本文整理汇总了C++中QContactNickname类的典型用法代码示例。如果您正苦于以下问题:C++ QContactNickname类的具体用法?C++ QContactNickname怎么用?C++ QContactNickname使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QContactNickname类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: QVERIFY
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: PbkPrintToLog
/*! Parses SIM contacts in TLV format.
*
* \param rawData SIM contacts in TLV format.
* \return List of contacts.
*/
QList<QContact> CntSimStorePrivate::decodeSimContactsL(TDes8& rawData) const
{
PbkPrintToLog(_L("CntSymbianSimEngine::decodeSimContactsL() - IN"));
QList<QContact> fetchedContacts;
QContact currentContact;
TBuf16<KDataClientBuf> buffer;
TPtrC16 bufPtr(buffer);
TUint8 tagValue(0);
CPhoneBookBuffer::TPhBkTagType dataType;
bool isAdditionalNumber = false;
CPhoneBookBuffer* pbBuffer = new(ELeave) CPhoneBookBuffer();
CleanupStack::PushL(pbBuffer);
pbBuffer->Set(&rawData);
pbBuffer->StartRead();
while (pbBuffer->GetTagAndType(tagValue, dataType) == KErrNone) {
switch (tagValue)
{
case RMobilePhoneBookStore::ETagPBAdnIndex:
{
//save contact's id (SIM card index) and manager's name
TUint16 index;
if (pbBuffer->GetValue(index) == KErrNone) {
QScopedPointer<QContactId> contactId(new QContactId());
contactId->setLocalId(index);
contactId->setManagerUri(m_managerUri);
currentContact.setId(*contactId);
}
isAdditionalNumber = false;
break;
}
case RMobilePhoneBookStore::ETagPBTonNpi:
{
// Note, that TON info can be incorporated into the phone number by Etel
// implementation (TSY). E.g. this is the case with Nokia TSY.
// Here general case is implemented.
// Check number type, we are only interested if it's international or not.
// We assume here that ETagPBTonNpi always comes after ETagPBNumber, not before.
TUint8 tonNpi;
if (pbBuffer->GetValue(tonNpi) == KErrNone) {
TUint8 intFlag = (tonNpi & KEtsiTonPosition) >> 4;
if (intFlag == 1) {
//international number format, append "+" to the last
//saved number
QList<QContactDetail> phoneNumbers = currentContact.details(
QContactPhoneNumber::DefinitionName);
if (phoneNumbers.count() > 0) {
QContactPhoneNumber lastNumber = static_cast<QContactPhoneNumber>(
phoneNumbers.at(phoneNumbers.count() - 1));
QString number = lastNumber.number();
number.insert(0, "+");
lastNumber.setNumber(number);
if (m_storeInfo.m_readOnlyAccess)
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());
//.........这里部分代码省略.........
示例7: main
//.........这里部分代码省略.........
QContactOnlineAccount newOnlineAcct; // new data, which should get promoted up etc.
newOnlineAcct.setAccountUri(QString(QLatin1String("test-aggregation-%[email protected]")).arg(i));
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>();
示例8: nickname
QString SeasidePerson::nickname() const
{
QContactNickname nameDetail = mContact.detail<QContactNickname>();
return nameDetail.nickname();
}
示例9: connect
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);
//.........这里部分代码省略.........