1 /* Copyright (C) 2006 - 2016 Jan Kundrát <jkt@kde.org>
2 Copyright (C) 2014 - 2015 Stephan Platz <trojita@paalsteek.de>
4 This file is part of the Trojita Qt IMAP e-mail client,
5 http://trojita.flaska.net/
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of
10 the License or (at your option) version 3 or any later version
11 accepted by the membership of KDE e.V. (or its successor approved
12 by the membership of KDE e.V.), which shall act as a proxy
13 defined in Section 14 of version 3 of the license.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #ifndef VIEW_MESSAGEVIEW_H
24 #define VIEW_MESSAGEVIEW_H
26 #include <QPersistentModelIndex>
30 #include "Composer/Recipients.h"
31 #include "Gui/PartWalker.h"
32 #include "Imap/Model/FavoriteTagsModel.h"
43 namespace Cryptography
{
49 class MsgPartNetAccessManager
;
65 class AbstractPartWidget
;
66 class EmbeddedWebView
;
69 class ExternalElementsWidget
;
74 /** @short Widget for displaying complete e-mail messages as available from the IMAP server
76 Widget which can render a regular message as exported by the Imap::Mailbox::Model model.
77 Notably, this class will not render message/rfc822 MIME parts.
79 class MessageView
: public QWidget
83 MessageView(QWidget
*parent
, QSettings
*settings
, Plugins::PluginManager
*pluginManager
,
84 Imap::Mailbox::FavoriteTagsModel
*m_favoriteTags
);
87 void setNetworkWatcher(Imap::Mailbox::NetworkWatcher
*netWatcher
);
88 void reply(MainWindow
*mainWindow
, Composer::ReplyMode mode
);
89 void forward(MainWindow
*mainWindow
, const Composer::ForwardMode mode
);
90 QModelIndex
currentMessage() const;
91 Plugins::PluginManager
*pluginManager() const;
92 QSettings
* profileSettings() const;
94 void setMessage(const QModelIndex
&index
);
96 void setHomepageUrl(const QUrl
&homepage
);
97 void stopAutoMarkAsRead();
102 void showEvent(QShowEvent
*se
) override
;
103 /** @short Forwarded method to the bodyWidget() */
104 void searchDialogRequested();
107 void externalsRequested(const QUrl
&url
);
108 void enableExternalData();
109 void newLabelAction(const QString
&tag
);
110 void deleteLabelAction(const QString
&tag
);
111 void partContextMenuRequested(const QPoint
&point
);
112 void partLinkHovered(const QString
&link
, const QString
&title
, const QString
&textContent
);
113 void triggerSearchDialogBy(EmbeddedWebView
*w
);
114 void onWebViewLoadStarted();
115 void onWebViewLoadFinished();
117 void messageChanged();
118 void messageModelChanged(QAbstractItemModel
*model
);
119 void linkHovered(const QString
&url
);
120 void searchRequestedBy(EmbeddedWebView
*webView
);
121 void transferError(const QString
&errorString
);
123 bool eventFilter(QObject
*object
, QEvent
*event
) override
;
124 Imap::Message::Envelope
envelope() const;
125 QString
quoteText() const;
126 void showMessageNow();
127 AbstractPartWidget
*bodyWidget() const;
128 void unsetPreviousMessage();
129 void clearWaitingConns();
131 QStackedLayout
*m_stack
;
132 QWebView
*m_homePage
;
134 QWidget
*m_messageWidget
;
135 QBoxLayout
*m_msgLayout
;
136 EnvelopeView
*m_envelope
;
137 ExternalElementsWidget
*externalElements
;
139 QPersistentModelIndex message
;
140 Cryptography::MessageModel
*messageModel
;
141 Imap::Network::MsgPartNetAccessManager
*netAccess
;
142 QPointer
<Imap::Mailbox::NetworkWatcher
> m_netWatcher
;
143 QTimer
*markAsReadTimer
;
144 QWidget
*m_bodyWidget
;
145 QAction
*m_zoomIn
, *m_zoomOut
, *m_zoomOriginal
;
146 QAction
*m_findAction
;
148 std::unique_ptr
<PartWidgetFactory
> factory
;
149 Spinner
*m_loadingSpinner
;
150 QSettings
*m_settings
;
151 Plugins::PluginManager
*m_pluginManager
;
152 QSet
<QWebView
*> m_loadingItems
;
154 std::vector
<QMetaObject::Connection
> m_waitingMessageConns
;
156 MessageView(const MessageView
&); // don't implement
157 MessageView
&operator=(const MessageView
&); // don't implement
159 friend class SimplePartWidget
; // needs access to onWebViewLoadStarted/onWebViewLoadFinished
164 #endif // VIEW_MESSAGEVIEW_H