24 #include "standardmailactionmanager.h"
26 #include "emptytrashcommand_p.h"
27 #include "markascommand_p.h"
28 #include "movetotrashcommand_p.h"
29 #include "specialmailcollections.h"
30 #include "removeduplicatesjob.h"
32 #include "akonadi/agentfilterproxymodel.h"
33 #include "akonadi/agentinstance.h"
34 #include "akonadi/agentinstancecreatejob.h"
35 #include "akonadi/agentmanager.h"
36 #include "akonadi/agenttypedialog.h"
37 #include "akonadi/collectionstatistics.h"
38 #include "akonadi/entitytreemodel.h"
39 #include "akonadi/kmime/messagestatus.h"
41 #include "akonadi/mimetypechecker.h"
42 #include "akonadi/subscriptiondialog_p.h"
45 #include <kactioncollection.h>
47 #include <klocalizedstring.h>
48 #include <kmessagebox.h>
49 #include <kmime/kmime_message.h>
51 #include <QtCore/QPointer>
52 #include <QItemSelectionModel>
54 using namespace Akonadi;
56 class StandardMailActionManager::Private
60 : mActionCollection(actionCollection)
61 , mParentWidget(parentWidget)
62 , mCollectionSelectionModel(0)
63 , mItemSelectionModel(0)
66 mGenericManager =
new StandardActionManager(actionCollection, parentWidget);
71 mGenericManager->setMimeTypeFilter(
QStringList() << KMime::Message::mimeType());
77 delete mGenericManager;
80 void updateGenericAllActions()
82 updateGenericAction(StandardActionManager::CreateCollection);
83 updateGenericAction(StandardActionManager::CopyCollections);
84 updateGenericAction(StandardActionManager::DeleteCollections);
85 updateGenericAction(StandardActionManager::SynchronizeCollections);
86 updateGenericAction(StandardActionManager::CollectionProperties);
87 updateGenericAction(StandardActionManager::CopyItems);
88 updateGenericAction(StandardActionManager::Paste);
89 updateGenericAction(StandardActionManager::DeleteItems);
90 updateGenericAction(StandardActionManager::ManageLocalSubscriptions);
91 updateGenericAction(StandardActionManager::AddToFavoriteCollections);
92 updateGenericAction(StandardActionManager::RemoveFromFavoriteCollections);
93 updateGenericAction(StandardActionManager::RenameFavoriteCollection);
94 updateGenericAction(StandardActionManager::CopyCollectionToMenu);
95 updateGenericAction(StandardActionManager::CopyItemToMenu);
96 updateGenericAction(StandardActionManager::MoveItemToMenu);
97 updateGenericAction(StandardActionManager::MoveCollectionToMenu);
98 updateGenericAction(StandardActionManager::CutItems);
99 updateGenericAction(StandardActionManager::CutCollections);
100 updateGenericAction(StandardActionManager::CreateResource);
101 updateGenericAction(StandardActionManager::DeleteResources);
102 updateGenericAction(StandardActionManager::ResourceProperties);
103 updateGenericAction(StandardActionManager::SynchronizeResources);
104 updateGenericAction(StandardActionManager::ToggleWorkOffline);
105 updateGenericAction(StandardActionManager::CopyCollectionToDialog);
106 updateGenericAction(StandardActionManager::MoveCollectionToDialog);
107 updateGenericAction(StandardActionManager::CopyItemToDialog);
108 updateGenericAction(StandardActionManager::MoveItemToDialog);
109 updateGenericAction(StandardActionManager::SynchronizeCollectionsRecursive);
110 updateGenericAction(StandardActionManager::MoveCollectionsToTrash);
111 updateGenericAction(StandardActionManager::MoveItemsToTrash);
112 updateGenericAction(StandardActionManager::RestoreCollectionsFromTrash);
113 updateGenericAction(StandardActionManager::RestoreItemsFromTrash);
114 updateGenericAction(StandardActionManager::MoveToTrashRestoreCollection);
115 updateGenericAction(StandardActionManager::MoveToTrashRestoreCollectionAlternative);
116 updateGenericAction(StandardActionManager::MoveToTrashRestoreItem);
117 updateGenericAction(StandardActionManager::MoveToTrashRestoreItemAlternative);
118 updateGenericAction(StandardActionManager::SynchronizeFavoriteCollections);
120 void updateGenericAction(StandardActionManager::Type type)
123 case Akonadi::StandardActionManager::CreateCollection:
124 mGenericManager->action(Akonadi::StandardActionManager::CreateCollection)->setText(
125 i18n(
"Add Folder..."));
126 mGenericManager->action(Akonadi::StandardActionManager::CreateCollection)->setWhatsThis(
127 i18n(
"Add a new folder to the currently selected account."));
128 mGenericManager->action(Akonadi::StandardActionManager::CreateCollection)->setHelpText(
129 i18n(
"Add a new folder to the currently selected account."));
131 mGenericManager->setContextText(
132 StandardActionManager::CreateCollection, StandardActionManager::DialogTitle,
133 i18nc(
"@title:window",
"New Folder"));
135 mGenericManager->setContextText(
136 StandardActionManager::CreateCollection, StandardActionManager::ErrorMessageText,
137 ki18n(
"Could not create folder: %1"));
139 mGenericManager->setContextText(
140 StandardActionManager::CreateCollection, StandardActionManager::ErrorMessageTitle,
141 i18n(
"Folder creation failed"));
144 case Akonadi::StandardActionManager::CopyCollections:
145 mGenericManager->setActionText(Akonadi::StandardActionManager::CopyCollections,
146 ki18np(
"Copy Folder",
"Copy %1 Folders"));
147 mGenericManager->action(Akonadi::StandardActionManager::CopyCollections)->setWhatsThis(
148 i18n(
"Copy the selected folders to the clipboard."));
149 mGenericManager->action(Akonadi::StandardActionManager::CopyCollections)->setHelpText(
150 i18n(
"Copy the selected folders to the clipboard."));
151 mGenericManager->setContextText(
152 StandardActionManager::CollectionProperties, StandardActionManager::DialogTitle,
153 ki18nc(
"@title:window",
"Properties of Folder %1"));
156 case Akonadi::StandardActionManager::DeleteCollections:
157 mGenericManager->setActionText(Akonadi::StandardActionManager::DeleteCollections,
158 ki18np(
"Delete Folder",
"Delete %1 Folders"));
159 mGenericManager->action(Akonadi::StandardActionManager::DeleteCollections)->setWhatsThis(
160 i18n(
"Delete the selected folders from the account."));
161 mGenericManager->action(Akonadi::StandardActionManager::DeleteCollections)->setHelpText(
162 i18n(
"Delete the selected folders from the account."));
163 mGenericManager->setContextText(
164 StandardActionManager::DeleteCollections, StandardActionManager::MessageBoxText,
165 ki18np(
"Do you really want to delete this folder and all its sub-folders?",
166 "Do you really want to delete %1 folders and all their sub-folders?"));
168 mGenericManager->setContextText(
169 StandardActionManager::DeleteCollections, StandardActionManager::MessageBoxTitle,
170 ki18ncp(
"@title:window",
"Delete folder?",
"Delete folders?"));
172 mGenericManager->setContextText(
173 StandardActionManager::DeleteCollections, StandardActionManager::ErrorMessageText,
174 ki18n(
"Could not delete folder: %1"));
176 mGenericManager->setContextText(
177 StandardActionManager::DeleteCollections, StandardActionManager::ErrorMessageTitle,
178 i18n(
"Folder deletion failed"));
181 case Akonadi::StandardActionManager::SynchronizeCollections:
182 mGenericManager->setActionText(Akonadi::StandardActionManager::SynchronizeCollections,
183 ki18np(
"Update Folder",
"Update Folders"));
185 mGenericManager->action(Akonadi::StandardActionManager::SynchronizeCollections)->setWhatsThis(
186 i18n(
"Update the contents of the selected folders."));
187 mGenericManager->action(Akonadi::StandardActionManager::SynchronizeCollections)->setHelpText(
188 i18n(
"Update the contents of the selected folders."));
190 case Akonadi::StandardActionManager::CutCollections:
191 mGenericManager->setActionText(Akonadi::StandardActionManager::CutCollections,
192 ki18np(
"Cut Folder",
"Cut %1 Folders"));
193 mGenericManager->action(Akonadi::StandardActionManager::CutCollections)->setWhatsThis(
194 i18n(
"Cut the selected folders from the account."));
195 mGenericManager->action(Akonadi::StandardActionManager::CutCollections)->setHelpText(
196 i18n(
"Cut the selected folders from the account."));
198 case Akonadi::StandardActionManager::CollectionProperties:
199 mGenericManager->action(Akonadi::StandardActionManager::CollectionProperties)->setText(
200 i18n(
"Folder Properties..."));
201 mGenericManager->action(Akonadi::StandardActionManager::CollectionProperties)->setWhatsThis(
202 i18n(
"Open a dialog to edit the properties of the selected folder."));
203 mGenericManager->action(Akonadi::StandardActionManager::CollectionProperties)->setHelpText(
204 i18n(
"Open a dialog to edit the properties of the selected folder."));
206 case Akonadi::StandardActionManager::CopyItems:
207 mGenericManager->setActionText(Akonadi::StandardActionManager::CopyItems,
208 ki18np(
"Copy Message",
"Copy %1 Messages"));
209 mGenericManager->action(Akonadi::StandardActionManager::CopyItems)->setWhatsThis(
210 i18n(
"Copy the selected messages to the clipboard."));
211 mGenericManager->action(Akonadi::StandardActionManager::CopyItems)->setHelpText(
212 i18n(
"Copy the selected messages to the clipboard."));
214 case Akonadi::StandardActionManager::DeleteItems:
215 mGenericManager->setActionText(Akonadi::StandardActionManager::DeleteItems,
216 ki18np(
"Delete Message",
"Delete %1 Messages"));
217 mGenericManager->action(Akonadi::StandardActionManager::DeleteItems)->setWhatsThis(
218 i18n(
"Delete the selected messages from the folder."));
219 mGenericManager->action(Akonadi::StandardActionManager::DeleteItems)->setHelpText(
220 i18n(
"Delete the selected messages from the folder."));
221 mGenericManager->setContextText(
222 StandardActionManager::DeleteItems, StandardActionManager::MessageBoxText,
223 ki18np(
"Do you really want to delete the selected message?",
224 "Do you really want to delete %1 messages?"));
226 mGenericManager->setContextText(
227 StandardActionManager::DeleteItems, StandardActionManager::MessageBoxTitle,
228 ki18ncp(
"@title:window",
"Delete Message?",
"Delete Messages?"));
230 mGenericManager->setContextText(
231 StandardActionManager::DeleteItems, StandardActionManager::ErrorMessageText,
232 ki18n(
"Could not delete message: %1"));
234 mGenericManager->setContextText(
235 StandardActionManager::DeleteItems, StandardActionManager::ErrorMessageTitle,
236 i18n(
"Message deletion failed"));
238 case Akonadi::StandardActionManager::CutItems:
239 mGenericManager->setActionText(Akonadi::StandardActionManager::CutItems,
240 ki18np(
"Cut Message",
"Cut %1 Messages"));
241 mGenericManager->action(Akonadi::StandardActionManager::CutItems)->setWhatsThis(
242 i18n(
"Cut the selected message from the folder."));
243 mGenericManager->action(Akonadi::StandardActionManager::CutItems)->setHelpText(
244 i18n(
"Cut the selected message from the folder."));
246 case Akonadi::StandardActionManager::CreateResource:
247 mGenericManager->action(Akonadi::StandardActionManager::CreateResource)->setText(
248 i18n(
"Add &Account..."));
249 mGenericManager->action(Akonadi::StandardActionManager::CreateResource)->setWhatsThis(
250 i18n(
"Add a new account<p>"
251 "You will be presented with a dialog where you can select "
252 "the type of the account that shall be added.</p>"));
253 mGenericManager->setContextText(
254 StandardActionManager::CreateResource, StandardActionManager::DialogTitle,
255 i18nc(
"@title:window",
"Add Account"));
257 mGenericManager->setContextText(
258 StandardActionManager::CreateResource, StandardActionManager::ErrorMessageText,
259 ki18n(
"Could not create account: %1"));
261 mGenericManager->setContextText(
262 StandardActionManager::CreateResource, StandardActionManager::ErrorMessageTitle,
263 i18n(
"Account creation failed"));
265 case Akonadi::StandardActionManager::DeleteResources:
266 mGenericManager->setActionText(Akonadi::StandardActionManager::DeleteResources,
267 ki18np(
"&Delete Account",
"&Delete %1 Accounts"));
268 mGenericManager->action(Akonadi::StandardActionManager::DeleteResources)->setWhatsThis(
269 i18n(
"Delete the selected accounts<p>"
270 "The currently selected accounts will be deleted, "
271 "along with all the messages they contain.</p>"));
272 mGenericManager->setContextText(
273 StandardActionManager::DeleteResources, StandardActionManager::MessageBoxText,
274 ki18np(
"Do you really want to delete this account?",
275 "Do you really want to delete %1 accounts?"));
277 mGenericManager->setContextText(
278 StandardActionManager::DeleteResources, StandardActionManager::MessageBoxTitle,
279 ki18ncp(
"@title:window",
"Delete Account?",
"Delete Accounts?"));
281 case Akonadi::StandardActionManager::ResourceProperties:
282 mGenericManager->action(Akonadi::StandardActionManager::ResourceProperties)->setText(
283 i18n(
"Account Properties..."));
284 mGenericManager->action(Akonadi::StandardActionManager::ResourceProperties)->setWhatsThis(
285 i18n(
"Open a dialog to edit properties of the selected account."));
287 case Akonadi::StandardActionManager::SynchronizeResources:
288 mGenericManager->setActionText(Akonadi::StandardActionManager::SynchronizeResources,
289 ki18np(
"Update Account",
"Update %1 Accounts"));
290 mGenericManager->action(Akonadi::StandardActionManager::SynchronizeResources)->setWhatsThis(
291 i18n(
"Updates the content of all folders of the selected accounts."));
294 case Akonadi::StandardActionManager::SynchronizeCollectionsRecursive:
296 mGenericManager->setActionText(Akonadi::StandardActionManager::SynchronizeCollectionsRecursive,
297 ki18np(
"Update This Folder and All Its Subfolders",
298 "Update These Folders and All Their Subfolders"));
300 mGenericManager->action(Akonadi::StandardActionManager::SynchronizeCollectionsRecursive)->setWhatsThis(
301 i18n(
"Update the contents of the selected folders and all their subfolders."));
302 mGenericManager->action(Akonadi::StandardActionManager::SynchronizeCollectionsRecursive)->setHelpText(
303 i18n(
"Update the contents of the selected folders and all their subfolders."));
305 case Akonadi::StandardActionManager::Paste:
306 mGenericManager->setContextText(
307 StandardActionManager::Paste, StandardActionManager::ErrorMessageText,
308 ki18n(
"Could not paste message: %1"));
310 mGenericManager->setContextText(
311 StandardActionManager::Paste, StandardActionManager::ErrorMessageTitle,
312 i18n(
"Paste failed"));
322 const Akonadi::Item::List
selectedItems = mGenericManager->selectedItems();
323 const Akonadi::Collection::List
selectedCollections = mGenericManager->selectedCollections();
325 bool itemIsSelected = !selectedItems.isEmpty();
326 bool collectionIsSelected = !selectedCollections.isEmpty();
328 if (itemIsSelected) {
329 bool allMarkedAsImportant =
true;
330 bool allMarkedAsRead =
true;
331 bool allMarkedAsUnread =
true;
332 bool allMarkedAsActionItem =
true;
334 foreach (
const Akonadi::Item &item, selectedItems) {
338 allMarkedAsImportant =
false;
341 allMarkedAsRead =
false;
343 allMarkedAsUnread =
false;
346 allMarkedAsActionItem =
false;
352 updateMarkAction(action, allMarkedAsRead);
353 if (allMarkedAsRead) {
362 updateMarkAction(action, allMarkedAsUnread);
363 if (allMarkedAsUnread) {
373 updateMarkAction(action, allMarkedAsImportant);
374 if (allMarkedAsImportant) {
375 action->
setText(i18n(
"Remove Important Mark"));
378 action->
setText(i18n(
"&Mark Mail as Important"));
387 updateMarkAction(action, allMarkedAsActionItem);
388 if (allMarkedAsActionItem) {
389 action->
setText(i18n(
"Remove Action Item Mark"));
392 action->
setText(i18n(
"&Mark Mail as Action Item"));
414 bool enableMarkAllAsRead =
false;
415 bool enableMarkAllAsUnread =
false;
416 bool canDeleteItem =
true;
417 bool isSystemFolder =
false;
418 if (collectionIsSelected) {
419 foreach (
const Collection &collection, selectedCollections) {
420 if (collection.isValid()) {
421 const Akonadi::CollectionStatistics stats = collection.statistics();
422 if (!enableMarkAllAsRead) {
423 enableMarkAllAsRead = (stats.unreadCount() > 0);
425 if (!enableMarkAllAsUnread) {
426 enableMarkAllAsUnread = (stats.count() != stats.unreadCount());
429 canDeleteItem = collection.rights() & Akonadi::Collection::CanDeleteItem;
431 if (!isSystemFolder) {
440 if (enableMarkAllAsRead && enableMarkAllAsUnread && !canDeleteItem && isSystemFolder) {
446 if (isSystemFolder) {
447 if (mGenericManager->action(StandardActionManager::DeleteCollections)) {
448 mGenericManager->action(StandardActionManager::DeleteCollections)->setEnabled(
false);
469 emit mParent->actionStateUpdated();
472 void updateMarkAction(
QAction *action,
bool allMarked)
489 const QAction *action = qobject_cast<
QAction *>(mParent->sender());
492 const Akonadi::Item::List items = mGenericManager->selectedItems();
493 if (items.isEmpty()) {
498 kDebug() <<
"Mark mail as: " << typeStr;
503 typeStr = typeStr.
mid(1);
510 if (typeStr ==
"U") {
514 }
else if (typeStr ==
"K") {
516 }
else if (typeStr ==
"G") {
520 if (mInterceptedActions.contains(type)) {
524 MarkAsCommand *command =
new MarkAsCommand(targetStatus, items, invert, mParent);
530 const QAction *action = qobject_cast<
QAction *>(mParent->sender());
534 kDebug() <<
"Mark all as: " << typeStr;
536 const Akonadi::Collection::List collections = mGenericManager->selectedCollections();
537 if (collections.isEmpty()) {
547 typeStr = typeStr.
mid(1);
551 if (typeStr ==
"U") {
555 }
else if (typeStr ==
"K") {
557 }
else if (typeStr ==
"G") {
561 if (mInterceptedActions.contains(type)) {
565 MarkAsCommand *command =
new MarkAsCommand(targetStatus, collections, invert, mParent);
569 void slotMoveToTrash()
575 if (mCollectionSelectionModel->selection().indexes().isEmpty()) {
579 const Item::List items = mGenericManager->selectedItems();
580 if (items.isEmpty()) {
584 MoveToTrashCommand *command =
new MoveToTrashCommand(mCollectionSelectionModel->model(), items, mParent);
588 void slotMoveAllToTrash()
594 if (mCollectionSelectionModel->selection().indexes().isEmpty()) {
598 const Collection::List collections = mGenericManager->selectedCollections();
599 if (collections.isEmpty()) {
603 MoveToTrashCommand *command =
new MoveToTrashCommand(mCollectionSelectionModel->model(), collections, mParent);
607 void slotRemoveDuplicates()
613 const Collection::List collections = mGenericManager->selectedCollections();
614 if (collections.isEmpty()) {
619 connect(job, SIGNAL(finished(KJob*)), mParent, SLOT(slotJobFinished(KJob*)));
622 void slotJobFinished(KJob *job)
625 Util::showJobError(job);
629 void slotEmptyAllTrash()
635 EmptyTrashCommand *command =
new EmptyTrashCommand(const_cast<QAbstractItemModel *>(mCollectionSelectionModel->model()), mParent);
639 void slotEmptyTrash()
645 if (mCollectionSelectionModel->selection().indexes().isEmpty()) {
649 const Collection::List collections = mGenericManager->selectedCollections();
650 if (collections.count() != 1) {
654 EmptyTrashCommand *command =
new EmptyTrashCommand(collections.first(), mParent);
658 KActionCollection *mActionCollection;
660 StandardActionManager *mGenericManager;
670 , d(new Private(actionCollection, parent, this))
681 d->mCollectionSelectionModel = selectionModel;
682 d->mGenericManager->setCollectionSelectionModel(selectionModel);
685 SLOT(updateActions()));
687 SLOT(updateActions()));
689 SLOT(updateActions()));
696 d->mItemSelectionModel = selectionModel;
697 d->mGenericManager->setItemSelectionModel(selectionModel);
700 SLOT(updateActions()));
704 SLOT(updateActions()));
711 if (d->mActions.contains(type)) {
712 return d->mActions.value(type);
719 action =
new KAction(d->mParentWidget);
721 action->setText(i18n(
"&Mark Message as Read"));
722 action->setIconText(i18n(
"Mark as Read"));
723 action->setHelpText(i18n(
"Mark selected messages as read."));
724 action->setWhatsThis(i18n(
"Mark selected messages as read."));
728 action->setShortcut(Qt::CTRL + Qt::Key_R);
729 connect(action, SIGNAL(triggered(
bool)),
this, SLOT(slotMarkAs()));
732 action =
new KAction(d->mParentWidget);
734 action->setText(i18n(
"&Mark Message as Unread"));
735 action->setIconText(i18n(
"Mark as Unread"));
736 action->setHelpText(i18n(
"Mark selected messages as unread."));
737 action->setWhatsThis(i18n(
"Mark selected messages as unread."));
740 action->setShortcut(Qt::CTRL + Qt::Key_U);
742 connect(action, SIGNAL(triggered(
bool)),
this, SLOT(slotMarkAs()));
745 action =
new KAction(d->mParentWidget);
746 action->setIcon(KIcon(
QLatin1String(
"mail-mark-important")));
747 action->setText(i18n(
"&Mark Message as Important"));
748 action->setIconText(i18n(
"Mark as Important"));
749 action->setHelpText(i18n(
"Mark selected messages as important."));
754 connect(action, SIGNAL(triggered(
bool)),
this, SLOT(slotMarkAs()));
757 action =
new KAction(d->mParentWidget);
759 action->setText(i18n(
"&Mark Message as Action Item"));
760 action->setIconText(i18n(
"Mark as Action Item"));
761 action->setHelpText(i18n(
"Mark selected messages as action items."));
762 action->setWhatsThis(i18n(
"Mark selected messages as action items."));
764 d->mActionCollection->addAction(
QString::fromLatin1(
"akonadi_mark_as_action_item"), action);
766 connect(action, SIGNAL(triggered(
bool)),
this, SLOT(slotMarkAs()));
769 action =
new KAction(d->mParentWidget);
771 action->setText(i18n(
"Mark &All Messages as Read"));
772 action->setIconText(i18n(
"Mark All as Read"));
773 action->setHelpText(i18n(
"Mark all messages as read."));
774 action->setWhatsThis(i18n(
"Mark all messages as read."));
778 connect(action, SIGNAL(triggered(
bool)),
this, SLOT(slotMarkAllAs()));
781 action =
new KAction(d->mParentWidget);
783 action->setText(i18n(
"Mark &All Messages as Unread"));
784 action->setIconText(i18n(
"Mark All as Unread"));
785 action->setHelpText(i18n(
"Mark all messages as unread."));
786 action->setWhatsThis(i18n(
"Mark all messages as unread."));
788 d->mActionCollection->addAction(
QString::fromLatin1(
"akonadi_mark_all_as_unread"), action);
790 connect(action, SIGNAL(triggered(
bool)),
this, SLOT(slotMarkAllAs()));
793 action =
new KAction(d->mParentWidget);
794 action->setIcon(KIcon(
QLatin1String(
"mail-mark-important")));
795 action->setText(i18n(
"Mark &All Messages as Important"));
796 action->setIconText(i18n(
"Mark All as Important"));
797 action->setHelpText(i18n(
"Mark all messages as important."));
798 action->setWhatsThis(i18n(
"Mark all messages as important."));
800 d->mActionCollection->addAction(
QString::fromLatin1(
"akonadi_mark_all_as_important"), action);
802 connect(action, SIGNAL(triggered(
bool)),
this, SLOT(slotMarkAllAs()));
805 action =
new KAction(d->mParentWidget);
806 action->setIconText(i18n(
"Mark All as Action Item"));
807 action->setText(i18n(
"Mark &All Messages as Action Item"));
809 action->setHelpText(i18n(
"Mark all messages as action items."));
810 action->setWhatsThis(i18n(
"Mark all messages as action items."));
812 d->mActionCollection->addAction(
QString::fromLatin1(
"akonadi_mark_all_as_action_item"), action);
814 connect(action, SIGNAL(triggered(
bool)),
this, SLOT(slotMarkAllAs()));
817 action =
new KAction(d->mParentWidget);
819 action->setText(i18n(
"Move to &Trash"));
821 action->setHelpText(i18n(
"Move selected messages to the trash folder."));
822 action->setWhatsThis(i18n(
"Move selected messages to the trash folder."));
825 connect(action, SIGNAL(triggered(
bool)),
this, SLOT(slotMoveToTrash()));
828 action =
new KAction(d->mParentWidget);
830 action->setText(i18n(
"Move All to &Trash"));
831 action->setHelpText(i18n(
"Move all messages to the trash folder."));
832 action->setWhatsThis(i18n(
"Move all messages to the trash folder."));
835 connect(action, SIGNAL(triggered(
bool)),
this, SLOT(slotMoveAllToTrash()));
838 action =
new KAction(d->mParentWidget);
839 action->setText(i18n(
"Remove &Duplicate Messages"));
840 action->setHelpText(i18n(
"Remove duplicate messages."));
841 action->setWhatsThis(i18n(
"Remove duplicate messages."));
842 action->setShortcut(
QKeySequence(Qt::CTRL + Qt::Key_Asterisk));
845 connect(action, SIGNAL(triggered(
bool)),
this, SLOT(slotRemoveDuplicates()));
848 action =
new KAction(d->mParentWidget);
849 action->setText(i18n(
"Empty All &Trash Folders"));
850 action->setHelpText(i18n(
"Permanently delete all messages from all trash folders."));
851 action->setWhatsThis(i18n(
"Permanently delete all messages from all trash folders."));
854 connect(action, SIGNAL(triggered(
bool)),
this, SLOT(slotEmptyAllTrash()));
857 action =
new KAction(d->mParentWidget);
858 action->setText(i18n(
"E&mpty Trash"));
859 action->setHelpText(i18n(
"Permanently delete all messages from the trash folder."));
860 action->setWhatsThis(i18n(
"Permanently delete all messages from the trash folder."));
863 connect(action, SIGNAL(triggered(
bool)),
this, SLOT(slotEmptyTrash()));
875 KAction *act = d->mGenericManager->action(type);
877 act = d->mGenericManager->createAction(type);
879 d->updateGenericAction(type);
899 d->mGenericManager->createAllActions();
900 d->updateGenericAllActions();
907 if (d->mActions.contains(type)) {
908 return d->mActions.value(type);
916 return d->mGenericManager->action(type);
921 d->mGenericManager->setActionText(type, text);
927 d->mInterceptedActions.insert(type);
929 d->mInterceptedActions.remove(type);
935 d->mGenericManager->interceptAction(type, intercept);
940 return d->mGenericManager->selectedCollections();
945 return d->mGenericManager->selectedItems();
950 d->mGenericManager->setFavoriteCollectionsModel(favoritesModel);
955 d->mGenericManager->setFavoriteSelectionModel(selectionModel);
958 void StandardMailActionManager::setCollectionPropertiesPageNames(
const QStringList &names)
960 d->mGenericManager->setCollectionPropertiesPageNames(names);
963 Akonadi::StandardActionManager *StandardMailActionManager::standardActionManager()
const
965 return d->mGenericManager;
968 #include "moc_standardmailactionmanager.cpp"
void setText(const QString &text)
Marks a mail as action item.
void createAllActions()
Convenience method to create all standard actions.
QByteArray toByteArray() const
void setRead(bool read=true)
Set the status to read.
Marks a mail as important.
The templates collection.
Akonadi::Item::List selectedItems() const
Returns the list of items that are currently selected.
void interceptAction(Type type, bool intercept=true)
Sets whether the default implementation for the given action type shall be executed when the action i...
bool startsWith(const QByteArray &ba) const
Marks all mails in a folder as unread.
Move all selected messages and folders to trash.
void actionStateUpdated()
This signal is emitted whenever the action state has been updated.
KAction * createAction(Type type)
Creates the action of the given type and adds it to the action collection specified in the constructo...
void setStatusFromFlags(const QSet< QByteArray > &flags)
Set the status as a whole e.g.
void setItemSelectionModel(QItemSelectionModel *selectionModel)
Sets the item selection model based on which the item related actions should operate.
Type
Describes the supported actions.
The sent-mail collection.
QByteArray & prepend(char ch)
bool isToAct() const
Check for ToAct status.
void setFavoriteCollectionsModel(FavoriteCollectionsModel *favoritesModel)
Sets the favorite collections model based on which the collection relatedactions should operate...
Akonadi::Collection::List selectedCollections() const
Returns the list of collections that are currently selected.
QByteArray mid(int pos, int len) const
static SpecialMailCollections * self()
Returns the global SpecialMailCollections instance.
void setData(const QVariant &userData)
Empties the trash folder, if a trash folder was selected.
KAction * action(Type type) const
Returns the action of the given type, 0 if it has not been created (yet).
Marks all mails in a folder as important.
StandardMailActionManager(KActionCollection *actionCollection, QWidget *parent=0)
Creates a new standard mail action manager.
Manages emails specific actions for collection and item views.
Marks all mails in a folder as action item.
Job that finds and removes duplicate messages in given collection.
void setActionText(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...
Akonadi KMime Message Status.
~StandardMailActionManager()
Destroys the standard mail action manager.
QString fromLatin1(const char *str, int size)
Empties trash folders on all accounts.
Akonadi::Collection defaultCollection(Type type) const
Returns the special mail collection of given type in the default resource, or an invalid collection i...
void setFavoriteSelectionModel(QItemSelectionModel *selectionModel)
Sets the favorite collection selection model based on which the favorite collection related actions s...
void setStatusFromStr(const QString &aStr)
Set the status based on a string representation.
Removes all duplicated messages.
Move all messages of the current folder to trash.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Marks all mails in a folder as read.
const QAbstractItemModel * model() const
void setCollectionSelectionModel(QItemSelectionModel *selectionModel)
Sets the collection selection model based on which the collection related actions should operate...
bool isRead() const
Check for Read status.
bool isImportant() const
Check for Important status.