1 /* Copyright 2010 Thomas McGuire <mcguire@kde.org>
3 This program is free software; you can redistribute it and/or
4 modify it under the terms of the GNU General Public License as
5 published by the Free Software Foundation; either version 2 of
6 the License or (at your option) version 3 or any later version
7 accepted by the membership of KDE e.V. (or its successor approved
8 by the membership of KDE e.V.), which shall act as a proxy
9 defined in Section 14 of version 3 of the license.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef TAGACTIONMANAGER_H
20 #define TAGACTIONMANAGER_H
22 #include "kmail_export.h"
24 #include <Soprano/Statement>
26 class KActionCollection
;
38 class SignalCacheModel
;
42 namespace MessageCore
{
51 * Creates actions related to the existing Nepomuk tags and plugs them into the GUI.
53 * The tag manager reads all tags from Nepomuk and adds each to the action collection
54 * and to the message status menu.
55 * For tags that should be in the toolbar, it plugs the action list
56 * toolbar_messagetag_actions.
58 * The actions are automatically updated when a Nepomuk tag changes.
60 class KMAIL_EXPORT TagActionManager
: public QObject
66 * Does not take ownership of the action collection, the GUI client or the message actions.
67 * Does not yet create the actions.
69 * @param actionCollection: Each tag action is added here
70 * @param messageActions: Each action is added to the message status menu
71 * @param guiClient: The action list with the toolbar action is plugged here
73 TagActionManager( QObject
*parent
, KActionCollection
*actionCollection
,
74 MessageActions
*messageActions
, KXMLGUIClient
*guiClient
);
79 * Removes all actions from the GUI again
84 * Creates and plugs all tag actions
89 * Updates the state of the toggle actions of all tags.
90 * The state of the action depends on the number of selected messages, for example
91 * all actions are disabled when no message is selected.
93 * @param selectedItem if exactly one item is selected, it should be passed here
95 void updateActionStates( int numberOfSelectedMessages
,
96 const Akonadi::Item
&selectedItem
);
102 * Emitted when one of the tagging actions was triggered. The user of this class
103 * should connect to this signal and change the tags of the messages
105 void tagActionTriggered( const QString
&tagLabel
);
110 void statementChanged( Soprano::Statement statement
);
114 KActionCollection
*mActionCollection
;
115 MessageActions
*mMessageActions
;
116 QSignalMapper
*mMessageTagToggleMapper
;
117 KXMLGUIClient
*mGUIClient
;
118 MessageCore::TagListMonitor
*mTagListMonitor
;
120 // Maps the resource URI or a tag to the action of a tag.
121 // Contains all existing tags
122 QMap
<QString
,KToggleAction
*> mTagActions
;
124 // The actions of all tags that are in the toolbar
125 QList
<QAction
*> mToolbarActions
;
127 // Needed so we can listen to Nepomuk Tag changes
128 QScopedPointer
<Soprano::Util::SignalCacheModel
> mSopranoModel
;