mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2026-06-04 06:54:47 -04:00
Priorities for decoded message highlighting and new worked before internal database
Settings option to highlight not worked before entities/grids/calls by mode. Fix issues with highlighting decodes and generally refactor the internal workings of ADIF and QSO recording for worked before detection.
This commit is contained in:
+57
-88
@@ -1,105 +1,74 @@
|
||||
#include "logbook.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QFontMetrics>
|
||||
#include <QStandardPaths>
|
||||
#include <QDir>
|
||||
#include "countrydat.h"
|
||||
#include "Configuration.hpp"
|
||||
|
||||
namespace
|
||||
LogBook::LogBook (Configuration const * configuration)
|
||||
: config_ {configuration}
|
||||
{
|
||||
auto logFileName = "wsjtx_log.adi";
|
||||
auto countryFileName = "cty.dat";
|
||||
}
|
||||
|
||||
void LogBook::init()
|
||||
void LogBook::match (QString const& call, QString const& mode, QString const& grid,
|
||||
QString &countryName,
|
||||
bool &callWorkedBefore,
|
||||
bool &countryWorkedBefore,
|
||||
bool &gridWorkedBefore,
|
||||
QString const& band) const
|
||||
{
|
||||
QDir dataPath {QStandardPaths::writableLocation (QStandardPaths::DataLocation)};
|
||||
QString countryDataFilename;
|
||||
if (dataPath.exists (countryFileName))
|
||||
if (call.length() > 0)
|
||||
{
|
||||
// User override
|
||||
countryDataFilename = dataPath.absoluteFilePath (countryFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
countryDataFilename = QString {":/"} + countryFileName;
|
||||
}
|
||||
|
||||
_countries.init(countryDataFilename);
|
||||
_countries.load();
|
||||
|
||||
_worked.init(_countries.getCountryNames());
|
||||
|
||||
_log.init(dataPath.absoluteFilePath (logFileName));
|
||||
_log.load();
|
||||
|
||||
_setAlreadyWorkedFromLog();
|
||||
|
||||
/*
|
||||
int QSOcount = _log.getCount();
|
||||
int count = _worked.getWorkedCount();
|
||||
qDebug() << QSOcount << "QSOs and" << count << "countries worked in file" << logFilename;
|
||||
*/
|
||||
|
||||
// QString call = "ok1ct";
|
||||
// QString countryName;
|
||||
// bool callWorkedBefore,countryWorkedBefore;
|
||||
// match(/*in*/call,grid, /*out*/ countryName,callWorkedBefore,countryWorkedBefore);
|
||||
// qDebug() << countryName;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void LogBook::_setAlreadyWorkedFromLog()
|
||||
{
|
||||
QList<QString> calls = _log.getCallList();
|
||||
QString c;
|
||||
foreach(c,calls)
|
||||
{
|
||||
QString countryName = _countries.find(c);
|
||||
if (countryName.length() > 0)
|
||||
{
|
||||
_worked.setAsWorked(countryName);
|
||||
//qDebug() << countryName << " worked " << c;
|
||||
}
|
||||
auto const& mode_to_check = (config_ && !config_->highlight_by_mode ()) ? QString {} : mode;
|
||||
callWorkedBefore = worked_before_.call_worked (call, mode_to_check, band);
|
||||
gridWorkedBefore = worked_before_.grid_worked(grid, mode_to_check, band);
|
||||
countryName = worked_before_.countries ().find (call);
|
||||
countryWorkedBefore = worked_before_.country_worked (countryName, mode_to_check, band);
|
||||
}
|
||||
}
|
||||
|
||||
void LogBook::match(/*in*/const QString call,QString grid,
|
||||
/*out*/ QString &countryName,
|
||||
bool &callWorkedBefore,
|
||||
bool &countryWorkedBefore,
|
||||
bool &gridWorkedBefore,
|
||||
QString currentBand) const
|
||||
bool LogBook::add (QString const& call
|
||||
, QString const& grid
|
||||
, QString const& band
|
||||
, QString const& mode
|
||||
, QByteArray const& ADIF_record)
|
||||
{
|
||||
// if(currentBand=="") qDebug() << "aa" << grid;
|
||||
// if(currentBand!="") qDebug() << "bb" << grid << currentBand;
|
||||
return worked_before_.add (call, grid, band, mode, ADIF_record);
|
||||
}
|
||||
|
||||
if (call.length() > 0) {
|
||||
QString currentMode = "JT9"; // JT65 == JT9 == FT8 in ADIF::match()
|
||||
// QString currentBand = ""; // match any band
|
||||
callWorkedBefore = _log.match(call,currentBand,currentMode);
|
||||
gridWorkedBefore = _log.match(grid,currentBand,currentMode);
|
||||
countryName = _countries.find(call);
|
||||
|
||||
if (countryName.length() > 0) { // country was found
|
||||
countryWorkedBefore = _worked.getHasWorked(countryName);
|
||||
QByteArray LogBook::QSOToADIF (QString const& hisCall, QString const& hisGrid, QString const& mode,
|
||||
QString const& rptSent, QString const& rptRcvd, QDateTime const& dateTimeOn,
|
||||
QDateTime const& dateTimeOff, QString const& band, QString const& comments,
|
||||
QString const& name, QString const& strDialFreq, QString const& myCall,
|
||||
QString const& myGrid, QString const& txPower, QString const& operator_call,
|
||||
QString const& xSent, QString const& xRcvd)
|
||||
{
|
||||
QString t;
|
||||
t = "<call:" + QString::number(hisCall.length()) + ">" + hisCall;
|
||||
t += " <gridsquare:" + QString::number(hisGrid.length()) + ">" + hisGrid;
|
||||
t += " <mode:" + QString::number(mode.length()) + ">" + mode;
|
||||
t += " <rst_sent:" + QString::number(rptSent.length()) + ">" + rptSent;
|
||||
t += " <rst_rcvd:" + QString::number(rptRcvd.length()) + ">" + rptRcvd;
|
||||
t += " <qso_date:8>" + dateTimeOn.date().toString("yyyyMMdd");
|
||||
t += " <time_on:6>" + dateTimeOn.time().toString("hhmmss");
|
||||
t += " <qso_date_off:8>" + dateTimeOff.date().toString("yyyyMMdd");
|
||||
t += " <time_off:6>" + dateTimeOff.time().toString("hhmmss");
|
||||
t += " <band:" + QString::number(band.length()) + ">" + band;
|
||||
t += " <freq:" + QString::number(strDialFreq.length()) + ">" + strDialFreq;
|
||||
t += " <station_callsign:" + QString::number(myCall.length()) + ">" + myCall;
|
||||
t += " <my_gridsquare:" + QString::number(myGrid.length()) + ">" + myGrid;
|
||||
if(txPower!="") t += " <tx_pwr:" + QString::number(txPower.length()) + ">" + txPower;
|
||||
if(comments!="") t += " <comment:" + QString::number(comments.length()) + ">" + comments;
|
||||
if(name!="") t += " <name:" + QString::number(name.length()) + ">" + name;
|
||||
if(operator_call!="") t+=" <operator:" + QString::number(operator_call.length()) + ">" + operator_call;
|
||||
if(xRcvd!="") {
|
||||
QString t1="";
|
||||
if(xRcvd.split(" ").size()==2) t1=xRcvd.split(" ").at(1);
|
||||
if(t1.toInt()>0) {
|
||||
t += " <SRX:" + QString::number(t1.length()) + ">" + t1;
|
||||
} else {
|
||||
countryName = "where?"; //error: prefix not found
|
||||
countryWorkedBefore = false;
|
||||
t += " <STATE:" + QString::number(t1.length()) + ">" + t1;
|
||||
}
|
||||
// qDebug() << "Logbook:" << call << currentBand << callWorkedBefore << countryName << countryWorkedBefore;
|
||||
}
|
||||
return t.toLatin1();
|
||||
}
|
||||
|
||||
void LogBook::addAsWorked(const QString call, const QString grid, const QString band,
|
||||
const QString mode, const QString date)
|
||||
{
|
||||
//qDebug() << "adding " << call << " as worked";
|
||||
_log.add(call,grid,band,mode,date);
|
||||
QString countryName = _countries.find(call);
|
||||
if (countryName.length() > 0)
|
||||
_worked.setAsWorked(countryName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user