Advance Phase 5: added EmailManager, updated main.cpp, improved ReaderPage placeholder, added ComposePage form
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#include "EmailManager.h"
|
||||
#include <QDir>
|
||||
#include <QStandardPaths>
|
||||
#include "../db/dao/mailitemdao.h"
|
||||
|
||||
EmailManager::EmailManager(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
MailItem EmailManager::getMailItemById(qint64 id) const
|
||||
{
|
||||
// Use the DAO to fetch the MailItem by id
|
||||
auto optItem = MailItemDao::instance().findById(id);
|
||||
if (optItem.has_value()) {
|
||||
return optItem.value();
|
||||
}
|
||||
// Return an empty MailItem if not found
|
||||
return MailItem();
|
||||
}
|
||||
|
||||
QString EmailManager::getStorageDirectory() const
|
||||
{
|
||||
// Define where .eml files are stored (e.g., in the application data directory)
|
||||
QString storagePath = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||
QDir dir(storagePath);
|
||||
if (!dir.exists()) {
|
||||
dir.mkpath("."); // create if it doesn't exist
|
||||
}
|
||||
// Assuming .eml files are stored directly in this directory
|
||||
return storagePath;
|
||||
}
|
||||
Reference in New Issue
Block a user