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() );
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->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 ) {
354 action->setEnabled(
false );
356 action->setEnabled(
true );
362 updateMarkAction( action, allMarkedAsUnread );
363 if ( allMarkedAsUnread ) {
364 action->setEnabled(
false );
366 action->setEnabled(
true );
372 action->setCheckable(
true);
373 updateMarkAction( action, allMarkedAsImportant );
374 if ( allMarkedAsImportant ) {
375 action->setText( i18n(
"Remove Important Mark" ) );
376 action->setChecked(
true);
378 action->setText( i18n(
"&Mark Mail as Important" ) );
379 action->setChecked(
false);
381 action->setEnabled(
true );
386 action->setCheckable(
true);
387 updateMarkAction( action, allMarkedAsActionItem );
388 if ( allMarkedAsActionItem ) {
389 action->setText( i18n(
"Remove Action Item Mark" ) );
390 action->setChecked(
true);
392 action->setText( i18n(
"&Mark Mail as Action Item" ) );
393 action->setChecked(
false);
395 action->setEnabled(
true );
400 action->setEnabled(
false );
405 action->setEnabled(
false );
410 action->setEnabled(
false );
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() );
428 if ( canDeleteItem ) {
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 );
461 action->setEnabled( enableMarkAllAsRead );
466 action->setEnabled( enableMarkAllAsUnread );
469 emit mParent->actionStateUpdated();
472 void updateMarkAction( QAction* action,
bool allMarked )
474 QByteArray data = action->data().toByteArray();
476 if ( !data.startsWith(
'!' ) ) {
480 if ( data.startsWith(
'!' ) ) {
481 data = data.mid( 1 );
484 action->setData( data );
489 const QAction *action = qobject_cast<QAction*>( mParent->sender() );
492 const Akonadi::Item::List items = mGenericManager->selectedItems();
493 if ( items.isEmpty() ) {
497 QByteArray typeStr = action->data().toByteArray();
498 kDebug() <<
"Mark mail as: " << typeStr;
501 if ( typeStr.startsWith(
'!' ) ) {
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() );
533 QByteArray typeStr = action->data().toByteArray();
534 kDebug() <<
"Mark all as: " << typeStr;
536 const Akonadi::Collection::List collections = mGenericManager->selectedCollections();
537 if ( collections.isEmpty() ) {
545 if ( typeStr.startsWith(
'!' ) ) {
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 )
624 if ( job->error() ) {
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;
659 QWidget *mParentWidget;
660 StandardActionManager *mGenericManager;
661 QItemSelectionModel *mCollectionSelectionModel;
662 QItemSelectionModel *mItemSelectionModel;
663 QHash<StandardMailActionManager::Type, KAction*> mActions;
664 QSet<StandardMailActionManager::Type> mInterceptedActions;
669 : QObject( parent ), d( new Private( actionCollection, parent, this ) )
680 d->mCollectionSelectionModel = selectionModel;
681 d->mGenericManager->setCollectionSelectionModel( selectionModel );
683 connect( selectionModel->model(), SIGNAL(rowsInserted(QModelIndex,
int,
int)),
684 SLOT(updateActions()) );
685 connect( selectionModel->model(), SIGNAL(rowsRemoved(QModelIndex,
int,
int)),
686 SLOT(updateActions()) );
687 connect( selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
688 SLOT(updateActions()) );
695 d->mItemSelectionModel = selectionModel;
696 d->mGenericManager->setItemSelectionModel( selectionModel );
698 connect( selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
699 SLOT(updateActions()) );
702 connect( selectionModel->model(), SIGNAL(dataChanged(QModelIndex,QModelIndex)),
703 SLOT(updateActions()) );
710 if ( d->mActions.contains( type ) ) {
711 return d->mActions.value( type );
718 action =
new KAction( d->mParentWidget );
719 action->setIcon( KIcon( QLatin1String(
"mail-mark-read" ) ) );
720 action->setText( i18n(
"&Mark Message as Read" ) );
721 action->setIconText( i18n(
"Mark as Read" ) );
722 action->setHelpText( i18n(
"Mark selected messages as read." ) );
723 action->setWhatsThis( i18n(
"Mark selected messages as read." ) );
725 d->mActionCollection->addAction( QString::fromLatin1(
"akonadi_mark_as_read" ), action );
726 action->setData( QByteArray(
"R" ) );
727 action->setShortcut( Qt::CTRL+Qt::Key_R );
728 connect( action, SIGNAL(triggered(
bool)),
this, SLOT(slotMarkAs()) );
731 action =
new KAction( d->mParentWidget );
732 action->setIcon( KIcon( QLatin1String(
"mail-mark-unread" ) ) );
733 action->setText( i18n(
"&Mark Message as Unread" ) );
734 action->setIconText( i18n(
"Mark as Unread" ) );
735 action->setHelpText( i18n(
"Mark selected messages as unread." ) );
736 action->setWhatsThis( i18n(
"Mark selected messages as unread." ) );
738 d->mActionCollection->addAction( QString::fromLatin1(
"akonadi_mark_as_unread" ), action );
739 action->setShortcut( Qt::CTRL+Qt::Key_U );
740 action->setData( QByteArray(
"U" ) );
741 connect( action, SIGNAL(triggered(
bool)),
this, SLOT(slotMarkAs()) );
744 action =
new KAction( d->mParentWidget );
745 action->setIcon( KIcon( QLatin1String(
"mail-mark-important" ) ) );
746 action->setText( i18n(
"&Mark Message as Important" ) );
747 action->setIconText( i18n(
"Mark as Important" ) );
748 action->setHelpText( i18n(
"Mark selected messages as important." ) );
751 d->mActionCollection->addAction( QString::fromLatin1(
"akonadi_mark_as_important" ), action );
752 action->setData( QByteArray(
"G" ) );
753 connect( action, SIGNAL(triggered(
bool)),
this, SLOT(slotMarkAs()) );
756 action =
new KAction( d->mParentWidget );
757 action->setIcon( KIcon( QLatin1String(
"mail-mark-task" ) ) );
758 action->setText( i18n(
"&Mark Message as Action Item" ) );
759 action->setIconText( i18n(
"Mark as Action Item" ) );
760 action->setHelpText( i18n(
"Mark selected messages as action items." ) );
761 action->setWhatsThis( i18n(
"Mark selected messages as action items." ) );
763 d->mActionCollection->addAction( QString::fromLatin1(
"akonadi_mark_as_action_item" ), action );
764 action->setData( QByteArray(
"K" ) );
765 connect( action, SIGNAL(triggered(
bool)),
this, SLOT(slotMarkAs()) );
768 action =
new KAction( d->mParentWidget );
769 action->setIcon( KIcon( QLatin1String(
"mail-mark-read" ) ) );
770 action->setText( i18n(
"Mark &All Messages as Read" ) );
771 action->setIconText( i18n(
"Mark All as Read" ) );
772 action->setHelpText( i18n(
"Mark all messages as read." ) );
773 action->setWhatsThis( i18n(
"Mark all messages as read." ) );
775 d->mActionCollection->addAction( QString::fromLatin1(
"akonadi_mark_all_as_read" ), action );
776 action->setData( QByteArray(
"R" ) );
777 connect( action, SIGNAL(triggered(
bool)),
this, SLOT(slotMarkAllAs()) );
780 action =
new KAction( d->mParentWidget );
781 action->setIcon( KIcon( QLatin1String(
"mail-mark-unread" ) ) );
782 action->setText( i18n(
"Mark &All Messages as Unread" ) );
783 action->setIconText( i18n(
"Mark All as Unread" ) );
784 action->setHelpText( i18n(
"Mark all messages as unread." ) );
785 action->setWhatsThis( i18n(
"Mark all messages as unread." ) );
787 d->mActionCollection->addAction( QString::fromLatin1(
"akonadi_mark_all_as_unread" ), action );
788 action->setData( QByteArray(
"U" ) );
789 connect( action, SIGNAL(triggered(
bool)),
this, SLOT(slotMarkAllAs()) );
792 action =
new KAction( d->mParentWidget );
793 action->setIcon( KIcon( QLatin1String(
"mail-mark-important" ) ) );
794 action->setText( i18n(
"Mark &All Messages as Important" ) );
795 action->setIconText( i18n(
"Mark All as Important" ) );
796 action->setHelpText( i18n(
"Mark all messages as important." ) );
797 action->setWhatsThis( i18n(
"Mark all messages as important." ) );
799 d->mActionCollection->addAction( QString::fromLatin1(
"akonadi_mark_all_as_important" ), action );
800 action->setData( QByteArray(
"G" ) );
801 connect( action, SIGNAL(triggered(
bool)),
this, SLOT(slotMarkAllAs()) );
804 action =
new KAction( d->mParentWidget );
805 action->setIconText( i18n(
"Mark All as Action Item" ) );
806 action->setText( i18n(
"Mark &All Messages as Action Item" ) );
807 action->setIcon( KIcon( QLatin1String(
"mail-mark-task" ) ) );
808 action->setHelpText( i18n(
"Mark all messages as action items." ) );
809 action->setWhatsThis( i18n(
"Mark all messages as action items." ) );
811 d->mActionCollection->addAction( QString::fromLatin1(
"akonadi_mark_all_as_action_item" ), action );
812 action->setData( QByteArray(
"K" ) );
813 connect( action, SIGNAL(triggered(
bool)),
this, SLOT(slotMarkAllAs()) );
816 action =
new KAction( d->mParentWidget );
817 action->setIcon( KIcon( QLatin1String(
"user-trash" ) ) );
818 action->setText( i18n(
"Move to &Trash" ) );
819 action->setShortcut( QKeySequence( Qt::Key_Delete ) );
820 action->setHelpText( i18n(
"Move selected messages to the trash folder." ) );
821 action->setWhatsThis( i18n(
"Move selected messages to the trash folder." ) );
823 d->mActionCollection->addAction( QString::fromLatin1(
"akonadi_move_to_trash" ), action );
824 connect( action, SIGNAL(triggered(
bool)),
this, SLOT(slotMoveToTrash()) );
827 action =
new KAction( d->mParentWidget );
828 action->setIcon( KIcon( QLatin1String(
"user-trash" ) ) );
829 action->setText( i18n(
"Move All to &Trash" ) );
830 action->setHelpText( i18n(
"Move all messages to the trash folder." ) );
831 action->setWhatsThis( i18n(
"Move all messages to the trash folder." ) );
833 d->mActionCollection->addAction( QString::fromLatin1(
"akonadi_move_all_to_trash" ), action );
834 connect( action, SIGNAL(triggered(
bool)),
this, SLOT(slotMoveAllToTrash()) );
837 action =
new KAction( d->mParentWidget );
838 action->setText( i18n(
"Remove &Duplicate Messages" ) );
839 action->setHelpText( i18n(
"Remove duplicate messages." ) );
840 action->setWhatsThis( i18n(
"Remove duplicate messages." ) );
841 action->setShortcut( QKeySequence( Qt::CTRL + Qt::Key_Asterisk ) );
843 d->mActionCollection->addAction( QString::fromLatin1(
"akonadi_remove_duplicates" ), action );
844 connect( action, SIGNAL(triggered(
bool)),
this, SLOT(slotRemoveDuplicates()) );
847 action =
new KAction( d->mParentWidget );
848 action->setText( i18n(
"Empty All &Trash Folders" ) );
849 action->setHelpText( i18n(
"Permanently delete all messages from all trash folders." ) );
850 action->setWhatsThis( i18n(
"Permanently delete all messages from all trash folders." ) );
852 d->mActionCollection->addAction( QString::fromLatin1(
"akonadi_empty_all_trash" ), action );
853 connect( action, SIGNAL(triggered(
bool)),
this, SLOT(slotEmptyAllTrash()) );
856 action =
new KAction( d->mParentWidget );
857 action->setText( i18n(
"E&mpty Trash" ) );
858 action->setHelpText( i18n(
"Permanently delete all messages from the trash folder." ) );
859 action->setWhatsThis( i18n(
"Permanently delete all messages from the trash folder." ) );
861 d->mActionCollection->addAction( QString::fromLatin1(
"akonadi_empty_trash" ), action );
862 connect( action, SIGNAL(triggered(
bool)),
this, SLOT(slotEmptyTrash()) );
874 KAction *act = d->mGenericManager->action(type);
876 act = d->mGenericManager->createAction( type );
877 d->updateGenericAction(type);
897 d->mGenericManager->createAllActions();
898 d->updateGenericAllActions();
905 if ( d->mActions.contains( type ) ) {
906 return d->mActions.value( type );
914 return d->mGenericManager->action( type );
919 d->mGenericManager->setActionText( type, text );
925 d->mInterceptedActions.insert( type );
927 d->mInterceptedActions.remove( type );
933 d->mGenericManager->interceptAction( type, intercept );
938 return d->mGenericManager->selectedCollections();
943 return d->mGenericManager->selectedItems();
948 d->mGenericManager->setFavoriteCollectionsModel( favoritesModel );
953 d->mGenericManager->setFavoriteSelectionModel( selectionModel );
956 void StandardMailActionManager::setCollectionPropertiesPageNames(
const QStringList &names )
958 d->mGenericManager->setCollectionPropertiesPageNames( names );
961 Akonadi::StandardActionManager* StandardMailActionManager::standardActionManager()
const
963 return d->mGenericManager;
966 #include "moc_standardmailactionmanager.cpp"
Marks a mail as action item.
void createAllActions()
Convenience method to create all standard actions.
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...
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.
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.
static SpecialMailCollections * self()
Returns the global SpecialMailCollections instance.
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.
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.
Marks all mails in a folder as read.
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.