Rename method
[kdepim.git] / kmail / kmmainwidget.h
bloba102e2ff016b069c88583c697ccc88163dd77737
1 /*
2 This file is part of KMail, the KDE mail client.
3 Copyright (c) 2002 Don Sanders <sanders@kde.org>
5 Based on the work of Stefan Taferner <taferner@kde.org>
7 KMail is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License, version 2, as
9 published by the Free Software Foundation.
11 KMail is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef __KMMAINWIDGET
22 #define __KMMAINWIDGET
24 #include "kmail_export.h"
25 #include "kmreaderwin.h" //for inline actions
26 #include "kmkernel.h" // for access to config
28 #include "mailcommon/foldertreewidget.h"
30 #include <kxmlguiclient.h>
31 #include "messageactions.h"
32 #include <kactioncollection.h>
33 #include <mailcommon/foldercollection.h>
35 #include <QPointer>
36 #include <QTimer>
37 #include <Akonadi/KMime/StandardMailActionManager>
38 #include <AkonadiCore/tag.h>
39 #include <MessageList/View>
41 namespace MailTransport
43 class Transport;
45 namespace Akonadi
47 class Tag;
50 namespace KMime
52 class Message;
54 class QUrl;
55 class QVBoxLayout;
56 class QSplitter;
57 class KMLaunchExternalComponent;
58 class DisplayMessageFormatActionMenu;
59 class QAction;
60 class KActionMenu;
61 class KToggleAction;
62 class KMMetaFilterActionCommand;
63 class CollectionPane;
64 class KMCommand;
65 class KMMoveCommand;
66 class KRecentFilesAction;
67 class ManageShowCollectionProperties;
68 class KActionMenuTransport;
69 class KActionMenuAccount;
70 template <typename T, typename S> class QMap;
72 namespace KIO
74 class Job;
77 namespace KMail
79 class SearchWindow;
80 class VacationScriptIndicatorWidget;
81 class TagActionManager;
82 class FolderShortcutActionManager;
85 namespace KSieveUi
87 class SieveDebugDialog;
88 class ManageSieveScriptsDialog;
89 class VacationManager;
92 namespace MailCommon
94 class FolderSelectionDialog;
95 class FavoriteCollectionWidget;
98 class KMAIL_EXPORT KMMainWidget : public QWidget
100 Q_OBJECT
102 public:
103 typedef QList<KMMainWidget *> PtrList;
105 KMMainWidget(QWidget *parent, KXMLGUIClient *aGUIClient,
106 KActionCollection *actionCollection,
107 KSharedConfig::Ptr config = KMKernel::self()->config());
108 virtual ~KMMainWidget();
109 void destruct();
111 /** Read configuration options before widgets are created. */
112 void readPreConfig();
114 /** Read configuration for current folder. */
115 void readFolderConfig();
117 /** Write configuration for current folder. */
118 void writeFolderConfig();
120 /** Read configuration options after widgets are created. */
121 void readConfig();
123 /** Write configuration options. */
124 void writeConfig(bool force = true);
126 void writeReaderConfig();
128 /** Easy access to main components of the window. */
129 KMReaderWin *messageView() const;
130 /** Access to the header list pane. */
131 CollectionPane *messageListPane() const;
133 QSharedPointer<MailCommon::FolderCollection> currentFolder() const;
135 static void cleanup();
136 QAction *action(const QString &name)
138 return mActionCollection->action(name);
140 KActionMenu *filterMenu() const
142 return mFilterMenu;
144 KActionMenu *mailingListActionMenu() const
146 return mMsgActions->mailingListActionMenu();
148 QAction *editAction() const
150 return mMsgActions->editAction();
152 QAction *sendAgainAction() const
154 return mSendAgainAction;
156 QAction *sendQueuedAction() const
158 return mSendQueued;
160 KActionMenuTransport *sendQueueViaMenu() const
162 return mSendActionMenu;
165 KMail::MessageActions *messageActions() const
167 return mMsgActions;
171 Returns a list of all KMMainWidgets. Warning, the list itself can be 0.
172 @return the list of all main widgets, or 0 if it is not yet initialized
174 static const PtrList *mainWidgetList();
176 QWidget *vacationScriptIndicator() const;
177 void updateVacationScriptStatus();
179 MailCommon::FolderTreeView *folderTreeView() const
181 return mFolderTreeWidget->folderTreeView();
184 /** Returns the XML GUI client. */
185 KXMLGUIClient *guiClient() const
187 return mGUIClient;
190 KMail::TagActionManager *tagActionManager() const;
192 KMail::FolderShortcutActionManager *folderShortcutActionManager() const;
193 void savePaneSelection();
195 void updatePaneTagComboBox();
197 void clearViewer();
199 void addRecentFile(const QUrl &mUrl);
200 void updateQuickSearchLineText();
202 void populateMessageListStatusFilterCombo();
203 public Q_SLOTS:
204 // Moving messages around
206 * This will ask for a destination folder and move the currently selected
207 * messages (in MessageListView) into it.
209 void slotMoveSelectedMessageToFolder();
211 // Copying messages around
214 * This will ask for a destination folder and copy the currently selected
215 * messages (in MessageListView) into it.
217 void slotCopySelectedMessagesToFolder();
220 * Implements the "move to trash" action
222 void slotTrashSelectedMessages();
224 void slotCheckMail();
226 void slotCheckMailOnStartup();
229 Select the given folder
230 If the folder is 0 the intro is shown
232 void folderSelected(const Akonadi::Collection &col);
235 Open a separate viewer window containing the specified message.
237 void slotMessageActivated(const Akonadi::Item &);
240 Opens mail in the internal viewer.
242 void slotMessageSelected(const Akonadi::Item &);
244 void slotItemsFetchedForActivation(KMCommand *command);
245 void slotMessageStatusChangeRequest(const Akonadi::Item &, const Akonadi::MessageStatus &, const Akonadi::MessageStatus &);
247 void slotReplaceMsgByUnencryptedVersion();
250 Update message menu
252 void updateMessageMenu();
255 Start a timer to update message actions
257 void startUpdateMessageActionsTimer();
259 /** Update message actions */
260 void updateMessageActions(bool fast = false);
261 void updateMessageActionsDelayed();
263 /** Clear and create actions for marked filters */
264 void clearFilterActions();
265 void initializeFilterActions();
267 /** Trigger the dialog for editing out-of-office scripts. */
268 void slotEditVacation(const QString &serverName = QString());
270 /** Adds if not existing/removes if existing the tag identified by @p aLabel
271 in all selected messages */
272 void slotUpdateMessageTagList(const Akonadi::Tag &tag);
273 void slotSelectMoreMessageTagList();
276 * Convenience function to get the action collection in a list.
278 * @return a list of action collections. The list only has one item, and
279 * that is the action collection of this main widget as returned
280 * by actionCollection().
282 QList<KActionCollection *> actionCollections() const;
284 QAction *akonadiStandardAction(Akonadi::StandardActionManager::Type type);
285 QAction *akonadiStandardAction(Akonadi::StandardMailActionManager::Type type);
286 Akonadi::StandardMailActionManager *standardMailActionManager() const
288 return mAkonadiStandardActionManager;
291 void refreshMessageListSelection();
293 void slotStartCheckMail();
294 void slotEndCheckMail();
296 void slotRemoveDuplicates();
298 void slotSelectCollectionFolder(const Akonadi::Collection &col);
300 void restoreCollectionFolderViewConfig();
301 Q_SIGNALS:
302 void messagesTransfered(bool);
303 void captionChangeRequest(const QString &caption);
304 void recreateGui();
306 protected:
307 void setupActions();
308 void createWidgets();
309 void deleteWidgets();
310 void layoutSplitters();
311 void newFromTemplate(const Akonadi::Item &);
312 void moveSelectedMessagesToFolder(const Akonadi::Collection &dest);
313 void copySelectedMessagesToFolder(const Akonadi::Collection &dest);
315 void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
317 KActionCollection *actionCollection() const
319 return mActionCollection;
323 @return the correct config dialog depending on whether the parent of
324 the mainWidget is a KPart or a KMMainWindow.
325 When dealing with geometries, use this pointer
327 KSharedConfig::Ptr config();
329 protected Q_SLOTS:
330 void updateFileMenu();
331 void slotHelp();
332 void slotFilter();
333 void slotManageSieveScripts();
334 void slotCompose();
335 void slotPostToML();
336 void slotExpireFolder();
337 void slotExpireAll();
338 void slotArchiveFolder();
339 void slotRemoveFolder();
340 void slotEmptyFolder();
341 void slotClearCurrentFolder();
342 void slotAddFavoriteFolder();
343 void slotShowSelectedFolderInPane();
344 void slotOverrideHtmlLoadExt();
345 void slotMessageQueuedOrDrafted();
346 void slotUseTemplate();
347 void slotDeleteMsg(bool confirmDelete = true); // completely delete message
348 void slotTrashThread();
349 void slotDeleteThread(bool confirmDelete = true); // completely delete thread
350 void slotUndo();
351 void slotReadOn();
352 void slotSaveMsg();
353 void slotOpenMsg();
354 void slotSaveAttachments();
355 void slotJumpToFolder();
356 void slotResendMsg();
357 void slotCheckVacation();
358 void slotDebugSieve();
359 void slotApplyFilters();
360 void slotApplyFiltersOnFolder();
361 void slotExpandThread();
362 void slotExpandAllThreads();
363 void slotCollapseThread();
364 void slotCollapseAllThreads();
365 void slotSetThreadStatusUnread();
366 void slotSetThreadStatusRead();
367 void slotSetThreadStatusImportant();
368 void slotSetThreadStatusToAct();
369 void slotSetThreadStatusWatched();
370 void slotSetThreadStatusIgnored();
371 void slotSendQueued();
372 void slotSendQueuedVia(MailTransport::Transport *transport);
373 void slotOnlineStatus();
374 void slotUpdateOnlineStatus(KMailSettings::EnumNetworkState::type);
375 void slotMessagePopup(const Akonadi::Item &, const QUrl &, const QUrl &imageUrl, const QPoint &);
376 void slotContactSearchJobForMessagePopupDone(KJob *job);
377 void slotSelectAllMessages();
378 void slotFocusQuickSearch();
379 bool slotSearch();
380 void slotIntro();
381 void slotShowStartupFolder();
383 /** Message navigation */
384 void slotSelectNextMessage();
385 void slotExtendSelectionToNextMessage();
386 void slotSelectNextUnreadMessage();
387 void slotSelectPreviousMessage();
388 void slotExtendSelectionToPreviousMessage();
389 void slotSelectPreviousUnreadMessage();
390 void slotFocusOnNextMessage();
391 void slotFocusOnPrevMessage();
392 void slotSelectFirstMessage();
393 void slotSelectLastMessage();
394 void slotSelectFocusedMessage();
396 void slotNextUnreadFolder();
397 void slotPrevUnreadFolder();
399 /** etc. */
400 void slotDisplayCurrentMessage();
402 void slotShowNewFromTemplate();
403 void slotDelayedShowNewFromTemplate(KJob *);
404 void slotNewFromTemplate(QAction *);
406 /** Update the undo action */
407 void slotUpdateUndo();
409 /** Update html and threaded messages preferences in Folder menu. */
410 void updateFolderMenu();
412 /** Settings menu */
414 /** XML-GUI stuff */
415 void slotEditNotifications();
417 /** Slot to reply to a message */
418 void slotCustomReplyToMsg(const QString &tmpl);
419 void slotCustomReplyAllToMsg(const QString &tmpl);
420 void slotForwardInlineMsg();
421 void slotForwardAttachedMsg();
422 void slotRedirectMsg();
423 void slotCustomForwardMsg(const QString &tmpl);
424 void slotSubjectFilter();
425 void slotFromFilter();
426 void slotToFilter();
428 void slotConfigChanged();
430 /** Show a splash screen for the longer-lasting operation */
431 void slotShowBusySplash();
434 Show a message screen explaining that we are currently offline, when
435 an online folder is selected.
437 void showOfflinePage();
438 void showResourceOfflinePage();
439 void updateVacationScriptStatus(bool active, const QString &serverName = QString());
441 void slotItemAdded(const Akonadi::Item &, const Akonadi::Collection &col);
442 void slotItemRemoved(const Akonadi::Item &);
443 void slotItemMoved(const Akonadi::Item &item, const Akonadi::Collection &from, const Akonadi::Collection &to);
444 void slotCollectionStatisticsChanged(Akonadi::Collection::Id, const Akonadi::CollectionStatistics &);
446 void slotAkonadiStandardActionUpdated();
447 void slotCollectionChanged(const Akonadi::Collection &, const QSet<QByteArray> &);
448 void slotCreateNewTab(bool);
449 void slotUpdateActionsAfterMailChecking();
450 void slotCreateAddressBookContact();
451 void slotOpenRecentMsg(const QUrl &url);
453 private:
454 void checkAkonadiServerManagerState();
455 void updateHtmlMenuEntry();
457 void updateMoveAction(const Akonadi::CollectionStatistics &statistic);
458 void updateMoveAction(bool hasUnreadMails, bool hasMails);
460 void updateAllToTrashAction(int statistics);
462 /** Get override character encoding. */
463 QString overrideEncoding() const;
465 void moveMessageSelected(MessageList::Core::MessageItemSetReference ref, const Akonadi::Collection &dest, bool confirmOnDeletion = true);
467 void copyMessageSelected(const Akonadi::Item::List &selectMsg, const Akonadi::Collection &dest);
470 * Move the messages referenced by the specified set to trash.
471 * The set parameter must not be null and the ownership is passed
472 * to this function.
474 void trashMessageSelected(MessageList::Core::MessageItemSetReference ref);
476 * Set the status of the messages referenced by the specified set, eventually toggling it.
477 * The set parameter must not be null and the ownership is passed to this function.
479 void setMessageSetStatus(const Akonadi::Item::List &select,
480 const Akonadi::MessageStatus &status,
481 bool toggle
484 * Toggles a tag for the messages referenced by the specified set.
485 * The set parameter must not be null and the ownership is passed to this function.
487 void toggleMessageSetTag(const Akonadi::Item::List &select, const Akonadi::Tag &tag);
489 * This applies setMessageSetStatus() on the current thread.
491 void setCurrentThreadStatus(const Akonadi::MessageStatus &status, bool toggle);
493 void applyFilters(const Akonadi::Item::List &selectedMessages);
496 * Internal helper that creates the folder selection dialog used for the
497 * move and copy to folder actions on demand. Only folders where items can
498 * be added are listed.
500 MailCommon::FolderSelectionDialog *moveOrCopyToDialog();
503 * Internal helper that creates the folder selection dialog used for
504 * jumping to folders, or adding them as favourites. All folders are listed.
506 MailCommon::FolderSelectionDialog *selectFromAllFoldersDialog();
509 * Internal helper that applies the current settings so the
510 * favorite folder view.
512 void refreshFavoriteFoldersViewProperties();
514 void openFilterDialog(const QByteArray &field, const QString &value);
516 void showMessagePopup(const Akonadi::Item &msg, const QUrl &aUrl, const QUrl &imageUrl, const QPoint &aPoint, bool contactAlreadyExists, bool uniqueContactFound);
518 private Q_SLOTS:
519 void slotMoveMessageToTrash();
521 * Called when a "move to trash" operation is completed
523 void slotTrashMessagesCompleted(KMMoveCommand *command);
526 * Called when a "move" operation is completed
528 void slotMoveMessagesCompleted(KMMoveCommand *command);
531 * Called when a "copy" operation is completed
533 void slotCopyMessagesCompleted(KMCommand *command);
535 void slotRequestFullSearchFromQuickSearch();
536 void slotFolderChanged(const Akonadi::Collection &);
537 void slotCollectionFetched(int collectionId);
539 void itemsReceived(const Akonadi::Item::List &list);
540 void itemsFetchDone(KJob *job);
542 void slotServerSideSubscription();
543 void slotFetchItemsForFolderDone(KJob *job);
544 void slotServerStateChanged(Akonadi::ServerManager::State state);
545 void slotArchiveMails();
546 void slotChangeDisplayMessageFormat(MessageViewer::Viewer::DisplayFormatMessage format);
548 void slotCollectionRemoved(const Akonadi::Collection &col);
549 void slotCcFilter();
550 void slotBandwidth(bool b);
551 void slotDeleteMessages();
553 void slotMarkAllMessageAsReadInCurrentFolderAndSubfolder();
554 private:
555 // Message actions
556 QAction *mDeleteAction;
557 QAction *mTrashThreadAction;
558 QAction *mDeleteThreadAction;
559 QAction *mSaveAsAction;
560 QAction *mUseAction;
561 QAction *mSendAgainAction;
562 QAction *mApplyAllFiltersAction;
563 QAction *mSaveAttachmentsAction;
564 QAction *mOpenAction;
565 QAction *mMoveMsgToFolderAction;
566 QAction *mCollectionProperties;
567 QAction *mSendQueued;
568 QAction *mArchiveAction;
569 KActionMenuTransport *mSendActionMenu;
570 // Filter actions
571 KActionMenu *mFilterMenu;
572 QAction *mExpireConfigAction;
573 QAction *mApplyFiltersOnFolder;
574 // Custom template actions menu
575 KActionMenu *mTemplateMenu;
577 KActionMenu *mThreadStatusMenu, *mApplyFilterActionsMenu;
578 QAction *mCopyActionMenu;
579 QAction *mMoveActionMenu;
580 QAction *mMarkThreadAsReadAction;
581 QAction *mMarkThreadAsUnreadAction;
582 KToggleAction *mToggleThreadImportantAction;
583 KToggleAction *mToggleThreadToActAction;
585 KToggleAction *mWatchThreadAction, *mIgnoreThreadAction;
587 MailCommon::FavoriteCollectionWidget *mFavoriteCollectionsView;
588 Akonadi::FavoriteCollectionsModel *mFavoritesModel;
589 QWidget *mSearchAndTree;
590 KMReaderWin *mMsgView;
591 QSplitter *mSplitter1;
592 QSplitter *mSplitter2;
593 QSplitter *mFolderViewSplitter;
594 Akonadi::Collection mTemplateFolder;
595 bool mLongFolderList;
596 bool mStartupDone;
597 bool mWasEverShown;
598 bool mHtmlGlobalSetting;
599 bool mHtmlLoadExtGlobalSetting;
600 bool mFolderHtmlLoadExtPreference;
601 bool mReaderWindowActive;
602 bool mReaderWindowBelow;
603 bool mEnableFavoriteFolderView;
604 bool mEnableFolderQuickSearch;
606 QPointer<KMail::SearchWindow> mSearchWin;
608 QAction *mExpireFolderAction;
609 QAction *mFolderMailingListPropertiesAction;
610 QAction *mShowFolderShortcutDialogAction;
611 QAction *mArchiveFolderAction;
612 QAction *mMessageNewList;
613 KToggleAction *mPreferHtmlLoadExtAction;
615 QTimer *menutimer;
616 QTimer *mShowBusySplashTimer;
618 KSieveUi::VacationManager *mVacationManager;
619 #if !defined(NDEBUG)
620 QPointer<KSieveUi::SieveDebugDialog> mSieveDebugDialog;
621 #endif
622 KActionCollection *mActionCollection;
623 QAction *mToolbarActionSeparator;
624 QVBoxLayout *mTopLayout;
625 bool mDestructed;
626 QList<QAction *> mFilterMenuActions;
627 QList<QAction *> mFilterTBarActions;
628 QList<KMMetaFilterActionCommand *> mFilterCommands;
630 KMail::TagActionManager *mTagActionManager;
631 KMail::FolderShortcutActionManager *mFolderShortcutActionManager;
632 KSharedConfig::Ptr mConfig;
633 KXMLGUIClient *mGUIClient;
635 KMail::MessageActions *mMsgActions;
636 Akonadi::StandardMailActionManager *mAkonadiStandardActionManager;
637 CollectionPane *mMessagePane;
638 QSharedPointer<MailCommon::FolderCollection> mCurrentFolder;
640 MailCommon::FolderTreeWidget *mFolderTreeWidget;
642 KMail::VacationScriptIndicatorWidget *mVacationScriptIndicator;
643 bool mVacationIndicatorActive;
644 bool mGoToFirstUnreadMessageInSelectedFolder;
645 MessageList::Core::PreSelectionMode mPreSelectionMode;
647 QTimer mCheckMailTimer;
649 QPointer<MailCommon::FolderSelectionDialog> mMoveOrCopyToDialog;
650 QPointer<MailCommon::FolderSelectionDialog> mSelectFromAllFoldersDialog;
651 QAction *mServerSideSubscription;
652 KRecentFilesAction *mOpenRecentAction;
653 QPointer<KSieveUi::ManageSieveScriptsDialog> mManageSieveDialog;
654 QAction *mQuickSearchAction;
655 DisplayMessageFormatActionMenu *mDisplayMessageFormatMenu;
656 MessageViewer::Viewer::DisplayFormatMessage mFolderDisplayFormatPreference;
657 QAction *mSearchMessages;
658 KMLaunchExternalComponent *mLaunchExternalComponent;
659 ManageShowCollectionProperties *mManageShowCollectionProperties;
660 QAction *mShowIntroductionAction;
661 KToggleAction *mLowBandwithAction;
662 QAction *mMarkAllMessageAsReadAndInAllSubFolder;
663 KActionMenuAccount *mAccountActionMenu;
666 #endif