Able to delete message from message inbox
This commit is contained in:
parent
538c70d158
commit
8b3b34d876
@ -1405,6 +1405,7 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
|
|||||||
|
|
||||||
QList<QPair<int, Message> > msgs;
|
QList<QPair<int, Message> > 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));
|
msgs.append(inbox.values("READ", "$.params.FROM", selectedCall, 0, 1000));
|
||||||
|
|
||||||
foreach(auto pair, inbox.values("UNREAD", "$.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();
|
refreshInboxCounts();
|
||||||
displayCallActivity();
|
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){
|
connect(mw, &MessageWindow::replyMessage, this, [this, mw](const QString &text){
|
||||||
addMessageText(text, true, true);
|
addMessageText(text, true, true);
|
||||||
refreshInboxCounts();
|
refreshInboxCounts();
|
||||||
|
@ -42,6 +42,30 @@ MessageWindow::MessageWindow(QWidget *parent) :
|
|||||||
|
|
||||||
ui->messageTableWidget->horizontalHeader()->setVisible(true);
|
ui->messageTableWidget->horizontalHeader()->setVisible(true);
|
||||||
ui->messageTableWidget->resizeColumnsToContents();
|
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()
|
MessageWindow::~MessageWindow()
|
||||||
|
@ -20,6 +20,7 @@ public:
|
|||||||
~MessageWindow();
|
~MessageWindow();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void deleteMessage(int id);
|
||||||
void replyMessage(const QString &call);
|
void replyMessage(const QString &call);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
Loading…
Reference in New Issue
Block a user