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 <qlayout.h>
00025 
00026 #include <kdebug.h>
00027 #include <klocale.h>
00028 
00029 #include "core.h"
00030 #include "addresseeeditorwidget.h"
00031 
00032 #include "addresseeeditordialog.h"
00033 
00034 AddresseeEditorDialog::AddresseeEditorDialog( KAB::Core *core,
00035                                               QWidget *parent, const char *name )
00036   : KDialogBase( KDialogBase::Plain, i18n( "Edit Contact" ), 
00037                  KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Apply,
00038                  KDialogBase::Ok, parent, name, false )
00039 {
00040   kdDebug(5720) << "AddresseeEditorDialog()" << endl;
00041 
00042   QWidget *page = plainPage();
00043 
00044   QVBoxLayout *layout = new QVBoxLayout( page );
00045 
00046   mEditorWidget = new AddresseeEditorWidget( core, false, page );
00047   connect( mEditorWidget, SIGNAL( modified( const KABC::Addressee::List& ) ),
00048            SLOT( widgetModified() ) );
00049   layout->addWidget( mEditorWidget );
00050 
00051   enableButton( KDialogBase::Apply, false );
00052 }
00053 
00054 AddresseeEditorDialog::~AddresseeEditorDialog()
00055 {
00056   kdDebug(5720) << "~AddresseeEditorDialog()" << endl;
00057 
00058   emit editorDestroyed( mEditorWidget->addressee().uid() );
00059 }
00060 
00061 void AddresseeEditorDialog::setAddressee( const KABC::Addressee &addr )
00062 {
00063   enableButton( KDialogBase::Apply, false );
00064 
00065   mEditorWidget->setAddressee( addr );
00066 }
00067 
00068 KABC::Addressee AddresseeEditorDialog::addressee()
00069 {
00070   return mEditorWidget->addressee();
00071 }
00072 
00073 bool AddresseeEditorDialog::dirty()
00074 {
00075   return mEditorWidget->dirty();
00076 }
00077 
00078 void AddresseeEditorDialog::slotApply()
00079 {
00080   if ( mEditorWidget->dirty() ) {
00081     mEditorWidget->save();
00082     emit contactModified( mEditorWidget->addressee() );
00083   }
00084 
00085   enableButton( KDialogBase::Apply, false );
00086 
00087   KDialogBase::slotApply();
00088 }
00089 
00090 void AddresseeEditorDialog::slotOk()
00091 {
00092   slotApply();
00093 
00094   KDialogBase::slotOk();
00095 
00096   // Destroy this dialog
00097   delayedDestruct();
00098 }
00099 
00100 void AddresseeEditorDialog::widgetModified()
00101 {
00102   enableButton( KDialogBase::Apply, true );
00103 }
00104 
00105 void AddresseeEditorDialog::slotCancel()
00106 {
00107   KDialogBase::slotCancel();
00108 
00109   // Destroy this dialog
00110   delayedDestruct();
00111 }
00112 
00113 #include "addresseeeditordialog.moc"
KDE Logo
This file is part of the documentation for kaddressbook Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat May 1 11:38:49 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003