From cc29364f06178f8f6b457384f2ec37a042bd9d43 Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 1 Sep 2010 00:37:02 +0000 Subject: * Massive set of changes to bring in all fixes and enhancements from the Enterprise PIM branch * Ensured that the Trinity changes were applied on top of those enhancements, and any redundancy removed * Added journal read support to the CalDAV resource * Fixed CalDAV resource to use events URL for tasks and journals when separate URL checkbox unchecked git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1170461 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- korganizer/koeditordetails.cpp | 87 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 72 insertions(+), 15 deletions(-) (limited to 'korganizer/koeditordetails.cpp') diff --git a/korganizer/koeditordetails.cpp b/korganizer/koeditordetails.cpp index 0b8c6159f..a882363da 100644 --- a/korganizer/koeditordetails.cpp +++ b/korganizer/koeditordetails.cpp @@ -72,7 +72,8 @@ template <> CustomListViewItem::~CustomListViewItem() { - delete mData; + // do not delete mData here +// delete mData; } template <> @@ -152,18 +153,15 @@ void KOAttendeeListView::dropEvent( TQDropEvent *e ) { #ifndef KORG_NODND TQString text; - TQString vcards; #ifndef KORG_NOKABC - if ( KVCardDrag::decode( e, vcards ) ) { - KABC::VCardConverter converter; - - KABC::Addressee::List list = converter.parseVCards( vcards ); + KABC::Addressee::List list; + if ( KVCardDrag::decode( e, list ) ) { KABC::Addressee::List::Iterator it; for ( it = list.begin(); it != list.end(); ++it ) { TQString em( (*it).fullEmail() ); - if (em.isEmpty()) { - em=(*it).realName(); + if ( em.isEmpty() ) { + em = (*it).realName(); } addAttendee( em ); } @@ -240,13 +238,22 @@ void KOEditorDetails::removeAttendee() static_cast( mListView->selectedItem() ); if ( !aItem ) return; - Attendee *delA = new Attendee( aItem->data()->name(), aItem->data()->email(), - aItem->data()->RSVP(), aItem->data()->status(), - aItem->data()->role(), aItem->data()->uid() ); - mdelAttendees.append( delA ); + AttendeeListItem *nextSelectedItem = static_cast( aItem->nextSibling() ); + if( mListView->childCount() == 1 ) + nextSelectedItem = 0; + if( mListView->childCount() > 1 && aItem == mListView->lastItem() ) + nextSelectedItem = static_cast( mListView->firstChild() ); + Attendee *attendee = aItem->data(); + Attendee *delA = new Attendee( attendee->name(), attendee->email(), + attendee->RSVP(), attendee->status(), + attendee->role(), attendee->uid() ); + mdelAttendees.append( delA ); delete aItem; + if( nextSelectedItem ) { + mListView->setSelected( nextSelectedItem, true ); + } updateAttendeeInput(); emit updateAttendeeSummary( mListView->childCount() ); } @@ -257,12 +264,25 @@ void KOEditorDetails::insertAttendee( Attendee *a, bool goodEmailAddress ) Q_UNUSED( goodEmailAddress ); // lastItem() is O(n), but for n very small that should be fine - AttendeeListItem *item = new AttendeeListItem( a, mListView, - static_cast( mListView->lastItem() ) ); + AttendeeListItem *item = new AttendeeListItem( + a, mListView, static_cast( mListView->lastItem() ) ); mListView->setSelected( item, true ); emit updateAttendeeSummary( mListView->childCount() ); } +void KOEditorDetails::removeAttendee( Attendee *attendee ) +{ + TQListViewItem *item; + for ( item = mListView->firstChild(); item; item = item->nextSibling() ) { + AttendeeListItem *anItem = static_cast( item ); + Attendee *att = anItem->data(); + if ( att == attendee ) { + delete anItem; + break; + } + } +} + void KOEditorDetails::setDefaults() { mRsvpButton->setChecked( true ); @@ -350,9 +370,34 @@ void KOEditorDetails::updateCurrentItem() item->updateItem(); } -void KOEditorDetails::slotInsertAttendee(Attendee * a) +void KOEditorDetails::slotInsertAttendee( Attendee *a ) { insertAttendee( a ); + mnewAttendees.append( a ); +} + +void KOEditorDetails::setSelected( int index ) +{ + int count = 0; + for ( TQListViewItemIterator it( mListView ); it.current(); ++it ) { + if ( count == index ) { + mListView->setSelected( *it, true ); + return; + } + count++; + } +} + +int KOEditorDetails::selectedIndex() +{ + int index = 0; + for ( TQListViewItemIterator it( mListView ); it.current(); ++it ) { + if ( mListView->isSelected( *it ) ) { + break; + } + index++; + } + return index; } void KOEditorDetails::changeStatusForMe(Attendee::PartStat status) @@ -369,4 +414,16 @@ void KOEditorDetails::changeStatusForMe(Attendee::PartStat status) } } +TQListViewItem* KOEditorDetails::hasExampleAttendee() const +{ + for ( TQListViewItemIterator it( mListView ); it.current(); ++it ) { + AttendeeListItem *item = static_cast( it.current() ); + Attendee *attendee = item->data(); + Q_ASSERT( attendee ); + if ( isExampleAttendee( attendee ) ) + return item; + } + return 0; +} + #include "koeditordetails.moc" -- cgit v1.2.1