File indexing completed on 2024-11-24 04:53:08

0001 /* Copyright (C) 2013  Ahmed Ibrahim Khalil <ahmedibrahimkhali@gmail.com>
0002    Copyright (C) 2006 - 2016 Jan Kundrát <jkt@kde.org>
0003 
0004    This file is part of the Trojita Qt IMAP e-mail client,
0005    http://trojita.flaska.net/
0006 
0007    This program is free software; you can redistribute it and/or
0008    modify it under the terms of the GNU General Public License as
0009    published by the Free Software Foundation; either version 2 of
0010    the License or (at your option) version 3 or any later version
0011    accepted by the membership of KDE e.V. (or its successor approved
0012    by the membership of KDE e.V.), which shall act as a proxy
0013    defined in Section 14 of version 3 of the license.
0014 
0015    This program is distributed in the hope that it will be useful,
0016    but WITHOUT ANY WARRANTY; without even the implied warranty of
0017    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0018    GNU General Public License for more details.
0019 
0020    You should have received a copy of the GNU General Public License
0021    along with this program.  If not, see <http://www.gnu.org/licenses/>.
0022 */
0023 
0024 #ifndef FULLMESSAGEDOWNLOADER_H
0025 #define FULLMESSAGEDOWNLOADER_H
0026 
0027 #include <QObject>
0028 #include <QPersistentModelIndex>
0029 
0030 
0031 namespace Imap
0032 {
0033 
0034 namespace Mailbox
0035 {
0036 
0037 /** @short Combines both the header and the body parts of a message into one part.
0038 
0039 Use FullMessageCombiner::load() to start loading the message, and when finished a SIGNAL(completed()) will be emitted
0040 then you can retrieve the combined parts using FullMessageCombiner::data(). If both parts are already fetched a SIGNAL(completed())
0041 will also be emitted.
0042 */
0043 
0044 class FullMessageCombiner : public QObject
0045 {
0046     Q_OBJECT
0047 public:
0048     explicit FullMessageCombiner(const QModelIndex &m_messageIndex, QObject *parent = 0);
0049     QByteArray data() const;
0050     bool loaded() const;
0051     void load();
0052 
0053 signals:
0054     void completed();
0055     void failed(const QString &message);
0056 
0057 private:
0058     bool indexesValid() const;
0059 
0060 private slots:
0061     void slotDataChanged(const QModelIndex &left, const QModelIndex &right);
0062 
0063 private:
0064     QPersistentModelIndex m_bodyPartIndex;
0065     QPersistentModelIndex m_headerPartIndex;
0066     QPersistentModelIndex m_messageIndex;
0067     QMetaObject::Connection m_dataChanged;
0068 };
0069 
0070 
0071 }
0072 }
0073 #endif // FULLMESSAGEDOWNLOADER_H