mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-23 04:38:37 -05:00
f37ed4cd78
Pass the temporary directory to jt9 and use it to give the correct paths to temporary files. Also jt9 passes the absolute path to kvasd.dat in the temporary directory to kvasd. Clear out all the annoying cruft that has accumulated due to having to run with $CWD as the temporary directory. Use QStandardPaths to find the writable data directory where needed rather than passing it around between objects. This now works because the $CWD hasn't been changed. Do away with the CMake option WSJT_STANDARD_FILE_LOCATIONS as it is no longer needed. Fix astro status file azel.dat formatting. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@4732 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
100 lines
2.6 KiB
C++
100 lines
2.6 KiB
C++
#include "logbook.h"
|
|
#include <QDebug>
|
|
#include <QFontMetrics>
|
|
#include <QStandardPaths>
|
|
#include <QDir>
|
|
|
|
namespace
|
|
{
|
|
auto logFileName = "wsjtx_log.adi";
|
|
auto countryFileName = "cty.dat";
|
|
}
|
|
|
|
void LogBook::init()
|
|
{
|
|
QDir dataPath {QStandardPaths::writableLocation (QStandardPaths::DataLocation)};
|
|
QString countryDataFilename;
|
|
if (dataPath.exists (countryFileName))
|
|
{
|
|
// 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, /*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;
|
|
}
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
//qDebug() << "Logbook:" << call << ":" << countryName << "Cty B4:" << countryWorkedBefore << "call B4:" << callWorkedBefore;
|
|
}
|
|
|
|
void LogBook::addAsWorked(const QString call, const QString band, const QString mode, const QString date)
|
|
{
|
|
//qDebug() << "adding " << call << " as worked";
|
|
_log.add(call,band,mode,date);
|
|
QString countryName = _countries.find(call);
|
|
if (countryName.length() > 0)
|
|
_worked.setAsWorked(countryName);
|
|
}
|
|
|
|
|
|
|