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;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef EMAILMANAGER_H
|
||||
#define EMAILMANAGER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QDateTime>
|
||||
#include <QVector>
|
||||
#include "core/mailitem.h"
|
||||
|
||||
class EmailManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit EmailManager(QObject *parent = nullptr);
|
||||
~EmailManager() override = default;
|
||||
|
||||
// Returns a MailItem by id, or null if not found
|
||||
Q_INVOKABLE MailItem getMailItemById(qint64 id) const;
|
||||
|
||||
// Returns the storage directory for .eml files
|
||||
Q_INVOKABLE QString getStorageDirectory() const;
|
||||
|
||||
private:
|
||||
// We'll use the DAO directly
|
||||
};
|
||||
|
||||
#endif // EMAILMANAGER_H
|
||||
Reference in New Issue
Block a user