feat: Focused/Other pivot for Inbox
- MailListView: new m_pivotCombo (Principal/Otros) visible only for Inbox folders - MailListView::setFolderType(folderType) called from MainMainWindow::onFolderSelected() - Folder::type() returns 'inbox', 'sent', 'drafts', 'trash', 'custom' - onPivotChanged() placeholder for future AI-based filtering (Focused vs Other) - UI hidden for non-Inbox folders
This commit is contained in:
@@ -38,6 +38,14 @@ public:
|
||||
int unreadCount() const { return m_unreadCount; }
|
||||
void setUnreadCount(int count) { m_unreadCount = count; }
|
||||
|
||||
QString type() const {
|
||||
if (m_isInbox) return "inbox";
|
||||
if (m_isSent) return "sent";
|
||||
if (m_isDrafts) return "drafts";
|
||||
if (m_isTrash) return "trash";
|
||||
return "custom";
|
||||
}
|
||||
|
||||
QDateTime lastSynced() const { return m_lastSynced; }
|
||||
void setLastSynced(const QDateTime& lastSynced) { m_lastSynced = lastSynced; }
|
||||
|
||||
|
||||
@@ -77,6 +77,22 @@ void MailListView::setupUI()
|
||||
|
||||
filterLayout->addStretch();
|
||||
|
||||
// Pivot control (Focused/Other) - only shown for Inbox folders
|
||||
m_pivotCombo = new QComboBox();
|
||||
m_pivotCombo->addItem("Principal"); // Focused
|
||||
m_pivotCombo->addItem("Otros"); // Other
|
||||
m_pivotCombo->setFixedWidth(140);
|
||||
m_pivotCombo->setStyleSheet(
|
||||
"QComboBox { border: 1px solid #d1d1d6; border-radius: 4px; padding: 4px 8px; "
|
||||
"background: white; min-height: 20px; }"
|
||||
"QComboBox:hover { border-color: #bdbdbd; }"
|
||||
"QComboBox:focus { border-color: #1976D2; }"
|
||||
);
|
||||
m_pivotCombo->setVisible(false); // Only visible for Inbox
|
||||
connect(m_pivotCombo, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
this, &MailListView::onPivotChanged);
|
||||
filterLayout->addWidget(m_pivotCombo);
|
||||
|
||||
// Display mode combo (Compact/Medium/Spacious)
|
||||
m_displayModeCombo = new QComboBox();
|
||||
m_displayModeCombo->addItem("Compacto");
|
||||
@@ -581,4 +597,26 @@ void MailListView::onBatchDeleteClicked()
|
||||
if (m_selectedMailIds.isEmpty()) return;
|
||||
emit batchDeleteRequested(m_selectedMailIds);
|
||||
exitMultiSelectMode();
|
||||
}
|
||||
|
||||
void MailListView::setFolderType(const QString& folderType)
|
||||
{
|
||||
m_pivotCombo->setVisible(folderType == "inbox");
|
||||
}
|
||||
|
||||
void MailListView::onPivotChanged(int index)
|
||||
{
|
||||
// 0 = Focused (Principal), 1 = Other (Otros)
|
||||
// TODO: Implement pivot filtering logic
|
||||
// For now, just update the model filter
|
||||
if (!m_sourceModel) return;
|
||||
|
||||
if (index == 0) {
|
||||
// Focused: important emails (could be based on sender frequency, AI, etc.)
|
||||
// m_sourceModel->setShowFocusedOnly(true);
|
||||
} else {
|
||||
// Other: promotional, notifications, etc.
|
||||
// m_sourceModel->setShowFocusedOnly(false);
|
||||
}
|
||||
refreshViews();
|
||||
}
|
||||
@@ -48,6 +48,9 @@ signals:
|
||||
void batchMarkUnreadRequested(const QVector<int>& mailIds);
|
||||
void batchMoveRequested(const QVector<int>& mailIds, int targetFolderId);
|
||||
|
||||
public slots:
|
||||
void setFolderType(const QString& folderType); // "inbox", "sent", "drafts", etc.
|
||||
|
||||
private slots:
|
||||
void onRowSelected(const QModelIndex &index);
|
||||
void onSearchTextChanged(const QString &text);
|
||||
@@ -74,6 +77,7 @@ private slots:
|
||||
void onBatchDeleteClicked();
|
||||
void enterMultiSelectMode();
|
||||
void exitMultiSelectMode();
|
||||
void onPivotChanged(int index); // Focused/Other pivot
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
@@ -101,6 +105,7 @@ private:
|
||||
QWidget *m_actionBar; // Action bar widget
|
||||
QComboBox *m_groupByCombo;
|
||||
QComboBox *m_displayModeCombo;
|
||||
QComboBox *m_pivotCombo; // Focused/Other pivot
|
||||
CompactMailDelegate *m_compactDelegate = nullptr;
|
||||
bool m_compactMode = false;
|
||||
int m_compactThreshold = 650;
|
||||
|
||||
@@ -388,6 +388,8 @@ void MainMainWindow::onFolderSelected(const QModelIndex &index)
|
||||
Account* account = m_accountService->findAccountById(folder.accountId());
|
||||
if (account) {
|
||||
m_mailService->fetchMails(QString::number(account->id()), QString::number(m_currentFolderId));
|
||||
// Tell MailListView the folder type for Focused/Other pivot
|
||||
m_mailListView->setFolderType(folder.type().toLower()); // "inbox", "sent", etc.
|
||||
delete account;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user