SVN_SILENT made messages (.desktop file)
[kdepim.git] / kmail / kmmainwidget.h
blob076f3e5cea185b52b85ecc9d4829adb0eab4d347
1 /* -*- mode: C++; c-file-style: "gnu" -*-
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 "foldertreewidget.h"
30 #include <kxmlguiclient.h>
31 #include "messageactions.h"
32 #include <kactioncollection.h>
33 #include <foldercollection.h>
35 #include <QPointer>
36 #include <QTimer>
37 #include <akonadi/kmime/standardmailactionmanager.h>
38 #include <akonadi/tag.h>
39 #include <messagelist/core/view.h>
41 namespace Akonadi {
42 class Tag;
45 namespace KMime {
46 class Message;
48 class KUrl;
49 class QVBoxLayout;
50 class QSplitter;
52 class QMenu;
53 class KAction;
54 class KActionMenu;
55 class KToggleAction;
56 class KMMetaFilterActionCommand;
57 class CollectionPane;
58 class KMCommand;
59 class KMMoveCommand;
60 class KRecentFilesAction;
61 class QDBusPendingCallWatcher;
62 template <typename T, typename S> class QMap;
64 namespace KIO {
65 class Job;
68 namespace KMail {
69 class SearchWindow;
70 class VacationScriptIndicatorWidget;
71 class TagActionManager;
72 class FolderShortcutActionManager;
75 namespace KSieveUi {
76 class SieveDebugDialog;
77 class Vacation;
78 class ManageSieveScriptsDialog;
79 class VacationManager;
82 namespace MailCommon {
83 class FolderSelectionDialog;
84 class FavoriteCollectionWidget;
87 class KMAIL_EXPORT KMMainWidget : public QWidget
89 Q_OBJECT
91 public:
92 typedef QList<KMMainWidget*> PtrList;
94 KMMainWidget(QWidget *parent, KXMLGUIClient *aGUIClient,
95 KActionCollection *actionCollection,
96 KSharedConfig::Ptr config = KMKernel::self()->config() );
97 virtual ~KMMainWidget();
98 void destruct();
100 /** Read configuration options before widgets are created. */
101 void readPreConfig();
103 /** Read configuration for current folder. */
104 void readFolderConfig();
106 /** Write configuration for current folder. */
107 void writeFolderConfig();
109 /** Read configuration options after widgets are created. */
110 void readConfig();
112 /** Write configuration options. */
113 void writeConfig(bool force = true);
115 void writeReaderConfig();
117 /** Easy access to main components of the window. */
118 KMReaderWin* messageView() const { return mMsgView; }
119 /** Access to the header list pane. */
120 CollectionPane* messageListPane() const { return mMessagePane; }
122 QSharedPointer<MailCommon::FolderCollection> currentFolder() const;
124 static void cleanup();
125 QAction *action( const QString &name ) { return mActionCollection->action( name ); }
126 KActionMenu *filterMenu() const { return mFilterMenu; }
127 KActionMenu *mailingListActionMenu() const { return mMsgActions->mailingListActionMenu(); }
128 KAction *editAction() const { return mMsgActions->editAction(); }
129 KAction *sendAgainAction() const { return mSendAgainAction; }
130 KAction *sendQueuedAction() const { return mSendQueued; }
131 KActionMenu *sendQueueViaMenu() const { return mSendActionMenu; }
133 KMail::MessageActions *messageActions() const { return mMsgActions; }
136 Returns a list of all KMMainWidgets. Warning, the list itself can be 0.
137 @return the list of all main widgets, or 0 if it is not yet initialized
139 static const PtrList *mainWidgetList();
141 QWidget *vacationScriptIndicator() const;
142 void updateVacationScriptStatus();
144 MailCommon::FolderTreeView *folderTreeView() const {
145 return mFolderTreeWidget->folderTreeView();
148 /** Returns the XML GUI client. */
149 KXMLGUIClient* guiClient() const { return mGUIClient; }
151 KMail::TagActionManager *tagActionManager() const;
153 KMail::FolderShortcutActionManager *folderShortcutActionManager() const;
154 void savePaneSelection();
156 void updatePaneTagComboBox();
158 void clearViewer();
160 void addRecentFile(const KUrl& mUrl);
161 void updateQuickSearchLineText();
163 public slots:
164 // Moving messages around
166 * This will ask for a destination folder and move the currently selected
167 * messages (in MessageListView) into it.
169 void slotMoveSelectedMessageToFolder();
171 // Copying messages around
174 * This will ask for a destination folder and copy the currently selected
175 * messages (in MessageListView) into it.
177 void slotCopySelectedMessagesToFolder();
180 * Implements the "move to trash" action
182 void slotTrashSelectedMessages();
184 void slotCheckMail();
186 void slotCheckMailOnStartup();
189 Select the given folder
190 If the folder is 0 the intro is shown
192 void folderSelected( const Akonadi::Collection & col );
195 Open a separate viewer window containing the specified message.
197 void slotMessageActivated( const Akonadi::Item & );
200 Opens mail in the internal viewer.
202 void slotMessageSelected( const Akonadi::Item & );
204 void slotItemsFetchedForActivation( const Akonadi::Item::List &list );
205 void slotMessageStatusChangeRequest( const Akonadi::Item &, const Akonadi::MessageStatus &, const Akonadi::MessageStatus & );
208 void slotReplaceMsgByUnencryptedVersion();
211 Update message menu
213 void updateMessageMenu();
216 Start a timer to update message actions
218 void startUpdateMessageActionsTimer();
220 /** Update message actions */
221 void updateMessageActions( bool fast = false );
222 void updateMessageActionsDelayed();
224 /** Clear and create actions for marked filters */
225 void clearFilterActions();
226 void initializeFilterActions();
229 /** Trigger the dialog for editing out-of-office scripts. */
230 void slotEditVacation(const QString &serverName = QString());
232 /** Adds if not existing/removes if existing the tag identified by @p aLabel
233 in all selected messages */
234 void slotUpdateMessageTagList( const Akonadi::Tag &tag );
235 void slotSelectMoreMessageTagList();
238 * Convenience function to get the action collection in a list.
240 * @return a list of action collections. The list only has one item, and
241 * that is the action collection of this main widget as returned
242 * by actionCollection().
244 QList<KActionCollection*> actionCollections() const;
247 KAction *akonadiStandardAction( Akonadi::StandardActionManager::Type type );
248 KAction *akonadiStandardAction( Akonadi::StandardMailActionManager::Type type );
249 Akonadi::StandardMailActionManager *standardMailActionManager() const { return mAkonadiStandardActionManager; }
251 void refreshMessageListSelection();
253 void slotStartCheckMail();
254 void slotEndCheckMail();
256 void slotCollectionProperties();
257 void slotRemoveDuplicates();
258 void slotRemoveDuplicatesDone( KJob* );
259 void slotRemoveDuplicatesCanceled( KPIM::ProgressItem* );
260 void slotRemoveDuplicatesUpdate( KJob *, const QString& );
262 void slotSelectCollectionFolder( const Akonadi::Collection & col );
264 void restoreCollectionFolderViewConfig();
265 signals:
266 void messagesTransfered( bool );
267 void captionChangeRequest( const QString &caption );
268 void recreateGui();
270 protected:
271 void setupActions();
272 void createWidgets();
273 void deleteWidgets();
274 void layoutSplitters();
275 void newFromTemplate( const Akonadi::Item& );
276 void moveSelectedMessagesToFolder( const Akonadi::Collection & dest );
277 void copySelectedMessagesToFolder( const Akonadi::Collection& dest );
280 virtual void showEvent( QShowEvent *event );
282 KActionCollection *actionCollection() const { return mActionCollection; }
285 @return the correct config dialog depending on whether the parent of
286 the mainWidget is a KPart or a KMMainWindow.
287 When dealing with geometries, use this pointer
289 KSharedConfig::Ptr config();
291 protected slots:
292 void updateFileMenu();
293 void slotCheckOneAccount( QAction* );
294 void getAccountMenu();
295 void getTransportMenu();
296 void slotHelp();
297 void slotFilter();
298 void slotManageSieveScripts();
299 void slotAddrBook();
300 void slotImport();
301 void slotCompose();
302 void slotPostToML();
303 void slotFolderMailingListProperties();
304 void slotShowFolderShortcutDialog();
305 void slotExpireFolder();
306 void slotExpireAll();
307 void slotArchiveFolder();
308 void slotRemoveFolder();
309 void slotDelayedRemoveFolder( KJob* );
310 void slotEmptyFolder();
311 void slotAddFavoriteFolder();
312 void slotShowSelectedFolderInPane();
313 void slotOverrideHtml();
314 void slotOverrideHtmlLoadExt();
315 void slotMessageQueuedOrDrafted();
316 void slotUseTemplate();
317 void slotDeleteMsg( bool confirmDelete = true ); // completely delete message
318 void slotTrashThread();
319 void slotDeleteThread( bool confirmDelete = true ); // completely delete thread
320 void slotUndo();
321 void slotReadOn();
322 void slotSaveMsg();
323 void slotOpenMsg();
324 void slotSaveAttachments();
325 void slotJumpToFolder();
326 void slotResendMsg();
327 void slotCheckVacation();
328 void slotDebugSieve();
329 void slotStartCertManager();
330 void slotStartWatchGnuPG();
331 void slotApplyFilters();
332 void slotApplyFiltersOnFolder();
333 void slotExpandThread();
334 void slotExpandAllThreads();
335 void slotCollapseThread();
336 void slotCollapseAllThreads();
337 void slotSetThreadStatusUnread();
338 void slotSetThreadStatusRead();
339 void slotSetThreadStatusImportant();
340 void slotSetThreadStatusToAct();
341 void slotSetThreadStatusWatched();
342 void slotSetThreadStatusIgnored();
343 void slotSendQueued();
344 void slotSendQueuedVia( QAction* item );
345 void slotOnlineStatus();
346 void slotUpdateOnlineStatus( GlobalSettings::EnumNetworkState::type );
347 void slotMessagePopup(const Akonadi::Item& ,const KUrl&,const KUrl &imageUrl,const QPoint& );
348 void slotContactSearchJobForMessagePopupDone( KJob *job );
349 void slotMarkAll();
350 void slotFocusQuickSearch();
351 bool slotSearch();
352 void slotIntro();
353 void slotShowStartupFolder();
354 /** Show tip-of-the-day, forced */
355 void slotShowTip();
356 void slotAntiSpamWizard();
357 void slotAntiVirusWizard();
358 void slotFilterLogViewer();
359 void slotAccountWizard();
360 void slotImportWizard();
362 /** Message navigation */
363 void slotSelectNextMessage();
364 void slotExtendSelectionToNextMessage();
365 void slotSelectNextUnreadMessage();
366 void slotSelectPreviousMessage();
367 void slotExtendSelectionToPreviousMessage();
368 void slotSelectPreviousUnreadMessage();
369 void slotFocusOnNextMessage();
370 void slotFocusOnPrevMessage();
371 void slotSelectFirstMessage();
372 void slotSelectLastMessage();
373 void slotSelectFocusedMessage();
375 void slotNextUnreadFolder();
376 void slotPrevUnreadFolder();
378 /** etc. */
379 void slotDisplayCurrentMessage();
381 void slotShowNewFromTemplate();
382 void slotDelayedShowNewFromTemplate( KJob* );
383 void slotNewFromTemplate( QAction* );
385 /** Update the undo action */
386 void slotUpdateUndo();
388 /** Update html and threaded messages preferences in Folder menu. */
389 void updateFolderMenu();
391 /** Settings menu */
393 /** XML-GUI stuff */
394 void slotEditNotifications();
396 /** Slot to reply to a message */
397 void slotCustomReplyToMsg( const QString &tmpl );
398 void slotCustomReplyAllToMsg( const QString &tmpl );
399 void slotForwardInlineMsg();
400 void slotForwardAttachedMsg();
401 void slotRedirectMsg();
402 void slotCustomForwardMsg( const QString &tmpl );
403 void slotSubjectFilter();
404 void slotFromFilter();
405 void slotToFilter();
407 void slotConfigChanged();
409 /** Show a splash screen for the longer-lasting operation */
410 void slotShowBusySplash();
413 Show a message screen explaining that we are currently offline, when
414 an online folder is selected.
416 void showOfflinePage();
417 void showResourceOfflinePage();
418 void updateVacationScriptStatus(bool active , const QString &serverName = QString());
421 void slotShowExpiryProperties();
422 void slotItemAdded( const Akonadi::Item &, const Akonadi::Collection& col);
423 void slotItemRemoved( const Akonadi::Item & );
424 void slotItemMoved( const Akonadi::Item &item, const Akonadi::Collection &from, const Akonadi::Collection &to );
425 void slotCollectionStatisticsChanged( const Akonadi::Collection::Id, const Akonadi::CollectionStatistics& );
427 void slotAkonadiStandardActionUpdated();
428 void slotCollectionChanged( const Akonadi::Collection&, const QSet<QByteArray>& );
429 void slotCreateNewTab( bool );
430 void slotUpdateActionsAfterMailChecking();
431 void slotConfigureAutomaticArchiving();
432 void slotExportData();
433 void slotCreateAddressBookContact();
434 void slotOpenRecentMsg(const KUrl& url);
435 void slotConfigureSendLater();
437 private:
438 void checkAkonadiServerManagerState();
439 void updateHtmlMenuEntry();
441 void updateMoveAction( const Akonadi::CollectionStatistics& statistic );
442 void updateMoveAction( bool hasUnreadMails, bool hasMails );
444 void updateAllToTrashAction(int statistics);
446 /** Get override character encoding. */
447 QString overrideEncoding() const;
449 void moveMessageSelected( MessageList::Core::MessageItemSetReference ref, const Akonadi::Collection &dest, bool confirmOnDeletion = true );
451 void copyMessageSelected( const QList<Akonadi::Item> &selectMsg, const Akonadi::Collection &dest );
455 * Move the messages referenced by the specified set to trash.
456 * The set parameter must not be null and the ownership is passed
457 * to this function.
459 void trashMessageSelected( MessageList::Core::MessageItemSetReference ref );
461 * Set the status of the messages referenced by the specified set, eventually toggling it.
462 * The set parameter must not be null and the ownership is passed to this function.
464 void setMessageSetStatus( const QList<Akonadi::Item> &select,
465 const Akonadi::MessageStatus &status,
466 bool toggle
469 * Toggles a tag for the messages referenced by the specified set.
470 * The set parameter must not be null and the ownership is passed to this function.
472 void toggleMessageSetTag( const QList<Akonadi::Item> &select, const Akonadi::Tag &tag );
474 * This applies setMessageSetStatus() on the current thread.
476 void setCurrentThreadStatus( const Akonadi::MessageStatus &status, bool toggle );
478 void applyFilters( const QList< Akonadi::Item >& selectedMessages );
481 * Internal helper that creates the folder selection dialog used for the
482 * move and copy to folder actions on demand. Only folders where items can
483 * be added are listed.
485 MailCommon::FolderSelectionDialog* moveOrCopyToDialog();
488 * Internal helper that creates the folder selection dialog used for
489 * jumping to folders, or adding them as favourites. All folders are listed.
491 MailCommon::FolderSelectionDialog* selectFromAllFoldersDialog();
495 * Internal helper that applies the current settings so the
496 * favorite folder view.
498 void refreshFavoriteFoldersViewProperties();
500 void openFilterDialog(const QByteArray &field, const QString &value);
502 void showMessagePopup(const Akonadi::Item&msg ,const KUrl&aUrl,const KUrl &imageUrl,const QPoint& aPoint, bool contactAlreadyExists, bool uniqueContactFound);
504 void showCollectionProperties( const QString &pageToShow );
505 void showCollectionPropertiesContinued( const QString &pageToShow, QPointer<KPIM::ProgressItem> progressItem );
507 private slots:
508 void slotMoveMessageToTrash();
510 * Called when a "move to trash" operation is completed
512 void slotTrashMessagesCompleted( KMMoveCommand *command );
515 * Called when a "move" operation is completed
517 void slotMoveMessagesCompleted( KMMoveCommand *command );
520 * Called when a "copy" operation is completed
522 void slotCopyMessagesCompleted( KMCommand *command );
524 void slotRequestFullSearchFromQuickSearch();
525 void slotFolderChanged( const Akonadi::Collection& );
526 void slotCollectionFetched( int collectionId );
528 void itemsReceived(const Akonadi::Item::List &list );
529 void itemsFetchDone( KJob *job );
530 void itemsFetchForActivationDone( KJob *job );
532 void slotCollectionPropertiesContinued( KJob* job );
533 void slotCollectionPropertiesFinished( KJob *job );
534 void slotDeletionCollectionResult(KJob* job);
535 void slotServerSideSubscription();
536 void slotFetchItemsForFolderDone(KJob*job);
537 void slotServerStateChanged(Akonadi::ServerManager::State state);
538 void slotConfigureSubscriptionFinished(QDBusPendingCallWatcher* watcher);
539 void slotArchiveMails();
540 private:
541 // Message actions
542 KAction *mDeleteAction, *mTrashThreadAction,
543 *mDeleteThreadAction, *mSaveAsAction, *mUseAction,
544 *mSendAgainAction, *mApplyAllFiltersAction,
545 *mSaveAttachmentsAction, *mOpenAction,
546 *mMoveMsgToFolderAction, *mCollectionProperties, *mSendQueued;
547 KAction *mArchiveAction;
548 KActionMenu *mSendActionMenu;
549 // Filter actions
550 KActionMenu *mFilterMenu;
551 KAction *mExpireConfigAction;
552 KAction *mApplyFiltersOnFolder;
553 // Custom template actions menu
554 KActionMenu *mTemplateMenu;
556 KActionMenu *mThreadStatusMenu, *mApplyFilterActionsMenu;
557 KAction *mCopyActionMenu;
558 KAction *mMoveActionMenu;
559 KAction *mMarkThreadAsReadAction;
560 KAction *mMarkThreadAsUnreadAction;
561 KToggleAction *mToggleThreadImportantAction;
562 KToggleAction *mToggleThreadToActAction;
564 KToggleAction *mWatchThreadAction, *mIgnoreThreadAction;
566 MailCommon::FavoriteCollectionWidget *mFavoriteCollectionsView;
567 Akonadi::FavoriteCollectionsModel *mFavoritesModel;
568 QWidget *mSearchAndTree;
569 KMReaderWin *mMsgView;
570 QSplitter *mSplitter1, *mSplitter2, *mFolderViewSplitter;
571 Akonadi::Collection mTemplateFolder;
572 QMenu *mActMenu;
573 QMenu *mSendMenu;
574 bool mLongFolderList;
575 bool mStartupDone;
576 bool mWasEverShown;
577 bool mHtmlPref, mHtmlLoadExtPref,
578 mFolderHtmlPref, mFolderHtmlLoadExtPref,
579 mReaderWindowActive, mReaderWindowBelow;
580 bool mEnableFavoriteFolderView;
581 bool mEnableFolderQuickSearch;
583 QPointer<KMail::SearchWindow> mSearchWin;
585 KAction *mExpireFolderAction,
586 *mFolderMailingListPropertiesAction,
587 *mShowFolderShortcutDialogAction,
588 *mArchiveFolderAction, *mMessageNewList;
589 KToggleAction *mPreferHtmlAction, *mPreferHtmlLoadExtAction;
591 QTimer *menutimer;
592 QTimer *mShowBusySplashTimer;
594 KSieveUi::VacationManager *mVacationManager;
595 #if !defined(NDEBUG)
596 QPointer<KSieveUi::SieveDebugDialog> mSieveDebugDialog;
597 #endif
598 KActionCollection *mActionCollection;
599 QAction *mToolbarActionSeparator;
600 QVBoxLayout *mTopLayout;
601 bool mDestructed;
602 QList<QAction*> mFilterMenuActions;
603 QList<QAction*> mFilterTBarActions;
604 QList<KMMetaFilterActionCommand*> mFilterCommands;
606 KMail::TagActionManager *mTagActionManager;
607 KMail::FolderShortcutActionManager *mFolderShortcutActionManager;
608 KSharedConfig::Ptr mConfig;
609 KXMLGUIClient *mGUIClient;
611 KMail::MessageActions *mMsgActions;
612 Akonadi::StandardMailActionManager *mAkonadiStandardActionManager;
613 CollectionPane *mMessagePane;
614 QSharedPointer<MailCommon::FolderCollection> mCurrentFolder;
616 MailCommon::FolderTreeWidget *mFolderTreeWidget;
618 KMail::VacationScriptIndicatorWidget *mVacationScriptIndicator;
619 bool mVacationIndicatorActive;
620 bool mGoToFirstUnreadMessageInSelectedFolder;
621 MessageList::Core::PreSelectionMode mPreSelectionMode;
623 QTimer mCheckMailTimer;
625 QPointer<MailCommon::FolderSelectionDialog> mMoveOrCopyToDialog;
626 QPointer<MailCommon::FolderSelectionDialog> mSelectFromAllFoldersDialog;
627 KAction *mServerSideSubscription;
628 KRecentFilesAction *mOpenRecentAction;
629 QPointer<KSieveUi::ManageSieveScriptsDialog> mManageSieveDialog;
630 KAction *mQuickSearchAction;
633 #endif