akonadi
standardcontactactionmanager.cpp
00001 /* 00002 This file is part of Akonadi Contact. 00003 00004 Copyright (c) 2009 - 2010 Tobias Koenig <tokoe@kde.org> 00005 00006 This library is free software; you can redistribute it and/or modify it 00007 under the terms of the GNU Library General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or (at your 00009 option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, but WITHOUT 00012 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00013 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00014 License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to the 00018 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00019 02110-1301, USA. 00020 */ 00021 00022 #include "standardcontactactionmanager.h" 00023 00024 #include "contacteditordialog.h" 00025 #include "contactgroupeditordialog.h" 00026 00027 #include <akonadi/entitytreemodel.h> 00028 #include <akonadi/mimetypechecker.h> 00029 #include <kabc/addressee.h> 00030 #include <kabc/contactgroup.h> 00031 #include <kaction.h> 00032 #include <kactioncollection.h> 00033 #include <klocale.h> 00034 #include <kmessagebox.h> 00035 00036 #include <QtCore/QPointer> 00037 #include <QtGui/QItemSelectionModel> 00038 00039 using namespace Akonadi; 00040 00041 class StandardContactActionManager::Private 00042 { 00043 public: 00044 Private( KActionCollection *actionCollection, QWidget *parentWidget, StandardContactActionManager *parent ) 00045 : mActionCollection( actionCollection ), mParentWidget( parentWidget ), 00046 mCollectionSelectionModel( 0 ), mItemSelectionModel( 0 ), mParent( parent ) 00047 { 00048 mGenericManager = new StandardActionManager( actionCollection, parentWidget ); 00049 mParent->connect( mGenericManager, SIGNAL( actionStateUpdated() ), 00050 mParent, SIGNAL( actionStateUpdated() ) ); 00051 mGenericManager->createAllActions(); 00052 00053 mGenericManager->action( Akonadi::StandardActionManager::CreateCollection )->setText( 00054 i18n( "Add Address Book Folder..." ) ); 00055 mGenericManager->action( Akonadi::StandardActionManager::CreateCollection )->setWhatsThis( 00056 i18n( "Add a new address book folder to the currently selected address book folder." ) ); 00057 00058 mGenericManager->setActionText( Akonadi::StandardActionManager::CopyCollections, 00059 ki18np( "Copy Address Book Folder", 00060 "Copy %1 Address Book Folders" ) ); 00061 mGenericManager->action( Akonadi::StandardActionManager::CopyCollections )->setWhatsThis( 00062 i18n( "Copy the selected address book folders to the clipboard." ) ); 00063 00064 mGenericManager->setActionText( Akonadi::StandardActionManager::DeleteCollections, 00065 ki18np( "Delete Address Book Folder", 00066 "Delete %1 Address Book Folders" ) ); 00067 mGenericManager->action( Akonadi::StandardActionManager::DeleteCollections )->setWhatsThis( 00068 i18n( "Delete the selected address book folders from the address book." ) ); 00069 00070 mGenericManager->setActionText( Akonadi::StandardActionManager::SynchronizeCollections, 00071 ki18np( "Update Address Book Folder", 00072 "Update %1 Address Book Folders" ) ); 00073 mGenericManager->action( Akonadi::StandardActionManager::SynchronizeCollections )->setWhatsThis( 00074 i18n( "Update the content of the selected address book folders." ) ); 00075 00076 mGenericManager->setActionText( Akonadi::StandardActionManager::CutCollections, 00077 ki18np( "Cut Address Book Folder", 00078 "Cut %1 Address Book Folders" ) ); 00079 mGenericManager->action( Akonadi::StandardActionManager::CutCollections )->setWhatsThis( 00080 i18n( "Cut the selected address book folders from the address book." ) ); 00081 00082 mGenericManager->action( Akonadi::StandardActionManager::CollectionProperties )->setText( 00083 i18n( "Folder Properties..." ) ); 00084 mGenericManager->action( Akonadi::StandardActionManager::CollectionProperties)->setWhatsThis( 00085 i18n( "Open a dialog to edit the properties of the selected address book folder." ) ); 00086 00087 mGenericManager->setActionText( Akonadi::StandardActionManager::CopyItems, 00088 ki18np( "Copy Contact", "Copy %1 Contacts" ) ); 00089 mGenericManager->action( Akonadi::StandardActionManager::CopyItems )->setWhatsThis( 00090 i18n( "Copy the selected contacts to the clipboard." ) ); 00091 00092 mGenericManager->setActionText( Akonadi::StandardActionManager::DeleteItems, 00093 ki18np( "Delete Contact", "Delete %1 Contacts" ) ); 00094 mGenericManager->action( Akonadi::StandardActionManager::DeleteItems )->setWhatsThis( 00095 i18n( "Delete the selected contacts from the address book." ) ); 00096 00097 mGenericManager->setActionText( Akonadi::StandardActionManager::CutItems, 00098 ki18np( "Cut Contact", "Cut %1 Contacts" ) ); 00099 mGenericManager->action( Akonadi::StandardActionManager::CutItems )->setWhatsThis( 00100 i18n( "Cut the selected contacts from the address book." ) ); 00101 00102 mGenericManager->action( Akonadi::StandardActionManager::CreateResource )->setText( 00103 i18n( "Add &Address Book..." ) ); 00104 mGenericManager->action( Akonadi::StandardActionManager::CreateResource )->setWhatsThis( 00105 i18n( "Add a new address book<p>" 00106 "You will be presented with a dialog where you can select " 00107 "the type of the address book that shall be added.</p>" ) ); 00108 00109 mGenericManager->setActionText( Akonadi::StandardActionManager::DeleteResources, 00110 ki18np( "&Delete Address Book", 00111 "&Delete %1 Address Books" ) ); 00112 mGenericManager->action( Akonadi::StandardActionManager::DeleteResources )->setWhatsThis( 00113 i18n( "Delete the selected address books<p>" 00114 "The currently selected address books will be deleted, " 00115 "along with all the contacts and contact groups they contain.</p>" ) ); 00116 00117 mGenericManager->action( Akonadi::StandardActionManager::ResourceProperties )->setText( 00118 i18n( "Address Book Properties..." ) ); 00119 mGenericManager->action( Akonadi::StandardActionManager::ResourceProperties )->setWhatsThis( 00120 i18n( "Open a dialog to edit properties of the selected address book." ) ); 00121 00122 mGenericManager->setActionText( Akonadi::StandardActionManager::SynchronizeResources, 00123 ki18np( "Update Address Book", 00124 "Update %1 Address Books" ) ); 00125 00126 mGenericManager->action( Akonadi::StandardActionManager::SynchronizeResources )->setWhatsThis 00127 ( i18n( "Updates the content of all folders of the selected address books." ) ); 00128 00129 mGenericManager->setContextText( 00130 StandardActionManager::CreateCollection, StandardActionManager::DialogTitle, 00131 i18nc( "@title:window", "New Address Book Folder" ) ); 00132 00133 mGenericManager->setContextText( 00134 StandardActionManager::CreateCollection, StandardActionManager::ErrorMessageText, 00135 i18n( "Could not create address book folder: %1" ) ); 00136 00137 mGenericManager->setContextText( 00138 StandardActionManager::CreateCollection, StandardActionManager::ErrorMessageTitle, 00139 i18n( "Address book folder creation failed" ) ); 00140 00141 mGenericManager->setContextText( 00142 StandardActionManager::DeleteCollections, StandardActionManager::MessageBoxText, 00143 ki18np( "Do you really want to delete this address book folder and all its sub-folders?", 00144 "Do you really want to delete %1 address book folders and all their sub-folders?" ) ); 00145 mGenericManager->setContextText( 00146 StandardActionManager::DeleteCollections, StandardActionManager::MessageBoxTitle, 00147 ki18ncp( "@title:window", "Delete address book folder?", "Delete address book folders?" ) ); 00148 00149 mGenericManager->setContextText( 00150 StandardActionManager::DeleteCollections, StandardActionManager::ErrorMessageText, 00151 i18n( "Could not delete address book folder: %1" ) ); 00152 00153 mGenericManager->setContextText( 00154 StandardActionManager::DeleteCollections, StandardActionManager::ErrorMessageTitle, 00155 i18n( "Address book folder deletion failed" ) ); 00156 00157 mGenericManager->setContextText( 00158 StandardActionManager::CollectionProperties, StandardActionManager::DialogTitle, 00159 i18nc( "@title:window", "Properties of Address Book Folder %1" ) ); 00160 00161 mGenericManager->setContextText( 00162 StandardActionManager::DeleteItems, StandardActionManager::MessageBoxText, 00163 ki18np( "Do you really want to delete the selected contact?", 00164 "Do you really want to delete %1 contacts?" ) ); 00165 00166 mGenericManager->setContextText( 00167 StandardActionManager::DeleteItems, StandardActionManager::MessageBoxTitle, 00168 ki18ncp( "@title:window", "Delete Contact?", "Delete Contacts?" ) ); 00169 00170 mGenericManager->setContextText( 00171 StandardActionManager::DeleteItems, StandardActionManager::ErrorMessageText, 00172 i18n( "Could not delete contact: %1" ) ); 00173 00174 mGenericManager->setContextText( 00175 StandardActionManager::DeleteItems, StandardActionManager::ErrorMessageTitle, 00176 i18n( "Contact deletion failed" ) ); 00177 00178 mGenericManager->setContextText( 00179 StandardActionManager::CreateResource, StandardActionManager::DialogTitle, 00180 i18nc( "@title:window", "Add Address Book" ) ); 00181 00182 mGenericManager->setContextText( 00183 StandardActionManager::CreateResource, StandardActionManager::ErrorMessageText, 00184 i18n( "Could not create address book: %1" ) ); 00185 00186 mGenericManager->setContextText( 00187 StandardActionManager::CreateResource, StandardActionManager::ErrorMessageTitle, 00188 i18n( "Address book creation failed" ) ); 00189 00190 mGenericManager->setContextText( 00191 StandardActionManager::DeleteResources, StandardActionManager::MessageBoxText, 00192 ki18np( "Do you really want to delete this address book?", 00193 "Do you really want to delete %1 address books?" ) ); 00194 00195 mGenericManager->setContextText( 00196 StandardActionManager::DeleteResources, StandardActionManager::MessageBoxTitle, 00197 ki18ncp( "@title:window", "Delete Address Book?", "Delete Address Books?" ) ); 00198 00199 mGenericManager->setContextText( 00200 StandardActionManager::Paste, StandardActionManager::ErrorMessageText, 00201 i18n( "Could not paste contact: %1" ) ); 00202 00203 mGenericManager->setContextText( 00204 StandardActionManager::Paste, StandardActionManager::ErrorMessageTitle, 00205 i18n( "Paste failed" ) ); 00206 00207 mGenericManager->setMimeTypeFilter( 00208 QStringList() << KABC::Addressee::mimeType() << KABC::ContactGroup::mimeType() ); 00209 00210 mGenericManager->setCapabilityFilter( QStringList() << QLatin1String( "Resource" ) ); 00211 } 00212 00213 ~Private() 00214 { 00215 delete mGenericManager; 00216 } 00217 00218 static bool hasWritableCollection( const QModelIndex &index, const QString &mimeType ) 00219 { 00220 const Akonadi::Collection collection = 00221 index.data( Akonadi::EntityTreeModel::CollectionRole ).value<Akonadi::Collection>(); 00222 if ( collection.isValid() ) { 00223 if ( collection.contentMimeTypes().contains( mimeType ) && 00224 ( collection.rights() & Akonadi::Collection::CanCreateItem ) ) { 00225 return true; 00226 } 00227 } 00228 00229 const QAbstractItemModel *model = index.model(); 00230 if ( !model ) 00231 return false; 00232 00233 for ( int row = 0; row < model->rowCount( index ); ++row ) { 00234 if ( hasWritableCollection( model->index( row, 0, index ), mimeType ) ) 00235 return true; 00236 } 00237 00238 return false; 00239 } 00240 00241 bool hasWritableCollection( const QString &mimeType ) const 00242 { 00243 if ( !mCollectionSelectionModel ) 00244 return false; 00245 00246 const QAbstractItemModel *collectionModel = mCollectionSelectionModel->model(); 00247 for ( int row = 0; row < collectionModel->rowCount(); ++row ) { 00248 if ( hasWritableCollection( collectionModel->index( row, 0, QModelIndex() ), mimeType ) ) 00249 return true; 00250 } 00251 00252 return false; 00253 } 00254 00255 void updateActions() 00256 { 00257 int itemCount = 0; 00258 if ( mItemSelectionModel ) { 00259 itemCount = mItemSelectionModel->selectedRows().count(); 00260 if ( itemCount == 1 ) { 00261 const QModelIndex index = mItemSelectionModel->selectedRows().first(); 00262 if ( index.isValid() ) { 00263 const QString mimeType = index.data( EntityTreeModel::MimeTypeRole ).toString(); 00264 if ( mimeType == KABC::Addressee::mimeType() ) { 00265 mGenericManager->setActionText( Akonadi::StandardActionManager::CopyItems, 00266 ki18np( "Copy Contact", "Copy %1 Contacts" ) ); 00267 mGenericManager->action( Akonadi::StandardActionManager::CopyItemToMenu )->setText( i18n( "Copy Contact To" ) ); 00268 mGenericManager->action( Akonadi::StandardActionManager::CopyItemToDialog )->setText( i18n( "Copy Contact To" ) ); 00269 mGenericManager->setActionText( Akonadi::StandardActionManager::DeleteItems, 00270 ki18np( "Delete Contact", "Delete %1 Contacts" ) ); 00271 mGenericManager->setActionText( Akonadi::StandardActionManager::CutItems, 00272 ki18np( "Cut Contact", "Cut %1 Contacts" ) ); 00273 mGenericManager->action( Akonadi::StandardActionManager::MoveItemToMenu )->setText( i18n( "Move Contact To" ) ); 00274 mGenericManager->action( Akonadi::StandardActionManager::MoveItemToDialog )->setText( i18n( "Move Contact To" ) ); 00275 if ( mActions.contains( StandardContactActionManager::EditItem ) ) 00276 mActions.value( StandardContactActionManager::EditItem )->setText( i18n( "Edit Contact..." ) ); 00277 } else if ( mimeType == KABC::ContactGroup::mimeType() ) { 00278 mGenericManager->setActionText( Akonadi::StandardActionManager::CopyItems, 00279 ki18np( "Copy Group", "Copy %1 Groups" ) ); 00280 mGenericManager->action( Akonadi::StandardActionManager::CopyItemToMenu )->setText( i18n( "Copy Group To" ) ); 00281 mGenericManager->action( Akonadi::StandardActionManager::CopyItemToDialog )->setText( i18n( "Copy Group To" ) ); 00282 mGenericManager->setActionText( Akonadi::StandardActionManager::DeleteItems, 00283 ki18np( "Delete Group", "Delete %1 Groups" ) ); 00284 mGenericManager->setActionText( Akonadi::StandardActionManager::CutItems, 00285 ki18np( "Cut Group", "Cut %1 Groups" ) ); 00286 mGenericManager->action( Akonadi::StandardActionManager::MoveItemToMenu )->setText( i18n( "Move Group To" ) ); 00287 mGenericManager->action( Akonadi::StandardActionManager::MoveItemToDialog )->setText( i18n( "Move Group To" ) ); 00288 if ( mActions.contains( StandardContactActionManager::EditItem ) ) 00289 mActions.value( StandardContactActionManager::EditItem )->setText( i18n( "Edit Group..." ) ); 00290 } 00291 } 00292 } 00293 } 00294 00295 if ( mActions.contains( StandardContactActionManager::CreateContact ) ) 00296 mActions[ StandardContactActionManager::CreateContact ]->setEnabled( hasWritableCollection( KABC::Addressee::mimeType() ) ); 00297 if ( mActions.contains( StandardContactActionManager::CreateContactGroup ) ) 00298 mActions[ StandardContactActionManager::CreateContactGroup ]->setEnabled( hasWritableCollection( KABC::ContactGroup::mimeType() ) ); 00299 00300 if ( mActions.contains( StandardContactActionManager::EditItem ) ) { 00301 bool canEditItem = true; 00302 00303 // only one selected item can be edited 00304 canEditItem = canEditItem && (itemCount == 1); 00305 00306 // check whether parent collection allows changing the item 00307 const QModelIndexList rows = mItemSelectionModel->selectedRows(); 00308 if ( rows.count() == 1 ) { 00309 const QModelIndex index = rows.first(); 00310 const Collection parentCollection = index.data( EntityTreeModel::ParentCollectionRole ).value<Collection>(); 00311 if ( parentCollection.isValid() ) 00312 canEditItem = canEditItem && (parentCollection.rights() & Collection::CanChangeItem); 00313 } 00314 00315 mActions.value( StandardContactActionManager::EditItem )->setEnabled( canEditItem ); 00316 } 00317 00318 emit mParent->actionStateUpdated(); 00319 } 00320 00321 Collection selectedCollection() const 00322 { 00323 if ( !mCollectionSelectionModel ) 00324 return Collection(); 00325 00326 if ( mCollectionSelectionModel->selectedIndexes().isEmpty() ) 00327 return Collection(); 00328 00329 const QModelIndex index = mCollectionSelectionModel->selectedIndexes().first(); 00330 if ( !index.isValid() ) 00331 return Collection(); 00332 00333 return index.data( EntityTreeModel::CollectionRole).value<Collection>(); 00334 } 00335 00336 void slotCreateContact() 00337 { 00338 if ( mInterceptedActions.contains( StandardContactActionManager::CreateContact ) ) 00339 return; 00340 00341 Akonadi::ContactEditorDialog dlg( Akonadi::ContactEditorDialog::CreateMode, mParentWidget ); 00342 dlg.setDefaultAddressBook( selectedCollection() ); 00343 00344 dlg.exec(); 00345 } 00346 00347 void slotCreateContactGroup() 00348 { 00349 if ( mInterceptedActions.contains( StandardContactActionManager::CreateContactGroup ) ) 00350 return; 00351 00352 Akonadi::ContactGroupEditorDialog dlg( Akonadi::ContactGroupEditorDialog::CreateMode, mParentWidget ); 00353 dlg.setDefaultAddressBook( selectedCollection() ); 00354 00355 dlg.exec(); 00356 } 00357 00358 void slotEditItem() 00359 { 00360 if ( mInterceptedActions.contains( StandardContactActionManager::EditItem ) ) 00361 return; 00362 00363 if ( !mItemSelectionModel ) 00364 return; 00365 00366 if ( mItemSelectionModel->selectedIndexes().isEmpty() ) 00367 return; 00368 00369 const QModelIndex index = mItemSelectionModel->selectedIndexes().first(); 00370 if ( !index.isValid() ) 00371 return; 00372 00373 const Item item = index.data( EntityTreeModel::ItemRole ).value<Item>(); 00374 if ( !item.isValid() ) 00375 return; 00376 00377 if ( Akonadi::MimeTypeChecker::isWantedItem( item, KABC::Addressee::mimeType() ) ) { 00378 Akonadi::ContactEditorDialog dlg( Akonadi::ContactEditorDialog::EditMode, mParentWidget ); 00379 dlg.setContact( item ); 00380 dlg.exec(); 00381 } 00382 else if ( Akonadi::MimeTypeChecker::isWantedItem( item, KABC::ContactGroup::mimeType() ) ) { 00383 Akonadi::ContactGroupEditorDialog dlg( Akonadi::ContactGroupEditorDialog::EditMode, mParentWidget ); 00384 dlg.setContactGroup( item ); 00385 dlg.exec(); 00386 } 00387 } 00388 00389 KActionCollection *mActionCollection; 00390 QWidget *mParentWidget; 00391 StandardActionManager *mGenericManager; 00392 QItemSelectionModel *mCollectionSelectionModel; 00393 QItemSelectionModel *mItemSelectionModel; 00394 QHash<StandardContactActionManager::Type, KAction*> mActions; 00395 QSet<StandardContactActionManager::Type> mInterceptedActions; 00396 StandardContactActionManager *mParent; 00397 }; 00398 00399 StandardContactActionManager::StandardContactActionManager( KActionCollection *actionCollection, QWidget *parent ) 00400 : QObject( parent ), d( new Private( actionCollection, parent, this ) ) 00401 { 00402 } 00403 00404 StandardContactActionManager::~StandardContactActionManager() 00405 { 00406 delete d; 00407 } 00408 00409 void StandardContactActionManager::setCollectionSelectionModel( QItemSelectionModel *selectionModel ) 00410 { 00411 d->mCollectionSelectionModel = selectionModel; 00412 d->mGenericManager->setCollectionSelectionModel( selectionModel ); 00413 00414 connect( selectionModel->model(), SIGNAL( rowsInserted( const QModelIndex&, int, int ) ), 00415 SLOT( updateActions() ) ); 00416 connect( selectionModel->model(), SIGNAL( rowsRemoved( const QModelIndex&, int, int ) ), 00417 SLOT( updateActions() ) ); 00418 connect( selectionModel, SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), 00419 SLOT( updateActions() ) ); 00420 00421 d->updateActions(); 00422 } 00423 00424 void StandardContactActionManager::setItemSelectionModel( QItemSelectionModel* selectionModel ) 00425 { 00426 d->mItemSelectionModel = selectionModel; 00427 d->mGenericManager->setItemSelectionModel( selectionModel ); 00428 00429 connect( selectionModel, SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), 00430 SLOT( updateActions() ) ); 00431 00432 d->updateActions(); 00433 } 00434 00435 KAction* StandardContactActionManager::createAction( Type type ) 00436 { 00437 if ( d->mActions.contains( type ) ) 00438 return d->mActions.value( type ); 00439 00440 KAction *action = 0; 00441 00442 switch ( type ) { 00443 case CreateContact: 00444 action = new KAction( d->mParentWidget ); 00445 action->setIcon( KIcon( QLatin1String( "contact-new" ) ) ); 00446 action->setText( i18n( "New &Contact..." ) ); 00447 action->setShortcut( QKeySequence( Qt::CTRL + Qt::Key_N ) ); 00448 action->setWhatsThis( i18n( "Create a new contact<p>You will be presented with a dialog where you can add data about a person, including addresses and phone numbers.</p>" ) ); 00449 d->mActions.insert( CreateContact, action ); 00450 d->mActionCollection->addAction( QString::fromLatin1( "akonadi_contact_create" ), action ); 00451 connect( action, SIGNAL( triggered( bool ) ), this, SLOT( slotCreateContact() ) ); 00452 break; 00453 case CreateContactGroup: 00454 action = new KAction( d->mParentWidget ); 00455 action->setIcon( KIcon( QLatin1String( "user-group-new" ) ) ); 00456 action->setText( i18n( "New &Group..." ) ); 00457 action->setShortcut( QKeySequence( Qt::CTRL + Qt::Key_G ) ); 00458 action->setWhatsThis( i18n( "Create a new group<p>You will be presented with a dialog where you can add a new group of contacts.</p>" ) ); 00459 d->mActions.insert( CreateContactGroup, action ); 00460 d->mActionCollection->addAction( QString::fromLatin1( "akonadi_contact_group_create" ), action ); 00461 connect( action, SIGNAL( triggered( bool ) ), this, SLOT( slotCreateContactGroup() ) ); 00462 break; 00463 case EditItem: 00464 action = new KAction( d->mParentWidget ); 00465 action->setIcon( KIcon( QLatin1String( "document-edit" ) ) ); 00466 action->setText( i18n( "Edit Contact..." ) ); 00467 action->setWhatsThis( i18n( "Edit the selected contact<p>You will be presented with a dialog where you can edit the data stored about a person, including addresses and phone numbers.</p>" ) ); 00468 action->setEnabled( false ); 00469 d->mActions.insert( EditItem, action ); 00470 d->mActionCollection->addAction( QString::fromLatin1( "akonadi_contact_item_edit" ), action ); 00471 connect( action, SIGNAL( triggered( bool ) ), this, SLOT( slotEditItem() ) ); 00472 break; 00473 default: 00474 Q_ASSERT( false ); // should never happen 00475 break; 00476 } 00477 00478 return action; 00479 } 00480 00481 KAction* StandardContactActionManager::createAction( StandardActionManager::Type type ) 00482 { 00483 return d->mGenericManager->createAction( type ); 00484 } 00485 00486 void StandardContactActionManager::createAllActions() 00487 { 00488 createAction( CreateContact ); 00489 createAction( CreateContactGroup ); 00490 createAction( EditItem ); 00491 00492 d->mGenericManager->createAllActions(); 00493 00494 d->updateActions(); 00495 } 00496 00497 KAction* StandardContactActionManager::action( Type type ) const 00498 { 00499 if ( d->mActions.contains( type ) ) 00500 return d->mActions.value( type ); 00501 00502 return 0; 00503 } 00504 00505 KAction* StandardContactActionManager::action( StandardActionManager::Type type ) const 00506 { 00507 return d->mGenericManager->action( type ); 00508 } 00509 00510 void StandardContactActionManager::setActionText( StandardActionManager::Type type, const KLocalizedString &text ) 00511 { 00512 d->mGenericManager->setActionText( type, text ); 00513 } 00514 00515 void StandardContactActionManager::interceptAction( Type type, bool intercept ) 00516 { 00517 if ( intercept ) 00518 d->mInterceptedActions.insert( type ); 00519 else 00520 d->mInterceptedActions.remove( type ); 00521 } 00522 00523 void StandardContactActionManager::interceptAction( StandardActionManager::Type type, bool intercept ) 00524 { 00525 d->mGenericManager->interceptAction( type, intercept ); 00526 } 00527 00528 Akonadi::Collection::List StandardContactActionManager::selectedCollections() const 00529 { 00530 return d->mGenericManager->selectedCollections(); 00531 } 00532 00533 Akonadi::Item::List StandardContactActionManager::selectedItems() const 00534 { 00535 return d->mGenericManager->selectedItems(); 00536 } 00537 00538 #include "standardcontactactionmanager.moc"