diff --git a/logbook/adif.cpp b/logbook/adif.cpp index f780675..0258bd1 100644 --- a/logbook/adif.cpp +++ b/logbook/adif.cpp @@ -333,7 +333,7 @@ QByteArray ADIF::QSOToADIF(QString const& hisCall, QString const& hisGrid, QStri , 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& m_myCall - , QString const& m_myGrid, QString const& operator_call) + , QString const& m_myGrid, QString const& operator_call, QMap const &additionalFields) { QString t; t = "" + hisCall; @@ -363,6 +363,12 @@ QByteArray ADIF::QSOToADIF(QString const& hisCall, QString const& hisGrid, QStri if (operator_call!="") t+=" " + operator_call; + + foreach(auto key, additionalFields.keys()){ + auto value = additionalFields[key]; + t += QString(" <%1:%2>%3").arg(key).arg(value.length()).arg(value); + } + return t.toLatin1 (); } diff --git a/logbook/adif.h b/logbook/adif.h index 18eafe4..1698cd2 100644 --- a/logbook/adif.h +++ b/logbook/adif.h @@ -42,7 +42,7 @@ class ADIF , QString const& rptRcvd, QDateTime const& dateTimeOn, QDateTime const& dateTimeOff , QString const& band, QString const& comments, QString const& name , QString const& strDialFreq, QString const& m_myCall, QString const& m_myGrid - , QString const& operator_call); + , QString const& operator_call, const QMap &additionalFields); struct QSO diff --git a/logqso.cpp b/logqso.cpp index 9dd09ff..4d13edf 100644 --- a/logqso.cpp +++ b/logqso.cpp @@ -114,9 +114,18 @@ void LogQSO::loadSettings () m_comments = m_settings->value ("LogComments", "").toString(); resetAdditionalFields(); - auto additionalFields = QSet::fromList(m_settings->value("AdditionalFields", {}).toStringList()); + auto additionalFields = m_settings->value("AdditionalFields", {}).toStringList(); + QSet additionalFieldsSet; foreach(auto key, additionalFields){ + if(key.isEmpty()){ + continue; + } + if(additionalFieldsSet.contains(key)){ + continue; + } + createAdditionalField(key); + additionalFieldsSet.insert(key); } m_settings->endGroup (); @@ -131,7 +140,11 @@ void LogQSO::storeSettings () const auto additionalFields = QStringList{}; foreach(auto field, m_additionalFieldsControls){ - additionalFields.append(field->property("fieldKey").toString()); + auto key = field->property("fieldKey").toString(); + if(key.isEmpty()){ + continue; + } + additionalFields.append(key); } m_settings->setValue ("AdditionalFields", additionalFields); @@ -194,6 +207,15 @@ void LogQSO::accept() QString hisCall,hisGrid,mode,submode,rptSent,rptRcvd,dateOn,dateOff,timeOn,timeOff,band,operator_call; QString comments,name; + QMap additionalFields; + foreach(auto field, m_additionalFieldsControls){ + auto key = field->property("fieldKey").toString(); + if(key.isEmpty()){ + continue; + } + additionalFields[key] = field->text(); + } + hisCall=ui->call->text().toUpper(); hisGrid=ui->grid->text().toUpper(); mode = ui->mode->text().toUpper(); @@ -218,7 +240,8 @@ void LogQSO::accept() adifile.init(adifilePath); QByteArray ADIF {adifile.QSOToADIF (hisCall, hisGrid, mode, submode, rptSent, rptRcvd, m_dateTimeOn, m_dateTimeOff, band - , comments, name, strDialFreq, m_myCall, m_myGrid, operator_call)}; + , comments, name, strDialFreq, m_myCall, m_myGrid, operator_call, additionalFields)}; + if (!adifile.addQSOToFile (ADIF)) { MessageBox::warning_message (this, tr ("Log file error"),