24 #include <tqapplication.h>
28 #include <tdelocale.h>
31 #include "addresseeeditorwidget.h"
32 #include "simpleaddresseeeditor.h"
35 #include "addresseeeditordialog.h"
37 AddresseeEditorDialog::AddresseeEditorDialog( KAB::Core *core,
38 TQWidget *parent,
const char *name )
39 : KDialogBase( KDialogBase::Plain, i18n(
"Edit Contact" ),
40 KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Apply,
41 KDialogBase::Ok, parent, name, false )
45 setWFlags( getWFlags() | WGroupLeader );
47 kdDebug(5720) <<
"AddresseeEditorDialog()" << endl;
49 TQWidget *page = plainPage();
51 TQVBoxLayout *layout =
new TQVBoxLayout( page );
53 if ( KABPrefs::instance()->editorType() == KABPrefs::SimpleEditor ) {
54 mEditorWidget =
new SimpleAddresseeEditor( page );
56 mEditorWidget =
new AddresseeEditorWidget( page );
58 connect( mEditorWidget, TQ_SIGNAL( modified() ), TQ_SLOT( widgetModified() ) );
59 layout->addWidget( mEditorWidget );
61 enableButton( KDialogBase::Apply,
false );
63 TDEConfig config(
"kaddressbookrc" );
64 config.setGroup(
"AddresseeEditor" );
65 TQSize defaultSize( 750, 570 );
66 resize( config.readSizeEntry(
"Size", &defaultSize ) );
69 AddresseeEditorDialog::~AddresseeEditorDialog()
71 kdDebug(5720) <<
"~AddresseeEditorDialog()" << endl;
73 TDEConfig config(
"kaddressbookrc" );
74 config.setGroup(
"AddresseeEditor" );
75 config.writeEntry(
"Size", size() );
77 emit editorDestroyed( mEditorWidget->addressee().uid() );
80 void AddresseeEditorDialog::setAddressee(
const TDEABC::Addressee &addr )
82 enableButton( KDialogBase::Apply,
false );
86 mEditorWidget->setAddressee( addr );
87 mEditorWidget->setInitialFocus();
90 TDEABC::Addressee AddresseeEditorDialog::addressee()
92 return mEditorWidget->addressee();
95 bool AddresseeEditorDialog::dirty()
97 return mEditorWidget->dirty();
100 void AddresseeEditorDialog::slotApply()
102 if ( !mEditorWidget->readyToClose() )
105 if ( mEditorWidget->dirty() ) {
106 TQApplication::setOverrideCursor( TQt::waitCursor );
107 mEditorWidget->save();
108 emit contactModified( mEditorWidget->addressee() );
109 TQApplication::restoreOverrideCursor();
112 enableButton( KDialogBase::Apply,
false );
114 KDialogBase::slotApply();
117 void AddresseeEditorDialog::slotOk()
119 if ( !mEditorWidget->readyToClose() )
124 KDialogBase::slotOk();
130 void AddresseeEditorDialog::widgetModified()
132 const TDEABC::Addressee addressee = mEditorWidget->addressee();
133 if ( !addressee.isEmpty() )
134 setTitle( addressee );
136 enableButton( KDialogBase::Apply,
true );
139 void AddresseeEditorDialog::slotCancel()
141 KDialogBase::slotCancel();
147 void AddresseeEditorDialog::setTitle(
const TDEABC::Addressee &addr )
149 if ( !addr.realName().isEmpty() )
150 setCaption( i18n(
"Edit Contact '%1'" ).arg( addr.realName() ) );
153 #include "addresseeeditordialog.moc"