diff --git a/src/awards.cpp b/src/awards.cpp index aa942ed3..8872b8df 100644 --- a/src/awards.cpp +++ b/src/awards.cpp @@ -99,7 +99,6 @@ QString Awards::getQSOofAward (const int _enti, const int _bandid, const int _lo stringQuery = QString("SELECT call, qso_date from log where dxcc='%1' AND bandid='%2' AND lognumber='%3'").arg(_enti).arg(_bandid).arg(_log); } - sqlOK = query.exec(stringQuery); //qDebug() << "Awards::getQSOofAward: stringQuery: " << stringQuery; if (sqlOK) @@ -1151,7 +1150,6 @@ void Awards::setColors (const QString &_newOne, const QString &_needed, const QS #else defaultColor.setNamedColor(_default.toUpper()); //To be replaced by .fromString in Qt6.6 #endif - } if (neededColor.isValid()) @@ -1161,7 +1159,6 @@ void Awards::setColors (const QString &_newOne, const QString &_needed, const QS #else neededColor.setNamedColor(_needed.toUpper()); //To be replaced by .fromString in Qt6.6 #endif - } if (confirmedColor.isValid()) @@ -1172,7 +1169,6 @@ void Awards::setColors (const QString &_newOne, const QString &_needed, const QS confirmedColor.setNamedColor(_confirmed.toUpper()); //To be replaced by .fromString in Qt6.6 #endif } - if (newOneColor.isValid()) { #if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0) @@ -1181,7 +1177,6 @@ void Awards::setColors (const QString &_newOne, const QString &_needed, const QS newOneColor.setNamedColor(_newOne.toUpper()); //To be replaced by .fromString in Qt6.6 #endif } - if (workedColor.isValid()) { #if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0) @@ -1189,8 +1184,6 @@ void Awards::setColors (const QString &_newOne, const QString &_needed, const QS #else workedColor.setNamedColor(_worked.toUpper()); #endif - - } } @@ -1649,7 +1642,6 @@ int Awards::dxccStatusBand(const int _ent, const int _band, const int _logNumber query.finish(); return -1; } - //qDebug() << "Awards::dxccStatusBand: return - 0.3"; return status; // if arrives to here decision => not worked } @@ -1819,7 +1811,6 @@ bool Awards::updateDXCCBandsStatus(const int _logNumber) if (sqlOK) { //qDebug() << Q_FUNC_INFO << " - exec query: " << query.lastQuery (); - dxccStatusList.clear(); while(query.next()) { diff --git a/src/dataproxy_sqlite.cpp b/src/dataproxy_sqlite.cpp index 8e27ed0b..50c8b6a2 100644 --- a/src/dataproxy_sqlite.cpp +++ b/src/dataproxy_sqlite.cpp @@ -5771,10 +5771,10 @@ bool DataProxy_SQLite::setDXCCAwardStatus(const int _qsoId) // If the band/mode/log is already worked and status confirmed: Update and Return true // If not worked: Add and Return true - //qDebug() << "DataProxy_SQLite::setDXCCAwardStatus: " << QString::number(_qsoId); + //qDebug() << Q_FUNC_ << QString::number(_qsoId); if (_qsoId <= 0) { - //qDebug() << "DataProxy_SQLite::setDXCCAwardStatus: QSOid <=0 " << QString::number(_qsoId); + //qDebug() << Q_FUNC_INFO << ": QSOid <=0 " << QString::number(_qsoId); return false; } QList values; @@ -5790,7 +5790,7 @@ bool DataProxy_SQLite::setDXCCAwardStatus(const int _qsoId) //int _dxcc = getDXCCFromId(_qsoId); if (_dxcc <= 0) { - //qDebug() << "DataProxy_SQLite::setDXCCAwardStatus: DXCC <= 0: DXCC: " << QString::number(_dxcc) << " - " << QString::number(_qsoId); + //qDebug() << Q_FUNC_INFO << ": DXCC <= 0: DXCC: " << QString::number(_dxcc) << " - " << QString::number(_qsoId); return false; } @@ -5798,21 +5798,21 @@ bool DataProxy_SQLite::setDXCCAwardStatus(const int _qsoId) //int _band = getBandFromId(_qsoId); if (_band <= 0) { - //qDebug() << "DataProxy_SQLite::setDXCCAwardStatus: Band <= 0: BAND: " << QString::number(_band) << " - " << QString::number(_qsoId); + //qDebug() << Q_FUNC_INFO << ": Band <= 0: BAND: " << QString::number(_band) << " - " << QString::number(_qsoId); return false; } int _mode = values.at(1); //int _mode = getModeFromId(_qsoId); if (_mode <= 0) { - //qDebug() << "DataProxy_SQLite::setDXCCAwardStatus: Mode <= 0: Mode: " << QString::number(_mode) << " - " << QString::number(_qsoId); + //qDebug() << Q_FUNC_INFO << ": Mode <= 0: Mode: " << QString::number(_mode) << " - " << QString::number(_qsoId); return false; } int _log = values.at(4); //int _log = getLogNumberFromQSOId(_qsoId); if (_log <= 0) { - //qDebug() << "DataProxy_SQLite::setDXCCAwardStatus: Log <= 0: Log: " << QString::number(_log) << " - " << QString::number(_qsoId); + //qDebug() << Q_FUNC_INFO << ": Log <= 0: Log: " << QString::number(_log) << " - " << QString::number(_qsoId); return false; } @@ -5825,10 +5825,17 @@ bool DataProxy_SQLite::setDXCCAwardStatus(const int _qsoId) // If the band/mode/log is already worked and status confirmed: Update and Return true // If not worked: Add and Return true - QString queryString = QString("SELECT id, confirmed, qsoid FROM awarddxcc WHERE band='%1' AND mode='%2' AND dxcc='%3'").arg(_band).arg(_mode).arg(_dxcc); + QString queryString = QString("SELECT id, confirmed, qsoid FROM awarddxcc WHERE band=:band AND mode=:mode AND dxcc=:dxcc"); + if (!query.prepare(queryString)) + { + return false; + } + query.bindValue(":band", _band); + query.bindValue(":mode", _mode); + query.bindValue(":dxcc", _dxcc); bool sqlOK = query.exec(queryString); - //qDebug() << "DataProxy_SQLite::setDXCCAwardStatus: Queryexec-1: " << queryString; + //qDebug() << Q_FUNC_INFO << ": Queryexec-1: " << queryString; queryString.clear(); if (sqlOK) @@ -5860,7 +5867,12 @@ bool DataProxy_SQLite::setDXCCAwardStatus(const int _qsoId) { // #3 - If the band/mode/log is already worked and status confirmed: Update and Return true nameCol = rec.indexOf("qsoid"); //int __qsoid = (query.value(nameCol)).toInt(); - queryString = QString("UPDATE awarddxcc SET confirmed = '1', qsoid = '%1' WHERE id = '%2'").arg(_qsoId).arg(__id); + queryString = QString("UPDATE awarddxcc SET confirmed = '1', qsoid = :qsoid WHERE id = :_id"); + query.finish(); + if (!query.prepare(queryString)) + return false; + query.bindValue("qsoid", _qsoId); + query.bindValue("_id", __id); } } else @@ -5868,9 +5880,6 @@ bool DataProxy_SQLite::setDXCCAwardStatus(const int _qsoId) query.finish(); return true; } - - query.finish(); - // #1 - If the band/mode/log is already confirmed: Return true // #2 - If the band/mode/log is already worked and status worked: Return true // #3 - If the band/mode/log is already worked and status confirmed: Update and Return true @@ -5881,14 +5890,20 @@ bool DataProxy_SQLite::setDXCCAwardStatus(const int _qsoId) //#4 - If not worked: Add and Return true query.finish(); // awarddxcc id dxcc band mode confirmed qsoid lognumber - queryString = QString("INSERT INTO awarddxcc (dxcc, band, mode, confirmed, qsoid, lognumber) values('%1','%2','%3','0', '%4', '%5')").arg(_dxcc).arg(_band).arg(_mode).arg(_qsoId).arg(_log); + //queryString = QString("INSERT INTO awarddxcc (dxcc, band, mode, confirmed, qsoid, lognumber) values('%1','%2','%3','0', '%4', '%5')").arg(_dxcc).arg(_band).arg(_mode).arg(_qsoId).arg(_log); + queryString = QString("INSERT INTO awarddxcc (dxcc, band, mode, confirmed, qsoid, lognumber) " + "values(:dxcc, :band, :mode,'0', :qsoid, :logNumber)"); + if (!query.prepare(queryString)) + return false; + query.bindValue(":dxcc", _dxcc); + query.bindValue(":band", _band); + query.bindValue(":mode", _mode); + query.bindValue(":qsoid", _qsoId); + query.bindValue(":logNumber", _log); } - - if (queryString.length()>5) - { if (query.exec(queryString)) { - //qDebug() << "DataProxy_SQLite::setDXCCAwardStatus: Queryexec-2: " << queryString; + //qDebug() << Q_FUNC_INFO << ": Queryexec-2: " << queryString; query.finish(); return true; } @@ -5901,7 +5916,6 @@ bool DataProxy_SQLite::setDXCCAwardStatus(const int _qsoId) return false; } } - } } else { @@ -5921,7 +5935,7 @@ bool DataProxy_SQLite::setWAZAwardStatus(const int _qsoId) // If the band/mode/log is already worked and status confirmed: Update and Return true // If not worked: Add and Return true - //qDebug() << "DataProxy_SQLite::setDXCCAwardStatus: " << QString::number(_qsoId); + //qDebug() << Q_FUNC_INFO << ": << QString::number(_qsoId); if (_qsoId <= 0) { return false; @@ -8336,19 +8350,24 @@ QString DataProxy_SQLite::getADIFQSO(const int _qsoId, ExportMode _em) return getADIFFromQSOQuery(rec, _em, false, false, -1); } +QString DataProxy_SQLite::getADIFValueFromRec(QSqlRecord _rec, const QString &_fieldName) +{// To refactor the getADIFFromQSOQuery function + int nameCol = _rec.indexOf(_fieldName); + if (nameCol>=0) + { + QSqlField field = _rec.field(nameCol); + return (field.value()).toString(); + } + return QString(); +} + QString DataProxy_SQLite::getADIFFromQSOQuery(QSqlRecord rec, ExportMode _em, bool _justMarked, bool _onlyRequested, const int _logN ) { //qDebug() << Q_FUNC_INFO << ": " << query.lastQuery(); - qDebug() << Q_FUNC_INFO << ": START"; + //qDebug() << Q_FUNC_INFO << ": START"; int nameCol; QString aux; - //bool propsat = false; // Reset the QSO in case it is a Satellite QSO - - //for(int i=0;igetDateTimeFromSQLiteString(aux); + qso.setDateTimeOn(tDateTime); - nameCol = rec.indexOf("call"); + aux = getADIFValueFromRec(rec, "bandid"); + qso.setBand(getNameFromBandId(aux.toInt())); - if (nameCol>=0) - { - field = rec.field(nameCol); - aux = (field.value()).toString(); - //aux = (query.value(nameCol)).toString(); - qso.setCall(aux); - } + aux = getADIFValueFromRec(rec, "freq"); + qso.setFreq(aux.toDouble()); - nameCol = rec.indexOf("qso_date"); - QDateTime tDateTime; - if (nameCol>=0) - { - field = rec.field(nameCol); - aux = (field.value()).toString(); - //aux = (query.value(nameCol)).toString(); - tDateTime = util->getDateTimeFromSQLiteString(aux); - qso.setDateTimeOn(tDateTime); - } + aux = getADIFValueFromRec(rec, "band_rx"); + aux = getNameFromBandId(aux.toInt()); + qso.setBandRX(aux); - nameCol = rec.indexOf("bandid"); - QString bandst = QString(); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); + aux = getADIFValueFromRec(rec, "freq_rx"); + qso.setFreqRX((aux.toDouble())); - //qDebug() << Q_FUNC_INFO << ": -Band-1: " << aux; - aux = util->checkAndFixASCIIinADIF(aux); - //qDebug() << Q_FUNC_INFO << ": -Band-2: " << aux; - qso.setBand(getNameFromBandId(aux.toInt())); - } + aux = getADIFValueFromRec(rec, "modeid"); + QString aux2 = getSubModeFromId(aux.toInt()); + aux = getNameFromSubMode(aux2); + qso.setMode(aux); + qso.setSubmode(aux2); - nameCol = rec.indexOf("freq"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); - //qDebug() << Q_FUNC_INFO << ": FREQ_TX-1: " << aux; - aux = util->checkAndFixASCIIinADIF(aux); - //qDebug() << Q_FUNC_INFO << ": FREQ_TX-2: " << aux; - qso.setFreq(aux.toDouble()); - } - // Now the BAND RX - nameCol = rec.indexOf("band_rx"); - QString bandrxst = QString(); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); - aux = util->checkAndFixASCIIinADIF(aux); - aux = getNameFromBandId(aux.toInt()); - qso.setBandRX(aux); - } + qso.setPropMode(getADIFValueFromRec(rec, "prop_mode")); + qso.setSatName(getADIFValueFromRec(rec, "sat_name")); - nameCol = rec.indexOf("freq_rx"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); - aux = util->checkAndFixASCIIinADIF(aux); - qso.setFreqRX(aux.toDouble()); - } + qso.setGridSquare(getADIFValueFromRec(rec, "gridsquare")); + qso.setMyGridSquare(getADIFValueFromRec(rec, "my_gridsquare")); - nameCol = rec.indexOf("modeid"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); - aux = util->checkAndFixASCIIinADIF(aux); - // get SubModeId to check if it is the same or not from modeid - QString aux2 = getSubModeFromId(aux.toInt()); - aux = getNameFromSubMode(aux2); - qso.setMode(aux); - qso.setSubmode(aux2); - } + if (_em != ModeEQSL) + qso.setStationCallsign(getADIFValueFromRec(rec, "station_callsign")); - nameCol = rec.indexOf("prop_mode"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setPropMode(aux); - //qDebug() << Q_FUNC_INFO << ": PROP_MODE" ; - } + aux = getADIFValueFromRec(rec, "qso_date_off"); + tDateTime = util->getDateTimeFromSQLiteString(aux); + qso.setDateOff(tDateTime.date()); + qso.setTimeOff(tDateTime.time()); - nameCol = rec.indexOf("sat_name"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setSatName(aux); - //qDebug() << Q_FUNC_INFO << ": SAT_NAME" ; - } + qso.setSrx((getADIFValueFromRec(rec, "srx")).toInt()); + qso.setSrxString(getADIFValueFromRec(rec, "srx_string")); - nameCol = rec.indexOf("gridsquare"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setGridSquare(aux); - } + qso.setStx((getADIFValueFromRec(rec, "stx")).toInt()); + qso.setStxString(getADIFValueFromRec(rec, "stx_string")); - nameCol = rec.indexOf("my_gridsquare"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setMyGridSquare(aux); - } + qso.setCQZone((getADIFValueFromRec(rec, "cqz")).toInt()); + qso.setItuZone((getADIFValueFromRec(rec, "ituz")).toInt()); + qso.setDXCC((getADIFValueFromRec(rec, "dxcc")).toInt()); + //qDebug() << Q_FUNC_INFO << ": - 100"; - nameCol = rec.indexOf("station_callsign"); - if ((nameCol>=0) && (_em != ModeEQSL)) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); - qso.setStationCallsign(aux); - } + qso.setAddress(getADIFValueFromRec(rec, "address")); + qso.setAge((getADIFValueFromRec(rec, "age")).toDouble()); - nameCol = rec.indexOf("qso_date_off"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); - aux = util->checkAndFixASCIIinADIF(aux); - tDateTime = util->getDateTimeFromSQLiteString(aux); - qso.setDateOff(tDateTime.date()); - qso.setTimeOff(tDateTime.time()); - } + qso.setCounty(getADIFValueFromRec(rec, "cnty")); + qso.setComment(getADIFValueFromRec(rec, "comment")); - nameCol = rec.indexOf("srx"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); - aux = util->checkAndFixASCIIinADIF(aux); - qso.setSrx(aux.toInt ()); - } + qso.setA_Index((getADIFValueFromRec(rec, "a_index")).toInt()); - nameCol = rec.indexOf("srx_string"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setSrxString(aux); - } + qso.setAnt_az((getADIFValueFromRec(rec, "ant_az")).toDouble()); + qso.setAnt_el((getADIFValueFromRec(rec, "ant_al")).toDouble()); + qso.setAnt_Path(getADIFValueFromRec(rec, "ant_path")); - nameCol = rec.indexOf("stx"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setStx(aux.toInt ()); - } + qso.setARRL_Sect(getADIFValueFromRec(rec, "arrl_sect")); + qso.setCheck(getADIFValueFromRec(rec, "checkcontest")); + qso.setClass(getADIFValueFromRec(rec, "class")); - nameCol = rec.indexOf("stx_string"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setStxString(aux); - } + //qDebug() << Q_FUNC_INFO << ": - 30"; + qso.setContinent(getADIFValueFromRec(rec, "cont")); + qso.setContactedOperator(getADIFValueFromRec(rec, "contacted_op")); + qso.setContestID(getADIFValueFromRec(rec, "contest_id")); - //qDebug() << Q_FUNC_INFO << ": - 100"; - nameCol = rec.indexOf("cqz"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setCQZone(aux.toInt()); - } + qso.setCountry(getADIFValueFromRec(rec, "country")); - nameCol = rec.indexOf("ituz"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setItuZone(aux.toInt()); + qso.setCreditSubmitted(getADIFValueFromRec(rec, "credit_submitted")); + qso.setCreditGranted(getADIFValueFromRec(rec, "credit_granted")); - } - //qDebug() << Q_FUNC_INFO << ": DXCC - Now..." ; - nameCol = rec.indexOf("dxcc"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setDXCC(aux.toInt()); - } + qso.setDistance(getADIFValueFromRec(rec, "distance").toDouble()); + qso.setDarcDok(getADIFValueFromRec(rec, "darc_dok")); - nameCol = rec.indexOf("address"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setAddress(aux); - } - nameCol = rec.indexOf("age"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setAge(aux.toInt()); - } + qso.setEQ_Call(getADIFValueFromRec(rec, "eq_call")); + qso.setEmail(getADIFValueFromRec(rec, "email")); - nameCol = rec.indexOf("cnty"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setCounty(aux); - } + aux = getADIFValueFromRec(rec, "eqsl_qslrdate"); + qso.setEQSLQSLRDate(util->getDateFromSQliteString(aux)); - nameCol = rec.indexOf("comment"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setComment(aux); - } + aux = getADIFValueFromRec(rec, "eqsl_qslsdate"); + qso.setEQSLQSLSDate(util->getDateFromSQliteString(aux)); - nameCol = rec.indexOf("a_index"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setA_Index(aux.toInt()); - } - nameCol = rec.indexOf("ant_az"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setAnt_az(aux.toDouble()); - } + qso.setEQSLQSL_RCVD(getADIFValueFromRec(rec, "eqsl_qsl_rcvd")); + qso.setEQSLQSL_SENT(getADIFValueFromRec(rec, "eqsl_qsl_sent")); - nameCol = rec.indexOf("ant_el"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setAnt_el(aux.toDouble()); - } + qso.setFists(getADIFValueFromRec(rec, "fists").toInt()); + qso.setFistsCC(getADIFValueFromRec(rec, "fists_cc").toInt()); + qso.setForceInit(util->QStringToBool(getADIFValueFromRec(rec, "force_init"))); - nameCol = rec.indexOf("ant_path"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setAnt_Path(aux); - } + aux = getADIFValueFromRec(rec, "hrdlog_qso_upload_date"); + qso.setHRDUpdateDate(util->getDateFromSQliteString(aux)); + qso.setHRDLogStatus(getADIFValueFromRec(rec, "hrdlog_qso_upload_status")); - nameCol = rec.indexOf("arrl_sect"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setARRL_Sect(aux); - } + qso.setMyAntenna(getADIFValueFromRec(rec, "my_antenna")); - nameCol = rec.indexOf("checkcontest"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setCheck(aux); - } + //qDebug() << Q_FUNC_INFO << ": my_antenna-99"; + qso.setMyDXCC(getADIFValueFromRec(rec, "my_dxcc").toInt()); - //qDebug() << Q_FUNC_INFO << ": - 30"; - nameCol = rec.indexOf("class"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setClass(aux); - } - nameCol = rec.indexOf("cont"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setContinent(aux); - } + qso.setMyFists(getADIFValueFromRec(rec, "my_fists").toInt()); + qso.setIOTA(getADIFValueFromRec(rec, "iota")); + qso.setIotaID(getADIFValueFromRec(rec, "iota_island_id").toInt()); - nameCol = rec.indexOf("contacted_op"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setContactedOperator(aux); - } + qso.setMyIOTA(getADIFValueFromRec(rec, "my_iota")); + qso.setMyIotaID(getADIFValueFromRec(rec, "my_iota_island_id").toInt()); + qso.setK_Index(getADIFValueFromRec(rec, "k_index").toInt()); + qso.setMyITUZone(getADIFValueFromRec(rec, "my_itu_zone").toInt()); - nameCol = rec.indexOf("contest_id"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setContestID(aux); - } + qso.setLatitude(getADIFValueFromRec(rec, "lat")); + qso.setLongitude(getADIFValueFromRec(rec, "lon")); - nameCol = rec.indexOf("country"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setCountry(aux); - } + qso.setMyLatitude(getADIFValueFromRec(rec, "my_lat")); + qso.setMyLongitude(getADIFValueFromRec(rec, "my_lon")); - nameCol = rec.indexOf("credit_submitted"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setCreditSubmitted(aux); - } + aux = getADIFValueFromRec(rec, "lotw_qslrdate"); + qso.setLoTWQSLRDate(util->getDateFromSQliteString(aux)); - nameCol = rec.indexOf("credit_granted"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setCreditGranted(aux); - } + aux = getADIFValueFromRec(rec, "lotw_qslsdate"); + qso.setLoTWQSLSDate(util->getDateFromSQliteString(aux)); - nameCol = rec.indexOf("distance"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setDistance(aux.toDouble ()); - } + qso.setLoTWQSL_RCVD(getADIFValueFromRec(rec, "lotw_qsl_rcvd")); + qso.setLoTWQSL_SENT(getADIFValueFromRec(rec, "lotw_qsl_sent")); - nameCol = rec.indexOf("darc_dok"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setDarcDok(aux); - } + aux = getADIFValueFromRec(rec, "clublog_qso_upload_date"); + qso.setClublogQSOUpdateDate(util->getDateFromSQliteString(aux)); - nameCol = rec.indexOf("eq_call"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setEQ_Call(aux); - } + qso.setClubLogStatus(getADIFValueFromRec(rec, "clublog_qso_upload_status")); - nameCol = rec.indexOf("email"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setEmail(aux); - } + aux = getADIFValueFromRec(rec, "qrzcom_qso_upload_date"); + qso.setQRZCOMDate(util->getDateFromSQliteString(aux)); - nameCol = rec.indexOf("eqsl_qslrdate"); - QDate date; - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); - date = util->getDateFromSQliteString(aux); - qso.setEQSLQSLRDate(date); - } + qso.setQRZCOMStatus(getADIFValueFromRec(rec, "qrzcom_qso_upload_status")); - nameCol = rec.indexOf("eqsl_qslsdate"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); - date = util->getDateFromSQliteString(aux); - qso.setEQSLQSLSDate(date); - } + qso.setMaxBursts(getADIFValueFromRec(rec, "max_bursts").toInt()); + qso.setMsShower(getADIFValueFromRec(rec, "ms_shower")); - nameCol = rec.indexOf("eqsl_qsl_rcvd"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setEQSLQSL_RCVD(aux); - } + qso.setMyCity(getADIFValueFromRec(rec, "my_city")); + qso.setMyCounty(getADIFValueFromRec(rec, "my_cnty")); + qso.setMyCountry(getADIFValueFromRec(rec, "my_country")); + qso.setMyCQZone(getADIFValueFromRec(rec, "my_cq_zone").toInt()); + qso.setMyName(getADIFValueFromRec(rec, "my_name")); - nameCol = rec.indexOf("eqsl_qsl_sent"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setEQSLQSL_SENT(aux); - } + qso.setName(getADIFValueFromRec(rec, "name")); + qso.setOperatorCallsign(getADIFValueFromRec(rec, "operator")); - nameCol = rec.indexOf("fists"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setFists(aux.toInt()); - } + qso.setOwnerCallsign(getADIFValueFromRec(rec, "owner_callsign")); + qso.setMyPostalCode(getADIFValueFromRec(rec, "my_postal_code")); + qso.setMyRig(getADIFValueFromRec(rec, "my_rig")); + qso.setMySig(getADIFValueFromRec(rec, "my_sig")); - nameCol = rec.indexOf("fists_cc"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setFistsCC(aux.toInt()); - } - nameCol = rec.indexOf("force_init"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setForceInit(util->QStringToBool(aux)); - } + qso.setMySOTA_REF(getADIFValueFromRec(rec, "my_sota_ref")); + qso.setMyState(getADIFValueFromRec(rec, "my_state")); + qso.setMyStreet(getADIFValueFromRec(rec, "my_street")); - nameCol = rec.indexOf("hrdlog_qso_upload_date"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); - date = util->getDateFromSQliteString(aux); - qso.setHRDUpdateDate(date); - } + qso.setNotes(getADIFValueFromRec(rec, "notes")); + qso.setNrBursts(getADIFValueFromRec(rec, "nr_bursts").toInt()); + qso.setNrPings(getADIFValueFromRec(rec, "nr_pings").toInt()); + qso.setPrefix(getADIFValueFromRec(rec, "pfx")); - nameCol = rec.indexOf("hrdlog_qso_upload_status"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - //TODO: Add a isValidUploadStatus - qso.setHRDLogStatus(aux); - } + qso.setPrecedence(getADIFValueFromRec(rec, "precedence")); + qso.setPublicKey(getADIFValueFromRec(rec, "public_key")); + qso.setQSLMsg(getADIFValueFromRec(rec, "qslmsg")); - nameCol = rec.indexOf("my_antenna"); - //qDebug() << Q_FUNC_INFO << ": my_antenna-0"; - if (nameCol>=0) - { - //qDebug() << Q_FUNC_INFO << ": my_antenna-1"; - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setMyAntenna(aux); - } - //qDebug() << Q_FUNC_INFO << ": my_antenna-99"; - nameCol = rec.indexOf("my_dxcc"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setMyDXCC(aux.toInt()); - } + aux = getADIFValueFromRec(rec, "qslrdate"); + qso.setQSLRDate(util->getDateFromSQliteString(aux)); - nameCol = rec.indexOf("my_fists"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setMyFists(aux.toInt()); - } + aux = getADIFValueFromRec(rec, "qslsdate"); + qso.setQSLSDate(util->getDateFromSQliteString(aux)); + qso.setQSL_RCVD(getADIFValueFromRec(rec, "qsl_rcvd")); + qso.setQSLRecVia(getADIFValueFromRec(rec, "qsl_rcvd_via")); - nameCol = rec.indexOf("iota"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setIOTA(aux); - } + qso.setQSL_SENT(getADIFValueFromRec(rec, "qsl_sent")); + qso.setQSLSenVia(getADIFValueFromRec(rec, "qsl_sent_via")); + qso.setQSLVia(getADIFValueFromRec(rec, "qsl_via")); - nameCol = rec.indexOf("iota_island_id"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setIotaID(aux.toInt()); - } - - nameCol = rec.indexOf("my_iota"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setMyIOTA(aux); - } - nameCol = rec.indexOf("my_iota_island_id"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setMyIotaID(aux.toInt()); - } - - nameCol = rec.indexOf("k_index"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setK_Index(aux.toInt()); - } - - nameCol = rec.indexOf("my_itu_zone"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setMyITUZone(aux.toInt()); - } + qso.setQSOComplete(util->getADIFQSO_CompleteFromDB(getADIFValueFromRec(rec, "qso_complete"))); + qso.setQSORandom(util->QStringToBool(getADIFValueFromRec(rec, "qso_random"))); - nameCol = rec.indexOf("lat"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setLatitude(aux); - } + qso.setQTH(getADIFValueFromRec(rec, "qth")); + qso.setRSTTX(getADIFValueFromRec(rec, "rst_sent")); - nameCol = rec.indexOf("lon"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setLongitude(aux); - } - - nameCol = rec.indexOf("my_lat"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setMyLatitude(aux); - } - - nameCol = rec.indexOf("my_lon"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setMyLongitude(aux); - } + qso.setRSTRX(getADIFValueFromRec(rec, "rst_rcvd")); + qso.setRegion(getADIFValueFromRec(rec, "region")); + qso.setRig(getADIFValueFromRec(rec, "rig")); - nameCol = rec.indexOf("lotw_qslrdate"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); - date = util->getDateFromSQliteString(aux); - qso.setLoTWQSLRDate(date); - } + qso.setRXPwr(getADIFValueFromRec(rec, "rx_pwr").toDouble()); + qso.setTXPwr(getADIFValueFromRec(rec, "tx_pwr").toDouble()); - nameCol = rec.indexOf("lotw_qslsdate"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); - date = util->getDateFromSQliteString(aux); - qso.setLoTWQSLSDate(date); - } + qso.setSatMode(getADIFValueFromRec(rec, "sat_mode")); - nameCol = rec.indexOf("lotw_qsl_rcvd"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setLoTWQSL_RCVD(aux); - } + qso.setSFI(getADIFValueFromRec(rec, "sfi").toInt()); + qso.setSig(getADIFValueFromRec(rec, "sig")); - nameCol = rec.indexOf("lotw_qsl_sent"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setLoTWQSL_SENT(aux); - } + qso.setSigInfo(getADIFValueFromRec(rec, "sig_info")); + qso.setSilentKey(util->QStringToBool(getADIFValueFromRec(rec, "silent_key"))); - nameCol = rec.indexOf("clublog_qso_upload_date"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); - date = util->getDateFromSQliteString(aux); - qso.setClublogQSOUpdateDate(date); - } + qso.setSkcc(getADIFValueFromRec(rec, "skcc")); + qso.setSOTA_REF(getADIFValueFromRec(rec, "sota_ref")); - nameCol = rec.indexOf("clublog_qso_upload_status"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setClubLogStatus(aux); - } + qso.setState(getADIFValueFromRec(rec, "state")); + qso.setSwl(util->QStringToBool(getADIFValueFromRec(rec, "swl"))); + qso.setTenTen(getADIFValueFromRec(rec, "ten_ten").toInt()); + qso.setUksmg(getADIFValueFromRec(rec, "uksmg").toInt()); - nameCol = rec.indexOf("qrzcom_qso_upload_date"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); - date = util->getDateFromSQliteString(aux); - qso.setQRZCOMDate(date); - } - nameCol = rec.indexOf("qrzcom_qso_upload_status"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setQRZCOMStatus(aux); - } - nameCol = rec.indexOf("max_bursts"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setMaxBursts(aux.toInt()); - } - nameCol = rec.indexOf("ms_shower"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setMsShower(aux); - } - nameCol = rec.indexOf("my_city"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setMyCity(aux); - } + qso.setVeProv(getADIFValueFromRec(rec, "ve_prov")); + qso.setMyUsacaCounties(getADIFValueFromRec(rec, "my_usaca_counties")); + qso.setUsacaCounties(getADIFValueFromRec(rec, "usaca_counties")); - nameCol = rec.indexOf("my_cnty"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setMyCounty(aux); - } - nameCol = rec.indexOf("my_country"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setMyCountry(aux); - } - nameCol = rec.indexOf("my_cq_zone"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setMyCQZone(aux.toInt()); - } - nameCol = rec.indexOf("my_name"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setMyName(aux); - } - nameCol = rec.indexOf("name"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setName(aux); - } - nameCol = rec.indexOf("operator"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setOperatorCallsign(aux); - } - nameCol = rec.indexOf("owner_callsign"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setOwnerCallsign(aux); - } - nameCol = rec.indexOf("my_postal_code"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setMyPostalCode(aux); - } - nameCol = rec.indexOf("my_rig"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setMyRig(aux); - } - nameCol = rec.indexOf("my_sig"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setMySig(aux); - } - nameCol = rec.indexOf("my_sota_ref"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setMySOTA_REF(aux); - } + qso.setVUCCGrids(getADIFValueFromRec(rec, "vucc_grids")); + qso.setMyVUCCGrids(getADIFValueFromRec(rec, "my_vucc_grids")); - nameCol = rec.indexOf("my_state"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setMyState(aux); - } - nameCol = rec.indexOf("my_street"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setMyStreet(aux); - } - nameCol = rec.indexOf("notes"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setNotes(aux); - } - nameCol = rec.indexOf("nr_bursts"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setNrBursts(aux.toInt()); - } - nameCol = rec.indexOf("nr_pings"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setNrPings(aux.toInt()); - } - nameCol = rec.indexOf("pfx"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setPrefix(aux); - } - - nameCol = rec.indexOf("precedence"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setPrecedence(aux); - } - nameCol = rec.indexOf("public_key"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setPublicKey(aux); - } - nameCol = rec.indexOf("qslmsg"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setQSLMsg(aux); - } - nameCol = rec.indexOf("qslrdate"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); - date = util->getDateFromSQliteString(aux); - qso.setQSLRDate(date); - } - nameCol = rec.indexOf("qslsdate"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); - date = util->getDateFromSQliteString(aux); - qso.setQSLSDate(date); - } - nameCol = rec.indexOf("qsl_rcvd"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setQSL_RCVD(aux); - } - - nameCol = rec.indexOf("qsl_rcvd_via"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setQSLRecVia(aux); - } - - nameCol = rec.indexOf("qsl_sent"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setQSL_SENT(aux); - } - nameCol = rec.indexOf("qsl_sent_via"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setQSLSenVia(aux); - } - nameCol = rec.indexOf("qsl_via"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setQSLVia(aux); - } - nameCol = rec.indexOf("qso_complete"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setQSOComplete(util->getADIFQSO_CompleteFromDB(aux)); - } - nameCol = rec.indexOf("qso_random"); - if (nameCol>=0) - { //TODO: Check wether it makes sense to use this field for ALL QSOs or just when it is not random. - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setQSORandom(util->QStringToBool(aux)); - } - nameCol = rec.indexOf("qth"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setQTH(aux); - } - nameCol = rec.indexOf("rst_sent"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setRSTTX(aux); - } - nameCol = rec.indexOf("rst_rcvd"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setRSTRX(aux); - } - nameCol = rec.indexOf("region"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setRegion(aux); - } - nameCol = rec.indexOf("rig"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setRig(aux); - } - nameCol = rec.indexOf("rx_pwr"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setRXPwr(aux.toDouble()); - } - nameCol = rec.indexOf("tx_pwr"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setTXPwr(aux.toDouble()); - } - nameCol = rec.indexOf("sat_mode"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setSatMode(aux); - } - nameCol = rec.indexOf("sfi"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setSFI(aux.toInt()); - } - nameCol = rec.indexOf("sig"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setSig(aux); - } - nameCol = rec.indexOf("sig_info"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setSigInfo(aux); - } - nameCol = rec.indexOf("silent_key"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setSilentKey(util->QStringToBool(aux)); - } - nameCol = rec.indexOf("skcc"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setSkcc(aux); - } - nameCol = rec.indexOf("sota_ref"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setSOTA_REF(aux); - } - nameCol = rec.indexOf("state"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setState(aux); - } - nameCol = rec.indexOf("swl"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setSwl(util->QStringToBool(aux)); - } - nameCol = rec.indexOf("ten_ten"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setTenTen(aux.toInt()); - } - - nameCol = rec.indexOf("uksmg"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setUksmg(aux.toInt()); - } - nameCol = rec.indexOf("ve_prov"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setVeProv(aux); - } - nameCol = rec.indexOf("my_usaca_counties"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setMyUsacaCounties(aux); - } - nameCol = rec.indexOf("usaca_counties"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setUsacaCounties(aux); - } - nameCol = rec.indexOf("vucc_grids"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setVUCCGrids(aux); - } - nameCol = rec.indexOf("my_vucc_grids"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setMyVUCCGrids(aux); - } - nameCol = rec.indexOf("web"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setWeb(aux); - } + qso.setWeb(getADIFValueFromRec(rec, "web")); if (_logN == -1) - { - nameCol = rec.indexOf("lognumber"); - if (nameCol>=0) - { - field = rec.field(nameCol); -aux = (field.value()).toString(); aux = util->checkAndFixASCIIinADIF(aux); - qso.setLogId(aux.toInt()); - } - } + qso.setLogId(getADIFValueFromRec(rec, "lognumber").toInt()); return qso.getADIF(); } diff --git a/src/dataproxy_sqlite.h b/src/dataproxy_sqlite.h index e1f594bc..8ed1d9e3 100644 --- a/src/dataproxy_sqlite.h +++ b/src/dataproxy_sqlite.h @@ -319,6 +319,7 @@ class DataProxy_SQLite : public QObject //void getFoundInLog(const QString &_txt, const int _log=-1); QString getADIFQSO(const int _qsoId, ExportMode _em = ModeADIF); + QString getADIFValueFromRec(QSqlRecord _rec, const QString &_fieldName); // To refactor the getADIFFromQSOQuery function QString getADIFFromQSOQuery(QSqlRecord _rec, ExportMode _em = ModeADIF, bool _justMarked = false, bool _onlyRequested = false, int _logN = -1); //QString getADIFFromQSOQuery2(QSqlRecord _rec, ExportMode _em = ModeADIF, bool _justMarked = false, bool _onlyRequested = false, int _logN = -1); diff --git a/src/filemanager.cpp b/src/filemanager.cpp index 12362ed4..385583e8 100644 --- a/src/filemanager.cpp +++ b/src/filemanager.cpp @@ -1142,491 +1142,6 @@ QList FileManager::adifLoTWReadLog2(const QString& fileName, const int logN return _qsos; } -QList FileManager::adifLoTWReadLog(const QString& tfileName, const int logN) -{ - //qDebug() << Q_FUNC_INFO << tfileName; - QString fileName = tfileName; - QList readed; - //QElapsedTimer time1 = QTime::currentTime(); - - readed.clear(); - if (!dataProxy->doesThisLogExist(logN)) - { - //qDebug() << Q_FUNC_INFO << " - ERROR: The log does not exist: " << QString::number(logN); - return readed; - } - QFile file( fileName ); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) /* Flawfinder: ignore */ - { - //qDebug() << Q_FUNC_INFO << " - File not found" << fileName; - QMessageBox msgBox; - msgBox.setIcon(QMessageBox::Warning); - msgBox.setWindowTitle(tr("KLog - File not opened")); - QString aux = QString(tr("It was not possible to open the file %1 for reading.") ).arg(fileName); - msgBox.setText(tr("KLog was not able to read the LoTW file")); - msgBox.setInformativeText(aux); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.exec(); - return readed; - } - - //qso->clear(); - - QStringList fields, qsToPass; - QStringList modifiedQSOList; // This is to emit it so after reading the full file, it is possible to show a qtable showing the QSOs that have been modified. - modifiedQSOList.clear(); - bool hasEOH = false; - int numberOfQsos = 0; - int i = 0; - //int numberOfQsosLoWTHeader = 0; - QString line = QString(); - QString auxString = QString(); - QString aux = QString(); - qint64 pos; //Position in the file - bool inHeader = true; - pos = file.pos(); - fields.clear(); - qsToPass.clear(); - QDateTime _dateTime; - bool alwaysAdd = false; - bool alwaysIgnore = false; - QString stationCallsign = QString(); - - //int step = 1; - - while ( !file.atEnd() ) - { - line = (file.readLine()).toUpper(); - numberOfQsos = numberOfQsos + line.count("EOR>"); - if ((line.count("")>0) && (!hasEOH)) - { - hasEOH = true; - } - } - - int step = util->getProgresStepForDialog(numberOfQsos); - - //847 - - //qDebug() << Q_FUNC_INFO << " - QSOs found: " << QString::number(numberOfQsos); - //qDebug() << Q_FUNC_INFO << " - STEP: " << QString::number(step); - - QProgressDialog progress(tr("Reading LoTW file..."), tr("Abort reading"), 0, numberOfQsos, this); - progress.setWindowModality(Qt::ApplicationModal); - progress.setVisible(true); - progress.setValue(0); - progress.setMaximum(numberOfQsos); - - //step = util->getProgresStepForDialog(numberOfQsos); - - file.seek(pos); - - /* - Optional header information may be included before the actual data in the file. - To include optional header info, the first character of the file must be something other than <. - Any amount of header info of any value except may be included. The header info must be - terminated with . Any number of characters of any value except < may follow . - The first < after is the start of the first field of the first data record in the file. - */ - - //qDebug() << Q_FUNC_INFO << " - Going to read the HEADER"; - //Read HEADER - line = file.readLine().trimmed().toUpper(); - //qDebug() << Q_FUNC_INFO << line; - - if ( (!(line.startsWith('<'))) && (inHeader) ) - { // The file has a header - if (line.contains("")) // To check if the first line contains the EOR but not alone in the line. - { - inHeader = false; - } - - line.clear(); // We should finish the if with real data in "line" or a clear one. - while ( inHeader && hasEOH) - { - line = file.readLine().trimmed().toUpper(); - if (line.contains("OWNCALL:")) - { - stationCallsign = line.section(": ", 1, 1); - if (!util->isValidCall(stationCallsign)) - { - stationCallsign = QString(); - } - } - if (line.contains("")) - { - inHeader = false; - line.clear(); //TODO: Maybe this clearing deletes a line that may have data... - } - } - pos = file.pos(); - } - else if (!(line.startsWith('<'))) - { // The file does not have any header. - // Reading the first QSO... - /* - Cases: - 1.- One big line with several QSO - 2.- One QSO uses several lines. - THIS IS USUALLY THE CASE FOR LOTW - 3.- Last line of one QSO includes data of the next one - */ - inHeader = true; - while (inHeader) - { - pos = file.pos(); - line = file.readLine().trimmed().toUpper(); - if ( (line.startsWith('<')) ) - { - inHeader = false; - line.clear(); //TODO: Maybe this clearing deletes a line that may have data... - } - } - } - - file.seek(pos); - //START reading QSO data... - //qDebug() << Q_FUNC_INFO << " - QSO data reading started..." ; - QDate _tdate; - noMoreQso = false; - //time1.start(); - while (!noMoreQso ) - { - if (!file.atEnd()) - { - line.clear(); - line.append(file.readLine().trimmed().toUpper()); - if (line.contains("")) - { - noMoreQso = true; - } - //line.append(file.readLine().toUpper()); // TODO: Check if we should remove extra spaces,tabs and so on... - //qDebug() << Q_FUNC_INFO << " -line:" << line; - fields << line.split("<", QT_SKIP); - - - qsToPass.clear(); - auxString.clear(); - foreach (aux, fields) - { - aux = aux.trimmed(); - if ( (aux.contains('>')) && (auxString.length() > 0) ) - { - qsToPass.last() = qsToPass.last() + auxString; - //qDebug() << Q_FUNC_INFO << " - Modified in qsToPass: " << qsToPass.last(); - //qsToPass << aux.trimmed(); - //qDebug() << Q_FUNC_INFO << " - Added to qsToPass: " << aux.trimmed(); - auxString.clear(); - } - else if (( aux.contains('>')) && (auxString.length() <= 0) ) - { - qsToPass << aux.trimmed(); - } - else - { - auxString = auxString + "-" + aux.trimmed(); - //qDebug() << Q_FUNC_INFO << " - auxString: " << auxString; - } - //qDebug() << Q_FUNC_INFO << " - fields: " << aux; - } - - if (auxString.length()>0) - { - //qDebug() << Q_FUNC_INFO << " - auxString2: " << auxString; - qsToPass.last() = qsToPass.last() + auxString.trimmed(); - } - //qDebug() << Q_FUNC_INFO << " - END fields"; - //qDebug() << Q_FUNC_INFO << " - Mod: " << qsToPass.join("/"); - //qDebug() << Q_FUNC_INFO << " - END2 fields"; - - fields = qsToPass; - - if (fields.contains("EOR>")) // We are going to add a QSO to the log... prepare the Query! - { - //qDebug() << Q_FUNC_INFO << " - START of QSO adding"<< QT_ENDL; - //dataProxy->isThisQSODuplicated() - - //int getDuplicatedQSOId(const QString &_qrz, const QString &_date, const QString &_time, const int _band, const int _mode); - QString str, _call, _date, _time, _band, _mode; - double _freq = 0.0; - bool haveBand = false; - QDate _qslrdate = QDate::currentDate(); - QString _satName = QString(); - - bool qsl_rcvd = false; - QString field, data; - QStringList clearAdif; - bool validQSO = false; - int modifiedQSO = -1; - foreach (str, fields) - { - //field = readAdifField("<"+str).at(0); - clearAdif.clear(); - clearAdif << readAdifField("<"+str); - //qDebug() << Q_FUNC_INFO << " - clearAdif length: " << QString::number(clearAdif.length()); - if (clearAdif.length()==2) - { - validQSO = true; - field = clearAdif.at(0); - data = clearAdif.at(1); - - //qDebug() << Q_FUNC_INFO << " - field: " << field; - //qDebug() << Q_FUNC_INFO << " - data: " << data; - if (field == "CALL") - { - if (util->isValidCall(data)) - { - _call = data; - } - else - { - _call = util->getAValidCall(data); - } - } - else if (field == "QSO_DATE") - { - //qDebug() << Q_FUNC_INFO << " - field: " << field; - //qDebug() << Q_FUNC_INFO << " - data: " << data; - - _tdate = util->getDateFromADIFDateString(data); - if (_tdate.isValid()) - { - _dateTime.setDate(_tdate); - } - } - else if (field == "TIME_ON") - { - //qDebug() << Q_FUNC_INFO << " - field: " << field; - //qDebug() << Q_FUNC_INFO << " - data: " << data; - _time = data; - - if (util->getTimeFromADIFTimeString(data).isValid()) - { - _dateTime.setTime(util->getTimeFromADIFTimeString(data)); - } - } - else if (field == "BAND") - { - _band = data; - haveBand = true; - } - else if (field == "MODE") - { - _mode = data; - } - else if (field == "FREQ") // In MHz with 5 decimal places - { - if (haveBand) - { - int bandi = dataProxy->getIdFromBandName(_band); - if (dataProxy->getBandIdFromFreq(data.toDouble()) == bandi) - { - _freq = data.toDouble(); - } - else - { - _freq = dataProxy->getLowLimitBandFromBandId(bandi); - // IF band is defined but not the same than freq, Band wins - } - } - else - { - _freq = data.toDouble(); - - int bandi = dataProxy->getBandIdFromFreq(data.toDouble()); - if (bandi>=0) - { - _band = dataProxy->getBandNameFromFreq(_freq); - haveBand = true; - } - } - } - else if (field == "APP_LOTW_RXQSO") - { - //_qslsdate = data; - } - else if (field == "QSL_RCVD") - { - if (data == "Y") - { - qsl_rcvd = true; - } - } - else if (field == "QSLRDATE") - { - if ((util->getDateFromADIFDateString(data)).isValid()) - { - _qslrdate = util->getDateFromADIFDateString(data); - } - } - else if (field == "SAT_NAME") - { - if (dataProxy->getSatelliteName(data).length()>0) - { - _satName = data; - } - } - else - { - //Unknown ADIF received. - } - } - else - { - //qDebug() << Q_FUNC_INFO << " - NOT VALID ADIF RECEIVED: " << "<" + str; - } - } - //qDebug() << Q_FUNC_INFO << " - If QSO is valid, we will call the addQSOToList" << "<" + str; - //qDebug() << Q_FUNC_INFO << " - New Add String query: "; - //dataProxy->addQSO(&qso); - if (validQSO) - { - modifiedQSO = -2; // - if (qsl_rcvd) - { - modifiedQSO = dataProxy->lotwUpdateQSLReception (_call, _dateTime, _band, _mode, _qslrdate); - } - //qDebug() << Q_FUNC_INFO << " - QSO Modified: " << QString::number(modifiedQSO); - if (modifiedQSO>0) - { - //qDebug() << Q_FUNC_INFO << " - QSO Modified: " << _call; - readed.append(modifiedQSO); - modifiedQSOList << _call << util->getDateTimeSQLiteStringFromDateTime(_dateTime) << _band << _mode;// << util->getDateSQLiteStringFromDate(_qslrdate); - emit addQSOToList(modifiedQSOList); - modifiedQSOList.clear(); - } - else if ((modifiedQSO == -1 ) && (!qsl_rcvd)) - { - bool ignoreQSO = false; - //qDebug() << Q_FUNC_INFO << " - QSO NOT found but confirmed by LoTW - Is it an error or should I add it to the log? " << _call; - if (alwaysAdd) - { - //qDebug() << Q_FUNC_INFO << " - ADD THE QSO AUTOMATICALLY!!!" ; - modifiedQSO = dataProxy->addQSOFromLoTW(_call, _dateTime, _mode, _band, _freq, _qslrdate, stationCallsign, logN); - if (modifiedQSO>0) - { - readed.append(modifiedQSO); - //qDebug() << Q_FUNC_INFO << " - QSO ADDED readed: " << QString::number(readed.length()); - modifiedQSOList << _call << util->getDateTimeSQLiteStringFromDateTime(_dateTime) << _band << _mode;// << util->getDateSQLiteStringFromDate(_qslrdate); - emit addQSOToList(modifiedQSOList); - modifiedQSOList.clear(); - //qDebug() << Q_FUNC_INFO << " - QSO ADDED: " << QString::number(modifiedQSO); - } - else - { - //qDebug() << Q_FUNC_INFO << " - QSO NOT ADDED: " << QString::number(modifiedQSO); - } - } - else if (alwaysIgnore) - { - //qDebug() << Q_FUNC_INFO << " - IGNORE THE QSO AUTOMATICALLY!!!" ; - } - else - { - //if (askUserToAddThisQSOToLog(_call, _dateTime, _mode, _band, _freq, _qslrdate)) - if (askUserToAddThisQSOToLog(_call, _dateTime, _mode, _band, _freq)) - { - //qDebug() << Q_FUNC_INFO << " - ADD THE QSO !!!" ; - modifiedQSO = dataProxy->addQSOFromLoTW(_call, _dateTime, _mode, _band, _freq, _qslrdate, stationCallsign, logN); - if (modifiedQSO>0) - { - readed.append(modifiedQSO); - //qDebug() << Q_FUNC_INFO << " - QSO ADDED-2 readed: " << QString::number(readed.length()); - modifiedQSOList << _call << util->getDateTimeSQLiteStringFromDateTime(_dateTime) << _band << _mode;// << util->getDateSQLiteStringFromDate(_qslrdate); - emit addQSOToList(modifiedQSOList); - modifiedQSOList.clear(); - //qDebug() << Q_FUNC_INFO << " - QSO ADDED-2: " << QString::number(modifiedQSO); - } - else - { - //qDebug() << Q_FUNC_INFO << " - QSO NOT ADDED-2: " << QString::number(modifiedQSO); - } - } - else - { - //qDebug() << Q_FUNC_INFO << " - IGNORE THE QSO !!!" ; - } - if (askUserToUseAlwaysSameAnswer()) - { - if (!ignoreQSO) - { - alwaysAdd = true; - } - else - { - alwaysIgnore = true; - } - } - else - { - alwaysAdd = false; - alwaysIgnore = false; - } - } - } - else - { - //qDebug() << Q_FUNC_INFO << " - QSO NOT Modified: Error: " << QString::number(modifiedQSO) << " - " << _call; - } - } - _call.clear(); - _date.clear(); - _time.clear(); - _band.clear(); - _mode.clear(); - _qslrdate = QDate::currentDate(); - - //qDebug() << Q_FUNC_INFO << " - END of QSO "<< QT_ENDL; - fields.clear(); - i++; - } // END of if (fields.contains("EOR>")) // We are going to add a QSO to the log... ! - else - { - if (file.atEnd()) - { - noMoreQso = true; - } - //qDebug() << Q_FUNC_INFO << " - fields DOES NOT contains EOR>"; - } - if (( (i % step ) == 0) ) - { // To update the speed I will only show the progress once each X QSOs - //qDebug() << Q_FUNC_INFO << " - MOD 0 - i = " << QString::number(i) ; - aux = tr("Importing LoTW ADIF file...") + "\n" + tr(" QSO: ") + QString::number(i) + "/" + QString::number(numberOfQsos); - progress.setLabelText(aux); - progress.setValue(i); - } - if (i>=numberOfQsos) - { - noMoreQso = true; - } - if ( progress.wasCanceled() ) - { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("KLog - User cancelled")); - aux = QString(tr("You have canceled the file import. The file will be removed and no data will be imported.") + "\n" + tr("Do you still want to cancel?")); - msgBox.setText(aux); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::No); - int ret = msgBox.exec(); - switch (ret) { - case QMessageBox::Yes: - // Yes was clicked - noMoreQso = true; - break; - case QMessageBox::No: - // No Save was clicked - break; - default: - // should never be reached - break; - } - } - } - } - progress.setValue(numberOfQsos); - //qDebug() << Q_FUNC_INFO << " - - END: " << QString::number(readed.length()); - return readed; -} - bool FileManager::adifReadLog2(const QString& tfileName, const int logN) { //qDebug() << Q_FUNC_INFO << " - Start: " << tfileName << "/" << QString::number(logN); @@ -1731,538 +1246,44 @@ bool FileManager::adifReadLog2(const QString& tfileName, const int logN) // should never be reached break; } - } - //qDebug() << Q_FUNC_INFO << QString(": Field process finished: ").arg(fieldToAnalyze) ; - } - //qDebug() << Q_FUNC_INFO << QString(": List of fields is empty!") ; - } - //qDebug() << Q_FUNC_INFO << QString(": End of File or no more QSOs") ; - file.close (); - progress.setValue(qsos); // Closes the progressDialog - - //qDebug() << Q_FUNC_INFO << " - END"; - return true; -} - -qint64 FileManager::passHeader(QFile & _f) -{ - //qDebug() << Q_FUNC_INFO << " - Start: " << _f.fileName (); - QFile &file = _f; - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) /* Flawfinder: ignore */ - { - //qDebug() << Q_FUNC_INFO << " File not found" ; - return false; - } - //bool hasEOH = false; - qint64 pos = file.pos(); - QString line; - while ( !file.atEnd() ) - { - line = file.readLine ().toUpper (); - //qDebug() << Q_FUNC_INFO << " - " << line; - if (line.count ("")>0) - { - break; - } - } - pos = file.pos(); - file.close (); - //qDebug() << Q_FUNC_INFO << " - END (" << QString::number(pos) << ")"; - return pos; -} - -bool FileManager::adifReadLog(const QString& tfileName, const int logN) -{ - //qDebug() << Q_FUNC_INFO << " " << tfileName; - //QElapsedTimer time1; - - //int n = 0; - //QSqlDatabase db = QSqlDatabase::database(); - //int maxLogs = dataProxy->getNumberOfManagedLogs(); // To manage several logs - usePreviousStationCallsignAnswerAlways = false; // This is to ensure that the StationCallsign is used in the process Line function - bool sqlOK = true; - QStringList queries = QStringList(); - queries.clear(); - QSqlQuery query; - - QStringList fields, qsToPass, qsAux; - QStringList currentQSOfields = QStringList(); - fields.clear(); - qsToPass.clear(); - qsAux.clear(); - - QString fieldToAnalyze = QString(); - QString fileName = tfileName; - QString line = QString(); - QString aux = QString(); - QString auxString = QString(); - QString _band = QString(); - - bool inHeader = true; - bool EOR = false; - noMoreQso = false; - bool isDupeQSO = false; - bool askedToAddDupeQSOs = false; - bool addDupeQSOs = false; - qint64 pos; //Position in the file - int i = 0; //Aunxiliar variable - int numberOfQsos = 0; - int step = 1; - //int errorCode = -1; - //int qsosInTransaction = 0; - bool ignoreErrorCode19 = false; - - QFile file( fileName ); - - //bool moreThanOneLog = adifCheckMoreThanOneLog(file); - int howManyLogs = howManyLogsInFile(file); - fillHashLog(file); - //I am creating several logs when importing a file - //We need to fill the hashLog to process then in processLog - - //bool keepLogsInFile = false; - - //qDebug() << Q_FUNC_INFO << " Logs: " << QString::number(howManyLogs); - - if (howManyLogs>1) - { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("KLog - Log selection")); - aux = QString(tr("There is more than one log in this logfile.") + "\n" + tr("All logs will be imported into the current log.") + "\n" + tr("Do you want to continue?")); - msgBox.setText(aux); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::No); - int ret = msgBox.exec(); - switch (ret) { - case QMessageBox::Yes: - // Yes was clicked - //qDebug() << Q_FUNC_INFO << " clicked YES"; - //keepLogsInFile = true; - break; - case QMessageBox::No: - // No Save was clicked - //qDebug() << Q_FUNC_INFO << " clicked NO"; - //keepLogsInFile = false; - return false; - default: - // should never be reached - //keepLogsInFile = false; - return false; - //qDebug() << Q_FUNC_INFO << " default"; - } - } - - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) /* Flawfinder: ignore */ - { - //qDebug() << Q_FUNC_INFO << " File not found" << fileName; - return false; - } - - bool hasEOH = false; - pos = file.pos(); - - while ( !file.atEnd() ) - { - line = (file.readLine()).toUpper(); - numberOfQsos = numberOfQsos + line.count("EOR>"); - if ((line.count("")>0) && (!hasEOH)) - { - hasEOH = true; - } - } - //qDebug() << Q_FUNC_INFO << " QSOs found: " << QString::number(numberOfQsos); - - QProgressDialog progress(tr("Reading ADIF file..."), tr("Abort reading"), 0, numberOfQsos, this); - /*progress.setWindowModality(Qt::WindowModal);*/ - progress.setWindowModality(Qt::ApplicationModal); - progress.setVisible(true); - progress.setValue(0); - progress.setMaximum(numberOfQsos); - - step = util->getProgresStepForDialog(numberOfQsos); - - //step = getProgresStepForDialog(numberOfQsos); - //qDebug() << Q_FUNC_INFO << " (STEP)/Number: " << QString::number(step) << "/" << QString::number(numberOfQsos); - //qDebug() << Q_FUNC_INFO << " (number & step: " << QString::number(numberOfQsos % step); - - file.seek(pos); - - /* - Optional header information may be included before the actual data in the file. - To include optional header info, the first character of the file must be something other than <. - Any amount of header info of any value except may be included. The header info must be - terminated with . Any number of characters of any value except < may follow . - The first < after is the start of the first field of the first data record in the file. - */ - - //qDebug() << Q_FUNC_INFO << " Going to read the HEADER"; - //Read HEADER - line = file.readLine().trimmed().toUpper(); - //qDebug() << Q_FUNC_INFO << " " << line; - - if ( (!(line.startsWith('<'))) && (inHeader) ) - { // The file has a header - if (line.contains("")) // To check if the first line contains the EOR but not alone in the line. - { - inHeader = false; - } - - line.clear(); // We should finish the if with real data in "line" or a clear one. - while ( inHeader && hasEOH) - { - line = file.readLine().trimmed().toUpper(); - if (line.contains("")) - { - inHeader = false; - line.clear(); //TODO: Maybe this clearing deletes a line that may have data... - } - } - pos = file.pos(); - } - else if (!(line.startsWith('<'))) - { // The file does not have any header. - // Reading the first QSO... - /* - Cases: - 1.- One big line with several QSO - 2.- One QSO uses several lines. - 3.- Last line of one QSO includes data of the next one - */ - inHeader = true; - while (inHeader) - { - pos = file.pos(); - line = file.readLine().trimmed().toUpper(); - if ( (line.startsWith('<')) ) - { - inHeader = false; - line.clear(); //TODO: Maybe this clearing deletes a line that may have data... - } - } - } - - file.seek(pos); - - // START reading QSO data... - //qDebug() << Q_FUNC_INFO << " QSO data reading started..." ; - - preparedQuery.prepare( "INSERT INTO log (call, qso_date, bandid, modeid, srx, stx, srx_string, stx_string, qso_date_off, band_rx, rst_sent, rst_rcvd, cqz, ituz, dxcc, address, age, cnty, comment, a_index, ant_az, ant_el, ant_path, arrl_sect, checkcontest, class, contacted_op, contest_id, country, credit_submitted, credit_granted, distance, eq_call, email, eqsl_qslrdate, eqsl_qslsdate, eqsl_qsl_rcvd, eqsl_qsl_sent, force_init, freq, freq_rx, gridsquare, my_gridsquare, iota, iota_island_id, my_iota, my_iota_island_id, k_index, lat, lon, my_lat, my_lon, lotw_qslrdate, lotw_qslsdate, lotw_qsl_rcvd, lotw_qsl_sent, clublog_qso_upload_date, clublog_qso_upload_status, max_bursts, ms_shower, my_antenna, my_city, my_cnty, my_country, my_cq_zone, my_name, name, operator, station_callsign, owner_callsign, my_rig, my_sig, my_sig_info, my_sota_ref, my_state, state, my_street, my_vucc_grids, notes, nr_bursts, nr_pings, pfx, precedence, prop_mode, public_key, qslmsg, qslrdate, qslsdate, qsl_rcvd, qsl_sent, qsl_rcvd_via, qsl_sent_via, qsl_via, qso_complete, qso_random, qth, rx_pwr, tx_pwr, sat_mode, sat_name, sfi, sig, sota_ref, swl, ten_ten, vucc_grids, web, lognumber) VALUES (:call, :qso_date, :bandid, :modeid, :srx, :stx, :srx_string, :stx_string, :qso_date_off, :band_rx, :rst_sent, :rst_rcvd, :cqz, :ituz, :dxcc, :address, :age, :cnty, :comment, :a_index, :ant_az, :ant_el, :ant_path, :arrl_sect, :checkcontest, :class, :contacted_op, :contest_id, :country, :credit_submitted, :credit_granted, :distance, :eq_call, :email, :eqsl_qslrdate, :eqsl_qslsdate, :eqsl_qsl_rcvd, :eqsl_qsl_sent, :force_init, :freq, :freq_rx, :gridsquare, :my_gridsquare, :iota, :iota_island_id, :my_iota, :my_iota_island_id, :k_index, :lat, :lon, :my_lat, :my_lon, :lotw_qslrdate, :lotw_qslsdate, :lotw_qsl_rcvd, :lotw_qsl_sent, :clublog_qso_upload_date, :clublog_qso_upload_status, :max_bursts, :ms_shower, :my_antenna, :my_city, :my_cnty, :my_country, :my_cq_zone, :my_name, :name, :operator, :station_callsign, :owner_callsign, :my_rig, :my_sig, :my_sig_info, :my_sota_ref, :my_state, :state, :my_street, :my_vucc_grids, :notes, :nr_bursts, :nr_pings, :pfx, :precedence, :prop_mode, :public_key, :qslmsg, :qslrdate, :qslsdate, :qsl_rcvd, :qsl_sent, :qsl_rcvd_via, :qsl_sent_via, :qsl_via, :qso_complete, :qso_random, :qth, :rx_pwr, :tx_pwr, :sat_mode, :sat_name, :sfi, :sig, :sota_ref, :swl, :ten_ten, :vucc_grids, :web, :lognumber)" ); - - //file.seek(pos); - fields.clear(); - // while ( (!file.atEnd() ) && (!noMoreQso) && (sqlOK)) - //time1.start(); - while ((!noMoreQso) && (sqlOK)) - { - if (!file.atEnd()) - { - line.clear(); - line.append(file.readLine().trimmed().toUpper()); - //line.append(file.readLine().toUpper()); // TODO: Check if we should remove extra spaces,tabs and so on... - //qDebug() << Q_FUNC_INFO << " -line:" << line; - //fields.clear(); //TODO: Check if I should clear fields... I think I should not because I could loose data if a line contains data after an - fields << line.split("<", QT_SKIP); - } - - //TODO: Check what happens - - //qDebug() << Q_FUNC_INFO << " START fields"; - qsToPass.clear(); - auxString.clear(); - foreach (aux, fields) - { - QString fieldToCheck; - fieldToCheck = "<" + aux; - //QStringList _TEST; - //_TEST.clear(); - //_TEST << util->getValidADIFFieldAndData('<'+fields.at(0)); - aux = aux.trimmed(); - if ( (aux.contains('>')) && (auxString.length() > 0) ) - { - //qsToPass << auxString + aux; - qsToPass.last() = qsToPass.last() + auxString; - //qDebug() << Q_FUNC_INFO << " Modified in qsToPass: " << qsToPass.last(); - qsToPass << aux.trimmed(); - //qDebug() << Q_FUNC_INFO << " Added to qsToPass: " << aux.trimmed(); - auxString.clear(); - } - else if (( aux.contains('>')) && (auxString.length() <= 0) ) - { - qsToPass << aux.trimmed(); - } - else - { - auxString = auxString + "-" + aux.trimmed(); - //qDebug() << Q_FUNC_INFO << " auxString: " << auxString; - } - //qDebug() << Q_FUNC_INFO << " fields: " << aux; - } - - //qDebug() << Q_FUNC_INFO << " -W-1"; - - if (auxString.length()>0) - { - //qDebug() << Q_FUNC_INFO << " auxString2: " << auxString; - qsToPass.last() = qsToPass.last() + auxString.trimmed(); - } - - //qDebug() << Q_FUNC_INFO << " END fields"; - //qDebug() << Q_FUNC_INFO << " Mod: " << qsToPass.join("/"); - //qDebug() << Q_FUNC_INFO << " END2 fields"; - - fields = qsToPass; - - if (fields.contains("EOR>")) // We are going to add a QSO to the log... prepare the Query! - { - //qDebug() << Q_FUNC_INFO << " fields contains EOR>"; - preparedQuery.bindValue( ":lognumber", logN); - - while ( (!EOR) && (!fields.isEmpty()) ) - { - //qDebug() << Q_FUNC_INFO << " -W-2"; - fieldToAnalyze = (fields.takeFirst()).trimmed(); - - if ( fieldToAnalyze.contains("EOR>") ) - { - //qDebug() << Q_FUNC_INFO << " -W-2.1"; - currentQSOfields << fieldToAnalyze; - isDupeQSO = processQsoReadingADIF(currentQSOfields, logN); - if (isDupeQSO && (!askedToAddDupeQSOs)) - { - askedToAddDupeQSOs = true; - QMessageBox msgBox; - msgBox.setWindowTitle(tr("KLog - Add new QSOs?")); - QString aux = QString(tr("Do you want to add dupe QSOs to your local log?")); - msgBox.setText(aux); - msgBox.setDetailedText(tr("There are some QSOs in this logfile that may be dupes as they have same call, band & mode and a very close date.")); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::No); - int ret = msgBox.exec(); - switch (ret) - { - case QMessageBox::Yes: - addDupeQSOs = true; - break; - case QMessageBox::No: - addDupeQSOs = false; - break; - default: - // should never be reached - break; - } - //qDebug() << Q_FUNC_INFO << " isDupeQSO = true" ; - } - } - else - { - //qDebug() << Q_FUNC_INFO << " Not contains EOR" ; - - if ((!fieldToAnalyze.contains('>')) && (currentQSOfields.length()>0)) - { - //qDebug() << Q_FUNC_INFO << " Contains > & currentsQSOfields.length>0" ; - auxString = currentQSOfields.at(currentQSOfields.length()-1); - auxString = auxString + "\n" + fieldToAnalyze; - //currentQSOfields.at(currentQSOfields.length()) = auxString; - fieldToAnalyze = auxString; - } - currentQSOfields << fieldToAnalyze; - EOR = false; - } - } - if ((!isDupeQSO) || (addDupeQSOs)) - { - sqlOK = preparedQuery.exec(); - } - else - { - //qDebug() << Q_FUNC_INFO << " DUPE QSO, not adding it"; - } - - //qDebug() << Q_FUNC_INFO << " executedQuery1: " << preparedQuery.executedQuery() ; - //qDebug() << Q_FUNC_INFO << " executedQuery2: " << preparedQuery.executedQuery() ; - //qDebug() << Q_FUNC_INFO << " LastQuery2: " << preparedQuery.lastQuery() ; - - - if (( (i % step ) == 0) ) - { // To update the speed I will only show the progress once each X QSOs - //qDebug() << Q_FUNC_INFO << " MOD 0 - i = " << QString::number(i) ; - //aux = QString(tr("Importing LoTW ADIF file...\n QSO: %1/%2\nImporting speed: 0 QSOs/sec")).arg(i).arg(numberOfQsos); - - aux = tr("Importing ADIF file...") + "\n" + tr(" QSO: ") + QString::number(i) + "/" + QString::number(numberOfQsos); - - progress.setLabelText(aux); - progress.setValue(i); - } - else - { - //qDebug() << Q_FUNC_INFO << " Mod: "<< QString::number(i) << " mod " << QString::number(step) << " = " << QString::number(i % step); - } - - if (sqlOK) - { - //qDebug() << Q_FUNC_INFO << " (1) in While sqlOK (QSO added) = TRUE" ; - } - else - { - //errorCode = preparedQuery.lastError().nativeErrorCode(); - //qDebug() << Q_FUNC_INFO << " QSO DUPE"; - - //qDebug() << Q_FUNC_INFO << " (1) LastQuery: " << preparedQuery.lastQuery() ; - //qDebug() << Q_FUNC_INFO << " (1) LastError-data: " << preparedQuery.lastError().databaseText() ; - //qDebug() << Q_FUNC_INFO << " (1) LastError-driver: " << preparedQuery.lastError().driverText() ; - //qDebug() << Q_FUNC_INFO << " (1) LastError-n: " << QString::number(preparedQuery.lastError().nativeErrorCode() ); - if (((preparedQuery.lastError().nativeErrorCode()).toInt() == 19) && (!ignoreErrorCode19)) - { // There are some repeated QSO - QMessageBox msgBox; - msgBox.setWindowTitle(tr("KLog - Duplicated QSOs")); - aux = tr("It seems that there are some duplicated QSOs in the ADIF file you are importing. Do you want to continue? (Duped QSOs will not be imported)"); - msgBox.setText(aux); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::Yes); - int ret = msgBox.exec(); - switch (ret) { - case QMessageBox::Yes: - // Yes was clicked - //qDebug() << Q_FUNC_INFO << " (1) clicked YES"; - sqlOK = true; - break; - case QMessageBox::YesToAll: - // Yes was clicked - //qDebug() << Q_FUNC_INFO << " (1) clicked YES to ALL"; - ignoreErrorCode19 = true; - sqlOK = true; - break; - case QMessageBox::No: - // No Save was clicked - //qDebug() << Q_FUNC_INFO << " (1) clicked NO"; - sqlOK = false; - break; - default: - // should never be reached - sqlOK = true; - //qDebug() << Q_FUNC_INFO << " (1) default"; - break; - } - //; - } - else if(((preparedQuery.lastError().nativeErrorCode()).toInt() == 19) && (ignoreErrorCode19)) - { - sqlOK = true; - //qDebug() << Q_FUNC_INFO << " errorCode=19 && ignoreErrorCode19"; - } - else - { - //qDebug() << Q_FUNC_INFO << " (2) LastQuery: " << preparedQuery.lastQuery() ; - //qDebug() << Q_FUNC_INFO << " (2) LastError-data: " << preparedQuery.lastError().databaseText() ; - //qDebug() << Q_FUNC_INFO << " (2) LastError-driver: " << preparedQuery.lastError().driverText() ; - //qDebug() << Q_FUNC_INFO << " (2) LastError-n: " << QString::number(preparedQuery.lastError().nativeErrorCode() ); - - emit queryError( Q_FUNC_INFO, preparedQuery.lastError().databaseText(), preparedQuery.lastError().nativeErrorCode(), preparedQuery.lastQuery()); - noMoreQso = true; - } - } - if ( progress.wasCanceled() ) - { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("KLog - User cancelled")); - aux = QString(tr("You have canceled the file import. The file will be removed and no data will be imported.") + "\n" + tr("Do you still want to cancel?")); - msgBox.setText(aux); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::No); - int ret = msgBox.exec(); - switch (ret) { - case QMessageBox::Yes: - // Yes was clicked - noMoreQso = true; - break; - case QMessageBox::No: - // No Save was clicked - break; - default: - // should never be reached - break; - } - } - currentQSOfields.clear(); - queryPreparation(logN); // to clear Values - //progress.setValue(i); - i++; - } // END of if (fields.contains("EOR>")) // We are going to add a QSO to the log... ! - else - { - if (file.atEnd()) - { - noMoreQso = true; - } - //qDebug() << Q_FUNC_INFO << " fields DOES NOT contains EOR>"; - } - //TODO: Check how to stop the importing process - } // END OF WHILE - - if (noMoreQso) - { - //qDebug() << Q_FUNC_INFO << " noMoreQso = true"; - progress.setValue(numberOfQsos); - } - else - { - //qDebug() << Q_FUNC_INFO << " noMoreQso = false"; - } - if (sqlOK) - { - //qDebug() << Q_FUNC_INFO << " sqlOK = true"; - } - else - { - //qDebug() << Q_FUNC_INFO << " sqlOK = false"; - } - - if (sqlOK) - { - /* - if (db.commit()) - { - //qDebug() << Q_FUNC_INFO << " Last commit OK" ; + } + //qDebug() << Q_FUNC_INFO << QString(": Field process finished: ").arg(fieldToAnalyze) ; } - else - { - errorCode = preparedQuery.lastError().nativeErrorCode(); - QMessageBox msgBox; - aux = tr("An error ocurred while importing. No data will be imported. Please send this code to the developer for analysis: "); - msgBox.setText(aux + "FM-3 #" + QString::number(errorCode)); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); + //qDebug() << Q_FUNC_INFO << QString(": List of fields is empty!") ; + } + //qDebug() << Q_FUNC_INFO << QString(": End of File or no more QSOs") ; + file.close (); + progress.setValue(qsos); // Closes the progressDialog - int ret = msgBox.exec(); - switch (ret) { - case QMessageBox::Ok: - // Yes was clicked - sqlOK = false; - //qDebug() << Q_FUNC_INFO << " I have just set sqlOK=False (5)"; - break; - default: - // should never be reached - sqlOK = false; - //qDebug() << Q_FUNC_INFO << " I have just set sqlOK=False (6)"; - break; - } + //qDebug() << Q_FUNC_INFO << " - END"; + return true; +} - if (db.rollback()) - {} - else - { - //TODO: Check the error if db.rollback returns false - } - } - */ +qint64 FileManager::passHeader(QFile & _f) +{ + //qDebug() << Q_FUNC_INFO << " - Start: " << _f.fileName (); + QFile &file = _f; + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) /* Flawfinder: ignore */ + { + //qDebug() << Q_FUNC_INFO << " File not found" ; + return false; } - else + //bool hasEOH = false; + qint64 pos = file.pos(); + QString line; + while ( !file.atEnd() ) { - //qDebug() << Q_FUNC_INFO << " sqlOK = NOK" ; + line = file.readLine ().toUpper (); + //qDebug() << Q_FUNC_INFO << " - " << line; + if (line.count ("")>0) + { + break; + } } - progress.setValue(numberOfQsos); - //qDebug() << Q_FUNC_INFO << " END " ; - return true; + pos = file.pos(); + file.close (); + //qDebug() << Q_FUNC_INFO << " - END (" << QString::number(pos) << ")"; + return pos; } QHash FileManager::SwitchHash; @@ -2406,1063 +1427,6 @@ void FileManager::initializeSwitchHash() { {"APP_KLOG_LOGN", 138}, {"APP_N1MM_POINTS", 139} }; - -} - -bool FileManager::processQsoReadingADIF(const QStringList &_line, const int logNumber) //, const bool _keepLogsInFile) -//bool FileManager::processQsoReadingADIF(const QStringList _line, const int logNumber, const bool _keepLogsInFile, QHash &_logs) -{ - //qDebug() << "FileManager::processQsoReadingADIF: log: " << QString::number(logNumber); - //qDebug() << "FileManager::processQsoReadingADIF: log: " << _line.at(0); - //qDebug() << "FileManager::processQsoReadingADIF: " << _line.join("/"); - - //QHash &hashLogs = _logs; - - //QFile &file = _f; - - //bool keepLogsInF;// = _keepLogsInFile; //TODO: Check if needed or remove it completely. This line is just to remove a warning - int i = -1; - QDate date, dateT; - date = QDate(); - dateT = QDate(); - QTime time; - QDateTime dateTime, dateTimeOFF; - dateTime = QDateTime(); - QStringList qs = _line; - QStringList oneField; - QString field, data; - QSqlQuery query; - - if (SwitchHash.empty()) initializeSwitchHash(); - - //confirmed = 0; // 0 means worked, 1 means confirmed - - //QString queryString, stringFields, stringData; - - QString aux; // Aux string - QString aux2; - QString qrzCall = QString(); - QString submode = QString(); - QString defaultRSTTX = util->getDefaultRST(QString()); - QString defaultRSTRX = util->getDefaultRST(QString()); - - bool isDupeQSO = false; - int modei = -1; - int bandi = -1; - int bandrxi = -1; - bool rstRXr = false; - bool rstTXr = false; - - //KLog does not understand (and will not import) a QSO without these fields - bool haveCall = false; - //QString wrongCall = QString(); - bool haveBand = false; - bool bandRXDef = false; - bool haveMode = false; - bool haveSubMode = false; - bool haveTime = false; - bool haveDate = false; - bool haveTimeOff = false; - bool haveDateOff = false; - - bool haveFreqTX = false; - bool haveFreqRX = false; - bool hasStationCall = false; - bool hasLotwQslSent = false; - bool hasEqslQslSent = false; - bool hasQrzQslSent = false; - bool hasClublogQslSent = false; - QString freqTX = QString(); - - //bool ret; - //int length = 0; - //int currentLog = logNumber; - - //qDebug() << "FileManager::processQsoReadingADIF" << QString::number(qs.size()) << "/" << QString::number(logNumber); - //TODO: To remove the next line, it was just to measure the time it takes. - ignoreUnknownAlways = true; - QString str; - //preparedQuery.bindValue( ":confirmed", '0' ); - - //qDebug() << "FileManager::processQsoReadingADIF: Entering the foreach"; - foreach (str, qs) - { - //qDebug() << "FileManager::processQsoReadingADIF: " << str; - if ( !( (str.contains(":")) && (str.contains(">")) ) ) - { - //qDebug() << "FileManager::processQsoReadingADIF: NOT (contains : and >): " << str; - } - else - { - //qDebug() << "FileManager::processQsoReadingADIF: (contains : and >): " << str; - - oneField = str.split(">", QT_SKIP); - - //qDebug() << "FileManager::processQsoReadingADIF: (oneField)" << oneField; - if (checkADIFValidFormat(oneField)) - { - i = (qs.at(0)).count(":"); - field = (oneField.at(0)).trimmed(); // Needs to be cleared FIELD:4:D - data = (oneField.at(1)).trimmed(); - data = util->checkAndFixASCIIinADIF(data); - //qDebug() << "FileManager::processQsoReadingADIF: field/data" << field << "/" << data; - - if (i == 2) - { // DATE:8:D / 20141020 - //length = (field.section(':', 1, 1)).toInt(); - field = field.section(':', 0, 0); - } - else if (i == 1) - { // DATE:8 / 20141020 - //length = (field.section(':', 1, 1)).toInt(); - field = field.section(':', 0, 0); - } - else - { - //qDebug() << "FileManager::checkADIFValidFormat-1 "; - //return false; - } - - //field = oneField.at(0).trimmed(); - //data = oneField.at(1).trimmed(); - - //length = field.indexOf(":"); - //field = field.left(length); - //qDebug() << "FileManager::processQsoReadingADIF (field/data): " << field << "/" << data; - if (SwitchHash.find(field) != SwitchHash.end()) { - switch (SwitchHash[field]) { - case(1): - //qDebug() << "FileManager::processQsoReadingADIF-CALL:" << data; - qrzCall = data; - haveCall = util->isValidCall(qrzCall); - if (haveCall) - { - //qDebug() << "FileManager::processQsoReadingADIF-CALL: Have CALL!!" ; - preparedQuery.bindValue(":call", qrzCall); - } - //qDebug() << "FileManager::processQsoReadingADIF-CALL-END:" << data; - break; - case(2): - //qDebug() << "FileManager::processQsoReadingADIF-QSO_DATE:" << data; - dateT = util->getDateFromADIFDateString(data); - if (dateT.isValid()) - { - dateTime.setDate(dateT); - haveDate = true; - } - else { - //qDebug() << "FileManager::processQsoReadingADIF QSO_DATE is NOT VALID: " << data; - } - break; - case(3): - - //preparedQuery.bindValue( ":bandid", data ); - i = dataProxy->getIdFromBandName(data); - //i = db->getBandIDFromName2(data); - if (i >= 0) - { - preparedQuery.bindValue(":bandid", QString::number(i)); - haveBand = true; - bandi = i; - - //qDebug() << "FileManager::processQsoReadingADIF-Band: " << data << "/" << QString::number(i); - } - else - { - //qDebug() << "FileManager::processQsoReadingADIF-Band - Wrong band: " << data << "/" << QString::number(i); - } - /* - queryString = QString("SELECT id FROM band WHERE name ='%1'").arg(data); - query.exec(queryString); - query.next(); - if (query.isValid()) - { - preparedQuery.bindValue( ":bandid", query.value(0).toInt() ); - - //qDebug() << "FileManager::bprocessQsoReadingADIF-Band: " << data; - } - */ - break; - case(4): - modei = dataProxy->getSubModeIdFromSubMode(data); - // get modeid - if (modei >= 0) - { - { - if (!haveSubMode) - { - preparedQuery.bindValue(":modeid", QString::number(modei)); - haveMode = true; - haveSubMode = true; - submode = dataProxy->getSubModeFromId(modei); - } - } - } - break; - case(5): - modei = dataProxy->getSubModeIdFromSubMode(data); - if (modei >= 0) - { - preparedQuery.bindValue(":modeid", QString::number(modei)); - preparedQuery.bindValue(":submode", QString::number(modei)); - haveSubMode = true; - haveMode = true; - submode = data; - //submode = data; - } - break; - case(6): - preparedQuery.bindValue(":srx", data); - - //qDebug() << "FileManager::bprocessQsoReadingADIF-srx: " << data; - break; - case(7): - preparedQuery.bindValue(":stx", data); - - //qDebug() << "FileManager::bprocessQsoReadingADIF-stx: " << data; - break; - case(8): - time = util->getTimeFromADIFTimeString(data); - - if (time.isValid()) - { - dateTime.setTime(time); - haveTime = true; - } - break; - case(9): - dateT = util->getDateFromADIFDateString(data); - if (dateT.isValid()) - { - dateTimeOFF.setDate(dateT); - haveDateOff = true; - } - break; - case(10): - i = dataProxy->getIdFromBandName(data); - - //i = db->getBandIDFromName2(data); - if (i >= 0) - { - preparedQuery.bindValue(":band_rx", QString::number(i)); - bandRXDef = true; - bandrxi = i; - } - break; - case(11): - time = util->getTimeFromADIFTimeString(data); - if (time.isValid()) - { - dateTimeOFF.setTime(time); - haveTimeOff = true; - } - break; - case(12): - preparedQuery.bindValue(":rst_sent", data); - - //qDebug() << "FileManager::bprocessQsoReadingADIF-rst_rsent: " << data; - rstTXr = true; - break; - case(13): - - //qDebug() << "FileManager::bprocessQsoReadingADIF-rst_rcvd: " << data; - preparedQuery.bindValue(":rst_rcvd", data); - rstRXr = true; - break; - case(14): - preparedQuery.bindValue(":srx_string", data); - break; - case(15): - preparedQuery.bindValue(":stx_string", data); - break; - case(16): - preparedQuery.bindValue(":cqz", data); - - //cqz = data.toInt(); - break; - case(17): - preparedQuery.bindValue(":ituz", data); - - //ituz = data.toInt(); - break; - case(18): - - //dxcc = data.toInt(); - preparedQuery.bindValue(":dxcc", data); - break; - case(19): - preparedQuery.bindValue(":address", data); - break; - case(20): - preparedQuery.bindValue(":age", data); - break; - case(21): - preparedQuery.bindValue(":cnty", data); - break; - case(22): - preparedQuery.bindValue(":comment", data); - break; - case(23): - preparedQuery.bindValue(":a_index", data); - break; - case(24): - preparedQuery.bindValue(":ant_az", data); - break; - case(25): - preparedQuery.bindValue(":ant_el", data); - break; - case(26): - preparedQuery.bindValue(":ant_path", data); - break; - case(27): - preparedQuery.bindValue(":arrl_sect", data); - break; - case(28): - preparedQuery.bindValue(":award_granted", data); - break; - case(29): - preparedQuery.bindValue(":award_submitted", data); - break; - case(30): - preparedQuery.bindValue(":checkcontest", data); - break; - case(31): - preparedQuery.bindValue(":class", data); - break; - case(32): - preparedQuery.bindValue(":cont", data); - break; - case(33): - preparedQuery.bindValue(":contacted_op", data); - break; - case(34): - preparedQuery.bindValue(":contest_id", data); - break; - case(35): - preparedQuery.bindValue(":country", data); - break; - case(36): - preparedQuery.bindValue(":credit_submitted", data); - break; - case(37): - preparedQuery.bindValue(":credit_granted", data); - break; - case(38): - preparedQuery.bindValue(":distance", data); - break; - case(39): - preparedQuery.bindValue(":darc_dok", data); - break; - case(40): - preparedQuery.bindValue(":eq_call", data); - break; - case(41): - if (data.contains("@") && (data.contains("."))) - { - preparedQuery.bindValue(":email", data); - } - break; - case(42): - dateT = util->getDateFromADIFDateString(data); - if (dateT.isValid()) - { - preparedQuery.bindValue(":eqsl_qslrdate", util->getDateSQLiteStringFromDate(dateT)); - } - break; - case(43): - dateT = util->getDateFromADIFDateString(data); - if (dateT.isValid()) - { - preparedQuery.bindValue(":eqsl_qslsdate", util->getDateSQLiteStringFromDate(dateT)); - } - break; - case(44): - preparedQuery.bindValue(":eqsl_qsl_rcvd", data); - break; - case(45): - preparedQuery.bindValue(":eqsl_qsl_sent", data); - hasEqslQslSent = true; - break; - case(46): - preparedQuery.bindValue(":fists", data); - break; - case(47): - preparedQuery.bindValue(":fists_cc", data); - break; - case(48): - preparedQuery.bindValue(":force_init", data); - break; - case(49): - - //qDebug() << "FileManager::processQsoReadingADIF -FREQ: " << QString::number(data.toDouble()); - if (haveBand) - { - if (dataProxy->getBandIdFromFreq(data.toDouble()) == bandi) - - //if (db->isThisFreqInBand(db->getBandNameFromNumber(bandi), data)) - { - preparedQuery.bindValue(":freq", data); - haveFreqTX = true; - freqTX = data; - } - else - { - - // IF band is defined but not the same than freq, Band wins - } - } - else - { - preparedQuery.bindValue(":freq", data); - haveFreqTX = true; - freqTX = data; - i = dataProxy->getBandIdFromFreq(data.toDouble()); - - if (i >= 0) - { - preparedQuery.bindValue(":bandid", QString::number(i)); - haveBand = true; - - //qDebug() << "FileManager::processQsoReadingADIF-Band: " << data << "/" << QString::number(i); - } - } - break; - case(50): - if (bandRXDef) - { - if (dataProxy->getBandIdFromFreq(data.toDouble()) == bandrxi) - { - preparedQuery.bindValue(":freq_rx", data); - haveFreqRX = true; - } - else - { - - // IF band is defined but not the same than freq, Band wins - } - } - else - { - preparedQuery.bindValue(":freq_rx", data); - haveFreqRX = true; - i = dataProxy->getBandIdFromFreq(data.toDouble()); - - if (i >= 0) - { - preparedQuery.bindValue(":band_rx", QString::number(i)); - bandRXDef = true; - - //qDebug() << "FileManager::processQsoReadingADIF-Band: " << data << "/" << QString::number(i); - } - } - break; - case(51): - preparedQuery.bindValue(":gridsquare", data); - break; - case(53): - dateT = util->getDateFromADIFDateString(data); - if (dateT.isValid()) - { - preparedQuery.bindValue(":hrd_qso_upload_date", util->getDateSQLiteStringFromDate(dateT)); - } - break; - case(54): - preparedQuery.bindValue(":hrd_qso_upload_status", data); - break; - case(55): - //TODO: if data is NULL or empty, ask for my_gridsquare - preparedQuery.bindValue(":my_gridsquare", data); - break; - case(56): - - //qDebug() << ": MY_ANTENNA: " << data; - preparedQuery.bindValue(":my_antenna", data); - break; - case(57): - - //qDebug() << "FileManager::processQsoReadingADIF (IOTA): " << data; - data = awards->checkIfValidIOTA(data); - /* - if (data.length()==4) - //EU-1 - { - data.insert(3, "00"); - } - else if (data.length()==5) - //EU-01 - { - data.insert(3, "0"); - } - */ - if (data.length() == 6) - { - preparedQuery.bindValue(":iota", data); - } - break; - case(58): - preparedQuery.bindValue(":iota_island_id", data); - break; - case(59): - /* - if (data.length()==4) - //EU-1 - { - data.insert(3, "00"); - } - else if (data.length()==5) - //EU-01 - { - data.insert(3, "0"); - } - */ - data = awards->checkIfValidIOTA(data); - if (data.length() == 6) - { - preparedQuery.bindValue(":my_iota", data); - } - break; - case(60): - preparedQuery.bindValue(":my_dxcc", data); - break; - case(61): - preparedQuery.bindValue(":my_fists", data); - break; - case(62): - preparedQuery.bindValue(":my_iota_island_id", data); - break; - case(63): - preparedQuery.bindValue(":k_index", data); - break; - case(64): - preparedQuery.bindValue(":lat", data); - break; - case(65): - preparedQuery.bindValue(":lon", data); - break; - case(66): - preparedQuery.bindValue(":my_lat", data); - break; - case(67): - preparedQuery.bindValue(":my_lon", data); - break; - case(68): - preparedQuery.bindValue(":my_itu_zone", data); - break; - case(69): - preparedQuery.bindValue(":my_postal_code", data); - break; - case(70): - dateT = util->getDateFromADIFDateString(data); - if (dateT.isValid()) - { - preparedQuery.bindValue(":lotw_qslrdate", util->getDateSQLiteStringFromDate(dateT)); - } - break; - case(71): - dateT = util->getDateFromADIFDateString(data); - if (dateT.isValid()) - { - preparedQuery.bindValue(":lotw_qslsdate", util->getDateSQLiteStringFromDate(dateT)); - } - break; - case(72): - preparedQuery.bindValue(":lotw_qsl_rcvd", data); - break; - case(73): - preparedQuery.bindValue(":lotw_qsl_sent", data); - hasLotwQslSent = true; - break; - case(74): - dateT = util->getDateFromADIFDateString(data); - if (dateT.isValid()) - { - preparedQuery.bindValue(":clublog_qso_upload_date", util->getDateSQLiteStringFromDate(dateT)); - hasClublogQslSent = true; - } - break; - case(75): - preparedQuery.bindValue(":clublog_qso_upload_status", data); - break; - case(76): - preparedQuery.bindValue(":max_bursts", data); - break; - case(77): - preparedQuery.bindValue(":ms_shower", data); - break; - case(78): - preparedQuery.bindValue(":my_city", data); - break; - case(79): - preparedQuery.bindValue(":my_cnty", data); - break; - case(80): - preparedQuery.bindValue(":my_country", data); - break; - case(81): - preparedQuery.bindValue(":my_cq_zone", data); - break; - case(82): - preparedQuery.bindValue(":my_name", data); - break; - case(83): - preparedQuery.bindValue(":name", data); - break; - case(84): - if (util->isValidCall(data)) - { - preparedQuery.bindValue(":operator", data); - } - break; - case(85): - if (util->isValidCall(data)) - { - hasStationCall = true; - preparedQuery.bindValue(":station_callsign", data); - } - break; - case(86): - if (util->isValidCall(data)) - { - preparedQuery.bindValue(":owner_callsign", data); - } - break; - case(87): - preparedQuery.bindValue(":my_rig", data); - break; - case(88): - preparedQuery.bindValue(":my_sig", data); - break; - case(89): - preparedQuery.bindValue(":my_sig_info", data); - break; - case(90): - preparedQuery.bindValue(":my_sota_ref", data); - break; - case(91): - preparedQuery.bindValue(":my_state", data); - break; - case(92): - preparedQuery.bindValue(":state", data); - break; - case(93): - preparedQuery.bindValue(":my_street", data); - break; - case(94): - preparedQuery.bindValue(":my_usaca_counties", data); - break; - case(95): - preparedQuery.bindValue(":my_vucc_grids", data); - break; - case(96): - preparedQuery.bindValue(":notes", data); - break; - case(97): - preparedQuery.bindValue(":nr_bursts", data); - break; - case(98): - preparedQuery.bindValue(":nr_pings", data); - break; - case(99): - preparedQuery.bindValue(":pfx", data); - break; - case(100): - preparedQuery.bindValue(":precedence", data); - break; - case(101): - preparedQuery.bindValue(":prop_mode", data); - break; - case(102): - preparedQuery.bindValue(":public_key", data); - break; - case(103): - dateT = util->getDateFromADIFDateString(data); - if (dateT.isValid()) - { - preparedQuery.bindValue(":qrzcom_qso_upload_date", util->getDateSQLiteStringFromDate(dateT)); - hasQrzQslSent = true; - } - break; - case(104): - preparedQuery.bindValue(":qrzcom_qso_upload_status", data); - break; - case(105): - preparedQuery.bindValue(":qslmsg", data); - break; - case(106): - dateT = util->getDateFromADIFDateString(data); - if (dateT.isValid()) - { - preparedQuery.bindValue(":qslrdate", util->getDateSQLiteStringFromDate(dateT)); - } - break; - case(107): - dateT = util->getDateFromADIFDateString(data); - if (dateT.isValid()) - { - preparedQuery.bindValue(":qslsdate", util->getDateSQLiteStringFromDate(dateT)); - } - break; - case(108): - preparedQuery.bindValue(":qsl_rcvd", data); - - //preparedQuery.bindValue( ":confirmed", '1' ); - break; - case(109): - preparedQuery.bindValue(":qsl_sent", data); - break; - case(110): - preparedQuery.bindValue(":qsl_rcvd_via", data); - break; - case(111): - preparedQuery.bindValue(":qsl_sent_via", data); - break; - case(112): - - //qDebug() << "FileManager::bprocessQsoReadingADIF-QSL_VIA: " << data; - if (data == "BUREAU") - // This comprobation is to "correct" old logs, mainly from KLog - - // comming from older ADIF files - { - preparedQuery.bindValue(":qsl_sent_via", "B"); - } - else if ((data == "B") || (data == "D") || (data == "E")) - // M Deprecated value from ADIF 304 - { - preparedQuery.bindValue(":qsl_via", data); - } - else - { - - // If values are not valid, are not imported. - - //TODO: Send an error to the user to show that there was an invalid field - } - break; - case(113): - //preparedQuery.bindValue(":qso_complete", data); - preparedQuery.bindValue(":qso_complete", util->getQSO_CompleteFromADIF(data)); - break; - case(114): - preparedQuery.bindValue(":qso_random", data); - break; - case(115): - preparedQuery.bindValue(":qth", data); - break; - case(116): - preparedQuery.bindValue(":region", data); - break; - case(117): - preparedQuery.bindValue(":rig", data); - break; - case(118): - - //qDebug() << "FileManager::bprocessQsoReadingADIF-rx_pwr: " << data; - preparedQuery.bindValue(":rx_pwr", data); - break; - case(119): - - //qDebug() << "FileManager::bprocessQsoReadingADIF-tx_pwr: " << data; - preparedQuery.bindValue(":tx_pwr", data); - break; - case(120): - preparedQuery.bindValue(":sat_mode", data); - break; - case(121): - preparedQuery.bindValue(":sat_name", data); - break; - case(122): - preparedQuery.bindValue(":sfi", data); - break; - case(123): - preparedQuery.bindValue(":sig", data); - break; - case(124): - preparedQuery.bindValue(":sig_info", data); - break; - case(125): - preparedQuery.bindValue(":silent_key", data); - break; - case(126): - preparedQuery.bindValue(":skcc", data); - break; - case(127): - preparedQuery.bindValue(":sota_ref", data); - break; - case(128): - preparedQuery.bindValue(":swl", data); - break; - case(129): - preparedQuery.bindValue(":ten_ten", data); - break; - case(130): - preparedQuery.bindValue(":uksmg", data); - break; - case(131): - preparedQuery.bindValue(":usaca_counties", data); - break; - case(132): - preparedQuery.bindValue(":ve_prov", data); - break; - case(133): - preparedQuery.bindValue(":vucc_grids", data); - break; - case(134): - preparedQuery.bindValue(":web", data); - break; - case(138): //Lognumber in a multiple-log file - - //TODO: Think about how to import a file with different logs - - //isThisQSODuplicated(const QString &_qrz, const QString &_date, const QString &_time, const int _band, const int _mode) - break; - case(139): //Importing from N1MM - preparedQuery.bindValue(":points", data); - break; - } - } - } - else - { - //qDebug() << "FileManager::processQsoReadingADIF (field) CheckAdif FALSE: " << field; - } - } - } - - if (sendEQSLByDefault) - { - if (!hasLotwQslSent) - { - preparedQuery.bindValue( ":lotw_qsl_sent","Q"); - } - - if (!hasEqslQslSent) - { - preparedQuery.bindValue( ":eqsl_qsl_sent","Q"); - } - if (!hasClublogQslSent) - { - preparedQuery.bindValue( ":clublog_qso_upload_status","M"); - } - - if (!hasQrzQslSent) - { - preparedQuery.bindValue( ":qrzcom_qso_upload_status","M"); - } - } - - if ( haveCall && haveDate && haveTime && haveBand && haveMode) - { - QList _dupeQSOs; - _dupeQSOs.clear(); - _dupeQSOs << dataProxy->isThisQSODuplicated(Q_FUNC_INFO, qrzCall, dateTime, bandi, modei, duplicatedQSOSlotInSecs); - if (_dupeQSOs.length()>0) - { - isDupeQSO = true; - } - //QList DataProxy_SQLite::isThisQSODuplicated(const QString &_qrz, const QDateTime &_dateTime, const int _band, const int _mode, const int _secs) - } - - if ( (haveDate) && (haveTime)) - { - preparedQuery.bindValue( ":qso_date", util->getDateTimeSQLiteStringFromDateTime(dateTime)); - //preparedQuery.bindValue( ":time_on", dateTime.toString("hhmmss")); - } - - if ( (haveDateOff) && (haveTimeOff)) - { - preparedQuery.bindValue( ":qso_date_off", util->getDateTimeSQLiteStringFromDateTime(dateTimeOFF)); - } - if ((haveBand) && (!haveFreqTX)) - { - preparedQuery.bindValue( ":freq", dataProxy->getFreqFromBandId(bandi)); - } - if ((bandRXDef) && (!haveFreqRX)) - { - preparedQuery.bindValue( ":freq_rx", dataProxy->getFreqFromBandId(bandrxi)); - } - if ((haveFreqTX) && (!haveFreqRX)) - { - preparedQuery.bindValue( ":freq_rx", freqTX); - } - if (!haveCall) - { - QString text = util->getAValidCall(qrzCall); - if (!(util->isValidCall(text))) - { - haveCall = true; - qrzCall = text; - } - else - { - qrzCall = QString(); - haveCall = false; - } - } - if (!(haveBand && haveMode && haveTime && haveDate )) - { - //qDebug() << "FileManager::processQsoReadingADIF (Don't have all mandatory fields): "; - aux2 = tr ("This QSO is not including the minimum data to consider a QSO as valid!") + "\n\n\n" + tr("Please edit the ADIF file and make sure that it include at least:") + "\n\nCALL, QSO_DATE, TIME_ON, BAND "+ tr("and") +" MODE.\n\n" + tr("This QSO had:") + "\n"; - if (!haveBand) - { - aux2 = aux2 + tr(" - The band missing and the following call: ") + qrzCall + ".\n"; - } - if (!haveMode) - { - aux2 = aux2 + tr(" - The mode missing and the following call: ") + qrzCall + ".\n"; - } - if (!haveDate) - { - aux2 = aux2 + tr(" - The date missing and the following call: ") + qrzCall + ".\n"; - } - if (!haveTime) - { - aux2 = aux2 + tr(" - The time missing and the following call: ") + qrzCall + ".\n"; - } - aux2 = aux2 + "\n\n" + tr("Do you want to continue with the current file?"); - //qDebug() << "FileManager::processQsoReadingADIF - Missing fields: " << aux2; - - QMessageBox msgBox; - msgBox.setWindowTitle(tr("KLog: Not all required data found!")); - msgBox.setText(aux2); - msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::Cancel); - msgBox.setDefaultButton(QMessageBox::Cancel); - msgBox.setIcon(QMessageBox::Warning); - int ret = msgBox.exec(); - switch (ret) - { - case QMessageBox::Yes: - // Yes was clicked - break; - case QMessageBox::Cancel: - noMoreQso = true; - break; - default: - // should never be reached - break; - } - } - - if ((!rstTXr) && (!rstTXDefault)) - { - //submode = dataProxy->getSubModeFromId(i); - defaultRSTTX = util->getDefaultRST(submode); - QMessageBox msgBox; - aux = tr("Some QSOs of this log, (i.e.: %1) seems to lack RST-TX information.").arg(qrzCall) + "\n\n" + tr("Click on Yes to add a default %1 for mode %2 to all QSOs with a similar problem.").arg(defaultRSTTX).arg(submode) + "\n\n" + tr("If you select NO, maybe the QSO will not be imported."); - msgBox.setWindowTitle(tr("KLog: No RST TX found!")); - msgBox.setText(aux); - msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::Yes); - msgBox.setIcon(QMessageBox::Warning); - int ret = msgBox.exec(); - switch (ret) { - case QMessageBox::Yes: - // Yes was clicked - rstTXDefault = true; - break; - default: - // should never be reached - rstTXDefault = false; - break; - } - } - if ((!rstRXr) && (!rstRXDefault)) - { - defaultRSTRX = util->getDefaultRST(submode); - QMessageBox msgBox; - //aux = tr("Some QSOs of this log, (i.e.: %1) seems to lack RST-RX information.").arg(qrzCall) + "\n\n" + tr("Click on Yes to add a default 59 to all QSO with a similar problem.") + "\n\n" + tr("If you select NO, the QSO may not be imported."); - aux = tr("Some QSOs of this log, (i.e.: %1) seems to lack RST-RX information.").arg(qrzCall) + "\n\n" + tr("Click on Yes to add a default %1 for mode %2 to all QSOs with a similar problem.").arg(defaultRSTRX).arg(submode) + "\n\n" + tr("If you select NO, maybe the QSO will not be imported."); - msgBox.setText(aux); - msgBox.setWindowTitle(tr("KLog: No RST RX found!")); - msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::Yes); - msgBox.setIcon(QMessageBox::Warning); - int ret = msgBox.exec(); - switch (ret) { - case QMessageBox::Yes: - // Yes was clicked - rstRXDefault = true; - break; - default: - // should never be reached - rstRXDefault = false; - break; - } - } - - if ((!rstTXr) && (rstTXDefault)) - { - preparedQuery.bindValue( ":rst_sent", defaultRSTTX ); - } - - if ((!rstRXr) && (rstRXDefault)) - { - preparedQuery.bindValue( ":rst_rcvd", defaultRSTRX ); - } - - if ((!hasStationCall) ) - { - if (!usePreviousStationCallsignAnswerAlways) - { - QMessageBox msgBox; - if(getStationCallsignFromUser(qrzCall, dateTime.date())) - { - hasStationCall = true; - } - else - { - msgBox.setWindowTitle(tr("KLog - No Station callsign entered.")); - msgBox.setIcon(QMessageBox::Warning); - msgBox.setText("KLog - No Station callsign entered."); - msgBox.setInformativeText("Not entering a valid Station Callsign may create problems in some ocasions, like when uploading data to LoTW.\n\n Do you want to try again?"); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::Yes); - int ret = msgBox.exec(); - if (ret == QMessageBox::Yes) - { - if (!getStationCallsignFromUser(qrzCall, dateTime.date())) - { - msgBox.setWindowTitle(tr("KLog - No Station callsign entered.")); - msgBox.setIcon(QMessageBox::Warning); - msgBox.setText("KLog - No Station callsign entered."); - msgBox.setInformativeText("No valid station callsign to add to the QSO."); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.exec(); - } - else - { - hasStationCall = true; - } - } - } - - msgBox.setWindowTitle(tr("KLog - Apply to all QSOs in this log?")); - msgBox.setIcon(QMessageBox::Question); - msgBox.setText("KLog - Do you want to use the same answer for all the QSOs in this log?"); - msgBox.setInformativeText("KLog can use the same answer that you provided to all the QSOs in this logfile when importing it."); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::Yes); - int ret = msgBox.exec(); - if (ret == QMessageBox::Yes) - { - usePreviousStationCallsignAnswerAlways = true; - } - else - { - usePreviousStationCallsignAnswerAlways = false; - } - } - //qDebug() << "FileManager::processQsoReadingADIF defaultStationCallsign: " << defaultStationCallsign; - - if ((hasStationCall) || (util->isValidCall(defaultStationCallsign))) - { - preparedQuery.bindValue( ":station_callsign", defaultStationCallsign ); - } - } - - preparedQuery.bindValue( ":lognumber", QString::number(logNumber)); - return isDupeQSO; } bool FileManager::getStationCallsignFromUser(const QString &_qrzDX, const QDate &_dt) diff --git a/src/filemanager.h b/src/filemanager.h index 99676e81..da7542da 100644 --- a/src/filemanager.h +++ b/src/filemanager.h @@ -69,10 +69,9 @@ class FileManager : public QWidget ~FileManager(); void init(); //bool readAdif(const QString& tfileName, const int logN); - bool adifReadLog(const QString& tfileName, const int logN); + //bool adifReadLog(const QString& tfileName, const int logN); bool adifReadLog2(const QString& tfileName, const int logN); QList adifLoTWReadLog2(const QString& fileName, const int logN); - QList adifLoTWReadLog(const QString& tfileName, const int logN); //QList adifLoTWLogExport(const QString& _fileName, const QString &_callsign, const QDate &_startDate, const QDate &_endDate, const int _logN); //QList (const QString& _fileName, const QString &_callsign, const QDate &_startDate, const QDate &_endDate, const int _logN, const bool LoTWOnly); @@ -114,7 +113,7 @@ class FileManager : public QWidget //QString checkAndFixASCIIinADIF(_data); - bool processQsoReadingADIF(const QStringList &_line, const int logNumber);//, const bool _keepLogsInFile); + //bool processQsoReadingADIF(const QStringList &_line, const int logNumber);//, const bool _keepLogsInFile); void queryPreparation(const int _logN); bool checkADIFValidFormat(const QStringList &_qs); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ab5fa3c6..4d1db075 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2738,7 +2738,6 @@ void MainWindow::slotLoTWDownloadedFileProcess(const QString &_fn) msgBox.setInformativeText(aux); msgBox.exec(); } - //filemanager->adifLoTWReadLog(_fn); logEvent(Q_FUNC_INFO, "END", Debug); } @@ -5187,19 +5186,19 @@ void MainWindow::showDXMarathonNeeded(const int _dxcc, const int _cqz, const int void MainWindow::slotShowAwards() { //To be called from the logWindow & searchWidget - qDebug() << Q_FUNC_INFO; + //qDebug() << Q_FUNC_INFO; logEvent(Q_FUNC_INFO, "Start", Debug); awards->recalculateAwards(); - qDebug() << Q_FUNC_INFO << " - 1"; + //qDebug() << Q_FUNC_INFO << " - 1"; //logWindow->refresh(); - qDebug() << Q_FUNC_INFO << " - 2"; + //qDebug() << Q_FUNC_INFO << " - 2"; awardsWidget->showAwards(); - qDebug() << Q_FUNC_INFO << " - 3"; + //qDebug() << Q_FUNC_INFO << " - 3"; //dxccStatusWidget->refresh(); setMainWindowTitle(); logEvent(Q_FUNC_INFO, "END", Debug); - qDebug() << Q_FUNC_INFO << " - END"; + //qDebug() << Q_FUNC_INFO << " - END"; } void MainWindow::fillQSOData()