Clazy fix++
[kdepim.git] / kmail / kmreaderwin.h
blobf21736902249e2c415417c217ec0c3da2b236221
1 /*
2 This file is part of KMail, the KDE mail client.
3 Copyright (c) 1997 Markus Wuebben <markus.wuebben@kde.org>
4 Copyright (C) 2013-2015 Laurent Montel <montel@kde.org>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU 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 KMREADERWIN_H
22 #define KMREADERWIN_H
24 #include <QWidget>
25 #include <qurl.h>
26 #include <messageviewer/viewer.h>
27 #include <messageviewer/bodypart.h>
28 #include <AkonadiCore/Item>
29 #include <KContacts/Addressee>
30 class KActionCollection;
31 class QAction;
32 class KToggleAction;
33 class QMenu;
34 namespace MessageViewer
36 class CSSHelper;
37 class AttachmentStrategy;
40 class KJob;
42 /**
43 This class implements a "reader window", that is a window
44 used for reading or viewing messages.
47 class KMReaderWin: public QWidget
49 Q_OBJECT
51 public:
52 explicit KMReaderWin(QWidget *parent, QWidget *mainWindow,
53 KActionCollection *actionCollection, Qt::WindowFlags f = Q_NULLPTR);
54 virtual ~KMReaderWin();
56 /** Read settings from app's config file. */
57 void readConfig();
59 /** Get/set the message attachment strategy. */
60 const MessageViewer::AttachmentStrategy *attachmentStrategy() const;
62 void setAttachmentStrategy(const MessageViewer::AttachmentStrategy *strategy);
64 /** Get selected override character encoding.
65 @return The encoding selected by the user or an empty string if auto-detection
66 is selected. */
67 QString overrideEncoding() const;
68 /** Set the override character encoding. */
69 void setOverrideEncoding(const QString &encoding);
70 virtual void setPrinting(bool enable);
72 void setMessage(const Akonadi::Item &item, MessageViewer::Viewer::UpdateMode updateMode = MessageViewer::Viewer::Delayed);
74 void setMessage(const KMime::Message::Ptr &message);
76 /** Instead of settings a message to be shown sets a message part
77 to be shown */
78 void setMsgPart(KMime::Content *aMsgPart);
80 /** Clear the reader and discard the current message. */
81 void clear(bool force = false);
83 void update(bool force = false);
85 /** Return selected text */
86 QString copyText() const;
88 /** Override default html mail setting */
89 bool htmlOverride() const;
90 void setHtmlOverride(bool override);
91 MessageViewer::Viewer::DisplayFormatMessage displayFormatMessageOverwrite() const;
92 void setDisplayFormatMessageOverwrite(MessageViewer::Viewer::DisplayFormatMessage format);
94 /** Override default load external references setting */
95 bool htmlLoadExtOverride() const;
96 void setHtmlLoadExtOverride(bool override);
98 /** Is html mail to be supported? Takes into account override */
99 bool htmlMail() const;
101 /** Is loading ext. references to be supported? Takes into account override */
102 bool htmlLoadExternal();
104 /** Returns the MD5 hash for the list of new features */
105 static QString newFeaturesMD5();
107 /** Display a generic HTML splash page instead of a message */
108 void displaySplashPage(const QString &templateName, const QVariantHash &data);
110 /** Display the about page instead of a message */
111 void displayAboutPage();
113 /** Display the 'please wait' page instead of a message */
114 void displayBusyPage();
115 /** Display the 'we are currently in offline mode' page instead of a message */
116 void displayOfflinePage();
118 void displayResourceOfflinePage();
120 bool isFixedFont() const;
121 void setUseFixedFont(bool useFixedFont);
122 MessageViewer::Viewer *viewer()
124 return mViewer;
126 KToggleAction *toggleFixFontAction() const;
127 QAction *mailToComposeAction() const
129 return mMailToComposeAction;
131 QAction *mailToReplyAction() const
133 return mMailToReplyAction;
135 QAction *mailToForwardAction() const
137 return mMailToForwardAction;
139 QAction *addAddrBookAction() const
141 return mAddAddrBookAction;
143 QAction *openAddrBookAction() const
145 return mOpenAddrBookAction;
147 QAction *copyAction() const;
148 QAction *selectAllAction() const;
149 QAction *copyURLAction() const;
150 QAction *copyImageLocation() const;
151 QAction *urlOpenAction() const;
152 QAction *urlSaveAsAction() const
154 return mUrlSaveAsAction;
156 QAction *addBookmarksAction() const
158 return mAddBookmarksAction;
160 QAction *toggleMimePartTreeAction() const;
161 QAction *speakTextAction() const;
162 QAction *downloadImageToDiskAction() const;
163 QAction *viewSourceAction() const;
164 QAction *findInMessageAction() const;
165 QAction *saveAsAction() const;
166 QAction *saveMessageDisplayFormatAction() const;
167 QAction *resetMessageDisplayFormatAction() const;
168 QAction *blockImage() const;
169 QAction *openBlockableItems() const;
170 QAction *expandShortUrlAction() const;
172 QAction *editContactAction() const
174 return mEditContactAction;
177 QMenu *viewHtmlOption() const
179 return mViewHtmlOptions;
181 QAction *shareImage() const
183 return mShareImage;
186 QAction *addToExistingContactAction() const
188 return mAddEmailToExistingContactAction;
191 Akonadi::Item message() const;
193 QWidget *mainWindow()
195 return mMainWindow;
198 /** Enforce message decryption. */
199 void setDecryptMessageOverwrite(bool overwrite = true);
201 MessageViewer::CSSHelper *cssHelper() const;
203 bool printSelectedText(bool preview);
205 void setContactItem(const Akonadi::Item &contact, const KContacts::Addressee &address);
206 void clearContactItem();
207 bool adblockEnabled() const;
208 bool isAShortUrl(const QUrl &url) const;
210 bool mimePartTreeIsEmpty() const;
211 KActionMenu *shareServiceUrlMenu() const;
213 QList<QAction *> viewerPluginActionList(MessageViewer::ViewerPluginInterface::SpecificFeatureTypes features);
215 Q_SIGNALS:
216 /** Emitted after parsing of a message to have it stored
217 in unencrypted state in it's folder. */
218 void replaceMsgByUnencryptedVersion();
220 void showStatusBarMessage(const QString &message);
222 public Q_SLOTS:
223 /** Force update even if message is the same */
224 void clearCache();
226 /** The user selected "Find" from the menu. */
227 void slotFind();
228 /** Copy the selected text to the clipboard */
229 void slotCopySelectedText();
230 /** Operations on mailto: URLs. */
231 void slotMailtoReply();
232 void slotMailtoCompose();
233 void slotMailtoForward();
234 void slotMailtoAddAddrBook();
235 void slotMailtoOpenAddrBook();
236 /** Save the page to a file */
237 void slotUrlSave();
238 void slotAddBookmarks();
239 void slotUrlClicked(const Akonadi::Item &, const QUrl &);
240 void slotShowReader(KMime::Content *, bool html, const QString &);
241 void slotShowMessage(const KMime::Message::Ptr &message, const QString &encoding);
242 void slotDeleteMessage(const Akonadi::Item &);
243 void slotSaveImageOnDisk();
245 void slotPrintComposeResult(KJob *job);
246 void slotEditContact();
247 void contactStored(const Akonadi::Item &item);
248 void slotContactEditorError(const QString &error);
250 void slotContactHtmlOptions();
251 void slotShareImage();
252 void slotMailToAddToExistingContact();
254 protected:
255 QUrl urlClicked() const;
256 QUrl imageUrlClicked() const;
258 private:
259 void createActions();
260 void updateHtmlActions();
262 private:
263 KContacts::Addressee mSearchedAddress;
264 Akonadi::Item mSearchedContact;
265 QWidget *mMainWindow;
266 KActionCollection *mActionCollection;
268 QAction *mMailToComposeAction;
269 QAction *mMailToReplyAction;
270 QAction *mMailToForwardAction;
271 QAction *mAddAddrBookAction;
272 QAction *mOpenAddrBookAction;
273 QAction *mUrlSaveAsAction;
274 QAction *mAddBookmarksAction;
275 QAction *mImageUrlSaveAsAction;
276 QAction *mEditContactAction;
277 QAction *mViewAsHtml;
278 QAction *mLoadExternalReference;
279 QAction *mShareImage;
280 QAction *mAddEmailToExistingContactAction;
282 QMenu *mViewHtmlOptions;
284 MessageViewer::Viewer *mViewer;
287 #endif