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{
37
38public:
39 /**
40 * Describes the supported actions.
41 */
42 enum Type {
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 */
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 */
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 */
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 */
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 */
159
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}
QList< Collection > List
QList< Item > List
Manages contact specific actions for collection and item views.
@ EditItem
Edits the selected contact resp. contact group.
void setCollectionPropertiesPageNames(const QStringList &names)
StandardContactActionManager(KActionCollection *actionCollection, QWidget *parent=nullptr)
Creates a new standard contact action manager.
QAction * action(Type type) const
Returns the action of the given type, 0 if it has not been created (yet).
void setCollectionSelectionModel(QItemSelectionModel *selectionModel)
Sets the collection selection model based on which the collection related actions should operate.
Akonadi::Item::List selectedItems() const
Returns the list of items that are currently selected.
Akonadi::Collection::List selectedCollections() const
Returns the list of collections that are currently selected.
void actionStateUpdated()
This signal is emitted whenever the action state has been updated.
void createAllActions()
Convenience method to create all standard actions.
~StandardContactActionManager() override
Destroys the standard contact action manager.
QAction * createAction(Type type)
Creates the action of the given type and adds it to the action collection specified in the constructo...
void setItemSelectionModel(QItemSelectionModel *selectionModel)
Sets the item selection model based on which the item related actions should operate.
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 setActionText(Akonadi::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...
A widget for editing the display name of a contact.
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:55:33 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.