28 #include <tdelocale.h>
29 #include <kstandarddirs.h>
31 #include <libkcal/freebusyurlstore.h>
33 #include "freebusywidget.h"
35 FreeBusyWidget::FreeBusyWidget( TDEABC::AddressBook *ab, TQWidget *parent, const char *name )
36 : KAB::ContactEditorWidget( ab, parent, name )
38 TQHBoxLayout *layout = new TQHBoxLayout( this, KDialog::marginHint(),
39 KDialog::spacingHint() );
41 TQLabel *label = new TQLabel( i18n( "Location of Free/Busy information:" ), this );
42 layout->addWidget( label );
44 mURL = new KURLRequester( this );
45 label->setBuddy( mURL );
46 layout->addWidget( mURL );
48 connect( mURL, TQ_SIGNAL( textChanged( const TQString& ) ),
49 this, TQ_SLOT( setModified() ) );
52 FreeBusyWidget::~FreeBusyWidget()
56 void FreeBusyWidget::loadContact( TDEABC::Addressee *addr )
58 if ( addr->preferredEmail().isEmpty() )
61 mURL->setURL( KCal::FreeBusyUrlStore::self()->readUrl( addr->preferredEmail() ) );
64 void FreeBusyWidget::storeContact( TDEABC::Addressee *addr )
66 if ( addr->preferredEmail().isEmpty() )
69 KCal::FreeBusyUrlStore::self()->writeUrl( addr->preferredEmail(), mURL->url() );
70 KCal::FreeBusyUrlStore::self()->sync();
71 if ( mURL->url().isEmpty() ) {
72 addr->removeCustom( "KADDRESSBOOK", "FreeBusyURL" );
74 addr->insertCustom( "KADDRESSBOOK", "FreeBusyURL", mURL->url() );
78 void FreeBusyWidget::setReadOnly( bool readOnly )
80 mURL->setEnabled( !readOnly );
83 #include "freebusywidget.moc"
|