From ad4e567392e75b334065daf55cf10c8382799daa Mon Sep 17 00:00:00 2001 From: Jordan Sherer Date: Thu, 16 Aug 2018 11:31:10 -0400 Subject: [PATCH] Fixed display of allcalls. No longer red --- mainwindow.cpp | 32 +++++++++++++++++++++----------- mainwindow.h | 11 ++++++++--- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index c25bdf2..2c53062 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -6197,7 +6197,7 @@ bool MainWindow::isFreqOffsetFree(int f, int bw){ } // if this frequency is in our directed cache, it's always "free" - if(m_rxDirectedCache.contains(f/10*10)){ + if(isDirectedOffset(f, nullptr)){ return true; } @@ -8381,16 +8381,24 @@ void MainWindow::markOffsetRecent(int offset){ m_rxRecentCache.insert(offset/10*10+10, new QDateTime(QDateTime::currentDateTimeUtc()), 10); } -bool MainWindow::isDirectedOffset(int offset){ - return ( +bool MainWindow::isDirectedOffset(int offset, bool *pIsAllCall){ + bool isDirected = ( m_rxDirectedCache.contains(offset/10*10) && - m_rxDirectedCache[offset/10*10]->secsTo(QDateTime::currentDateTimeUtc()) < 300 + m_rxDirectedCache[offset/10*10]->date.secsTo(QDateTime::currentDateTimeUtc()) < 300 ); + + if(isDirected){ + if(pIsAllCall) *pIsAllCall = m_rxDirectedCache[offset/10*10]->isAllcall; + } + + return isDirected; } -void MainWindow::markOffsetDirected(int offset){ - m_rxDirectedCache.insert(offset/10*10, new QDateTime(QDateTime::currentDateTimeUtc()), 10); - m_rxDirectedCache.insert(offset/10*10+10, new QDateTime(QDateTime::currentDateTimeUtc()), 10); +void MainWindow::markOffsetDirected(int offset, bool isAllCall){ + CachedDirectedType *d1 = new CachedDirectedType{ isAllCall, QDateTime::currentDateTimeUtc() }; + CachedDirectedType *d2 = new CachedDirectedType{ isAllCall, QDateTime::currentDateTimeUtc() }; + m_rxDirectedCache.insert(offset/10*10, d1, 10); + m_rxDirectedCache.insert(offset/10*10+10, d2, 10); } bool MainWindow::isMyCallIncluded(const QString &text){ @@ -8463,8 +8471,9 @@ void MainWindow::processRxActivity() { // if this is a (recent) directed offset, bump the cache, and display... // this will allow a directed free text command followed by non-buffered data frames. - if(isDirectedOffset(d.freq)){ - markOffsetDirected(d.freq); + bool isDirectedAllCall = false; + if(isDirectedOffset(d.freq, &isDirectedAllCall)){ + markOffsetDirected(d.freq, isDirectedAllCall); shouldDisplay = true; } @@ -8745,7 +8754,7 @@ void MainWindow::processCommandActivity() { } // and mark the offset as a directed offset so future free text is displayed - markOffsetDirected(ad.freq); + markOffsetDirected(ad.freq, isAllCall); // construct a reply, if needed QString reply; @@ -9073,7 +9082,8 @@ void MainWindow::displayBandActivity() { textItem->setBackground(QBrush(m_config.color_CQ())); } - if (isDirectedOffset(offset)) { + bool isDirectedAllCall = false; + if (isDirectedOffset(offset, &isDirectedAllCall) && !isDirectedAllCall) { offsetItem->setBackground(QBrush(m_config.color_MyCall())); ageItem->setBackground(QBrush(m_config.color_MyCall())); snrItem->setBackground(QBrush(m_config.color_MyCall())); diff --git a/mainwindow.h b/mainwindow.h index 432ee97..16b5d01 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -724,6 +724,11 @@ private: } }; + struct CachedDirectedType { + bool isAllcall; + QDateTime date; + }; + QPriorityQueue m_txMessageQueue; // messages to be sent QQueue m_txFrameQueue; // frames to be sent QQueue m_rxActivityQueue; // all rx activity queue @@ -732,7 +737,7 @@ private: QMap m_compoundCallCache; // base callsign -> compound callsign QCache m_txAllcallCommandCache; // callsign -> last tx QCache m_rxRecentCache; // freq -> last rx - QCache m_rxDirectedCache; // freq -> last directed rx + QCache m_rxDirectedCache; // freq -> last directed rx QCache m_rxCallCache; // call -> last freq seen QMap m_rxFrameBlockNumbers; // freq -> block QMap> m_bandActivity; // freq -> [(text, last timestamp), ...] @@ -836,8 +841,8 @@ private: QString callsignSelected(); bool isRecentOffset(int offset); void markOffsetRecent(int offset); - bool isDirectedOffset(int offset); - void markOffsetDirected(int offset); + bool isDirectedOffset(int offset, bool *pIsAllCall); + void markOffsetDirected(int offset, bool isAllCall); void processActivity(bool force=false); void processRxActivity(); void processCompoundActivity();