Akonadi Calendar

standardcalendaractionmanager.h
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 #pragma once
10 
11 #include "akonadi-calendar_export.h"
12 
13 #include <AkonadiWidgets/StandardActionManager>
14 #include <kcalendarcore/todo.h>
15 
16 #include <QObject>
17 
18 // needed for windows ce, its defined somewhere
19 #undef CreateEvent
20 
21 class QAction;
22 class KActionCollection;
24 class QWidget;
25 
26 namespace Akonadi
27 {
28 class Item;
29 /**
30  * @short Manages calendar specific actions for collection and item views.
31  *
32  * @author Casey Link <[email protected]>
33  * @since 4.6
34  */
35 class AKONADI_CALENDAR_EXPORT StandardCalendarActionManager : public QObject
36 {
37  Q_OBJECT
38 public:
39  /**
40  * Describes the supported actions.
41  */
42  enum Type {
43  CreateEvent = StandardActionManager::LastType + 1, ///< Creates a new event
44  CreateTodo, ///< Creates a new todo
45  CreateSubTodo, ///< Creates a new sub-todo
46  CreateJournal, ///< Creates a new journal
47  EditIncidence, ///< Edit currently selected event/todo/journal
48  LastType ///< Marks last action
49  };
50 
51  /**
52  * Creates a new standard calendar action manager.
53  *
54  * @param actionCollection The action collection to operate on.
55  * @param parent The parent widget.
56  */
57  explicit StandardCalendarActionManager(KActionCollection *actionCollection, QWidget *parent = nullptr);
58 
59  /**
60  * Destroys the standard calendar action manager.
61  */
63 
64  /**
65  * Sets the collection selection model based on which the collection
66  * related actions should operate. If none is set, all collection actions
67  * will be disabled.
68  * @param selectionModel the selection model for collections
69  */
70  void setCollectionSelectionModel(QItemSelectionModel *selectionModel);
71 
72  /**
73  * Sets the item selection model based on which the item related actions
74  * should operate. If none is set, all item actions will be disabled.
75  * @param selectionModel the selection model for items
76  */
77  void setItemSelectionModel(QItemSelectionModel *selectionModel);
78 
79  /**
80  * Creates the action of the given type and adds it to the action collection
81  * specified in the constructor if it does not exist yet. The action is
82  * connected to its default implementation provided by this class.
83  * @param type the type of action to create
84  */
85  QAction *createAction(Type type);
86 
87  /**
88  * Creates the action of the given type and adds it to the action collection
89  * specified in the constructor if it does not exist yet. The action is
90  * connected to its default implementation provided by this class.
91  * @param type the type of action to create
92  */
93  QAction *createAction(StandardActionManager::Type type);
94 
95  /**
96  * Convenience method to create all standard actions.
97  * @see createAction()
98  */
99  void createAllActions();
100 
101  /**
102  * Returns the action of the given type, 0 if it has not been created (yet).
103  */
104  QAction *action(Type type) const;
105 
106  /**
107  * Returns the action of the given type, 0 if it has not been created (yet).
108  * @param type the type of action to return
109  */
110  QAction *action(StandardActionManager::Type type) const;
111 
112  /**
113  * Sets the label of the action @p type to @p text, which is used during
114  * updating the action state and substituted according to the number of
115  * selected objects. This is mainly useful to customize the label of actions
116  * that can operate on multiple objects.
117  *
118  * Example:
119  * @code
120  * acctMgr->setActionText( Akonadi::StandardActionManager::CopyItems,
121  * ki18np( "Copy Item", "Copy %1 Items" ) );
122  * @endcode
123  */
124  void setActionText(StandardActionManager::Type type, const KLocalizedString &text);
125 
126  /**
127  * Sets whether the default implementation for the given action @p type
128  * shall be executed when the action is triggered.
129  *
130  * @param intercept If @c false, the default implementation will be executed,
131  * if @c true no action is taken.
132  */
133  void interceptAction(Type type, bool intercept = true);
134 
135  /**
136  * Sets whether the default implementation for the given action @p type
137  * shall be executed when the action is triggered.
138  *
139  * @param intercept If @c false, the default implementation will be executed,
140  * if @c true no action is taken.
141  */
142  void interceptAction(StandardActionManager::Type type, bool intercept = true);
143 
144  /**
145  * Returns the list of collections that are currently selected.
146  * The list is empty if no collection is currently selected.
147  */
148  Q_REQUIRED_RESULT Akonadi::Collection::List selectedCollections() const;
149 
150  /**
151  * Returns the list of items that are currently selected.
152  * The list is empty if no item is currently selected.
153  */
154  Q_REQUIRED_RESULT Akonadi::Item::List selectedItems() const;
155 
156  /**
157  * Sets the @p text of the action @p type for the given @p context.
158  */
159  void setContextText(StandardActionManager::Type type, StandardActionManager::TextContext context, const QString &text);
160 
161  /**
162  * Sets the @p text of the action @p type for the given @p context.
163  */
164  void setContextText(StandardActionManager::Type type, StandardActionManager::TextContext context, const KLocalizedString &text);
165 
166  void setCollectionPropertiesPageNames(const QStringList &names);
167 
168 Q_SIGNALS:
169  /**
170  * This signal is emitted whenever the action state has been updated.
171  * In case you have special needs for changing the state of some actions,
172  * connect to this signal and adjust the action state.
173  */
174  void actionStateUpdated();
175 
176 private:
177  //@cond PRIVATE
178  class Private;
179  Private *const d;
180  //@endcond
181 };
182 }
183 
Manages calendar specific actions for collection and item views.
FreeBusyManager::Singleton.
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.