Working toward activating highlights for "New DXCC on band", "New Grid", and "New Grid on Band".

This commit is contained in:
Joe Taylor 2018-08-24 14:42:08 -04:00
parent 0fbc9f3514
commit 68ec268fef
6 changed files with 49 additions and 50 deletions

View File

@ -151,8 +151,8 @@ void DisplayText::appendText(QString const& text, QColor bg, QString const& call
document ()->setMaximumBlockCount (document ()->maximumBlockCount ()); document ()->setMaximumBlockCount (document ()->maximumBlockCount ());
} }
QString DisplayText::appendDXCCWorkedB4(QString message, QString const& callsign, QColor * bg, QString DisplayText::appendWorkedB4(QString message, QString const& callsign, QString grid,
LogBook const& logBook, QString currentBand) QColor * bg, LogBook const& logBook, QString currentBand)
{ {
// allow for seconds // allow for seconds
int padding {message.indexOf (" ") > 4 ? 2 : 0}; int padding {message.indexOf (" ") > 4 ? 2 : 0};
@ -162,6 +162,9 @@ QString DisplayText::appendDXCCWorkedB4(QString message, QString const& callsign
bool callB4onBand; bool callB4onBand;
bool countryWorkedBefore; bool countryWorkedBefore;
bool countryB4onBand; bool countryB4onBand;
bool gridB4;
bool gridB4onBand;
if(call.length()==2) { if(call.length()==2) {
int i0=message.indexOf("CQ "+call); int i0=message.indexOf("CQ "+call);
@ -172,8 +175,8 @@ QString DisplayText::appendDXCCWorkedB4(QString message, QString const& callsign
if(call.length()<3) return message; if(call.length()<3) return message;
if(!call.contains(QRegExp("[0-9]|[A-Z]"))) return message; if(!call.contains(QRegExp("[0-9]|[A-Z]"))) return message;
logBook.match(/*in*/call,/*out*/countryName,callWorkedBefore,countryWorkedBefore); logBook.match(/*in*/call,grid,/*out*/countryName,callWorkedBefore,countryWorkedBefore,gridB4);
logBook.match(/*in*/call,/*out*/countryName,callB4onBand,countryB4onBand, logBook.match(/*in*/call,grid,/*out*/countryName,callB4onBand,countryB4onBand,gridB4onBand,
/*in*/ currentBand); /*in*/ currentBand);
message = message.trimmed (); message = message.trimmed ();
@ -232,12 +235,10 @@ QString DisplayText::appendDXCCWorkedB4(QString message, QString const& callsign
// it again later, align appended data at a fixed column if // it again later, align appended data at a fixed column if
// there is space otherwise let it float to the right // there is space otherwise let it float to the right
int space_count {40 + padding - message.size ()}; int space_count {40 + padding - message.size ()};
if (space_count > 0) if (space_count > 0) {
{ message += QString {space_count, QChar {' '}};
message += QString {space_count, QChar {' '}}; }
}
message += QChar::Nbsp + appendage; message += QChar::Nbsp + appendage;
return message; return message;
} }
@ -267,12 +268,14 @@ void DisplayText::displayDecodedText(DecodedText const& decodedText, QString con
auto message = decodedText.string(); auto message = decodedText.string();
QString dxCall; QString dxCall;
QString dxGrid; QString dxGrid;
decodedText.deCallAndGrid (dxCall, dxGrid); decodedText.deCallAndGrid (/*out*/ dxCall, dxGrid);
QRegularExpression m_grid_regexp {"\\A(?![Rr]{2}73)[A-Ra-r]{2}[0-9]{2}([A-Xa-x]{2}){0,1}\\z"};
if(!dxGrid.contains(m_grid_regexp)) dxGrid="";
message = message.left (message.indexOf (QChar::Nbsp)); // strip appended info message = message.left (message.indexOf (QChar::Nbsp)); // strip appended info
if (displayDXCCEntity && CQcall) if (displayDXCCEntity && CQcall)
// if enabled add the DXCC entity and B4 status to the end of the // if enabled add the DXCC entity and B4 status to the end of the
// preformated text line t1 // preformated text line t1
message = appendDXCCWorkedB4 (message, decodedText.CQersCall (), &bg, logBook, currentBand); message = appendWorkedB4 (message, decodedText.CQersCall(), dxGrid, &bg, logBook, currentBand);
appendText (message.trimmed (), bg, decodedText.call (), dxCall); appendText (message.trimmed (), bg, decodedText.call (), dxCall);
} }

View File

@ -45,7 +45,7 @@ protected:
private: private:
bool m_bPrincipalPrefix; bool m_bPrincipalPrefix;
QString appendDXCCWorkedB4(QString message, QString const& callsign, QColor * bg, QString appendWorkedB4(QString message, QString const& callsign, QString grid, QColor * bg,
LogBook const& logBook, QString currentBand); LogBook const& logBook, QString currentBand);
QFont char_font_; QFont char_font_;

View File

@ -124,35 +124,29 @@ void ADIF::add(QString const& call, QString const& band, QString const& mode, QS
// return true if in the log same band and mode (where JT65 == JT9 == FT8) // return true if in the log same band and mode (where JT65 == JT9 == FT8)
bool ADIF::match(QString const& call, QString const& band, QString const& mode) const bool ADIF::match(QString const& call, QString const& band, QString const& mode) const
{ {
QList<QSO> qsos = _data.values(call); QList<QSO> qsos = _data.values(call);
if (qsos.size()>0) if (qsos.size()>0) {
{ QSO q;
QSO q; foreach(q,qsos) {
foreach(q,qsos) if((band.compare(q.band,Qt::CaseInsensitive) == 0) || (band=="") || (q.band=="")) {
{ if((
if ( (band.compare(q.band,Qt::CaseInsensitive) == 0) ((mode.compare("JT65",Qt::CaseInsensitive)==0) ||
|| (band=="") (mode.compare("JT9",Qt::CaseInsensitive)==0) ||
|| (q.band=="")) (mode.compare("FT8",Qt::CaseInsensitive)==0))
{ &&
if ( ((q.mode.compare("JT65",Qt::CaseInsensitive)==0) ||
( (q.mode.compare("JT9",Qt::CaseInsensitive)==0) ||
((mode.compare("JT65",Qt::CaseInsensitive)==0) || (q.mode.compare("FT8",Qt::CaseInsensitive)==0))
(mode.compare("JT9",Qt::CaseInsensitive)==0) || )
(mode.compare("FT8",Qt::CaseInsensitive)==0)) || (mode.compare(q.mode,Qt::CaseInsensitive)==0)
&& || (mode=="")
((q.mode.compare("JT65",Qt::CaseInsensitive)==0) || || (q.mode=="")
(q.mode.compare("JT9",Qt::CaseInsensitive)==0) || )
(q.mode.compare("FT8",Qt::CaseInsensitive)==0)) return true;
) }
|| (mode.compare(q.mode,Qt::CaseInsensitive)==0)
|| (mode=="")
|| (q.mode=="")
)
return true;
}
}
} }
return false; }
return false;
} }
QList<QString> ADIF::getCallList() const QList<QString> ADIF::getCallList() const

View File

@ -43,7 +43,7 @@ void LogBook::init()
// QString call = "ok1ct"; // QString call = "ok1ct";
// QString countryName; // QString countryName;
// bool callWorkedBefore,countryWorkedBefore; // bool callWorkedBefore,countryWorkedBefore;
// match(/*in*/call, /*out*/ countryName,callWorkedBefore,countryWorkedBefore); // match(/*in*/call,grid, /*out*/ countryName,callWorkedBefore,countryWorkedBefore);
// qDebug() << countryName; // qDebug() << countryName;
} }
@ -64,12 +64,16 @@ void LogBook::_setAlreadyWorkedFromLog()
} }
} }
void LogBook::match(/*in*/const QString call, void LogBook::match(/*in*/const QString call,QString grid,
/*out*/ QString &countryName, /*out*/ QString &countryName,
bool &callWorkedBefore, bool &callWorkedBefore,
bool &countryWorkedBefore, bool &countryWorkedBefore,
bool &gridWorkedBefore,
QString currentBand) const QString currentBand) const
{ {
if(currentBand=="") qDebug() << "aa" << grid;
if(currentBand!="") qDebug() << "bb" << grid << currentBand;
if (call.length() > 0) { if (call.length() > 0) {
QString currentMode = "JT9"; // JT65 == JT9 == FT8 in ADIF::match() QString currentMode = "JT9"; // JT65 == JT9 == FT8 in ADIF::match()
// QString currentBand = ""; // match any band // QString currentBand = ""; // match any band

View File

@ -20,11 +20,9 @@ class LogBook
{ {
public: public:
void init(); void init();
void match(/*in*/ const QString call, void match(/*in*/ const QString call, QString grid,
/*out*/ QString &countryName, /*out*/ QString &countryName, bool &callWorkedBefore, bool &countryWorkedBefore,
bool &callWorkedBefore, bool &gridWorkedBefore, QString currentBand="") const;
bool &countryWorkedBefore,
QString currentBand="") const;
void addAsWorked(const QString call, const QString band, const QString mode, const QString date); void addAsWorked(const QString call, const QString band, const QString mode, const QString date);
private: private:

View File

@ -7799,9 +7799,9 @@ void MainWindow::houndCallers()
if(m_loggedByFox[houndCall].contains(m_lastBand)) continue; //already logged on this band if(m_loggedByFox[houndCall].contains(m_lastBand)) continue; //already logged on this band
if(m_foxQSO.contains(houndCall)) continue; //still in the QSO map if(m_foxQSO.contains(houndCall)) continue; //still in the QSO map
QString countryName,continent; QString countryName,continent;
bool callWorkedBefore,countryWorkedBefore; bool callWorkedBefore,countryWorkedBefore,gridWorkedBefore;
m_logBook.match(/*in*/houndCall,/*out*/countryName,callWorkedBefore,countryWorkedBefore, m_logBook.match(/*in*/houndCall,"",/*out*/countryName,callWorkedBefore,countryWorkedBefore,
/*in*/ m_currentBand); gridWorkedBefore,/*in*/ m_currentBand);
int i1=countryName.lastIndexOf(";"); int i1=countryName.lastIndexOf(";");
continent=countryName.mid(i1+2,-1); continent=countryName.mid(i1+2,-1);