GUI: enable/disable the reply actions based on the message's contents
[trojita.git] / src / Gui / MessageView.h
blob5975b2aee3cf5cc222c3c52e70ebd994669a1f4e
1 /* Copyright (C) 2006 - 2012 Jan Kundrát <jkt@flaska.net>
3 This file is part of the Trojita Qt IMAP e-mail client,
4 http://trojita.flaska.net/
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License as
8 published by the Free Software Foundation; either version 2 of
9 the License or (at your option) version 3 or any later version
10 accepted by the membership of KDE e.V. (or its successor approved
11 by the membership of KDE e.V.), which shall act as a proxy
12 defined in Section 14 of version 3 of the license.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef VIEW_MESSAGEVIEW_H
23 #define VIEW_MESSAGEVIEW_H
25 #include <QPersistentModelIndex>
26 #include <QWidget>
27 #include "Composer/Recipients.h"
29 class QBoxLayout;
30 class QLabel;
31 class QLayout;
32 class QTimer;
33 class QUrl;
34 class QWebView;
36 namespace Imap
38 namespace Network
40 class MsgPartNetAccessManager;
42 namespace Message
44 class Envelope;
48 namespace Gui
51 class MainWindow;
52 class PartWidgetFactory;
53 class ExternalElementsWidget;
54 class TagListWidget;
57 /** @short Widget for displaying complete e-mail messages as available from the IMAP server
59 Widget which can render a regular message as exported by the Imap::Mailbox::Model model.
60 Notably, this class will not render message/rfc822 MIME parts.
62 class MessageView : public QWidget
64 Q_OBJECT
65 public:
66 explicit MessageView(QWidget *parent=0);
67 ~MessageView();
69 void reply(MainWindow *mainWindow, Composer::ReplyMode mode);
70 QModelIndex currentMessage() const;
71 public slots:
72 void setMessage(const QModelIndex &index);
73 void setEmpty();
74 void setHomepageUrl(const QUrl &homepage);
75 protected:
76 void showEvent(QShowEvent *se);
77 private slots:
78 void markAsRead();
79 void externalsRequested(const QUrl &url);
80 void externalsEnabled();
81 void linkInTitleHovered(const QString &target);
82 void newLabelAction(const QString &tag);
83 void deleteLabelAction(const QString &tag);
84 void handleDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
85 void headerLinkActivated(QString);
86 void partContextMenuRequested(const QPoint &point);
87 void partLinkHovered(const QString &link, const QString &title, const QString &textContent);
88 signals:
89 void messageChanged();
90 void linkHovered(const QString &url);
91 private:
92 bool eventFilter(QObject *object, QEvent *event);
93 Imap::Message::Envelope envelope() const;
94 QString headerText();
95 QString quoteText() const;
97 QWidget *viewer;
98 QWidget *headerSection;
99 QLabel *header;
100 ExternalElementsWidget *externalElements;
101 QBoxLayout *layout;
102 TagListWidget *tags;
103 QPersistentModelIndex message;
104 Imap::Network::MsgPartNetAccessManager *netAccess;
105 QTimer *markAsReadTimer;
106 QWebView *emptyView;
107 PartWidgetFactory *factory;
109 MessageView(const MessageView &); // don't implement
110 MessageView &operator=(const MessageView &); // don't implement
115 #endif // VIEW_MESSAGEVIEW_H