本文整理汇总了C++中QContact::details方法的典型用法代码示例。如果您正苦于以下问题:C++ QContact::details方法的具体用法?C++ QContact::details怎么用?C++ QContact::details使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QContact
的用法示例。
在下文中一共展示了QContact::details方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: 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;
}
示例3:
QList<QContactDetail> CntMessageAction::supportedDetails(const QContact& contact) const
{
QList<QContactDetail> details = contact.details(QContactPhoneNumber::DefinitionName);
QList<QContactDetail> supportedDetails;
for (int i = 0; i < details.count(); i++)
{
if (!static_cast<QContactPhoneNumber>(details[i]).subTypes().isEmpty()
&& static_cast<QContactPhoneNumber>(details[i]).subTypes().first() == QContactPhoneNumber::SubTypeMobile)
{
supportedDetails.append(details[i]);
}
}
return supportedDetails;
}
示例4: setContact
void QDeclarativeContact::setContact(const QContact& contact)
{
m_id = contact.id();
foreach (QDeclarativeContactDetail *detail, m_details)
delete detail;
m_details.clear();
m_preferredDetails.clear();
QList<QContactDetail> details(contact.details());
foreach (const QContactDetail &detail, details) {
QDeclarativeContactDetail *contactDetail = QDeclarativeContactDetailFactory::createContactDetail(static_cast<QDeclarativeContactDetail::DetailType>(detail.type()));
contactDetail->setParent(this);
contactDetail->setDetail(detail);
connect(contactDetail, SIGNAL(detailChanged()), this, SIGNAL(contactChanged()));
m_details.append(contactDetail);
}
示例5: templates
void tst_QContactDetail::templates()
{
QContact c;
QContactPhoneNumber p1, p2;
p1.setNumber("1234");
p2.setNumber("5678");
QVERIFY(c.saveDetail(&p1));
QVERIFY(c.saveDetail(&p2));
QList<QContactDetail> l = c.details("PhoneNumber");
QCOMPARE(l.count(), 2);
QCOMPARE(QContactPhoneNumber(l.at(0)), p1);
QCOMPARE(QContactPhoneNumber(l.at(1)), p2);
QList<QContactPhoneNumber> l2 = c.details<QContactPhoneNumber>();
QCOMPARE(l2.count(), 2);
QCOMPARE(l2.at(0), p1);
QCOMPARE(l2.at(1), p2);
}
示例6: qDebug
void MainWindow::on_pushButton_3_clicked()
{
// qDebug() << "The default manager for the platform is:" << cm.managerName();
// qDebug() << "It" << (cm.isRelationshipTypeSupported(QContactRelationship::HasAssistant) ? "supports" : "does not support") << "assistant relationships.";
// qDebug() << "It" << (cm.supportedContactTypes().contains(QContactType::TypeGroup) ? "supports" : "does not support") << "groups.";
// qDebug() << "It" << (cm.hasFeature(QContactManager::MutableDefinitions) ? "supports" : "does not support") << "mutable detail definitions.";
QList<QContactLocalId> contactIds = cm.contactIds();
QContact a = cm.contact(contactIds.first());
qDebug() << "Viewing the details of" << a.displayLabel();
QList<QContactDetail> allDetails = a.details();
for (int i = 0; i < allDetails.size(); i++) {
QContactDetail detail = allDetails.at(i);
QContactDetailDefinition currentDefinition = cm.detailDefinition(detail.definitionName());
QMap<QString, QContactDetailFieldDefinition> fields = currentDefinition.fields();
qDebug("\tDetail #%d (%s):", i, detail.definitionName().toAscii().constData());
foreach (const QString& fieldKey, fields.keys()) {
qDebug() << "\t\t" << fieldKey << "(" << fields.value(fieldKey).dataType() << ") =" << detail.value(fieldKey);
}
qDebug();
}
QContact b;
QContactDetail de;
foreach (const QContactLocalId& ids, contactIds )
{
b = cm.contact(ids);
de = b.detail("PhoneNumber");
bool s = de.hasValue("PhoneNumber");
qDebug()<< " has Value PhoneNumber key"<<s<<"|"<<de.value("PhoneNumber");
QString show;
show = b.displayLabel();
show.append("\t");
show.append(de.value("PhoneNumber"));
ui->listWidget_2->addItem(show);
}
示例7: bufPtr
/*! 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());
//.........这里部分代码省略.........
示例8: replaceSocamPersonTags
string DecodedDataDocumentParser::replaceSocamPersonTags (string text)
{
regex_t regex;
const char* tag_regex_text = "<\\s*person\\s*>([^,]*),([^<]*)<\\s*/person\\s*>";
compileRegex(®ex, tag_regex_text);
size_t ngroups = regex.re_nsub + 1;
regmatch_t *groups = (regmatch_t *) malloc(ngroups * sizeof(regmatch_t));
//string text(to_match);
while (1) {
const char * p = text.c_str();
int nomatch = regexec(®ex, p, ngroups, groups, 0);
if (nomatch) {
break;
}
regmatch_t match = groups[0];
if (groups[0].rm_so == -1) {
break;
}
string name, surname;
size_t nmatched;
for (nmatched = 0; nmatched < ngroups; nmatched++) {
if (groups[nmatched].rm_so == (size_t)(-1)) {
break;
}
string matchStr = text.substr (groups[nmatched].rm_so,groups[nmatched].rm_eo-groups[nmatched].rm_so);
cout << "Match: "<< matchStr << endl;
if(nmatched == 1) {
name = matchStr;
}
else if(nmatched == 2) {
surname = matchStr;
}
}
cout << "Parsed: name=" << name << " surname=" << surname << endl;
string tag = text.substr (match.rm_so,match.rm_eo-match.rm_so);
QContact contact = getContact(name, surname);
//qWarning("\tContact ID: %d -- UUID: %s",contact.localId(),contact.details("Guid").at(0).value("Guid").toStdString().c_str());
//qWarning("\t\tDisplayLabel: %s",contact.details("DisplayLabel").at(0).value("Label").toStdString().c_str());
//qWarning("\t\tEmail %s",contact.details("EmailAddress").at(0).value("EmailAddress").toStdString().c_str());
//qWarning("\t\tPhoneNumber: %s",contact.details("PhoneNumber").at(0).value("PhoneNumber").toStdString().c_str());
/*
QContactDetail(name="DisplayLabel", key=7, "Label"=QVariant(QString, "Self Simulator") );
QContactDetail(name="Type", key=10, "Type"=QVariant(QString, "Contact") );
QContactDetail(name="Name", key=13, "CustomLabel"=QVariant(QString, "Self Simulator") , "FirstName"=QVariant(QString, "Self") , "LastName"=QVariant(QString, "Simulator") );
QContactDetail(name="EmailAddress", key=16, "EmailAddress"=QVariant(QString, "[email protected]") );
QContactDetail(name="PhoneNumber", key=19, "PhoneNumber"=QVariant(QString, "+44123456789") );
QContactDetail(name="Address", key=22, "Country"=QVariant(QString, "UK") , "Locality"=QVariant(QString, "Leister") , "Street"=QVariant(QString, "56 Edmonton Square") );
QContactDetail(name="Guid", key=25, "Guid"=QVariant(QString, "0") );
QContactDetail(name="Timestamp", key=28, "CreationTimestamp"=QVariant(QDateTime, QDateTime("dom 13. mar 12:21:09 2011") ) , "ModificationTimestamp"=QVariant(QDateTime, QDateTime("dom 13. mar 12:21:09 2011") ) );
*/
ostringstream oss ;
oss << "<table>";
oss << "<tr>";
if(contact.details("DisplayLabel").count()>0) {
oss << "<td>" << contact.details("DisplayLabel").at(0).value("Label").toStdString() << "</td>";
}
oss << "</tr>";
oss << "<tr>";
if(contact.details("EmailAddress").count()>0) {
oss << "<td>" << contact.details("EmailAddress").at(0).value("EmailAddress").toStdString() << "</td>";
}
oss << "</tr>";
oss << "<tr>";
if(contact.details("PhoneNumber").count()>0) {
oss << "<td>" << contact.details("PhoneNumber").at(0).value("PhoneNumber").toStdString() << "</td>";
}
oss << "</tr>";
oss << "</table>";
string newTagContent = oss.str();
text.replace(match.rm_so,match.rm_eo-match.rm_so,newTagContent);
cout<<"Replaced:" <<text<<endl;
}
regfree (®ex);
return text;
//.........这里部分代码省略.........