Files
wino-mail-dtkqt/test_imap.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

64 lines
2.2 KiB
C++

#include <QCoreApplication>
#include <QDebug>
#include "services/accountservice.h"
#include "services/imap/imapsynchronizer.h"
#include "core/models/account.h"
#include "db/databasemanager.h"
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
// Initialize database
DatabaseManager::instance().initializeDatabase();
AccountService accountService;
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"; // non-existent
settings.incomingPort = 993;
settings.incomingSsl = true;
settings.username = "test@example.com";
settings.password = "password";
settings.outgoingHost = "smtp.example.com";
settings.outgoingPort = 465;
settings.outgoingSsl = true;
settings.authMethod = "plain";
acc.setConnectionSettings(settings);
qDebug() << "Adding test account...";
accountService.addAccount(acc);
qDebug() << "Accounts after add:" << accountService.getAllAccounts().size();
// Trigger folder sync manually
QString accountIdStr = QString::number(acc.id());
Synchronizer *sync = SynchronizerProvider::instance().getSynchronizer(accountIdStr);
if (!sync) {
sync = SynchronizerProvider::instance().createSynchronizer(accountIdStr, "imap");
}
if (sync) {
sync->initialize(acc);
qDebug() << "Getting folders...";
QVector<Folder> folders = sync->getFolders();
qDebug() << "Folders found:" << folders.size();
for (const Folder &f : folders) {
qDebug() << " -" << f.name();
}
// Try to fetch from inbox (first folder)
if (!folders.isEmpty()) {
qDebug() << "Fetching mail items for first folder...";
QVector<MailItem> items = sync->fetchMailItems(QString::number(folders.first().id()), 0);
qDebug() << "Items fetched:" << items.size();
}
} else {
qDebug() << "Failed to get/create synchronizer";
}
// Clean up: remove account
accountService.removeAccount(acc.id());
qDebug() << "Account removed.";
return 0;
}