Files
wino-mail-dtkqt/test_dao.cpp
T
javier 4c4fec7a0a feat: responsive compact mail view + folder unread badges
- CompactMailDelegate: card-based view for narrow panels (<420px)
  * Avatar with hash-based color, sender + date (relative format)
  * Subject line with attachment icon
  * Action buttons: flag, delete, category, more (context menu)
  * Unread highlight with light blue background + bold sender
- MailListView: automatic switch between tree/table (wide) and list/cards (narrow)
  * QStackedWidget with QTreeView + QListView sharing same proxy model
  * resizeEvent threshold at 420px
  * Signals forwarded to MainMainWindow for actions
- FolderTreeDelegate: custom paint for folder tree
  * Unread count badge (blue pill) right-aligned on folder nodes
  * Account nodes bold, folder nodes normal weight
  * Proper indentation per depth level
- MailItemDao::countUnreadByFolderId() for real-time unread counts
- MainMainWindow handlers for compact actions (flag, delete, category, more menu)
2026-08-24 23:25:13 +02:00

76 lines
2.7 KiB
C++

#include <QString>
#include <QDebug>
#include <QCoreApplication>
#include "src/db/databasemanager.h"
#include "src/db/dao/accountdao.h"
#include "src/core/models/account.h"
int main(int argc, char *argv[]) {
QCoreApplication app(argc, argv);
// Initialize database (will open/create wino-mail.sqlite in current dir)
if (!DatabaseManager::instance().initialize()) {
qCritical() << "Failed to initialize database";
return 1;
}
qInfo() << "Database initialized";
// Prepare test account
Account acc;
acc.setEmail("test@example.com");
acc.setDisplayName("Test User");
acc.setType(AccountType::IMAP);
Account::ConnectionSettings settings;
settings.type = "imap";
settings.incomingHost = "imap.example.com";
settings.incomingPort = 993;
settings.incomingSsl = true;
settings.outgoingHost = "smtp.example.com";
settings.outgoingPort = 465;
settings.outgoingSsl = true;
settings.username = "test@example.com";
settings.password = "SuperSecret123!";
settings.authMethod = "plain";
acc.setConnectionSettings(settings);
// Insert
bool inserted = AccountDao::insert(acc);
if (!inserted) {
qCritical() << "Failed to insert account";
return 1;
}
qInfo() << "Account inserted with ID:" << acc.id();
// Retrieve by email
Account* retrieved = AccountDao::findByEmail("test@example.com");
if (!retrieved) {
qCritical() << "Failed to retrieve account by email";
return 1;
}
qInfo() << "Retrieved account ID:" << retrieved->id();
qInfo() << "Email:" << retrieved->email();
qInfo() << "DisplayName:" << retrieved->displayName();
qInfo() << "Type:" << static_cast<int>(retrieved->type());
const auto& rs = retrieved->connectionSettings();
qInfo() << "Incoming host:" << rs.incomingHost;
qInfo() << "Incoming port:" << rs.incomingPort;
qInfo() << "Incoming SSL:" << rs.incomingSsl;
qInfo() << "Username:" << rs.username;
qInfo() << "Password (encrypted stored):" << // we need to get raw from DB? we can't directly.
"[encrypted]"; // we will decrypt
QString decryptedPass = Account::decryptPassword(rs.password);
qInfo() << "Decrypted password:" << decryptedPass;
bool ok = (decryptedPass == settings.password);
if (ok) {
qInfo() << "SUCCESS: password matches after decrypt";
} else {
qCritical: Also check that the stored password in DB is encrypted (not plain). We could query directly but we trust encrypt function.
// Cleanup: remove the account
if (!AccountDao::remove(retrieved->id())) {
qWarning() << "Failed to remove test account";
} else {
qInfo() << "Test account removed";
}
delete retrieved;
return ok ? 0 : 2;
}