File indexing completed on 2024-11-24 04:50:44
0001 // SPDX-FileCopyrightText: 2023 Aakarsh MJ <mj.akarsh@gmail.com> 0002 // SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0003 0004 #pragma once 0005 0006 #include <QAbstractListModel> 0007 0008 class MailHeaderModel : public QAbstractListModel 0009 { 0010 Q_OBJECT 0011 0012 public: 0013 enum Roles { 0014 NameRole = Qt::UserRole, 0015 ValueRole, 0016 }; 0017 Q_ENUM(Roles) 0018 0019 enum Header { 0020 To, 0021 From, 0022 BCC, 0023 CC, 0024 ReplyTo, 0025 }; 0026 Q_ENUM(Header) 0027 0028 explicit MailHeaderModel(QObject *parent = nullptr); 0029 ~MailHeaderModel() override = default; 0030 0031 QVariant data(const QModelIndex &index, int role) const override; 0032 Q_INVOKABLE int rowCount(const QModelIndex &parent = {}) const override; 0033 0034 Q_INVOKABLE void updateModel(const int row, const QString &value); 0035 Q_INVOKABLE void updateHeaderType(const int row, const Header headerName); 0036 0037 private: 0038 struct HeaderItem { 0039 Header header; 0040 QString value; 0041 }; 0042 0043 QList<HeaderItem> m_headers; 0044 };