diff --git a/mainwindow.cpp b/mainwindow.cpp index cc1d1f6..1635898 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1405,6 +1405,7 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, QList > msgs; + msgs.append(inbox.values("STORE", "$.params.FROM", Radio::base_callsign(m_config.my_callsign()), 0, 1000)); msgs.append(inbox.values("READ", "$.params.FROM", selectedCall, 0, 1000)); foreach(auto pair, inbox.values("UNREAD", "$.params.FROM", selectedCall, 0, 1000)){ @@ -1425,6 +1426,14 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, refreshInboxCounts(); displayCallActivity(); }); + connect(mw, &MessageWindow::deleteMessage, this, [this](int id){ + Inbox inbox(inboxPath()); + if(!inbox.open()){ + return; + } + + inbox.del(id); + }); connect(mw, &MessageWindow::replyMessage, this, [this, mw](const QString &text){ addMessageText(text, true, true); refreshInboxCounts(); diff --git a/messagewindow.cpp b/messagewindow.cpp index 96d468c..ca7e0e7 100644 --- a/messagewindow.cpp +++ b/messagewindow.cpp @@ -42,6 +42,30 @@ MessageWindow::MessageWindow(QWidget *parent) : ui->messageTableWidget->horizontalHeader()->setVisible(true); ui->messageTableWidget->resizeColumnsToContents(); + + ui->messageTableWidget->setContextMenuPolicy(Qt::ActionsContextMenu); + auto deleteAction = new QAction("Delete", ui->messageTableWidget); + connect(deleteAction, &QAction::triggered, this, [this](){ + auto items = ui->messageTableWidget->selectedItems(); + if(items.isEmpty()){ + return; + } + auto item = items.first(); + auto col = ui->messageTableWidget->item(item->row(), 1); + if(!col){ + return; + } + bool ok = false; + auto mid = col->data(Qt::UserRole).toInt(&ok); + if(!ok){ + return; + } + + ui->messageTableWidget->removeRow(item->row()); + + emit this->deleteMessage(mid); + }); + ui->messageTableWidget->addAction(deleteAction); } MessageWindow::~MessageWindow() diff --git a/messagewindow.h b/messagewindow.h index 9ba7bea..2b29c8c 100644 --- a/messagewindow.h +++ b/messagewindow.h @@ -20,6 +20,7 @@ public: ~MessageWindow(); signals: + void deleteMessage(int id); void replyMessage(const QString &call); public slots: