feat: Online search button
- MailListView: new '🌐 Online' button in search bar
- Clicking button emits onlineSearchRequested(query)
- If search box empty, shows QInputDialog for query entry
- MainMainWindow::onOnlineSearchRequested() handler:
- Validates current folder selected
- Gets account for folder
- Shows status message
- Shows info dialog with query/folder/account (placeholder for IMAP SEARCH)
- Signal: onlineSearchRequested(const QString& query)
- Button styled in blue (online theme)
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include <QMenu>
|
||||
#include <QDrag>
|
||||
#include <QMimeData>
|
||||
#include <QInputDialog>
|
||||
#include "ui/delegates/CompactMailDelegate.h"
|
||||
|
||||
MailListView::MailListView(QWidget *parent) : QWidget(parent), m_sourceModel(nullptr), m_multiSelectMode(false)
|
||||
@@ -51,6 +52,20 @@ void MailListView::setupUI()
|
||||
searchLayout->addWidget(m_searchEdit);
|
||||
connect(m_searchEdit, &QLineEdit::textChanged, this, &MailListView::onSearchTextChanged);
|
||||
|
||||
// Online search button
|
||||
m_onlineSearchBtn = new QToolButton();
|
||||
m_onlineSearchBtn->setText("🌐 Online");
|
||||
m_onlineSearchBtn->setToolTip("Buscar en servidor (IMAP)");
|
||||
m_onlineSearchBtn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||
m_onlineSearchBtn->setStyleSheet(
|
||||
"QToolButton { background: #e3f2fd; border: 1px solid #90caf9; border-radius: 6px; "
|
||||
"padding: 6px 12px; font-size: 12px; color: #1565c0; }"
|
||||
"QToolButton:hover { background: #bbdefb; border-color: #42a5f5; }"
|
||||
"QToolButton:pressed { background: #90caf9; }"
|
||||
);
|
||||
connect(m_onlineSearchBtn, &QToolButton::clicked, this, &MailListView::onOnlineSearchClicked);
|
||||
searchLayout->addWidget(m_onlineSearchBtn);
|
||||
|
||||
layout->addWidget(searchBar);
|
||||
|
||||
// Filter bar
|
||||
@@ -687,6 +702,22 @@ void MailListView::initDrag()
|
||||
Q_UNUSED(dropAction);
|
||||
}
|
||||
|
||||
void MailListView::onOnlineSearchClicked()
|
||||
{
|
||||
QString query = m_searchEdit->text().trimmed();
|
||||
if (query.isEmpty()) {
|
||||
// If search box is empty, show a dialog to enter search query
|
||||
bool ok;
|
||||
query = QInputDialog::getText(this, "Buscar en servidor",
|
||||
"Introduce términos de búsqueda:",
|
||||
QLineEdit::Normal,
|
||||
"", &ok);
|
||||
if (!ok || query.trimmed().isEmpty()) return;
|
||||
}
|
||||
|
||||
emit onlineSearchRequested(query);
|
||||
}
|
||||
|
||||
void MailListView::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
|
||||
@@ -47,6 +47,8 @@ signals:
|
||||
void batchDeleteRequested(const QVector<int>& mailIds);
|
||||
void batchMarkUnreadRequested(const QVector<int>& mailIds);
|
||||
void batchMoveRequested(const QVector<int>& mailIds, int targetFolderId);
|
||||
// Online search
|
||||
void onlineSearchRequested(const QString& query);
|
||||
|
||||
public slots:
|
||||
void setFolderType(const QString& folderType); // "inbox", "sent", "drafts", etc.
|
||||
@@ -78,6 +80,7 @@ private slots:
|
||||
void enterMultiSelectMode();
|
||||
void exitMultiSelectMode();
|
||||
void onPivotChanged(int index); // Focused/Other pivot
|
||||
void onOnlineSearchClicked();
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
@@ -109,6 +112,7 @@ private:
|
||||
QCheckBox *m_pinnedOnlyCheck;
|
||||
QCheckBox *m_selectAllCheck; // Select all checkbox in action bar
|
||||
QWidget *m_actionBar; // Action bar widget
|
||||
QToolButton *m_onlineSearchBtn; // Online search button
|
||||
QComboBox *m_groupByCombo;
|
||||
QComboBox *m_displayModeCombo;
|
||||
QComboBox *m_pivotCombo; // Focused/Other pivot
|
||||
|
||||
@@ -1118,3 +1118,34 @@ void MainMainWindow::onEmbeddedDetachRequested(QWidget *widget)
|
||||
|
||||
statusBar()->showMessage(tr("Compose view detached to separate window"), 3000);
|
||||
}
|
||||
|
||||
void MainMainWindow::onOnlineSearchRequested(const QString& query)
|
||||
{
|
||||
if (m_currentFolderId < 0) {
|
||||
QMessageBox::warning(this, "Buscar online", "Selecciona una carpeta primero");
|
||||
return;
|
||||
}
|
||||
|
||||
std::optional<Folder> optFolder = FolderDao::findById(m_currentFolderId);
|
||||
if (!optFolder.has_value()) return;
|
||||
|
||||
Folder folder = optFolder.value();
|
||||
Account* account = m_accountService->findAccountById(folder.accountId());
|
||||
if (!account) {
|
||||
QMessageBox::warning(this, "Buscar online", "No se encontró la cuenta para esta carpeta");
|
||||
return;
|
||||
}
|
||||
|
||||
// Use MailService to search online (IMAP SEARCH)
|
||||
statusBar()->showMessage(tr("Buscando en servidor: %1").arg(query), 3000);
|
||||
|
||||
// TODO: Implement IMAP SEARCH in MailService
|
||||
// For now, show a message
|
||||
QMessageBox::information(this, "Buscar online",
|
||||
QString("Búsqueda en servidor para: '%1'\nCarpeta: %2\nCuenta: %3")
|
||||
.arg(query)
|
||||
.arg(folder.name())
|
||||
.arg(account->email()));
|
||||
|
||||
delete account;
|
||||
}
|
||||
|
||||
@@ -82,6 +82,8 @@ private slots:
|
||||
void onReplyRequested(int mailId);
|
||||
void onForwardRequested(int mailId);
|
||||
void onMarkUnreadRequested(int mailId);
|
||||
// Online search
|
||||
void onOnlineSearchRequested(const QString& query);
|
||||
|
||||
// Slots for embedded compose view
|
||||
void onEmbeddedSendRequested(const QString &to, const QString &cc, const QString &bcc,
|
||||
|
||||
Reference in New Issue
Block a user