File indexing completed on 2024-05-26 05:28:16
0001 /* Copyright (C) 2006 - 2014 Jan Kundrát <jkt@flaska.net> 0002 0003 This file is part of the Trojita Qt IMAP e-mail client, 0004 http://trojita.flaska.net/ 0005 0006 This program is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU General Public License as 0008 published by the Free Software Foundation; either version 2 of 0009 the License or (at your option) version 3 or any later version 0010 accepted by the membership of KDE e.V. (or its successor approved 0011 by the membership of KDE e.V.), which shall act as a proxy 0012 defined in Section 14 of version 3 of the license. 0013 0014 This program is distributed in the hope that it will be useful, 0015 but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0017 GNU General Public License for more details. 0018 0019 You should have received a copy of the GNU General Public License 0020 along with this program. If not, see <http://www.gnu.org/licenses/>. 0021 */ 0022 #ifndef GUI_PARTWIDGET_H 0023 #define GUI_PARTWIDGET_H 0024 0025 #include <QFrame> 0026 #include <QTabWidget> 0027 0028 #include "Gui/AbstractPartWidget.h" 0029 #include "Gui/MessageView.h" 0030 #include "Gui/PartWalker.h" 0031 #include "Gui/Spinner.h" 0032 #include "UiUtils/PartLoadingOptions.h" 0033 0034 class QModelIndex; 0035 class QPushButton; 0036 0037 namespace Gui 0038 { 0039 0040 /** @short Message quoting support for multipart/alternative MIME type */ 0041 class MultipartAlternativeWidget: public QTabWidget, public AbstractPartWidget 0042 { 0043 Q_OBJECT 0044 public: 0045 MultipartAlternativeWidget(QWidget *parent, PartWidgetFactory *factory, 0046 const QModelIndex &partIndex, 0047 const int recursionDepth, const UiUtils::PartLoadingOptions options); 0048 QString quoteMe() const override; 0049 bool searchDialogRequested() override; 0050 void reloadContents() override; 0051 void zoomIn() override; 0052 void zoomOut() override; 0053 void zoomOriginal() override; 0054 protected: 0055 bool eventFilter(QObject *o, QEvent *e) override; 0056 }; 0057 0058 /** @short Widget to display status information when processing message parts */ 0059 class PartStatusWidget: public QFrame 0060 { 0061 Q_OBJECT 0062 public: 0063 explicit PartStatusWidget(QWidget *parent); 0064 0065 void showStatus(const QString &icon, const QString &status, const QString &details = QString()); 0066 0067 protected slots: 0068 void showDetails(); 0069 0070 private: 0071 QLabel *m_icon, *m_text, *m_details; 0072 QFrame *m_seperator; 0073 QPushButton *m_detailButton; 0074 }; 0075 0076 /** @short Base class for handling parts where the structure of the chilren is not known yet */ 0077 class AsynchronousPartWidget: public QFrame, public AbstractPartWidget 0078 { 0079 Q_OBJECT 0080 public: 0081 AsynchronousPartWidget(QWidget *parent, PartWidgetFactory *factory, const QModelIndex &partIndex, const int recursionDepth, 0082 const UiUtils::PartLoadingOptions loadingOptions); 0083 0084 protected slots: 0085 void handleRowsInserted(const QModelIndex &parent, int first, int last); 0086 void handleLayoutChanged(const QList<QPersistentModelIndex> &parents); 0087 void handleError(const QModelIndex &parent, const QString &status, const QString &details); 0088 void handleDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); 0089 virtual void updateStatusIndicator() = 0; 0090 0091 private: 0092 void buildWidgets(); 0093 0094 protected: 0095 virtual QWidget *addingOneWidget(const QModelIndex &index, UiUtils::PartLoadingOptions options); 0096 0097 PartStatusWidget *m_statusWidget; 0098 PartWidgetFactory *m_factory; 0099 QPersistentModelIndex m_partIndex; 0100 const int m_recursionDepth; 0101 const UiUtils::PartLoadingOptions m_options; 0102 }; 0103 0104 /** @short Widget for multipart/signed or multipart/encrypted MIME types */ 0105 class MultipartSignedEncryptedWidget: public AsynchronousPartWidget 0106 { 0107 Q_OBJECT 0108 public: 0109 MultipartSignedEncryptedWidget(QWidget *parent, PartWidgetFactory *factory, 0110 const QModelIndex &partIndex, const int recursionDepth, 0111 const UiUtils::PartLoadingOptions loadingOptions); 0112 QString quoteMe() const override; 0113 bool searchDialogRequested() override; 0114 void reloadContents() override; 0115 void zoomIn() override; 0116 void zoomOut() override; 0117 void zoomOriginal() override; 0118 protected slots: 0119 void updateStatusIndicator() override; 0120 protected: 0121 QWidget *addingOneWidget(const QModelIndex &index, UiUtils::PartLoadingOptions options) override; 0122 }; 0123 0124 /** @short Message quoting support for generic multipart/ * */ 0125 class GenericMultipartWidget: public QWidget, public AbstractPartWidget 0126 { 0127 Q_OBJECT 0128 public: 0129 GenericMultipartWidget(QWidget *parent, PartWidgetFactory *factory, 0130 const QModelIndex &partIndex, const int recursionDepth, 0131 const UiUtils::PartLoadingOptions loadingOptions); 0132 QString quoteMe() const override; 0133 bool searchDialogRequested() override; 0134 void reloadContents() override; 0135 void zoomIn() override; 0136 void zoomOut() override; 0137 void zoomOriginal() override; 0138 }; 0139 0140 /** @short Message quoting support for generic multipart/ * */ 0141 class Message822Widget: public QWidget, public AbstractPartWidget 0142 { 0143 Q_OBJECT 0144 public: 0145 Message822Widget(QWidget *parent, PartWidgetFactory *factory, 0146 const QModelIndex &partIndex, const int recursionDepth, 0147 const UiUtils::PartLoadingOptions loadingOptions); 0148 QString quoteMe() const override; 0149 bool searchDialogRequested() override; 0150 void reloadContents() override; 0151 void zoomIn() override; 0152 void zoomOut() override; 0153 void zoomOriginal() override; 0154 }; 0155 0156 0157 } 0158 0159 #endif // GUI_PARTWIDGET_H