File indexing completed on 2024-11-24 04:53:13
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 0023 #ifndef IMAP_MODEL_ONEMESSAGEMODEL_H 0024 #define IMAP_MODEL_ONEMESSAGEMODEL_H 0025 0026 #include <QDateTime> 0027 #include <QPersistentModelIndex> 0028 #include <QUrl> 0029 #include <QVariant> 0030 0031 class KDescendantsProxyModel; 0032 0033 /** @short Namespace for IMAP interaction */ 0034 namespace Imap 0035 { 0036 0037 /** @short Classes for handling of mailboxes and connections */ 0038 namespace Mailbox 0039 { 0040 0041 class Model; 0042 class SubtreeModelOfModel; 0043 0044 /** @short Publish contents of a selected message */ 0045 class OneMessageModel: public QObject 0046 { 0047 Q_OBJECT 0048 Q_DISABLE_COPY(OneMessageModel) 0049 0050 Q_PROPERTY(QString subject READ subject NOTIFY envelopeChanged) 0051 Q_PROPERTY(QDateTime date READ date NOTIFY envelopeChanged) 0052 Q_PROPERTY(QDateTime receivedDate READ receivedDate NOTIFY envelopeChanged) 0053 Q_PROPERTY(QVariantList from READ from NOTIFY envelopeChanged) 0054 Q_PROPERTY(QVariantList to READ to NOTIFY envelopeChanged) 0055 Q_PROPERTY(QVariantList cc READ cc NOTIFY envelopeChanged) 0056 Q_PROPERTY(QVariantList bcc READ bcc NOTIFY envelopeChanged) 0057 Q_PROPERTY(QVariantList sender READ sender NOTIFY envelopeChanged) 0058 Q_PROPERTY(QVariantList replyTo READ replyTo NOTIFY envelopeChanged) 0059 Q_PROPERTY(QByteArray inReplyTo READ inReplyTo NOTIFY envelopeChanged) 0060 Q_PROPERTY(QByteArray messageId READ messageId NOTIFY envelopeChanged) 0061 Q_PROPERTY(bool isMarkedDeleted READ isMarkedDeleted WRITE setMarkedDeleted NOTIFY flagsChanged) 0062 Q_PROPERTY(bool isMarkedRead READ isMarkedRead WRITE setMarkedRead NOTIFY flagsChanged) 0063 Q_PROPERTY(bool isMarkedForwarded READ isMarkedForwarded NOTIFY flagsChanged) 0064 Q_PROPERTY(bool isMarkedReplied READ isMarkedReplied NOTIFY flagsChanged) 0065 Q_PROPERTY(bool isMarkedRecent READ isMarkedRecent NOTIFY flagsChanged) 0066 Q_PROPERTY(bool isMarkedFlagged READ isMarkedFlagged NOTIFY flagsChanged) 0067 Q_PROPERTY(bool isMarkedJunk READ isMarkedJunk NOTIFY flagsChanged) 0068 Q_PROPERTY(bool isMarkedNotJunk READ isMarkedNotJunk NOTIFY flagsChanged) 0069 Q_PROPERTY(QUrl mainPartUrl READ mainPartUrl NOTIFY mainPartUrlChanged) 0070 Q_PROPERTY(QObject* attachmentsModel READ attachmentsModel NOTIFY mainPartUrlChanged) 0071 Q_PROPERTY(bool hasValidIndex READ hasValidIndex NOTIFY envelopeChanged) 0072 Q_PROPERTY(QModelIndex mainPartModelIndex READ mainPartModelIndex) 0073 0074 public: 0075 explicit OneMessageModel(Model *model); 0076 0077 QString subject() const; 0078 QDateTime date() const; 0079 QDateTime receivedDate() const; 0080 QVariantList from() const; 0081 QVariantList to() const; 0082 QVariantList cc() const; 0083 QVariantList bcc() const; 0084 QVariantList sender() const; 0085 QVariantList replyTo() const; 0086 QByteArray inReplyTo() const; 0087 QByteArray messageId() const; 0088 bool isMarkedDeleted() const; 0089 void setMarkedDeleted(const bool marked); 0090 bool isMarkedRead() const; 0091 void setMarkedRead(const bool marked); 0092 bool isMarkedForwarded() const; 0093 bool isMarkedReplied() const; 0094 bool isMarkedRecent() const; 0095 bool isMarkedFlagged() const; 0096 bool isMarkedJunk() const; 0097 bool isMarkedNotJunk() const; 0098 QUrl mainPartUrl() const; 0099 QObject *attachmentsModel() const; 0100 bool hasValidIndex() const; 0101 QModelIndex mainPartModelIndex(); 0102 0103 Q_INVOKABLE void setMessage(const QString &mailbox, const uint uid); 0104 void setMessage(const QModelIndex &message); 0105 0106 signals: 0107 void envelopeChanged(); 0108 void flagsChanged(); 0109 void mainPartUrlChanged(); 0110 0111 private slots: 0112 void handleModelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); 0113 0114 private: 0115 QPersistentModelIndex m_message; 0116 SubtreeModelOfModel *m_subtree; 0117 KDescendantsProxyModel *m_flatteningModel; 0118 QUrl m_mainPartUrl; 0119 }; 0120 0121 } 0122 0123 } 0124 0125 #endif /* IMAP_MODEL_ONEMESSAGEMODEL_H */