コード例 #1
0
HbWidget* CntEmailEditorViewItem::createCustomWidget()
{
    mItem = new CntCommonDetailViewItem(this);
    mItem->editor()->setMaxLength( CNT_EMAIL_EDITOR_MAXLENGTH );
    mItem->editor()->setInputMethodHints(Qt::ImhPreferLowercase);

    HbDataFormModel* model = static_cast<HbDataFormModel*>(itemView()->model());
    CntDetailModelItem* item = static_cast<CntDetailModelItem*>( model->itemFromIndex(modelIndex()) );
    QContactDetail detail = item->detail();

    mItem->editor()->setInputMethodHints( Qt::ImhEmailCharactersOnly );

    constructSubTypeModel( detail.contexts() );

    QContactEmailAddress address = detail;
    QString d = address.emailAddress();
    mItem->editor()->setText( address.emailAddress() );

    connect( mItem->comboBox(), SIGNAL(currentIndexChanged(int)), this, SLOT(indexChanged(int)) );
    connect( mItem->editor(), SIGNAL(textChanged(QString)),this, SLOT(textChanged(QString)) );

    // Naming UI components for automation testability
    QString editorObjName = detail.definitionName() + " line edit %1";
    mItem->editor()->setObjectName(editorObjName.arg(modelIndex().row()));

    QString comboBoxObjName = detail.definitionName() + " combo box %1";
    mItem->comboBox()->setObjectName(comboBoxObjName.arg(modelIndex().row()));
    return mItem;
}
コード例 #2
0
void tst_QContactDetail::contexts()
{
    QContactDetail d;
    QVERIFY(d.contexts().count() == 0);

    // test set contexts
    d.setContexts(QContactDetail::ContextWork);
    QVERIFY(d.contexts().count() == 1);
    QVERIFY(d.contexts().contains(QContactDetail::ContextWork));
    QVERIFY(!d.contexts().contains(QContactDetail::ContextOther));
    QVERIFY(!d.contexts().contains(QContactDetail::ContextHome));

    QStringList contexts;
    contexts.append(QContactDetail::ContextHome);
    contexts.append(QContactDetail::ContextOther);
    contexts.append("CustomContext"); // note: won't (necessarily) validate but will work in QCD.
    d.setContexts(contexts);
    QVERIFY(d.contexts().count() == 3);
    QVERIFY(!d.contexts().contains(QContactDetail::ContextWork));
    QVERIFY(d.contexts().contains(QContactDetail::ContextOther));
    QVERIFY(d.contexts().contains(QContactDetail::ContextHome));
    QVERIFY(d.contexts().contains("CustomContext"));
    QCOMPARE(d.contexts(), contexts);

    // test that contexts are values.
    QCOMPARE(d.value<QStringList>(QContactDetail::FieldContext), d.contexts());
}