Implement basic UI with QML (MailListPage) and batching DbChangeProcessor (Step 3-4 of transition plan)
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
#include "FolderListModel.h"
|
||||
#include <QDebug>
|
||||
|
||||
FolderListModel::FolderListModel(QObject *parent)
|
||||
: QAbstractListModel(parent),
|
||||
m_folderDao(FolderDao::instance())
|
||||
{
|
||||
refresh();
|
||||
}
|
||||
|
||||
int FolderListModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
if (parent.isValid())
|
||||
return 0;
|
||||
return m_folderNames.size();
|
||||
}
|
||||
|
||||
QVariant FolderListModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid() || index.row() >= m_folderNames.size())
|
||||
return QVariant();
|
||||
|
||||
if (role == FolderNameRole)
|
||||
return m_folderNames.at(index.row());
|
||||
else if (role == UnreadCountRole)
|
||||
return m_unreadCounts.at(index.row());
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> FolderListModel::roleNames() const
|
||||
{
|
||||
QHash<int, QByteArray> roles;
|
||||
roles[FolderNameRole] = "folderName";
|
||||
roles[UnreadCountRole] = "unreadCount";
|
||||
return roles;
|
||||
}
|
||||
|
||||
void FolderListModel::refresh()
|
||||
{
|
||||
beginResetModel();
|
||||
// For now, we'll just use hardcoded folders until we implement the DAO properly
|
||||
m_folderNames = {"Inbox", "Sent", "Drafts", "Trash", "Spam"};
|
||||
m_unreadCounts = {5, 0, 0, 0, 0};
|
||||
endResetModel();
|
||||
qDebug() << "FolderListModel refreshed with" << m_folderNames.size() << "folders";
|
||||
}
|
||||
Reference in New Issue
Block a user