00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
#include <qlayout.h>
00025
#include <qlabel.h>
00026
00027
#include <klineedit.h>
00028
#include <klocale.h>
00029
#include <kdialog.h>
00030
00031
#include "simpleaddresseeeditor.h"
00032
00033 SimpleAddresseeEditor::SimpleAddresseeEditor( KAB::Core *core,
bool isExtension,
00034
QWidget *parent,
const char *name )
00035 : AddresseeEditorBase( core, isExtension, parent, name ), mDirty( false ),
00036 mBlockModified( false )
00037 {
00038 kdDebug(5720) <<
"SimpleAddresseeEditor()" << endl;
00039
00040 initGui();
00041
00042
00043 load();
00044
00045 mDirty =
false;
00046 }
00047
00048 SimpleAddresseeEditor::~SimpleAddresseeEditor()
00049 {
00050 kdDebug(5720) <<
"~SimpleAddresseeEditor()" << endl;
00051 }
00052
00053
void SimpleAddresseeEditor::setAddressee(
const KABC::Addressee &addr )
00054 {
00055 mAddressee = addr;
00056
00057 load();
00058 }
00059
00060
const KABC::Addressee &SimpleAddresseeEditor::addressee()
00061 {
00062
return mAddressee;
00063 }
00064
00065
void SimpleAddresseeEditor::setInitialFocus()
00066 {
00067 mNameEdit->setFocus();
00068 }
00069
00070
void SimpleAddresseeEditor::initGui()
00071 {
00072
QGridLayout *topLayout =
new QGridLayout(
this, 2, 2, KDialog::marginHint(),
00073 KDialog::spacingHint() );
00074
00075
QLabel *label =
new QLabel( i18n(
"Name:" ),
this );
00076 topLayout->addWidget( label, 0, 0 );
00077
00078 mNameEdit =
new KLineEdit(
this );
00079 topLayout->addWidget( mNameEdit, 0, 1 );
00080 connect( mNameEdit, SIGNAL( textChanged(
const QString & ) ),
00081 SLOT( emitModified() ) );
00082
00083 label =
new QLabel( i18n(
"Email:" ),
this );
00084 topLayout->addWidget( label, 1, 0 );
00085
00086 mEmailEdit =
new KLineEdit(
this );
00087 topLayout->addWidget( mEmailEdit, 1, 1 );
00088 connect( mEmailEdit, SIGNAL( textChanged(
const QString & ) ),
00089 SLOT( emitModified() ) );
00090 }
00091
00092
void SimpleAddresseeEditor::load()
00093 {
00094 kdDebug(5720) <<
"SimpleAddresseeEditor::load()" << endl;
00095
00096 kdDebug(5720) <<
"ASSEMBLED NAME: " << mAddressee.assembledName() << endl;
00097 kdDebug(5720) <<
"EMAIL NAME: " << mAddressee.preferredEmail() << endl;
00098
00099 mBlockModified =
true;
00100
00101 mNameEdit->setText( mAddressee.assembledName() );
00102
00103 mEmailEdit->setText( mAddressee.preferredEmail() );
00104
00105 mBlockModified =
false;
00106
00107 mDirty =
false;
00108 }
00109
00110
void SimpleAddresseeEditor::save()
00111 {
00112
if ( !mDirty )
return;
00113
00114 mAddressee.setNameFromString( mNameEdit->text() );
00115 mAddressee.insertEmail( mEmailEdit->text(),
true );
00116
00117 mDirty =
false;
00118 }
00119
00120
bool SimpleAddresseeEditor::dirty()
00121 {
00122
return mDirty;
00123 }
00124
00125
QString SimpleAddresseeEditor::title()
const
00126
{
00127
return i18n(
"Simple Contact Editor" );
00128 }
00129
00130
QString SimpleAddresseeEditor::identifier()
const
00131
{
00132
return "simple_contact_editor";
00133 }
00134
00135
void SimpleAddresseeEditor::emitModified()
00136 {
00137 mDirty =
true;
00138
00139 KABC::Addressee::List list;
00140
00141
if ( isExtension() && !mBlockModified ) {
00142 save();
00143 list.append( mAddressee );
00144 }
00145
00146 emit modified( list );
00147 }
00148
00149
#include "simpleaddresseeeditor.moc"