Akonadi Contacts

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

KDE's Doxygen guidelines are available online.