Implement basic UI with QML (MailListPage) and batching DbChangeProcessor (Step 3-4 of transition plan)

This commit is contained in:
Padrino
2026-05-17 01:09:01 +02:00
parent e3071a23e0
commit acec320222
20 changed files with 829 additions and 82 deletions
+25 -25
View File
@@ -1,5 +1,4 @@
#include "accountdao.h"
#include <optional>
bool AccountDao::insert(const Account& account)
{
@@ -69,7 +68,7 @@ bool AccountDao::remove(int id)
return true;
}
std::optional<Account> AccountDao::findById(int id)
Account* AccountDao::findById(int id)
{
QSqlDatabase& db = DatabaseManager::instance().database();
QSqlQuery query(db);
@@ -78,21 +77,22 @@ std::optional<Account> AccountDao::findById(int id)
if (!query.exec()) {
qWarning() << "Failed to find account by id:" << query.lastError().text();
return std::nullopt;
return nullptr;
}
if (query.next()) {
Account acc;
acc.setId(query.value(0).toInt());
acc.setEmail(query.value(1).toString());
acc.setDisplayName(query.value(2).toString());
acc.setType(static_cast<AccountType>(query.value(3).toInt()));
acc.setAccessToken(query.value(4).toString());
acc.setRefreshToken(query.value(5).toString());
acc.setTokenExpires(query.value(6).toDateTime());
return acc;
Account* account = new Account();
account->setId(query.value("id").toLongLong());
account->setEmail(query.value("email").toString());
account->setDisplayName(query.value("displayName").toString());
account->setType(static_cast<AccountType>(query.value("type").toInt()));
account->setAccessToken(query.value("accessToken").toString());
account->setRefreshToken(query.value("refreshToken").toString());
account->setTokenExpires(query.value("tokenExpires").toDateTime());
return account;
}
return std::nullopt;
return nullptr;
}
QVector<Account> AccountDao::findAll()
@@ -119,7 +119,7 @@ QVector<Account> AccountDao::findAll()
return accounts;
}
std::optional<Account> AccountDao::findByEmail(const QString& email)
Account* AccountDao::findByEmail(const QString& email)
{
QSqlDatabase& db = DatabaseManager::instance().database();
QSqlQuery query(db);
@@ -128,19 +128,19 @@ std::optional<Account> AccountDao::findByEmail(const QString& email)
if (!query.exec()) {
qWarning() << "Failed to find account by email:" << query.lastError().text();
return std::nullopt;
return nullptr;
}
if (query.next()) {
Account acc;
acc.setId(query.value(0).toInt());
acc.setEmail(query.value(1).toString());
acc.setDisplayName(query.value(2).toString());
acc.setType(static_cast<AccountType>(query.value(3).toInt()));
acc.setAccessToken(query.value(4).toString());
acc.setRefreshToken(query.value(5).toString());
acc.setTokenExpires(query.value(6).toDateTime());
Account* acc = new Account();
acc->setId(query.value(0).toLongLong());
acc->setEmail(query.value(1).toString());
acc->setDisplayName(query.value(2).toString());
acc->setType(static_cast<AccountType>(query.value(3).toInt()));
acc->setAccessToken(query.value(4).toString());
acc->setRefreshToken(query.value(5).toString());
acc->setTokenExpires(query.value(6).toDateTime());
return acc;
}
return std::nullopt;
}
return nullptr;
}
+3
View File
@@ -1,4 +1,7 @@
#include <QSqlQuery>
#include "folderdao.h"
#include <QSqlError>
#include <QSqlError>
#include <optional>
bool FolderDao::insert(const Folder& folder)
+2
View File
@@ -1,3 +1,5 @@
#include <QSqlQuery>
#include <QSqlError>
#include "mailitemdao.h"
#include <optional>