korganizer

koeditordetails.cpp

00001 /*
00002     This file is part of KOrganizer.
00003 
00004     Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
00005     Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00006 
00007     This program is free software; you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation; either version 2 of the License, or
00010     (at your option) any later version.
00011 
00012     This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program; if not, write to the Free Software
00019     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020 
00021     As a special exception, permission is given to link this program
00022     with any edition of Qt, and distribute the resulting executable,
00023     without including the source code for Qt in the source distribution.
00024 */
00025 
00026 #include "koeditordetails.h"
00027 
00028 #include <qbuttongroup.h>
00029 #include <qcheckbox.h>
00030 #include <qcombobox.h>
00031 #include <qdatetime.h>
00032 #include <qdragobject.h>
00033 #include <qfiledialog.h>
00034 #include <qgroupbox.h>
00035 #include <qlabel.h>
00036 #include <qlayout.h>
00037 #include <qlineedit.h>
00038 #include <qpushbutton.h>
00039 #include <qradiobutton.h>
00040 #include <qregexp.h>
00041 #include <qtooltip.h>
00042 #include <qvbox.h>
00043 #include <qvgroupbox.h>
00044 #include <qwhatsthis.h>
00045 #include <qwidgetstack.h>
00046 
00047 #include <kdebug.h>
00048 #include <klocale.h>
00049 #include <kiconloader.h>
00050 #include <kmessagebox.h>
00051 #ifndef KORG_NOKABC
00052 #include <kabc/addresseedialog.h>
00053 #include <kabc/vcardconverter.h>
00054 #include <libkdepim/addressesdialog.h>
00055 #include <libkdepim/addresseelineedit.h>
00056 #include <kabc/distributionlist.h>
00057 #include <kabc/stdaddressbook.h>
00058 #endif
00059 #include <libkdepim/kvcarddrag.h>
00060 #include <libemailfunctions/email.h>
00061 
00062 #include <libkcal/incidence.h>
00063 
00064 #include "koprefs.h"
00065 #include "koglobals.h"
00066 
00067 #include "koeditorfreebusy.h"
00068 
00069 #include "kocore.h"
00070 
00071 template <>
00072 CustomListViewItem<KCal::Attendee *>::~CustomListViewItem()
00073 {
00074   delete mData;
00075 }
00076 
00077 template <>
00078 void CustomListViewItem<KCal::Attendee *>::updateItem()
00079 {
00080   setText(0,mData->name());
00081   setText(1,mData->email());
00082   setText(2,mData->roleStr());
00083   setText(3,mData->statusStr());
00084   if (mData->RSVP() && !mData->email().isEmpty())
00085     setPixmap(4,KOGlobals::self()->smallIcon("mailappt"));
00086   else
00087     setPixmap(4,KOGlobals::self()->smallIcon("nomailappt"));
00088 }
00089 
00090 KOAttendeeListView::KOAttendeeListView ( QWidget *parent, const char *name )
00091   : KListView(parent, name)
00092 {
00093   setAcceptDrops( true );
00094   setAllColumnsShowFocus( true );
00095   setSorting( -1 );
00096 }
00097 
00103 KOAttendeeListView::~KOAttendeeListView()
00104 {
00105 }
00106 
00107 void KOAttendeeListView::contentsDragEnterEvent( QDragEnterEvent *e )
00108 {
00109   dragEnterEvent(e);
00110 }
00111 
00112 void KOAttendeeListView::contentsDragMoveEvent( QDragMoveEvent *e )
00113 {
00114 #ifndef KORG_NODND
00115   if ( KVCardDrag::canDecode( e ) || QTextDrag::canDecode( e ) ) {
00116     e->accept();
00117   } else {
00118     e->ignore();
00119   }
00120 #endif
00121 }
00122 
00123 void KOAttendeeListView::dragEnterEvent( QDragEnterEvent *e )
00124 {
00125 #ifndef KORG_NODND
00126   if ( KVCardDrag::canDecode( e ) || QTextDrag::canDecode( e ) ) {
00127     e->accept();
00128   } else {
00129     e->ignore();
00130   }
00131 #endif
00132 }
00133 
00134 void KOAttendeeListView::addAttendee( const QString &newAttendee )
00135 {
00136   kdDebug(5850) << " Email: " << newAttendee << endl;
00137   QString name;
00138   QString email;
00139   KPIM::getNameAndMail( newAttendee, name, email );
00140   emit dropped( new Attendee( name, email, true ) );
00141 }
00142 
00143 void KOAttendeeListView::contentsDropEvent( QDropEvent *e )
00144 {
00145   dropEvent(e);
00146 }
00147 
00148 void KOAttendeeListView::dropEvent( QDropEvent *e )
00149 {
00150 #ifndef KORG_NODND
00151   QString text;
00152   QString vcards;
00153 
00154 #ifndef KORG_NOKABC
00155   if ( KVCardDrag::decode( e, vcards ) ) {
00156     KABC::VCardConverter converter;
00157 
00158     KABC::Addressee::List list = converter.parseVCards( vcards );
00159     KABC::Addressee::List::Iterator it;
00160     for ( it = list.begin(); it != list.end(); ++it ) {
00161       QString em( (*it).fullEmail() );
00162       if (em.isEmpty()) {
00163         em=(*it).realName();
00164       }
00165       addAttendee( em );
00166     }
00167   } else
00168 #endif // KORG_NOKABC
00169   if (QTextDrag::decode(e,text)) {
00170     kdDebug(5850) << "Dropped : " << text << endl;
00171     QStringList emails = QStringList::split(",",text);
00172     for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
00173       addAttendee(*it);
00174     }
00175   }
00176 #endif //KORG_NODND
00177 }
00178 
00179 
00180 KOEditorDetails::KOEditorDetails( int spacing, QWidget *parent,
00181                                   const char *name )
00182   : QWidget( parent, name), mDisableItemUpdate( false ), mFreeBusy( 0 )
00183 {
00184   QGridLayout *topLayout = new QGridLayout( this );
00185   topLayout->setSpacing( spacing );
00186 
00187   mOrganizerHBox = new QHBox( this );
00188   // If creating a new event, then the user is the organizer -> show the
00189   // identity combo
00190   // readEvent will delete it and set another label text instead, if the user
00191   // isn't the organizer.
00192   // Note that the i18n text below is duplicated in readEvent
00193   QString whatsThis = i18n("Sets the identity corresponding to "
00194                "the organizer of this to-do or event. "
00195                "Identities can be set in the 'Personal' "
00196                "section of the KOrganizer configuration, or in the "
00197                "'Security & Privacy'->'Password & User Account' "
00198                "section of the KDE Control Center. In addition, "
00199                "identities are gathered from your KMail settings "
00200                "and from your address book. If you choose "
00201                "to set it globally for KDE in the Control Center, "
00202                "be sure to check 'Use email settings from "
00203                "Control Center' in the 'Personal' section of the "
00204                "KOrganizer configuration.");
00205   mOrganizerLabel = new QLabel( i18n( "Identity as organizer:" ),
00206                                 mOrganizerHBox );
00207   mOrganizerCombo = new QComboBox( mOrganizerHBox );
00208   QWhatsThis::add( mOrganizerLabel, whatsThis );
00209   QWhatsThis::add( mOrganizerCombo, whatsThis );
00210   fillOrganizerCombo();
00211   mOrganizerHBox->setStretchFactor( mOrganizerCombo, 100 );
00212 
00213   mListView = new KOAttendeeListView( this, "mListView" );
00214   QWhatsThis::add( mListView,
00215            i18n("Displays information about current attendees. "
00216             "To edit an attendee, select it in this list "
00217             "and modify the values in the area below. "
00218             "Clicking on a column title will sort the list "
00219             "according to that column. The RSVP column "
00220             "indicates whether or not a response is requested "
00221             "from the attendee.") );
00222   mListView->addColumn( i18n("Name"), 200 );
00223   mListView->addColumn( i18n("Email"), 200 );
00224   mListView->addColumn( i18n("Role"), 60 );
00225   mListView->addColumn( i18n("Status"), 100 );
00226   mListView->addColumn( i18n("RSVP"), 35 );
00227   mListView->setResizeMode( QListView::LastColumn );
00228   if ( KOPrefs::instance()->mCompactDialogs ) {
00229     mListView->setFixedHeight( 78 );
00230   }
00231 
00232   connect( mListView, SIGNAL( selectionChanged( QListViewItem * ) ),
00233            SLOT( updateAttendeeInput() ) );
00234 #ifndef KORG_NODND
00235   connect( mListView, SIGNAL( dropped( Attendee * ) ),
00236            SLOT( insertAttendee( Attendee * ) ) );
00237 #endif
00238 
00239   whatsThis = i18n("Edits the name of the attendee selected in the list "
00240            "above, or adds a new attendee if there are no attendees"
00241            "in the list.");
00242   QLabel *attendeeLabel = new QLabel( this );
00243   QWhatsThis::add( attendeeLabel, whatsThis );
00244   attendeeLabel->setText( i18n("Na&me:") );
00245 
00246   mNameEdit = new KPIM::AddresseeLineEdit( this );
00247   QWhatsThis::add( mNameEdit, whatsThis );
00248   mNameEdit->setClickMessage( i18n("Click to add a new attendee") );
00249   attendeeLabel->setBuddy( mNameEdit );
00250   mNameEdit->installEventFilter( this );
00251   connect( mNameEdit, SIGNAL( textChanged( const QString & ) ),
00252            SLOT( updateAttendeeItem() ) );
00253 
00254   whatsThis = i18n("Edits the role of the attendee selected "
00255            "in the list above.");
00256   QLabel *attendeeRoleLabel = new QLabel( this );
00257   QWhatsThis::add( attendeeRoleLabel, whatsThis );
00258   attendeeRoleLabel->setText( i18n("Ro&le:") );
00259 
00260   mRoleCombo = new QComboBox( false, this );
00261   QWhatsThis::add( mRoleCombo, whatsThis );
00262   mRoleCombo->insertStringList( Attendee::roleList() );
00263   attendeeRoleLabel->setBuddy( mRoleCombo );
00264   connect( mRoleCombo, SIGNAL( activated( int ) ),
00265            SLOT( updateAttendeeItem() ) );
00266 
00267   whatsThis = i18n("Edits the current attendance status of the attendee "
00268            "selected in the list above.");
00269   QLabel *statusLabel = new QLabel( this );
00270   QWhatsThis::add( statusLabel, whatsThis );
00271   statusLabel->setText( i18n("Stat&us:") );
00272 
00273   mStatusCombo = new QComboBox( false, this );
00274   QWhatsThis::add( mStatusCombo, whatsThis );
00275   mStatusCombo->insertStringList( Attendee::statusList() );
00276   statusLabel->setBuddy( mStatusCombo );
00277   connect( mStatusCombo, SIGNAL( activated( int ) ),
00278            SLOT( updateAttendeeItem() ) );
00279 
00280   mRsvpButton = new QCheckBox( this );
00281   QWhatsThis::add( mRsvpButton,
00282            i18n("Edits whether to send an email to the attendee "
00283             "selected in the list above to request "
00284             "a response concerning attendance.") );
00285   mRsvpButton->setText( i18n("Re&quest response") );
00286   connect( mRsvpButton, SIGNAL( clicked() ), SLOT( updateAttendeeItem() ) );
00287 
00288   QWidget *buttonBox = new QWidget( this );
00289   QVBoxLayout *buttonLayout = new QVBoxLayout( buttonBox );
00290 
00291   QPushButton *newButton = new QPushButton( i18n("&New"), buttonBox );
00292   QWhatsThis::add( newButton,
00293            i18n("Adds a new attendee to the list. Once the "
00294             "attendee is added, you will be able to "
00295             "edit the attendee's name, role, attendance "
00296             "status, and whether or not the attendee is required "
00297             "to respond to the invitation. To select an attendee "
00298             "from your addressbook, click the 'Select Addressee' "
00299             "button instead.") );
00300   buttonLayout->addWidget( newButton );
00301   connect( newButton, SIGNAL( clicked() ), SLOT( addNewAttendee() ) );
00302 
00303   mRemoveButton = new QPushButton( i18n("&Remove"), buttonBox );
00304   QWhatsThis::add( mRemoveButton,
00305            i18n("Removes the attendee selected in "
00306             "the list above.") );
00307   buttonLayout->addWidget( mRemoveButton );
00308   connect( mRemoveButton, SIGNAL( clicked() ), SLOT( removeAttendee() ) );
00309 
00310   mAddressBookButton = new QPushButton( i18n("Select Addressee..."),
00311                                         buttonBox );
00312   QWhatsThis::add( mAddressBookButton,
00313            i18n("Opens your address book, allowing you to select "
00314             "new attendees from it.") );
00315   buttonLayout->addWidget( mAddressBookButton );
00316   connect( mAddressBookButton, SIGNAL( clicked() ), SLOT( openAddressBook() ) );
00317 
00318   topLayout->addMultiCellWidget( mOrganizerHBox, 0, 0, 0, 5 );
00319   topLayout->addMultiCellWidget( mListView, 1, 1, 0, 5 );
00320   topLayout->addWidget( attendeeLabel, 2, 0 );
00321   topLayout->addMultiCellWidget( mNameEdit, 2, 2, 1, 1 );
00322 //  topLayout->addWidget( emailLabel, 3, 0 );
00323   topLayout->addWidget( attendeeRoleLabel, 3, 0 );
00324   topLayout->addWidget( mRoleCombo, 3, 1 );
00325 #if 0
00326   topLayout->setColStretch( 2, 1 );
00327   topLayout->addWidget( statusLabel, 3, 3 );
00328   topLayout->addWidget( mStatusCombo, 3, 4 );
00329 #else
00330   topLayout->addWidget( statusLabel, 4, 0 );
00331   topLayout->addWidget( mStatusCombo, 4, 1 );
00332 #endif
00333   topLayout->addMultiCellWidget( mRsvpButton, 5, 5, 0, 1 );
00334   topLayout->addMultiCellWidget( buttonBox, 2, 4, 5, 5 );
00335 
00336 #ifdef KORG_NOKABC
00337   mAddressBookButton->hide();
00338 #endif
00339 
00340   updateAttendeeInput();
00341 }
00342 
00343 KOEditorDetails::~KOEditorDetails()
00344 {
00345 }
00346 
00347 bool KOEditorDetails::hasAttendees()
00348 {
00349   return mListView->childCount() > 0;
00350 }
00351 
00352 bool KOEditorDetails::eventFilter( QObject *watched, QEvent *ev)
00353 {
00354   if ( watched && watched == mNameEdit && ev->type() == QEvent::FocusIn &&
00355        mListView->childCount() == 0 ) {
00356     addNewAttendee();
00357   }
00358 
00359   return QWidget::eventFilter( watched, ev );
00360 }
00361 
00362 void KOEditorDetails::removeAttendee()
00363 {
00364   AttendeeListItem *aItem =
00365       static_cast<AttendeeListItem *>( mListView->selectedItem() );
00366   if ( !aItem ) return;
00367 
00368   Attendee *delA = new Attendee( aItem->data()->name(), aItem->data()->email(),
00369                                  aItem->data()->RSVP(), aItem->data()->status(),
00370                                  aItem->data()->role(), aItem->data()->uid() );
00371   mdelAttendees.append( delA );
00372 
00373   if ( mFreeBusy ) mFreeBusy->removeAttendee( aItem->data() );
00374   delete aItem;
00375 
00376   updateAttendeeInput();
00377 }
00378 
00379 
00380 void KOEditorDetails::openAddressBook()
00381 {
00382 #ifndef KORG_NOKABC
00383   KPIM::AddressesDialog *dia = new KPIM::AddressesDialog( this, "adddialog" );
00384   dia->setShowCC( false );
00385   dia->setShowBCC( false );
00386   if ( dia->exec() ) {
00387     KABC::Addressee::List aList = dia->allToAddressesNoDuplicates();
00388     for ( KABC::Addressee::List::iterator itr = aList.begin();
00389           itr != aList.end(); ++itr ) {
00390       KABC::Addressee a = (*itr);
00391       bool myself = KOPrefs::instance()->thatIsMe( a.preferredEmail() );
00392       bool sameAsOrganizer = mOrganizerCombo && 
00393         KPIM::compareEmail( a.preferredEmail(), mOrganizerCombo->currentText(), false );
00394       KCal::Attendee::PartStat partStat;
00395       if ( myself && sameAsOrganizer ) 
00396         partStat = KCal::Attendee::Accepted;
00397       else 
00398         partStat = KCal::Attendee::NeedsAction;
00399       insertAttendee( new Attendee( a.realName(), a.preferredEmail(),
00400                                     !myself, partStat,
00401                                     KCal::Attendee::ReqParticipant, a.uid() ),
00402                       true );
00403     }
00404   }
00405   delete dia;
00406   return;
00407 #if 0
00408     // old code
00409     KABC::Addressee a = KABC::AddresseeDialog::getAddressee(this);
00410     if (!a.isEmpty()) {
00411         // If this is myself, I don't want to get a response but instead
00412         // assume I will be available
00413         bool myself = KOPrefs::instance()->thatIsMe( a.preferredEmail() );
00414         KCal::Attendee::PartStat partStat =
00415             myself ? KCal::Attendee::Accepted : KCal::Attendee::NeedsAction;
00416         insertAttendee( new Attendee( a.realName(), a.preferredEmail(),
00417                                       !myself, partStat,
00418                                       KCal::Attendee::ReqParticipant, a.uid() ) );
00419     }
00420 #endif
00421 #endif
00422 }
00423 
00424 
00425 void KOEditorDetails::addNewAttendee()
00426 {
00427   Attendee *a = new Attendee( i18n("Firstname Lastname"),
00428                               i18n("name") + "@localhost", true );
00429   insertAttendee( a, false );
00430   // We don't want the hint again
00431   mNameEdit->setClickMessage( "" );
00432   mNameEdit->setFocus();
00433   QTimer::singleShot( 0, mNameEdit, SLOT( selectAll() ) );
00434 }
00435 
00436 
00437 void KOEditorDetails::insertAttendee( Attendee *a )
00438 {
00439   insertAttendee( a, true );
00440 }
00441 
00442 void KOEditorDetails::insertAttendee( Attendee *a, bool goodEmailAddress )
00443 {
00444   // lastItem() is O(n), but for n very small that should be fine
00445   AttendeeListItem *item = new AttendeeListItem( a, mListView,
00446       static_cast<KListViewItem*>( mListView->lastItem() ) );
00447   mListView->setSelected( item, true );
00448   if( mFreeBusy ) mFreeBusy->insertAttendee( a, goodEmailAddress );
00449 }
00450 
00451 void KOEditorDetails::setDefaults()
00452 {
00453   mRsvpButton->setChecked( true );
00454 }
00455 
00456 void KOEditorDetails::readEvent( Incidence *event )
00457 {
00458   // Stop flickering in the free/busy view (not sure if this is necessary)
00459   bool block = false;
00460   if( mFreeBusy ) {
00461     block = mFreeBusy->updateEnabled();
00462     mFreeBusy->setUpdateEnabled( false );
00463     mFreeBusy->clearAttendees();
00464   }
00465 
00466   mListView->clear();
00467   mdelAttendees.clear();
00468   Attendee::List al = event->attendees();
00469   Attendee::List::ConstIterator it;
00470   for( it = al.begin(); it != al.end(); ++it )
00471     insertAttendee( new Attendee( **it ), true );
00472 
00473   mListView->setSelected( mListView->firstChild(), true );
00474 
00475   if ( KOPrefs::instance()->thatIsMe( event->organizer().email() ) ) {
00476     if ( !mOrganizerCombo ) {
00477       mOrganizerCombo = new QComboBox( mOrganizerHBox );
00478       fillOrganizerCombo();
00479     }
00480     mOrganizerLabel->setText( i18n( "Identity as organizer:" ) );
00481 
00482     int found = -1;
00483     QString fullOrganizer = event->organizer().fullName();
00484     for ( int i = 0 ; i < mOrganizerCombo->count(); ++i ) {
00485       if ( mOrganizerCombo->text( i ) == fullOrganizer ) {
00486         found = i;
00487         mOrganizerCombo->setCurrentItem( i );
00488         break;
00489       }
00490     }
00491     if ( found < 0 ) {
00492       mOrganizerCombo->insertItem( fullOrganizer, 0 );
00493       mOrganizerCombo->setCurrentItem( 0 );
00494     }
00495   } else { // someone else is the organizer
00496     if ( mOrganizerCombo ) {
00497       delete mOrganizerCombo;
00498       mOrganizerCombo = 0;
00499     }
00500     mOrganizerLabel->setText( i18n( "Organizer: %1" ).arg( event->organizer().fullName() ) );
00501   }
00502 
00503   // Reinstate free/busy view updates
00504   if( mFreeBusy ) mFreeBusy->setUpdateEnabled( block );
00505 }
00506 
00507 void KOEditorDetails::writeEvent(Incidence *event)
00508 {
00509   event->clearAttendees();
00510   QListViewItem *item;
00511   AttendeeListItem *a;
00512   for (item = mListView->firstChild(); item;
00513        item = item->nextSibling()) {
00514     a = (AttendeeListItem *)item;
00515     event->addAttendee(new Attendee(*(a->data())));
00516   }
00517   if ( mOrganizerCombo ) {
00518     event->setOrganizer( mOrganizerCombo->currentText() );
00519   }
00520 }
00521 
00522 void KOEditorDetails::cancelAttendeeEvent(Incidence *event)
00523 {
00524   event->clearAttendees();
00525   Attendee * att;
00526   for (att=mdelAttendees.first();att;att=mdelAttendees.next()) {
00527     event->addAttendee(new Attendee(*att));
00528   }
00529   mdelAttendees.clear();
00530 }
00531 
00532 bool KOEditorDetails::validateInput()
00533 {
00534   return true;
00535 }
00536 
00537 void KOEditorDetails::updateAttendeeInput()
00538 {
00539   setEnableAttendeeInput(!mNameEdit->text().isEmpty());
00540   QListViewItem *item = mListView->selectedItem();
00541   AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item );
00542   if (aItem) {
00543     fillAttendeeInput( aItem );
00544   } else {
00545     clearAttendeeInput();
00546   }
00547 }
00548 
00549 void KOEditorDetails::clearAttendeeInput()
00550 {
00551   mNameEdit->setText("");
00552   mUid = QString::null;
00553   mRoleCombo->setCurrentItem(0);
00554   mStatusCombo->setCurrentItem(0);
00555   mRsvpButton->setChecked(true);
00556   setEnableAttendeeInput( false );
00557 }
00558 
00559 void KOEditorDetails::fillAttendeeInput( AttendeeListItem *aItem )
00560 {
00561   Attendee *a = aItem->data();
00562   mDisableItemUpdate = true;
00563   QString name = a->name();
00564   if (!a->email().isEmpty()) {
00565     name = KPIM::quoteNameIfNecessary( name );
00566     name += " <" + a->email() + ">";
00567   }
00568   mNameEdit->setText(name);
00569   mUid = a->uid();
00570   mRoleCombo->setCurrentItem(a->role());
00571   mStatusCombo->setCurrentItem(a->status());
00572   mRsvpButton->setChecked(a->RSVP());
00573 
00574   mDisableItemUpdate = false;
00575 
00576   setEnableAttendeeInput( true );
00577 }
00578 
00579 void KOEditorDetails::setEnableAttendeeInput( bool enabled )
00580 {
00581   //mNameEdit->setEnabled( enabled );
00582   mRoleCombo->setEnabled( enabled );
00583   mStatusCombo->setEnabled( enabled );
00584   mRsvpButton->setEnabled( enabled );
00585 
00586   mRemoveButton->setEnabled( enabled );
00587 }
00588 
00589 void KOEditorDetails::updateAttendeeItem()
00590 {
00591   if (mDisableItemUpdate) return;
00592 
00593   QListViewItem *item = mListView->selectedItem();
00594   AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item );
00595   if ( !aItem ) return;
00596 
00597   Attendee *a = aItem->data();
00598 
00599   QString name;
00600   QString email;
00601   KPIM::getNameAndMail(mNameEdit->text(), name, email);
00602 
00603   bool iAmTheOrganizer = mOrganizerCombo &&
00604     KOPrefs::instance()->thatIsMe( mOrganizerCombo->currentText() );
00605   if ( iAmTheOrganizer ) {
00606     bool myself =
00607       KPIM::compareEmail( email, mOrganizerCombo->currentText(), false );
00608     bool wasMyself = 
00609       KPIM::compareEmail( a->email(), mOrganizerCombo->currentText(), false );
00610     if ( myself ) {
00611       mStatusCombo->setCurrentItem( KCal::Attendee::Accepted );
00612       mRsvpButton->setChecked( false );
00613       mRsvpButton->setEnabled( false );
00614     } else if ( wasMyself ) {
00615       // this was me, but is no longer, reset
00616       mStatusCombo->setCurrentItem( KCal::Attendee::NeedsAction );
00617       mRsvpButton->setChecked( true );
00618       mRsvpButton->setEnabled( true );
00619     }
00620   }
00621   a->setName( name );
00622   a->setUid( mUid );
00623   a->setEmail( email );
00624   a->setRole( Attendee::Role( mRoleCombo->currentItem() ) );
00625   a->setStatus( Attendee::PartStat( mStatusCombo->currentItem() ) );
00626   a->setRSVP( mRsvpButton->isChecked() );
00627   aItem->updateItem();
00628   if ( mFreeBusy ) mFreeBusy->updateAttendee( a );
00629 }
00630 
00631 void KOEditorDetails::setFreeBusyWidget( KOEditorFreeBusy *v )
00632 {
00633   mFreeBusy = v;
00634 }
00635 
00636 void KOEditorDetails::fillOrganizerCombo()
00637 {
00638   Q_ASSERT( mOrganizerCombo );
00639   // Get all emails from KOPrefs (coming from various places),
00640   // and insert them - removing duplicates
00641   const QStringList lst = KOPrefs::instance()->fullEmails();
00642   QStringList uniqueList;
00643   for( QStringList::ConstIterator it = lst.begin(); it != lst.end(); ++it ) {
00644     if ( uniqueList.find( *it ) == uniqueList.end() )
00645       uniqueList << *it;
00646   }
00647   mOrganizerCombo->insertStringList( uniqueList );
00648 }
00649 
00650 #include "koeditordetails.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys