Akonadi Calendar

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

KDE's Doxygen guidelines are available online.