From e452707fdfbd61be1e5633b516b653b7337e7865 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 29 May 2017 16:17:04 +0200 Subject: Reduced the messagetreeparser to aproximately what we actually require While in a much more managable state it's still not pretty. However, further refactoring can now gradually happen as we need to do further work on it. Things that should happen eventually: * Simplify the logic that creates the messageparts (we don't need the whole formatter plugin complexity) * Get rid of the nodehelper (let the parts hold the necessary data) * Get rid of partmetadata (let the part handleit) --- framework/src/domain/mime/messageparser.h | 71 ++++--------------------------- 1 file changed, 8 insertions(+), 63 deletions(-) (limited to 'framework/src/domain/mime/messageparser.h') diff --git a/framework/src/domain/mime/messageparser.h b/framework/src/domain/mime/messageparser.h index de72a025..785b8f47 100644 --- a/framework/src/domain/mime/messageparser.h +++ b/framework/src/domain/mime/messageparser.h @@ -30,18 +30,19 @@ class QAbstractItemModel; -class Parser; class MessagePartPrivate; -class NewModelPrivate; -class AttachmentModelPrivate; +namespace MimeTreeParser { + class ObjectTreeParser; +} class MessageParser : public QObject { Q_OBJECT Q_PROPERTY (QVariant message READ message WRITE setMessage) - Q_PROPERTY (QAbstractItemModel* newTree READ newTree NOTIFY htmlChanged) + Q_PROPERTY (QAbstractItemModel* parts READ parts NOTIFY htmlChanged) Q_PROPERTY (QAbstractItemModel* attachments READ attachments NOTIFY htmlChanged) + Q_PROPERTY (QString rawContent READ rawContent NOTIFY htmlChanged) public: explicit MessageParser(QObject *parent = Q_NULLPTR); @@ -49,71 +50,15 @@ public: QVariant message() const; void setMessage(const QVariant &to); - QAbstractItemModel *newTree() const; + QAbstractItemModel *parts() const; QAbstractItemModel *attachments() const; + QString rawContent() const; signals: void htmlChanged(); private: std::unique_ptr d; + QString mRawContent; }; -class NewModel : public QAbstractItemModel { - Q_OBJECT -public: - NewModel(std::shared_ptr parser); - ~NewModel(); - -public: - enum Roles { - TypeRole = Qt::UserRole + 1, - ContentsRole, - ContentRole, - IsComplexHtmlContentRole, - IsEmbededRole, - SecurityLevelRole, - EncryptionErrorType, - EncryptionErrorString - }; - - QHash roleNames() const Q_DECL_OVERRIDE; - QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; - QModelIndex parent(const QModelIndex &index) const Q_DECL_OVERRIDE; - int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; - int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; - -private: - std::unique_ptr d; -}; - -class AttachmentModel : public QAbstractItemModel { - Q_OBJECT -public: - AttachmentModel(std::shared_ptr parser); - ~AttachmentModel(); - -public: - enum Roles { - TypeRole = Qt::UserRole + 1, - IconRole, - NameRole, - SizeRole, - IsEncryptedRole, - IsSignedRole - }; - - QHash roleNames() const Q_DECL_OVERRIDE; - QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; - QModelIndex parent(const QModelIndex &index) const Q_DECL_OVERRIDE; - int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; - int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; - - Q_INVOKABLE bool saveAttachmentToDisk(const QModelIndex &parent); - Q_INVOKABLE bool openAttachment(const QModelIndex &index); - -private: - std::unique_ptr d; -}; -- cgit v1.2.3