File indexing completed on 2024-11-24 04:50:44
0001 // SPDX-FileCopyrightText: 2021 Simon Schmeisser <s.schmeisser@gmx.net> 0002 // SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org> 0003 // SPDX-License-Identifier: GPL-3.0-or-later 0004 0005 #pragma once 0006 0007 #include <Akonadi/Item> 0008 #include <QObject> 0009 #include <QSortFilterProxyModel> 0010 0011 #include "messagestatus.h" 0012 0013 class MailModel : public QSortFilterProxyModel 0014 { 0015 Q_OBJECT 0016 Q_PROPERTY(QString searchString READ searchString WRITE setSearchString NOTIFY searchStringChanged) 0017 0018 public: 0019 enum ExtraRole { 0020 TitleRole = Qt::UserRole + 1, 0021 SenderRole, 0022 FromRole, 0023 ToRole, 0024 TextColorRole, 0025 DateRole, 0026 DateTimeRole, 0027 BackgroundColorRole, 0028 StatusRole, 0029 FavoriteRole, 0030 ItemRole, 0031 }; 0032 0033 explicit MailModel(QObject *parent = nullptr); 0034 QHash<int, QByteArray> roleNames() const override; 0035 virtual QVariant data(const QModelIndex &index, int role) const override; 0036 bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; 0037 0038 Q_INVOKABLE void updateMessageStatus(int row, MessageStatus messageStatus); 0039 Q_INVOKABLE MessageStatus copyMessageStatus(MessageStatus messageStatus); 0040 0041 QString searchString() const; 0042 void setSearchString(const QString &searchString); 0043 0044 Q_SIGNALS: 0045 void searchStringChanged(); 0046 0047 private: 0048 Akonadi::Item itemForRow(int row) const; 0049 QString m_searchString; 0050 };