diff options
| author | Danilo M. <danix@danix.xyz> | 2026-08-26 16:13:06 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-08-26 16:13:06 +0200 |
| commit | 409faeadf013952420963fa1b740d44526d8a95e (patch) | |
| tree | fdfc02bf1dd4321f6fcab110e7205835ecdb51c9 /src/mainwindow.cpp | |
| parent | bd90331cba3633754482fc13b99ae39a3b5f79a2 (diff) | |
| download | qtmaildir-409faeadf013952420963fa1b740d44526d8a95e.tar.gz qtmaildir-409faeadf013952420963fa1b740d44526d8a95e.zip | |
feat: load the business-senders list at startup
Diffstat (limited to 'src/mainwindow.cpp')
| -rw-r--r-- | src/mainwindow.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 9166588..ec43b3c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -520,6 +520,17 @@ MainWindow::MainWindow(const Config &config, QWidget *parent) buildUi(); registerActions(); + // Both need the delegate, which buildUi() just created. The list is loaded + // once at startup and again only on an explicit reload, never per repaint: + // the painting path runs on every row of every scroll. + loadBusinessSenders(); + applyCurrentAccountToDelegate(); + // A change takes effect without a restart. Its own connect, not the one in + // buildSavedQueryRow(), which belongs to the filter-buttons row and is + // rebuilt with it. + connect(m_accountBox, &QComboBox::currentIndexChanged, this, + [this]() { applyCurrentAccountToDelegate(); }); + // After registerActions(), not inside buildUi(): the query bar exists by // then but the action does not, so wiring this where the field is built // silently connected nothing and left Save query enabled on an empty @@ -831,7 +842,8 @@ void MainWindow::buildUi() // delegate is confined to one column's rectangle. m_threadView = new ThreadListView(central); m_threadView->setModel(m_model); - m_threadView->setItemDelegate(new CardDelegate(this)); + m_cardDelegate = new CardDelegate(this); + m_threadView->setItemDelegate(m_cardDelegate); m_threadView->setHeaderHidden(true); m_threadView->setSelectionBehavior(QAbstractItemView::SelectRows); m_threadView->setSelectionMode(QAbstractItemView::ExtendedSelection); @@ -2794,6 +2806,27 @@ void MainWindow::selectAccountForTesting(const QString &key) m_accountBox->setCurrentIndex(index); } +void MainWindow::loadBusinessSenders(const QString &path) +{ + m_businessSenders = BusinessSenders::load( + path.isEmpty() ? BusinessSenders::defaultPath() : path); + m_cardDelegate->setBusinessSenders(m_businessSenders); +} + +void MainWindow::applyCurrentAccountToDelegate() +{ + const QString key = m_accountBox->currentData().toString(); + if (key.isEmpty()) { + m_cardDelegate->setAccountAddress(QString()); + m_cardDelegate->setAccountLabel(QString()); + return; + } + const Account account = m_config.account(key); + m_cardDelegate->setAccountAddress(account.address); + m_cardDelegate->setAccountLabel( + account.name.isEmpty() ? account.key : account.name); +} + void MainWindow::onRulePreviewRequested(const QString &query) { // Unscoped, deliberately. runQuery() wraps the bar's text in the selected |
