22 #include "nameeditwidget.h"
24 #include "nameeditdialog.h"
26 #include <QtCore/QPointer>
27 #include <QHBoxLayout>
28 #include <QToolButton>
30 #include <kabc/addressee.h>
32 #include <klineedit.h>
33 #include <klocalizedstring.h>
35 NameEditWidget::NameEditWidget(
QWidget *parent)
42 mNameEdit =
new KLineEdit;
43 mNameEdit->setTrapReturnKey(
true);
45 setFocusProxy(mNameEdit);
46 setFocusPolicy(Qt::StrongFocus);
49 mButtonEdit->
setText(i18n(
"..."));
53 connect( mNameEdit, SIGNAL(textChanged(
QString)),
this, SLOT(textChanged(
QString)) );
54 connect( mButtonEdit, SIGNAL(clicked()),
this, SLOT(openNameEditDialog()) );
57 NameEditWidget::~NameEditWidget()
63 mNameEdit->setReadOnly(readOnly);
64 mButtonEdit->setEnabled(!readOnly);
71 disconnect(mNameEdit, SIGNAL(textChanged(
QString)),
this, SLOT(textChanged(
QString)));
72 mNameEdit->setText(contact.assembledName());
73 connect(mNameEdit, SIGNAL(textChanged(
QString)),
this, SLOT(textChanged(
QString)));
78 contact.setPrefix(mContact.prefix());
79 contact.setGivenName(mContact.givenName());
80 contact.setAdditionalName(mContact.additionalName());
81 contact.setFamilyName(mContact.familyName());
82 contact.setSuffix(mContact.suffix());
85 void NameEditWidget::textChanged(
const QString &text)
87 mContact.setNameFromString(text);
89 emit nameChanged(mContact);
92 void NameEditWidget::openNameEditDialog()
96 dlg->setPrefix(mContact.prefix());
97 dlg->setGivenName(mContact.givenName());
98 dlg->setAdditionalName(mContact.additionalName());
99 dlg->setFamilyName(mContact.familyName());
100 dlg->setSuffix(mContact.suffix());
102 if (dlg->exec() == QDialog::Accepted) {
103 mContact.setPrefix(dlg->prefix());
104 mContact.setGivenName(dlg->givenName());
105 mContact.setAdditionalName(dlg->additionalName());
106 mContact.setFamilyName(dlg->familyName());
107 mContact.setSuffix(dlg->suffix());
109 disconnect(mNameEdit, SIGNAL(textChanged(
QString)),
this, SLOT(textChanged(
QString)));
110 mNameEdit->setText(mContact.assembledName());
111 connect(mNameEdit, SIGNAL(textChanged(
QString)),
this, SLOT(textChanged(
QString)));
113 emit nameChanged(mContact);
void setMargin(int margin)
void setText(const QString &text)
void setSpacing(int spacing)