26 #include "koeditordetails.h"
28 #include <tqbuttongroup.h>
29 #include <tqcheckbox.h>
30 #include <tqcombobox.h>
31 #include <tqdatetime.h>
32 #include <tqdragobject.h>
33 #include <tqfiledialog.h>
34 #include <tqgroupbox.h>
37 #include <tqlineedit.h>
38 #include <tqpushbutton.h>
39 #include <tqradiobutton.h>
41 #include <tqtooltip.h>
43 #include <tqvgroupbox.h>
44 #include <tqwhatsthis.h>
45 #include <tqwidgetstack.h>
46 #include <tqvaluevector.h>
49 #include <tdelocale.h>
50 #include <kiconloader.h>
51 #include <tdemessagebox.h>
53 #include <tdeabc/addresseedialog.h>
54 #include <tdeabc/vcardconverter.h>
55 #include <libtdepim/addressesdialog.h>
56 #include <libtdepim/addresseelineedit.h>
57 #include <libtdepim/distributionlist.h>
58 #include <tdeabc/stdaddressbook.h>
60 #include <libtdepim/kvcarddrag.h>
61 #include <libemailfunctions/email.h>
63 #include <libkcal/incidence.h>
66 #include "koglobals.h"
68 #include "koeditorfreebusy.h"
73 CustomListViewItem<KCal::Attendee *>::~CustomListViewItem()
80 void CustomListViewItem<KCal::Attendee *>::updateItem()
82 setText(0,mData->name());
83 setText(1,mData->email());
84 setText(2,mData->roleStr());
85 setText(3,mData->statusStr());
86 if (mData->RSVP() && !mData->email().isEmpty())
87 setPixmap(4,KOGlobals::self()->smallIcon(
"mailappt"));
89 setPixmap(4,KOGlobals::self()->smallIcon(
"nomailappt"));
90 setText(5, mData->delegate());
91 setText(6, mData->delegator());
94 KOAttendeeListView::KOAttendeeListView ( TQWidget *parent,
const char *name )
95 : TDEListView(parent, name)
97 setAcceptDrops(
true );
98 setAllColumnsShowFocus(
true );
111 void KOAttendeeListView::contentsDragEnterEvent( TQDragEnterEvent *e )
116 void KOAttendeeListView::contentsDragMoveEvent( TQDragMoveEvent *e )
119 if ( KVCardDrag::canDecode( e ) || TQTextDrag::canDecode( e ) ) {
127 void KOAttendeeListView::dragEnterEvent( TQDragEnterEvent *e )
130 if ( KVCardDrag::canDecode( e ) || TQTextDrag::canDecode( e ) ) {
138 void KOAttendeeListView::addAttendee(
const TQString &newAttendee )
140 kdDebug(5850) <<
" Email: " << newAttendee << endl;
143 KPIM::getNameAndMail( newAttendee, name, email );
144 emit dropped(
new Attendee( name, email,
true ) );
147 void KOAttendeeListView::contentsDropEvent( TQDropEvent *e )
152 void KOAttendeeListView::dropEvent( TQDropEvent *e )
158 TDEABC::Addressee::List list;
159 if ( KVCardDrag::decode( e, list ) ) {
160 TDEABC::Addressee::List::Iterator it;
161 for ( it = list.begin(); it != list.end(); ++it ) {
162 TQString em( (*it).fullEmail() );
163 if ( em.isEmpty() ) {
164 em = (*it).realName();
170 if (TQTextDrag::decode(e,text)) {
171 kdDebug(5850) <<
"Dropped : " << text << endl;
172 TQStringList emails = TQStringList::split(
",",text);
173 for(TQStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
181 KOEditorDetails::KOEditorDetails(
int spacing, TQWidget *parent,
185 TQBoxLayout *topLayout =
new TQVBoxLayout(
this );
186 topLayout->setSpacing( spacing );
188 initOrganizerWidgets(
this, topLayout );
191 TQWhatsThis::add( mListView,
192 i18n(
"Displays information about current attendees. "
193 "To edit an attendee, select it in this list "
194 "and modify the values in the area below. "
195 "Clicking on a column title will sort the list "
196 "according to that column. The RSVP column "
197 "indicates whether or not a response is requested "
198 "from the attendee.") );
199 mListView->addColumn( i18n(
"Name"), 200 );
200 mListView->addColumn( i18n(
"Email"), 200 );
201 mListView->addColumn( i18n(
"Role"), 80 );
202 mListView->addColumn( i18n(
"Status"), 100 );
203 mListView->addColumn( i18n(
"RSVP"), 55 );
204 mListView->addColumn( i18n(
"Delegated to"), 120 );
205 mListView->addColumn( i18n(
"Delegated from" ), 120 );
206 mListView->setResizeMode( TQListView::LastColumn );
207 if ( KOPrefs::instance()->mCompactDialogs ) {
208 mListView->setFixedHeight( 78 );
211 connect( mListView, TQ_SIGNAL( selectionChanged( TQListViewItem * ) ),
212 TQ_SLOT( updateAttendeeInput() ) );
214 connect( mListView, TQ_SIGNAL( dropped(
Attendee * ) ),
215 TQ_SLOT( slotInsertAttendee(
Attendee * ) ) );
217 topLayout->addWidget( mListView );
219 initEditWidgets(
this, topLayout );
221 connect( mRemoveButton, TQ_SIGNAL(clicked()), TQ_SLOT(removeAttendee()) );
223 updateAttendeeInput();
226 KOEditorDetails::~KOEditorDetails()
230 bool KOEditorDetails::hasAttendees()
232 return mListView->childCount() > 0;
235 void KOEditorDetails::removeAttendee()
237 AttendeeListItem *aItem =
238 static_cast<AttendeeListItem *
>( mListView->selectedItem() );
239 if ( !aItem )
return;
241 AttendeeListItem *nextSelectedItem =
static_cast<AttendeeListItem*
>( aItem->nextSibling() );
242 if( mListView->childCount() == 1 )
243 nextSelectedItem = 0;
244 if( mListView->childCount() > 1 && aItem == mListView->lastItem() )
245 nextSelectedItem =
static_cast<AttendeeListItem*
>( mListView->firstChild() );
250 attendee->
role(), attendee->
uid() );
251 mdelAttendees.append( delA );
254 if( nextSelectedItem ) {
255 mListView->setSelected( nextSelectedItem,
true );
257 updateAttendeeInput();
258 emit updateAttendeeSummary( mListView->childCount() );
262 void KOEditorDetails::insertAttendee(
Attendee *a,
bool goodEmailAddress )
264 Q_UNUSED( goodEmailAddress );
267 AttendeeListItem *item =
new AttendeeListItem(
268 a, mListView,
static_cast<TDEListViewItem*
>( mListView->lastItem() ) );
269 mListView->setSelected( item,
true );
270 emit updateAttendeeSummary( mListView->childCount() );
273 void KOEditorDetails::removeAttendee(
Attendee *attendee )
275 TQListViewItem *item;
276 for ( item = mListView->firstChild(); item; item = item->nextSibling() ) {
277 AttendeeListItem *anItem =
static_cast<AttendeeListItem *
>( item );
279 if ( att == attendee ) {
286 void KOEditorDetails::setDefaults()
288 mRsvpButton->setChecked(
true );
291 void KOEditorDetails::readEvent(
Incidence *event )
294 KOAttendeeEditor::readEvent( event );
296 mListView->setSelected( mListView->firstChild(),
true );
298 emit updateAttendeeSummary( mListView->childCount() );
301 void KOEditorDetails::writeEvent(
Incidence *event)
303 event->clearAttendees();
304 TQValueVector<TQListViewItem*> toBeDeleted;
305 TQListViewItem *item;
307 for (item = mListView->firstChild(); item;
308 item = item->nextSibling()) {
309 a = (AttendeeListItem *)item;
311 Q_ASSERT( attendee );
313 if ( attendee->email().isEmpty() ) {
314 KPIM::DistributionList list =
315 KPIM::DistributionList::findByName( TDEABC::StdAddressBook::self(), attendee->name() );
316 if ( !list.isEmpty() ) {
317 toBeDeleted.push_back( item );
318 KPIM::DistributionList::Entry::List entries = list.entries( TDEABC::StdAddressBook::self() );
319 KPIM::DistributionList::Entry::List::Iterator it( entries.begin() );
320 while ( it != entries.end() ) {
321 KPIM::DistributionList::Entry &e = ( *it );
324 insertAttendeeFromAddressee( e.addressee, attendee );
330 if ( attendee->email().endsWith(
"example.net" ) ) {
331 if ( KMessageBox::warningYesNo(
this, i18n(
"%1 does not look like a valid email address. "
332 "Are you sure you want to invite this participant?").arg( attendee->email() ),
333 i18n(
"Invalid email address") ) != KMessageBox::Yes ) {
338 event->addAttendee(
new Attendee( *attendee ) );
343 KOAttendeeEditor::writeEvent( event );
346 TQValueVector<TQListViewItem*>::iterator it;
347 for( it = toBeDeleted.begin(); it != toBeDeleted.end(); ++it ) {
352 bool KOEditorDetails::validateInput()
359 TQListViewItem *item = mListView->selectedItem();
360 AttendeeListItem *aItem =
static_cast<AttendeeListItem *
>( item );
363 return aItem->data();
366 void KOEditorDetails::updateCurrentItem()
368 AttendeeListItem *item =
static_cast<AttendeeListItem*
>( mListView->selectedItem() );
373 void KOEditorDetails::slotInsertAttendee(
Attendee *a )
376 mnewAttendees.append( a );
379 void KOEditorDetails::setSelected(
int index )
382 for ( TQListViewItemIterator it( mListView ); it.current(); ++it ) {
383 if ( count == index ) {
384 mListView->setSelected( *it,
true );
391 int KOEditorDetails::selectedIndex()
394 for ( TQListViewItemIterator it( mListView ); it.current(); ++it ) {
395 if ( mListView->isSelected( *it ) ) {
403 void KOEditorDetails::changeStatusForMe(Attendee::PartStat status)
405 const TQStringList myEmails = KOPrefs::instance()->allEmails();
406 for ( TQListViewItemIterator it( mListView ); it.current(); ++it ) {
407 AttendeeListItem *item =
static_cast<AttendeeListItem*
>( it.current() );
408 for ( TQStringList::ConstIterator it2( myEmails.begin() ), end( myEmails.end() ); it2 != end; ++it2 ) {
409 if ( item->data()->email() == *it2 ) {
410 item->data()->setStatus( status );
417 TQListViewItem* KOEditorDetails::hasExampleAttendee()
const
419 for ( TQListViewItemIterator it( mListView ); it.current(); ++it ) {
420 AttendeeListItem *item =
static_cast<AttendeeListItem*
>( it.current() );
422 Q_ASSERT( attendee );
423 if ( isExampleAttendee( attendee ) )
429 #include "koeditordetails.moc"
Common base class for attendee editor and free busy view.
KOAttendeeListView is a child class of TDEListView which supports dropping of attendees (e....
virtual ~KOAttendeeListView()
KOAttendeeListView is a child class of TDEListView which supports dropping of attendees (e....