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

akonadi

  • akonadi
  • calendar
standardcalendaractionmanager.cpp
1 /*
2  * Copyright (C) 2010 Casey Link <unnamedrambler@gmail.com>
3  * Copyright (C) 2010 Klaralvdalens Datakonsult AB, a KDAB Group company <info@kdab.net>
4  * Copyright (c) 2009 - 2010 Tobias Koenig <tokoe@kde.org>
5  *
6  * This library is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU Library General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or (at your
9  * option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14  * License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB. If not, write to the
18  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
22 #include "standardcalendaractionmanager.h"
23 
24 #include <akonadi/entitytreemodel.h>
25 
26 #include <kaction.h>
27 #include <kactioncollection.h>
28 #include <kcalcore/event.h>
29 #include <kcalcore/journal.h>
30 #include <kcalcore/todo.h>
31 #include <klocale.h>
32 
33 #include <QtGui/QItemSelectionModel>
34 
35 using namespace Akonadi;
36 
37 class StandardCalendarActionManager::Private
38 {
39  public:
40  Private( KActionCollection *actionCollection, QWidget *parentWidget, StandardCalendarActionManager *parent )
41  : mActionCollection( actionCollection ),
42  mParentWidget( parentWidget ),
43  mCollectionSelectionModel( 0 ),
44  mItemSelectionModel( 0 ),
45  mParent( parent )
46  {
47  KGlobal::locale()->insertCatalog(QLatin1String("libakonadi-calendar"));
48  mGenericManager = new StandardActionManager( actionCollection, parentWidget );
49  mParent->connect( mGenericManager, SIGNAL(actionStateUpdated()),
50  mParent, SIGNAL(actionStateUpdated()) );
51  mGenericManager->createAllActions();
52 
53  mGenericManager->action( Akonadi::StandardActionManager::CreateCollection )->setText(
54  i18n( "Add Calendar Folder..." ) );
55  mGenericManager->action( Akonadi::StandardActionManager::CreateCollection )->setWhatsThis(
56  i18n( "Add a new calendar folder to the currently selected calendar folder." ) );
57 
58  mGenericManager->setActionText( Akonadi::StandardActionManager::CopyCollections,
59  ki18np( "Copy Calendar Folder", "Copy %1 Calendar Folders" ) );
60  mGenericManager->action( Akonadi::StandardActionManager::CopyCollections )->setWhatsThis(
61  i18n( "Copy the selected calendar folders to the clipboard." ) );
62 
63  mGenericManager->setActionText( Akonadi::StandardActionManager::DeleteCollections,
64  ki18np( "Delete Calendar Folder", "Delete %1 Calendar Folders" ) );
65  mGenericManager->action( Akonadi::StandardActionManager::DeleteCollections )->setWhatsThis(
66  i18n( "Delete the selected calendar folders from the calendar." ) );
67 
68  mGenericManager->setActionText( Akonadi::StandardActionManager::SynchronizeCollections,
69  ki18np( "Update Calendar Folder", "Update %1 Calendar Folders" ) );
70  mGenericManager->action( Akonadi::StandardActionManager::SynchronizeCollections )->setWhatsThis(
71  i18n( "Update the content of the selected calendar folders." ) );
72 
73  mGenericManager->setActionText( Akonadi::StandardActionManager::CutCollections,
74  ki18np( "Cut Calendar Folder", "Cut %1 Calendar Folders" ) );
75  mGenericManager->action( Akonadi::StandardActionManager::CutCollections )->setWhatsThis(
76  i18n( "Cut the selected calendar folders from the calendar." ) );
77 
78  mGenericManager->action( Akonadi::StandardActionManager::CollectionProperties )->setText(
79  i18n( "Folder Properties..." ) );
80  mGenericManager->action( Akonadi::StandardActionManager::CollectionProperties)->setWhatsThis(
81  i18n( "Open a dialog to edit the properties of the selected calendar folder." ) );
82 
83  mGenericManager->setActionText( Akonadi::StandardActionManager::CopyItems,
84  ki18np( "Copy Event", "Copy %1 Events" ) );
85  mGenericManager->action( Akonadi::StandardActionManager::CopyItems )->setWhatsThis(
86  i18n( "Copy the selected events to the clipboard." ) );
87 
88  mGenericManager->setActionText( Akonadi::StandardActionManager::DeleteItems,
89  ki18np( "Delete Event", "Delete %1 Events" ) );
90  mGenericManager->action( Akonadi::StandardActionManager::DeleteItems )->setWhatsThis(
91  i18n( "Delete the selected events from the calendar." ) );
92 
93  mGenericManager->setActionText( Akonadi::StandardActionManager::CutItems,
94  ki18np( "Cut Event", "Cut %1 Events" ) );
95  mGenericManager->action( Akonadi::StandardActionManager::CutItems )->setWhatsThis(
96  i18n( "Cut the selected events from the calendar." ) );
97 
98  mGenericManager->action( Akonadi::StandardActionManager::CreateResource )->setText(
99  i18n( "Add &Calendar..." ) );
100  mGenericManager->action( Akonadi::StandardActionManager::CreateResource )->setWhatsThis(
101  i18n( "Add a new calendar<p>"
102  "You will be presented with a dialog where you can select "
103  "the type of the calendar that shall be added.</p>" ) );
104 
105  mGenericManager->setActionText( Akonadi::StandardActionManager::DeleteResources,
106  ki18np( "&Delete Calendar", "&Delete %1 Calendars" ) );
107  mGenericManager->action( Akonadi::StandardActionManager::DeleteResources )->setWhatsThis(
108  i18n( "Delete the selected calendars<p>"
109  "The currently selected calendars will be deleted, "
110  "along with all the events, todos and journals they contain.</p>" ) );
111 
112  mGenericManager->action( Akonadi::StandardActionManager::ResourceProperties )->setText(
113  i18n( "Calendar Properties..." ) );
114  mGenericManager->action( Akonadi::StandardActionManager::ResourceProperties )->setWhatsThis(
115  i18n( "Open a dialog to edit properties of the selected calendar." ) );
116 
117  mGenericManager->setActionText( Akonadi::StandardActionManager::SynchronizeResources,
118  ki18np( "Update Calendar", "Update %1 Calendars" ) );
119  mGenericManager->action( Akonadi::StandardActionManager::SynchronizeResources )->setWhatsThis(
120  i18n( "Updates the content of all folders of the selected calendars." ) );
121 
122  mGenericManager->action( Akonadi::StandardActionManager::CopyItemToMenu )->setText(
123  i18n( "&Copy to Calendar" ) );
124  mGenericManager->action( Akonadi::StandardActionManager::CopyItemToMenu )->setWhatsThis(
125  i18n( "Copy the selected event to a different calendar." ) );
126 
127  mGenericManager->action( Akonadi::StandardActionManager::MoveItemToMenu )->setText(
128  i18n( "&Move to Calendar" ) );
129  mGenericManager->action( Akonadi::StandardActionManager::MoveItemToMenu )->setWhatsThis(
130  i18n( "Move the selected event to a different calendar." ) );
131 
132 
133  mGenericManager->setContextText(
134  StandardActionManager::CreateCollection, StandardActionManager::DialogTitle,
135  i18nc( "@title:window", "New Calendar Folder" ) );
136 
137  mGenericManager->setContextText(
138  StandardActionManager::CreateCollection, StandardActionManager::ErrorMessageText,
139  ki18n( "Could not create calendar folder: %1" ) );
140 
141  mGenericManager->setContextText(
142  StandardActionManager::CreateCollection, StandardActionManager::ErrorMessageTitle,
143  i18n( "Calendar folder creation failed" ) );
144 
145  mGenericManager->setContextText(
146  StandardActionManager::DeleteCollections, StandardActionManager::MessageBoxText,
147  ki18np( "Do you really want to delete this calendar folder and all its sub-folders?",
148  "Do you really want to delete %1 calendar folders and all their sub-folders?" ) );
149 
150  mGenericManager->setContextText(
151  StandardActionManager::DeleteCollections, StandardActionManager::MessageBoxTitle,
152  ki18ncp( "@title:window", "Delete calendar folder?", "Delete calendar folders?" ) );
153 
154  mGenericManager->setContextText(
155  StandardActionManager::DeleteCollections, StandardActionManager::ErrorMessageText,
156  ki18n( "Could not delete calendar folder: %1" ) );
157 
158  mGenericManager->setContextText(
159  StandardActionManager::DeleteCollections, StandardActionManager::ErrorMessageTitle,
160  i18n( "Calendar folder deletion failed" ) );
161 
162  mGenericManager->setContextText(
163  StandardActionManager::CollectionProperties, StandardActionManager::DialogTitle,
164  ki18nc( "@title:window", "Properties of Calendar Folder %1" ) );
165 
166  mGenericManager->setContextText(
167  StandardActionManager::DeleteItems, StandardActionManager::MessageBoxText,
168  ki18np( "Do you really want to delete the selected event?",
169  "Do you really want to delete %1 events?" ) );
170 
171  mGenericManager->setContextText(
172  StandardActionManager::DeleteItems, StandardActionManager::MessageBoxTitle,
173  ki18ncp( "@title:window", "Delete Event?", "Delete Events?" ) );
174 
175  mGenericManager->setContextText(
176  StandardActionManager::DeleteItems, StandardActionManager::ErrorMessageText,
177  ki18n( "Could not delete event: %1" ) );
178 
179  mGenericManager->setContextText(
180  StandardActionManager::DeleteItems, StandardActionManager::ErrorMessageTitle,
181  i18n( "Event deletion failed" ) );
182 
183  mGenericManager->setContextText(
184  StandardActionManager::CreateResource, StandardActionManager::DialogTitle,
185  i18nc( "@title:window", "Add Calendar" ) );
186 
187  mGenericManager->setContextText(
188  StandardActionManager::CreateResource, StandardActionManager::ErrorMessageText,
189  ki18n( "Could not create calendar: %1" ) );
190 
191  mGenericManager->setContextText(
192  StandardActionManager::CreateResource, StandardActionManager::ErrorMessageTitle,
193  i18n( "Calendar creation failed" ) );
194 
195  mGenericManager->setContextText(
196  StandardActionManager::DeleteResources, StandardActionManager::MessageBoxText,
197  ki18np( "Do you really want to delete this calendar?",
198  "Do you really want to delete %1 calendars?" ) );
199 
200  mGenericManager->setContextText(
201  StandardActionManager::DeleteResources, StandardActionManager::MessageBoxTitle,
202  ki18ncp( "@title:window", "Delete Calendar?", "Delete Calendars?" ) );
203 
204  mGenericManager->setContextText(
205  StandardActionManager::Paste, StandardActionManager::ErrorMessageText,
206  ki18n( "Could not paste event: %1" ) );
207 
208  mGenericManager->setContextText(
209  StandardActionManager::Paste, StandardActionManager::ErrorMessageTitle,
210  i18n( "Paste failed" ) );
211 
212  mGenericManager->setMimeTypeFilter( QStringList() << QLatin1String( "text/calendar" ) );
213  mGenericManager->setCapabilityFilter( QStringList() << QLatin1String( "Resource" ) );
214  }
215 
216  ~Private()
217  {
218  delete mGenericManager;
219  }
220 
221  static bool hasWritableCollection( const QModelIndex &index, const QString &mimeType )
222  {
223  const Akonadi::Collection collection =
224  index.data( Akonadi::EntityTreeModel::CollectionRole ).value<Akonadi::Collection>();
225  if ( collection.isValid() ) {
226  if ( collection.contentMimeTypes().contains( mimeType ) &&
227  ( collection.rights() & Akonadi::Collection::CanCreateItem ) ) {
228  return true;
229  }
230  }
231 
232  const QAbstractItemModel *model = index.model();
233  if ( !model )
234  return false;
235 
236  for ( int row = 0; row < model->rowCount( index ); ++row ) {
237  if ( hasWritableCollection( model->index( row, 0, index ), mimeType ) )
238  return true;
239  }
240 
241  return false;
242  }
243 
244  bool hasWritableCollection( const QString &mimeType ) const
245  {
246  if ( !mCollectionSelectionModel )
247  return false;
248 
249  const QAbstractItemModel *collectionModel = mCollectionSelectionModel->model();
250  for ( int row = 0; row < collectionModel->rowCount(); ++row ) {
251  if ( hasWritableCollection( collectionModel->index( row, 0, QModelIndex() ), mimeType ) )
252  return true;
253  }
254 
255  return false;
256  }
257 
258  void updateActions()
259  {
260  if ( !mItemSelectionModel )
261  return;
262 
263  // update action labels
264  const int itemCount = mItemSelectionModel->selectedRows().count();
265  if ( itemCount == 1 ) {
266  const QModelIndex index = mItemSelectionModel->selectedRows().first();
267  if ( index.isValid() ) {
268  const QString mimeType = index.data( EntityTreeModel::MimeTypeRole ).toString();
269  if ( mimeType == KCalCore::Event::eventMimeType() ) {
270  mGenericManager->setActionText( Akonadi::StandardActionManager::CopyItems,
271  ki18np( "Copy Event", "Copy %1 Events" ) );
272  mGenericManager->action( Akonadi::StandardActionManager::CopyItemToMenu )->setText( i18n( "Copy Event To" ) );
273  mGenericManager->action( Akonadi::StandardActionManager::CopyItemToDialog )->setText( i18n( "Copy Event To" ) );
274  mGenericManager->setActionText( Akonadi::StandardActionManager::DeleteItems,
275  ki18np( "Delete Event", "Delete %1 Events" ) );
276  mGenericManager->setActionText( Akonadi::StandardActionManager::CutItems,
277  ki18np( "Cut Event", "Cut %1 Events" ) );
278  mGenericManager->action( Akonadi::StandardActionManager::MoveItemToMenu )->setText( i18n( "Move Event To" ) );
279  mGenericManager->action( Akonadi::StandardActionManager::MoveItemToDialog )->setText( i18n( "Move Event To" ) );
280  if ( mActions.contains( StandardCalendarActionManager::EditIncidence ) )
281  mActions.value( StandardCalendarActionManager::EditIncidence )->setText( i18n( "Edit Event..." ) );
282  } else if ( mimeType == KCalCore::Todo::todoMimeType() ) {
283  mGenericManager->setActionText( Akonadi::StandardActionManager::CopyItems,
284  ki18np( "Copy To-do", "Copy %1 To-dos" ) );
285  mGenericManager->action( Akonadi::StandardActionManager::CopyItemToMenu )->setText( i18n( "Copy To-do To" ) );
286  mGenericManager->action( Akonadi::StandardActionManager::CopyItemToDialog )->setText( i18n( "Copy To-do To" ) );
287  mGenericManager->setActionText( Akonadi::StandardActionManager::DeleteItems,
288  ki18np( "Delete To-do", "Delete %1 To-dos" ) );
289  mGenericManager->setActionText( Akonadi::StandardActionManager::CutItems,
290  ki18np( "Cut To-do", "Cut %1 To-dos" ) );
291  mGenericManager->action( Akonadi::StandardActionManager::MoveItemToMenu )->setText( i18n( "Move To-do To" ) );
292  mGenericManager->action( Akonadi::StandardActionManager::MoveItemToDialog )->setText( i18n( "Move To-do To" ) );
293  if ( mActions.contains( StandardCalendarActionManager::EditIncidence ) )
294  mActions.value( StandardCalendarActionManager::EditIncidence )->setText( i18n( "Edit To-do..." ) );
295  } else if ( mimeType == KCalCore::Journal::journalMimeType() ) {
296  mGenericManager->setActionText( Akonadi::StandardActionManager::CopyItems,
297  ki18np( "Copy Journal", "Copy %1 Journals" ) );
298  mGenericManager->action( Akonadi::StandardActionManager::CopyItemToMenu )->setText( i18n( "Copy Journal To" ) );
299  mGenericManager->action( Akonadi::StandardActionManager::CopyItemToDialog )->setText( i18n( "Copy Journal To" ) );
300  mGenericManager->setActionText( Akonadi::StandardActionManager::DeleteItems,
301  ki18np( "Delete Journal", "Delete %1 Journals" ) );
302  mGenericManager->setActionText( Akonadi::StandardActionManager::CutItems,
303  ki18np( "Cut Journal", "Cut %1 Journals" ) );
304  mGenericManager->action( Akonadi::StandardActionManager::MoveItemToMenu )->setText( i18n( "Move Journal To" ) );
305  mGenericManager->action( Akonadi::StandardActionManager::MoveItemToDialog )->setText( i18n( "Move Journal To" ) );
306  if ( mActions.contains( StandardCalendarActionManager::EditIncidence ) )
307  mActions.value( StandardCalendarActionManager::EditIncidence )->setText( i18n( "Edit Journal..." ) );
308  }
309  }
310  }
311 
312  // update action states
313  if ( mActions.contains( StandardCalendarActionManager::CreateEvent ) )
314  mActions[ StandardCalendarActionManager::CreateEvent ]->setEnabled( hasWritableCollection( KCalCore::Event::eventMimeType() ) );
315  if ( mActions.contains( StandardCalendarActionManager::CreateTodo ) )
316  mActions[ StandardCalendarActionManager::CreateTodo ]->setEnabled( hasWritableCollection( KCalCore::Todo::todoMimeType() ) );
317  if ( mActions.contains( StandardCalendarActionManager::CreateJournal ) )
318  mActions[ StandardCalendarActionManager::CreateJournal ]->setEnabled( hasWritableCollection( KCalCore::Journal::journalMimeType() ) );
319 
320  if ( mActions.contains( StandardCalendarActionManager::EditIncidence ) ) {
321  bool canEditItem = true;
322 
323  // only one selected item can be edited
324  canEditItem = canEditItem && (itemCount == 1);
325 
326  // check whether parent collection allows changing the item
327  const QModelIndexList rows = mItemSelectionModel->selectedRows();
328  if ( rows.count() == 1 ) {
329  const QModelIndex index = rows.first();
330  const Collection parentCollection = index.data( EntityTreeModel::ParentCollectionRole ).value<Collection>();
331  if ( parentCollection.isValid() )
332  canEditItem = canEditItem && (parentCollection.rights() & Collection::CanChangeItem);
333  }
334 
335  mActions.value( StandardCalendarActionManager::EditIncidence )->setEnabled( canEditItem );
336  }
337 
338  if ( mActions.contains( StandardCalendarActionManager::CreateSubTodo ) )
339  mActions[ StandardCalendarActionManager::CreateSubTodo ]->setEnabled( false );
340 
341  if ( itemCount == 1 ) {
342  const Akonadi::Item item = mGenericManager->selectedItems().first();
343 
344  if ( item.isValid() && item.hasPayload<KCalCore::Todo::Ptr>() ) {
345  if ( mActions.contains( StandardCalendarActionManager::CreateSubTodo ) )
346  mActions[ StandardCalendarActionManager::CreateSubTodo ]->setEnabled( hasWritableCollection( KCalCore::Todo::todoMimeType() ) );
347  }
348  }
349 
350  emit mParent->actionStateUpdated();
351  }
352 
353  void slotCreateEvent()
354  {
355  // dummy as long as there are no editors available in kdepimlibs/
356  }
357 
358  void slotCreateTodo()
359  {
360  // dummy as long as there are no editors available in kdepimlibs/
361  }
362 
363  void slotCreateSubTodo()
364  {
365  // dummy as long as there are no editors available in kdepimlibs/
366  }
367 
368  void slotCreateJournal()
369  {
370  // dummy as long as there are no editors available in kdepimlibs/
371  }
372 
373  void slotEditIncidence()
374  {
375  // dummy as long as there are no editors available in kdepimlibs/
376  }
377 
378  KActionCollection *mActionCollection;
379  QWidget *mParentWidget;
380  StandardActionManager *mGenericManager;
381  QItemSelectionModel *mCollectionSelectionModel;
382  QItemSelectionModel *mItemSelectionModel;
383  QHash<StandardCalendarActionManager::Type, KAction*> mActions;
384  QSet<StandardCalendarActionManager::Type> mInterceptedActions;
385  StandardCalendarActionManager *mParent;
386 };
387 
388 
389 Akonadi::StandardCalendarActionManager::StandardCalendarActionManager( KActionCollection *actionCollection, QWidget *parent )
390  : QObject( parent ),
391  d( new Private( actionCollection, parent, this ) )
392 {
393 }
394 
395 StandardCalendarActionManager::~StandardCalendarActionManager()
396 {
397  delete d;
398 }
399 
400 void StandardCalendarActionManager::setCollectionSelectionModel( QItemSelectionModel *selectionModel )
401 {
402  d->mCollectionSelectionModel = selectionModel;
403  d->mGenericManager->setCollectionSelectionModel( selectionModel );
404 
405  connect( selectionModel->model(), SIGNAL(rowsInserted(QModelIndex,int,int)),
406  SLOT(updateActions()) );
407  connect( selectionModel->model(), SIGNAL(rowsRemoved(QModelIndex,int,int)),
408  SLOT(updateActions()) );
409  connect( selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
410  SLOT(updateActions()) );
411  d->updateActions();
412 }
413 
414 void StandardCalendarActionManager::setItemSelectionModel( QItemSelectionModel *selectionModel )
415 {
416  d->mItemSelectionModel = selectionModel;
417  d->mGenericManager->setItemSelectionModel( selectionModel );
418 
419  connect( selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
420  SLOT(updateActions()) );
421 
422  d->updateActions();
423 }
424 
425 KAction* StandardCalendarActionManager::createAction( StandardCalendarActionManager::Type type )
426 {
427  if ( d->mActions.contains( type ) )
428  return d->mActions.value( type );
429 
430  KAction *action = 0;
431  switch ( type ) {
432  case CreateEvent:
433  action = new KAction( d->mParentWidget );
434  action->setIcon( KIcon( QLatin1String( "appointment-new" ) ) );
435  action->setText( i18n( "New E&vent..." ) );
436  action->setWhatsThis( i18n( "Create a new event" ) );
437  d->mActions.insert( CreateEvent, action );
438  d->mActionCollection->addAction( QString::fromLatin1( "akonadi_event_create" ), action );
439  connect( action, SIGNAL(triggered(bool)), this, SLOT(slotCreateEvent()) );
440  break;
441  case CreateTodo:
442  action = new KAction( d->mParentWidget );
443  action->setIcon( KIcon( QLatin1String( "task-new" ) ) );
444  action->setText( i18n( "New &To-do..." ) );
445  action->setWhatsThis( i18n( "Create a new To-do" ) );
446  d->mActions.insert( CreateTodo, action );
447  d->mActionCollection->addAction( QString::fromLatin1( "akonadi_todo_create" ), action );
448  connect( action, SIGNAL(triggered(bool)), this, SLOT(slotCreateTodo()) );
449  break;
450  case CreateSubTodo:
451  action = new KAction( d->mParentWidget );
452  action->setIcon( KIcon( QLatin1String( "new_subtodo" ) ) );
453  action->setText( i18n( "New Su&b-to-do..." ) );
454  action->setWhatsThis( i18n( "Create a new Sub-to-do" ) );
455  d->mActions.insert( CreateSubTodo, action );
456  d->mActionCollection->addAction( QString::fromLatin1( "akonadi_subtodo_create" ), action );
457  connect( action, SIGNAL(triggered(bool)), this, SLOT(slotCreateSubTodo()) );
458  break;
459  case CreateJournal:
460  action = new KAction( d->mParentWidget );
461  action->setIcon( KIcon( QLatin1String( "journal-new" ) ) );
462  action->setText( i18n( "New &Journal..." ) );
463  action->setWhatsThis( i18n( "Create a new Journal" ) );
464  d->mActions.insert( CreateJournal, action );
465  d->mActionCollection->addAction( QString::fromLatin1( "akonadi_journal_create" ), action );
466  connect( action, SIGNAL(triggered(bool)), this, SLOT(slotCreateJournal()) );
467  break;
468  case EditIncidence:
469  action = new KAction( d->mParentWidget );
470  action->setText( i18n( "&Edit..." ) );
471  action->setWhatsThis( i18n( "Edit the selected incidence." ) );
472  d->mActions.insert( EditIncidence, action );
473  d->mActionCollection->addAction( QString::fromLatin1( "akonadi_incidence_edit" ), action );
474  connect( action, SIGNAL(triggered(bool)), this, SLOT(slotEditIncidence()) );
475  break;
476  default:
477  Q_ASSERT( false ); // should never happen
478  break;
479  }
480 
481  return action;
482 }
483 
484 KAction* StandardCalendarActionManager::createAction( StandardActionManager::Type type )
485 {
486  return d->mGenericManager->createAction( type );
487 }
488 
489 void StandardCalendarActionManager::createAllActions()
490 {
491  createAction( CreateEvent );
492  createAction( CreateTodo );
493  createAction( CreateSubTodo );
494  createAction( CreateJournal );
495  createAction( EditIncidence );
496 
497  d->mGenericManager->createAllActions();
498  d->updateActions();
499 }
500 
501 KAction* StandardCalendarActionManager::action( StandardCalendarActionManager::Type type ) const
502 {
503  if ( d->mActions.contains( type ) )
504  return d->mActions.value( type );
505 
506  return 0;
507 }
508 
509 KAction* StandardCalendarActionManager::action( StandardActionManager::Type type ) const
510 {
511  return d->mGenericManager->action( type );
512 }
513 
514 void StandardCalendarActionManager::setActionText( StandardActionManager::Type type, const KLocalizedString &text )
515 {
516  d->mGenericManager->setActionText( type, text );
517 }
518 
519 void StandardCalendarActionManager::interceptAction( StandardCalendarActionManager::Type type, bool intercept )
520 {
521  if ( intercept )
522  d->mInterceptedActions.insert( type );
523  else
524  d->mInterceptedActions.remove( type );
525 }
526 
527 void StandardCalendarActionManager::interceptAction( StandardActionManager::Type type, bool intercept )
528 {
529  d->mGenericManager->interceptAction( type, intercept );
530 }
531 
532 Akonadi::Collection::List StandardCalendarActionManager::selectedCollections() const
533 {
534  return d->mGenericManager->selectedCollections();
535 }
536 
537 Akonadi::Item::List StandardCalendarActionManager::selectedItems() const
538 {
539  return d->mGenericManager->selectedItems();
540 }
541 
542 void StandardCalendarActionManager::setContextText( StandardActionManager::Type type, StandardActionManager::TextContext context, const QString &text )
543 {
544  d->mGenericManager->setContextText( type, context, text );
545 }
546 
547 void StandardCalendarActionManager::setContextText( StandardActionManager::Type type, StandardActionManager::TextContext context, const KLocalizedString &text )
548 {
549  d->mGenericManager->setContextText( type, context, text );
550 }
551 
552 void StandardCalendarActionManager::setCollectionPropertiesPageNames( const QStringList &names )
553 {
554  d->mGenericManager->setCollectionPropertiesPageNames( names );
555 }
556 
557 #include "standardcalendaractionmanager.moc"
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Sep 24 2012 09:06:28 by doxygen 1.8.1.1 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.9.1 API Reference

Skip menu "kdepimlibs-4.9.1 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