make the setings dialog adapt to the pages size
[trojita.git] / src / Gui / AttachmentView.h
blob14599c42d2cb9befb69b26365c25d175380dfe16
1 /* Copyright (C) 2006 - 2014 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 ATTACHMENTVIEW_H
23 #define ATTACHMENTVIEW_H
25 #include <QFrame>
26 #include <QModelIndex>
27 #include "Gui/AbstractPartWidget.h"
29 class QLabel;
30 class QMenu;
31 class QNetworkReply;
32 class QPushButton;
33 class QTemporaryFile;
34 class QToolButton;
36 namespace Imap
38 namespace Network
40 class MsgPartNetAccessManager;
44 namespace Gui
47 class MessageView;
49 /** @short Widget depicting an attachment
51 This widget provides a graphical representation about an e-mail attachment,
52 that is, an interactive item which shows some basic information like the MIME
53 type of the body part and the download button. It also includes code for
54 handling the actual download.
56 class AttachmentView : public QFrame, public AbstractPartWidget
58 Q_OBJECT
59 public:
60 AttachmentView(QWidget *parent, Imap::Network::MsgPartNetAccessManager *manager, const QModelIndex &m_partIndex,
61 MessageView *messageView, QWidget *contentWidget);
62 virtual QString quoteMe() const;
63 virtual void reloadContents();
64 protected:
65 virtual void mouseMoveEvent(QMouseEvent *event);
66 virtual void mousePressEvent(QMouseEvent *event);
67 virtual void paintEvent(QPaintEvent *event);
68 private slots:
69 void slotDownloadAttachment();
70 void slotOpenAttachment();
72 void indicateHover();
73 void openDownloadedAttachment();
74 void slotFileNameRequestedOnOpen(QString *fileName);
75 void slotFileNameRequested(QString *fileName);
76 void enableDownloadAgain();
77 void onOpenFailed();
78 void updateShowHideAttachmentState();
79 void showMenu();
80 void showMenuOrPreview();
81 void toggleIconCursor();
83 private:
84 QPersistentModelIndex m_partIndex;
86 MessageView *m_messageView;
88 QAction *m_downloadAttachment;
89 QAction *m_openAttachment;
90 QAction *m_showHideAttachment;
91 QMenu *m_menu;
92 QToolButton *m_icon;
93 QLabel *m_fileName;
95 Imap::Network::MsgPartNetAccessManager *m_netAccess;
97 QTemporaryFile *m_tmpFile;
98 QWidget *m_contentWidget;
100 QPoint m_dragStartPos;
102 bool previewIsShown() const;
104 AttachmentView(const AttachmentView &); // don't implement
105 AttachmentView &operator=(const AttachmentView &); // don't implement
110 #endif // ATTACHMENTVIEW_H