diff --git a/Configuration.ui b/Configuration.ui
index d507c5a7b..38aedf125 100644
--- a/Configuration.ui
+++ b/Configuration.ui
@@ -2197,7 +2197,7 @@ Right click for insert and delete options.
true
- <html><head/><body><p>Enable or disable using the check boxes and right-click an item to change the foreground color, background color, or reset the item to default values.</p></body></html>
+ <html><head/><body><p>Enable or disable using the check boxes and right-click an item to change the foreground color, background color, or reset the item to default values. Drag and drop the items to change their priority, higher in the list is higher in priority.</p></body></html>
Qt::ScrollBarAlwaysOff
@@ -3026,11 +3026,11 @@ Right click for insert and delete options.
-
-
+
+
diff --git a/DecodeHighlightingModel.cpp b/DecodeHighlightingModel.cpp
index b86e85224..8e4b3bbdb 100644
--- a/DecodeHighlightingModel.cpp
+++ b/DecodeHighlightingModel.cpp
@@ -29,9 +29,7 @@ public:
};
QList const DecodeHighlightingModel::impl::defaults_ = {
- {Highlight::CQ, true, {}, {{0x66, 0xff, 0x66}}}
- , {Highlight::MyCall, true, {}, {{0xff, 0x66, 0x66}}}
- , {Highlight::Tx, true, {}, {{Qt::yellow}}}
+ {Highlight::MyCall, true, {}, {{0xff, 0x66, 0x66}}}
, {Highlight::DXCC, true, {}, {{0xff, 0x00, 0xff}}}
, {Highlight::DXCCBand, true, {}, {{0xff, 0xaa, 0xff}}}
, {Highlight::Grid, false, {}, {{0xff, 0x80, 0x00}}}
@@ -39,6 +37,8 @@ QList const DecodeHighlightingModel::imp
, {Highlight::Call, false, {}, {{0x00, 0xff, 0xff}}}
, {Highlight::CallBand, false, {}, {{0x99, 0xff, 0xff}}}
, {Highlight::LotW, false, {{0x99, 0x00, 0x00}}, {}}
+ , {Highlight::CQ, true, {}, {{0x66, 0xff, 0x66}}}
+ , {Highlight::Tx, true, {}, {{Qt::yellow}}}
};
bool operator == (DecodeHighlightingModel::HighlightInfo const& lhs, DecodeHighlightingModel::HighlightInfo const& rhs)
diff --git a/displaytext.cpp b/displaytext.cpp
index bc51734b6..80aed95fe 100644
--- a/displaytext.cpp
+++ b/displaytext.cpp
@@ -1,4 +1,8 @@
#include "displaytext.h"
+
+#include
+#include
+
#include
#include
#include
@@ -6,6 +10,7 @@
#include
#include
#include
+#include
#include "Configuration.hpp"
#include "LotWUsers.hpp"
@@ -78,13 +83,19 @@ void DisplayText::insertLineSpacer(QString const& line)
namespace
{
- void set_colours (Configuration const * config, QColor * bg, QColor * fg, DecodeHighlightingModel::Highlight type)
+ using highlight_types = std::vector;
+ void set_colours (Configuration const * config, QColor * bg, QColor * fg, highlight_types const& types)
{
if (config)
{
- for (auto const& item : config->decode_highlighting ().items ())
+ QListIterator it {config->decode_highlighting ().items ()};
+ // iterate in reverse to honor priorities
+ it.toBack ();
+ while (it.hasPrevious ())
{
- if (type == item.type_ && item.enabled_)
+ auto const& item = it.previous ();
+ auto const& type = std::find (types.begin (), types.end (), item.type_);
+ if (type != types.end () && *type == item.type_ && item.enabled_)
{
if (item.background_.style () != Qt::NoBrush)
{
@@ -94,7 +105,6 @@ namespace
{
*fg = item.foreground_.color ();
}
- break;
}
}
}
@@ -191,7 +201,8 @@ void DisplayText::appendText(QString const& text, QColor bg, QColor fg
{
QColor bg;
QColor fg;
- set_colours (m_config, &bg, &fg, DecodeHighlightingModel::Highlight::LotW);
+ highlight_types types {DecodeHighlightingModel::Highlight::LotW};
+ set_colours (m_config, &bg, &fg, types);
if (bg.isValid ()) format.setBackground (bg);
if (fg.isValid ()) format.setForeground (fg);
}
@@ -238,37 +249,28 @@ QString DisplayText::appendWorkedB4(QString message, QString const& callsign, QS
message = message.trimmed ();
QString appendage{""};
+ highlight_types types;
+ // no shortcuts here as some types may be disabled
if (!countryWorkedBefore) {
- // therefore not worked call either
- // appendage += "!";
- set_colours (m_config, bg, fg, DecodeHighlightingModel::Highlight::DXCC);
- } else {
- if(!countryB4onBand) {
- set_colours (m_config, bg, fg, DecodeHighlightingModel::Highlight::DXCCBand);
- } else {
- if(!gridB4) {
- set_colours (m_config, bg, fg, DecodeHighlightingModel::Highlight::Grid);
- } else {
- if(!gridB4onBand) {
- set_colours (m_config, bg, fg, DecodeHighlightingModel::Highlight::GridBand);
- } else {
- if (!callWorkedBefore) {
- // but have worked the country
-// appendage += "~";
- set_colours (m_config, bg, fg, DecodeHighlightingModel::Highlight::Call);
- } else {
- if(!callB4onBand) {
-// appendage += "~";
- set_colours (m_config, bg, fg, DecodeHighlightingModel::Highlight::CallBand);
- } else {
-// appendage += " "; // have worked this call before
- set_colours (m_config, bg, fg, DecodeHighlightingModel::Highlight::CQ);
- }
- }
- }
- }
- }
+ types.push_back (DecodeHighlightingModel::Highlight::DXCC);
}
+ if(!countryB4onBand) {
+ types.push_back (DecodeHighlightingModel::Highlight::DXCCBand);
+ }
+ if(!gridB4) {
+ types.push_back (DecodeHighlightingModel::Highlight::Grid);
+ }
+ if(!gridB4onBand) {
+ types.push_back (DecodeHighlightingModel::Highlight::GridBand);
+ }
+ if (!callWorkedBefore) {
+ types.push_back (DecodeHighlightingModel::Highlight::Call);
+ }
+ if(!callB4onBand) {
+ types.push_back (DecodeHighlightingModel::Highlight::CallBand);
+ }
+ types.push_back (DecodeHighlightingModel::Highlight::CQ);
+ set_colours (m_config, bg, fg, types);
int i1=countryName.indexOf(";");
if(m_bPrincipalPrefix) {
@@ -323,7 +325,8 @@ void DisplayText::displayDecodedText(DecodedText const& decodedText, QString con
|| decodedText.string ().contains (" QRZ "))
{
CQcall = true;
- set_colours (m_config, &bg, &fg, DecodeHighlightingModel::Highlight::CQ);
+ highlight_types types {DecodeHighlightingModel::Highlight::CQ};
+ set_colours (m_config, &bg, &fg, types);
}
if(bCQonly and !CQcall) return;
if (myCall != "" and (decodedText.indexOf (" " + myCall + " ") >= 0
@@ -334,7 +337,8 @@ void DisplayText::displayDecodedText(DecodedText const& decodedText, QString con
or decodedText.indexOf ("<" + myCall + " ") >= 0
or decodedText.indexOf ("<" + myCall + ">") >= 0
or decodedText.indexOf (" " + myCall + ">") >= 0)) {
- set_colours (m_config, &bg, &fg, DecodeHighlightingModel::Highlight::MyCall);
+ highlight_types types {DecodeHighlightingModel::Highlight::MyCall};
+ set_colours (m_config, &bg, &fg, types);
}
auto message = decodedText.string();
QString dxCall;
@@ -373,7 +377,8 @@ void DisplayText::displayTransmittedText(QString text, QString modeTx, qint32 tx
}
QColor bg;
QColor fg;
- set_colours (m_config, &bg, &fg, DecodeHighlightingModel::Highlight::Tx);
+ highlight_types types {DecodeHighlightingModel::Highlight::Tx};
+ set_colours (m_config, &bg, &fg, types);
appendText (t, bg, fg);
}