From kde-commits Tue Jun 30 22:56:45 2009 From: Sebastian Sauer Date: Tue, 30 Jun 2009 22:56:45 +0000 To: kde-commits Subject: branches/work/akonadi-ports/kdepim/korganizer Message-Id: <1246402605.272753.31468.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=124653891819667 SVN commit 989781 by sebsauer: impl 'delete calendar' M +38 -21 akonadicollectionview.cpp M +2 -1 akonadicollectionview.h --- branches/work/akonadi-ports/kdepim/korganizer/akonadicollectionview.cpp #989780:989781 @@ -66,6 +66,7 @@ #include #include #include +#include #include #include #include @@ -366,7 +367,7 @@ mActionManager->setCollectionSelectionModel( mCollectionview->selectionModel() ); KAction *createAction = new KAction( mCollectionview ); - createAction->setIcon( KIcon( "calendar-new" ) ); + createAction->setIcon( KIcon( "new" ) ); createAction->setText( i18n( "New Calendar..." ) ); //action->setWhatsThis( i18n( "Create a new contact

You will be presented with a dialog where you can add all data about a person, including addresses and phone numbers.

" ) ); xmlclient->actionCollection()->addAction( QString::fromLatin1( "akonadi_calendar_create" ), createAction ); @@ -430,18 +431,18 @@ if ( agentType.isValid() ) { Akonadi::AgentInstanceCreateJob *job = new Akonadi::AgentInstanceCreateJob( agentType, this ); job->configure( this ); - connect( job, SIGNAL( result( KJob* ) ), this, SLOT( newCalendarResult( KJob* ) ) ); + connect( job, SIGNAL( result( KJob* ) ), this, SLOT( newCalendarDone( KJob* ) ) ); job->start(); } } } -void AkonadiCollectionView::newCalendarResult( KJob *job ) +void AkonadiCollectionView::newCalendarDone( KJob *job ) { kDebug(); Akonadi::AgentInstanceCreateJob *createjob = static_cast( job ); - if ( job->error() ) { - kWarning( 5250 ) << "Add calendar failed:" << job->errorString(); + if ( createjob->error() ) { + kWarning( 5250 ) << "Create calendar failed:" << createjob->errorString(); return; } //TODO @@ -450,25 +451,41 @@ void AkonadiCollectionView::deleteCalendar() { kDebug(); - //TODO - /* - const AgentInstance agent = ui.instanceWidget->currentAgentInstance(); - if ( agent.isValid() ) { - if ( KMessageBox::questionYesNo( this, - i18n( "Do you really want to delete agent instance %1?", agent.name() ), - i18n( "Agent Deletion" ), - KStandardGuiItem::del(), - KStandardGuiItem::cancel(), - QString(), - KMessageBox::Dangerous ) - == KMessageBox::Yes ) - { - AgentManager::self()->removeInstance( agent ); - } + + QModelIndex index = mCollectionview->selectionModel()->currentIndex(); //selectedRows() + Q_ASSERT( index.isValid() ); + const Akonadi::Collection collection = index.model()->data( index, Akonadi::CollectionModel::CollectionRole ).value(); + Q_ASSERT( collection.isValid() ); + //Q_ASSERT( mCollectionview->selectionModel()->isSelected(index) ); + + QString displayname = index.model()->data( index, Qt::DisplayRole ).value(); + Q_ASSERT( ! displayname.isEmpty() ); + + if( KMessageBox::questionYesNo( this, + i18n( "Do you really want to delete calendar %1?", displayname ), + i18n( "Delete Calendar" ), + KStandardGuiItem::del(), + KStandardGuiItem::cancel(), + QString(), + KMessageBox::Dangerous ) + == KMessageBox::Yes ) + { + Akonadi::CollectionDeleteJob *job = new Akonadi::CollectionDeleteJob( collection /* , m_session */ ); + connect( job, SIGNAL( result( KJob* ) ), this, SLOT( deleteCalendarDone( KJob* ) ) ); } - */ } +void AkonadiCollectionView::deleteCalendarDone( KJob *job ) +{ + kDebug(); + Akonadi::CollectionDeleteJob *createjob = static_cast( job ); + if ( createjob->error() ) { + kWarning( 5250 ) << "Delete calendar failed:" << createjob->errorString(); + return; + } + //TODO +} + #if 0 void AkonadiCollectionView::emitResourcesChanged() { --- branches/work/akonadi-ports/kdepim/korganizer/akonadicollectionview.h #989780:989781 @@ -161,9 +161,10 @@ void collectionClicked(const QModelIndex&); void newCalendar(); - void newCalendarResult( KJob* ); + void newCalendarDone( KJob* ); void deleteCalendar(); + void deleteCalendarDone( KJob* ); #endif private: