Implement basic UI with QML (MailListPage) and batching DbChangeProcessor (Step 3-4 of transition plan)
This commit is contained in:
+25
-25
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
#include <QSqlQuery>
|
||||
#include "folderdao.h"
|
||||
#include <QSqlError>
|
||||
#include <QSqlError>
|
||||
#include <optional>
|
||||
|
||||
bool FolderDao::insert(const Folder& folder)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlError>
|
||||
#include "mailitemdao.h"
|
||||
#include <optional>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user