Updated message inbox window for future work

This commit is contained in:
Jordan Sherer 2019-02-07 12:19:07 -05:00
parent bfd80df456
commit 24004b805c
5 changed files with 44 additions and 22 deletions

View File

@ -1380,7 +1380,7 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
displayActivity(true); displayActivity(true);
}); });
auto historyAction = new QAction(QString("Message History..."), ui->tableWidgetCalls); auto historyAction = new QAction(QString("View Message Inbox..."), ui->tableWidgetCalls);
connect(historyAction, &QAction::triggered, this, [this](){ connect(historyAction, &QAction::triggered, this, [this](){
QString selectedCall = callsignSelected(); QString selectedCall = callsignSelected();
if(selectedCall.isEmpty()){ if(selectedCall.isEmpty()){
@ -1393,21 +1393,32 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
} }
QList<Message> msgs; QList<Message> msgs;
foreach(auto pair, inbox.values("UNREAD", "$.params.FROM", selectedCall, 0, 1000)){
msgs.append(pair.second);
}
foreach(auto pair, inbox.values("READ", "$.params.FROM", selectedCall, 0, 1000)){ foreach(auto pair, inbox.values("READ", "$.params.FROM", selectedCall, 0, 1000)){
msgs.append(pair.second); msgs.append(pair.second);
} }
foreach(auto pair, inbox.values("UNREAD", "$.params.FROM", selectedCall, 0, 1000)){
auto msg = pair.second;
msgs.append(msg);
// mark as read
msg.setType("READ");
inbox.set(pair.first, msg);
}
qStableSort(msgs.begin(), msgs.end(), [](Message const &a, Message const &b){ qStableSort(msgs.begin(), msgs.end(), [](Message const &a, Message const &b){
return a.params().value("UTC") < b.params().value("UTC"); return a.params().value("UTC") > b.params().value("UTC");
}); });
auto mw = new MessageWindow(this); auto mw = new MessageWindow(this);
connect(mw, &MessageWindow::replyMessage, this, [this](const QString &text){ connect(mw, &MessageWindow::finished, this, [this](int){
addMessageText(text, true, false); refreshInboxCounts();
toggleTx(true); displayCallActivity();
});
connect(mw, &MessageWindow::replyMessage, this, [this, mw](const QString &text){
addMessageText(text, true, true);
refreshInboxCounts();
displayCallActivity();
mw->close();
}); });
mw->setCall(selectedCall); mw->setCall(selectedCall);
mw->populateMessages(msgs); mw->populateMessages(msgs);
@ -1448,10 +1459,8 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
menu->addAction(logAction); menu->addAction(logAction);
logAction->setDisabled(missingCallsign || isAllCall); logAction->setDisabled(missingCallsign || isAllCall);
#if SHOW_MESSAGE_HISTORY
menu->addAction(historyAction); menu->addAction(historyAction);
historyAction->setDisabled(missingCallsign || isAllCall || isGroupCall); historyAction->setDisabled(missingCallsign || isAllCall || isGroupCall || !hasMessageHistory(selectedCall));
#endif
menu->addSeparator(); menu->addSeparator();
@ -1575,7 +1584,7 @@ void MainWindow::checkStartupWarnings ()
{ {
MessageBox::critical_message (this, MessageBox::critical_message (this,
QString("This version of %1 is a pre-release development\n" QString("This version of %1 is a pre-release development\n"
"build andw will expire after %2 (UTC), upon which you\n" "build and will expire after %2 (UTC), upon which you\n"
"will need to upgrade to the latest version. \n\n" "will need to upgrade to the latest version. \n\n"
"Use of development versions of JS8Call are at your own risk \n" "Use of development versions of JS8Call are at your own risk \n"
"and carry a responsiblity to report any problems to:\n" "and carry a responsiblity to report any problems to:\n"
@ -1629,10 +1638,11 @@ void MainWindow::initializeDummyData(){
// qDebug() << Varicode::unpackAlphaNumeric50(Varicode::packAlphaNumeric50("@GROUP/42")); // qDebug() << Varicode::unpackAlphaNumeric50(Varicode::packAlphaNumeric50("@GROUP/42"));
// qDebug() << Varicode::unpackAlphaNumeric50(Varicode::packAlphaNumeric50("SP1ATOM")); // qDebug() << Varicode::unpackAlphaNumeric50(Varicode::packAlphaNumeric50("SP1ATOM"));
if(!m_config.my_groups().contains("@GROUP42")){
m_config.addGroup("@GROUP42");
}
QList<QString> calls = { QList<QString> calls = {
"@GROUP42",
"KN4CRD", "KN4CRD",
"VE7/KN4CRD", "VE7/KN4CRD",
"KN4CRD/P", "KN4CRD/P",
@ -7844,7 +7854,7 @@ void MainWindow::on_tableWidgetRXAll_selectionChanged(const QItemSelection &/*se
} }
ui->extFreeTextMsgEdit->setPlaceholderText(placeholderText); ui->extFreeTextMsgEdit->setPlaceholderText(placeholderText);
#if JS8CALL_SHOW_CALL_DETAIL_BROWSER #if SHOW_CALL_DETAIL_BROWSER
auto html = generateCallDetail(selectedCall); auto html = generateCallDetail(selectedCall);
ui->callDetailTextBrowser->setHtml(html); ui->callDetailTextBrowser->setHtml(html);
ui->callDetailTextBrowser->setVisible(!selectedCall.isEmpty() && (!hearing.isEmpty() || !heardby.isEmpty())); ui->callDetailTextBrowser->setVisible(!selectedCall.isEmpty() && (!hearing.isEmpty() || !heardby.isEmpty()));
@ -7886,7 +7896,7 @@ void MainWindow::on_tableWidgetCalls_cellDoubleClicked(int row, int col){
auto call = callsignSelected(); auto call = callsignSelected();
addMessageText(call); addMessageText(call);
#if 0 #if SHOW_MESSAGE_HISTORY_ON_DOUBLECLICK
if(m_rxInboxCountCache.value(call, 0) > 0){ if(m_rxInboxCountCache.value(call, 0) > 0){
// TODO: // TODO:
@ -10318,6 +10328,17 @@ void MainWindow::refreshInboxCounts(){
} }
} }
bool MainWindow::hasMessageHistory(QString call){
auto inbox = Inbox(inboxPath());
if(!inbox.open()){
return false;
}
int unread = inbox.count("UNREAD", "$.params.FROM", call);
int read = inbox.count("READ", "$.params.FROM", call);
return (unread + read) > 0;
}
int MainWindow::addCommandToMyInbox(CommandDetail d){ int MainWindow::addCommandToMyInbox(CommandDetail d){
// local cache for inbox count // local cache for inbox count
m_rxInboxCountCache[d.from] = m_rxInboxCountCache.value(d.from, 0) + 1; m_rxInboxCountCache[d.from] = m_rxInboxCountCache.value(d.from, 0) + 1;

View File

@ -952,6 +952,7 @@ private:
void processCommandActivity(); void processCommandActivity();
QString inboxPath(); QString inboxPath();
void refreshInboxCounts(); void refreshInboxCounts();
bool hasMessageHistory(QString call);
int addCommandToMyInbox(CommandDetail d); int addCommandToMyInbox(CommandDetail d);
int addCommandToInboxStorage(QString type, CommandDetail d); int addCommandToInboxStorage(QString type, CommandDetail d);
int getNextMessageIdForCallsign(QString callsign); int getNextMessageIdForCallsign(QString callsign);

View File

@ -111,8 +111,7 @@ void MessageWindow::populateMessages(QList<Message> msgs){
} }
} }
QString MessageWindow::prepareReplyMessage(QString path){ QString MessageWindow::prepareReplyMessage(QString path, QString text){
auto text = ui->replytextEdit->toPlainText();
return QString("%1 MSG %2").arg(path).arg(text); return QString("%1 MSG %2").arg(path).arg(text);
} }
@ -135,9 +134,8 @@ void MessageWindow::on_replyPushButton_clicked(){
} }
auto path = item->data(Qt::UserRole).toString(); auto path = item->data(Qt::UserRole).toString();
auto message = prepareReplyMessage(path); auto text = "[MESSAGE]"; // ui->replytextEdit->toPlainText();
auto message = prepareReplyMessage(path, text);
emit replyMessage(message); emit replyMessage(message);
close();
} }

View File

@ -24,7 +24,7 @@ signals:
public slots: public slots:
void setCall(const QString &call); void setCall(const QString &call);
void populateMessages(QList<Message> msgs); void populateMessages(QList<Message> msgs);
QString prepareReplyMessage(QString path); QString prepareReplyMessage(QString path, QString text);
private slots: private slots:
void on_messageTableWidget_selectionChanged(const QItemSelection &/*selected*/, const QItemSelection &/*deselected*/); void on_messageTableWidget_selectionChanged(const QItemSelection &/*selected*/, const QItemSelection &/*deselected*/);

View File

@ -136,6 +136,7 @@
</column> </column>
</widget> </widget>
<widget class="QTextEdit" name="messageTextEdit"> <widget class="QTextEdit" name="messageTextEdit">
<property name="visible"><bool>false</bool></property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding"> <sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -152,6 +153,7 @@
</property> </property>
</widget> </widget>
<widget class="QTextEdit" name="replytextEdit"> <widget class="QTextEdit" name="replytextEdit">
<property name="visible"><bool>false</bool></property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding"> <sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>