First attempt at decode huighlighting priorities

Drag'n'drop highligting items in "Settings->Colors" to set priorities,
higher up is higher priority.  The default priorities and colours have
been changed to give a reasonable starting configuration.
This commit is contained in:
Bill Somerville 2018-10-18 21:11:39 +01:00
parent 55daa1db7f
commit 088e2ce69e
3 changed files with 48 additions and 43 deletions

View File

@ -2197,7 +2197,7 @@ Right click for insert and delete options.</string>
<bool>true</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;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.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;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.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
@ -3026,11 +3026,11 @@ Right click for insert and delete options.</string>
</connections>
<buttongroups>
<buttongroup name="CAT_handshake_button_group"/>
<buttongroup name="PTT_method_button_group"/>
<buttongroup name="split_mode_button_group"/>
<buttongroup name="TX_mode_button_group"/>
<buttongroup name="CAT_stop_bits_button_group"/>
<buttongroup name="CAT_data_bits_button_group"/>
<buttongroup name="PTT_method_button_group"/>
<buttongroup name="CAT_stop_bits_button_group"/>
<buttongroup name="TX_audio_source_button_group"/>
</buttongroups>
</ui>

View File

@ -29,9 +29,7 @@ public:
};
QList<DecodeHighlightingModel::HighlightInfo> 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<DecodeHighlightingModel::HighlightInfo> 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)

View File

@ -1,4 +1,8 @@
#include "displaytext.h"
#include <vector>
#include <algorithm>
#include <QMouseEvent>
#include <QDateTime>
#include <QTextCharFormat>
@ -6,6 +10,7 @@
#include <QTextBlock>
#include <QMenu>
#include <QAction>
#include <QListIterator>
#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<DecodeHighlightingModel::Highlight>;
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<DecodeHighlightingModel::HighlightInfo> 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);
}