diff --git a/mainwindow.cpp b/mainwindow.cpp index a5349c6..51a2e6f 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1392,21 +1392,21 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, return; } - QList msgs; - foreach(auto pair, inbox.values("READ", "$.params.FROM", selectedCall, 0, 1000)){ - msgs.append(pair.second); - } + QList > msgs; + + msgs.append(inbox.values("READ", "$.params.FROM", selectedCall, 0, 1000)); + foreach(auto pair, inbox.values("UNREAD", "$.params.FROM", selectedCall, 0, 1000)){ - auto msg = pair.second; - msgs.append(msg); + msgs.append(pair); // mark as read + auto msg = pair.second; msg.setType("READ"); inbox.set(pair.first, msg); } - qStableSort(msgs.begin(), msgs.end(), [](Message const &a, Message const &b){ - return a.params().value("UTC") > b.params().value("UTC"); + qStableSort(msgs.begin(), msgs.end(), [](QPair const &a, QPair const &b){ + return a.second.params().value("UTC") > b.second.params().value("UTC"); }); auto mw = new MessageWindow(this); @@ -7436,6 +7436,19 @@ void MainWindow::buildQueryMenu(QMenu * menu, QString call){ addMessageText(QString("%1>[MESSAGE]").arg(selectedCall), true, true); }); + auto msgAction = menu->addAction(QString("%1 MSG [MESSAGE] - Please store this message in your inbox").arg(call).trimmed()); + msgAction->setDisabled(isAllCall); + connect(msgAction, &QAction::triggered, this, [this](){ + + QString selectedCall = callsignSelected(); + if(selectedCall.isEmpty()){ + return; + } + + addMessageText(QString("%1 MSG [MESSAGE]").arg(selectedCall), true, true); + }); + + auto msgToAction = menu->addAction(QString("%1 MSG TO:[CALLSIGN] [MESSAGE] - Please store this message at your station for later retreival by [CALLSIGN]").arg(call).trimmed()); msgToAction->setDisabled(isAllCall); connect(msgToAction, &QAction::triggered, this, [this](){ @@ -7459,7 +7472,7 @@ void MainWindow::buildQueryMenu(QMenu * menu, QString call){ addMessageText(QString("%1 QUERY CALL [CALLSIGN]?").arg(selectedCall), true, true); }); - auto qsoQueryMsgAction = menu->addAction(QString("%1 QUERY MSGS - Please deliver any messages you have for me").arg(call).trimmed()); + auto qsoQueryMsgAction = menu->addAction(QString("%1 QUERY MSGS - Do you have any messages for me?").arg(call).trimmed()); connect(qsoQueryMsgAction, &QAction::triggered, this, [this](){ QString selectedCall = callsignSelected(); @@ -9992,12 +10005,6 @@ void MainWindow::processCommandActivity() { // if we make it here, this is a message addCommandToMyInbox(d); #endif - -#if ALERT_ON_NEW_MSG - QTimer::singleShot(500, this, [this, d](){ - MessageBox::information_message(this, QString("A new message was received at %1 UTC from %2").arg(d.utcTimestamp.time().toString()).arg(d.from)); - }); -#endif } } @@ -10083,6 +10090,19 @@ void MainWindow::processCommandActivity() { // we haven't replaced the from with the relay path, so we have to use it for the ack if there is one reply = QString("%1 ACK").arg(calls.length() > 1 ? d.relayPath : d.from); + +#define SHOW_ALERT_FOR_MSG 1 +#if SHOW_ALERT_FOR_MSG + SelfDestructMessageBox * m = new SelfDestructMessageBox(300, + "New Message Received", + QString("A new message was received at %1 UTC from %2").arg(d.utcTimestamp.time().toString()).arg(d.from), + QMessageBox::Information, + QMessageBox::Ok, + QMessageBox::Ok, + this); + + m->show(); +#endif } // PROCESS ACKS @@ -11894,7 +11914,7 @@ void MainWindow::tx_watchdog (bool triggered) QMessageBox * msgBox = new QMessageBox(this); msgBox->setIcon(QMessageBox::Information); - msgBox->setText("Idle Timeout"); + msgBox->setWindowTitle("Idle Timeout"); msgBox->setInformativeText(QString("You have been idle for more than %1 minutes.").arg(m_config.watchdog())); msgBox->addButton(QMessageBox::Ok); diff --git a/messagewindow.cpp b/messagewindow.cpp index 0c59a3b..b83b007 100644 --- a/messagewindow.cpp +++ b/messagewindow.cpp @@ -52,14 +52,16 @@ void MessageWindow::setCall(const QString &call){ setWindowTitle(QString("Message History: %1").arg(call)); } -void MessageWindow::populateMessages(QList msgs){ +void MessageWindow::populateMessages(QList > msgs){ for(int i = ui->messageTableWidget->rowCount(); i >= 0; i--){ ui->messageTableWidget->removeRow(i); } ui->messageTableWidget->setUpdatesEnabled(false); { - foreach(auto msg, msgs){ + foreach(auto pair, msgs){ + auto mid = pair.first; + auto msg = pair.second; auto params = msg.params(); int row = ui->messageTableWidget->rowCount(); @@ -72,6 +74,11 @@ void MessageWindow::populateMessages(QList msgs){ typeItem->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter); ui->messageTableWidget->setItem(row, col++, typeItem); + auto midItem = new QTableWidgetItem(QString::number(mid)); + midItem->setData(Qt::UserRole, mid); + midItem->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter); + ui->messageTableWidget->setItem(row, col++, midItem); + auto date = params.value("UTC").toString(); auto timestamp = QDateTime::fromString(date, "yyyy-MM-dd hh:mm:ss"); auto dateItem = new QTableWidgetItem(timestamp.toString()); @@ -103,6 +110,7 @@ void MessageWindow::populateMessages(QList msgs){ ui->messageTableWidget->resizeColumnToContents(1); ui->messageTableWidget->resizeColumnToContents(2); ui->messageTableWidget->resizeColumnToContents(3); + ui->messageTableWidget->resizeColumnToContents(4); } ui->messageTableWidget->setUpdatesEnabled(true); diff --git a/messagewindow.h b/messagewindow.h index 66a5e75..9ba7bea 100644 --- a/messagewindow.h +++ b/messagewindow.h @@ -2,6 +2,7 @@ #define MESSAGEWINDOW_H #include +#include #include #include "Message.h" @@ -23,7 +24,7 @@ signals: public slots: void setCall(const QString &call); - void populateMessages(QList msgs); + void populateMessages(QList> msgs); QString prepareReplyMessage(QString path, QString text); private slots: diff --git a/messagewindow.ui b/messagewindow.ui index 72596e2..b2f369a 100644 --- a/messagewindow.ui +++ b/messagewindow.ui @@ -110,10 +110,18 @@ + + Read / Unread Status + AlignCenter + + + ID + + Date @@ -136,7 +144,6 @@ - false 0 @@ -148,18 +155,23 @@ 14 + + false + QTextEdit { background-color:#ffeaa7; } - false 0 1 + + false +