File indexing completed on 2024-09-08 13:15:39
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 <QItemSelectionModel> 0009 #include <QObject> 0010 #include <QSortFilterProxyModel> 0011 0012 #include "messagestatus.h" 0013 0014 class MailModel : public QSortFilterProxyModel 0015 { 0016 Q_OBJECT 0017 Q_PROPERTY(QString searchString READ searchString WRITE setSearchString NOTIFY searchStringChanged) 0018 0019 public: 0020 enum ExtraRole { 0021 TitleRole = Qt::UserRole + 1, 0022 SenderRole, 0023 FromRole, 0024 ToRole, 0025 TextColorRole, 0026 DateRole, 0027 DateTimeRole, 0028 BackgroundColorRole, 0029 StatusRole, 0030 FavoriteRole, 0031 ItemRole, 0032 }; 0033 0034 explicit MailModel(QObject *parent = nullptr); 0035 QHash<int, QByteArray> roleNames() const override; 0036 virtual QVariant data(const QModelIndex &index, int role) const override; 0037 bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; 0038 0039 Q_INVOKABLE void updateMessageStatus(int row, MessageStatus messageStatus); 0040 Q_INVOKABLE MessageStatus copyMessageStatus(MessageStatus messageStatus); 0041 0042 QString searchString() const; 0043 void setSearchString(const QString &searchString); 0044 0045 Q_SIGNALS: 0046 void searchStringChanged(); 0047 0048 private: 0049 Akonadi::Item itemForRow(int row) const; 0050 QString m_searchString; 0051 };