void EmailEditWidgetTest::shouldChangeEmail()
{
    EmailEditWidget widget;
    QLineEdit *lineedit = widget.findChild<QLineEdit *>(QStringLiteral("emailedit"));
    KContacts::Addressee addr;
    KContacts::Email::List lst;
    const QString firstEmail(QStringLiteral("*****@*****.**"));
    lst << KContacts::Email(firstEmail);
    lst << KContacts::Email(QStringLiteral("*****@*****.**"));
    addr.setEmailList(lst);
    widget.loadContact(addr);
    const QString changedEmail(QStringLiteral("*****@*****.**"));
    lineedit->setText(changedEmail);
    KContacts::Addressee result;
    widget.storeContact(result);
    QVERIFY(!result.emailList().isEmpty());
    QCOMPARE(result.emailList().first().mail(), changedEmail);
}
void MailWidgetLister::loadContact(const KContacts::Addressee &contact)
{
    KContacts::Email::List mailList = contact.emailList();
    if (mailList.isEmpty()) {
        setNumberOfShownWidgetsTo(1);
    } else {
        setNumberOfShownWidgetsTo(mailList.count());
        const QList<QWidget *> widgetList = widgets();
        auto wIt = widgetList.constBegin();
        auto wEnd = widgetList.constEnd();
        for (int i = 0; wIt != wEnd; ++wIt, ++i) {
            MailWidget *w = qobject_cast<MailWidget *>(*wIt);
            w->setMail(mailList.at(i));
        }
    }
}