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 <kmessagebox.h>
48 #include <kmime/kmime_message.h>
50 #include <QtCore/QPointer>
51 #include <QItemSelectionModel>
53 using namespace Akonadi;
55 class StandardMailActionManager::Private
59 : mActionCollection( actionCollection ),
60 mParentWidget( parentWidget ),
61 mCollectionSelectionModel( 0 ),
62 mItemSelectionModel( 0 ),
65 mGenericManager =
new StandardActionManager( actionCollection, parentWidget );
71 mGenericManager->setMimeTypeFilter( QStringList() << KMime::Message::mimeType() );
72 mGenericManager->setCapabilityFilter( QStringList() << QLatin1String(
"Resource" ) );
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->setContextText(
129 StandardActionManager::CreateCollection, StandardActionManager::DialogTitle,
130 i18nc(
"@title:window",
"New Folder" ) );
132 mGenericManager->setContextText(
133 StandardActionManager::CreateCollection, StandardActionManager::ErrorMessageText,
134 ki18n(
"Could not create folder: %1" ) );
136 mGenericManager->setContextText(
137 StandardActionManager::CreateCollection, StandardActionManager::ErrorMessageTitle,
138 i18n(
"Folder creation failed" ) );
141 case Akonadi::StandardActionManager::CopyCollections:
142 mGenericManager->setActionText( Akonadi::StandardActionManager::CopyCollections,
143 ki18np(
"Copy Folder",
"Copy %1 Folders" ) );
144 mGenericManager->action( Akonadi::StandardActionManager::CopyCollections )->setWhatsThis(
145 i18n(
"Copy the selected folders to the clipboard." ) );
146 mGenericManager->setContextText(
147 StandardActionManager::CollectionProperties, StandardActionManager::DialogTitle,
148 ki18nc(
"@title:window",
"Properties of Folder %1" ) );
151 case Akonadi::StandardActionManager::DeleteCollections:
152 mGenericManager->setActionText( Akonadi::StandardActionManager::DeleteCollections,
153 ki18np(
"Delete Folder",
"Delete %1 Folders" ) );
154 mGenericManager->action( Akonadi::StandardActionManager::DeleteCollections )->setWhatsThis(
155 i18n(
"Delete the selected folders from the account." ) );
156 mGenericManager->setContextText(
157 StandardActionManager::DeleteCollections, StandardActionManager::MessageBoxText,
158 ki18np(
"Do you really want to delete this folder and all its sub-folders?",
159 "Do you really want to delete %1 folders and all their sub-folders?" ) );
161 mGenericManager->setContextText(
162 StandardActionManager::DeleteCollections, StandardActionManager::MessageBoxTitle,
163 ki18ncp(
"@title:window",
"Delete folder?",
"Delete folders?" ) );
165 mGenericManager->setContextText(
166 StandardActionManager::DeleteCollections, StandardActionManager::ErrorMessageText,
167 ki18n(
"Could not delete folder: %1" ) );
169 mGenericManager->setContextText(
170 StandardActionManager::DeleteCollections, StandardActionManager::ErrorMessageTitle,
171 i18n(
"Folder deletion failed" ) );
174 case Akonadi::StandardActionManager::SynchronizeCollections:
175 mGenericManager->setActionText( Akonadi::StandardActionManager::SynchronizeCollections,
176 ki18np(
"Update Folder",
"Update Folders" ) );
178 mGenericManager->action( Akonadi::StandardActionManager::SynchronizeCollections )->setWhatsThis(
179 i18n(
"Update the content of the selected folders." ) );
181 case Akonadi::StandardActionManager::CutCollections:
182 mGenericManager->setActionText( Akonadi::StandardActionManager::CutCollections,
183 ki18np(
"Cut Folder",
"Cut %1 Folders" ) );
184 mGenericManager->action( Akonadi::StandardActionManager::CutCollections )->setWhatsThis(
185 i18n(
"Cut the selected folders from the account." ) );
187 case Akonadi::StandardActionManager::CollectionProperties:
188 mGenericManager->action( Akonadi::StandardActionManager::CollectionProperties )->setText(
189 i18n(
"Folder Properties..." ) );
190 mGenericManager->action( Akonadi::StandardActionManager::CollectionProperties)->setWhatsThis(
191 i18n(
"Open a dialog to edit the properties of the selected folder." ) );
193 case Akonadi::StandardActionManager::CopyItems:
194 mGenericManager->setActionText( Akonadi::StandardActionManager::CopyItems,
195 ki18np(
"Copy Email",
"Copy %1 Emails" ) );
196 mGenericManager->action( Akonadi::StandardActionManager::CopyItems )->setWhatsThis(
197 i18n(
"Copy the selected emails to the clipboard." ) );
199 case Akonadi::StandardActionManager::DeleteItems:
200 mGenericManager->setActionText( Akonadi::StandardActionManager::DeleteItems,
201 ki18np(
"Delete Email",
"Delete %1 Emails" ) );
202 mGenericManager->action( Akonadi::StandardActionManager::DeleteItems )->setWhatsThis(
203 i18n(
"Delete the selected emails from the folder." ) );
204 mGenericManager->setContextText(
205 StandardActionManager::DeleteItems, StandardActionManager::MessageBoxText,
206 ki18np(
"Do you really want to delete the selected email?",
207 "Do you really want to delete %1 emails?" ) );
209 mGenericManager->setContextText(
210 StandardActionManager::DeleteItems, StandardActionManager::MessageBoxTitle,
211 ki18ncp(
"@title:window",
"Delete Email?",
"Delete Emails?" ) );
213 mGenericManager->setContextText(
214 StandardActionManager::DeleteItems, StandardActionManager::ErrorMessageText,
215 ki18n(
"Could not delete email: %1" ) );
217 mGenericManager->setContextText(
218 StandardActionManager::DeleteItems, StandardActionManager::ErrorMessageTitle,
219 i18n(
"Email deletion failed" ) );
221 case Akonadi::StandardActionManager::CutItems:
222 mGenericManager->setActionText( Akonadi::StandardActionManager::CutItems,
223 ki18np(
"Cut Email",
"Cut %1 Emails" ) );
224 mGenericManager->action( Akonadi::StandardActionManager::CutItems )->setWhatsThis(
225 i18n(
"Cut the selected emails from the folder." ) );
227 case Akonadi::StandardActionManager::CreateResource:
228 mGenericManager->action( Akonadi::StandardActionManager::CreateResource )->setText(
229 i18n(
"Add &Account..." ) );
230 mGenericManager->action( Akonadi::StandardActionManager::CreateResource )->setWhatsThis(
231 i18n(
"Add a new account<p>"
232 "You will be presented with a dialog where you can select "
233 "the type of the account that shall be added.</p>" ) );
234 mGenericManager->setContextText(
235 StandardActionManager::CreateResource, StandardActionManager::DialogTitle,
236 i18nc(
"@title:window",
"Add Account" ) );
238 mGenericManager->setContextText(
239 StandardActionManager::CreateResource, StandardActionManager::ErrorMessageText,
240 ki18n(
"Could not create account: %1" ) );
242 mGenericManager->setContextText(
243 StandardActionManager::CreateResource, StandardActionManager::ErrorMessageTitle,
244 i18n(
"Account creation failed" ) );
246 case Akonadi::StandardActionManager::DeleteResources:
247 mGenericManager->setActionText( Akonadi::StandardActionManager::DeleteResources,
248 ki18np(
"&Delete Account",
"&Delete %1 Accounts" ) );
249 mGenericManager->action( Akonadi::StandardActionManager::DeleteResources )->setWhatsThis(
250 i18n(
"Delete the selected accounts<p>"
251 "The currently selected accounts will be deleted, "
252 "along with all the emails they contain.</p>" ) );
253 mGenericManager->setContextText(
254 StandardActionManager::DeleteResources, StandardActionManager::MessageBoxText,
255 ki18np(
"Do you really want to delete this account?",
256 "Do you really want to delete %1 accounts?" ) );
258 mGenericManager->setContextText(
259 StandardActionManager::DeleteResources, StandardActionManager::MessageBoxTitle,
260 ki18ncp(
"@title:window",
"Delete Account?",
"Delete Accounts?" ) );
262 case Akonadi::StandardActionManager::ResourceProperties:
263 mGenericManager->action( Akonadi::StandardActionManager::ResourceProperties )->setText(
264 i18n(
"Account Properties..." ) );
265 mGenericManager->action( Akonadi::StandardActionManager::ResourceProperties )->setWhatsThis(
266 i18n(
"Open a dialog to edit properties of the selected account." ) );
268 case Akonadi::StandardActionManager::SynchronizeResources:
269 mGenericManager->setActionText( Akonadi::StandardActionManager::SynchronizeResources,
270 ki18np(
"Update Account",
"Update %1 Accounts" ) );
271 mGenericManager->action( Akonadi::StandardActionManager::SynchronizeResources )->setWhatsThis(
272 i18n(
"Updates the content of all folders of the selected accounts." ) );
275 case Akonadi::StandardActionManager::SynchronizeCollectionsRecursive:
277 mGenericManager->setActionText( Akonadi::StandardActionManager::SynchronizeCollectionsRecursive,
278 ki18np(
"Update folder and its subfolders",
"Update folders and their subfolders" ) );
280 mGenericManager->action( Akonadi::StandardActionManager::SynchronizeCollectionsRecursive )->setWhatsThis(
281 i18n(
"Update the content of the selected folders and their subfolders." ) );
283 case Akonadi::StandardActionManager::Paste:
284 mGenericManager->setContextText(
285 StandardActionManager::Paste, StandardActionManager::ErrorMessageText,
286 ki18n(
"Could not paste email: %1" ) );
288 mGenericManager->setContextText(
289 StandardActionManager::Paste, StandardActionManager::ErrorMessageTitle,
290 i18n(
"Paste failed" ) );
300 const Akonadi::Item::List
selectedItems = mGenericManager->selectedItems();
301 const Akonadi::Collection::List
selectedCollections = mGenericManager->selectedCollections();
303 bool itemIsSelected = !selectedItems.isEmpty();
304 bool collectionIsSelected = !selectedCollections.isEmpty();
306 if ( itemIsSelected ) {
307 bool allMarkedAsImportant =
true;
308 bool allMarkedAsRead =
true;
309 bool allMarkedAsUnread =
true;
310 bool allMarkedAsActionItem =
true;
312 foreach (
const Akonadi::Item &item, selectedItems ) {
316 allMarkedAsImportant =
false;
319 allMarkedAsRead=
false;
321 allMarkedAsUnread =
false;
324 allMarkedAsActionItem =
false;
330 updateMarkAction( action, allMarkedAsRead );
331 if ( allMarkedAsRead ) {
332 action->setEnabled(
false );
334 action->setEnabled(
true );
340 updateMarkAction( action, allMarkedAsUnread );
341 if ( allMarkedAsUnread ) {
342 action->setEnabled(
false );
344 action->setEnabled(
true );
350 updateMarkAction( action, allMarkedAsImportant );
351 if ( allMarkedAsImportant ) {
352 action->setText( i18n(
"Remove Important Mark" ) );
354 action->setText( i18n(
"&Mark Mail as Important" ) );
356 action->setEnabled(
true );
361 updateMarkAction( action, allMarkedAsActionItem );
362 if ( allMarkedAsActionItem ) {
363 action->setText( i18n(
"Remove Action Item Mark" ) );
365 action->setText( i18n(
"&Mark Mail as Action Item" ) );
367 action->setEnabled(
true );
372 action->setEnabled(
false );
377 action->setEnabled(
false );
382 action->setEnabled(
false );
386 bool enableMarkAllAsRead =
false;
387 bool enableMarkAllAsUnread =
false;
388 bool canDeleteItem =
true;
389 bool isSystemFolder =
false;
390 if ( collectionIsSelected ) {
391 foreach (
const Collection &collection, selectedCollections ) {
392 if ( collection.isValid() ) {
393 const Akonadi::CollectionStatistics stats = collection.statistics();
394 if ( !enableMarkAllAsRead ) {
395 enableMarkAllAsRead = ( stats.unreadCount() > 0 );
397 if ( !enableMarkAllAsUnread ) {
398 enableMarkAllAsUnread = ( stats.count() != stats.unreadCount() );
400 if ( canDeleteItem ) {
401 canDeleteItem = collection.rights() & Akonadi::Collection::CanDeleteItem;
403 if ( !isSystemFolder ) {
412 if ( enableMarkAllAsRead && enableMarkAllAsUnread && !canDeleteItem && isSystemFolder ) {
418 if ( isSystemFolder ) {
419 if ( mGenericManager->action( StandardActionManager::DeleteCollections ) ) {
420 mGenericManager->action( StandardActionManager::DeleteCollections )->setEnabled(
false );
433 action->setEnabled( enableMarkAllAsRead );
438 action->setEnabled( enableMarkAllAsUnread );
441 emit mParent->actionStateUpdated();
444 void updateMarkAction( QAction* action,
bool allMarked )
446 QByteArray data = action->data().toByteArray();
448 if ( !data.startsWith(
'!' ) ) {
452 if ( data.startsWith(
'!' ) ) {
453 data = data.mid( 1 );
456 action->setData( data );
461 const QAction *action = qobject_cast<QAction*>( mParent->sender() );
464 const Akonadi::Item::List items = mGenericManager->selectedItems();
465 if ( items.isEmpty() ) {
469 QByteArray typeStr = action->data().toByteArray();
470 kDebug() <<
"Mark mail as: " << typeStr;
473 if ( typeStr.startsWith(
'!' ) ) {
475 typeStr = typeStr.mid( 1 );
482 if ( typeStr ==
"U" ) {
486 }
else if ( typeStr ==
"K" ) {
488 }
else if ( typeStr ==
"G" ) {
492 if ( mInterceptedActions.contains( type ) ) {
496 MarkAsCommand *command =
new MarkAsCommand( targetStatus, items, invert, mParent );
502 const QAction *action = qobject_cast<QAction*>( mParent->sender() );
505 QByteArray typeStr = action->data().toByteArray();
506 kDebug() <<
"Mark all as: " << typeStr;
508 const Akonadi::Collection::List collections = mGenericManager->selectedCollections();
509 if ( collections.isEmpty() ) {
517 if ( typeStr.startsWith(
'!' ) ) {
519 typeStr = typeStr.mid( 1 );
523 if ( typeStr ==
"U" ) {
527 }
else if ( typeStr ==
"K" ) {
529 }
else if ( typeStr ==
"G" ) {
533 if ( mInterceptedActions.contains( type ) ) {
537 MarkAsCommand *command =
new MarkAsCommand( targetStatus, collections, invert, mParent );
541 void slotMoveToTrash()
547 if ( mCollectionSelectionModel->selection().indexes().isEmpty() ) {
551 const Item::List items = mGenericManager->selectedItems();
552 if ( items.isEmpty() ) {
556 MoveToTrashCommand *command =
new MoveToTrashCommand( mCollectionSelectionModel->model(), items, mParent );
560 void slotMoveAllToTrash()
566 if ( mCollectionSelectionModel->selection().indexes().isEmpty() ) {
570 const Collection::List collections = mGenericManager->selectedCollections();
571 if ( collections.isEmpty() ) {
575 MoveToTrashCommand *command =
new MoveToTrashCommand( mCollectionSelectionModel->model(), collections, mParent );
579 void slotRemoveDuplicates()
585 const Collection::List collections = mGenericManager->selectedCollections();
586 if ( collections.isEmpty() ) {
591 connect( job, SIGNAL(finished(KJob*)), mParent, SLOT(slotJobFinished(KJob*)) );
594 void slotJobFinished( KJob *job )
596 if ( job->error() ) {
597 Util::showJobError( job );
601 void slotEmptyAllTrash()
607 EmptyTrashCommand *command =
new EmptyTrashCommand( const_cast<QAbstractItemModel*>( mCollectionSelectionModel->model() ), mParent );
611 void slotEmptyTrash()
617 if ( mCollectionSelectionModel->selection().indexes().isEmpty() ) {
621 const Collection::List collections = mGenericManager->selectedCollections();
622 if ( collections.count() != 1 ) {
626 EmptyTrashCommand *command =
new EmptyTrashCommand( collections.first(), mParent );
630 KActionCollection *mActionCollection;
631 QWidget *mParentWidget;
632 StandardActionManager *mGenericManager;
633 QItemSelectionModel *mCollectionSelectionModel;
634 QItemSelectionModel *mItemSelectionModel;
635 QHash<StandardMailActionManager::Type, KAction*> mActions;
636 QSet<StandardMailActionManager::Type> mInterceptedActions;
642 : QObject( parent ), d( new Private( actionCollection, parent, this ) )
653 d->mCollectionSelectionModel = selectionModel;
654 d->mGenericManager->setCollectionSelectionModel( selectionModel );
656 connect( selectionModel->model(), SIGNAL(rowsInserted(QModelIndex,
int,
int)),
657 SLOT(updateActions()) );
658 connect( selectionModel->model(), SIGNAL(rowsRemoved(QModelIndex,
int,
int)),
659 SLOT(updateActions()) );
660 connect( selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
661 SLOT(updateActions()) );
668 d->mItemSelectionModel = selectionModel;
669 d->mGenericManager->setItemSelectionModel( selectionModel );
671 connect( selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
672 SLOT(updateActions()) );
675 connect( selectionModel->model(), SIGNAL(dataChanged(QModelIndex,QModelIndex)),
676 SLOT(updateActions()) );
683 if ( d->mActions.contains( type ) ) {
684 return d->mActions.value( type );
691 action =
new KAction( d->mParentWidget );
692 action->setIcon( KIcon( QLatin1String(
"mail-mark-read" ) ) );
693 action->setText( i18n(
"&Mark Mail as Read" ) );
694 action->setIconText( i18n(
"Mark as Read" ) );
695 action->setWhatsThis( i18n(
"Mark selected messages as read" ) );
697 d->mActionCollection->addAction( QString::fromLatin1(
"akonadi_mark_as_read" ), action );
698 action->setData( QByteArray(
"R" ) );
699 action->setShortcut( Qt::CTRL+Qt::Key_R );
700 connect( action, SIGNAL(triggered(
bool)),
this, SLOT(slotMarkAs()) );
703 action =
new KAction( d->mParentWidget );
704 action->setText( i18n(
"&Mark Mail as Unread" ) );
705 action->setIconText( i18n(
"Mark as Unread" ) );
706 action->setIcon( KIcon( QLatin1String(
"mail-mark-unread" ) ) );
708 d->mActionCollection->addAction( QString::fromLatin1(
"akonadi_mark_as_unread" ), action );
709 action->setShortcut( Qt::CTRL+Qt::Key_U );
710 action->setData( QByteArray(
"U" ) );
711 connect( action, SIGNAL(triggered(
bool)),
this, SLOT(slotMarkAs()) );
714 action =
new KAction( d->mParentWidget );
715 action->setIcon( KIcon( QLatin1String(
"mail-mark-important" ) ) );
716 action->setText( i18n(
"&Mark Mail as Important" ) );
717 action->setIconText( i18n(
"Mark as Important" ) );
719 d->mActionCollection->addAction( QString::fromLatin1(
"akonadi_mark_as_important" ), action );
720 action->setData( QByteArray(
"G" ) );
721 connect( action, SIGNAL(triggered(
bool)),
this, SLOT(slotMarkAs()) );
724 action =
new KAction( d->mParentWidget );
725 action->setText( i18n(
"&Mark Mail as Action Item" ) );
726 action->setIconText( i18n(
"Mark as Action Item" ) );
727 action->setIcon( KIcon( QLatin1String(
"mail-mark-task" ) ) );
729 d->mActionCollection->addAction( QString::fromLatin1(
"akonadi_mark_as_action_item" ), action );
730 action->setData( QByteArray(
"K" ) );
731 connect( action, SIGNAL(triggered(
bool)),
this, SLOT(slotMarkAs()) );
734 action =
new KAction( d->mParentWidget );
735 action->setIcon( KIcon( QLatin1String(
"mail-mark-read" ) ) );
736 action->setText( i18n(
"Mark &All Mails as Read" ) );
737 action->setIconText( i18n(
"Mark All as Read" ) );
739 d->mActionCollection->addAction( QString::fromLatin1(
"akonadi_mark_all_as_read" ), action );
740 action->setData( QByteArray(
"R" ) );
741 connect( action, SIGNAL(triggered(
bool)),
this, SLOT(slotMarkAllAs()) );
744 action =
new KAction( d->mParentWidget );
745 action->setText( i18n(
"Mark &All Mails as Unread" ) );
746 action->setIconText( i18n(
"Mark All as Unread" ) );
747 action->setIcon( KIcon( QLatin1String(
"mail-mark-unread" ) ) );
749 d->mActionCollection->addAction( QString::fromLatin1(
"akonadi_mark_all_as_unread" ), action );
750 action->setData( QByteArray(
"U" ) );
751 connect( action, SIGNAL(triggered(
bool)),
this, SLOT(slotMarkAllAs()) );
754 action =
new KAction( d->mParentWidget );
755 action->setText( i18n(
"Mark &All Mails as Important" ) );
756 action->setIconText( i18n(
"Mark All as Important" ) );
757 action->setIcon( KIcon( QLatin1String(
"mail-mark-important" ) ) );
759 d->mActionCollection->addAction( QString::fromLatin1(
"akonadi_mark_all_as_important" ), action );
760 action->setData( QByteArray(
"G" ) );
761 connect( action, SIGNAL(triggered(
bool)),
this, SLOT(slotMarkAllAs()) );
764 action =
new KAction( d->mParentWidget );
765 action->setText( i18n(
"Mark &All Mails as Action Item" ) );
766 action->setIconText( i18n(
"Mark All as Action Item" ) );
767 action->setIcon( KIcon( QLatin1String(
"mail-mark-task" ) ) );
769 d->mActionCollection->addAction( QString::fromLatin1(
"akonadi_mark_all_as_action_item" ), action );
770 action->setData( QByteArray(
"K" ) );
771 connect( action, SIGNAL(triggered(
bool)),
this, SLOT(slotMarkAllAs()) );
774 action =
new KAction( d->mParentWidget );
775 action->setIcon( KIcon( QLatin1String(
"user-trash" ) ) );
776 action->setText( i18n(
"Move to &Trash" ) );
777 action->setShortcut( QKeySequence( Qt::Key_Delete ) );
778 action->setWhatsThis( i18n(
"Move message to trashcan" ) );
780 d->mActionCollection->addAction( QString::fromLatin1(
"akonadi_move_to_trash" ), action );
781 connect( action, SIGNAL(triggered(
bool)),
this, SLOT(slotMoveToTrash()) );
784 action =
new KAction( d->mParentWidget );
785 action->setIcon( KIcon( QLatin1String(
"user-trash" ) ) );
786 action->setText( i18n(
"Move All to &Trash" ) );
788 d->mActionCollection->addAction( QString::fromLatin1(
"akonadi_move_all_to_trash" ), action );
789 connect( action, SIGNAL(triggered(
bool)),
this, SLOT(slotMoveAllToTrash()) );
792 action =
new KAction( d->mParentWidget );
793 action->setText( i18n(
"Remove &Duplicate Mails" ) );
794 action->setShortcut( QKeySequence( Qt::CTRL + Qt::Key_Asterisk ) );
796 d->mActionCollection->addAction( QString::fromLatin1(
"akonadi_remove_duplicates" ), action );
797 connect( action, SIGNAL(triggered(
bool)),
this, SLOT(slotRemoveDuplicates()) );
800 action =
new KAction( d->mParentWidget );
801 action->setText( i18n(
"Empty All &Trash Folders" ) );
803 d->mActionCollection->addAction( QString::fromLatin1(
"akonadi_empty_all_trash" ), action );
804 connect( action, SIGNAL(triggered(
bool)),
this, SLOT(slotEmptyAllTrash()) );
807 action =
new KAction( d->mParentWidget );
808 action->setText( i18n(
"E&mpty Trash" ) );
810 d->mActionCollection->addAction( QString::fromLatin1(
"akonadi_empty_trash" ), action );
811 connect( action, SIGNAL(triggered(
bool)),
this, SLOT(slotEmptyTrash()) );
823 KAction *act = d->mGenericManager->action(type);
825 act = d->mGenericManager->createAction( type );
826 d->updateGenericAction(type);
846 d->mGenericManager->createAllActions();
847 d->updateGenericAllActions();
854 if ( d->mActions.contains( type ) ) {
855 return d->mActions.value( type );
863 return d->mGenericManager->action( type );
868 d->mGenericManager->setActionText( type, text );
874 d->mInterceptedActions.insert( type );
876 d->mInterceptedActions.remove( type );
882 d->mGenericManager->interceptAction( type, intercept );
887 return d->mGenericManager->selectedCollections();
892 return d->mGenericManager->selectedItems();
897 d->mGenericManager->setFavoriteCollectionsModel( favoritesModel );
902 d->mGenericManager->setFavoriteSelectionModel( selectionModel );
905 void StandardMailActionManager::setCollectionPropertiesPageNames(
const QStringList &names )
907 d->mGenericManager->setCollectionPropertiesPageNames( names );
910 Akonadi::StandardActionManager* StandardMailActionManager::standardActionManager()
const
912 return d->mGenericManager;
915 #include "moc_standardmailactionmanager.cpp"