Akonadi Calendar

standardcalendaractionmanager.cpp
1 /*
2  * SPDX-FileCopyrightText: 2010 Casey Link <[email protected]>
3  * SPDX-FileCopyrightText: 2010 Klaralvdalens Datakonsult AB, a KDAB Group company <[email protected]>
4  * SPDX-FileCopyrightText: 2009-2010 Tobias Koenig <[email protected]>
5  *
6  * SPDX-License-Identifier: LGPL-2.0-or-later
7  */
8 
9 #include "standardcalendaractionmanager.h"
10 
11 #include <Akonadi/EntityTreeModel>
12 
13 #include <KActionCollection>
14 #include <KCalendarCore/Event>
15 #include <KCalendarCore/Journal>
16 #include <KLocalizedString>
17 #include <QAction>
18 
19 #include <QItemSelectionModel>
20 
21 using namespace Akonadi;
22 
23 class Akonadi::StandardCalendarActionManagerPrivate
24 {
25 public:
26  StandardCalendarActionManagerPrivate(KActionCollection *actionCollection, QWidget *parentWidget, StandardCalendarActionManager *parent)
27  : mActionCollection(actionCollection)
28  , mParentWidget(parentWidget)
29  , mParent(parent)
30  {
31  mGenericManager = new StandardActionManager(actionCollection, parentWidget);
33  mGenericManager->setMimeTypeFilter(QStringList() << QStringLiteral("text/calendar"));
34  mGenericManager->setCapabilityFilter(QStringList() << QStringLiteral("Resource"));
35  }
36 
37  ~StandardCalendarActionManagerPrivate()
38  {
39  delete mGenericManager;
40  }
41 
42  void updateGenericAction(StandardActionManager::Type type)
43  {
44  switch (type) {
46  mGenericManager->action(Akonadi::StandardActionManager::CreateCollection)->setText(i18n("Add Folder..."));
48  ->setWhatsThis(i18n("Add a new calendar folder to the currently selected calendar folder."));
49  mGenericManager->setContextText(StandardActionManager::CreateCollection, StandardActionManager::DialogTitle, i18nc("@title:window", "New Folder"));
50 
51  mGenericManager->setContextText(StandardActionManager::CreateCollection,
53  ki18n("Could not create calendar folder: %1"));
54 
55  mGenericManager->setContextText(StandardActionManager::CreateCollection,
57  i18n("Calendar folder creation failed"));
59  ->setProperty("ContentMimeTypes",
60  QStringList() << QStringLiteral("inode/directory") << QStringLiteral("application/x-vnd.akonadi.calendar.todo")
61  << QStringLiteral("application/x-vnd.akonadi.calendar.event")
62  << QStringLiteral("application/x-vnd.akonadi.calendar.journal"));
63 
64  break;
66  mGenericManager->setActionText(Akonadi::StandardActionManager::CopyCollections, ki18np("Copy Folder", "Copy %1 Folders"));
68  ->setWhatsThis(i18n("Copy the selected calendar folders to the clipboard."));
69  break;
71  mGenericManager->setActionText(Akonadi::StandardActionManager::DeleteCollections, ki18np("Delete Folder", "Delete %1 Folders"));
73  ->setWhatsThis(i18n("Delete the selected calendar folders from the calendar."));
74  mGenericManager->setContextText(StandardActionManager::DeleteCollections,
76  ki18np("Do you really want to delete this calendar folder and all its sub-folders?",
77  "Do you really want to delete %1 calendar folders and all their sub-folders?"));
78 
79  mGenericManager->setContextText(StandardActionManager::DeleteCollections,
81  ki18ncp("@title:window", "Delete calendar folder?", "Delete calendar folders?"));
82 
83  mGenericManager->setContextText(StandardActionManager::DeleteCollections,
85  ki18n("Could not delete calendar folder: %1"));
86 
87  mGenericManager->setContextText(StandardActionManager::DeleteCollections,
89  i18n("Calendar folder deletion failed"));
90 
91  break;
93  mGenericManager->setActionText(Akonadi::StandardActionManager::SynchronizeCollections, ki18np("Update Folder", "Update %1 Folders"));
95  ->setWhatsThis(i18n("Update the content of the selected calendar folders."));
96 
97  break;
99  mGenericManager->setActionText(Akonadi::StandardActionManager::CutCollections, ki18np("Cut Folder", "Cut %1 Folders"));
100  mGenericManager->action(Akonadi::StandardActionManager::CutCollections)->setWhatsThis(i18n("Cut the selected calendar folders from the calendar."));
101  break;
103  mGenericManager->action(Akonadi::StandardActionManager::CollectionProperties)->setText(i18n("Folder Properties..."));
105  ->setWhatsThis(i18n("Open a dialog to edit the properties of the selected calendar folder."));
106  mGenericManager->setContextText(StandardActionManager::CollectionProperties,
108  ki18nc("@title:window", "Properties of Calendar Folder %1"));
109  break;
111  mGenericManager->setActionText(Akonadi::StandardActionManager::CopyItems, ki18np("Copy Event", "Copy %1 Events"));
112  mGenericManager->action(Akonadi::StandardActionManager::CopyItems)->setWhatsThis(i18n("Copy the selected events to the clipboard."));
113 
114  break;
116  mGenericManager->setActionText(Akonadi::StandardActionManager::DeleteItems, ki18np("Delete Event", "Delete %1 Events"));
117  mGenericManager->action(Akonadi::StandardActionManager::DeleteItems)->setWhatsThis(i18n("Delete the selected events from the calendar."));
118  mGenericManager->setContextText(StandardActionManager::DeleteItems,
120  ki18np("Do you really want to delete the selected event?", "Do you really want to delete %1 events?"));
121 
122  mGenericManager->setContextText(StandardActionManager::DeleteItems,
124  ki18ncp("@title:window", "Delete Event?", "Delete Events?"));
125 
126  mGenericManager->setContextText(StandardActionManager::DeleteItems, StandardActionManager::ErrorMessageText, ki18n("Could not delete event: %1"));
127 
128  mGenericManager->setContextText(StandardActionManager::DeleteItems, StandardActionManager::ErrorMessageTitle, i18n("Event deletion failed"));
129  break;
130 
132  mGenericManager->setActionText(Akonadi::StandardActionManager::CutItems, ki18np("Cut Event", "Cut %1 Events"));
133  mGenericManager->action(Akonadi::StandardActionManager::CutItems)->setWhatsThis(i18n("Cut the selected events from the calendar."));
134  break;
136  mGenericManager->action(Akonadi::StandardActionManager::CreateResource)->setText(i18n("Add &Calendar..."));
137  mGenericManager->action(Akonadi::StandardActionManager::CreateResource)
138  ->setWhatsThis(i18n("Add a new calendar<p>"
139  "You will be presented with a dialog where you can select "
140  "the type of the calendar that shall be added.</p>"));
141  mGenericManager->setContextText(StandardActionManager::CreateResource, StandardActionManager::DialogTitle, i18nc("@title:window", "Add Calendar"));
142 
143  mGenericManager->setContextText(StandardActionManager::CreateResource,
145  ki18n("Could not create calendar: %1"));
146 
147  mGenericManager->setContextText(StandardActionManager::CreateResource, StandardActionManager::ErrorMessageTitle, i18n("Calendar creation failed"));
148 
149  break;
151 
152  mGenericManager->setActionText(Akonadi::StandardActionManager::DeleteResources, ki18np("&Delete Calendar", "&Delete %1 Calendars"));
153  mGenericManager->action(Akonadi::StandardActionManager::DeleteResources)
154  ->setWhatsThis(i18n("Delete the selected calendars<p>"
155  "The currently selected calendars will be deleted, "
156  "along with all the events, todos and journals they contain.</p>"));
157  mGenericManager->setContextText(StandardActionManager::DeleteResources,
159  ki18np("Do you really want to delete this calendar?", "Do you really want to delete %1 calendars?"));
160 
161  mGenericManager->setContextText(StandardActionManager::DeleteResources,
163  ki18ncp("@title:window", "Delete Calendar?", "Delete Calendars?"));
164 
165  break;
167  mGenericManager->action(Akonadi::StandardActionManager::ResourceProperties)->setText(i18n("Calendar Properties..."));
169  ->setWhatsThis(i18n("Open a dialog to edit properties of the selected calendar."));
170  break;
172 
173  mGenericManager->setActionText(Akonadi::StandardActionManager::SynchronizeResources, ki18np("Update Calendar", "Update %1 Calendars"));
175  ->setWhatsThis(i18n("Updates the content of all folders of the selected calendars."));
176  break;
178  mGenericManager->action(Akonadi::StandardActionManager::CopyItemToMenu)->setText(i18n("&Copy to Calendar"));
179  mGenericManager->action(Akonadi::StandardActionManager::CopyItemToMenu)->setWhatsThis(i18n("Copy the selected event to a different calendar."));
180  break;
182  mGenericManager->action(Akonadi::StandardActionManager::MoveItemToMenu)->setText(i18n("&Move to Calendar"));
183  mGenericManager->action(Akonadi::StandardActionManager::MoveItemToMenu)->setWhatsThis(i18n("Move the selected event to a different calendar."));
184  break;
186  mGenericManager->setContextText(StandardActionManager::Paste, StandardActionManager::ErrorMessageText, ki18n("Could not paste event: %1"));
187 
188  mGenericManager->setContextText(StandardActionManager::Paste, StandardActionManager::ErrorMessageTitle, i18n("Paste failed"));
189  break;
191  mGenericManager->action(Akonadi::StandardActionManager::SynchronizeCollectionTree)->setText(i18n("Update Available Calendars"));
192  mGenericManager->action(Akonadi::StandardActionManager::SynchronizeCollectionTree)->setWhatsThis(i18n("Updates the tree of available calendars."));
193 
194  break;
195  default:
196  break;
197  }
198  }
199 
200  void updateGenericAllActions()
201  {
202  updateGenericAction(StandardActionManager::CreateCollection);
203  updateGenericAction(StandardActionManager::CopyCollections);
204  updateGenericAction(StandardActionManager::DeleteCollections);
206  updateGenericAction(StandardActionManager::CollectionProperties);
207  updateGenericAction(StandardActionManager::CopyItems);
208  updateGenericAction(StandardActionManager::Paste);
209  updateGenericAction(StandardActionManager::DeleteItems);
214  updateGenericAction(StandardActionManager::CopyCollectionToMenu);
215  updateGenericAction(StandardActionManager::CopyItemToMenu);
216  updateGenericAction(StandardActionManager::MoveItemToMenu);
217  updateGenericAction(StandardActionManager::MoveCollectionToMenu);
218  updateGenericAction(StandardActionManager::CutItems);
219  updateGenericAction(StandardActionManager::CutCollections);
220  updateGenericAction(StandardActionManager::CreateResource);
221  updateGenericAction(StandardActionManager::DeleteResources);
222  updateGenericAction(StandardActionManager::ResourceProperties);
223  updateGenericAction(StandardActionManager::SynchronizeResources);
224  updateGenericAction(StandardActionManager::ToggleWorkOffline);
227  updateGenericAction(StandardActionManager::CopyItemToDialog);
228  updateGenericAction(StandardActionManager::MoveItemToDialog);
231  updateGenericAction(StandardActionManager::MoveItemsToTrash);
240  }
241 
242  static bool hasWritableCollection(const QModelIndex &index, const QString &mimeType)
243  {
245  if (collection.isValid()) {
246  if (collection.contentMimeTypes().contains(mimeType) && (collection.rights() & Akonadi::Collection::CanCreateItem)) {
247  return true;
248  }
249  }
250 
251  const QAbstractItemModel *model = index.model();
252  if (!model) {
253  return false;
254  }
255 
256  for (int row = 0; row < model->rowCount(index); ++row) {
257  if (hasWritableCollection(model->index(row, 0, index), mimeType)) {
258  return true;
259  }
260  }
261 
262  return false;
263  }
264 
265  Q_REQUIRED_RESULT bool hasWritableCollection(const QString &mimeType) const
266  {
267  if (!mCollectionSelectionModel) {
268  return false;
269  }
270 
271  const QAbstractItemModel *collectionModel = mCollectionSelectionModel->model();
272  for (int row = 0; row < collectionModel->rowCount(); ++row) {
273  if (hasWritableCollection(collectionModel->index(row, 0, QModelIndex()), mimeType)) {
274  return true;
275  }
276  }
277 
278  return false;
279  }
280 
281  void updateActions()
282  {
283  if (!mItemSelectionModel) {
284  return;
285  }
286 
287  // update action labels
288  const int itemCount = mItemSelectionModel->selectedRows().count();
289  if (itemCount == 1) {
290  const QModelIndex index = mItemSelectionModel->selectedRows().at(0);
291  if (index.isValid()) {
293  if (mimeType == KCalendarCore::Event::eventMimeType()) {
294  if (mGenericManager->action(Akonadi::StandardActionManager::CopyItems)) {
295  mGenericManager->setActionText(Akonadi::StandardActionManager::CopyItems, ki18np("Copy Event", "Copy %1 Events"));
296  }
297  QAction *act = mGenericManager->action(Akonadi::StandardActionManager::CopyItemToMenu);
298  if (act) {
299  act->setText(i18n("Copy Event To"));
300  }
301  act = mGenericManager->action(Akonadi::StandardActionManager::CopyItemToDialog);
302  if (act) {
303  act->setText(i18n("Copy Event To"));
304  }
305  if (mGenericManager->action(Akonadi::StandardActionManager::DeleteItems)) {
306  mGenericManager->setActionText(Akonadi::StandardActionManager::DeleteItems, ki18np("Delete Event", "Delete %1 Events"));
307  }
308  if (mGenericManager->action(Akonadi::StandardActionManager::CutItems)) {
309  mGenericManager->setActionText(Akonadi::StandardActionManager::CutItems, ki18np("Cut Event", "Cut %1 Events"));
310  }
311  act = mGenericManager->action(Akonadi::StandardActionManager::MoveItemToMenu);
312  if (act) {
313  act->setText(i18n("Move Event To"));
314  }
315  act = mGenericManager->action(Akonadi::StandardActionManager::MoveItemToDialog);
316  if (act) {
317  act->setText(i18n("Move Event To"));
318  }
319  act = mActions.value(StandardCalendarActionManager::EditIncidence);
320  if (act) {
321  act->setText(i18n("Edit Event..."));
322  }
323  } else if (mimeType == KCalendarCore::Todo::todoMimeType()) {
324  if (mGenericManager->action(Akonadi::StandardActionManager::CopyItems)) {
325  mGenericManager->setActionText(Akonadi::StandardActionManager::CopyItems, ki18np("Copy To-do", "Copy %1 To-dos"));
326  }
327  QAction *act = mGenericManager->action(Akonadi::StandardActionManager::CopyItemToMenu);
328  if (act) {
329  act->setText(i18n("Copy To-do To"));
330  }
331  act = mGenericManager->action(Akonadi::StandardActionManager::CopyItemToDialog);
332  if (act) {
333  act->setText(i18n("Copy To-do To"));
334  }
335  if (mGenericManager->action(Akonadi::StandardActionManager::DeleteItems)) {
336  mGenericManager->setActionText(Akonadi::StandardActionManager::DeleteItems, ki18np("Delete To-do", "Delete %1 To-dos"));
337  }
338  if (mGenericManager->action(Akonadi::StandardActionManager::CutItems)) {
339  mGenericManager->setActionText(Akonadi::StandardActionManager::CutItems, ki18np("Cut To-do", "Cut %1 To-dos"));
340  }
341  act = mGenericManager->action(Akonadi::StandardActionManager::MoveItemToMenu);
342  if (act) {
343  act->setText(i18n("Move To-do To"));
344  }
345  act = mGenericManager->action(Akonadi::StandardActionManager::MoveItemToDialog);
346  if (act) {
347  act->setText(i18n("Move To-do To"));
348  }
349  act = mActions.value(StandardCalendarActionManager::EditIncidence);
350  if (act) {
351  act->setText(i18n("Edit To-do..."));
352  }
353  } else if (mimeType == KCalendarCore::Journal::journalMimeType()) {
354  if (mGenericManager->action(Akonadi::StandardActionManager::CopyItems)) {
355  mGenericManager->setActionText(Akonadi::StandardActionManager::CopyItems, ki18np("Copy Journal", "Copy %1 Journals"));
356  }
357  QAction *act = mGenericManager->action(Akonadi::StandardActionManager::CopyItemToMenu);
358  if (act) {
359  act->setText(i18n("Copy Journal To"));
360  }
361  act = mGenericManager->action(Akonadi::StandardActionManager::CopyItemToDialog);
362  if (act) {
363  act->setText(i18n("Copy Journal To"));
364  }
365  if (mGenericManager->action(Akonadi::StandardActionManager::DeleteItems)) {
366  mGenericManager->setActionText(Akonadi::StandardActionManager::DeleteItems, ki18np("Delete Journal", "Delete %1 Journals"));
367  }
368  if (mGenericManager->action(Akonadi::StandardActionManager::CutItems)) {
369  mGenericManager->setActionText(Akonadi::StandardActionManager::CutItems, ki18np("Cut Journal", "Cut %1 Journals"));
370  }
371  act = mGenericManager->action(Akonadi::StandardActionManager::MoveItemToMenu);
372  if (act) {
373  act->setText(i18n("Move Journal To"));
374  }
375  act = mGenericManager->action(Akonadi::StandardActionManager::MoveItemToDialog);
376  if (act) {
377  act->setText(i18n("Move Journal To"));
378  }
379  act = mActions.value(StandardCalendarActionManager::EditIncidence);
380  if (act) {
381  act->setText(i18n("Edit Journal..."));
382  }
383  }
384  }
385  }
386 
387  // update action states
389  if (act) {
390  act->setEnabled(hasWritableCollection(KCalendarCore::Event::eventMimeType()));
391  }
392  act = mActions.value(StandardCalendarActionManager::CreateTodo);
393  if (act) {
394  act->setEnabled(hasWritableCollection(KCalendarCore::Todo::todoMimeType()));
395  }
396  act = mActions.value(StandardCalendarActionManager::CreateJournal);
397  if (act) {
398  act->setEnabled(hasWritableCollection(KCalendarCore::Journal::journalMimeType()));
399  }
400 
401  act = mActions.value(StandardCalendarActionManager::EditIncidence);
402  if (act) {
403  bool canEditItem = true;
404 
405  // only one selected item can be edited
406  canEditItem = canEditItem && (itemCount == 1);
407 
408  // check whether parent collection allows changing the item
409  const QModelIndexList rows = mItemSelectionModel->selectedRows();
410  if (rows.count() == 1) {
411  const QModelIndex index = rows.first();
412  const auto parentCollection = index.data(EntityTreeModel::ParentCollectionRole).value<Collection>();
413  if (parentCollection.isValid()) {
414  canEditItem = canEditItem && (parentCollection.rights() & Collection::CanChangeItem);
415  }
416  }
417 
418  act->setEnabled(canEditItem);
419  }
420 
421  act = mActions.value(StandardCalendarActionManager::CreateSubTodo);
422  if (act) {
423  act->setEnabled(false);
424  }
425 
426  if (itemCount == 1) {
427  const Akonadi::Item item = mGenericManager->selectedItems().at(0);
428  if (item.isValid() && item.hasPayload<KCalendarCore::Todo::Ptr>()) {
429  if (QAction *actSubTodo = mActions.value(StandardCalendarActionManager::CreateSubTodo)) {
430  actSubTodo->setEnabled(hasWritableCollection(KCalendarCore::Todo::todoMimeType()));
431  }
432  }
433  }
434 
435  Q_EMIT mParent->actionStateUpdated();
436  }
437 
438  void slotCreateEvent()
439  {
440  // dummy as long as there are no editors available in kdepimlibs/
441  }
442 
443  void slotCreateTodo()
444  {
445  // dummy as long as there are no editors available in kdepimlibs/
446  }
447 
448  void slotCreateSubTodo()
449  {
450  // dummy as long as there are no editors available in kdepimlibs/
451  }
452 
453  void slotCreateJournal()
454  {
455  // dummy as long as there are no editors available in kdepimlibs/
456  }
457 
458  void slotEditIncidence()
459  {
460  // dummy as long as there are no editors available in kdepimlibs/
461  }
462 
463  KActionCollection *mActionCollection = nullptr;
464  QWidget *mParentWidget = nullptr;
465  StandardActionManager *mGenericManager = nullptr;
466  QItemSelectionModel *mCollectionSelectionModel = nullptr;
467  QItemSelectionModel *mItemSelectionModel = nullptr;
469  QSet<StandardCalendarActionManager::Type> mInterceptedActions;
470  StandardCalendarActionManager *const mParent;
471 };
472 
474  : QObject(parent)
475  , d(new StandardCalendarActionManagerPrivate(actionCollection, parent, this))
476 {
477 }
478 
480 
482 {
483  d->mCollectionSelectionModel = selectionModel;
484  d->mGenericManager->setCollectionSelectionModel(selectionModel);
485 
486  connect(selectionModel->model(), &QAbstractItemModel::rowsInserted, this, [this]() {
487  d->updateActions();
488  });
489  connect(selectionModel->model(), &QAbstractItemModel::rowsRemoved, this, [this]() {
490  d->updateActions();
491  });
492  connect(selectionModel, &QItemSelectionModel::selectionChanged, this, [this]() {
493  d->updateActions();
494  });
495  d->updateActions();
496 }
497 
499 {
500  d->mItemSelectionModel = selectionModel;
501  d->mGenericManager->setItemSelectionModel(selectionModel);
502 
503  connect(selectionModel, &QItemSelectionModel::selectionChanged, this, [this]() {
504  d->updateActions();
505  });
506 
507  d->updateActions();
508 }
509 
511 {
512  QAction *action = d->mActions.value(type);
513  if (action) {
514  return action;
515  }
516 
517  switch (type) {
518  case CreateEvent:
519  action = new QAction(d->mParentWidget);
520  action->setIcon(QIcon::fromTheme(QStringLiteral("appointment-new")));
521  action->setText(i18n("New E&vent..."));
522  action->setWhatsThis(i18n("Create a new event"));
523  d->mActions.insert(CreateEvent, action);
524  d->mActionCollection->addAction(QStringLiteral("akonadi_event_create"), action);
525  connect(action, &QAction::triggered, this, [this]() {
526  d->slotCreateEvent();
527  });
528  break;
529  case CreateTodo:
530  action = new QAction(d->mParentWidget);
531  action->setIcon(QIcon::fromTheme(QStringLiteral("task-new")));
532  action->setText(i18n("New &To-do..."));
533  action->setWhatsThis(i18n("Create a new To-do"));
534  d->mActions.insert(CreateTodo, action);
535  d->mActionCollection->addAction(QStringLiteral("akonadi_todo_create"), action);
536  connect(action, &QAction::triggered, this, [this]() {
537  d->slotCreateTodo();
538  });
539  break;
540  case CreateSubTodo:
541  action = new QAction(d->mParentWidget);
542  action->setText(i18n("New Su&b-to-do..."));
543  action->setWhatsThis(i18n("Create a new Sub-to-do"));
544  d->mActions.insert(CreateSubTodo, action);
545  d->mActionCollection->addAction(QStringLiteral("akonadi_subtodo_create"), action);
546  connect(action, &QAction::triggered, this, [this]() {
547  d->slotCreateSubTodo();
548  });
549  break;
550  case CreateJournal:
551  action = new QAction(d->mParentWidget);
552  action->setIcon(QIcon::fromTheme(QStringLiteral("journal-new")));
553  action->setText(i18n("New &Journal..."));
554  action->setWhatsThis(i18n("Create a new Journal"));
555  d->mActions.insert(CreateJournal, action);
556  d->mActionCollection->addAction(QStringLiteral("akonadi_journal_create"), action);
557  connect(action, &QAction::triggered, this, [this]() {
558  d->slotCreateJournal();
559  });
560  break;
561  case EditIncidence:
562  action = new QAction(d->mParentWidget);
563  action->setText(i18n("&Edit..."));
564  action->setWhatsThis(i18n("Edit the selected incidence."));
565  d->mActions.insert(EditIncidence, action);
566  d->mActionCollection->addAction(QStringLiteral("akonadi_incidence_edit"), action);
567  connect(action, &QAction::triggered, this, [this]() {
568  d->slotEditIncidence();
569  });
570  break;
571  default:
572  Q_ASSERT(false); // should never happen
573  break;
574  }
575 
576  return action;
577 }
578 
580 {
581  QAction *act = d->mGenericManager->action(type);
582  if (!act) {
583  act = d->mGenericManager->createAction(type);
584  }
585  d->updateGenericAction(type);
586  return act;
587 }
588 
590 {
596 
597  d->mGenericManager->createAllActions();
598  d->updateGenericAllActions();
599  d->updateActions();
600 }
601 
603 {
604  return d->mActions.value(type);
605 }
606 
608 {
609  return d->mGenericManager->action(type);
610 }
611 
613 {
614  d->mGenericManager->setActionText(type, text);
615 }
616 
618 {
619  if (intercept) {
620  d->mInterceptedActions.insert(type);
621  } else {
622  d->mInterceptedActions.remove(type);
623  }
624 }
625 
627 {
628  d->mGenericManager->interceptAction(type, intercept);
629 }
630 
632 {
633  return d->mGenericManager->selectedCollections();
634 }
635 
637 {
638  return d->mGenericManager->selectedItems();
639 }
640 
642 {
643  d->mGenericManager->setContextText(type, context, text);
644 }
645 
647 {
648  d->mGenericManager->setContextText(type, context, text);
649 }
650 
651 void StandardCalendarActionManager::setCollectionPropertiesPageNames(const QStringList &names)
652 {
653  d->mGenericManager->setCollectionPropertiesPageNames(names);
654 }
655 
656 #include "moc_standardcalendaractionmanager.cpp"
bool isValid() const
QAction * action(Type type) const
Returns the action of the given type, 0 if it has not been created (yet).
~StandardCalendarActionManager() override
Destroys the standard calendar action manager.
StandardCalendarActionManager(KActionCollection *actionCollection, QWidget *parent=nullptr)
Creates a new standard calendar action manager.
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
virtual int rowCount(const QModelIndex &parent) const const=0
KLocalizedString KI18N_EXPORT ki18nc(const char *context, const char *text)
const QAbstractItemModel * model() const const
void setItemSelectionModel(QItemSelectionModel *selectionModel)
Sets the item selection model based on which the item related actions should operate.
Akonadi::Collection::List selectedCollections() const
Returns the list of collections that are currently selected.
static QLatin1String todoMimeType()
T value() const const
QIcon fromTheme(const QString &name)
KCALUTILS_EXPORT QString mimeType()
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
bool hasPayload() const
QVariant data(int role) const const
void setIcon(const QIcon &icon)
QString i18n(const char *text, const TYPE &arg...)
KLocalizedString KI18N_EXPORT ki18ncp(const char *context, const char *singular, const char *plural)
QAction * createAction(Type type)
Creates the action of the given type and adds it to the action collection specified in the constructo...
static QLatin1String eventMimeType()
void setText(const QString &text)
KLocalizedString KI18N_EXPORT ki18n(const char *text)
bool isValid() const const
void interceptAction(Type type, bool intercept=true)
Sets whether the default implementation for the given action type shall be executed when the action i...
@ EditIncidence
Edit currently selected event/todo/journal.
void setWhatsThis(const QString &what)
Manages calendar specific actions for collection and item views.
static QLatin1String journalMimeType()
void triggered(bool checked)
void rowsInserted(const QModelIndex &parent, int first, int last)
void setEnabled(bool)
void rowsRemoved(const QModelIndex &parent, int first, int last)
void setActionText(StandardActionManager::Type type, const KLocalizedString &text)
Sets the label of the action type to text, which is used during updating the action state and substit...
void setContextText(StandardActionManager::Type type, StandardActionManager::TextContext context, const QString &text)
Sets the text of the action type for the given context.
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const=0
KLocalizedString KI18N_EXPORT ki18np(const char *singular, const char *plural)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void setCollectionSelectionModel(QItemSelectionModel *selectionModel)
Sets the collection selection model based on which the collection related actions should operate.
void createAllActions()
Convenience method to create all standard actions.
Akonadi::Item::List selectedItems() const
Returns the list of items that are currently selected.
void actionStateUpdated()
This signal is emitted whenever the action state has been updated.
const QAbstractItemModel * model() const const
QString toString() const const
FreeBusyManager::Singleton.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Mon Oct 3 2022 03:53:48 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.