Complete Phase 4: Basic UI with QML - MailListPage with folder/email navigation, models connected to DAOs, placeholder pages for Calendar/Contacts/Settings

This commit is contained in:
Padrino
2026-05-17 01:52:34 +02:00
parent acec320222
commit 822ed5db47
7 changed files with 235 additions and 43 deletions
+46
View File
@@ -0,0 +1,46 @@
#ifndef EMAILLISTMODEL_H
#define EMAILLISTMODEL_H
#include <QAbstractListModel>
#include <QHash>
#include <QByteArray>
#include "../db/dao/mailitemdao.h"
class EmailListModel : public QAbstractListModel
{
Q_OBJECT
public:
explicit EmailListModel(QObject *parent = nullptr);
~EmailListModel() override = default;
enum EmailRoles {
IdRole = Qt::UserRole + 1,
SubjectRole,
SenderRole,
RecipientRole,
DateRole,
ReadRole,
FlaggedRole,
AttachmentsRole,
FileIdRole,
SizeRole,
MessageIdRole,
SenderInitialRole // computed from sender
};
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QHash<int, QByteArray> roleNames() const override;
// Set the folderId to filter emails; -1 means all folders
void setFolderId(int folderId);
// Refresh the model from the database based on current folderId
void refresh();
private:
QVector<MailItem> m_emails;
int m_folderId{-1}; // -1 means all folders
MailItemDao& m_mailItemDao;
};
#endif // EMAILLISTMODEL_H