Akonadi Contacts

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

KDE's Doxygen guidelines are available online.