本文整理汇总了C++中QContact类的典型用法代码示例。如果您正苦于以下问题:C++ QContact类的具体用法?C++ QContact怎么用?C++ QContact使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QContact类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setContact
void MessageModel::setContact(const QContact& contact)
{
clear();
// Locate messages whose sender is this contact
QMailMessageKey msgsFrom;
// Locate messages whose recipients list contains this contact
QMailMessageKey msgsTo;
// Match on any of contact's phone numbers
foreach(const QString& number, contact.phoneNumbers().values()) {
msgsFrom |= QMailMessageKey(QMailMessageKey::Sender, number);
msgsTo |= QMailMessageKey(QMailMessageKey::Recipients, number, QMailMessageKey::Contains);
}
// Match on any of contact's email addresses
foreach(const QString& address, contact.emailList()) {
msgsFrom |= QMailMessageKey(QMailMessageKey::Sender, address);
msgsTo |= QMailMessageKey(QMailMessageKey::Recipients, address, QMailMessageKey::Contains);
}
// Sort messages by timestamp, newest to oldest
QMailMessageSortKey sort(QMailMessageSortKey::TimeStamp, Qt::DescendingOrder);
// Fetch the messages matching either of our queries, and return them sorted
QMailIdList matches(QMailStore::instance()->queryMessages(msgsFrom | msgsTo, sort));
// Add each returned message to our data model
foreach (const QMailId& id, matches)
appendRow(new MessageItem(id));
}
示例2: QVERIFY
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);
}
示例3: QContactFilter
void TestSymbianEngine::saveContacts()
{
QContactManager::Error err;
QContactFilter defaultFilter = QContactFilter();
QList<QContactSortOrder> sortOrders;
QList<QContact> contacts;
QContactId empty;
int count = 5;
int init_count = m_engine->contactIds(defaultFilter, sortOrders, &err).count();
QVERIFY(err == QContactManager::NoError);
// NULL
QMap<int, QContactManager::Error> errorMap;
QVERIFY(!m_engine->saveContacts(NULL, &errorMap, &err));
QVERIFY(errorMap.count() == 0);
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 "non contact(Jargon) type" contacts
for(int i=0; i<count; i++) {
QContact alice;
alice.setType("Jargon");
contacts.append(alice);
}
QVERIFY(!m_engine->saveContacts(&contacts, &errorMap, &err));
QVERIFY(err == QContactManager::InvalidDetailError);
foreach(QContactManager::Error err, errorMap) {
QVERIFY(err == QContactManager::InvalidDetailError);
}
示例4: 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";
}
示例5: spy
void TestCntPresenceInfoProvider::testHandlePresenceUpdate()
{
QSignalSpy spy(mCntPresenceInfoProvider, SIGNAL(infoFieldReady(CntInfoProvider*, int, ContactInfoField, const QString&)));
PrcPresenceWriter *writer = PrcPresenceWriter::createWriter();
PrcPresenceReader *reader = PrcPresenceReader::createReader();
PrcPresenceBuddyInfoQt *dummyBuddy = PrcPresenceBuddyInfoQt::createInstance();
dummyBuddy->setIdentity("sip:[email protected]");
dummyBuddy->setAvailability(PrcPresenceBuddyInfoQt::PrcAvailable, "meh");
writer->writePresence(*dummyBuddy);
mCntPresenceInfoProvider->handlePresenceUpdate(true, dummyBuddy);
QCOMPARE(spy.count(), 0);
mCntPresenceInfoProvider->handlePresenceUpdate(false, dummyBuddy);
QCOMPARE(spy.count(), 0);
mCntPresenceInfoProvider->handlePresenceUpdate(true, NULL);
QCOMPARE(spy.count(), 0);
PrcPresenceBuddyInfoQt *buddy = reader->presenceInfo("sip:[email protected]");
buddy->setAvailability(PrcPresenceBuddyInfoQt::PrcNotAvailable, "meh");
writer->writePresence(*buddy);
QTest::qWait(5000);
QCOMPARE(spy.count(), 1);
QContactManager manager("symbian");
QContact c = manager.contact(mCntPresenceInfoProvider->mBuddyMap.value("sip:[email protected]"));
QList<QContactOnlineAccount> accounts = c.details<QContactOnlineAccount>();
foreach (QContactOnlineAccount account, accounts)
{
c.removeDetail(&account);
}
示例6: setDisplayLabelDetails
/*!
* Returns a synthesised display label of a contact
* \a contact to read the data from .
* \a error On return, contains the possible error.
* \return synthesised display label
*/
QString CntDisplayLabel::synthesizedDisplayLabel(const QContact& contact, QContactManager::Error* error)
{
QString displayLabel;
*error = QContactManager::NoError;
int value = m_settings->getValue();
if (value != -1 && value != m_nameOrder) {
m_nameOrder = value;
setDisplayLabelDetails();
}
//contact
if(contact.type() == QContactType::TypeContact) {
displayLabel = generateDisplayLabel(contact, m_contactDisplayLabelDetails);
}
//group
else if (contact.type() == QContactType::TypeGroup) {
displayLabel = generateDisplayLabel(contact, m_groupDisplayLabelDetails);
}
//invalid type
else {
*error = QContactManager::InvalidContactTypeError;
}
return displayLabel;
}
示例7: Q_ASSERT
QContactManager::Error
GContactsBackend::modifyContact(const QString &aID,
QContact &aContact)
{
FUNCTION_CALL_TRACE;
Q_ASSERT (iMgr);
LOG_DEBUG("Modifying a Contact with ID" << aID);
QContactManager::Error modificationStatus = QContactManager::UnspecifiedError;
QContact oldContactData;
getContact(QContactId::fromString(aID), oldContactData);
aContact.setId(oldContactData.id());
oldContactData = aContact;
bool modificationOk = iMgr->saveContact(&oldContactData);
modificationStatus = iMgr->error();
if(!modificationOk) {
// either contact exists or something wrong with one of the detailed definitions
LOG_WARNING("Contact Modification Failed");
} // no else
return modificationStatus;
}
示例8: apiId
SeasideCache::ContactIdType SeasideCache::apiId(const QContact &contact)
{
#ifdef USING_QTPIM
return contact.id();
#else
return contact.id().localId();
#endif
}
示例9: foreach
QDebug operator<<(QDebug dbg, const QContact& contact)
{
dbg.nospace() << "QContact(" << contact.id() << ")";
foreach (const QContactDetail& detail, contact.details()) {
dbg.space() << '\n' << detail;
}
return dbg.maybeSpace();
}
示例10: qHash
/*!
\relates QContact
Returns the hash value for \a key.
*/
uint qHash(const QContact &key)
{
uint hash = qHash(key.id());
foreach (const QContactDetail& detail, key.details()) {
hash += qHash(detail);
}
return hash;
}
示例11: emptyContactNoActionSupport
void TestCntActions::emptyContactNoActionSupport()
{
QContact contact;
m_manager->saveContact(&contact);
//expected no actions found
QList<QContactActionDescriptor> actions = contact.availableActions();
QVERIFY(actions.count() == 0);
}
示例12: 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;
}
示例13: 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();
}
示例14: 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);
}
}
}
示例15: 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");
}