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

akonadi

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

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • 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
Generated for KDE-PIM Libraries by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal