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

KDE's Doxygen guidelines are available online.