Narrow decode prints in the Band Activity window

This commit is contained in:
Bill Somerville 2020-07-21 00:29:22 +01:00
parent 2da65408a8
commit 0f6d054276
No known key found for this signature in database
GPG Key ID: D864B06D1E81618F
2 changed files with 37 additions and 22 deletions

View File

@ -241,10 +241,9 @@ void DisplayText::new_period ()
QString DisplayText::appendWorkedB4 (QString message, QString call, QString const& grid, QString DisplayText::appendWorkedB4 (QString message, QString call, QString const& grid,
QColor * bg, QColor * fg, LogBook const& logBook, QColor * bg, QColor * fg, LogBook const& logBook,
QString const& currentBand, QString const& currentMode) QString const& currentBand, QString const& currentMode,
QString extra)
{ {
// allow for seconds
int padding {message.indexOf (" ") > 4 ? 2 : 0};
QString countryName; QString countryName;
bool callB4; bool callB4;
bool callB4onBand; bool callB4onBand;
@ -278,7 +277,6 @@ QString DisplayText::appendWorkedB4 (QString message, QString call, QString cons
} }
message = message.trimmed (); message = message.trimmed ();
QString appendage;
highlight_types types; highlight_types types;
// no shortcuts here as some types may be disabled // no shortcuts here as some types may be disabled
@ -329,20 +327,20 @@ QString DisplayText::appendWorkedB4 (QString message, QString call, QString cons
{ {
case Highlight::Continent: case Highlight::Continent:
case Highlight::ContinentBand: case Highlight::ContinentBand:
appendage = AD1CCty::continent (looked_up.continent); extra += AD1CCty::continent (looked_up.continent);
break; break;
case Highlight::CQZone: case Highlight::CQZone:
case Highlight::CQZoneBand: case Highlight::CQZoneBand:
appendage = QString {"CQ Zone %1"}.arg (looked_up.CQ_zone); extra += QString {"CQ Zone %1"}.arg (looked_up.CQ_zone);
break; break;
case Highlight::ITUZone: case Highlight::ITUZone:
case Highlight::ITUZoneBand: case Highlight::ITUZoneBand:
appendage = QString {"ITU Zone %1"}.arg (looked_up.ITU_zone); extra += QString {"ITU Zone %1"}.arg (looked_up.ITU_zone);
break; break;
default: default:
if (m_bPrincipalPrefix) if (m_bPrincipalPrefix)
{ {
appendage = looked_up.primary_prefix; extra += looked_up.primary_prefix;
} }
else else
{ {
@ -368,19 +366,30 @@ QString DisplayText::appendWorkedB4 (QString message, QString call, QString cons
countryName.replace ("European", "EU"); countryName.replace ("European", "EU");
countryName.replace ("African", "AF"); countryName.replace ("African", "AF");
appendage += countryName; extra += countryName;
} }
} }
m_CQPriority=DecodeHighlightingModel::highlight_name(top_highlight); m_CQPriority=DecodeHighlightingModel::highlight_name(top_highlight);
// use a nbsp to save the start of appended text so we can find return leftJustifyAppendage (message, extra);
// it again later, align appended data at a fixed column if }
// there is space otherwise let it float to the right
int space_count {40 + padding - message.size ()}; QString DisplayText::leftJustifyAppendage (QString message, QString const& appendage) const
if (space_count > 0) { {
message += QString {space_count, QChar {' '}}; if (appendage.size ())
} {
message += QChar::Nbsp + appendage; // allow for seconds
int padding {message.indexOf (" ") > 4 ? 2 : 0};
// use a nbsp to save the start of appended text so we can find
// it again later, align appended data at a fixed column if
// there is space otherwise let it float to the right
int space_count {40 + padding - message.size ()};
if (space_count > 0) {
message += QString {space_count, QChar {' '}};
}
message += QChar::Nbsp + appendage;
}
return message; return message;
} }
@ -421,11 +430,11 @@ void DisplayText::displayDecodedText(DecodedText const& decodedText, QString con
decodedText.deCallAndGrid (/*out*/ dxCall, dxGrid); decodedText.deCallAndGrid (/*out*/ dxCall, dxGrid);
QRegularExpression grid_regexp {"\\A(?![Rr]{2}73)[A-Ra-r]{2}[0-9]{2}([A-Xa-x]{2}){0,1}\\z"}; QRegularExpression grid_regexp {"\\A(?![Rr]{2}73)[A-Ra-r]{2}[0-9]{2}([A-Xa-x]{2}){0,1}\\z"};
if(!dxGrid.contains(grid_regexp)) dxGrid=""; if(!dxGrid.contains(grid_regexp)) dxGrid="";
message = message.left (message.indexOf (QChar::Nbsp)); // strip appended info message = message.left (message.indexOf (QChar::Nbsp)).trimmed (); // strip appended info
QString extra;
if (haveFSpread) if (haveFSpread)
{ {
message += QString {37 - message.size (), QChar {' '}}; extra = QString {"%1"}.arg (fSpread, 5, 'f', fSpread < 0.95 ? 3 : 2) + QChar {' '};
message += QChar::Nbsp + QString {"%1"}.arg (fSpread, 5, 'f', fSpread < 0.95 ? 3 : 2);
} }
m_CQPriority=""; m_CQPriority="";
if (CQcall) if (CQcall)
@ -440,10 +449,11 @@ void DisplayText::displayDecodedText(DecodedText const& decodedText, QString con
currentMode = decodedText.isJT65 () ? "JT65" : "JT9"; currentMode = decodedText.isJT65 () ? "JT65" : "JT9";
} }
message = appendWorkedB4 (message, decodedText.CQersCall(), dxGrid, &bg, &fg message = appendWorkedB4 (message, decodedText.CQersCall(), dxGrid, &bg, &fg
, logBook, currentBand, currentMode); , logBook, currentBand, currentMode, extra);
} }
else else
{ {
message = leftJustifyAppendage (message, extra);
highlight_types types {Highlight::CQ}; highlight_types types {Highlight::CQ};
if (m_config && m_config->lotw_users ().user (decodedText.CQersCall())) if (m_config && m_config->lotw_users ().user (decodedText.CQersCall()))
{ {
@ -452,6 +462,10 @@ void DisplayText::displayDecodedText(DecodedText const& decodedText, QString con
set_colours (m_config, &bg, &fg, types); set_colours (m_config, &bg, &fg, types);
} }
} }
else
{
message = leftJustifyAppendage (message, extra);
}
appendText (message.trimmed (), bg, fg, decodedText.call (), dxCall); appendText (message.trimmed (), bg, fg, decodedText.call (), dxCall);
} }

View File

@ -47,6 +47,7 @@ public:
Q_SLOT void highlight_callsign (QString const& callsign, QColor const& bg, QColor const& fg, bool last_period_only); Q_SLOT void highlight_callsign (QString const& callsign, QColor const& bg, QColor const& fg, bool last_period_only);
private: private:
QString leftJustifyAppendage (QString message, QString const& appendage) const;
void mouseDoubleClickEvent (QMouseEvent *) override; void mouseDoubleClickEvent (QMouseEvent *) override;
void extend_vertical_scrollbar (int min, int max); void extend_vertical_scrollbar (int min, int max);
@ -57,7 +58,7 @@ private:
QString appendWorkedB4(QString message, QString callsign QString appendWorkedB4(QString message, QString callsign
, QString const& grid, QColor * bg, QColor * fg , QString const& grid, QColor * bg, QColor * fg
, LogBook const& logBook, QString const& currentBand , LogBook const& logBook, QString const& currentBand
, QString const& currentMode); , QString const& currentMode, QString extra);
QFont char_font_; QFont char_font_;
QAction * erase_action_; QAction * erase_action_;
QHash<QString, QPair<QColor, QColor>> highlighted_calls_; QHash<QString, QPair<QColor, QColor>> highlighted_calls_;