Better wording
[kdepim.git] / kmail / tagactionmanager.h
blob85495f61433b6bc1bc8a26cf942ac31a1a27427c
1 /* Copyright 2010 Thomas McGuire <mcguire@kde.org>
3 Copyright 2011 Laurent Montel <montel@kde.org>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of
8 the License or (at your option) version 3 or any later version
9 accepted by the membership of KDE e.V. (or its successor approved
10 by the membership of KDE e.V.), which shall act as a proxy
11 defined in Section 14 of version 3 of the license.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef TAGACTIONMANAGER_H
22 #define TAGACTIONMANAGER_H
24 #include "kmail_export.h"
25 #include "tag.h"
26 #include <QMap>
28 class KActionCollection;
29 class KXMLGUIClient;
30 class KToggleAction;
31 class QAction;
32 class QSignalMapper;
33 class KAction;
34 namespace Akonadi {
35 class Item;
38 namespace MessageCore {
39 class TagListMonitor;
42 namespace KMail {
44 class MessageActions;
46 /**
47 * Creates actions related to the existing Nepomuk tags and plugs them into the GUI.
49 * The tag manager reads all tags from Nepomuk and adds each to the action collection
50 * and to the message status menu.
51 * For tags that should be in the toolbar, it plugs the action list
52 * toolbar_messagetag_actions.
54 * The actions are automatically updated when a Nepomuk tag changes.
56 class KMAIL_EXPORT TagActionManager : public QObject
58 Q_OBJECT
59 public:
61 /**
62 * Does not take ownership of the action collection, the GUI client or the message actions.
63 * Does not yet create the actions.
65 * @param actionCollection: Each tag action is added here
66 * @param messageActions: Each action is added to the message status menu
67 * @param guiClient: The action list with the toolbar action is plugged here
69 TagActionManager( QObject *parent, KActionCollection *actionCollection,
70 MessageActions *messageActions, KXMLGUIClient *guiClient );
72 ~TagActionManager();
74 /**
75 * Removes all actions from the GUI again
77 void clearActions();
79 /**
80 * Creates and plugs all tag actions
82 void createActions();
84 /**
85 * Updates the state of the toggle actions of all tags.
86 * The state of the action depends on the number of selected messages, for example
87 * all actions are disabled when no message is selected.
89 * @param selectedItem if exactly one item is selected, it should be passed here
91 void updateActionStates( int numberOfSelectedMessages,
92 const Akonadi::Item &selectedItem );
95 Q_SIGNALS:
97 /**
98 * Emitted when one of the tagging actions was triggered. The user of this class
99 * should connect to this signal and change the tags of the messages
101 void tagActionTriggered( const QString &tagLabel );
103 * Emitted when we want to select more action
105 void tagMoreActionClicked();
107 private Q_SLOTS:
108 void tagsChanged();
109 void slotNepomukStarted();
110 void slotNepomukStopped();
111 private:
112 void createTagAction( const KMail::Tag::Ptr &tag, bool addToMenu );
114 KActionCollection *mActionCollection;
115 MessageActions *mMessageActions;
116 QSignalMapper *mMessageTagToggleMapper;
117 KXMLGUIClient *mGUIClient;
118 MessageCore::TagListMonitor *mTagListMonitor;
120 KAction *mSeparatorAction;
121 KAction *mMoreAction;
122 // Maps the resource URI or a tag to the action of a tag.
123 // Contains all existing tags
124 QMap<QString,KToggleAction*> mTagActions;
126 // The actions of all tags that are in the toolbar
127 QList<QAction*> mToolbarActions;
129 // Cache of the tags to avoid expensive Nepomuk queries
130 QList<Tag::Ptr> mTags;
135 #endif