kaddressbook Library API Documentation

addresseeeditordialog.cpp

00001 /* 00002 This file is part of KAddressBook. 00003 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 00019 As a special exception, permission is given to link this program 00020 with any edition of Qt, and distribute the resulting executable, 00021 without including the source code for Qt in the source distribution. 00022 */ 00023 00024 #include <qapplication.h> 00025 #include <qlayout.h> 00026 00027 #include <kdebug.h> 00028 #include <klocale.h> 00029 00030 #include "core.h" 00031 #include "addresseeeditorwidget.h" 00032 #include "simpleaddresseeeditor.h" 00033 #include "kabprefs.h" 00034 00035 #include "addresseeeditordialog.h" 00036 00037 AddresseeEditorDialog::AddresseeEditorDialog( KAB::Core *core, 00038 QWidget *parent, const char *name ) 00039 : KDialogBase( KDialogBase::Plain, i18n( "Edit Contact" ), 00040 KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Apply, 00041 KDialogBase::Ok, parent, name, false ) 00042 { 00043 kdDebug(5720) << "AddresseeEditorDialog()" << endl; 00044 00045 QWidget *page = plainPage(); 00046 00047 QVBoxLayout *layout = new QVBoxLayout( page ); 00048 00049 if ( KABPrefs::instance()->mEditorType == KABPrefs::SimpleEditor ) { 00050 mEditorWidget = new SimpleAddresseeEditor( core, false, page ); 00051 } else { 00052 mEditorWidget = new AddresseeEditorWidget( core, false, page ); 00053 } 00054 connect( mEditorWidget, SIGNAL( modified( const KABC::Addressee::List& ) ), 00055 SLOT( widgetModified() ) ); 00056 layout->addWidget( mEditorWidget ); 00057 00058 enableButton( KDialogBase::Apply, false ); 00059 00060 KConfig config( "kaddressbookrc" ); 00061 config.setGroup( "AddresseeEditor" ); 00062 QSize defaultSize( 750, 570 ); 00063 resize( config.readSizeEntry( "Size", &defaultSize ) ); 00064 } 00065 00066 AddresseeEditorDialog::~AddresseeEditorDialog() 00067 { 00068 kdDebug(5720) << "~AddresseeEditorDialog()" << endl; 00069 00070 KConfig config( "kaddressbookrc" ); 00071 config.setGroup( "AddresseeEditor" ); 00072 config.writeEntry( "Size", size() ); 00073 00074 emit editorDestroyed( mEditorWidget->addressee().uid() ); 00075 } 00076 00077 void AddresseeEditorDialog::setAddressee( const KABC::Addressee &addr ) 00078 { 00079 enableButton( KDialogBase::Apply, false ); 00080 00081 mEditorWidget->setAddressee( addr ); 00082 mEditorWidget->setInitialFocus(); 00083 } 00084 00085 KABC::Addressee AddresseeEditorDialog::addressee() 00086 { 00087 return mEditorWidget->addressee(); 00088 } 00089 00090 bool AddresseeEditorDialog::dirty() 00091 { 00092 return mEditorWidget->dirty(); 00093 } 00094 00095 void AddresseeEditorDialog::slotApply() 00096 { 00097 if ( mEditorWidget->dirty() ) { 00098 QApplication::setOverrideCursor( Qt::waitCursor ); 00099 mEditorWidget->save(); 00100 emit contactModified( mEditorWidget->addressee() ); 00101 QApplication::restoreOverrideCursor(); 00102 } 00103 00104 enableButton( KDialogBase::Apply, false ); 00105 00106 KDialogBase::slotApply(); 00107 } 00108 00109 void AddresseeEditorDialog::slotOk() 00110 { 00111 slotApply(); 00112 00113 KDialogBase::slotOk(); 00114 00115 // Destroy this dialog 00116 delayedDestruct(); 00117 } 00118 00119 void AddresseeEditorDialog::widgetModified() 00120 { 00121 enableButton( KDialogBase::Apply, true ); 00122 } 00123 00124 void AddresseeEditorDialog::slotCancel() 00125 { 00126 KDialogBase::slotCancel(); 00127 00128 // Destroy this dialog 00129 delayedDestruct(); 00130 } 00131 00132 #include "addresseeeditordialog.moc"
KDE Logo
This file is part of the documentation for kaddressbook Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Oct 1 15:19:04 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003