2013-07-31 07:29:42 -04:00
|
|
|
#include "logbook.h"
|
2013-08-08 19:51:53 -04:00
|
|
|
#include <QDebug>
|
2013-08-08 23:17:04 -04:00
|
|
|
#include <QFontMetrics>
|
|
|
|
|
2013-07-31 07:29:42 -04:00
|
|
|
|
|
|
|
void LogBook::init()
|
|
|
|
{
|
|
|
|
const QString logFilename = "wsjtx_log.adi"; //TODO get from user
|
|
|
|
const QString countryDataFilename = "cty.dat"; //TODO get from user
|
|
|
|
|
|
|
|
_countries.init(countryDataFilename);
|
|
|
|
_countries.load();
|
|
|
|
|
|
|
|
_worked.init(_countries.getCountryNames());
|
|
|
|
|
|
|
|
_log.init(logFilename);
|
|
|
|
_log.load();
|
|
|
|
|
|
|
|
_setAlreadyWorkedFromLog();
|
|
|
|
|
2013-08-08 10:26:53 -04:00
|
|
|
/*
|
2013-07-31 07:29:42 -04:00
|
|
|
int QSOcount = _log.getCount();
|
|
|
|
int count = _worked.getWorkedCount();
|
|
|
|
qDebug() << QSOcount << "QSOs and" << count << "countries worked in file" << logFilename;
|
2013-08-08 10:26:53 -04:00
|
|
|
*/
|
2013-08-15 08:24:12 -04:00
|
|
|
|
|
|
|
// QString call = "ok1ct";
|
|
|
|
// QString countryName;
|
|
|
|
// bool callWorkedBefore,countryWorkedBefore;
|
|
|
|
// match(/*in*/call, /*out*/ countryName,callWorkedBefore,countryWorkedBefore);
|
|
|
|
// qDebug() << countryName;
|
|
|
|
|
2013-07-31 07:29:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void LogBook::match(/*in*/const QString call,
|
|
|
|
/*out*/ QString &countryName,
|
|
|
|
bool &callWorkedBefore,
|
|
|
|
bool &countryWorkedBefore)
|
|
|
|
{
|
|
|
|
if (call.length() > 0)
|
|
|
|
{
|
|
|
|
QString currentMode = "JT9"; // JT65 == JT9 in ADIF::match()
|
|
|
|
QString currentBand = ""; // match any band
|
|
|
|
callWorkedBefore = _log.match(call,currentBand,currentMode);
|
|
|
|
countryName = _countries.find(call);
|
|
|
|
if (countryName.length() > 0) // country was found
|
|
|
|
countryWorkedBefore = _worked.getHasWorked(countryName);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
countryName = "where?"; //error: prefix not found
|
|
|
|
countryWorkedBefore = false;
|
|
|
|
}
|
|
|
|
}
|
2013-08-08 19:51:53 -04:00
|
|
|
//qDebug() << "Logbook:" << call << ":" << countryName << "Cty B4:" << countryWorkedBefore << "call B4:" << callWorkedBefore;
|
2013-07-31 07:29:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void LogBook::addAsWorked(const QString call)
|
|
|
|
{
|
|
|
|
qDebug() << "adding " << call << " as worked";
|
|
|
|
_log.add(call);
|
|
|
|
QString countryName = _countries.find(call);
|
|
|
|
if (countryName.length() > 0)
|
|
|
|
_worked.setAsWorked(countryName);
|
|
|
|
}
|
2013-08-08 23:17:04 -04:00
|
|
|
|
|
|
|
|
|
|
|
|