Added log details to the call activity menu

This commit is contained in:
Jordan Sherer 2019-03-10 23:48:56 -04:00
parent 43401c3c26
commit 1febb18495
6 changed files with 125 additions and 37 deletions

View File

@ -101,14 +101,17 @@ void ADIF::load()
, extractField (record, "BAND")
, extractField (record, "MODE")
, extractField (record, "SUBMODE")
, extractField (record, "QSO_DATE"));
, extractField (record, "QSO_DATE")
, extractField (record, "NAME")
, extractField (record, "COMMENT")
);
}
inputFile.close ();
}
}
void ADIF::add(QString const& call, QString const& band, QString const& mode, QString const& submode, QString const& date)
void ADIF::add(QString const& call, QString const& band, QString const& mode, QString const& submode, QString const& date, QString const& name, QString const& comment)
{
QSO q;
q.call = call;
@ -116,6 +119,9 @@ void ADIF::add(QString const& call, QString const& band, QString const& mode, QS
q.mode = mode;
q.submode = submode;
q.date = date;
q.name = name;
q.comment = comment;
if (q.call.size ())
{
_data.insert(q.call,q);
@ -135,13 +141,18 @@ bool ADIF::match(QString const& call, QString const& band) const
if ( (band.compare(q.band,Qt::CaseInsensitive) == 0)
|| (band=="")
|| (q.band==""))
{
{
return true;
}
}
}
return false;
}
}
QList<ADIF::QSO> ADIF::find(QString const& call) const
{
return _data.values(call);
}
QList<QString> ADIF::getCallList() const
{
@ -154,8 +165,6 @@ QList<QString> ADIF::getCallList() const
}
return p;
}
int ADIF::getCount() const
{

View File

@ -21,10 +21,14 @@ class QDateTime;
class ADIF
{
public:
struct QSO;
void init(QString const& filename);
void load();
void add(QString const& call, QString const& band, QString const& mode, const QString &submode, QString const& date);
void add(QString const& call, QString const& band, QString const& mode, const QString &submode, QString const& date, const QString &name, const QString &comment);
bool match(QString const& call, QString const& band) const;
QList<ADIF::QSO> find(QString const& call) const;
QList<QString> getCallList() const;
int getCount() const;
@ -38,12 +42,13 @@ class ADIF
, QString const& operator_call);
private:
struct QSO
{
QString call,band,mode,submode,date;
QString call,band,mode,submode,date,name,comment;
};
private:
QMultiHash<QString, QSO> _data;
QString _filename;

View File

@ -59,25 +59,53 @@ void LogBook::match(/*in*/const QString call,
bool &callWorkedBefore,
bool &countryWorkedBefore) const
{
if (call.length() > 0)
{
QString currentBand = ""; // match any band
callWorkedBefore = _log.match(call,currentBand);
countryName = _countries.find(call);
if(call.isEmpty()){
return;
}
if (countryName.length() > 0) // country was found
QString currentBand = ""; // match any band
callWorkedBefore = _log.match(call, currentBand);
countryName = _countries.find(call);
if (countryName.length() > 0){ // country was found
countryWorkedBefore = _worked.getHasWorked(countryName);
else
{
countryName = "where?"; //error: prefix not found
countryWorkedBefore = false;
}
} else {
countryName = "where?"; //error: prefix not found
countryWorkedBefore = false;
}
}
void LogBook::addAsWorked(const QString call, const QString band, const QString mode, const QString submode, const QString date)
bool LogBook::findCallDetails(
/*in*/
const QString call,
/*out*/
QString &date,
QString &name,
QString &comment) const
{
_log.add(call,band,mode,submode,date);
qDebug() << "looking for call" << call;
if(call.isEmpty()){
return false;
}
auto qsos = _log.find(call);
qDebug() << "found" << qsos.length() << "qsos for call" << call;
if(qsos.isEmpty()){
return false;
}
foreach(auto qso, qsos){
if(date.isEmpty() && !qso.date.isEmpty()) date = qso.date;
if(name.isEmpty() && !qso.name.isEmpty()) name = qso.name;
if(comment.isEmpty() && !qso.comment.isEmpty()) comment = qso.comment;
}
return true;
}
void LogBook::addAsWorked(const QString call, const QString band, const QString mode, const QString submode, const QString date, const QString name, const QString comment)
{
_log.add(call,band,mode,submode,date,name,comment);
QString countryName = _countries.find(call);
if (countryName.length() > 0)
_worked.setAsWorked(countryName);

View File

@ -25,7 +25,14 @@ public:
/*out*/ QString &countryName,
bool &callWorkedBefore,
bool &countryWorkedBefore) const;
void addAsWorked(const QString call, const QString band, const QString mode, const QString submode, const QString date);
bool findCallDetails(
/*in*/
const QString call,
/*out*/
QString &date,
QString &name,
QString &comment) const;
void addAsWorked(const QString call, const QString band, const QString mode, const QString submode, const QString date, const QString name, const QString comment);
private:
CountryDat _countries;

View File

@ -1261,7 +1261,11 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
connect(ui->tableWidgetRXAll->horizontalHeader(), &QHeaderView::customContextMenuRequested, this, [this](QPoint const &point){
QMenu * menu = new QMenu(ui->tableWidgetRXAll);
buildBandActivitySortByMenu(menu);
QMenu * sortByMenu = menu->addMenu("Sort By...");
buildBandActivitySortByMenu(sortByMenu);
QMenu * showColumnsMenu = menu->addMenu("Show Columns...");
buildShowColumnsMenu(showColumnsMenu, "band");
menu->popup(ui->tableWidgetRXAll->horizontalHeader()->mapToGlobal(point));
});
@ -1475,7 +1479,11 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
connect(ui->tableWidgetCalls->horizontalHeader(), &QHeaderView::customContextMenuRequested, this, [this](QPoint const &point){
QMenu * menu = new QMenu(ui->tableWidgetCalls);
buildCallActivitySortByMenu(menu);
QMenu * sortByMenu = menu->addMenu("Sort By...");
buildCallActivitySortByMenu(sortByMenu);
QMenu * showColumnsMenu = menu->addMenu("Show Columns...");
buildShowColumnsMenu(showColumnsMenu, "call");
menu->popup(ui->tableWidgetCalls->horizontalHeader()->mapToGlobal(point));
});
@ -6414,7 +6422,7 @@ void MainWindow::acceptQSO (QDateTime const& QSO_date_off, QString const& call,
, QString const& my_call, QString const& my_grid, QByteArray const& ADIF)
{
QString date = QSO_date_on.toString("yyyyMMdd");
m_logBook.addAsWorked (m_hisCall, m_config.bands ()->find (m_freqNominal), mode, submode, date);
m_logBook.addAsWorked (m_hisCall, m_config.bands ()->find (m_freqNominal), mode, submode, date, name, comments);
sendNetworkMessage("LOG.QSO", QString(ADIF), {
{"UTC.ON", QVariant(QSO_date_on.toMSecsSinceEpoch())},
@ -7276,7 +7284,9 @@ void MainWindow::buildShowColumnsMenu(QMenu *menu, QString tableKey){
columnKeys.append({
{"Grid Locator", "grid"},
{"Distance", "distance"},
{"Log Details", "log"}
{"Worked Before", "log"},
{"Logged Name", "logName"},
{"Logged Comment", "logComment"},
});
}
@ -11262,7 +11272,7 @@ void MainWindow::displayCallActivity() {
displayItem->setToolTip(generateCallDetail(displayCall));
ui->tableWidgetCalls->setItem(row, col++, displayItem);
if(d.utcTimestamp.isValid()){
if(1){ //d.utcTimestamp.isValid()){
auto ageItem = new QTableWidgetItem(since(d.utcTimestamp));
ageItem->setTextAlignment(Qt::AlignCenter | Qt::AlignVCenter);
ageItem->setToolTip(d.utcTimestamp.toString());
@ -11283,16 +11293,32 @@ void MainWindow::displayCallActivity() {
auto distanceItem = new QTableWidgetItem(calculateDistance(d.grid));
distanceItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
ui->tableWidgetCalls->setItem(ui->tableWidgetCalls->rowCount() - 1, col++, distanceItem);
ui->tableWidgetCalls->setItem(row, col++, distanceItem);
QString flag;
if(m_logBook.hasWorkedBefore(d.call, "")){
// unicode checkmark
flag = "\u2713";
}
auto logDetailsItem = new QTableWidgetItem(flag);
logDetailsItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui->tableWidgetCalls->setItem(row, col++, logDetailsItem);
auto workedBeforeItem = new QTableWidgetItem(flag);
workedBeforeItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui->tableWidgetCalls->setItem(row, col++, workedBeforeItem);
QString logDetailDate;
QString logDetailName;
QString logDetailComment;
if(showColumn("call", "log") || showColumn("call", "logName") || showColumn("call", "logComment")){
m_logBook.findCallDetails(d.call, logDetailDate, logDetailName, logDetailComment);
}
auto logNameItem = new QTableWidgetItem(logDetailName);
logNameItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui->tableWidgetCalls->setItem(row, col++, logNameItem);
auto logCommentItem = new QTableWidgetItem(logDetailComment);
logCommentItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui->tableWidgetCalls->setItem(row, col++, logCommentItem);
} else {
ui->tableWidgetCalls->setItem(row, col++, new QTableWidgetItem("")); // age
@ -11301,7 +11327,9 @@ void MainWindow::displayCallActivity() {
ui->tableWidgetCalls->setItem(row, col++, new QTableWidgetItem("")); // tdrift
ui->tableWidgetCalls->setItem(row, col++, new QTableWidgetItem("")); // grid
ui->tableWidgetCalls->setItem(row, col++, new QTableWidgetItem("")); // distance
ui->tableWidgetCalls->setItem(row, col++, new QTableWidgetItem("")); // log details
ui->tableWidgetCalls->setItem(row, col++, new QTableWidgetItem("")); // worked before
ui->tableWidgetCalls->setItem(row, col++, new QTableWidgetItem("")); // log name
ui->tableWidgetCalls->setItem(row, col++, new QTableWidgetItem("")); // log comment
}
if (isCallSelected) {
@ -11351,6 +11379,8 @@ void MainWindow::displayCallActivity() {
ui->tableWidgetCalls->setColumnHidden(6, !showColumn("call", "grid", false));
ui->tableWidgetCalls->setColumnHidden(7, !showColumn("call", "distance", false));
ui->tableWidgetCalls->setColumnHidden(8, !showColumn("call", "log"));
ui->tableWidgetCalls->setColumnHidden(9, !showColumn("call", "logName"));
ui->tableWidgetCalls->setColumnHidden(10, !showColumn("call", "logComment"));
// Resize the table columns
ui->tableWidgetCalls->resizeColumnToContents(0);
@ -11361,6 +11391,8 @@ void MainWindow::displayCallActivity() {
ui->tableWidgetCalls->resizeColumnToContents(5);
ui->tableWidgetCalls->resizeColumnToContents(6);
ui->tableWidgetCalls->resizeColumnToContents(7);
ui->tableWidgetCalls->resizeColumnToContents(8);
ui->tableWidgetCalls->resizeColumnToContents(9);
// Reset the scroll position
ui->tableWidgetCalls->verticalScrollBar()->setValue(currentScrollPos);

View File

@ -1274,13 +1274,20 @@ QTextEdit[transmitting=&quot;true&quot;] {
</column>
<column>
<property name="text">
<string>Log Details</string>
<string></string>
</property>
<property name="toolTip">
<string/>
<string>Worked Before</string>
</property>
<property name="textAlignment">
<set>AlignCenter</set>
</column>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Comment</string>
</property>
</column>
</widget>