22 #include "customfieldeditordialog.h"
24 #include <kcombobox.h>
25 #include <klineedit.h>
26 #include <klocalizedstring.h>
29 #include <QFormLayout>
30 #include <QRegExpValidator>
32 CustomFieldEditorDialog::CustomFieldEditorDialog( QWidget *parent )
35 setCaption( i18n(
"Edit Custom Field" ) );
36 setButtons( Ok | Cancel | Details );
38 QWidget *widget =
new QWidget(
this );
39 setMainWidget( widget );
41 QFormLayout *layout =
new QFormLayout( widget );
44 mTitle =
new KLineEdit;
45 mType =
new KComboBox;
46 mScope =
new QCheckBox( i18n(
"Use field for all contacts" ) );
48 layout->addRow( i18nc(
"The title of a custom field",
"Title" ), mTitle );
49 layout->addRow( i18nc(
"The type of a custom field",
"Type" ), mType );
50 layout->addRow( QString(), mScope );
52 QWidget *detailsWidget =
new QWidget;
53 QFormLayout *detailsLayout =
new QFormLayout( detailsWidget );
54 detailsLayout->addRow( i18n(
"Key" ), mKey );
56 setDetailsWidget( detailsWidget );
57 setButtonText( Details, i18nc(
"@label Opens the advanced dialog",
"Advanced" ) );
59 mType->addItem( i18n(
"Text" ), CustomField::TextType );
60 mType->addItem( i18n(
"Numeric" ), CustomField::NumericType );
61 mType->addItem( i18n(
"Boolean" ), CustomField::BooleanType );
62 mType->addItem( i18n(
"Date" ), CustomField::DateType );
63 mType->addItem( i18n(
"Time" ), CustomField::TimeType );
64 mType->addItem( i18n(
"DateTime" ), CustomField::DateTimeType );
65 mType->addItem( i18n(
"Url" ), CustomField::UrlType );
67 mKey->setValidator(
new QRegExpValidator( QRegExp( QLatin1String(
"[a-zA-Z0-9\\-]+" ) ),
this ) );
71 void CustomFieldEditorDialog::setCustomField(
const CustomField &field )
75 mKey->setText( mCustomField.key() );
76 mTitle->setText( mCustomField.title() );
77 mType->setCurrentIndex( mType->findData( mCustomField.type() ) );
81 CustomField CustomFieldEditorDialog::customField()
const
85 customField.setKey( mKey->text() );
86 customField.setTitle( mTitle->text() );
87 customField.setType( static_cast<CustomField::Type>( mType->itemData( mType->currentIndex() ).toInt() ) );
A class that represents non-standard contact fields.
Field has been defined by the external data source (e.g. vCard)
Field has been defined by user for all contacts.
Field has been defined by user for one contact.