• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.8.3 API Reference
  • KDE Home
  • Contact Us
 

akonadi

standardcalendaractionmanager.cpp
00001 /*
00002  *  Copyright (C) 2010 Casey Link <unnamedrambler@gmail.com>
00003  *  Copyright (C) 2010 Klaralvdalens Datakonsult AB, a KDAB Group company <info@kdab.net>
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 "standardcalendaractionmanager.h"
00023 
00024 #include <akonadi/entitytreemodel.h>
00025 
00026 #include <kaction.h>
00027 #include <kactioncollection.h>
00028 #include <kcalcore/event.h>
00029 #include <kcalcore/journal.h>
00030 #include <kcalcore/todo.h>
00031 #include <klocale.h>
00032 
00033 #include <QtGui/QItemSelectionModel>
00034 
00035 using namespace Akonadi;
00036 
00037 class StandardCalendarActionManager::Private
00038 {
00039   public:
00040     Private( KActionCollection *actionCollection, QWidget *parentWidget, StandardCalendarActionManager *parent )
00041       : mActionCollection( actionCollection ),
00042         mParentWidget( parentWidget ),
00043         mCollectionSelectionModel( 0 ),
00044         mItemSelectionModel( 0 ),
00045         mParent( parent )
00046     {
00047       KGlobal::locale()->insertCatalog(QLatin1String("libakonadi-calendar"));
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 Calendar Folder..." ) );
00055       mGenericManager->action( Akonadi::StandardActionManager::CreateCollection )->setWhatsThis(
00056         i18n( "Add a new calendar folder to the currently selected calendar folder." ) );
00057 
00058       mGenericManager->setActionText( Akonadi::StandardActionManager::CopyCollections,
00059                                       ki18np( "Copy Calendar Folder", "Copy %1 Calendar Folders" ) );
00060       mGenericManager->action( Akonadi::StandardActionManager::CopyCollections )->setWhatsThis(
00061         i18n( "Copy the selected calendar folders to the clipboard." ) );
00062 
00063       mGenericManager->setActionText( Akonadi::StandardActionManager::DeleteCollections,
00064                                       ki18np( "Delete Calendar Folder", "Delete %1 Calendar Folders" ) );
00065       mGenericManager->action( Akonadi::StandardActionManager::DeleteCollections )->setWhatsThis(
00066         i18n( "Delete the selected calendar folders from the calendar." ) );
00067 
00068       mGenericManager->setActionText( Akonadi::StandardActionManager::SynchronizeCollections,
00069                                       ki18np( "Update Calendar Folder", "Update %1 Calendar Folders" ) );
00070       mGenericManager->action( Akonadi::StandardActionManager::SynchronizeCollections )->setWhatsThis(
00071         i18n( "Update the content of the selected calendar folders." ) );
00072 
00073       mGenericManager->setActionText( Akonadi::StandardActionManager::CutCollections,
00074                                       ki18np( "Cut Calendar Folder", "Cut %1 Calendar Folders" ) );
00075       mGenericManager->action( Akonadi::StandardActionManager::CutCollections )->setWhatsThis(
00076         i18n( "Cut the selected calendar folders from the calendar." ) );
00077 
00078       mGenericManager->action( Akonadi::StandardActionManager::CollectionProperties )->setText(
00079         i18n( "Folder Properties..." ) );
00080       mGenericManager->action( Akonadi::StandardActionManager::CollectionProperties)->setWhatsThis(
00081         i18n( "Open a dialog to edit the properties of the selected calendar folder." ) );
00082 
00083       mGenericManager->setActionText( Akonadi::StandardActionManager::CopyItems,
00084                                       ki18np( "Copy Event", "Copy %1 Events" ) );
00085       mGenericManager->action( Akonadi::StandardActionManager::CopyItems )->setWhatsThis(
00086         i18n( "Copy the selected events to the clipboard." ) );
00087 
00088       mGenericManager->setActionText( Akonadi::StandardActionManager::DeleteItems,
00089                                       ki18np( "Delete Event", "Delete %1 Events" ) );
00090       mGenericManager->action( Akonadi::StandardActionManager::DeleteItems )->setWhatsThis(
00091         i18n( "Delete the selected events from the calendar." ) );
00092 
00093       mGenericManager->setActionText( Akonadi::StandardActionManager::CutItems,
00094                                       ki18np( "Cut Event", "Cut %1 Events" ) );
00095       mGenericManager->action( Akonadi::StandardActionManager::CutItems )->setWhatsThis(
00096         i18n( "Cut the selected events from the calendar." ) );
00097 
00098       mGenericManager->action( Akonadi::StandardActionManager::CreateResource )->setText(
00099         i18n( "Add &Calendar..." ) );
00100       mGenericManager->action( Akonadi::StandardActionManager::CreateResource )->setWhatsThis(
00101         i18n( "Add a new calendar<p>"
00102               "You will be presented with a dialog where you can select "
00103               "the type of the calendar that shall be added.</p>" ) );
00104 
00105       mGenericManager->setActionText( Akonadi::StandardActionManager::DeleteResources,
00106                                       ki18np( "&Delete Calendar", "&Delete %1 Calendars" ) );
00107       mGenericManager->action( Akonadi::StandardActionManager::DeleteResources )->setWhatsThis(
00108         i18n( "Delete the selected calendars<p>"
00109               "The currently selected calendars will be deleted, "
00110               "along with all the events, todos and journals they contain.</p>" ) );
00111 
00112       mGenericManager->action( Akonadi::StandardActionManager::ResourceProperties )->setText(
00113         i18n( "Calendar Properties..." ) );
00114       mGenericManager->action( Akonadi::StandardActionManager::ResourceProperties )->setWhatsThis(
00115         i18n( "Open a dialog to edit properties of the selected calendar." ) );
00116 
00117       mGenericManager->setActionText( Akonadi::StandardActionManager::SynchronizeResources,
00118                                       ki18np( "Update Calendar", "Update %1 Calendars" ) );
00119       mGenericManager->action( Akonadi::StandardActionManager::SynchronizeResources )->setWhatsThis(
00120         i18n( "Updates the content of all folders of the selected calendars." ) );
00121 
00122       mGenericManager->action( Akonadi::StandardActionManager::CopyItemToMenu )->setText(
00123         i18n( "&Copy to Calendar" ) );
00124       mGenericManager->action( Akonadi::StandardActionManager::CopyItemToMenu )->setWhatsThis(
00125         i18n( "Copy the selected event to a different calendar." ) );
00126 
00127       mGenericManager->action( Akonadi::StandardActionManager::MoveItemToMenu )->setText(
00128         i18n( "&Move to Calendar" ) );
00129       mGenericManager->action( Akonadi::StandardActionManager::MoveItemToMenu  )->setWhatsThis(
00130         i18n( "Move the selected event to a different calendar." ) );
00131 
00132 
00133       mGenericManager->setContextText(
00134         StandardActionManager::CreateCollection, StandardActionManager::DialogTitle,
00135         i18nc( "@title:window", "New Calendar Folder" ) );
00136 
00137       mGenericManager->setContextText(
00138         StandardActionManager::CreateCollection, StandardActionManager::ErrorMessageText,
00139         ki18n( "Could not create calendar folder: %1" ) );
00140 
00141       mGenericManager->setContextText(
00142         StandardActionManager::CreateCollection, StandardActionManager::ErrorMessageTitle,
00143         i18n( "Calendar folder creation failed" ) );
00144 
00145       mGenericManager->setContextText(
00146         StandardActionManager::DeleteCollections, StandardActionManager::MessageBoxText,
00147         ki18np( "Do you really want to delete this calendar folder and all its sub-folders?",
00148                 "Do you really want to delete %1 calendar folders and all their sub-folders?" ) );
00149 
00150       mGenericManager->setContextText(
00151         StandardActionManager::DeleteCollections, StandardActionManager::MessageBoxTitle,
00152         ki18ncp( "@title:window", "Delete calendar folder?", "Delete calendar folders?" ) );
00153 
00154       mGenericManager->setContextText(
00155         StandardActionManager::DeleteCollections, StandardActionManager::ErrorMessageText,
00156         ki18n( "Could not delete calendar folder: %1" ) );
00157 
00158       mGenericManager->setContextText(
00159         StandardActionManager::DeleteCollections, StandardActionManager::ErrorMessageTitle,
00160         i18n( "Calendar folder deletion failed" ) );
00161 
00162       mGenericManager->setContextText(
00163         StandardActionManager::CollectionProperties, StandardActionManager::DialogTitle,
00164         ki18nc( "@title:window", "Properties of Calendar Folder %1" ) );
00165 
00166       mGenericManager->setContextText(
00167         StandardActionManager::DeleteItems, StandardActionManager::MessageBoxText,
00168         ki18np( "Do you really want to delete the selected event?",
00169                 "Do you really want to delete %1 events?" ) );
00170 
00171       mGenericManager->setContextText(
00172         StandardActionManager::DeleteItems, StandardActionManager::MessageBoxTitle,
00173         ki18ncp( "@title:window", "Delete Event?", "Delete Events?" ) );
00174 
00175       mGenericManager->setContextText(
00176         StandardActionManager::DeleteItems, StandardActionManager::ErrorMessageText,
00177         ki18n( "Could not delete event: %1" ) );
00178 
00179       mGenericManager->setContextText(
00180         StandardActionManager::DeleteItems, StandardActionManager::ErrorMessageTitle,
00181         i18n( "Event deletion failed" ) );
00182 
00183       mGenericManager->setContextText(
00184         StandardActionManager::CreateResource, StandardActionManager::DialogTitle,
00185         i18nc( "@title:window", "Add Calendar" ) );
00186 
00187       mGenericManager->setContextText(
00188         StandardActionManager::CreateResource, StandardActionManager::ErrorMessageText,
00189         ki18n( "Could not create calendar: %1" ) );
00190 
00191       mGenericManager->setContextText(
00192         StandardActionManager::CreateResource, StandardActionManager::ErrorMessageTitle,
00193         i18n( "Calendar creation failed" ) );
00194 
00195       mGenericManager->setContextText(
00196         StandardActionManager::DeleteResources, StandardActionManager::MessageBoxText,
00197         ki18np( "Do you really want to delete this calendar?",
00198                 "Do you really want to delete %1 calendars?" ) );
00199 
00200       mGenericManager->setContextText(
00201         StandardActionManager::DeleteResources, StandardActionManager::MessageBoxTitle,
00202         ki18ncp( "@title:window", "Delete Calendar?", "Delete Calendars?" ) );
00203 
00204       mGenericManager->setContextText(
00205         StandardActionManager::Paste, StandardActionManager::ErrorMessageText,
00206         ki18n( "Could not paste event: %1" ) );
00207 
00208       mGenericManager->setContextText(
00209         StandardActionManager::Paste, StandardActionManager::ErrorMessageTitle,
00210         i18n( "Paste failed" ) );
00211 
00212       mGenericManager->setMimeTypeFilter( QStringList() << QLatin1String( "text/calendar" ) );
00213       mGenericManager->setCapabilityFilter( QStringList() << QLatin1String( "Resource" ) );
00214     }
00215 
00216     ~Private()
00217     {
00218       delete mGenericManager;
00219     }
00220 
00221     static bool hasWritableCollection( const QModelIndex &index, const QString &mimeType )
00222     {
00223       const Akonadi::Collection collection =
00224         index.data( Akonadi::EntityTreeModel::CollectionRole ).value<Akonadi::Collection>();
00225       if ( collection.isValid() ) {
00226         if ( collection.contentMimeTypes().contains( mimeType ) &&
00227              ( collection.rights() & Akonadi::Collection::CanCreateItem ) ) {
00228           return true;
00229         }
00230       }
00231 
00232       const QAbstractItemModel *model = index.model();
00233       if ( !model )
00234         return false;
00235 
00236       for ( int row = 0; row < model->rowCount( index ); ++row ) {
00237         if ( hasWritableCollection( model->index( row, 0, index ), mimeType ) )
00238           return true;
00239       }
00240 
00241       return false;
00242     }
00243 
00244     bool hasWritableCollection( const QString &mimeType ) const
00245     {
00246       if ( !mCollectionSelectionModel )
00247         return false;
00248 
00249       const QAbstractItemModel *collectionModel = mCollectionSelectionModel->model();
00250       for ( int row = 0; row < collectionModel->rowCount(); ++row ) {
00251         if ( hasWritableCollection( collectionModel->index( row, 0, QModelIndex() ), mimeType ) )
00252           return true;
00253       }
00254 
00255       return false;
00256     }
00257 
00258     void updateActions()
00259     {
00260       if ( !mItemSelectionModel )
00261         return;
00262 
00263       // update action labels
00264       const int itemCount = mItemSelectionModel->selectedRows().count();
00265       if ( itemCount == 1 ) {
00266         const QModelIndex index = mItemSelectionModel->selectedRows().first();
00267         if ( index.isValid() ) {
00268           const QString mimeType = index.data( EntityTreeModel::MimeTypeRole ).toString();
00269           if ( mimeType == KCalCore::Event::eventMimeType() ) {
00270             mGenericManager->setActionText( Akonadi::StandardActionManager::CopyItems,
00271                                             ki18np( "Copy Event", "Copy %1 Events" ) );
00272             mGenericManager->action( Akonadi::StandardActionManager::CopyItemToMenu )->setText( i18n( "Copy Event To" ) );
00273             mGenericManager->action( Akonadi::StandardActionManager::CopyItemToDialog )->setText( i18n( "Copy Event To" ) );
00274             mGenericManager->setActionText( Akonadi::StandardActionManager::DeleteItems,
00275                                             ki18np( "Delete Event", "Delete %1 Events" ) );
00276             mGenericManager->setActionText( Akonadi::StandardActionManager::CutItems,
00277                                             ki18np( "Cut Event", "Cut %1 Events" ) );
00278             mGenericManager->action( Akonadi::StandardActionManager::MoveItemToMenu )->setText( i18n( "Move Event To" ) );
00279             mGenericManager->action( Akonadi::StandardActionManager::MoveItemToDialog )->setText( i18n( "Move Event To" ) );
00280             if ( mActions.contains( StandardCalendarActionManager::EditIncidence ) )
00281               mActions.value( StandardCalendarActionManager::EditIncidence )->setText( i18n( "Edit Event..." ) );
00282           } else if ( mimeType == KCalCore::Todo::todoMimeType() ) {
00283             mGenericManager->setActionText( Akonadi::StandardActionManager::CopyItems,
00284                                             ki18np( "Copy To-do", "Copy %1 To-dos" ) );
00285             mGenericManager->action( Akonadi::StandardActionManager::CopyItemToMenu )->setText( i18n( "Copy To-do To" ) );
00286             mGenericManager->action( Akonadi::StandardActionManager::CopyItemToDialog )->setText( i18n( "Copy To-do To" ) );
00287             mGenericManager->setActionText( Akonadi::StandardActionManager::DeleteItems,
00288                                             ki18np( "Delete To-do", "Delete %1 To-dos" ) );
00289             mGenericManager->setActionText( Akonadi::StandardActionManager::CutItems,
00290                                             ki18np( "Cut To-do", "Cut %1 To-dos" ) );
00291             mGenericManager->action( Akonadi::StandardActionManager::MoveItemToMenu )->setText( i18n( "Move To-do To" ) );
00292             mGenericManager->action( Akonadi::StandardActionManager::MoveItemToDialog )->setText( i18n( "Move To-do To" ) );
00293             if ( mActions.contains( StandardCalendarActionManager::EditIncidence ) )
00294               mActions.value( StandardCalendarActionManager::EditIncidence )->setText( i18n( "Edit To-do..." ) );
00295           } else if ( mimeType == KCalCore::Journal::journalMimeType() ) {
00296             mGenericManager->setActionText( Akonadi::StandardActionManager::CopyItems,
00297                                             ki18np( "Copy Journal", "Copy %1 Journals" ) );
00298             mGenericManager->action( Akonadi::StandardActionManager::CopyItemToMenu )->setText( i18n( "Copy Journal To" ) );
00299             mGenericManager->action( Akonadi::StandardActionManager::CopyItemToDialog )->setText( i18n( "Copy Journal To" ) );
00300             mGenericManager->setActionText( Akonadi::StandardActionManager::DeleteItems,
00301                                             ki18np( "Delete Journal", "Delete %1 Journals" ) );
00302             mGenericManager->setActionText( Akonadi::StandardActionManager::CutItems,
00303                                             ki18np( "Cut Journal", "Cut %1 Journals" ) );
00304             mGenericManager->action( Akonadi::StandardActionManager::MoveItemToMenu )->setText( i18n( "Move Journal To" ) );
00305             mGenericManager->action( Akonadi::StandardActionManager::MoveItemToDialog )->setText( i18n( "Move Journal To" ) );
00306             if ( mActions.contains( StandardCalendarActionManager::EditIncidence ) )
00307               mActions.value( StandardCalendarActionManager::EditIncidence )->setText( i18n( "Edit Journal..." ) );
00308           }
00309         }
00310       }
00311 
00312       // update action states
00313       if ( mActions.contains( StandardCalendarActionManager::CreateEvent ) )
00314         mActions[ StandardCalendarActionManager::CreateEvent ]->setEnabled( hasWritableCollection( KCalCore::Event::eventMimeType() ) );
00315       if ( mActions.contains( StandardCalendarActionManager::CreateTodo ) )
00316         mActions[ StandardCalendarActionManager::CreateTodo ]->setEnabled( hasWritableCollection( KCalCore::Todo::todoMimeType() ) );
00317       if ( mActions.contains( StandardCalendarActionManager::CreateJournal ) )
00318         mActions[ StandardCalendarActionManager::CreateJournal ]->setEnabled( hasWritableCollection( KCalCore::Journal::journalMimeType() ) );
00319 
00320       if ( mActions.contains( StandardCalendarActionManager::EditIncidence ) ) {
00321         bool canEditItem = true;
00322 
00323         // only one selected item can be edited
00324         canEditItem = canEditItem && (itemCount == 1);
00325 
00326         // check whether parent collection allows changing the item
00327         const QModelIndexList rows = mItemSelectionModel->selectedRows();
00328         if ( rows.count() == 1 ) {
00329           const QModelIndex index = rows.first();
00330           const Collection parentCollection = index.data( EntityTreeModel::ParentCollectionRole ).value<Collection>();
00331           if ( parentCollection.isValid() )
00332             canEditItem = canEditItem && (parentCollection.rights() & Collection::CanChangeItem);
00333         }
00334 
00335         mActions.value( StandardCalendarActionManager::EditIncidence )->setEnabled( canEditItem );
00336       }
00337 
00338       if ( mActions.contains( StandardCalendarActionManager::CreateSubTodo ) )
00339         mActions[ StandardCalendarActionManager::CreateSubTodo ]->setEnabled( false );
00340 
00341       if ( itemCount == 1 ) {
00342         const Akonadi::Item item = mGenericManager->selectedItems().first();
00343 
00344         if ( item.isValid() && item.hasPayload<KCalCore::Todo::Ptr>() ) {
00345           if ( mActions.contains( StandardCalendarActionManager::CreateSubTodo ) )
00346             mActions[ StandardCalendarActionManager::CreateSubTodo ]->setEnabled( hasWritableCollection( KCalCore::Todo::todoMimeType() ) );
00347         }
00348       }
00349 
00350       emit mParent->actionStateUpdated();
00351     }
00352 
00353     void slotCreateEvent()
00354     {
00355       // dummy as long as there are no editors available in kdepimlibs/
00356     }
00357 
00358     void slotCreateTodo()
00359     {
00360       // dummy as long as there are no editors available in kdepimlibs/
00361     }
00362 
00363     void slotCreateSubTodo()
00364     {
00365       // dummy as long as there are no editors available in kdepimlibs/
00366     }
00367 
00368     void slotCreateJournal()
00369     {
00370       // dummy as long as there are no editors available in kdepimlibs/
00371     }
00372 
00373     void slotEditIncidence()
00374     {
00375       // dummy as long as there are no editors available in kdepimlibs/
00376     }
00377 
00378     KActionCollection *mActionCollection;
00379     QWidget *mParentWidget;
00380     StandardActionManager *mGenericManager;
00381     QItemSelectionModel *mCollectionSelectionModel;
00382     QItemSelectionModel *mItemSelectionModel;
00383     QHash<StandardCalendarActionManager::Type, KAction*> mActions;
00384     QSet<StandardCalendarActionManager::Type> mInterceptedActions;
00385     StandardCalendarActionManager *mParent;
00386 };
00387 
00388 
00389 Akonadi::StandardCalendarActionManager::StandardCalendarActionManager( KActionCollection *actionCollection, QWidget *parent )
00390   : QObject( parent ),
00391     d( new Private( actionCollection, parent, this ) )
00392 {
00393 }
00394 
00395 StandardCalendarActionManager::~StandardCalendarActionManager()
00396 {
00397   delete d;
00398 }
00399 
00400 void StandardCalendarActionManager::setCollectionSelectionModel( QItemSelectionModel *selectionModel )
00401 {
00402   d->mCollectionSelectionModel = selectionModel;
00403   d->mGenericManager->setCollectionSelectionModel( selectionModel );
00404 
00405   connect( selectionModel->model(), SIGNAL(rowsInserted(QModelIndex,int,int)),
00406            SLOT(updateActions()) );
00407   connect( selectionModel->model(), SIGNAL(rowsRemoved(QModelIndex,int,int)),
00408            SLOT(updateActions()) );
00409   connect( selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
00410            SLOT(updateActions()) );
00411   d->updateActions();
00412 }
00413 
00414 void StandardCalendarActionManager::setItemSelectionModel( QItemSelectionModel *selectionModel )
00415 {
00416   d->mItemSelectionModel = selectionModel;
00417   d->mGenericManager->setItemSelectionModel( selectionModel );
00418 
00419   connect( selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
00420            SLOT(updateActions()) );
00421 
00422   d->updateActions();
00423 }
00424 
00425 KAction* StandardCalendarActionManager::createAction( StandardCalendarActionManager::Type type )
00426 {
00427   if ( d->mActions.contains( type ) )
00428     return d->mActions.value( type );
00429 
00430   KAction *action = 0;
00431   switch ( type ) {
00432     case CreateEvent:
00433       action = new KAction( d->mParentWidget );
00434       action->setIcon( KIcon( QLatin1String( "appointment-new" ) ) );
00435       action->setText( i18n( "New E&vent..." ) );
00436       action->setWhatsThis( i18n( "Create a new event" ) );
00437       d->mActions.insert( CreateEvent, action );
00438       d->mActionCollection->addAction( QString::fromLatin1( "akonadi_event_create" ), action );
00439       connect( action, SIGNAL(triggered(bool)), this, SLOT(slotCreateEvent()) );
00440       break;
00441     case CreateTodo:
00442       action = new KAction( d->mParentWidget );
00443       action->setIcon( KIcon( QLatin1String( "task-new" ) ) );
00444       action->setText( i18n( "New &To-do..." ) );
00445       action->setWhatsThis( i18n( "Create a new To-do" ) );
00446       d->mActions.insert( CreateTodo, action );
00447       d->mActionCollection->addAction( QString::fromLatin1( "akonadi_todo_create" ), action );
00448       connect( action, SIGNAL(triggered(bool)), this, SLOT(slotCreateTodo()) );
00449       break;
00450     case CreateSubTodo:
00451       action = new KAction( d->mParentWidget );
00452       action->setIcon( KIcon( QLatin1String( "new_subtodo" ) ) );
00453       action->setText( i18n( "New Su&b-to-do..." ) );
00454       action->setWhatsThis( i18n( "Create a new Sub-to-do" ) );
00455       d->mActions.insert( CreateSubTodo, action );
00456       d->mActionCollection->addAction( QString::fromLatin1( "akonadi_subtodo_create" ), action );
00457       connect( action, SIGNAL(triggered(bool)), this, SLOT(slotCreateSubTodo()) );
00458       break;
00459     case CreateJournal:
00460       action = new KAction( d->mParentWidget );
00461       action->setIcon( KIcon( QLatin1String( "journal-new" ) ) );
00462       action->setText( i18n( "New &Journal..." ) );
00463       action->setWhatsThis( i18n( "Create a new Journal" ) );
00464       d->mActions.insert( CreateJournal, action );
00465       d->mActionCollection->addAction( QString::fromLatin1( "akonadi_journal_create" ), action );
00466       connect( action, SIGNAL(triggered(bool)), this, SLOT(slotCreateJournal()) );
00467       break;
00468     case EditIncidence:
00469       action = new KAction( d->mParentWidget );
00470       action->setText( i18n( "&Edit..." ) );
00471       action->setWhatsThis( i18n( "Edit the selected incidence." ) );
00472       d->mActions.insert( EditIncidence, action );
00473       d->mActionCollection->addAction( QString::fromLatin1( "akonadi_incidence_edit" ), action );
00474       connect( action, SIGNAL(triggered(bool)), this, SLOT(slotEditIncidence()) );
00475       break;
00476     default:
00477       Q_ASSERT( false ); // should never happen
00478       break;
00479   }
00480 
00481   return action;
00482 }
00483 
00484 KAction* StandardCalendarActionManager::createAction( StandardActionManager::Type type )
00485 {
00486   return d->mGenericManager->createAction( type );
00487 }
00488 
00489 void StandardCalendarActionManager::createAllActions()
00490 {
00491   createAction( CreateEvent );
00492   createAction( CreateTodo );
00493   createAction( CreateSubTodo );
00494   createAction( CreateJournal );
00495   createAction( EditIncidence );
00496 
00497   d->mGenericManager->createAllActions();
00498   d->updateActions();
00499 }
00500 
00501 KAction* StandardCalendarActionManager::action( StandardCalendarActionManager::Type type ) const
00502 {
00503   if ( d->mActions.contains( type ) )
00504     return d->mActions.value( type );
00505 
00506   return 0;
00507 }
00508 
00509 KAction* StandardCalendarActionManager::action( StandardActionManager::Type type ) const
00510 {
00511   return d->mGenericManager->action( type );
00512 }
00513 
00514 void StandardCalendarActionManager::setActionText( StandardActionManager::Type type, const KLocalizedString &text )
00515 {
00516   d->mGenericManager->setActionText( type, text );
00517 }
00518 
00519 void StandardCalendarActionManager::interceptAction( StandardCalendarActionManager::Type type, bool intercept )
00520 {
00521   if ( intercept )
00522     d->mInterceptedActions.insert( type );
00523   else
00524     d->mInterceptedActions.remove( type );
00525 }
00526 
00527 void StandardCalendarActionManager::interceptAction( StandardActionManager::Type type, bool intercept )
00528 {
00529   d->mGenericManager->interceptAction( type, intercept );
00530 }
00531 
00532 Akonadi::Collection::List StandardCalendarActionManager::selectedCollections() const
00533 {
00534   return d->mGenericManager->selectedCollections();
00535 }
00536 
00537 Akonadi::Item::List StandardCalendarActionManager::selectedItems() const
00538 {
00539   return d->mGenericManager->selectedItems();
00540 }
00541 
00542 void StandardCalendarActionManager::setContextText( StandardActionManager::Type type, StandardActionManager::TextContext context, const QString &text )
00543 {
00544   d->mGenericManager->setContextText( type, context, text );
00545 }
00546 
00547 void StandardCalendarActionManager::setContextText( StandardActionManager::Type type, StandardActionManager::TextContext context, const KLocalizedString &text )
00548 {
00549   d->mGenericManager->setContextText( type, context, text );
00550 }
00551 
00552 void StandardCalendarActionManager::setCollectionPropertiesPageNames( const QStringList &names )
00553 {
00554   d->mGenericManager->setCollectionPropertiesPageNames( names );
00555 }
00556 
00557 #include "standardcalendaractionmanager.moc"
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Apr 30 2012 21:49:16 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules
  • Related Pages

kdepimlibs-4.8.3 API Reference

Skip menu "kdepimlibs-4.8.3 API Reference"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal