File indexing completed on 2025-01-05 04:54:57

0001 /*
0002     Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com>
0003 
0004     This library is free software; you can redistribute it and/or modify it
0005     under the terms of the GNU Library General Public License as published by
0006     the Free Software Foundation; either version 2 of the License, or (at your
0007     option) any later version.
0008 
0009     This library is distributed in the hope that it will be useful, but WITHOUT
0010     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0011     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
0012     License for more details.
0013 
0014     You should have received a copy of the GNU Library General Public License
0015     along with this library; see the file COPYING.LIB.  If not, write to the
0016     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0017     02110-1301, USA.
0018 */
0019 
0020 #pragma once
0021 #include "kube_export.h"
0022 #include <QObject>
0023 #include <QString>
0024 #include <QStringList>
0025 
0026 #include <QAbstractItemModel>
0027 #include <QModelIndex>
0028 
0029 #include <memory>
0030 
0031 class QAbstractItemModel;
0032 
0033 class MessagePartPrivate;
0034 
0035 namespace MimeTreeParser {
0036     class ObjectTreeParser;
0037 }
0038 
0039 class KUBE_EXPORT MessageParser : public QObject
0040 {
0041     Q_OBJECT
0042     Q_PROPERTY (QVariant message READ message WRITE setMessage)
0043     Q_PROPERTY (QAbstractItemModel* parts READ parts NOTIFY htmlChanged)
0044     Q_PROPERTY (QAbstractItemModel* attachments READ attachments NOTIFY htmlChanged)
0045     Q_PROPERTY (QString rawContent READ rawContent NOTIFY htmlChanged)
0046     Q_PROPERTY (QString structureAsString READ structureAsString NOTIFY htmlChanged)
0047     Q_PROPERTY (bool loaded READ loaded NOTIFY htmlChanged)
0048 
0049 public:
0050     explicit MessageParser(QObject *parent = Q_NULLPTR);
0051     ~MessageParser();
0052 
0053     QVariant message() const;
0054     void setMessage(const QVariant &to);
0055     QAbstractItemModel *parts() const;
0056     QAbstractItemModel *attachments() const;
0057     QString rawContent() const;
0058     QString structureAsString() const;
0059     bool loaded() const;
0060 signals:
0061     void htmlChanged();
0062 
0063 private:
0064     std::unique_ptr<MessagePartPrivate> d;
0065     QString mRawContent;
0066 };
0067