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