diff --git a/src/ui/maillistview.cpp b/src/ui/maillistview.cpp index 8d19f53..24691cf 100644 --- a/src/ui/maillistview.cpp +++ b/src/ui/maillistview.cpp @@ -149,6 +149,8 @@ void MailListView::setupUI() ); connect(m_groupByCombo, QOverload::of(&QComboBox::currentIndexChanged), this, &MailListView::onGroupByChanged); + // Default to conversation grouping (Wino-style), index 2 = GroupByThread + m_groupByCombo->setCurrentIndex(2); filterLayout->addWidget(m_groupByCombo); layout->addWidget(filterBar); @@ -244,6 +246,8 @@ void MailListView::setupUI() ); m_treeModel = new EmailTreeModel(this); + // Wino-style default: group inbox by conversation (thread) + m_treeModel->setGroupMode(EmailTreeModel::GroupByThread); m_proxyModel = new QSortFilterProxyModel(this); m_proxyModel->setSourceModel(m_treeModel); m_proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); @@ -528,6 +532,7 @@ void MailListView::onFilterChanged() void MailListView::onGroupByChanged(int index) { + if (!m_treeModel) return; switch (index) { case 0: // Sin agrupación m_treeModel->setGroupMode(EmailTreeModel::NoGrouping); @@ -542,7 +547,7 @@ void MailListView::onGroupByChanged(int index) m_treeModel->setGroupMode(EmailTreeModel::GroupBySender); break; } - m_treeView->expandAll(); + if (m_treeView) m_treeView->expandAll(); } void MailListView::onDisplayModeChanged(int index) diff --git a/src/ui/models/EmailTreeModel.cpp b/src/ui/models/EmailTreeModel.cpp index 1500122..f8a0881 100644 --- a/src/ui/models/EmailTreeModel.cpp +++ b/src/ui/models/EmailTreeModel.cpp @@ -465,6 +465,16 @@ void EmailTreeModel::buildThreads() return dateA < dateB; // Oldest first }); + if (sortedIndices.size() == 1) { + // A single-message "thread" isn't a real conversation — add it as a + // plain Mail row directly under root (no expander, no nesting). + TreeItem* mailItem = new TreeItem(TreeItem::Mail, m_rootItem); + mailItem->mailIndex = sortedIndices.first(); + mailItem->row = m_rootItem->children.size(); + m_rootItem->children.append(mailItem); + continue; + } + TreeItem* threadItem = new TreeItem(TreeItem::Thread, m_rootItem); threadItem->threadId = threadId; threadItem->groupIndex = threadIdx++;