本文整理汇总了C++中QContactDetail::value方法的典型用法代码示例。如果您正苦于以下问题:C++ QContactDetail::value方法的具体用法?C++ QContactDetail::value怎么用?C++ QContactDetail::value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QContactDetail
的用法示例。
在下文中一共展示了QContactDetail::value方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: generateDisplayLabel
/*!
* Generate the display label
* \a contact to read the data from .
* \a detailList contains the details to be read from the contact
* \return synthesised display label
*/
QString CntDisplayLabel::generateDisplayLabel( const QContact &contact, const QList<QList<QPair<QLatin1String, QLatin1String> > > detailList) const
{
// Default to empty display label. It is up to the client to create a
// localised presentation of a contact without a name.
QString displayLabel("");
//loop through the details and create display label
for(int i = 0; i < detailList.count() && displayLabel.isEmpty(); i++ )
{
QList<QPair<QLatin1String, QLatin1String> > detailPairList = detailList.at(i);
QContactDetail contactDetail;
for(int j = 0; j < detailPairList.count(); j++)
{
contactDetail = contact.detail(detailPairList.at(j).first);
if(displayLabel.isEmpty()){ //read the value and set it as display label
displayLabel = contactDetail.value(detailPairList.at(j).second);
}
else{ //read the value and append it to the display label
QString label = contactDetail.value(detailPairList.at(j).second);
if(!label.isEmpty())
{
#ifdef SYMBIAN_BACKEND_USE_SQLITE
// Inlcude a comma if needed in the display label
if (m_nameOrder == CntOrderLastCommaFirst)
displayLabel.append(comma());
#endif
displayLabel.append(delimiter());
displayLabel.append(label);
}
}
}
}
return displayLabel;
}
示例3: values
void tst_QContactDetail::values()
{
QContactDetail p;
QCOMPARE(p.variantValues(), QVariantMap());
QDateTime dt = QDateTime::currentDateTime();
QTime t = dt.time();
t.setHMS(t.hour(), t.minute(), t.second(), 0); // milliseconds don't round trip through ISODate
dt.setTime(t);
QDate d = dt.date();
QDateTime ddt(d); // DateTime version of a Date (QTime())
p.setValue("string", "This is a string");
p.setValue("date", d);
p.setValue("datetime", dt);
p.setValue("int", (int)6);
p.setValue("stringdate", d.toString(Qt::ISODate));
p.setValue("stringdatetime", dt.toString(Qt::ISODate));
// Test the setter that takes a QString
p.setValue(QLatin1String("stringint"), "123");
// and the setter that takes a QL1C
p.setValue(QContactPhoneNumber::FieldNumber, "1234");
/* Presence test (const char * version) */
QVERIFY(p.hasValue("string"));
QVERIFY(p.hasValue("date"));
QVERIFY(p.hasValue("datetime"));
QVERIFY(p.hasValue("int"));
QVERIFY(p.hasValue("stringdate"));
QVERIFY(p.hasValue("stringdatetime"));
QVERIFY(p.hasValue("stringint"));
QVERIFY(p.hasValue(QContactPhoneNumber::FieldNumber.latin1()));
QVERIFY(!p.hasValue("non existent field"));
/* QLatin1Constant version */
QVERIFY(p.hasValue(QContactPhoneNumber::FieldNumber));
QVERIFY(!p.hasValue(QContactAddress::FieldCountry));
/* Again with QString version */
QVERIFY(p.hasValue(QLatin1String("string")));
QVERIFY(p.hasValue(QLatin1String("date")));
QVERIFY(p.hasValue(QLatin1String("datetime")));
QVERIFY(p.hasValue(QLatin1String("int")));
QVERIFY(p.hasValue(QLatin1String("stringdate")));
QVERIFY(p.hasValue(QLatin1String("stringdatetime")));
QVERIFY(p.hasValue(QLatin1String("stringint")));
QVERIFY(p.hasValue(QString(QLatin1String(QContactPhoneNumber::FieldNumber))));
QVERIFY(!p.hasValue(QLatin1String("non existent field")));
/* string accessors with const char* key */
QCOMPARE(p.value("string"), QString("This is a string"));
QCOMPARE(p.value("date"), d.toString(Qt::ISODate));
QCOMPARE(p.value("datetime"), dt.toString(Qt::ISODate));
QCOMPARE(p.value("int"), QString("6"));
QCOMPARE(p.value("stringdate"), d.toString(Qt::ISODate));
QCOMPARE(p.value("stringdatetime"), dt.toString(Qt::ISODate));
QCOMPARE(p.value("stringint"), QString("123"));
QCOMPARE(p.value(QContactPhoneNumber::FieldNumber.latin1()), QString("1234"));
/* string accessor with QL1C key */
QCOMPARE(p.value(QContactPhoneNumber::FieldNumber), QString("1234"));
/* string accessors with QString key */
QCOMPARE(p.value(QLatin1String("string")), QString("This is a string"));
QCOMPARE(p.value(QLatin1String("date")), d.toString(Qt::ISODate));
QCOMPARE(p.value(QLatin1String("datetime")), dt.toString(Qt::ISODate));
QCOMPARE(p.value(QLatin1String("int")), QString("6"));
QCOMPARE(p.value(QLatin1String("stringdate")), d.toString(Qt::ISODate));
QCOMPARE(p.value(QLatin1String("stringdatetime")), dt.toString(Qt::ISODate));
QCOMPARE(p.value(QLatin1String("stringint")), QString("123"));
QCOMPARE(p.value(QString(QLatin1String(QContactPhoneNumber::FieldNumber))), QString("1234"));
/* Variant accessor with const char * key */
QCOMPARE(p.variantValue("string"), QVariant(QString("This is a string")));
QCOMPARE(p.variantValue("date"), QVariant(d));
QCOMPARE(p.variantValue("datetime"), QVariant(dt));
QCOMPARE(p.variantValue("int"), QVariant((int)6));
QCOMPARE(p.variantValue("stringdate"), QVariant(d.toString(Qt::ISODate)));
QCOMPARE(p.variantValue("stringdatetime"), QVariant(dt.toString(Qt::ISODate)));
QCOMPARE(p.variantValue("stringint"), QVariant(QString("123")));
QCOMPARE(p.variantValue(QContactPhoneNumber::FieldNumber.latin1()), QVariant(QString("1234")));
/* Variant accessor with QL1C key */
QCOMPARE(p.variantValue(QContactPhoneNumber::FieldNumber), QVariant(QString("1234")));
/* Variant accessor with QString key */
QCOMPARE(p.variantValue(QLatin1String("string")), QVariant(QString("This is a string")));
QCOMPARE(p.variantValue(QLatin1String("date")), QVariant(d));
QCOMPARE(p.variantValue(QLatin1String("datetime")), QVariant(dt));
QCOMPARE(p.variantValue(QLatin1String("int")), QVariant((int)6));
QCOMPARE(p.variantValue(QLatin1String("stringdate")), QVariant(d.toString(Qt::ISODate)));
QCOMPARE(p.variantValue(QLatin1String("stringdatetime")), QVariant(dt.toString(Qt::ISODate)));
QCOMPARE(p.variantValue(QLatin1String("stringint")), QVariant(QString("123")));
QCOMPARE(p.variantValue(QLatin1String(QContactPhoneNumber::FieldNumber)), QVariant(QString("1234")));
//.........这里部分代码省略.........
示例4: classHierarchy
void tst_QContactDetail::classHierarchy()
{
QContactDetail f1;
QContactDetail f2;
QVERIFY(f1.isEmpty());
QVERIFY(f2.isEmpty());
QContactPhoneNumber p1;
p1.setNumber("123456");
QVERIFY(!p1.isEmpty());
QVERIFY(p1.definitionName() == QContactPhoneNumber::DefinitionName);
QContactName m1;
m1.setFirstName("Bob");
QVERIFY(!m1.isEmpty());
QVERIFY(m1.definitionName() == QContactName::DefinitionName);
QVERIFY(p1 != m1);
QVERIFY(f1 == f2);
f1 = p1; // f1 is a phonenumber
QVERIFY(f1 == p1);
f1 = f1; // assign to itself
QVERIFY(f1 == f1);
QVERIFY(f1 == p1);
QVERIFY(f1 != f2);
QVERIFY(p1 != f2);
p1 = p1; // assign leaf class to itself
QVERIFY(p1 == p1);
QVERIFY(f1 == p1);
QVERIFY(p1 == f1);
f2 = f1; // f2 = f1 = phonenumber
QVERIFY(f1 == f2);
QVERIFY(f2 == f1);
QVERIFY(f2 == p1);
QVERIFY(f1 == p1);
f1 = m1; // f1 = name, f2 = phonenumber
QVERIFY(f1 == m1);
QVERIFY(f1 != f2);
QVERIFY(f2 == p1);
QContactPhoneNumber p2(f2); // p2 = f2 = phonenumber
QVERIFY(p1 == p2);
QVERIFY(p1 == f2);
QCOMPARE(p2.number(), p1.number());
QCOMPARE(p2.number(), QString("123456"));
p2 = p1; // phone number to phone number
QVERIFY(p1 == p2);
QVERIFY(p1 == f2);
QCOMPARE(p2.number(), p1.number());
QCOMPARE(p2.number(), QString("123456"));
p2.setNumber("5678"); // NOTE: implicitly shared, this has caused a detach so p1 != 2
QVERIFY(p1 != p2);
QVERIFY(p1 == f2);
QVERIFY(p2 != f2);
QCOMPARE(p2.number(), QString("5678"));
QCOMPARE(p1.number(), QString("123456"));
/* Bad assignment */
p2 = m1; // assign a name to a phone number
QVERIFY(p2 != m1);
QVERIFY(p2.definitionName() == QContactPhoneNumber::DefinitionName); // should still be a phone number though
QVERIFY(p2.isEmpty());
/* copy ctor */
QContactName m2(m1);
QVERIFY(m2 == m1);
/* another bad assignment */
m2 = p2; // phone number to a name
QVERIFY(m2 != m1);
QVERIFY(m2.definitionName() == QContactName::DefinitionName);
QVERIFY(m2.isEmpty());
/* Check contexts are considered for equality */
p2 = QContactPhoneNumber(); // new id / detach
p2.setNumber(p1.number());
p2.setContexts(QContactDetail::ContextHome);
QVERIFY(p1 != p2);
p2.removeValue(QContactDetail::FieldContext); // note, context is a value.
QVERIFY(p1 == p2); // different ids but same values should be equal
/* Copy ctor from valid type */
QContactDetail f3(p2);
QVERIFY(f3 == p2);
QVERIFY(f3.definitionName() == QContactPhoneNumber::DefinitionName);
/* Copy ctor from invalid type */
QContactPhoneNumber p3(m1);
QVERIFY(p3 != m1);
QVERIFY(p3.definitionName() == QContactPhoneNumber::DefinitionName);
QVERIFY(p3.isEmpty());
//.........这里部分代码省略.........
示例5:
// -----------------------------------------------------------------------------
// Copy c'tor
// -----------------------------------------------------------------------------
//
QContactDetail::QContactDetail(const QContactDetail& other)
{
mValue = other.value("");
}